
	var map = null;
    var geocoder = null;
	var gmarkers=[];
	
	var iconBlue = new GIcon(); 
	iconBlue.image= '/templates/default/images/home.png';
	//iconBlue.image = 'http://labs.google.com/ridefinder/images/mm_20_blue.png';
	iconBlue.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconBlue.iconSize = new GSize(24, 24);
	iconBlue.shadowSize = new GSize(22, 20);
	iconBlue.iconAnchor = new GPoint(6, 20);
	iconBlue.infoWindowAnchor = new GPoint(5, 1);
	var myMarker=iconBlue;

	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;
	
	var iconPink = new GIcon(); 
	iconPink.image = '/templates/default/images/mm_20_pink.png';
	iconPink.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconPink.iconSize = new GSize(24, 24);
	iconPink.shadowSize = new GSize(22, 20);
	iconPink.iconAnchor = new GPoint(6, 20);
	iconPink.infoWindowAnchor = new GPoint(5, 1);
	var myplace_Marker=iconPink;

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

	var iconGreen = new GIcon(); 
	//iconGreen.image = 'http://labs.google.com/ridefinder/images/mm_20_green.png';
	iconGreen.image='/templates/default/images/coffee.png';
	iconGreen.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconGreen.iconSize = new GSize(26, 17);
	iconGreen.shadowSize = new GSize(22, 20);
	iconGreen.iconAnchor = new GPoint(6, 20);
	iconGreen.infoWindowAnchor = new GPoint(5, 1);

	var iconRed = new GIcon(); 
	iconRed.image ='/templates/default/images/hospital.png';
	//iconRed.image = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
	iconRed.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconRed.iconSize = new GSize(19, 20);
	iconRed.shadowSize = new GSize(22, 20);
	iconRed.iconAnchor = new GPoint(6, 20);
	iconRed.infoWindowAnchor = new GPoint(5, 1);

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

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

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

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

	var iconBrown = new GIcon(); 
	//iconBrown.image = 'http://labs.google.com/ridefinder/images/mm_20_brown.png';
	iconBrown.image='/templates/default/images/restaurant.png';
	iconBrown.shadow = 'http://labs.google.com/ridefinder/images/mm_20_shadow.png';
	iconBrown.iconSize = new GSize(22, 21);
	iconBrown.shadowSize = new GSize(22, 20);
	iconBrown.iconAnchor = new GPoint(6, 20);
	iconBrown.infoWindowAnchor = new GPoint(5, 1);	
	<!-- End of Google icons-->

	<!-- This array is used to assign the icons for different landmarks -->
	var customIcons = [];
	customIcons["Restaurants"] = iconBrown;
	customIcons["Hotels"] = iconWhite;
	customIcons["Coffee Shops"] = iconGreen;
	customIcons["Theatres"] = iconPurple;
	customIcons["Schools"] = iconYellow;
	customIcons["Colleges"] = iconYellow;
	customIcons["Hospitals"] = iconRed;
	customIcons["Supermarket"] = iconOrange;
	customIcons["shop"] = iconYellow;
	customIcons["bar"] = iconBlue;
	customIcons["jewelleryshop"] = iconShop;
	customIcons["default"] = iconLocation;

	var PropInfo	=	[];
	var PropInfo1	=	[];

//=============================================================================================
			//Google Map Code for search pages
