
	var theMap;
	var theGeocoder;
	var VictoireLatLng = new GLatLng(52.6233, 4.7678);
	var SourceLatLng;

	function LoadGoogleMap() {
		if (GBrowserIsCompatible()) {
			theMap = new GMap2(document.getElementById("googlemap"));
			theMap.addControl(new GSmallMapControl());
			theMap.addControl(new GMapTypeControl());
			theMap.setCenter(VictoireLatLng, 13);
			theMap.setMapType(G_NORMAL_MAP);
			CreateMarker(VictoireLatLng, "Vul het <strong>adres</strong>, de <strong>postcode</strong> en/of de <strong>plaatsnaam</strong> in van het vertrekadres en klik op <strong>Zoek vertrekadres</strong>.", "");
			theGeocoder = new GClientGeocoder();
			theGeocoder.setBaseCountryCode("nl");
		}
	}

	function SearchStartAddress(address) {
		if (address.length != 0) {
			if (theGeocoder) {

				theGeocoder.getLatLng(address,

					function(theLatLng) {
						var errorLayer = getLayer("googlemapserror");
						if (!theLatLng) {
							if (errorLayer) {
								errorLayer.innerHTML = "Er kan geen bijpassend adres worden gevonden!";
								errorLayer.style.display = "block";
							}
						} else {
							if (errorLayer) {
								errorLayer.style.display = "none";
							}
							theMap.setCenter(theLatLng, 14);
							SourceLatLng = theLatLng;
							CreateMarker(theLatLng, "Controleer het gevonden vertrekpunt en klik op <strong>Bereken route</strong> om de routebeschrijving te laten berekenen.", address);
						}
					}

				);

			}
		}

		return false;
	}

	function CreateMarker(theLatLng, htmltext, address) {

		var	startHTML  = "<div class=\"googlemapinfotab\" style=\"width: 300px;\">" + htmltext + "<br />";
			startHTML += "<form id=\"googlemapsentry\" action=\"http://maps.google.nl/maps\" method=\"get\" target=\"_blank\">";
			startHTML += "<fieldset><div id=\"googlemapserror\" style=\"display: none;\"></div><input type=\"text\" class=\"text\" name=\"searchaddress\" id=\"searchaddress\" value=\"" + address + "\" /><br />";
			startHTML += "<input type=\"submit\" class=\"button\" value=\"Zoek vertrekadres\" onclick=\"return SearchStartAddress(document.forms['googlemapsentry'].searchaddress.value)\">";
			if (SourceLatLng) {
				startHTML += "<input type=\"submit\" class=\"button\" value=\"Bereken route\" />";
				startHTML += "<input type=\"hidden\" name=\"saddr\" value=\"" + SourceLatLng.lat() + ',' + SourceLatLng.lng() + "\" />";
			}
			startHTML += "<input type=\"hidden\" name=\"daddr\" value=\"" + VictoireLatLng.lat() + ',' + VictoireLatLng.lng() + "\" />";
			startHTML += "</fieldset></form><br />";
			startHTML += "</div>";

		var	destHTML  = "<div class=\"googlemapinfotab\" style=\"width: 300px;\">Het bestemmingsadres is:<br /><strong>Victoire Yachts BV<br />Kraspolderweg 2<br />1821 BW ALKMAAR</strong></div>";

		var InfoWindowTabs = [
			new GInfoWindowTab("Vertrek", startHTML),
			new GInfoWindowTab("Bestemming", destHTML)
		];

		var theMarker = new GMarker(theLatLng);
		GEvent.addListener(theMarker, "click",

			function() {
				theMarker.openInfoWindowTabsHtml(InfoWindowTabs);
			}

		);

		theMap.addOverlay(theMarker);
		theMarker.openInfoWindowTabsHtml(InfoWindowTabs);

	}
