var map;
var centerLatitude = 41.664;
var centerLongitude = -78.2107;
var startZoom = 5;

function addMarker(latitude, longitude, description) {
	var marker = new GMarker(new GLatLng(latitude, longitude));
	
	GEvent.addListener(marker, 'click',
		function() {
			marker.openInfoWindowHtml(description);
		}
	);
	map.addOverlay(marker);
}

function init() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		var location = new GLatLng(centerLatitude, centerLongitude);
		map.setCenter(location, startZoom); // setCenter() *must* be set before trying to add any markers
		
		for (id in markers) {
			addMarker(markers[id].latitude, markers[id].longitude, markers[id].name);
		}
	}
}

window.onload = init;
window.onunload = GUnload;
