	var sLongitude = '';
	var sLatitude = '';
	var sAddress = '';
	var geocode = new GClientGeocoder();
    var map = null;
    var geocoder = null;
	if (location.search){
var vals=location.search.substr(1).split("&");
var request= new Array();

for (var i in vals) {
vals[i] = vals[i].replace(/\+/g, " ").split("=");
request[unescape(vals[i][0])] =unescape(vals[i][1]);
}
}
var city = request["City"]
var state = request["state"]
var sDistance = request["Distance"]
var CategoryId = request["categoryid"]
var rc = request["rc"]
if (sDistance == undefined) {
	sDistance = '30'
	}

	//var city = document.location.search.substring(1);
	//b=new Array();
	//b=city[1].split('=');
window.onload = function() {
	// Create new map object
	
	StartUp();
}	
	
function GetLonLat(searchid) { 
	geocode.getLocations(searchid, addpoint); 
}

function addpoint(results){
	var place;
	var errcode;
		if(results.Status.code != 200){
			//alert(results.Status.code)
			window.location = "/SearchCompany.asp?msg=Not Found";
			return;
		}
	if(results.Status.code == 200) {
		/*
		http://www.google.com/apis/maps/documentation/reference.html#GGeoStatusCode
		G_GEO_SUCCESS (200) 	 No errors occurred; the address was successfully parsed and its geocode has been returned. (Since 2.55)
		G_GEO_SERVER_ERROR (500) 	A geocoding request could not be successfully processed, yet the exact reason for the failure is not known. (Since 2.55)
		G_GEO_MISSING_ADDRESS (601) 	The HTTP q parameter was either missing or had no value. (Since 2.55)
		G_GEO_UNKNOWN_ADDRESS (602) 	No corresponding geographic location could be found for the specified address. This may be due to the fact that the address is relatively new, or it may be incorrect. (Since 2.55)
		G_UNAVAILABLE_ADDRESS (603) 	The geocode for the given address cannot be returned due to legal or contractual reasons. (Since 2.55)
		G_GEO_BAD_KEY (610) 	The given key is either invalid or does not match the domain for which it was given. (Since 2.55)
		*/
		
		place = results.Placemark[0];
		sLongitude = place.Point.coordinates[0];
		sLatitude = place.Point.coordinates[1];
		try 
			{
			city = results.Placemark[0].AddressDetails.Country.AdministrativeArea.Locality.LocalityName
			}
		catch(err)
		{}

		
		if (sDistance == undefined)
			{
			sDistance = ''
			}
			if (rc == 'mobile')
				{
					window.location = "/Mobile/SearchCity.asp?City=" + city + "&state=" + state + "&sLatitude=" + sLatitude + "&sLongitude=" + sLongitude + "&distance=" + sDistance + "&categoryId=" + CategoryId
				}
				else
				{
					window.location = "CitySearch.asp?City=" + city + "&state=" + state + "&sLatitude=" + sLatitude + "&sLongitude=" + sLongitude + "&distance=" + sDistance + "&categoryId=" + CategoryId
				}
			
			}
			else
			{
			if (rc == 'mobile')
				{
					window.location = "/Mobile/"
				}
				else
				{
					window.location = "/CitySearch.asp?slongitude=error&Err=<strong><font style='color:red'>Please check Spelling</font></strong>&city=" + city + "&State=" + state 
				}
			}
		
	}
