var tip = 1;
var geo = new GClientGeocoder(new GGeocodeCache());
var reasons=[];
 reasons[G_GEO_SUCCESS]= "Success";
 reasons[G_GEO_MISSING_ADDRESS]= "Missing Address: The address was either missing or had no value.";
 reasons[G_GEO_UNKNOWN_ADDRESS]= "Unknown Address:  No corresponding geographic location could be found for the specified address.";
 reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
 reasons[G_GEO_BAD_KEY]= "Bad Key: The API key is either invalid or does not match the domain for which it was given";
 reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
 reasons[G_GEO_SERVER_ERROR]   = "Server error: The geocoding request could not be successfully processed.";


// ====== Geocoding ======
function showAddress(t) {
	t = typeof(t) != 'undefined' ? t : 0;
	var search = document.getElementById("search").value;
	geo.getLatLng(search, function (point) {
		if (point) {
			map.setCenter(point,9);
			if (t == 1) { // marker & POST form
				map.clearOverlays();
				addPostMarker(point);
			}
		} else { // ====== Decode the error status ======
			// ==Look to see if the query was cached ==
			var result=geo.getCache().get(search);
			if (result) {
				var reason="Code "+result.Status.code;
				if (reasons[result.Status.code]) {
					reason = reasons[result.Status.code]
				}
			} else {
				var reason = "";
			}
			alert('Could not find "'+search+ '" ' + reason);
		}
  });
}

function clearTip(o) {
	if (tip == 1) {
		o.value='';
		tip = 0;
	}
}
