function _reload_location_data(c,f,b){var a=$("#countylist").hasClass("allow_any")?1:0;var d=$("#citylist").hasClass("allow_any")?1:0;var e=$("#citylist").length>0?1:0;$.getJSON("/location_ajax.php",{country_id:c,county_id:f,city_id:b,anycounty:a,anycity:d,hascity:e},function(g){if(g[0]==""&&!a){$("#countylist").parents(".countyparent").fadeOut();$("#countylist").attr("disabled","disabled");$("#countylist").change()}else{$("#countylist").removeAttr("disabled");$("#countylist").html(g[0]);$("#countylist").change();$("#countylist").parents(".countyparent").show()}$("#citylist").html(g[1])})}$(document).ready(function(){$("#countrylist").change(function(){_reload_location_data($(this).val(),0,0)});_latitude_dest=$("#lat");_longitude_dest=$("#lng");_zoom_dest=$("#zoom");$("#google_map_btn_ok").click(function(){_latitude_dest.val(_new_latitude);_longitude_dest.val(_new_longitude);_zoom_dest.val(_new_zoom);var a=_new_zoom;if(!!$("#google_map_btn_open").data("minzoom")){a=$("#google_map_btn_open").data("minzoom")}if(a>_new_zoom){alert("For best results, please zoom in further, using the mousewheel or [+] button on the map.\n\nOnce zoomed, click the map to drop the pin in the exact location")}else{if($("#isdefaultmaploc").length==1){$("#isdefaultmaploc").val("0")}var b=_new_latitude.toString()+","+_new_longitude.toString();var c=_map_getimgurl(_new_latitude,_new_longitude,_new_zoom);$("#google_map_image").html('<img border="0" src="'+c+'">');$.unblockUI();$("#google_map_img_container").attr("display","inline");$("#google_map_img_container").fadeIn("slow")}});$("#google_map_btn_open").click(function(){if(!$("#google_map_container").is(":visible")){$.blockUI({message:$("#google_map_container")});_map_start()}});$("#google_map_btn_cancel").click(function(){$("#google_map_container").hide();$.unblockUI()})});function _map_getimgurl(b,c,a){return"http://maps.google.com/maps/api/staticmap?center="+b.toString()+","+c.toString()+"&zoom="+a.toString()+"&size=300x300&markers=color:red|label:My Location|"+b.toString()+","+c.toString()+" &sensor=false"}function _map_start(){if(typeof(_map)!="undefined"){_map_show_window();return}_new_latitude=_latitude_dest.val();_new_longitude=_longitude_dest.val();_new_zoom=_zoom_dest.val();var b;var a={mapTypeId:google.maps.MapTypeId.ROADMAP};var d=!(_latitude_dest.val()==""||_longitude_dest.val()==""||_zoom_dest.val()=="");if(d){var c=new google.maps.LatLng(_new_latitude,_new_longitude);a.zoom=parseInt(_new_zoom);a.center=c}else{a.zoom=8;a.center=new google.maps.LatLng(-34.397,150.644)}_map=new google.maps.Map($("#google_map").get(0),a);if(d){b=_map_create_marker(c)}google.maps.event.addListener(_map,"zoom_changed",function(){_new_zoom=_map.getZoom()});google.maps.event.addListener(_map,"click",function(e){if(typeof(b)=="undefined"){b=_map_create_marker(e.latLng)}else{b.setPosition(e.latLng)}_map_save_values(e.latLng)});$("#google_map_container").height("600px");$("#google_map_container").width("700px");_map_show_window()}function _map_show_window(){var a=$(window).height();var d=$(window).width();var b=$("#google_map_container").width();var c=$("#google_map_container").height();$("#google_map_container").css("top",(a/2-c/2));$("#google_map_container").css("left",d/2-b/2);$("#google_map_container").show();resizeGoogleMapDialog()}function _map_create_marker(a){var b=new google.maps.Marker({position:a,map:_map,draggable:true});google.maps.event.addListener(b,"dragend",function(c){_map_save_values(c.latLng)});return b}function _map_save_values(a){_new_latitude=a.lat();_new_longitude=a.lng();_new_zoom=_map.getZoom()}$(window).bind("resize",resizeGoogleMapDialog);var tmid=0,winw=0,winh=0;function resizeGoogleMapDialog(){if((b!=$(window).width())||(d!=$(window).height())){var d=$(window).height();var b=$(window).width();var a=(b-600);if(a>800){a=800}if(a<550){a=550}var c=(d-100);if(c>800){c=800}$("#google_map_container").css("width",a);$("#google_map_container").css("height",c);$("#google_map_container").css("top",(d/2-c/2));$("#google_map_container").css("left",(b/2-a/2));$("#google_map").css("width",a-10);$("#google_map").css("height",c-100)}};
