var Gmap = null;
var lon_wgs84 = null;
var lat_wgs84 = null;

function load() {
   lon_wgs84 = document.getElementById("lon_wgs84H").value;
   lat_wgs84 = document.getElementById("lat_wgs84H").value;
   
   if(lon_wgs84 == null || lon_wgs84.length == 0 || lat_wgs84 == null || lat_wgs84.length == 0){
		// No location for this postcode was found
		//document.getElementById('map').style.display = 'none';
   } else {
		try{
		  if (GBrowserIsCompatible()){
		   //  alert('Loading Google Maps');
			document.getElementById('map').style.visibility = 'visible';
			LoadGoogleMaps();
		  }
		}catch(err){
			//alert('Map for this venue could not be loaded!');
		}
   }
}

function LoadGoogleMaps() {
   Gmap = new GMap2(document.getElementById("map"));
   Gmap.addControl(new GSmallMapControl());
   Gmap.addControl(new GMapTypeControl());
   lon_wgs84 = document.getElementById("lon_wgs84H").value;
   lat_wgs84 = document.getElementById("lat_wgs84H").value;

   Gmap.setCenter(new GLatLng(lat_wgs84, lon_wgs84), 14);

   // Creates a marker at the given point with the given number label
   function createMarker(point) {
      var venueInfo = document.getElementById("venueInfoH").value;
      var marker = new GMarker(point);
      GEvent.addListener(marker, "click", function(){ marker.openInfoWindowHtml(venueInfo); } );
      return marker;
   }
   
   var marker = createMarker(new GLatLng(lat_wgs84, lon_wgs84));

   Gmap.addOverlay(marker);
}

function newWindow(url, width, height) {
   window.open(url, 'POIDetails', 'width=' + width + ',height=' + height + ',scrollbars=yes,resizable=yes')
   return false
}
