var WPNavMenuHandler=function(d){var h={},f=30,c=11,j=function(l,p,m,o){if(l&&l[0]){var n=d.parseJSON(l[0]);if(n.post_title){if(n.ID&&n.post_type){h[n.post_title]={ID:n.ID,object_type:n.post_type}}return n.post_title}}},k=function(l,p,m,o){if(l&&l[0]){var n=d.parseJSON(l[0]);if(n.post_title){return n.post_title}}},b=function(r,q){if(!r){return false}q=q||document;var m=["menu-item-db-id","menu-item-object-id","menu-item-object","menu-item-parent-id","menu-item-position","menu-item-type","menu-item-append","menu-item-title","menu-item-url","menu-item-description","menu-item-attr-title","menu-item-target","menu-item-classes","menu-item-xfn"],l={},n=q.getElementsByTagName("input"),p=n.length,o,s=document.getElementById("nav-menu-meta-object-id").value;while(p--){o=m.length;while(o--){if(n[p]&&n[p].name&&"menu-item["+r+"]["+m[o]+"]"==n[p].name){l[m[o]]=n[p].value}}}return l},a=function(){g.find(".menu-item-data-position").val(function(l){return l+1})},e=function(l){return l*f},i=function(l){return Math.floor(l/f)},g;d.fn.extend({menuItemDepth:function(){return i(this.eq(0).css("margin-left").slice(0,-2))},updateDepthClass:function(m,l){return this.each(function(){var n=d(this);l=l||n.menuItemDepth();d(this).removeClass("menu-item-depth-"+l).addClass("menu-item-depth-"+m)})},shiftDepthClass:function(l){return this.each(function(){var m=d(this),n=m.menuItemDepth();d(this).removeClass("menu-item-depth-"+n).addClass("menu-item-depth-"+(n+l))})},childMenuItems:function(){var l=d();this.each(function(){var m=d(this),o=m.menuItemDepth(),n=m.next();while(n.length&&n.menuItemDepth()>o){l=l.add(n);n=n.next()}});return l},updateParentMenuItemDBId:function(){return this.each(function(){var n=d(this),l=n.find(".menu-item-data-parent-id"),o=n.menuItemDepth(),m=n.prev();if(o==0){l.val(0)}else{while(m.menuItemDepth()!=o-1){m=m.prev()}l.val(m.find(".menu-item-data-object-id").val())}})},hideAdvancedMenuItemFields:function(){return this.each(function(){var l=d(this);d(".hide-column-tog").not(":checked").each(function(){l.find(".field-"+d(this).val()).addClass("hidden-field")})})},});return{init:function(){g=d("#menu-to-edit");this.attachMenuEditListeners();this.attachMenuMetaListeners(document.getElementById("nav-menu-meta"));this.attachTabsPanelListeners();if(g.length){this.initSortables()}this.initToggles();this.initTabManager()},initToggles:function(){postboxes.add_postbox_toggles("nav-menus");columns.useCheckboxesForHidden();columns.checked=function(l){d(".field-"+l).removeClass("hidden-field")};columns.unchecked=function(l){d(".field-"+l).addClass("hidden-field")};g.hideAdvancedMenuItemFields()},initSortables:function(){var o=0,m,p,r,n=g.offset().left;g.sortable({handle:" > dl",placeholder:"sortable-placeholder",start:function(w,x){var v,z,s,y,t,A,u=x.item.children(".menu-item-transport");m=x.item.menuItemDepth();l(x,m);y=(x.item.next()[0]==x.placeholder[0])?x.item.next():x.item;t=y.childMenuItems();u.append(t);q(x);z=u.outerHeight();z+=(z>0)?(x.placeholder.css("margin-top").slice(0,-2)*1):0;z+=x.item.outerHeight();z-=2;x.placeholder.height(z);A=m;t.each(function(){var B=d(this).menuItemDepth();A=(B>A)?B:A});s=x.item.find("dl dt").outerWidth();s+=e(A-m);s-=2;x.placeholder.width(s)},stop:function(v,u){var t,s=o-m;t=u.item.children(".menu-item-transport").children().insertAfter(u.item);if(s!=0){u.item.updateDepthClass(o);t.shiftDepthClass(s)}u.item.updateParentMenuItemDBId();a()},change:function(t,s){if(!s.placeholder.parent().hasClass("menu")){s.placeholder.appendTo(g)}q(s)},sort:function(t,s){var u=i(s.item.offset().left-n);if(ur){u=r}}if(u!=o){l(s,u)}}});function q(u){var t=u.placeholder.prev(),s=u.placeholder.next(),v;if(t[0]==u.item[0]){t=t.prev()}if(s[0]==u.item[0]){s=s.next()}p=(s.length)?s.menuItemDepth():0;if(t.length){r=((v=t.menuItemDepth()+1)>c)?c:v}else{r=0}}function l(s,t){s.placeholder.updateDepthClass(t,o);o=t}},attachMenuEditListeners:function(){var l=this;d("#update-nav-menu").bind("click",function(m){if(m.target&&m.target.className){if(-1!=m.target.className.indexOf("item-edit")){return l.eventOnClickEditLink(m.target)}else{if(-1!=m.target.className.indexOf("menu-delete")){return l.eventOnClickMenuDelete(m.target)}else{if(-1!=m.target.className.indexOf("item-delete")){return l.eventOnClickMenuItemDelete(m.target)}else{if(-1!=m.target.className.indexOf("item-close")){return l.eventOnClickCloseLink(m.target)}}}}}})},setupInputWithDefaultTitle:function(){var l="input-with-default-title";d("."+l).each(function(){var o=d(this),n=o.attr("title"),m=o.val();o.data(l,n);if(""==m){o.val(n)}else{if(n==m){return}else{o.removeClass(l)}}}).focus(function(){var m=d(this);if(m.val()==m.data(l)){m.val("").removeClass(l)}}).blur(function(){var m=d(this);if(""==m.val()){m.val(m.data(l)).addClass(l)}})},attachMenuMetaListeners:function(l){if(!l){return}var m=this;this.setupInputWithDefaultTitle();d("input.quick-search").each(function(n,o){m.setupQuickSearchEventListeners(o)});d(l).bind("submit",function(n){return m.eventSubmitMetaForm.call(m,this,n)});d(l).find("input:submit").click(function(){d(this).siblings("img.waiting").show()})},attachTabsPanelListeners:function(){d("#menu-settings-column").bind("click",function(q){if(q.target&&q.target.className&&-1!=q.target.className.indexOf("nav-tab-link")){var r,m=/#(.*)$/.exec(q.target.href),p,s=d(q.target).parents(".inside").first()[0],l=s?s.getElementsByTagName("input"):[],n=l.length;while(n--){l[n].checked=false}d(".tabs-panel",s).each(function(){if(this.className){this.className=this.className.replace("tabs-panel-active","tabs-panel-inactive")}});d(".tabs",s).each(function(){this.className=this.className.replace("tabs","")});q.target.parentNode.className+=" tabs";if(m&&m[1]){r=document.getElementById(m[1]);if(r){r.className=r.className.replace("tabs-panel-inactive","tabs-panel-active")}}return false}else{if(q.target&&q.target.className&&-1!=q.target.className.indexOf("select-all")){var o=/#(.*)$/.exec(q.target.href);if(o&&o[1]){d("#"+o[1]+" .tabs-panel-active input[type=checkbox]").attr("checked","checked");return false}}}})},initTabManager:function(){var q=d(".nav-tabs-wrapper"),r=q.children(".nav-tabs"),p=r.children(".nav-tab-active"),t=r.children(".nav-tab"),n=0,u,o,s,m;resizing=false;function l(){o=q.offset().left;u=o+q.width();p.makeTabVisible()}d.fn.extend({makeTabVisible:function(){var w=this.eq(0),x=w.offset().left,v=x+w.outerWidth();if(v>u){r.animate({"margin-left":"+="+(u-v)+"px",},"fast")}else{if(x=o)?true:false}});s=d('');m=d('');q.wrap('