

    function initialize() {
      var basis_url = ""; // "http://fydee-noordholland.nl";
      var provincie = new GLatLng(52.567419,4.820023);
      var basis_zoom = 9;
      var kantoor_zoom = 15;
      var cur_zoom = basis_zoom;
      var basis_map_type = G_PHYSICAL_MAP; // G_PHYSICAL_MAP - G_MAPMAKER_NORMAL_MAP;
      var zoom_map_type = G_NORMAL_MAP;
      var geocoder = null;

      var returnGeom = '52.32753,4.49389,0|52.37132,4.52362,0|52.42411,4.55658,0|52.45425,4.55795,0|52.49440,4.58679,0|52.64215,4.62250,0|52.75284,4.64859,0|52.82426,4.68704,0|52.86739,4.70490,0|52.89639,4.71451,0|52.93780,4.71451,0|52.95848,4.72275,0|52.96758,4.77905,0|52.95766,4.80240,0|52.93862,4.79416,0|52.91130,4.79965,0|52.86159,4.92737,0|52.87816,4.93011,0|52.89142,4.90952,0|52.92290,4.95758,0|52.94028,5.02350,0|52.84749,5.11963,0|52.76863,5.10864,0|52.73704,5.18005,0|52.75533,5.19379,0|52.74619,5.27618,0|52.72789,5.29266,0|52.69711,5.29816,0|52.68046,5.24872,0|52.65048,5.23499,0|52.61881,5.15533,0|52.61797,5.12375,0|52.63548,5.07843,0|52.63881,5.04547,0|52.62464,5.01663,0|52.55373,5.04684,0|52.49691,5.08804,0|52.47768,5.05646,0|52.46346,5.07294,0|52.43416,5.04959,0|52.43081,5.08392,0|52.40904,5.06882,0|52.40736,5.04684,0|52.38222,5.00977,0|52.36629,5.01663,0|52.37300,4.98917,0|52.35958,4.98505,0|52.32854,5.06195,0|52.33609,5.07156,0|52.33777,5.09628,0|';
      returnGeom = returnGeom + '52.32183,5.13611,0|52.30493,5.16618,0|52.30955,5.23897,0|52.29359,5.29527,0|52.27595,5.30901,0|52.27889,5.27330,0|52.21920,5.22455,0|52.17627,5.19296,0|52.17880,5.12086,0|52.16153,5.04671,0|52.18090,5.04053,0|52.18343,5.03160,0|52.19629,5.02734,0|52.23079,5.02734,0|52.25013,5.05893,0|52.28038,5.06030,0|52.28878,5.00949,0|52.27450,4.95868,0|52.27786,4.92435,0|52.24676,4.90924,0|52.24676,4.86118,0|52.22321,4.81998,0|52.22406,4.77054,0|52.20470,4.73071,0|52.21361,4.72199,0|52.23065,4.72302,0|52.22287,4.67530,0|52.22602,4.66363,0|52.21424,4.62792,0|52.21424,4.59531,0|52.21698,4.58535,0|52.21551,4.56818,0|52.21866,4.55445,0|52.22665,4.55170,0|52.23107,4.55479,0|52.23254,4.56303,0|52.25987,4.57024,0|52.26764,4.56818,0|52.28130,4.58844,0|52.28781,4.59153,0|52.29075,4.59702,0|52.29453,4.59599,0|52.31132,4.61144,0|52.31620,4.61148,0|52.31756,4.60839,0|52.31714,4.58899,0|52.31819,4.58315,0|52.31473,4.57234,0|52.31599,4.56805,0|52.31326,4.56684,0|';
      returnGeom = returnGeom + '52.31378,4.56255,0|52.30990,4.55723,0|52.32627,4.49904,0|52.32753,4.49389,0';
      var geomAry = new Array(); 
      geomAry = returnGeom.split('|'); 
      var XY = new Array(); 
      var points = []; 
      for (var i = 0; i < geomAry.length; i++) 
      { 
      XY = geomAry[i].split(','); 
      points.push( new GLatLng(parseFloat(XY[0]),parseFloat(XY[1]))) ; 
      } 
      //var provincie_polygon = new GPolygon(points,'#f33f00', 0, 1, '#ffffff', 0.3);
      var provincie_polygon = new GPolygon(points,'#BED630', 1, 1, '#ffffff', 0.5); 



      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        geocoder = new GClientGeocoder();
        if (!geocoder) {
	 alert("Geen geocoder!");
	 return false;
        }


	function setAdres(id, titel, straat, postcode, stad, menuid, along, alat) {
	 if (along!="" && alat!="") {
	  apoint = new GLatLng(along, alat);
	  showAdres(id, titel, straat, postcode, stad, menuid, apoint);
	 } else {
	  geocoder.getLatLng(
	    straat+", "+postcode+", "+stad,
	    function(point) {
	      if (!point) {
	        alert(titel+"\n'"+straat + "' '"+ postcode+"' '"+stad + "' niet gevonden!");
	      } else {
	        showAdres(id, titel, straat, postcode, stad, menuid, point);
	      }
	    }
	  );
	 }
	}

	function showAdres(id, titel, straat, postcode, stad, menuid, point) {
		markerOptions = { icon:tinyIcon, title:titel, id:id };

	        var marker = new GMarker(point, markerOptions);
	        map.addOverlay(marker);

// alert("id:"+id+" "+titel);
		markers[id] = marker;

		GEvent.addListener(marker, "click", function() {
			if (map.getCurrentMapType() != basis_map_type) {
				map.openInfoWindowHtml(this.getPoint(),
                           	"<div class='google-info-window'><b>"+titel+"</b><br />\n"+straat+"<br />\n"+postcode+" "+stad+"<br />\n<a href='/index.php?id="+menuid+"&kid="+kantids[id]+"' target='_top'>Meer informatie</a></div>");
			} else {
				changeMarkers();
				provincie_polygon.hide();
				// this.setImage(basis_url+"/assets/images/place_icon.png");
			}

			cur_zoom = map.getZoom();
			map.setMapType(zoom_map_type);
			map.setZoom(kantoor_zoom);
			map.panTo(this.getPoint());
		});

	}

        map.setCenter(provincie, basis_zoom);
// 	map.setUIToDefault();
	map.addControl(new GLargeMapControl3D());
	map.enableScrollWheelZoom();
	map.setMapType(basis_map_type);


// Create our "tiny" marker icon
var tinyIcon = new GIcon();
tinyIcon.image = basis_url+"/assets/images/place_ico2s.png";
tinyIcon.iconSize = new GSize(40, 35);
tinyIcon.iconAnchor = new GPoint(13, 35);
tinyIcon.infoWindowAnchor = new GPoint(5, 1);

// Set up our GMarkerOptions object literal
// markerOptions = { icon:tinyIcon };






	function goHome() {
//	 map.setCenter(provincie, basis_zoom);
	provincie_polygon.show();
	 for (var i=0; i<kantoren.length; i++) {
	  markers[i].setImage(basis_url+"/assets/images/place_ico2s.png");
	 }
	 map.setMapType(basis_map_type);
	 map.setZoom(basis_zoom);
	 map.panTo(provincie);
	}

	function changeMarkers() {
	 for (var i=0; i<markers.length; i++) {
	  markers[i].setImage(basis_url+"/assets/images/place_icon.png");
	 }
	}

	function TextBtnControl() {
	}
	TextBtnControl.prototype = new GControl();

	// Creates a one DIV for each of the buttons and places them in a container
	// DIV which is returned as our control element. We add the control to
	// to the map container and return the element for the map class to
	// position properly.

	TextBtnControl.prototype.initialize = function(map) {
	  var container = document.createElement("div");
	  var zoomInDiv = document.createElement("div");
	  this.setButtonStyle_(zoomInDiv);
	  container.appendChild(zoomInDiv);
	  zoomInDiv.appendChild(document.createTextNode("Overzicht"));
	  GEvent.addDomListener(zoomInDiv, "click", function() {
	    // map.zoomIn();
	    goHome();
	  });
	  map.getContainer().appendChild(container);
	  return container;
	}

	// By default, the control will appear in the top left corner of the
	// map with 7 pixels of padding.
	TextBtnControl.prototype.getDefaultPosition = function() {
	  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
	}

	// Sets the proper CSS for the given button element.
	TextBtnControl.prototype.setButtonStyle_ = function(button) {
//	  button.style.textDecoration = "underline";
	  button.style.color = "#000000";
	  button.style.backgroundColor = "white";
	  button.style.font = "small Arial";
	  button.style.border = "1px solid black";
	  button.style.padding = "2px";
	  button.style.marginBottom = "3px";
	  button.style.textAlign = "center";
	  button.style.width = "6em";
	  button.style.cursor = "pointer";
	}

	map.addControl(new TextBtnControl());

	map.addOverlay(provincie_polygon);

	// =====================

	for (var i=0; i<kantoren.length; i++) {
	 setAdres(i, kantoren[i], straten[i],postcodes[i], steden[i], menuids[i], alongs[i], alats[i]);
	}





/*
        // Add 10 markers to the map at random locations
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
        for (var i = 0; i < 10; i++) {
          var point = new GLatLng(southWest.lat() + latSpan * Math.random(),
                                  southWest.lng() + lngSpan * Math.random());
          map.addOverlay(new GMarker(point));
        }
*/

      }
    }




window.onload = initialize;
window.onunload = GUnload;