$(function(){function k(a){a=a.find("a.label");return 0==a.length?"":a.attr("rel")}function h(a){d&&d.removeClass("current");d=a;if(d.length){l=d.attr("id");d.addClass("current");var b=jQuery.parseJSON(d.find("span").html()),a=d.find(".external").length?p:q,b=$.extend({},{title:"",layout_color:"",layout_label:"",types:"",size:"",mtime:"",opts:""},b),a=a.replace(/\[title\]/g,b.title).replace(/\[key\]/g,b.key).replace(/\[url\]/g,b.url).replace(/\[layout_label\]/g,b.layout_label).replace(/\[types\]/g,
b.types).replace(/\[size\]/g,b.size).replace(/\[mtime\]/g,b.mtime).replace(/\[options\]/g,b.opts.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">"));e.show().html(a).find(".layout_icon").css({background:b.layout_color});b.special&&e.find(".not_special").hide();b.has_layout?e.find(".no_layout").hide():e.find(".has_layout").hide();b.level>=max_level_index&&e.find(".insert_child").hide();a=e.height();b=i.height();b<a&&i.css("min-height",a);var c=d.position();if(c){var g=0;0<c.top&&(g=Math.round(100*
(c.top/b)));a=c.top-g/120*a;a=Math.max(0,a);e.stop().animate({top:a})}}else e.hide()}function m(){var a,b,c=$("#admin_menu"),g={path:gpBLink+"/Admin_Menu",expires:100};if(0<c.length){a:{a="gp_menu_hide=";for(var d=document.cookie.split(";"),e=0;e<d.length;e++){for(var f=d[e];" "==f.charAt(0);)f=f.substring(1,f.length);if(0==f.indexOf(a)){a=f.substring(a.length,f.length);break a}}a=!1}a=decodeURIComponent(a||"");d=$("#gp_curr_menu").val();a=a.replace(RegExp("#"+d+"=\\[[^#=\\]\\[]*\\]",""),"");b="#"+
$("#gp_curr_menu").val()+"=[";c.find(".hidechildren > div > .label").each(function(a,c){b+=c.rel+","});b+="]";$.cookie("gp_menu_hide",a+b,g)}$.cookie("gp_menu_prefs",$("#gp_menu_select_form").serialize(),g)}function n(){var a,b,c="";$(".menu_marker").each(function(){var d=$(this);b=d.data("menuid");a=d.children();c+="&menus["+b+"]="+encodeURIComponent(a.eq(0).val());c+="&menuh["+b+"]="+encodeURIComponent(a.eq(1).val());c+="&menuc["+b+"]="+encodeURIComponent(a.eq(2).val())});return c}var i=$("#admin_menu"),
e=$("#admin_menu_tools"),d=!1,l=!1,j=!1,q=$("#menu_info").html(),p=$("#menu_info_extern").html();i.nestedSortable({disableNesting:"no-nest",forcePlaceholderSize:!0,handle:"a.sort",items:"li",opacity:0.8,placeholder:"placeholder",tabSize:25,toleranceElement:"> div",listType:"ul",delay:2,stop:function(a,b){var c=b.item,d=c.parent().siblings("div"),e=c.children("div"),c={cmd:"drag",drag_key:k(e),parent:k(d),prev:k(c.prev().children("div")),hidden:c.closest("#menu_available_list").length};0<d.length&&
d.parent(":not(.haschildren)").addClass("haschildren");0<j.length&&0==j.find("li").length&&j.removeClass("haschildren");h(e);loading();c=jQuery.param(c,!0);c+=n();$gp.postC(window.location.href,c)},start:function(a,b){j=b.item.parent().siblings("div").parent()}}).disableSelection();gpresponse.gp_menu_refresh=function(){i.nestedSortable("refresh");if(l){var a=$("#"+l);h(a)}};gplinks.menu_info=function(a,b){b.preventDefault();var c=$(this).parent();window.setTimeout(function(){h(c)},100)};gplinks.expand_img=
function(a,b){gplinks.menu_info.call(this,a,b);$li=$(this).closest("li");$li.hasClass("haschildren")&&($li.toggleClass("hidechildren"),m())};gpresponse.replacemenu=function(a){$(a.SELECTOR).find("ul:first").replaceWith(a.CONTENT)};gpinputs.menupost=function(){var a=n(),b=$(this).closest("form");b.attr("action",jPrep(b.attr("action"),a));$gp.post(this);return!1};gplinks.menupost=function(a,b){b.preventDefault();var c=strip_to(this.search,"?"),c=c+n();$gp.postC(this.href,c)};$("#gp_menu_select").change(function(){m();
window.location=strip_from(window.location.href,"?")});$("input:checkbox").live("click",function(){$this=$(this);0<$this.filter(":checked").length?$this.closest("li").addClass("gpui-state-checked"):$this.closest("li").removeClass("gpui-state-checked")});$("input.gpsearch").live("keyup",function(){var a=this.value.toLowerCase();$(this).closest("form").find(".gpui-scrolllist li:not(.gpui-state-checked)").each(function(){var b=$(this);-1==b.text().toLowerCase().indexOf(a)?b.hide():b.show()})});var r=
$("#admin_menu").find("div:first");h(r);m()});