YP.Geolocation={};YP.Geolocation.CURR_LOC="Current Location";YP.Geolocation.IMG_SIZE=23;YP.Geolocation.REGION={};
YP.Geolocation.provide_loc=function(a){if(a&&a.coords){$("#lat").val(a.coords.latitude);$("#long").val(a.coords.longitude);
$("#place_input").val(YP.Geolocation.CURR_LOC).css("color","blue").keydown(YP.Geolocation.check_location_input).removeClass("geolocate").addClass("geolocated");
}};YP.Geolocation.check_location_input=function(a){if(!a){a=window.event;}if(!a){return false;}if((a.keyCode==127||a.keyCode==8||a.keyCode==46)&&($("#place_input").val()==YP.Geolocation.CURR_LOC)){$("#place_input").val("");
}$("#place_input").css("color","black").unbind("keydown");YP.Geolocation.set_loc();return false;};YP.Geolocation.set_loc=function(){var a=$("#place_input");
if(a.val()!=YP.Geolocation.CURR_LOC&&a.val()!=YP.DEFAULT_WHERE){$("#lat").val("");$("#long").val("");
a.css("color","black").click(YP.Geolocation.click_event).removeClass("geolocated").addClass("geolocate");
}};YP.Geolocation.find_loc=function(){if(navigator&&navigator.geolocation){var a=$("#place_input");var b=$("#place_input").position();
YP.Geolocation.REGION={miny:parseInt(b.top),minx:parseInt(b.left)};YP.Geolocation.REGION.maxy=YP.Geolocation.REGION.miny+YP.Geolocation.IMG_SIZE;
YP.Geolocation.REGION.maxx=YP.Geolocation.REGION.minx+YP.Geolocation.IMG_SIZE;a.click(YP.Geolocation.click_event).addClass("geolocate");
if(a.val()&&a.val()!=YP.DEFAULT_WHERE){return false;}YP.Geolocation.find_my_location();}};YP.Geolocation.find_my_location=function(){navigator.geolocation.getCurrentPosition(function(a){YP.Geolocation.provide_loc(a);
},function(){$("#place_input").removeClass("geolocate").removeClass("geolocated");});};YP.Geolocation.click_event=function(c){if(!c){var c=window.event;
}if(c.type!="click"){return false;}var a;if(c.target){a=c.target;}else{if(c.srcElement){a=c.srcElement;
}}if(a.nodeType==3){a=a.parentNode;}if(a.id!="place_input"){return false;}var d=c.pageX;var b=c.pageY;
if((d>=YP.Geolocation.REGION.minx&&d<=YP.Geolocation.REGION.maxx)&&(b>=YP.Geolocation.REGION.miny&&b<=YP.Geolocation.REGION.maxy)){YP.Geolocation.find_my_location();
}};$(document).ready(YP.Geolocation.find_loc);
