
	var map = null;
    var geocoder = null;
	var gmarkers=[];

	var iconLocation = new GIcon(); 
	iconLocation.image= '/templates/default/images/location.png';
	//iconLocation.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
	iconLocation.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconLocation.iconSize = new GSize(24, 24);
	iconLocation.shadowSize = new GSize(22, 20);
	iconLocation.iconAnchor = new GPoint(6, 20);
	iconLocation.infoWindowAnchor = new GPoint(5, 1);
	var myMarker=iconLocation;
	

	<!-- This array is used to assign the icons for different landmarks -->
	var customIcons = [];
	customIcons["location"] = iconLocation;

	var PropInfo	=	[];

function initialize() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map_canvas"));
		map.addControl(new GMapTypeControl());
		map.addControl(new GOverviewMapControl());
		map.addControl(new GLargeMapControl());
		//map.enableScrollWheelZoom();
		map.setCenter(new GLatLng(13.060416, 80.249634), 13);			
        geocoder = new GClientGeocoder();
		//map.setMapType(G_HYBRID_TYPE); 
		//map.openInfoWindow(map.getCenter(),
        //document.createTextNode("Chennai City"));
		ew = new EWindow(map, E_STYLE_6);		  
      	map.addOverlay(ew);
		loadPlots();		
      }
    }	

function loadPlots()
{
 var frm		=	document.searchString;
// var city		=	frm.city.value;
 var navURL		=	document.getElementById("navURL").value + "&act=genXML";
 //showAddress(city + ",India");
 GDownloadUrl(navURL, function(data) {
		  var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
			  for (var i = 0; i < markers.length; i++) {	
				PropInfo["provider_type"]	= markers[i].getAttribute("provider_type");
				PropInfo["provider_name"]	= markers[i].getAttribute("provider_name");
				PropInfo["phone_mobile"]	= markers[i].getAttribute("phone_mobile");
				PropInfo["city"]			= markers[i].getAttribute("city");
				PropInfo["locality"]		= markers[i].getAttribute("locality");
				PropInfo["pincode"]			= markers[i].getAttribute("pincode");
				PropInfo["office_name"]		= markers[i].getAttribute("office_name");
				showAddress(PropInfo["provider_type"], PropInfo["provider_name"], PropInfo["phone_mobile"], PropInfo["city"], PropInfo["pincode"], PropInfo["locality"], PropInfo["office_name"]);
				if (markers.length > 0)
				{
					PropInfo["provider_type"]	= markers[0].getAttribute("provider_type");
					PropInfo["provider_name"]	= markers[0].getAttribute("provider_name");
					PropInfo["phone_mobile"]	= markers[0].getAttribute("phone_mobile");
					PropInfo["city"]			= markers[0].getAttribute("city");
					PropInfo["locality"]		= markers[0].getAttribute("locality");
					PropInfo["pincode"]			= markers[0].getAttribute("pincode");
					PropInfo["office_name"]		= markers[0].getAttribute("office_name");
					showAddress(PropInfo["provider_type"], PropInfo["provider_name"], PropInfo["phone_mobile"], PropInfo["city"], PropInfo["pincode"], PropInfo["locality"], PropInfo["office_name"]);
				}
				//createMarker(PropInfo);
			  }
	});
}



