$A.AccordionMenu=Ext.extend($A.Component,{constructor:function(a){$A.AccordionMenu.superclass.constructor.call(this,a);this.context=a.context||""},initComponent:function(a){$A.AccordionMenu.superclass.initComponent.call(this,a);this.body=this.wrap.child("ul[atype=navigationbar.body]");this.navbar=[]},processListener:function(a){this.wrap[a]("click",this.onClick,this);if(Ext.isIE6){this.wrap[a]("mouseover",this.onMouseOver,this);this.wrap[a]("mouseout",this.onMouseOut,this)}},initEvents:function(){$A.AccordionMenu.superclass.initEvents.call(this);this.addEvents("click")},bind:function(b){if(typeof(b)==="string"){b=$(b);if(!b){return}}var a=this;a.dataset=b;this.initNavBar();this.buildView();this.showCurrent();this.showSubCurrent();if(Ext.isIE6){this.correctForIE6()}if(Ext.isIE7||Ext.isIE8){Ext.fly("adminmenushadow").removeClass("adminmenushadow")}},showCurrent:function(){if(this.menu_id){Ext.fly(this.menu_id).addClass("wp-has-current-submenu").removeClass("wp-not-current-submenu")}},showSubCurrent:function(){if(this.submenu_id){Ext.fly(this.submenu_id).addClass("current")}},createNode:function(a){return{record:a,children:[]}},initNavBar:function(){if(!this.idfield||!this.parentfield){return}var j={};var h={};var g=this.dataset.data;var c=g.length;for(var d=0;d<c;d++){var f=g[d];var a=f.get(this.idfield);var b=this.createNode(f);j[a]=b;h[a]=b}for(var m in h){var b=h[m];var f=b.record;var e=f.get(this.parentfield);var k=h[e];if(k){k.children.add(b);delete j[m]}}for(var m in j){var b=h[m];this.navbar.add(b)}},sort:function(e,d){e.sort(function(g,f){var i=g.record.get(d)||Number.MAX_VALUE;var h=f.record.get(d)||Number.MAX_VALUE;return parseFloat(i)-parseFloat(h)});var a=e.length;for(var b=0;b<a;b++){var c=e[b];this.sort(c.children,d)}},buildView:function(){if(this.sequencefield&&this.sequencefield!=""){this.sort(this.navbar,this.sequencefield)}var n=this.navbar.length;for(var q=0;q<n;q++){var b=this.navbar[q].record;var c=this.navbar[q].children;var s=c.length;var g=document.createElement("li");g.id=b.id;g.menu_id=b.id;g.className="wp-first-item wp-not-current-submenu wp-has-submenu wp-menu-open menu-top menu-top-first menu-icon-dashboard menu-top-last";var u=document.createElement("div");u.className="wp-menu-image";var m=document.createElement("div");u.appendChild(m);g.appendChild(u);if(!Ext.isIE6&&!Ext.isIE7&&!Ext.isIE8){var k=document.createElement("div");k.className="wp-menu-arrow";k.id="wp-menu-arrow";k.appendChild(m);g.appendChild(k)}var v=document.createElement("a");v.className="mymenu menu-top wp-has-current-submenu";var f=document.createTextNode(b.get(this.displayfield));var w=document.createElement("div");w.className="wp-submenu";w.id="hide-"+g.id;var e=document.createElement("div");e.className="wp-submenu-wrap";w.appendChild(e);var h=document.createElement("ul");e.appendChild(h);this.body.dom.appendChild(g);g.appendChild(v);g.appendChild(w);v.appendChild(f);for(var o=0;o<s;o++){var r=c[o].record;var y=document.createElement("li");y.id=r.id;y.menu_id=g.id;y.submenu_id=y.id;h.appendChild(y);var t=document.createElement("a");y.appendChild(t);if(this.icon&&this.icon!=""){var x=document.createElement("img");x.style.cssText="margin-left:8px;";x.src=this.icon;t.appendChild(x)}var p=document.createElement("span");p.style.cssText="margin-left:8px;";t.appendChild(p);var d=document.createTextNode(r.get(this.displayfield));p.appendChild(d)}}},correctForIE6:function(){Ext.fly("adminmenushadow").removeClass("adminmenushadow");var c=[];c=Ext.query(".mymenu");for(var b=0;b<c.length;b++){var a=new Ext.Element(c[b]);a.addClass("myMenu")}},onClick:function(c){var b=Ext.fly(c.target).findParent("li");if(!b){return}var a=this.dataset.findById(b.id);this.fireEvent("click",this,a,b.menu_id,b.submenu_id)},onMouseOver:function(b){var a=Ext.fly(b.target).findParent("li");if(!a){return}if(a.menu_id==this.menu_id){return}var c="hide-"+a.menu_id;Ext.fly(c).setStyle("display","block").setStyle("margin-left","-29px")},onMouseOut:function(b){var a=Ext.fly(b.target).findParent("li");if(!a){return}if(a.menu_id==this.menu_id){return}var c="hide-"+a.menu_id;Ext.fly(c).setStyle("display","none")}});