Glider=Class.create();
Object.extend(Object.extend(Glider.prototype,Abstract.prototype),{initialize:function(_1,_2){
this.scrolling=false;
this.wrapper=$(_1);
this.scroller=this.wrapper.down("div.scroller");
this.options=Object.extend({duration:1,frequency:3},_2||{});
this.recheck();
this.events={click:this.click.bind(this)};
this.addObservers();
if(this.options.initialSection){
this.moveTo(this.options.initialSection,this.scroller,{duration:this.options.duration});
}
if(this.options.autoGlide){
this.start();
}
},recheck:function(){
this.sections=this.wrapper.getElementsBySelector("div.show");
this.sections.each(function(_3,_4){
_3._index=_4;
});
},addObservers:function(){
var _5=this.wrapper.getElementsBySelector(".controls a");
_5.invoke("observe","click",this.events.click);
},click:function(_6){
this.stop();
var _7=Event.findElement(_6,"a");
if(this.scrolling){
this.scrolling.cancel();
}
this.moveTo(_7.href.split("#")[1],this.scroller,{duration:this.options.duration});
Event.stop(_6);
},moveTo:function(_8,_9,_a){
this.current=$(_8);
Position.prepare();
var _b=Position.cumulativeOffset(_9),_c=Position.cumulativeOffset($(_8));
this.scrolling=new Effect.SmoothScroll(_9,{duration:_a.duration,x:(_c[0]-_b[0]),y:(_c[1]-_b[1])});
return false;
},first:function(){
this.moveTo(this.sections[0],this.scroller,{duration:this.options.duration});
},last:function(){
this.moveTo(this.sections[this.sections.length-1],this.scroller,{duration:this.options.duration});
},next:function(){
if(this.current){
var _d=this.current._index;
var _e=(this.sections.length-1==_d)?0:_d+1;
}else{
var _e=1;
}
this.moveTo(this.sections[_e],this.scroller,{duration:this.options.duration});
},previous:function(){
if(this.current){
var _f=this.current._index;
var _10=(_f==0)?this.sections.length-1:_f-1;
}else{
var _10=this.sections.length-1;
}
this.moveTo(this.sections[_10],this.scroller,{duration:this.options.duration});
},stop:function(){
clearTimeout(this.timer);
},start:function(){
this.periodicallyUpdate();
},periodicallyUpdate:function(){
if(this.timer!=null){
clearTimeout(this.timer);
this.next();
}
this.timer=setTimeout(this.periodicallyUpdate.bind(this),this.options.frequency*1000);
}});
Effect.SmoothScroll=Class.create();
Object.extend(Object.extend(Effect.SmoothScroll.prototype,Effect.Base.prototype),{initialize:function(_11){
this.element=$(_11);
var _12=Object.extend({x:0,y:0,mode:"absolute"},arguments[1]||{});
this.start(_12);
},setup:function(){
if(this.options.continuous&&!this.element._ext){
this.element.cleanWhitespace();
this.element._ext=true;
this.element.appendChild(this.element.firstChild);
}
this.originalLeft=this.element.scrollLeft;
this.originalTop=this.element.scrollTop;
if(this.options.mode=="absolute"){
this.options.x-=this.originalLeft;
this.options.y-=this.originalTop;
}
},update:function(_13){
this.element.scrollLeft=this.options.x*_13+this.originalLeft;
this.element.scrollTop=this.options.y*_13+this.originalTop;
}});

