/* Copyright (C) 2007 - 2011 YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

var YOOaccordion=new Class({initialize:function(a,e,b){this.setOptions({open:"first",allowMultipleOpen:false,fade:false,fadeDuration:600,transition:Fx.Transitions.linear,duration:400},b);this.togglers=a;this.elements=e;this.elementFx=[];this.elementVisible=[];this.togglers.each(function(d,c){d.addEvent("click",function(){this.toggleSection(c)}.bind(this))},this);this.elements.each(function(d,c){this.elementFx[c]=new Fx.Slide(d,this.options);this.options.allowMultipleOpen&&this.options.open=="all"||
this.hide(c)},this);this.options.open=="first"&&function(){this.slideIn(0)}.delay(1,this)},toggleSection:function(a){this.options.allowMultipleOpen||this.elements.each(function(e,b){this.elementVisible[b]&&b!=a&&this.slideOut(b)},this);this.toggle(a)},toggle:function(a){this.elementFx[a].toggle().chain(function(){this.elementVisible[a]=(this.elementVisible[a]+1)%2}.bind(this));this.options.fade&&this.fade(a)},slideIn:function(a){this.elementFx[a].slideIn().chain(function(){this.elementVisible[a]=
1}.bind(this));this.options.fade&&this.fade(a)},slideOut:function(a){this.elementFx[a].slideOut().chain(function(){this.elementVisible[a]=0}.bind(this));this.options.fade&&this.fade(a)},show:function(a){this.elementVisible[a]=1;this.elementFx[a].show()},hide:function(a){this.elementVisible[a]=0;this.elementFx[a].hide()},fade:function(a){(new Fx.Styles(this.elements[a],{duration:this.options.fadeDuration,wait:false})).start({opacity:[this.elementVisible[a],(this.elementVisible[a]+1)%2]})}});YOOaccordion.implement(new Options);

