var map;
var locationData = {};
function load() {
	var i, location, initialLocation, dataLength, marker;
	if (GBrowserIsCompatible()) {
		dataLength = mapData.length;
		map = new GMap2(document.getElementById("worldmap"));
		
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        
        function createMarker(point, name, description) {
			// Set up our GMarkerOptions object
			markerOptions = {};
			var marker = new GMarker(point, markerOptions);
			
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml("<b>" + name + "</b><br/><br/>" + description);
			});
			return marker;
		}
		
		map.setCenter (new GLatLng (defLat, defLong), defZoom);
		for (i = 0; i < dataLength; i++) {
			location = mapData [i];
			if (location) {
				marker = createMarker (
					new GLatLng(
						location.latitude,
						location.longitude
					), 
					location.location, 
					location.description
				);
				map.addOverlay(marker);
				locationData [location.location] = marker;
			}
		}
	}
}
function inspect (thing) {
	var s = "";
	for (var p in thing) {
		s += p + ": " + thing[p] + "\n";
	}
	return s;
}

function displayLocation (location,latitude,longitude) {
	//map.setCenter(new GLatLng(latitude, longitude), 14);
	//map.panTo (new GLatLng(latitude, longitude));
	
	var marker = locationData [location];	
	GEvent.trigger (marker, "click");
}
