var SlidingTabs=new Class({options:{startingSlide:false,activeButtonClass:"active",activationEvent:"click",wrap:true,slideEffect:{duration:400},animateHeight:true,rightOversized:0},current:null,buttons:false,outerSlidesBox:null,innerSlidesBox:null,panes:null,fx:null,heightFx:null,initialize:function(_1,_2,_3){
if(_1){
this.buttons=$(_1).getChildren();
}
this.outerSlidesBox=$(_2);
this.innerSlidesBox=this.outerSlidesBox.getFirst();
this.panes=this.innerSlidesBox.getChildren();
this.setOptions(_3);
this.fx=new Fx.Scroll(this.outerSlidesBox,this.options.slideEffect);
this.heightFx=this.outerSlidesBox.effect("height",this.options.slideEffect);
this.current=this.options.startingSlide?this.panes.indexOf($(this.options.startingSlide)):0;
if(this.buttons){
this.buttons[this.current].addClass(this.options.activeButtonClass);
}
this.outerSlidesBox.setStyle("overflow","hidden");
this.panes.each(function(_4,_5){
_4.setStyles({"float":"left","overflow":"hidden"});
}.bind(this));
this.innerSlidesBox.setStyle("float","left");
if(this.options.startingSlide){
this.fx.toElement(this.options.startingSlide);
}
if(this.buttons){
this.buttons.each(function(_6){
_6.addEvent(this.options.activationEvent,this.buttonEventHandler.bindWithEvent(this,_6));
}.bind(this));
}
if(this.options.animateHeight){
this.heightFx.set(this.panes[this.current].offsetHeight);
}
this.recalcWidths();
},changeTo:function(_7,_8){
if($type(_7)=="number"){
_7=this.panes[_7-1];
}
if(!$defined(_8)){
_8=true;
}
var _9={cancel:false,target:$(_7),animateChange:_8};
this.fireEvent("change",_9);
if(_9.cancel==true){
return;
}
if(this.buttons){
this.buttons[this.current].removeClass(this.options.activeButtonClass);
}
this.current=this.panes.indexOf($(_9.target));
if(this.buttons){
this.buttons[this.current].addClass(this.options.activeButtonClass);
}
this.fx.stop();
if(_9.animateChange){
this.fx.toElement(_9.target);
}else{
this.outerSlidesBox.scrollTo(this.current*this.outerSlidesBox.offsetWidth.toInt(),0);
}
if(this.options.animateHeight){
this.heightFx.start(this.panes[this.current].offsetHeight);
}
},buttonEventHandler:function(_a,_b){
if(_a.target==this.buttons[this.current]){
return;
}
this.changeTo(this.panes[this.buttons.indexOf($(_b))]);
},next:function(){
var _c=this.current+1;
if(_c==this.panes.length){
if(this.options.wrap==true){
_c=0;
}else{
return;
}
}
this.changeTo(this.panes[_c]);
},previous:function(){
var _d=this.current-1;
if(_d<0){
if(this.options.wrap==true){
_d=this.panes.length-1;
}else{
return;
}
}
this.changeTo(this.panes[_d]);
},recalcWidths:function(){
this.panes.each(function(_e,_f){
_e.setStyle("width",this.outerSlidesBox.offsetWidth.toInt()-this.options.rightOversized+"px");
}.bind(this));
this.innerSlidesBox.setStyle("width",(this.outerSlidesBox.offsetWidth.toInt()*this.panes.length)+"px");
if(this.current>0){
this.fx.stop();
this.outerSlidesBox.scrollTo(this.current*this.outerSlidesBox.offsetWidth.toInt(),0);
}
}});
SlidingTabs.implement(new Options,new Events);