//=============================================================================================

   function initialize() {
	
      if (GBrowserIsCompatible())
	  {
        map = new GMap2(document.getElementById("map_canvas"));
		
		 // map.setMapType(G_DEFAULT_MAP_TYPES);
		map.addControl(new GMapTypeControl());
		
		//map.addControl(new GOverviewMapControl());
		map.addControl(new GLargeMapControl());
		//map.enableScrollWheelZoom();
		map.setCenter(new GLatLng(13.060416, 80.249634), 16);			
        map.setMapType(G_HYBRID_MAP);//satelitte view
        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");
		     var j="";
			  for (var i = 0; i < markers.length; i++) {				
				var property_id					= markers[i].getAttribute("property_id");
				PropInfo["property_code"]		= markers[i].getAttribute("property_code");
				PropInfo["property_type"]		= markers[i].getAttribute("property_type");
				PropInfo["property_sale_type"]	= markers[i].getAttribute("property_sale_type");
				PropInfo["plot_size"]			= markers[i].getAttribute("plot_size");
				PropInfo["expected_price"]		= markers[i].getAttribute("expected_price");
				PropInfo["city"]				= markers[i].getAttribute("city");
				PropInfo["location"]			= markers[i].getAttribute("locality");
				if ( markers[i].getAttribute("no_of_bedrooms") == null )
				{
					PropInfo["no_of_bedrooms"]		= "NA";
				}
				else
				{
					PropInfo["no_of_bedrooms"]		= markers[i].getAttribute("no_of_bedrooms");
				}
				PropInfo["availability"]		= markers[i].getAttribute("availability");
				
				PropInfo["property_category"]	= markers[i].getAttribute("property_category");
				var displayatMap	=	markers[i].getAttribute("display_at_map");
				 var point				= new GLatLng(parseFloat(markers[i].getAttribute("latitude")),
										parseFloat(markers[i].getAttribute("longtitude")));
				/* var point1				= new GLatLng(parseFloat(markers[0].getAttribute("latitude")),
										parseFloat(markers[0].getAttribute("longtitude")));
				 alert();*/
				 if ( displayatMap == "Yes" )
				 { 					 
					 //chelvam added here on on 280409
					 if(j=="")
					 {
						 j+=i
                     }
					 //chelvam end here
					 createMarker(point, property_id, PropInfo);
				 }
			   
			  
			 }			 
			 if (markers.length > 0)
			  {
				//chelvam changed here markers[j] instead of  markers[0] on 280409 .
					PropInfo1["property_code"]		= markers[j].getAttribute("property_code");
					PropInfo1["property_type"]		= markers[j].getAttribute("property_type");
					PropInfo1["property_sale_type"]	= markers[j].getAttribute("property_sale_type");
					PropInfo1["plot_size"]			= markers[j].getAttribute("plot_size");
					PropInfo1["expected_price"]		= markers[j].getAttribute("expected_price");
					PropInfo1["location"]			= markers[j].getAttribute("locality");
					if ( markers[j].getAttribute("no_of_bedrooms") == null )
					{
						PropInfo1["no_of_bedrooms"]	=	"NA"
					}
					else
					{
						PropInfo1["no_of_bedrooms"]		= markers[j].getAttribute("no_of_bedrooms");
					}
					PropInfo1["availability"]		= markers[j].getAttribute("availability");
					PropInfo1["city"]				= markers[j].getAttribute("city");
					PropInfo1["property_category"]	= markers[j].getAttribute("property_category");
					var displayatMap	=	markers[j].getAttribute("display_at_map");
					var point				= new GLatLng(parseFloat(markers[j].getAttribute("latitude")),
											parseFloat(markers[j].getAttribute("longtitude")));
					//createMarker(point, property_id, PropInfo);
					if ( displayatMap == "Yes" )
					{				   
						map.panTo(new GLatLng(parseFloat(markers[j].getAttribute("latitude")),parseFloat(markers[j].getAttribute("longtitude"))),15);
						createMarker(point, markers[j].getAttribute("property_id"), PropInfo1);
					}					  
			  }
			 
        });
}



function showAddress(address)
{
  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() {
		 
//map.openInfoWindow(point,address);
ew.openOnMarker(marker,html);

  map.panTo(new GLatLng(lat,lng),16);
		}, 1000);

			}
		});
	}
}
//=====================Creates the image on the map===============================================
	function createMarker(point, property_id, PropInfo)
	{
		var l="";
		if ( PropInfo["location"] == undefined && PropInfo["location"] == null)
		{
			l = PropInfo["city"];
		}
		else
		{
			l = PropInfo["location"];
		}
        var marker = new GMarker(point, customIcons['bar']);
		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;">'+PropInfo["property_category"]+" "+PropInfo["property_type"]+" for "+PropInfo["property_sale_type"]+'</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'>In "+l+"</td></tr><tr><td align='left' colspan='2'><span style='color:green;font-size:12px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Area :"+ PropInfo["plot_size"]+"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Price :"+PropInfo["expected_price"]+"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rooms :"+PropInfo["no_of_bedrooms"]+"</span></td></tr></table>"; 


     // var html = "<table width='100%' cellspacing='1' cellpadding='4' border='0' bgcolor='#000000'><tr><td class='green1' nowrap>Property Code</td><td class='green2'><a href='javascript:void(0);' onclick='javascript:window.open(/property/viewproperty/?property_id="+property_id+");'>"+PropInfo["property_code"]+"</a></td></tr><tr><td class='green1'>Property Type</td><td class='green2'>"+PropInfo["property_type"]+"</td> </tr>  <tr> <td class='green1'>Availability</td> <td class='green2' nowrap>"+PropInfo["availability"]+"</td> </tr><tr><td class='green1'>City</td><td class='green2'>"+PropInfo["city"]+"</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.004),16);
	  //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.004),16);
	
        });
			  

GEvent.addListener(marker, "click", function(overlay,point) {
        if (!overlay) {
          ew.hide();
        }
      });
    }	
//=-------------------------------------------------------------------------------------------------------------------------------
function Locate(lat, lng,property_id, property_code,property_type, availability,city,display_at_map, plot_size,no_of_bedrooms,expected_price,locality, property_category, property_sale_type)
{
		var l="";
		if ( locality == "")
		{
			l = city;
		}
		else
		{
			l = locality;
		}

		
		if ( display_at_map == "No")
		{
			alert("This property disabled from showing in map");
			return false;
		}
	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_category+" "+property_type+" for "+property_sale_type+'</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 "+l+"</td></tr><tr><td align='left' colspan='2'><span style='color:green;font-size:12px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Area :"+ plot_size+"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Price :"+expected_price+"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rooms :"+no_of_bedrooms+"</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.002);
	   map.panTo(new GLatLng(point.lat(),lngP),16);

	   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.004),16);
	
        });


}
//====================Ends Here===================================================================
//=============================================================================================
			//Google Map Code for view plot
