Glider=Class.create();Object.extend(Object.extend(Glider.prototype,Abstract.prototype),{init:function(C,B,A){this.scrolling=false;this.wrapper=$(C);this.scroller=this.wrapper.down("div.scroller");this.sections=this.wrapper.getElementsBySelector("div.section");this.options=Object.extend({duration:1,frequency:3},A||{});this.chunk=B;this.sections.each(function(E,D){E._index=D});if(this.options.initialSection){this.moveTo(this.options.initialSection,this.scroller,{duration:this.options.duration})}if(this.options.autoGlide){this.start()}},addObservers:function(){var A=this.wrapper.getElementsBySelector("div.controls a");A.invoke("observe","click",this.events.click)},click:function(B){this.stop();var A=Event.findElement(B,"a");if(this.scrolling){this.scrolling.cancel()}this.moveTo(A.href.split("#")[1],this.scroller,{duration:this.options.duration});Event.stop(B)},moveIndexTo:function(A){var B=Math.floor(A/this.chunk);this.moveTo(this.sections[B],this.scroller,{duration:this.options.duration})},moveTo:function(D,A,C){this.current=$(D);Position.prepare();var E=Position.cumulativeOffset(A),B=Position.cumulativeOffset($(D));this.scrolling=new Effect.SmoothScroll(A,{duration:C.duration,x:(B[0]-E[0]),y:(B[1]-E[1])});return false},next:function(){if(this.current){var B=this.current._index;var A=(this.sections.length-1==B)?0:B+1}else{var A=1}this.moveTo(this.sections[A],this.scroller,{duration:this.options.duration})},previous:function(){if(this.current){var A=this.current._index;var B=(A==0)?this.sections.length-1:A-1}else{var B=this.sections.length-1}this.moveTo(this.sections[B],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(B){this.element=$(B);var A=Object.extend({x:0,y:0,mode:"absolute"},arguments[1]||{});this.start(A)},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(A){this.element.scrollLeft=this.options.x*A+this.originalLeft;this.element.scrollTop=this.options.y*A+this.originalTop}});