// JavaScript Document
// map functions
//
// mapLat and mapLong are the centre popints of the google map... client locaion
//

// var startZoom = 8;
var map;
var homeMarkerLat = 52.023993030098666;
var homeMarketLong = -1.1396920680999756;
/* var points = [
	{lat:52.023998,lng:-0.468000,markerInfo:11},
	{lat:51.876999,lng:-0.536000,markerInfo:28},
	{lat:51.744999,lng:-1.259000,markerInfo:69},
	{lat:51.522999,lng:-0.726000,markerInfo:69},
	{lat:52.609001,lng:-1.115000,markerInfo:70},
	{lat:52.668999,lng:0.139000,markerInfo:74},
	{lat:52.765999,lng:-1.192000,markerInfo:87},
	{lat:52.131001,lng:1.116000,markerInfo:109},
	{lat:52.448002,lng:-1.993000,markerInfo:110},
	{lat:52.476002,lng:1.061000,markerInfo:112},
	{lat:51.530998,lng:-1.819000,markerInfo:114},
	{lat:51.898998,lng:-2.107000,markerInfo:129}
];  */

		

function load() {
      if (GBrowserIsCompatible() ) {
        map = new GMap2(document.getElementById("map") );
		var location = new GLatLng(centerLatitude, centerLongitude);
        map.setCenter(location, startZoom);
		updateMarkers();
		map.addControl(new GLargeMapControl() );
		GEvent.addListener(map,'zoomend', updateMarkers() );
      }
}

	function updateMarkers() {
		map.clearOverlays();
		
		for (id in points) {
		addMarker(points[id].Latitude, points[id].Longitude, points[id].Information);
		}
	}


	function addMarker(markerLat, markerLong,  markerInfo) {
		var marker = new GMarker(new GLatLng(markerLat,markerLong))
		map.addOverlay(marker);
		GEvent.addListener(marker, 'click',
				   function() {
						   marker.openLittleInfoWindow(markerInfo,150);
					   }
				   );
	}
