/* Google maps */
// Author: Pim Hoogendoorn - www.willenium.nl
// Date: 19 july 2008
// 
// Options which can be used:
//	Maptypes (default=G_NORMAL_MAP):
//	G_NORMAL_MAP=Drawing (default)
//	G_HYBRID_MAP=Hybrid map with both
//	G_SATELLITE_MAP=overview with cityinfo
//	
//	Zoomlevel (default=12):
//	 On a scale from 1 to 20. 
//	 1 is far and 20 is close.
//
//	Controls (default=false):
//	 new GLargeMapControl() = Full controls [arrows & zoomlevel-slider ]
//	 new GSmallMapControl() = Small controls [arrows & +/-]
//	 new GSmallZoomControl() = Mini controls [+/-]
//	 new GScaleControl() = Scale controls
//	 new GMapTypeControl() = User can switch maptype
//	 new GOverviewMapControl() = Gives a small overview window in the right corner
//	infoBox (default=false):
//	 Show or hide the info balloon
// --------------------------------

	// Map options
	divId = "map"; // The id of the element where the map is drawn
	Lat = 52.21649; // Latitude
	Long = 5.01567; // Longitude
	Zoom = 12; // Zoom level 
	Type = G_NORMAL_MAP; // Type of map
	control = false; // Type of controls
		controlType = new GOverviewMapControl(); // Controls to use when control = true
	infoBox = false; // Infobox for marker
		infoText = '<strong>Sv de Vecht</strong>'; // Text to use in the infoBox when infoBox = true
	errormsg = "Sorry, the Google Maps API is niet compatible met uw browser.";
	//------------

function loadMap(){
	if (GBrowserIsCompatible()) {
		if (document.getElementById(divId)) {
			// Display the map, with some controls and set the initial locati
			var Place = new GLatLng(Lat, Long);
			var map = new GMap2(document.getElementById(divId));
			map.setMapType(Type); // Type of map
			if(control==true){ map.addControl(controlType); }// Type of controls
			map.setCenter(Place, Zoom);	// Set the center of the map
			var point = Place; // Set up the marker with info window
			// Draw the map
			if(infoBox==true){
				marker = createMarker(point, infoText);
				map.addOverlay(marker);
				marker.openInfoWindowHtml(infoText);	
			}
			else{
				var marker = new GMarker(new GLatLng(Lat,Long));
				map.addOverlay(marker);
			}
		}
	}
	// display a warning if the browser was not compatible
	else {
		alert(errormsg);
	}
}

// A function to create the marker and set up the event windows
// 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) {
	var marker = new GMarker(point);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});
	return marker;
}
