
Fx.Expando=Class.create({initialize:function(options){this.expandoElement=$$(options.expandoSelector)[0];this.toggleElement=$$(options.toggleSelector)[0];this.expandedClass=options.expandedClass||'expanded';this.collapsedClass=options.collapsedClass||'collapsed';this.onExpandComplete=options.onExpandComplete||function(){return false;};this.onCollapseComplete=options.onCollapseComplete||function(){return false;};this.onStart=options.onStart||function(){return false;};this.duration=options.duration||500;this.expandedHeight=options.expandedHeight;this.collapsedHeight=options.collapsedHeight;this.fx=new Fx.Style(this.expandoElement,"height",{options:{duration:this.duration,wait:true},onStart:this.onStart});this.toggleElement.observe('click',this.toggle.bind(this));},toggle:function(event){var that=this;if(this.expandoElement.hasClassName(this.expandedClass)){this.fx.options.onComplete=function(){that.expandoElement.removeClassName(that.expandedClass).addClassName(that.collapsedClass);that.onCollapseComplete();};this.fx.start(this.expandedHeight,this.collapsedHeight);}else{this.fx.options.onComplete=function(){that.expandoElement.removeClassName(that.collapsedClass).addClassName(that.expandedClass);that.onExpandComplete();};this.fx.start(this.collapsedHeight,this.expandedHeight);}}});