if (GBrowserIsCompatible()) {
      var gmarkers = [];
      var gicons = [];



      var baseIcon = new GIcon();
      baseIcon.iconAnchor = new GPoint(0,33);
      baseIcon.iconSize = new GSize(32,37);
      baseIcon.infoWindowAnchor = new GPoint(9,2);


      gicons["winkels"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/winkel.png");
      gicons["bedrijven"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/bedrijf.png");
      gicons["hotels"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/hotel.png");
	  gicons["restaurants"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/restaurants.png");
	  gicons["strandpaviljoens"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/strandpaviljoens.png");
	  gicons["cafes"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/cafes.png");
	  gicons["financiel"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/financiel.png");
	  gicons["scholen"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/school.png");
	  gicons["bezienswaardigheden"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/bezienswaardigheden.png");
	  gicons["parkeren"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/parkeren.png");
	  gicons["parkeergarage"] = new GIcon(baseIcon,"http://www.allesoverkatwijk.nl/plattegrond/icon/parkeergarage.png");




	// === discard all except the first two results ===
      function doSearchCompleteCallback(search) {
        search.results.splice(2);        
      }

      var map = new GMap2(document.getElementById("map"),{googleBarOptions:
          {onSearchCompleteCallback:doSearchCompleteCallback}
      })

      map.setCenter(new GLatLng(52.204584420969994,4.39752459526062),16);
	  //map.setCenter(new GLatLng(0,0),0);
      map.addControl(new GMapTypeControl());
      map.addControl(new GLargeMapControl());

      map.enableGoogleBar();




      // A function to create the marker and set up the event window
      function createMarker(point,name,html,category) {
        var marker = new GMarker(point,gicons[category]);
        // === Store the category and name info as a marker properties ===
        marker.mycategory = category;                                 
        marker.myname = name;
        GEvent.addListener(marker, "click", function() {
        marker.openInfoWindowHtml(html);
			
        });
        gmarkers.push(marker);
        return marker;
      }
	  
	  
	  	  

      // == shows all markers of a particular category, and ensures the checkbox is checked ==
      function show(category) {
        for (var i=0; i<gmarkers.length; i++) {
          if (gmarkers[i].mycategory == category) {
            gmarkers[i].show();
          }
        }
        // == check the checkbox ==
        document.getElementById(category+"box").checked = true;
      }

      // == hides all markers of a particular category, and ensures the checkbox is cleared ==
      function hide(category) {
        for (var i=0; i<gmarkers.length; i++) {
          if (gmarkers[i].mycategory == category) {
            gmarkers[i].hide();
          }
        }
        // == clear the checkbox ==
        document.getElementById(category+"box").checked = false;
        // == close the info window, in case its open on a marker that we just hid
        map.closeInfoWindow();
      }

      // == a checkbox has been clicked ==
      function boxclick(box,category) {
        if (box.checked) {
          show(category);
        } else {
          hide(category);
        }
        // == rebuild the side bar
        makeSidebar();
      }



      function myclick(i) {
        GEvent.trigger(gmarkers[i],"click");
      }
	  
	  
	    


      // == rebuilds the sidebar to match the markers currently displayed ==
      function makeSidebar() {
        var html = "";
        for (var i=0; i<gmarkers.length; i++) {
          if (!gmarkers[i].isHidden()) {
            html += '<a href="javascript:myclick(' + i + ')"><div class="locatie_naam">' + gmarkers[i].myname + '<\/div><\/a>';
          }
        }
        document.getElementById("side_bar").innerHTML = html;
      }


	



	// ===== Start with an empty GLatLngBounds object =====     
      var bounds = new GLatLngBounds();

	 

	

      // Read the data
      GDownloadUrl("http://www.allesoverkatwijk.nl/plattegrond/categories.xml", function(doc) {
        var xmlDoc = GXml.parse(doc);
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");
          
        for (var i = 0; i < markers.length; i++) {
          // obtain the attribues of each marker
          var lat = parseFloat(markers[i].getAttribute("lat"));
          var lng = parseFloat(markers[i].getAttribute("lng"));
          var point = new GLatLng(lat,lng);
          var address = markers[i].getAttribute("address");
          var name = markers[i].getAttribute("name");          
		  var html = GXml.value(markers[i].getElementsByTagName("infowindow")[0]);
          var category = markers[i].getAttribute("category");
          // create the marker
          var marker = createMarker(point,name,html,category);
          map.addOverlay(marker);
		  
		  // ==== Each time a point is found, extent the bounds ato include it =====
            bounds.extend(point);
		  
        }
		
		 // ===== determine the zoom level from the bounds =====
         // map.setZoom(map.getBoundsZoomLevel(bounds));

          // ===== determine the centre from the bounds ======
         //map.setCenter(bounds.getCenter());

			

        // == show or hide the categories initially ==
        show("winkels");
        show("bedrijven");
        show("hotels");
		show("restaurants");
		show("strandpaviljoens");
		show("cafes");
		show("financiel");
		show("scholen");
        // == create the initial sidebar ==
        makeSidebar();
        
        
        
        
        var query = location.search.substring(1);
        

  	var pos = query.indexOf("=");
  	var argname = query.substring(0,pos);
  	var value = query.substring(pos+1);
//  	console.log("Query: "+query);
//  	console.log("argname: "+argname);
//  	console.log("value: "+value);
  	if (argname=="marker") {
  		//var laatzien = value;

  		//value = value.replace(/%20/gi, " ");
  		value = decodeURI(value);
  		//console.log(value);
  	//	GEvent.trigger(gmarkers[value],"click");
  		for (i=0; i<gmarkers.length; i++) {
  			if (gmarkers[i]['myname'] == value) {
  				GEvent.trigger(gmarkers[i],"click");
  			}
  		}
  				
  	}
  	
  	//console.log(gmarkers[12]);
        
        
        
      });
      

 
      
      
      
      
	  
	 
	 
	 
	 
	  
    }

    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
    // This Javascript is based on code provided by the
    // Community Church Javascript Team
    // http://www.bisphamchurch.org.uk/   
    // http://econym.org.uk/gmap/

    //]]>
