$.fn.menuTree=function(b){var d=jQuery.extend({buttonbeforelink:true,showglobalbuttons:true},b),a=$(this);b=$("li:has(ul)",a).length;var e=$('<button type="button"/>').click(function(c){c=$(c.target);c.toggleClass("collapse").blur();c.parent("li").find("ul:first").slideToggle(250);return false}).attr({title:"Expand/Collapse this section"});$("li:has(ul)",a).addClass("parent").each(function(){d.buttonbeforelink?$(this).prepend(e.clone(true)):$("a:first",this).after(e.clone(true))}).find("ul").hide();
$("#here, #current").each(function(){$("button:first",this).addClass("collapse");$("ul:first",this).show()}).parents("li.parent").each(function(){$("button:first",this).addClass("collapse");$("ul:first",this).show()});if(b>0&&d.showglobalbuttons){b=$("<button/>").attr({id:"expandall",title:"Expand All"}).text("Expand All").wrapInner($("<span/>")).click(function(){$("li ul:hidden",a).show();$("button:not(.collapse)",a).addClass("collapse");$(this).blur();return false});var f=$("<button/>").attr({id:"collapseall",
title:"Collapse All"}).text("Collapse All").wrapInner($("<span/>")).click(function(){$("li ul:visible",a).hide();$("button.collapse",a).removeClass("collapse");$(this).blur();return false});b=$("<div/>").attr("id","listtools").append(b,f);a.before(b)}return a};
