	var sLongitude = '';
	var sLatitude = '';
	var sAddress = '';
	var zipcode = '';
	var sdistance = '';
	var catid = '';
	var state = '';
	var city = '';
	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 = document.location.search.substring(1);
	//b=new Array();
	//b=city[1].split('=');
window.onload = function() {
	// Create new map object
	
	StartUp();
}	
	
function GetLonLat(searchid, ZipCode, CatId, Distance) { 
	zipcode = ZipCode
	catid = CatId
	sdistance = Distance
	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];
		
//		place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName
		
		try 
			{
			city = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName
			state = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;
			}
		catch(err)
		{}
			var varwString = "/UpdateInfo.asp?ZipCode=" + zipcode + "&sLatitude=" + sLatitude + "&sLongitude=" + sLongitude + "&distance=" + sdistance + "&categoryId=" + catid + "&cityname=" + city + "&statecode=" + state
				window.location = varwString
	}
}
