Glider=Class.create();Object.extend(Object.extend(Glider.prototype,Abstract.prototype),{initialize:function(b,a){this.scrolling=false;this.wrapper=$(b);this.scroller=this.wrapper.down("div.scroller");this.sections=this.wrapper.getElementsBySelector("div.section");this.options=Object.extend({duration:1,frequency:3},a||{});this.sections.each(function(d,c){d._index=c});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()}},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)},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}});