//=============================================================================================

function initialize_plot() {
      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(18.060416, 85.249634+0.004), 16);	
		map.setMapType(G_HYBRID_MAP);//satellite view
        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);

		showPlot();

      }
    }
function showPlot()
{
 var frm		=	document.viewpropertymap;
 var property_id		=	frm.property_id.value;
 GDownloadUrl("/property/google/?act=getPlot&property_id="+property_id, function(data) {
		  var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
			  for (var i = 0; i < markers.length; i++) {

				var property_id = markers[i].getAttribute("property_id");
				PropInfo["property_code"]		= markers[i].getAttribute("property_code");
				PropInfo["property_type"]		= markers[i].getAttribute("property_type");
				PropInfo["property_sale_type"]		= markers[i].getAttribute("property_sale_type");
				PropInfo["plot_size"]			= markers[i].getAttribute("plot_size");
				PropInfo["expected_price"]		= markers[i].getAttribute("expected_price");
				PropInfo["location"]			= markers[i].getAttribute("locality");
				if ( markers[i].getAttribute("no_of_bedrooms") == null )
				{
					PropInfo["no_of_bedrooms"]		= "NA";
				}
				else
				{
					PropInfo["no_of_bedrooms"]		= markers[i].getAttribute("no_of_bedrooms");
				}
				PropInfo["availability"]		= markers[i].getAttribute("availability");
				PropInfo["city"]				= markers[i].getAttribute("city");
				PropInfo["property_category"]	= markers[i].getAttribute("property_category");
				
			  }

			  if (markers.length > 0)
			  {
			  var point = new GLatLng(parseFloat(markers[0].getAttribute("latitude")),
										parseFloat(markers[0].getAttribute("longtitude")));
				
				//map.panTo(new GLatLng(parseFloat(markers[0].getAttribute("latitude")),parseFloat(markers[0].getAttribute("longtitude"))),13);
				frm.lat.value	=	parseFloat(markers[0].getAttribute("latitude"));
				frm.lng.value	=	parseFloat(markers[0].getAttribute("longtitude"));	
				var displayatMap	=	markers[0].getAttribute("display_at_map");
				if ( displayatMap == "Yes" )
				{
					createMarker(point, property_id, PropInfo);
				}
				
			  }
        });
}

function showPolylineAddress(address1) {
	var address	=	address1+",India";
 if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
				//map.setCenter(point, 13);
				 map.panTo(new GLatLng(point.lat(),point.lng()+0.004),16);
				var frm		=	document.viewpropertymap;
			  var marker = new GMarker(point);
		var polyline = new GPolyline([
					  new GLatLng(frm.lat.value, frm.lng.value, 16),
					  new GLatLng(point.lat(),point.lng(), 16)
					], "#ff0000", 13);
				//frm.lat.value	=	point.lat();
				//frm.lng.value	=	point.lng();			
					map.addOverlay(polyline);
					createMarkerPlot(point,address);
						  }
          }
        );
      }
}

function createLandMarks(landmarkType)
{
		var lmk=landmarkType;
		var urlLM	=	"/property/google/?act=genLM&find="+lmk;
	if (document.getElementById(""+landmarkType+"").checked == true) 
	{ 	
		GDownloadUrl(urlLM, function(data) {
		  var xml = GXml.parse(data);
          var markers = xml.documentElement.getElementsByTagName("marker");
		  for (var i = 0; i < markers.length; i++) {

			var name = markers[i].getAttribute("name");
			var address = markers[i].getAttribute("address");
			var type = markers[i].getAttribute("type");
			if(type == lmk)
			{
				var point = new GLatLng(parseFloat(markers[i].getAttribute("latitude")),
										parseFloat(markers[i].getAttribute("longtitude")));
				var lmarker = createMarkerPlot(point,address, type);
				gmarkers.push(lmarker);	
				lmarker.type=lmk;											
				map.addOverlay(lmarker);
				
			}
		  }			
		});	
	}else
	{
		for (var i=0; i< gmarkers.length; i++) 
		{
			 if (gmarkers[i].type==lmk)  
			 {
				map.removeOverlay(gmarkers[i]);
				map.closeInfoWindow(gmarkers[i]);
				ew.hide();

			 }
      	}
	}
}

function createMarkerPlot(point, address, type) {
	
	if ( type == ""  )
	{
		var pointImg	=	customIcons['default'];
	}
	else
	{
		var pointImg	=	customIcons[type];
	}
      var marker = new GMarker(point, pointImg);
	  var html = "<div style='width:300px;border:1px solid #000000'>"+address+"</b></div>";
	  map.addOverlay(marker);
	  ew.openOnMarker(marker,html);
	 // 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()+0.004),16);
        });

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



return marker;

    }
//====================Ends Here===================================================================