var objLongitude;
var objLatitude;
var objVenueDesc;

function loadMap( ) 
{
   initControls(); // function written from .net page 
   //get map values from .net page
   var dLat, dLong, sDescription;
   dLat = objLatitude.value;
   dLong = objLongitude.value;
   sDescription = objVenueDesc.value;
   
//   var query = window.location.search.substring(1);
//   var vars = query.split("&");
//   
//   var dLat, dLong, sDescription;
//   
//   for ( var i = 0; i<vars.length; i++ ){
//    var pair = vars[i].split("=");
//    
//    if ( pair[0] == "lat" )
//        dLat = pair[1];
//    if ( pair[0] == "long" )
//        dLong = pair[1];
//    if ( pair[0] == "desc" )
//        sDescription = unescape(pair[1]);
//   }
       
  if (GBrowserIsCompatible() && dLat != "") 
  {     
  
    var mapSize = new GSize(400,400);
	var map = new GMap2(document.getElementById("map"), mapSize);


	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.setCenter(new GLatLng(dLat, dLong), 15);
	
	var geocoder = new GClientGeocoder();
	geocoder.setCache(null);
	        
	// Download the data in data.xml and load it on the map
		  	  	  	  
	var point = new GLatLng(dLat, dLong);		
							
	map.addOverlay(createMarker(point, sDescription));
    
	map.addControl(new GScaleControl  ());
	}
}	

function createMarker(point, description) 
{  
	var marker = new GMarker(point);  
	
	var sHTML = new String('');
		
	sHTML = '<div style="float: left; width: 160px;">' + description + '</div>';
	
	GEvent.addListener(marker, "click", function() 	{    marker.openInfoWindowHtml(sHTML);  });  
	return marker;
}

