//<![CDATA[	
	var map;
	var geocoder = null;
	var container;
	
	var tooltip;
	var clusterer;
	var om;
	var lastmarker;
	var dbClickFlag = false;
	var catFlag = false;
	var searchonmap = false;
	var showFlag = 'no';
	var baseIcon;
	var newIcon;
	var hMarker;
	var sel_marker;
	var center_marker = null;

	var accuracyToZoomLevel = [
		1,  // 0 - Unknown location
		5,  // 1 - Country
		6,  // 2 - Region (state, province, prefecture, etc.)
		8,  // 3 - Sub-region (county, municipality, etc.)
		11, // 4 - Town (city, village)
		13, // 5 - Post code (zip code)
		15, // 6 - Street
		16, // 7 - Intersection
		17 // 8 - Address
	];


	var locator = {
		vars:{
			map:false,
			gmarkers: [],
			mType : 0,
			centerPoint : false,
			minZoomLevel: 1,
			maxZoomLevel: 17
		},
		pars: {
			address: false,
			operation:'radiusSearch',
			lat:false,
			lon:false,
			radius:false
		},
		cords:{
			x:[],
			y:[]
		}
	}

	// Initialisation function
    function load() 
	{
		var page = "";
		var mapchange = "";

		if ($("hidMapPage"))
		{
			page = $("hidMapPage").value;
		}
		if($('hidMapChange'))
		{
			mapchange = $('hidMapChange').value;
		}
			
		if($("map"))
		{
			if (GBrowserIsCompatible()) 
			{
				container = $("map");
				//Default center point
				//locator.vars.centerPoint = new GLatLng(43.834526782236814, -37.265625);
				locator.vars.centerPoint = new GLatLng(20,1);

				map = new GMap2(container);
				
				map.setCenter(locator.vars.centerPoint, 3);
				map.setMapType(map.getMapTypes()[locator.vars.mType]);
				map.addControl(new GLargeMapControl());
				map.addControl(new GScaleControl());
				map.addControl(new GOverviewMapControl());
				map.enableScrollWheelZoom();
				//locator.vars.map = map;
				
				
				baseIcon = new GIcon();
				baseIcon.iconSize = new GSize(16,31);
				//baseIcon.shadowSize = new GSize(49.0, 32.0);
				baseIcon.iconAnchor = new GPoint(0.0, 29.0);
				baseIcon.infoWindowAnchor = new GPoint(16.0, 16.0);

				newIcon = new GIcon();
				newIcon.iconSize = new GSize(28,61);
				newIcon.iconAnchor = new GPoint(0.0, 59.0);
				newIcon.infoWindowAnchor = new GPoint(16.0, 16.0);

				om = new OverlayMessage(container);

				var address = trim(countryname+ " " + cityname) ;
				
				var clientobjectid = $('hidclientobjectid').value;
				var cityid = $('hidcityid').value;	
				var countryid = $('hidcountryid').value;

				/*if (countryid != "" && cityid != "")
				{
					locator.vars.maxZoomLevel = 11;
					locator.vars.minZoomLevel = 1;
				}
				else if (countryid != "" && cityid == "")
				{
					locator.vars.maxZoomLevel = 5;
				}*/
							
				//alert(clientobjectid+"---"+cityid+"---"+countryid);

				//This is the case when we are listing objects via default 20 search results/Fav page results
				if (clientobjectid != "" && (cityid == "" && countryid == ""))
				{
					var searchUrl = 'search=mapview'+'&clientobjectid='+ clientobjectid +'&countryid='+countryid +'&cityid='+cityid +'&show=yes'+'&page='+page +'&mapchange='+mapchange;
					
					locatorService( 'areasearch.php',searchUrl,showList);
				}
				else
				{
					//alert(address)
					var geocoder = new GClientGeocoder();
					if (geocoder) 
					{
						geocoder.getLatLng(address,function(point) {
							if (!point) {
								//'We\'re having trouble locating this address. Try one of the following search tips: <ul style="padding-left:20px;"><li>Double-check the spelling or try varying the spelling of your location.</li><li>Make sure you have the correct City, State or ZIP code associated with your location.</li><li>Make sure you use one of the following formats for searching:<br /> -Street Address, City, State<br /> -City, State<br /> -ZIP Code</li></ul>'
							   return false;
							} 
							else 
							{
								locator.pars.lat = point.lat();
								locator.pars.lon = point.lng();
								map.panTo(point);
																
								om.Set('<span class="grey_text_dark"><b>'+  LBL_LOADING +'...</b></span>');
								//OverlayMessage.SetBorderColor( "red" );
								
								//if(countryid != "")
								//{
									var searchUrl = 'search=mapview'+'&clientobjectid='+ clientobjectid +'&countryid='+countryid +'&cityid='+cityid + '&known=' + point.toUrlValue()+'&show=yes'+'&page='+page+ '&mapchange='+mapchange;
									locatorService( 'areasearch.php',searchUrl,showList);
								//}
							}
						
						});


					}
				}

				//var searchUrl = 'search=mapview'+'&clientobjectid='+ clientobjectid +'&countryid='+countryid +'&cityid='+cityid ;
				//om.Set('<span class="grey_text_dark"><b>'+  LBL_LOADING +'...</b></span>');
				//locatorService( 'areasearch.php',searchUrl,showList);


				//Create a Clusterer object, passing it your map object
				/*clusterer=new Clusterer(map);
				clusterer.SetIcon(clusterIcon);	
				clusterer.SetMaxVisibleMarkers(1);*/
					
				GEvent.addListener(map, "dragend", function() {
				
					center_marker = null;
					// Reset the Country-City listboxes
					resetSearchMenu();
					
					if($('hidMapChange'))
					{
						$('hidMapChange').value = "Y";
					}
						
					searchonmap = true;
					catFlag = true;
					showFlag = 'no';
					searchLocationsNear("");

				});

				GEvent.addListener(map, "zoomend", function(oldzoom,newzoom) {
					if (center_marker != null)
					{
						var mapzoom = map.getZoom();
						map.setCenter(center_marker.getLatLng(),mapzoom);
					}					
				});

			}
		}
		//resizePage();
	}
	
	function mapType(map,i)
	{
		map.setMapType(G_DEFAULT_MAP_TYPES[i]);
		adjustMapButtons(map);
	}

	function adjustMapButtons( map )
	{
		Element.removeClassName('cmap','text_orange')
		Element.removeClassName('csat','text_orange')
		Element.removeClassName('chybrid','text_orange')
		
		var type = map.getCurrentMapType().getName();
		if(type == 'Map')
		{
			Element.addClassName('cmap','text_orange')
		}
		else if(type == 'Satellite')
		{
			Element.addClassName('csat','text_orange')
		}
		else if(type == 'Hybrid')
		{
			Element.addClassName('chybrid','text_orange')
		}
	}

	function locatorService( url,pars,callBack ) 
	{		
			var ajax = new Ajax.Request(HOST+"/"+url, { 
				method: 'post', 
				parameters: encodeURI(pars), 
				onComplete: callBack
					
			});
	}
	
