//<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());

  		// Create the custom icon
  		var icon = new GIcon();
  		icon.image = "/images/pin.gif";
  		icon.shadow = "/images/pin_shadow.png";
  		icon.iconSize = new GSize(30, 20);
  		icon.shadowSize = new GSize(38, 22);
  		icon.iconAnchor = new GPoint(0, 0);
  		icon.infoWindowAnchor = new GPoint(25, 1);
    
      // 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)
          {
            // A rudimentary effort at centering the map in the middle of
            // the points
            if (i <= oGLatLngs.length / 2)
            {
          		// center the map
          		map.setCenter(point, 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();
            }
          }
      	}
      }
    }
}
