if (GBrowserIsCompatible()) { 
	// A function to create the marker and set up the event window
	// Dont try to unroll this function. It has to be here for the function closure
	// Each instance of the function preserves the contends of a different instance
	// of the "marker" and "html" variables which will be needed later when the event triggers.    
	function createMarker(point,html,label)
	{
		var myicon = new GIcon(G_DEFAULT_ICON);
		myicon.image = "http://web.listing.nl/Digital4u-2009/images/marker.png";
		myicon.shadow = "http://web.listing.nl/Digital4u-2009/images/trans.png";
		myicon.iconSize = new GSize(25,25);
		myicon.iconAnchor = new GPoint(12,12); // het punt van de marker die op het LatLng moet vallen.
		
		var marker = new GMarker( point, { icon: myicon } );

		GEvent.addListener(marker, "click", function() {
			html2 = bubbleContent(html,label);
			marker.openInfoWindowHtml(html2);
			storeMarker = marker;
			storePoint = point;
		});
		return marker;
	}
	
	var storePoint = '';
	var storeMarker = '';
	
	function planRoute() {
		
		$('.adres').bind('keypress', function(e) {
			if (e.which == 32) {
				return false;
			}
		});
		
		var gdir;
		
		$(".bt").bind("click", pl = function(e){
			
			$(".routeText").show();
			$(".routeTitle").show();
			$(".prerouteText").hide();
			var saddr = $("#adres").val();
			var opts = {locale:"nl"};
			if (gdir)
			{
				gdir.clear();
			}
			gdir = new GDirections( map, document.getElementById('myroute1') );
			saddr = saddr.replace(" ", "+");
			saddr = saddr + '+Nederland';
			gdir.load("from: "+saddr+" to: " + storePoint, opts);
			$("#myroute1").show();
		});
	}
	//Google maps Wolkje
	function bubbleContent(html,label) {
		value = '';
		value += 'Digital4u<br />Noorderstraat 1t<br />1823 CS Alkmaar ';
		
		return value;
	}
	
	function clearText(e)
	{
		$(e).val('');
	}
	// Display the map, with some controls and set the initial location 
	function writemap()
	{
		map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(52.636125,4.750468),12);
	}
	
	function handleErrors(gdir)
	{
		alert('Een route tussen deze twee locaties kon niet worden berekend.');
	}


}
else
{
	alert("Excuses, de Google Maps API is niet compatible met uw browser");
}
	// This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://econym.googlepages.com/index.htm
	gmarkers = [];
	var map = '';
	var bounds = new GLatLngBounds();
	
$().ready(function() {
	// Bepaal de hoogte van de kaart container.
	//$("#kaart").css("height", "450px");
	// Schrijf de kaart naar het scherm.
	writemap();
	
	// HACK
	// Op de google map worden een aantal "no-print" ellement getoverd.
	// Deze blokeren de navigatie met de hand-cursor op de kaart.
	// daarom maken we ze een stuk kleiner, zodat we er geen last meer van hebben.
	// $(".gmnoprint").css("border", "solid 1px red"); // uncomment deze regel om de "no-print" area's zichtbaar te maken. 
	$(".gmnoprint").css("width", "5px");
	$(".gmnoprint").css("height", "30px");
	// END HACK
	// 
	// Loop door de data arrays, en creeer markers, op de kaart.
	for (c = 0; c < lats.length; c++ ) {
		var point = new GLatLng(lats[c],longs[c]);
		var marker = createMarker(point,htmls[c],labels[c]);
		map.addOverlay(marker);
		storePoint = point;
		gmarkers.push(point);
		bounds.extend(point);
		map.setZoom(map.getBoundsZoomLevel(bounds));
		map.setCenter(bounds.getCenter());
	}
	
	planRoute();
});