function showAddress(provider_type, provider_name, phone_mobile, city, pincode, locality, office_name) {
	var address	=	locality;
  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
		  //alert("Sorry, we were unable to find  " + address + ".");
		} else {
		  var lat = point.lat();
		  var lng = point.lng();
		  marker = new GMarker(point);
		  map.addOverlay(marker);
		  if (marker) map.removeOverlay(marker);
				window.setTimeout(function() {
		createMarker(point, provider_type, provider_name, phone_mobile, city, locality, office_name);
//map.openInfoWindow(point,address);
//ew.openOnMarker(marker,html);
		});
	}
	});
}
}
//=====================Creates the image on the map===============================================
	function createMarker(point, provider_type, provider_name, phone_mobile, city, locality, office_name) {
		
		var html	=	"";
        var marker = new GMarker(point, customIcons['location']);
		html = "<table cellpadding='0' cellspacing='0' border='0' style='font-size:12px; border:1px solid #6AA900;' width='200'><tr><td align='center' style='font-size:12px; border-bottom:1px solid #6AA900;'>"+office_name+"</td><td style='font-size:12px; border-bottom:1px solid #6AA900;'><a href='javascript:ew.hide()'><img width='11' height='11' title='Close' src='/templates/default/images/close.jpg' border=0 style='position:absolute;right:4px;top:4px'></a></td></tr><tr><td colspan='2' style='font-size:12px;' align='center'> "+provider_type+"</td></tr><tr><td align='center' colspan='2'><span style='color:green;font-size:12px;'>"+ locality+"<br>"+city+"</span></td></tr></table>"; 

	  map.addOverlay(marker);
	   ew.openOnMarker(marker,html);
	   //map.panTo(new GLatLng(point.lat(),point.lng()),13);
	    map.panTo(new GLatLng(point.lat(),point.lng()+0.026),13);
	  //map.openInfoWindow(point, html);
	
	  GEvent.addListener(marker,"click", function() {
          //marker.openInfoWindowHtml(html);
		  ew.openOnMarker(marker,html);
//map.panTo(new GLatLng(point.lat(),point.lng()),13);
 map.panTo(new GLatLng(point.lat(),point.lng()+0.026),13);
	
        });
			  

GEvent.addListener(marker, "click", function(overlay,point) {
        if (!overlay) {
          ew.hide();
        }
      });
    }	

function Locate(lat,lng,property_id,property_code,property_type,availability,city)
{
		//alert(lat);alert(lng);
	var point = new GLatLng(lat,lng);
if (marker) { map.removeOverlay(marker); } else { 
	 var marker = new GMarker(point, customIcons['bar']); }
      //var html = "<b>" + point.lat() + "</b> <br/><br/><br/>" + point.lng();
	  var url = '<a href="/property/viewproperty/?property_id='+property_id+'" target="_blank" style="text-decoration:none;font-weight:bold;color:#4C7100;font-size:12px;" onclick="javascript:window.open(\'/property/viewproperty/?property_id='+property_id+'\',\'view prop details\',\'width=830px,height=900px,scrollbars=yes\');return false;">'+property_code+'</a>';

		var html = "<table cellpadding='0' cellspacing='0' border='0' style='font-size:12px; border:1px solid #6AA900;' width='200'><tr><td align='center' style='font-size:12px; border-bottom:1px solid #6AA900;'>"+url+"</td><td style='font-size:12px; border-bottom:1px solid #6AA900;'><a href='javascript:ew.hide()'><img width='11' height='11' title='Close' src='/templates/default/images/close.jpg' border=0 style='position:absolute;right:4px;top:4px'></a></td></tr><tr><td colspan='2' style='font-size:12px;' align='center'>For "+PropInfo["property_type"]+"</td></tr><tr><td align='center' colspan='2'><span style='color:green;font-size:12px;'>"+ PropInfo["availability"]+"<br>"+PropInfo["city"]+"</span></td></tr></table>"; 

	  //var html = "<table width='100%' cellspacing='1' cellpadding='4' bgcolor='#000000'><tr><td class='green1' nowrap>Property Code</td><td class='green2'>"+property_code+"</td></tr><tr><td class='green1'>Property Type</td><td class='green2'>"+property_type+"</td></tr><tr> <td class='green1'>Availability</td><td class='green2' nowrap>"+availability+"</td></tr><tr><td class='green1'>City</td><td class='green2'>"+city+"</td></tr></table>";
	  map.addOverlay(marker);
	   ew.openOnMarker(marker,html);
	   var lngP	=	eval(lng) + eval(0.026);
	   map.panTo(new GLatLng(point.lat(),lngP),13);

	   GEvent.addListener(marker,"click", function() {
          //marker.openInfoWindowHtml(html);
		  ew.openOnMarker(marker,html);
//map.panTo(new GLatLng(point.lat(),point.lng()),13);
 map.panTo(new GLatLng(eval(point.lat()),eval(point.lng())+0.026),13);
	
        });


}
