(function(c){function b(h,i){var f=this;f.$container=h;f.widthCalculator=i;var g=c("<a />",{href:"#","class":"tab nowrap"}).text(PMA_messages.strMore).bind("click",false);var e=h.find("li img");if(e.length){c(PMA_getImage("b_more.png").toString()).prependTo(g)}var d=c("<li />",{"class":"submenu"}).append(g).append(c("<ul />")).mouseenter(function(){if(c(this).find("ul .tabactive").length==0){c(this).addClass("submenuhover").find("> a").addClass("tabactive")}}).mouseleave(function(){if(c(this).find("ul .tabactive").length==0){c(this).removeClass("submenuhover").find("> a").removeClass("tabactive")}});h.append(d);setTimeout(function(){f.resize()},4)}b.prototype.resize=function(){var r=this.widthCalculator.call(this.$container);var o=this.$container.find(".submenu:last");var g=o.outerWidth(true);var d=o.find("ul");var q=this.$container.find("> li");var k=d.find("li");var f=k.length>0;var h=f?g:0;var j=q.length-1;for(var m=0;m<j;m++){h+=c(q[m]).outerWidth(true)}var n=false;while(h>=r&&--j>=0){n=true;var e=c(q[j]);var p=e.outerWidth(true);e.data("width",p);if(!f){h-=p;e.prependTo(d);h+=g;f=true}else{h-=p;e.prependTo(d)}}if(!n){for(var m=0,j=k.length;m<j;m++){h+=c(k[m]).data("width");if(h<r||(m==k.length-1&&h-g<r)){c(k[m]).insertBefore(o)}else{break}}}if(d.find("li").length>0){o.addClass("shown")}else{o.removeClass("shown")}if(this.$container.find("> li").length==1){d.removeClass().addClass("only")}else{d.removeClass().addClass("notonly")}if(o.find(".tabactive").length){o.addClass("active").find("> a").removeClass("tab").addClass("tabactive")}else{o.removeClass("active").find("> a").addClass("tab").removeClass("tabactive")}};b.prototype.destroy=function(){var d=this.$container.find("li.submenu").removeData();d.find("li").appendTo(this.$container);d.remove()};var a={init:function(d){return this.each(function(){var e=c(this);if(!e.data("menuResizer")){e.data("menuResizer",new b(e,d))}})},resize:function(){return this.each(function(){var d=c(this).data("menuResizer");if(d){d.resize()}})},destroy:function(){return this.each(function(){var d=c(this).data("menuResizer");if(d){d.destroy()}})}};c.fn.menuResizer=function(d){if(a[d]){return a[d].call(this)}else{if(typeof d==="function"){return a.init.apply(this,[d])}else{c.error("Method "+d+" does not exist on jQuery.menuResizer")}}}})(jQuery);