//<script>
function MapDrawPoints(gZoomLevel)
{
	// daniel@klixo.net.nz
	// http://www.google.com/apis/maps/documentation/reference.html
	if (GBrowserIsCompatible()) 
	{	    
		// Initialise the map object
		var ele = document.getElementById("map");
		if (ele == null) return;
		var map = new GMap2(ele);
		map.addControl(new GMapTypeControl());
		map.addControl(new GLargeMapControl());
		map.addControl(new GOverviewMapControl());

		// Use Google Icon
		var icon = new GIcon(G_DEFAULT_ICON);
		    
		var minx = 0, maxx, miny, maxy;
		var pCentrePoint;
		    
		// Get an array of hidden inputs that contain the Points data    
		var oGLatLngs = document.getElementsByName("oGLatLng");
		// Loop through and create a marker for each point
		for (var i = 0; i < oGLatLngs.length; i++)
		{
			var sGLatLng = oGLatLngs[i].value;
			// If a GLatLng value exists for this story, use it to create a point
			if (sGLatLng.length > 0)
			{
				eval("var point = new GLatLng(" + sGLatLng + ");");
				if (point)
				{
					// Get the min and max x/y coordinates
					if (minx == 0)
					{
						pCentrePoint = new GLatLng(point.lat(), point.lng());
						minx = point.x;
						maxx = point.x;
						miny = point.y;
						maxy = point.y;
					}
					else
					{
						if (point.x < minx) minx = point.x;
						if (point.x > maxx) maxx = point.x;
						if (point.y < miny) miny = point.y;
						if (point.y > maxy) maxy = point.y;
						delete pCentrePoint;
						pCentrePoint = new GLatLng((miny + maxy) / 2, (minx + maxx) / 2);
					}
					// Centre the map
					map.setCenter(pCentrePoint, gZoomLevel);
					// Set the map type to Normal (can't do until Zoomlevel set)
					map.setMapType(G_NORMAL_MAP);
					// draw the marker
					var marker = new GMarker(point, icon);
					// Add the marker to the map
					map.addOverlay(marker); 
					// Get the info window div
					var j = i + 1;
					var info = document.getElementById("MapInfo" + j);
					if (info)
					{ 
						// Bind the div to the marker, ready to be opened when the marker
						// is clicked
						marker.bindInfoWindow(info);
						info.style.display = "block";
						// Open the window and then close it again so that the info div
						// does not display TODO: use div.innerHTML
						marker.openInfoWindow(info);
						marker.closeInfoWindow();
					}
				}
			}
		}
	}
}
