// Build gmap object
staticMap = {
	// Stores id of map div
	mapID:'staticMap',
	mapClass:'zone-map',
	
	// Instatiate object (checks for DOM support)
	init:function()
	{

		// Check to see if W3C DOM is available - if not terminate script
		// If required objects are available, hide js alert and show update form
		if(!document.getElementById || !document.createTextNode){return;}
		
		// Define mapcontainer
		var mapcontainer = document.getElementById(staticMap.mapID);
		// If the page contains the map container, dynamically remove the hde class and load the map
		if(mapcontainer)
		{
			//alert('container exists');
			var _map = helper.getElementsByClass(staticMap.mapClass, mapcontainer);
			for(var i=0; i<_map.length; i++)
			{
				staticMap.buildStaticMap(_map[i]);
				
			}
		}
	},
	buildStaticMap:function(map) {
	
		//var map = helper.getTarget(e);

		var lat = eval(map.getAttribute("lat"));//54.9877086346;
		var long =  eval(map.getAttribute("long")); // -1.6047334671;
		
		if(lat==0 || long ==0)
			return;

		// var mapLink = "http://maps.google.com/maps/api/staticmap?center=Brooklyn+Bridge,New+York,NY&zoom=14&size=512x512&maptype=roadmap&markers=color:blue|label:S|40.702147,-74.015794&markers=color:green|label:G|40.711614,-74.012318&markers=color:red|color:red|label:C|40.718217,-73.998284&sensor=false&key=ABQIAAAA2qeb3XqnxjV4vJoJUEuDBBSvcyjW6cwdozk8YYlZWBubZUJTQxRaucCGUTuinh3D1vezAFLp8PA1jQ"
		// var mapLink = "http://maps.google.com/staticmap?center="+lat+","+long+"&markers=color:blue|label:S|"+lat+","+long+"&zoom=14&size=425x300&key=ABQIAAAA2qeb3XqnxjV4vJoJUEuDBBSvcyjW6cwdozk8YYlZWBubZUJTQxRaucCGUTuinh3D1vezAFLp8PA1jQ";
		var mapLink = "http://maps.google.com/maps/api/staticmap?center="+lat+","+long+"&zoom=15&size=200x200&maptype=roadmap&markers=color:red|label:|"+lat+","+long+"&markers=color:red|label:D|"+lat+","+long+"&sensor=false&key=ABQIAAAA2qeb3XqnxjV4vJoJUEuDBBSvcyjW6cwdozk8YYlZWBubZUJTQxRaucCGUTuinh3D1vezAFLp8PA1jQ";

		map.style.background = "url("+mapLink+")";
		map.style.height = "150px";
		map.style.width = "200px";

	}
}
// addEvent is a method used to sort of stack functions up after the page has loaded.
// On this page this method is watching the window and waiting till its loaded.
// After which the gmap.init object is initialized
helper.addEvent(window, 'load', staticMap.init, false);