$A.Accordion=Ext.extend($A.Component,{constructor:function(a){$A.Accordion.superclass.constructor.call(this,a)},initComponent:function(b){$A.Accordion.superclass.initComponent.call(this,b);this.selectedItems=[];this.frequency=this.frequency||20;this.actionTimes=this.actionTimes||2;this.currentTime=1;this.accordions=this.wrap.query("div.item-accordion");this.strips=this.wrap.query("div.strip");this.bodys=this.wrap.query("div.item-accordion-body");this.stripheight=this.stripheight||25;for(var c=0;c<this.accordions.length;c++){var a=Ext.get(this.accordions[c]);if(a.hasClass("selected")){this.selectedItems.add(a);this.load.call(this,c)}}},processListener:function(a){$A.Accordion.superclass.processListener.call(this,a);this.wrap[a]("click",this.onClick,this)},initEvents:function(){$A.Accordion.superclass.initEvents.call(this);this.addEvents("select")},selectAccordionIndex:function(a){if(!this.accordions[a]){return}if(this.singlemode){this.selectedItems=[]}this.selectedItems.add(Ext.get(this.accordions[a]));this.intervalId=setInterval(this.go.createDelegate(this,[a]),this.frequency);this.go.call(this,a)},go:function(b){for(var c=0;c<this.accordions.length;c++){var a=Ext.get(this.accordions[c]);if(a.hasClass("selected")){if(this.singlemode||c==b){a.setHeight(this.stripheight+Ext.fly(this.bodys[c]).getHeight()*(1-this.currentTime/this.actionTimes))}}else{if(c==b){a.setHeight(this.stripheight+Ext.fly(this.bodys[c]).getHeight()*(this.currentTime/this.actionTimes))}}}if(this.actionTimes==this.currentTime){for(var c=0;c<this.accordions.length;c++){var a=Ext.get(this.accordions[c]);if(a.hasClass("selected")){if(this.singlemode||c==b){a.removeClass("selected");Ext.fly(this.bodys[c]).hide();this.selectedItems.remove(a)}}else{if(c==b){a.addClass("selected");Ext.fly(this.bodys[c]).show();this.load(b)}}}clearInterval(this.intervalId);this.currentTime=1}else{this.currentTime++}},onClick:function(d,c){c=Ext.fly(c);if(c.hasClass("item-accordion-btn")){c=c.parent()}if(c.hasClass("strip")){for(var b=0,a=this.strips.length;b<a;b++){if(c.dom==this.strips[b]){this.selectAccordionIndex(b);break}}}},onMouseOver:function(b,a){a=Ext.fly(a);if(a.hasClass("item-accordion-btn")){a.parent().addClass("strip-over")}$A.Accordion.superclass.onMouseOver.call(this,b,a)},onMouseOut:function(b,a){a=Ext.fly(a);if(a.hasClass("item-accordion-btn")){a.parent().removeClass("strip-over")}$A.Accordion.superclass.onMouseOut.call(this,b,a)},showLoading:function(a){a.update(_lang["accordion.loading"]);a.setStyle("text-align","center");a.setStyle("line-height",5)},clearLoading:function(a){a.update("");a.setStyle("text-align","");a.setStyle("line-height","")},load:function(b){var a=this.items[b].ref,d=Ext.get(this.bodys[b]);if(!a||d.isLoaded){this.fireEvent("select",this,b);return}d.isLoaded=true;d.cmps={};a=a+(a.indexOf("?")!=-1?"&":"?")+"_vw="+this.width+"&_vh="+(this.height-Ext.fly(this.strips[0]).getHeight());this.showLoading(d);var c=this;Ext.Ajax.request({url:a,success:function(e,f){c.clearLoading(d);var g=e.responseText;d.update(g,true,function(){c.fireEvent("select",c,b)},d)}})},setHeight:function(c){if(this.height==c){return}var a=this.accordions.length,c=Math.max(c,this.stripheight*a);this.height=c;for(var b=0;b<a;b++){Ext.fly(this.bodys[b]).setHeight((c-this.stripheight*a)/(this.singlemode?1:a))}for(var b=0;b<this.selectedItems.length;b++){this.selectedItems[b].setHeight(this.singlemode?(c-this.stripheight*(a-1)):(c/a))}},destroy:function(){var c=this.bodys;for(var f=0;f<c.length;f++){var a=Ext.get(c[f]),b=a.cmps;if(b){for(var d in this.cmps){var g=this.cmps[d];if(g.destroy){try{g.destroy()}catch(h){alert("销毁Accordion出错: "+h)}}}}}$A.Accordion.superclass.destroy.call(this)}});