var geocoder,zipcode,country="US",countryCode="US";
function validate(a){var b=jQuery.trim(a.what.value);a=a.where.value.replace(" ","");if(b==""){$("#what").animate({opacity:0},200).animate({opacity:1},200).focus();return false}else if(a=="")return locationInvalid();else if((country=="US"||country=="Germany")&&!isNumeric(a))return locationInvalid();if(zipcode){console.log("zipcode is somehow non-null:",zipcodea);return true}else{geocoder.getLocations(a+", "+country,rcvdGeoResponse);return false}}
function isNumeric(a){return!isNaN(parseInt(a))&&isFinite(a)}function locationInvalid(){$("#where_under").addClass("error").text("need a valid postal code in "+country);$("#where").select().focus().animate({opacity:0},200).animate({opacity:1},200);return false}
function rcvdGeoResponse(a){var b={};if(a.Status.code==200){flattenAddress.call(b,a.Placemark[0]);if(b.CountryNameCode!=countryCode||typeof b.PostalCodeNumber=="undefined")return locationInvalid();zipcode=b.PostalCodeNumber;$("#lat").val(a.Placemark[0].Point.coordinates[1]);$("#lon").val(a.Placemark[0].Point.coordinates[0]);$("#country").val(b.CountryNameCode);$("#search form").submit()}else return locationInvalid()}
function flattenAddress(a,b){if(b==null||isNaN(b))b=1;else if(b==10)return;b++;for(var c in a)if(typeof a[c]!="object"||a[c]instanceof Array)this[c]=a[c];else flattenAddress.call(this,a[c],b)}
function countryClicked(a){var b=a.target;a=$(b);if(!(!b||b.tagName!="A")){a.blur();$("#where").focus();country=b.innerHTML;countryCode=a.parent().attr("country");b=$("#countries span.chosen").attr("country");$("#where_under").removeClass("error").html("postal code ("+country+")");$("#countries span.chosen").removeClass("chosen").wrapInner('<a href="#'+b+'" />');a.parent().addClass("chosen").html(country)}}
function rdy(){if(ie6||ie7)$("#warning").html("You are running an older browser and may experience problems using Flippity.<br />You should really upgrade to <a target='_blank' href='http://www.google.com/chrome'>Google Chrome</a> or <a target='_blank' href='http://www.firefox.com'>Mozilla Firefox</a> !").show();zipcode=null;$("#what").focus();$("#countries").click(countryClicked);if(window.location.hash!=""){var a=window.location.hash.substr(1);a=$("#countries span[country="+a+"]");if(a.length==
1){countryClicked({target:a.children("a:first")[0]});$("#what").focus()}}google.load("maps","2",{callback:function(){geocoder=new GClientGeocoder}})}$(document).ready(rdy);

