/** */var VisualComponents = {};VisualComponents.VisualComponent = Class.create({	  getEl: function(el){    if(typeof el=="string") el = $(el);    return el;  },    getIfExist: function(val, defVal){    var value = val!=undefined? val : defVal;     return value;  }  })VisualComponents.Accordion =  Class.create(VisualComponents.VisualComponent,{  initialize: function(btnEl, tgEl, config) {    this.cfg = config;     this.btnEl = this.getEl(btnEl);    this.tgEl = this.getEl(tgEl);     this.initVars();    this.initEvents();    this.initElements();  },    initVars: function(){    this.isActive = this.getIfExist(this.cfg.active, false);    this.activeClass = this.getIfExist(this.cfg.activeClassName,"accordion-active");    this.expandSpeed = this.getIfExist(this.cfg.expandSpeed, .5);    this.collapseSpeed = this.getIfExist(this.cfg.collapseSpeed, .5);  },    initEvents: function(){     var func;    var _this = this;    if(this.cfg.isParentControlling){            func = function(ev){        ev.stop();         document.fire("accordion:activeEvent",{firingItem:_this});      }          }else{      func = this.toggle.bind(this);    }        var eventName = this.getIfExist(this.cfg.eventName,"click");    this.btnEl.observe(eventName,func);  },    initElements: function(){    if(this.isActive) this.expand();    this.updateClassNames();  },    updateClassNames: function(){       if(this.isActive){      this.btnEl.addClassName(this.activeClass);      this.tgEl.removeClassName("collapsed");      this.tgEl.addClassName("expanded");    }else{      this.btnEl.removeClassName(this.activeClass);      this.tgEl.removeClassName("expanded");      this.tgEl.addClassName("collapsed");    }  },    toggle: function(ev){    if(ev) ev.stop();    if(this.isActive){      this.expand();    }else{      this.collapse();    }  },    onExpand: function(){     document.fire("accordion:expandComplete");  },    onCollapse: function(){    document.fire("accordion:collapseComplete");  },    expand: function(){     Effect.BlindDown(this.tgEl, {      duration: this.expandSpeed,      afterFinish: this.onExpand    });    this.isActive = true;    this.updateClassNames();  },    collapse: function(){     Effect.BlindUp(this.tgEl, {      duration:  this.collapseSpeed,      afterFinish: this.onCollapse    });    this.isActive = false;    this.updateClassNames();  }    })VisualComponents.Accordions = Class.create(VisualComponents.VisualComponent,{    initialize: function(accordions, cfg) {    this.cfg = cfg;    this.isSingleOpen = cfg.isSingleOpen;    this.activeIndex = this.getIfExist(cfg.activeIndex, 0);    this.accordions = this.getIfExist(accordions,[]);    this.initEvents();    this.initAccordions();  },    initAccordions: function(){   // this.accordions[this.activeIndex].expand();  },    initEvents: function(){    document.observe("accordion:activeEvent", this.onActiveHandler.bind(this));    document.stopObserving("accordion:expandComplete");  },    onActiveHandler: function(ev){           var tgItem = ev.memo.firingItem;        if(!tgItem.isActive){       document.stopObserving("accordion:activeEvent");      document.observe("accordion:expandComplete", this.initEvents.bind(this) );      tgItem.expand();      if (this.isSingleOpen) {        this.accordions[this.activeIndex].collapse();      }      this.activeIndex = tgItem.cfg.index;          }else{       if(!this.isSingleOpen){        tgItem.collapse();      }    }  }  })