function mapsLoaded() {
  var lang1 = document.selectedLocForm.selectedLong.value;
  var lat2 = document.selectedLocForm.selectedLat.value;
  var googleAddress = document.selectedLocForm.selectedGoogleAddress.value;
  var displayAddress = document.selectedLocForm.selectedDisplayAddress.value;

  //var map = new google.maps.Map2(document.getElementById("localmap"));  
  //map.setCenter(new google.maps.LatLng(lang1, lat2), 13);	
   //var map = new google.maps.Map(document.getElementById("localmap"), myOptions);
   
  
   var map = new GMap2(document.getElementById("localmap"));
   map.addControl(new GLargeMapControl());
   map.setCenter(new GLatLng(lang1, lat2), 13);
   map.enableDoubleClickZoom();
   map.setUIToDefault();    
   map.setMapType(G_NORMAL_MAP);
  
  /*
  var companyMarker = new GMarker({
	position: new GLatLng(lang1,lat2),
	map: map,
	title: "Some title"
	}); 
*/

	var plcbicon = new GIcon(G_DEFAULT_ICON); 
	// 658 Icon change - start
	plcbicon.image = "/static/images/google_icon.png"; 
	plcbicon.shadow = "/static/images/google_shadow_icon.png"; 
	plcbicon.iconSize = new GSize(32,32);	
	plcbicon.shadowSize = new GSize(50, 32);
	// 658 - end
	//plcbicon.image = "http://localhost/static/images/favicon.ico"; 
	//plcbicon.image = "/static/images/google_icon.png"; 
	//plcbicon.shadow = "/static/images/google_shadow_icon.png"; 
	//plcbicon.iconSize = new GSize(32,32);	
	//plcbicon.shadowSize = new GSize(50, 32);
	//plcbicon.iconAnchor = new GPoint(25, 32); 
	var markerOptions = { icon: plcbicon }; 
	var point = new GLatLng(lang1,lat2);
	var marker = new GMarker(point, markerOptions);   
	//var message = ["This","is","the","secret","message"];   
	marker.value = "Store";   
	// var directionURL="http://maps.google.com/maps?saddr=&daddr="+lang1+","+lat2+"&hl=en";
	var directionURL="http://maps.google.com/maps?saddr=&daddr="+googleAddress+"&hl=en";
	
	var myHtml = "<font class=normalText><b>" + 
						"PA Wine & Spirits Store" + "</b><br/>" + displayAddress + "<br/>"+
						"FineWineAndGoodSpirits.com<br><br><a href='"+directionURL+"' target='_blank'>Directions</a></font>";     
	
	GEvent.addListener(marker, "click", 
		function() {     var myHtml = "<font class=normalText><b>" + 
						"PA Wine & Spirits Store" + "</b><br/><br/>" + displayAddress + "<br/>"+
						"FineWineAndGoodSpirits.com<br><br><a href='"+directionURL+"' target='_blank'>Directions</a></font>";     
						map.openInfoWindowHtml(point, myHtml);   });   
	
	map.addOverlay(marker);
	map.openInfoWindowHtml(point, myHtml);
   /*
   var map = new GMap2(document.getElementById("localmap"));
   map.addControl(new GLargeMapControl());
   map.setCenter(new GLatLng(lang1, lat2), 13);
   map.enableDoubleClickZoom();
   map.setUIToDefault();    
   map.setMapType(G_NORMAL_MAP);
   */
   
   /* working
	var point = new GLatLng(lang1,lat2);
	map.addOverlay(new GMarker(point));
	*/
}

function loadMaps() {
  google.load("maps", "2", {"callback" : mapsLoaded});
}
/*
function mapPopup(popup, longitude, latidude,index,lastindex){
		document.selectedLocForm.selectedLong.value = longitude;
		document.selectedLocForm.selectedLat.value = latidude;
		popupWindow = document.getElementById(popup);
		pageHeight= document.body.clientHeight;
		pageWidth = document.body.clientWidth;
		//popupWindow.style.left = eval(pageWidth/2-200-popupWindow.offsetWidth)+'px';
		if(index<(lastindex-1))
		{
			popupWindow.style.top = 500+(index*125)+'px';
		}
		else
		{
			popupWindow.style.top = 500+(index*105)+'px';
		}
		popupWindow.style.display='block';
		loadMaps();
}
*/
// Added by dipak 
function mapPopupWithDirection(popup, longitude, latidude, googleAddress, displayAddress, index,lastindex){		
	
		document.selectedLocForm.selectedLong.value = longitude;
		document.selectedLocForm.selectedLat.value = latidude;
		document.selectedLocForm.selectedGoogleAddress.value = googleAddress;
		document.selectedLocForm.selectedDisplayAddress.value = displayAddress;
			//alert('hi1');
			//alert(longitude);			
			//alert(latitude);
			//alert('hi2');
			//alert(googleAddress);
			//alert(displayAddress);
		popupWindow = document.getElementById(popup);
		pageHeight= document.body.clientHeight;
		pageWidth = document.body.clientWidth;
		//popupWindow.style.left = eval(pageWidth/2-200-popupWindow.offsetWidth)+'px';
		if(index<(lastindex-1))
		{
			popupWindow.style.top = 500+(index*125)+'px';
		}
		else
		{
			popupWindow.style.top = 500+(index*105)+'px';
		}
		popupWindow.style.display='block';
		loadMaps();
}


function closemap(popup){
	popupWindow = document.getElementById(popup);
	popupWindow.style.display='none';
}




/*function initialize() {
     if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("localmap"));
        map.setMapType(G_HYBRID_MAP );
        map.setCenter(new GLatLng(37.4419, -122.1419), 18);
   }
}*/

