/*
 * jQuery + Google API Location example
 * Mikael Korpela | http://www.ihminen.org
 * http://www.ihminen.org/file/examples/jquery_and_google_location.htm
 * 26. August 2008
 */

$(document).ready(function(){
	// If input is empty and google can found location...
	if( $("input#city").attr("value") == "" && google.loader.ClientLocation.address.city) {
		// Set suggested city
		var locationCity = google.loader.ClientLocation.address.city;
		$("span#clientLocation_city_name").text(locationCity);
		// Show question
		$("#clientLocation_city").show();
		// If user confirms
		$("a#clientLocation_city_confirm").click(function () {
			// Set input value
			$("input#city").attr("value",locationCity);
			// Hide question
			$("#clientLocation_city").fadeOut("slow");
			return false;
		});
	}
}); 
