var map;
var blnIcons = true;
var gmarkers = [];
var i=0;
var mapZoom = 13;

var txtInfoText = new Array();
var txtLabel = new Array();
var Lat = new Array();
var Lng = new Array();
var LatOffset = new Array();
var LngOffset = new Array();


function loadmap() {


	if (GBrowserIsCompatible()) {
	

		// ICON DEFAULT
		var baseIcon = new GIcon();
		baseIcon.iconSize = new GSize(20,34);
		baseIcon.shadowSize = new GSize(37,34);
		baseIcon.iconAnchor = new GPoint(9,34);
		baseIcon.infoWindowAnchor = new GPoint(9,2);
		baseIcon.infoShadowAnchor = new GPoint(18,25);



		// A function to create the marker and set up the event window
		function createMarker(fID, fChar) {
		
			var iconLetter = new GIcon(baseIcon)
			iconLetter.image = "http://www.google.com/mapfiles/marker" + fChar + ".png";
			var point = new GLatLng(Lat[fID], Lng[fID]);
			var labelname = txtLabel[fID];
			var html = txtInfoText[fID];
			if (fChar == "") {
				var marker = new GMarker(point, { clickable: true, title: labelname} );
				}
				else
				{
				var marker = new GMarker(point, {icon: iconLetter, clickable: true, title: labelname} );
				}
			gmarkers[i] = marker;
			i++;
			GEvent.addListener(marker, "click", function() { 
				marker.openInfoWindowHtml(html); 
				map.setCenter(point);
				});
			return marker;
	      }


		

		function SetPointData(fID, fLat, fLng, fLatOffset, fLngOffset, fLabel, fInfoText)
			{
			Lat[fID] = fLat;
			Lng[fID] = fLng;
			LatOffset[fID] = fLatOffset;
			LngOffset[fID] = fLngOffset;
			txtLabel[fID] = fLabel;
			var tmpText = "<div style='width:250px;height:70px;padding-top:10px;'>" + fInfoText
			tmpText = tmpText + "</div>";
			txtInfoText[fID] = tmpText;
			}


		
		SetPointData(0, 51.9456, 1.0669, 0 , -0.01 , "North House Gallery", "<b>North House Gallery</b>");
		SetPointData(1, 51.949, 1.0434, 0 , 0 , "Manningtree Railway Station", "<b>Manningtree Railway Station</b>");



		// SET MAP & CENTER
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());


		map.setCenter(new GLatLng( Lat[0] + LatOffset[0] ,Lng[0] + LngOffset[0]), mapZoom);
		// map.addControl(new GMapTypeControl());


		// ** NHG *****************************
		map.addOverlay(createMarker(0,""));
		gmarkers[0].openInfoWindowHtml(txtInfoText[0]);



		//** Manningtree Railway Sta
		map.addOverlay(createMarker(1,"T"));


		map.enableContinuousZoom();


		}
		else {
		alert("Sorry, your browser is unable to display the Location Map");
		}	
}




