!function($){$(document).ready(function(){var $sitemap_sections_checkboxes,$page_template_meta_boxes=$(".page-template-options").closest(".postbox"),$map=$(".contact-map"),$sitemap_sections=$("#sitemap-sections");function setup_contact_map(){var map,marker,$address=$("#contact_form_map_address"),$address_lat=$("#contact_form_map_address_lat"),$address_lng=$("#contact_form_map_address_lng"),$find_address=$("#contact_form_map_address_find"),$zoom_level=$("#contact_form_map_zoom"),geocoder=new google.maps.Geocoder;""===$zoom_level.val()&&$zoom_level.val(17);var geocode_address=function(){var address=$address.val();if(address.length<=0)return $address_lat.val(""),void $address_lng.val("");geocoder.geocode({address:address},function(results,status){if(status===google.maps.GeocoderStatus.OK){var result=results[0];$address.val(result.formatted_address),$address_lat.val(result.geometry.location.lat()),$address_lng.val(result.geometry.location.lng()),update_map(result.geometry.location)}else alert("Geocode was not successful for the following reason: "+status)})},update_map=function(LatLng){marker.setPosition(LatLng),map.setCenter(LatLng)};$address.on("blur",geocode_address).on("keydown",function(e){13===e.keyCode&&(geocode_address(),e.preventDefault())}),$find_address.on("click",function(e){e.preventDefault()}),setTimeout(function(){map=new google.maps.Map($map[0],{zoom:parseInt($zoom_level.val()),mapTypeId:google.maps.MapTypeId.ROADMAP}),marker=new google.maps.Marker({map:map,draggable:!0}),google.maps.event.addListener(marker,"dragend",function(){var drag_position=marker.getPosition();$address_lat.val(drag_position.lat()),$address_lng.val(drag_position.lng()),update_map(drag_position),latlng=new google.maps.LatLng(drag_position.lat(),drag_position.lng()),geocoder.geocode({latLng:latlng},function(results,status){status===google.maps.GeocoderStatus.OK?results[0]?$address.val(results[0].formatted_address):alert("No results found"):alert("Geocoder failed due to: "+status)})}),google.maps.event.addListener(map,"zoom_changed",function(){var zoom_level=map.getZoom();$zoom_level.val(zoom_level)}),""!==$address_lat.val()&&""!==$address_lng.val()&&update_map(new google.maps.LatLng($address_lat.val(),$address_lng.val())),""!==$zoom_level.val()&&map.setZoom(parseInt($zoom_level.val()))},200)}if($page_template_meta_boxes.each(function(){var this_id=$(this).attr("id");$("#"+this_id+"-hide").closest("label").hide()}),$("#page_template").change(function(){var current_page_template=$(this).val();$page_template_meta_boxes.each(function(){$(this).find(".page-template-options").val()===current_page_template?$(this).is(":visible")||$(this).effect("highlight"):$(this).hide()}),$page_template_meta_boxes.is(":visible")?$("#et_pb_layout").removeClass("first-visible"):$("#et_pb_layout").addClass("first-visible")}).trigger("change"),$("ul.checklist").on("change","input[type=checkbox]",function(){var $checklist=$(this).closest("ul.checklist"),$check_all=$checklist.find(".check_all"),$all_checkboxes=$checklist.find("input[type=checkbox]").not(".check_all");$all_checkboxes.filter(":checked").length===$all_checkboxes.length?$check_all.prop("checked",!0):void 0===$(this).attr("value")||$(this).is(":checked")||$check_all.prop("checked",!1)}),$("input[type=checkbox].check_all").click(function(){var $all_checkboxes=$(this).closest("ul.checklist").find("input[type=checkbox]").not(".check_all");$(this).is(":checked")?$all_checkboxes.prop("checked",!0):$all_checkboxes.prop("checked",!1)}),$sitemap_sections.length&&($sitemap_sections_checkboxes=$sitemap_sections.find("input[type=checkbox]"),$sitemap_sections.sortable({items:"li",cursor:"move",forcePlaceholderSize:!0}),$sitemap_sections_checkboxes.on("change",function(e){var $this=$(this),$settings_box=$("#sitemap_page_section_"+$this.val()),$all_settings_boxes=$(".sitemap_page_section"),is_all="1"===$this.val();$this.is(":checked")?($settings_box.slideDown("fast"),is_all&&$all_settings_boxes.slideDown("fast")):($settings_box.slideUp("fast"),is_all&&$all_settings_boxes.slideUp("fast"))}).trigger("change")),$map.length){if($("#page_template").on("change",function(){"page-template-contact.php"===$(this).val()&&setTimeout(function(){setup_contact_map()},1500)}),!$map.parent().is(":visible"))return;setup_contact_map()}})}(jQuery);