brose = new Object(); brose.c = new Object(); brose.o = new Object(); brose.c.TabManager = new Class({ Implements: [Events, Options, Chain], options: { iStartTab : 1, changeEvent: 'click', setAfterInit: true, css:{ activeSwitch: 'tab_active', firstSwitch: 'first', lastSwitch: 'last', activeContent: 'tab_active', firstContent: 'first', lastContent: 'last'
}
}, initialize: function(oDCtabs,oDCtabcontens,options){ this.setOptions(options); if($type(oDCtabs) == 'string'){ this.tabSw = $$(oDCtabs);}else if($type(oDCtabs) == 'collection' || $type(oDCtabs) == 'element' || $type(oDCtabs) == 'array'){ this.tabSw = oDCtabs;}else{ if($defined('console')){console.log('Argument oDCtabs is not a string, element or elementcollection');}
return false;}
if($type(oDCtabcontens) == 'string'){ this.tabCont = $$(oDCtabcontens);}else if($type(oDCtabcontens) == 'collection' || $type(oDCtabcontens) == 'element' || $type(oDCtabcontens) == 'array'){ this.tabCont = oDCtabcontens;}else{ if($defined('console')){console.log('Argument oDCtabcontens is not a string, element or elementcollection');}
return false;}
this.iCount = this.tabSw.length; if(this.tabCont.length < this.iCount){ this.iCount = this.tabCont.length;}
this.iCurr = this.options.iStartTab; if(this.iCurr > this.iCount){ this.iCurr = 1; if($defined('console')){console.log('Option iStartTab is invalid. Not enough tabs availible');}
}
this.iCurr --; this.tabSw.each(function(e,i,a){ if(this.options.css.firstSwitch.length && i == 0){ e.addClass(this.options.css.firstSwitch);}
if(this.options.css.lastSwitch.length && i+1 == a.length){ e.addClass(this.options.css.lastSwitch);}
e.addEvent(this.options.changeEvent, this.set.bindWithEvent(this, i+1));},this); this.tabCont.each(function(e,i,a){ if(this.options.css.firstContent.length && i == 0){ e.addClass(this.options.css.firstContent);}
if(this.options.css.lastContent.length && i+1 == a.length){ e.addClass(this.options.css.lastContent);}
},this); if(this.options.setAfterInit)
this.set(this.iCurr.toInt()+1); this.fireEvent('afterInit',[this]);}, _onBeforSet: function(iNr){ if(this.tabCont[iNr])
this.fireEvent('beforeSet',[iNr, this.tabCont[iNr],this]);}, _onAfterSet: function(iNr){ if(this.tabCont[iNr])
this.fireEvent('afterSet', [iNr, this.tabCont[iNr],this]);}, set: function(evnt,nr){ var iNr = arguments[arguments.length-1]-1; if(iNr < this.iCount){ this.chain( this._onBeforSet(iNr), this.setRunner(evnt,iNr), this._onAfterSet(iNr) ); this.callChain();}
}, setRunner: function(evnt,iNr){ if(iNr < this.iCount){ this.tabSw.each(function(e,i,a){ if(this.options.css.activeSwitch.length){ if(i == iNr){ e.addClass(this.options.css.activeSwitch); if(e.get('rel'))
e.addClass(this.options.css.activeSwitch + e.get('rel'));}else{ e.removeClass(this.options.css.activeSwitch); if(e.get('rel'))
e.removeClass(this.options.css.activeSwitch + e.get('rel'));}
}
},this); this.tabCont.each(function(e,i,a){ if(i != iNr){ e.setStyle('display','none');}else{ e.setStyle('display','block');}
if(this.options.css.activeSwitch.length){ if(i == iNr){ e.addClass(this.options.css.activeContent); if(e.get('rel'))
e.addClass(this.options.css.activeContent + e.get('rel'));}else{ e.removeClass(this.options.css.activeContent); if(e.get('rel'))
e.removeClass(this.options.css.activeContent + e.get('rel'));}
}
},this); this.iCurr = iNr;}
}
}); 