// Show the results obtained on the map	
	function showList( originalRequest ) 
	{
		if (om)
		{
			om.Clear();
		}
		
		var cobjid = "";
		var totalobjects = 0;
		//set cords arrays
		var cords = {y:[],x:[]};

		var xml = originalRequest.responseXML;
		var markers = xml.documentElement.getElementsByTagName('marker');
		
		/*04/05/09-10:51:07 AM Asif */
		//var clientobject_ids = xml.documentElement.getElementsByTagName('clientobjectids');
		//cobjid = clientobject_ids.item(0).firstChild.nodeValue;

		//clearMarkers();
		// For a initial search display total count of objects next to Show button
		if (xml.documentElement.getElementsByTagName('totalmarkers').length > 0 )
		{
			totalmarkers = xml.documentElement.getElementsByTagName('totalmarkers');
			totalobjects = totalmarkers.item(0).firstChild.nodeValue;
			$('searchcount').update(totalobjects);

			showtotalcount(totalobjects)
		}
		else
		{
			//Update the search result counter
			$('searchcount').update(markers.length);
		}

		//alert("markers.length>> "+markers.length + "-- totalmarkers" +totalobjects)

		if (showFlag == 'no' && totalobjects == 0)
		{
			if (dbClickFlag != true && SEARCH_SESSION != true && searchonmap != true)// on double click on map don't display error msg if 0 result found
			{
				alert(ERR_NO_SEARCH_RESULT);
				uncheckbox();
			}
			return;
		}
		else if(showFlag == 'yes' && markers.length == 0) 
		{
			if (dbClickFlag != true && SEARCH_SESSION != true && searchonmap != true)// on double click on map don't display error msg if 0 result found
			{
				alert(ERR_NO_SEARCH_RESULT);
				uncheckbox();
				
			}
			return;
		}
		
		//when draging the map now the pins should stay visible
		if (searchonmap != true)
		{
			clearMarkers();
		}
		
		if (catFlag)//When selecting categories dont perform map action till pressed at show button
		{
			return;
		}
		
		var bounds = new GLatLngBounds();
		for(var lcnt = 0;lcnt < markers.length; lcnt++) 
		{
			var objectname = markers[lcnt].getAttribute('name');
			var address = markers[lcnt].getAttribute('address');
			var city = markers[lcnt].getAttribute('city');
			var country = markers[lcnt].getAttribute('country');
			var clientobjectid = markers[lcnt].getAttribute('clientobjectid');
			var mainimage = (markers[lcnt].getAttribute('mainimage')== "" ?'picture_coming_soon.jpg':clientobjectid+"/"+markers[lcnt].getAttribute('mainimage'));
			
			var categoryid = markers[lcnt].getAttribute('categoryid');
			
			var addfldnamevalues = markers[lcnt].getAttribute('addfldnamevalues');
			
			/* Code spec to find out stars*/
			var starCount = 0;
			if (addfldnamevalues != "")
			{		
				var starPos = false;
				/*if (strripos(addfldnamevalues, 'star#') != false)
				{
					starPos = strripos(addfldnamevalues, 'star#') - 1;
				}
				else if (strripos(addfldnamevalues, 'stars#') != false)
				{
					starPos = strripos(addfldnamevalues, 'stars#') - 1;
				}
				var length = starPos - strripos(addfldnamevalues, '#classification');

				var str = substr( addfldnamevalues, strripos(addfldnamevalues, 'classification'), length);
				
				if (str != "")
				{
					var arrClassification = str.split("=");
					starCount = arrClassification[1];
				}*/

				if (strripos(addfldnamevalues, 'classification') != false)
				{
					var arrClassification = addfldnamevalues.split("=");
					starCount = arrClassification[1].match(/[\d\.]+/g);
				}
			}
			// Remove leading and trailing ~ symbol
			categoryid = substr(categoryid,1,categoryid.length);
			categoryid = substr(categoryid,0,-1);
			
			//he GMap does not show more than one node that has the same lat/long information. In this case, it only shows the first volunteer opportunity listed
			//The GMap does not show more than one node that has the same zipcode
			var lat = parseFloat(markers[lcnt].getAttribute("lat")); 
			var lng = parseFloat(markers[lcnt].getAttribute("lng")); 
			var point = new GLatLng(lat,lng); 
			
			//var point = new GLatLng(parseFloat(markers[lcnt].getAttribute('lat')),parseFloat(markers[lcnt].getAttribute('lng')));
			
			bounds.extend(point);
			cords.y.push(point.lng());
			cords.x.push(point.lat());
			
			// Show details of the selected object as well as enlarge image for that object on the map
			if (lcnt == 0)
			{
				
				if ($('hidselclientobjectid') && $('hidselclientobjectid').value != "")
				{
					selclientobjectid = $('hidselclientobjectid').value;
				}
				else
				{
					selclientobjectid = clientobjectid;
				}
				
				if (searchonmap != true)
				{
					showDetails(selclientobjectid);
				}

			}

			
			//var marker = createMarker(point, objectname, clientobjectid , categoryid, selclientobjectid);
			var marker = createMarker(point, html_entity_decode(objectname,'ENT_QUOTES'), address, categoryid, mainimage,starCount,clientobjectid,city,country,selclientobjectid);
			map.addOverlay(marker);
			
			// Append the clientobjectid
			//cobjid = cobjid + "~" + clientobjectid;
			
			// If selected object then hide the small pin first
			if ($('hidselclientobjectid'))
			{
				var selclientobjectid = $('hidselclientobjectid').value;
				if (selclientobjectid == clientobjectid && searchonmap != true)
				{
					marker.hide();
					lastmarker = marker;
					sel_marker = marker;
					center_marker = marker;
				}
			}
			
			//clusterer.AddMarker(marker,objectname);
			/*
			// Append the clientobjectid
			cobjid = cobjid + "~" + clientobjectid;*/
		}
		
		//$('hidclientobjectid').value = substr(cobjid,1,cobjid.length);
		
		adjustToMarkers(map,cords);
	}
	
	// Create markers on the map 
	//function createMarker(point, objectname, clientobjectid , categoryid, selclientobjectid)
	function createMarker(point, objectname, address, categoryid, mainimage,starCount,clientobjectid,city,country,selclientobjectid)
	{
		
		var pinimage = "";
		var catIcon = "";
		var marker = "";
		var categoryidarr = "";
		var countrycitydetails = "";

		var categoryidarr = categoryid.split('~');
		pinimage = 'catgm_'+categoryidarr[0]+'.gif'; 
		catIcon = (new GIcon(baseIcon,"/images/"+pinimage,null,null));

		// Show big image for selected object in list view
		if (selclientobjectid == clientobjectid && searchonmap != true)
		{
			var hIcon = (new GIcon(newIcon,"/images/catbgm_"+categoryidarr[0]+".gif",null,null));
			hMarker = new GMarker(point,{icon:hIcon,title:objectname,zIndexProcess:importanceOrder});
			hMarker.importance = 2;
			map.addOverlay(hMarker);
			
			/*GEvent.addListener(hMarker, 'click', function(){
			sel_marker.show();
			hMarker.hide();
			});*/
		}
	
				
		marker = new GMarker(point,{icon:catIcon,title:objectname,zIndexProcess:importanceOrder});
		marker.importance = 1;
		
		countrycitydetails = "";

		if (city != "" && country != "")
		{
			countrycitydetails = city +","+ country;
		}
		else if (city != "" && country == "")
		{
			countrycitydetails = city;
		}
		else if (city == "" && country != "")
		{
			countrycitydetails = country;
		}
		
		var catimage = "";
		var starimage = "";

		var html = '<table width="194" border="0" align="center" cellpadding="0" cellspacing="0" style="cursor:hand;cursor:pointer;" onclick="javascript:showDetails('+clientobjectid+');closePopup();">'+
					'<tr>' +
					'<td bgcolor="#FFFFFF"><table width="180" border="0" align="center" cellpadding="0" cellspacing="0">' +
					 '<tr>' +
						'<td height="7"></td>' +
					  '</tr>' +
					  '<tr>' +
						'<td bgcolor="#EE7B18"><table width="160" border="0" align="center" cellpadding="0" cellspacing="0">' +
						  '<tr>' +
							'<td height="11" colspan="2"></td>' +
							'</tr>' +
						  '<tr>' +
							'<td width="138"><img src="/images/'+ mainimage +'" width="138" height="90" /></td>' +
							'<td width="22" valign="top" align="right">';

							for(i=0;i<categoryidarr.length;i++)
							{	
								catimage += '<div style="height:20px"><img src="/images/catsm_'+ categoryidarr[i] +'.gif" width="15" height="15" /></div>'
							}
					html += catimage +
							'</td>' +
						  '</tr>' +
						  '<tr>' +
							'<td height="10" colspan="2"></td>' +
						  '</tr>' +
						  '<tr>' +
							'<td colspan="2"><div align="left">';
								if (starCount != 0)
								{
									for(i=0;i<starCount;i++)
									{
										starimage += '<img src="images/star_trans_img.gif" width="15" height="13" />&nbsp;';
									}

								}
					html += starimage +	
							'</div></td>' +
							'</tr>' +
						  '<tr>' +
							'<td height="5" colspan="2"></td>' +
						  '</tr>' +
						  '<tr>' +
							'<td class="text_white_popup_bold" colspan="2">'+ objectname +'</td>' +
							'</tr>' +
						  '<tr>' +
							'<td height="5" colspan="2"></td>' +
						  '</tr>' +
						  '<tr>' +
							'<td class="text_white_popup_normal" colspan="2">'+ countrycitydetails +' </td>' +
							'</tr>' +
						  '<tr>' +
						'<tr>' +
							'<td colspan="2" height="8px"></td>' +
							'</tr>' +
						'</table></td>' +
					  '</tr>' +
					  '<tr>' +
						'<td height="7"></td>' +
					  '</tr>' +
					'</table></td>' +
				  '</tr>' +
				'</table>';
			

		GEvent.addListener(marker, 'click', function() {
			marker.openExtInfoWindow(
			  map,
			  "event_window",
			  html,
			  {beakOffset: 3}
			);	
			sel_marker = marker;
			center_marker = marker;
			/*try { map.removeOverlay(hMarker); } catch (e) {}
			try { lastmarker.show();}catch (e){}
			
			var curricon = marker.getIcon();
			var currimage = curricon.image;
			
			var currimgarr = currimage.split(".gif");

			var index = currimgarr[0].match(/[\d\.]+/g);

			var nIcon = (new GIcon(newIcon,"/images/catbgm_"+index+".gif",null,null));

			hMarker = new GMarker(marker.getPoint(),{icon:nIcon,title:marker.getTitle(),zIndexProcess:importanceOrder});
			hMarker.importance = 2;
			map.addOverlay(hMarker);

					
			//alert("Marker>"+marker.getTitle()+" -- "+"LastMarker>"+(lastmarker?lastmarker.getTitle():''))

			lastmarker = marker;
			marker.hide();*/
			
			//showDetails(clientobjectid);
		
		});
		
		locator.vars.gmarkers.push(marker);
		return marker;
    }

	function importanceOrder (marker,b) 
	{
        return GOverlay.getZIndex(marker.getPoint().lat()) + marker.importance*1000000;
    }
	
	function closePopup()
	{
		map.closeExtInfoWindow();
		
		try { map.removeOverlay(hMarker); } catch (e) {}
		try { lastmarker.show();}catch (e){}
		
		var curricon = sel_marker.getIcon();
		var currimage = curricon.image;
		
		var currimgarr = currimage.split(".gif");

		var index = currimgarr[0].match(/[\d\.]+/g);

		var nIcon = (new GIcon(newIcon,"/images/catbgm_"+index+".gif",null,null));

		hMarker = new GMarker(sel_marker.getPoint(),{icon:nIcon,title:sel_marker.getTitle(),zIndexProcess:importanceOrder});
		hMarker.importance = 2;
		map.addOverlay(hMarker);

		GEvent.addListener(hMarker, 'click', function(){
			sel_marker.show();
			hMarker.hide();
		});		
		
		//alert("Marker>"+marker.getTitle()+" -- "+"LastMarker>"+(lastmarker?lastmarker.getTitle():''))

		lastmarker = sel_marker;
		sel_marker.hide();

		/*Make the map centrate at this pin*/
		//var zoom = map.getZoom();
		//map.checkResize();
		//map.setCenter(sel_marker.getPoint(),zoom);
	}

	//Clear all existing markers from the map
	function clearMarkers()
	{
		try { map.removeOverlay(hMarker); } catch (e) {}
		
		if(locator.vars.gmarkers.length>0)
		{
			while(locator.vars.gmarkers.length>0)
			{
				var marker = locator.vars.gmarkers.shift();
				//map.removeOverlay(marker);
				GEvent.clearListeners( marker, "click" ); 
			    marker = null; 
				//clusterer.RemoveMarker(locator.vars.gmarkers.shift());
			}
			map.clearOverlays();
		}
		locator.vars.gmarkers = [];
		center_marker = null;
	}
	
	//Function to get active cities of the country onchange of the country select
	function searchCountryCity( objSelect)
	{
		var radius = ($('delieveryradius').selectedIndex != 0 ? $('delieveryradius').value : "");

		//Reset the search by map flag to false
		searchonmap = false;
		showFlag = 'no';

		//Reset the city list box
		$('cityid').selectedIndex = 0;
		if ($('hidcountryname'))
		{
			$('hidcountryname').value = "";
			$('hidcityname').value = "";
		}

		if (objSelect.selectedIndex != 0) 
		{
			
			var contryResult = objSelect.value.split("~");    
			var countryid = contryResult[0]; 
			var countrycode = contryResult[1]; 
			var countrycont = contryResult[2]; 
			var params = 'search=getAciveObjCityList&countryid='+ countryid;
			
			// If the current page is index page
			if ($('hidcountryid') && (typeof map != 'undefined'))
			{
				zoomtoCountryCity();
				clearMarkers();
				catFlag = true;
				searchLocations();
			}
			else
			{
				//If search is fired from other pages then simply update the result since Gmap is not available
				catFlag = true;
				searchUrl = '&searchtype=bymenusearch'+'&radius='+radius + '&search=address'+'&countryid='+countryid +'&show='+showFlag;
				locatorService( 'areasearch.php',searchUrl,showList);
			}
			
			if($('hidMapChange'))
			{
				$('hidMapChange').value = "Y";
			}
			
			if($('hidselclientobjectid'))
			{
				$('hidselclientobjectid').value = "";
			}
			
			getActiveCity(params);
		}
	}
	
	// Function to get active city list on selection of country
	function getActiveCity( params)
	{		
		var rand   = Math.random(9999);
		var url    = HOST+'/areasearch.php?ms='+rand ;
		var pars   = params;
		var userAjax = new Ajax.Request( url, {
				method: 'post', 
				parameters: pars, 
				onComplete: function( originalRequest )
				{	
					var response = originalRequest.responseXML;
					var doc = response.documentElement;
					var city = doc.getElementsByTagName('city');
					
					// Clear the city select 
					clearSelection ( $('cityid') );

					$('cityid').options[0] = new Option(LBL_SELECT_CITY+"...","");
						
					for (var i=0; i< city.length; i++)
					{
						var cityid = city[i].getElementsByTagName("cityid").item(0).firstChild.nodeValue;
						var languageid = city[i].getElementsByTagName("languageid").item(0).firstChild.nodeValue;
						var cityname = city[i].getElementsByTagName("name").item(0).firstChild.nodeValue;
						$('cityid').options[i+1] = new Option(cityname,cityid);
					}
				}
		} );
	}
	
	// Function to zoom the GMap
	function zoomtoCountryCity()
	{
		var address = "";
		var country = "";
		var city = "";
		var zoom = 3;
		var countryid = "";
		var cityid = "";
		var radius = ($('delieveryradius').selectedIndex != 0 ? $('delieveryradius').value : "");
		//Reset the search by map flag to false
		searchonmap = false;
		showFlag = 'no';

		clearMarkers();

		if ($('countryid').selectedIndex != 0) 
		{
			var contryResult = $('countryid').value.split("~");    
			countryid = contryResult[0]; 

			/*var countrycode = contryResult[1]; 
			var countrycont = contryResult[2]; */

			country = ($('countryid').value != "" ? $('countryid').options[$('countryid').selectedIndex].text: "");
			
			if ($('hidcountryname'))
			{
				$('hidcountryname').value = country;
			}

			zoom = 1;
		}
		if ( $('cityid').selectedIndex != 0 )
		{
			city = ($('cityid').value != "" ? $('cityid').options[$('cityid').selectedIndex].text: "");	
			cityid = $('cityid').value;
			zoom = 3;
			
			if (typeof map != 'undefined')
			{
				catFlag = true;
				searchLocations();
			}
			else
			{
				//If search is fired from other pages then simply update the result since Gmap is not available
				catFlag = true;
				searchUrl = '&searchtype=bymenusearch'+'&radius='+radius + '&search=address'+'&countryid='+countryid +'&cityid='+cityid +'&show='+showFlag;
				locatorService( 'areasearch.php',searchUrl,showList);
			}

			
			if ($('hidcountryname'))
			{
				$('hidcityname').value = city;
			}
			
			if($('hidselclientobjectid'))
			{
				$('hidselclientobjectid').value = "";
			}
		}
		
		// If the current page is index page
		
		if ($('hidcountryid') && (typeof map != 'undefined'))
		{		
			// Assign country & city values
			$('hidcountryid').value = countryid;
			$('hidcityid').value = cityid;

			address = trim(country +" "+ city);
			zoomTo(map,address,zoom);
		}
		else if ($('hidSearchMenuSubmit'))
		{
			// Assign search menu submit flag to y
			$('hidSearchMenuSubmit').value = 'Y';
		}
		dbClickFlag = false;
	}
	
	// Function to zoom to country or city whichever selected from search menu
	function zoomTo(map,address,locationtype)
	{
		var accuracy = locationtype;
		var zoomLevel = accuracyToZoomLevel[accuracy] || 1;

		var geocoder = new GClientGeocoder();
		if (geocoder) 
		{
			geocoder.getLatLng(address,
			  function(point) {
				if (!point) {
						//'We\'re having trouble locating this address. Try one of the following search tips: <ul style="padding-left:20px;"><li>Double-check the spelling or try varying the spelling of your location.</li><li>Make sure you have the correct City, State or ZIP code associated with your location.</li><li>Make sure you use one of the following formats for searching:<br /> -Street Address, City, State<br /> -City, State<br /> -ZIP Code</li></ul>'
					  //alert(ERR_WRONG_ADDRESS);
					  return false;
					} 
					else 
					{ 
						//load results in cache
						//cache.geo.recs.unshift({call:address,response:{lat:point.lat(),lon:point.lng()}});
						//check size of cache and remove if nessessary
						//if(cache.geo.recs.length> cache.geo.count) cache.geo.recs.pop();
						var maxZoomLevel = locator.vars.maxZoomLevel;
						var minZoomLevel = locator.vars.minZoomLevel;

						var bounds = new GLatLngBounds();
						bounds.extend(point);
						map.setZoom(zoomLevel);
						map.panTo(bounds.getCenter());
					}
			});
		}

	}

	// Adjust the zoom level of map according to results obtained
	function adjustToMarkers(map,cords) 
	{
		var maxZoomLevel = locator.vars.maxZoomLevel;
		var minZoomLevel = locator.vars.minZoomLevel;

		var n = cords.x.max() + .01;
		var e = cords.y.max() + .01;
		var s = cords.x.min() - .01;
		var w = cords.y.min() - .01;
		
		var sw = new GLatLng(s,w);
		var ne = new GLatLng(n,e);
		
		var bounds = new GLatLngBounds(sw,ne);
		var propZoom = map.getBoundsZoomLevel(bounds);
		
		if(propZoom>maxZoomLevel)
		{
			map.setZoom(maxZoomLevel)
		}
		else if(propZoom<minZoomLevel)
		{
			map.setZoom(minZoomLevel)
		}
		else{
		map.setZoom(propZoom)
		}
		
		map.panTo(bounds.getCenter())
			
		if (center_marker != null)
		{
			map.setCenter(center_marker.getLatLng(),map.getBoundsZoomLevel(bounds) - 1);
		}
	}
	
	// Default search diepslay 20 results when page first loads
	function defaultSearch()
	{
		var point = locator.vars.centerPoint;
		var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		
		var getVars = 'ne='+ northEast.toUrlValue() + '&sw=' + southWest.toUrlValue()+ '&known=' + point.toUrlValue();
		
		var searchUrl = getVars + '&search=defaultsearch';

		locatorService( 'areasearch.php',searchUrl,showList);
	}
	
	// function to resize the map on window resize
	function resizePage() 
	{
		var oTable = $("outerTable");
		
		//oTable.style.width = document.documentElement.clientWidth  + 'px';
		var veHeight = 100;
		//$("map").style.height = document.documentElement.clientHeight - veHeight  + 'px';
		$("map").style.height = oTable.clientHeight - veHeight  + 'px';
		if (map) 
		{
			var center = map.getCenter();
			var zoom = map.getZoom();
			map.checkResize();
			map.setCenter(center,zoom);
		}
	}

	// Function to unload GMap
	function unload() 
	{
		GUnload();
	}
	
	window.onload = function()
	{
		load();
	}
	
	function mapViewSearchLocationsNear(point)
	{
		var searchUrl = "";
		var knownPoint = "";
		
		var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		var getVars = 'ne='+ northEast.toUrlValue() + '&sw=' + southWest.toUrlValue()+ knownPoint;
		
		searchUrl = getVars + '&searchtype=bymapsearch' + '&search=address';
		locatorService( 'areasearch.php',searchUrl,showList);
	}
	
	// Function to find locations
	function searchLocations() 
	{
		$('hidclientobjectid').value = "";
		$('searchcount').update('0');
				
		if( ($('countryid').selectedIndex == 0) && !searchonmap && !catFlag)
		{
			alert(ERR_SEL_COUNTRY_CAT);
			return;
		}
		/*else if ($('cityid').selectedIndex == 0)
		{
			alert(ERR_SELECT_CITY);
			return;
		}
		else if ($('delieveryradius').selectedIndex == 0)
		{
			alert(ERR_SELECT_RANGE);
			return
		}
		else
		{*/
			
			if ($('countryid').selectedIndex != 0 )
			{
				var contryResult = $('countryid').value.split("~");    
				var countryid = contryResult[0]; 

				var countrycode = contryResult[1]; 
				var countrycont = contryResult[2]; 

				var country = ($('countryid').value != "" ? $('countryid').options[$('countryid').selectedIndex].text: "");
				var city = ($('cityid').value != "" ? $('cityid').options[$('cityid').selectedIndex].text : "");

				var address = trim(country+ " " + city) ;
				
				if (address == "")
				{
					return;
				}
				var geocoder = new GClientGeocoder();
				if (geocoder) 
				{
					//geocoder.setBaseCountryCode(countryCode);
					geocoder.getLatLng(address,
					  function(point) {
						if (!point) {
							//'We\'re having trouble locating this address. Try one of the following search tips: <ul style="padding-left:20px;"><li>Double-check the spelling or try varying the spelling of your location.</li><li>Make sure you have the correct City, State or ZIP code associated with your location.</li><li>Make sure you use one of the following formats for searching:<br /> -Street Address, City, State<br /> -City, State<br /> -ZIP Code</li></ul>'
						  alert(ERR_WRONG_ADDRESS);
						  return false;
						} 
						else 
						{ 
							//load results in cache
							//cache.geo.recs.unshift({call:address,response:{lat:point.lat(),lon:point.lng()}});
							//check size of cache and remove if nessessary
							//if(cache.geo.recs.length> cache.geo.count) cache.geo.recs.pop();
							
							locator.pars.lat = point.lat();
							locator.pars.lon = point.lng();
							om.Set('<span class="grey_text_dark"><b>'+  LBL_LOADING +'...</b></span>');
							searchLocationsNear(point);
						}
				  }
				);
			  }
			}
			else if (searchonmap)
			{
				om.Set('<span class="grey_text_dark"><b>'+  LBL_LOADING +'...</b></span>');
				searchLocationsNear('');
			}

		//}
	}
	
	function searchLocationsNear(point) 
	{
		var radius = ($('delieveryradius').selectedIndex != 0 ? $('delieveryradius').value : "");
		var contryResult = $('countryid').value.split("~");    
		var countryid = contryResult[0]; 
		var cityid = $('cityid').value;
		var knownPoint = "";
		var pars = "";
		var searchUrl = "";
		var page = "";
		var mapchange = "";

		if ($("hidMapPage"))
		{
			page = $("hidMapPage").value;
		}
		if($('hidMapChange'))
		{
			mapchange = $('hidMapChange').value;
		}

		
		if (point != "")
		{
			map.panTo(point);
			knownPoint = '&known=' + point.toUrlValue();
		}
		else if ( dbClickFlag == true) // if double clicked
		{
			knownPoint = '&known=' + dbPoint.toUrlValue();
			radius = DEF_RADIUS;
		}
		
		
		//var defMarker = createMarker(point, '','', '' ,'default');
		//map.addOverlay(defMarker);
		//clusterer.AddMarker(defMarker,'');
		
		
		var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		var getVars = 'ne='+ northEast.toUrlValue() + '&sw=' + southWest.toUrlValue()+ knownPoint;

		//var getVars = "right="+bounds.maxX+"&left="+bounds.minX+"&top="+bounds.maxY+"&bottom="+bounds.minY;
		
		if (searchonmap)
		{
			searchUrl = getVars + '&searchtype=bymapsearch' + '&search=address'+'&show='+showFlag+'&page='+page +'&mapchange='+mapchange;
		}
		else
		{
			var getVars = 'ne=&sw='+ knownPoint;
			searchUrl = getVars + '&searchtype=bymenusearch'+'&radius='+radius + '&search=address'+'&countryid='+countryid +'&cityid='+cityid+'&show='+showFlag+'&page='+page +'&mapchange='+mapchange;
		}
				
		locatorService( 'areasearch.php',searchUrl,showList);
	}
	
	// Function to get locations on click of Show button
	function showLocations()
	{
		if(typeof map == 'undefined')
		{
			gotoIndex();
		}
		
		catFlag  = false;
		
		SEARCH_SESSION = false;
		showFlag = 'yes';
		clearMarkers();
		searchLocations();
	}
	
	function resetSearchMenu()
	{
		$('countryid').selectedIndex = 0;
		//$('hidclientobjectid').value = "";
		$('hidcountryid').value = "";
		$('hidcityid').value = "";
		$('hidcountryname').value = "";
		$('hidcityname').value = "";
		$('hidselclientobjectid').value = "";
		clearSelection ( $('cityid') );
		$('cityid').options[0] = new Option(LBL_SELECT_CITY+"...","");
		$('delieveryradius').selectedIndex = 0;
	}
	
	//function to search locations on basis of delivery radius
	function searchInRadius()
	{
		//Reset the search by map flag to false
		searchonmap = false;
		showFlag = 'no';

		if ((($('countryid').selectedIndex != 0) || ($('cityid').selectedIndex != 0)) && (typeof map != 'undefined'))
		{
				clearMarkers();
				catFlag = true;
				searchLocations();
		}
	}

	
function showtotalcount(total)
	{	
		if($('displaySimpleImage') != null && $('displayGlowImage') != null )
		{
			if(total >= 100 )
				{
					$('displaySimpleImage').style.display = "none";
					$('displayGlowImage').style.display = "block";
					
				}
				else
				{
					$('displayGlowImage').style.display = "none";
					$('displaySimpleImage').style.display = "block";
				}
		}
		else
		{
		}
	}

	//]]>
//-->