var map;
function loader(){
	map = createMap();
}

// Create flying site icon
var site_icon = new GIcon();
site_icon.image = site_icon_load.src;
site_icon.shadow = shadow_icon_load.src;
site_icon.iconSize = new GSize(12, 20);
site_icon.shadowSize = new GSize(22, 20);
site_icon.iconAnchor = new GPoint(6, 20);
site_icon.infoWindowAnchor = new GPoint(5, 1);
	
function createMap(){
	var newMap = new GMap2(document.getElementById("map"));
	// Add the controls
	newMap.addControl(new GSmallMapControl());
	newMap.addControl(new GMapTypeControl());
	// Center the map
	newMap.setCenter(new GLatLng(lat_center,lon_center), 6);
	newMap.setMapType(G_NORMAL_MAP);

	var icon;
	// Add site markers
	for (var i = 0; i < num_locations; i++) {
		var newMarker = new PdMarker( new GLatLng(locations[i][1],locations[i][2]), site_icon);
		newMarker.setTooltip(locations[i][0]);
            var html = "<p class='DetailWin'><b>" + locations[i][0] + "</b>" +
			"<br>&bull; <a class='DetailWin' href='" + locations[i][3] + "' target='_BLANK'>" + "Weather Underground" + "<\/a>" + 
			"<br>&bull; <a class='DetailWin' href='" + locations[i][4] + "' target='_BLANK'>" + "MM5 Sounding Generator" + "<\/a>" + 
			"<br>&bull; <a class='DetailWin' href='" + locations[i][5] + "' target='_BLANK'>" + "XC Skies Surface Winds" + "<\/a>" + 
			"<br>&bull; <a class='DetailWin' href='" + locations[i][6] + "' target='_BLANK'>" + "Personal WX Stations" + "<\/a>" + 
			"<br>&bull; <a class='DetailWin' href='" + locations[i][7] + "' target='_BLANK'>" + "NWS Point Forecast" + "<\/a>" + 
			"<br>&bull; <a class='DetailWin' href='" + locations[i][8] + "' target='_TOP'  >" + "Site Guide" + "<\/a>";
		newMarker.setDetailWinHTML(html);
		newMarker.setHoverImage("googlemaps/pin_red.png");
		newMap.addOverlay(newMarker);
	}
	
	return newMap;
}
