// Gaia Ajax Widgets Copyright (C) 2007  Frost Innovation AS. details at http://ajaxwidgets.com/
Gaia.Accordion=function(element,options){this.initialize(element,options);}
Gaia.Accordion._objects=new Array();Object.extend(Gaia.Accordion.prototype,Gaia.WebControl.prototype);Object.extend(Gaia.Accordion.prototype,Gaia.Container.prototype);Object.extend(Gaia.Accordion.prototype,{initialize:function(element,options){this.baseInitializeWebControl(element,options);this.realParentElId=this.element.parentNode.parentNode.id;this.originalParentToParentElement=this.element.parentNode.parentNode;if(!Gaia.Accordion._objects[this.realParentElId]){this.initializeContainers();}
Gaia.Accordion._objects[this.realParentElId].controls.push(this);this.setActive(this.options.active);this.getContentWrapper().style.height=this.options.height+'px';this._onClicked=this.clicked.bind(this);Element.observe(this.getHeader(),'click',this._onClicked);if(!this.options.className||this.options.className==''){this.getHeader().style.backgroundColor='Red';}},clicked:function(){if(this.options.active)
return;var toCloseElements=new Array();var toCloseObject=new Array();Gaia.Accordion._objects[this.realParentElId].controls.each(function(idx){if(idx.options.active){idx.options.active=false;toCloseElements.push(idx.getContentWrapper());toCloseObject.push(idx);}}.bind(this));this.options.active=true;this.getContentWrapper().style.height='0px';this.setActive(true);this.options.active=true;new Effect.ReSize(this.getContentWrapper(),{toSize:this.options.height,direction:'vert',duration:this.options.animationDuration,otherEl:toCloseElements,afterFinish:function(){toCloseObject.each(function(idx){idx.setActive(false);});},otherElToSize:0});},setAnimationDuration:function(value){this.options.animationDuration=value;return this;},setActive:function(value){if(value)
Element.show(this.getContentWrapper());else
Element.hide(this.getContentWrapper());},getContentWrapper:function(){if(!this.contentDiv){this.contentDiv=$(this.element.id.substr(0,this.element.id.length-4)+'_DIV');}
return this.contentDiv;},getHeader:function(){if(!this.headerDiv){this.headerDiv=$(this.element.id.substr(0,this.element.id.length-4)+'_DIV_CAPTION');}
return this.headerDiv;},initializeContainers:function(){if(!this.realParentElId||this.realParentElId==''){this.element.parentNode.parentNode.id=this.element.id+'___AccordionParentContainer';this.realParentElId=this.element.parentNode.parentNode.id;}
Gaia.Accordion._objects[this.realParentElId]={controls:new Array()};},setTabIndex:function(value){this.element.tabIndex=value;return this;},setVisible:function(value){if(value!=true){this.destroy();}
return this;},destroy:function(){this.destroyChildrenControls();Element.stopObserving(this.headerDiv,'click',this._onClicked);this.destroyContainer(this.element.id);var idxNo=0;Gaia.Accordion._objects[this.realParentElId].controls.each(function(idx){if(idx==this){throw $break;}
idxNo+=1;}.bind(this));Gaia.Accordion._objects[this.realParentElId].controls.splice(idxNo,1);this._destroyImpl();},_getElementPostValue:function(){return'';}});Gaia.Accordion.browserFinishedLoading=true;