Slider=Class.create();var Position_new={includeScrollOffsets:false,prepare_new:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;},cumulativeOffset_new:function(V){var o=0,k=0;do{o+=V.offsetTop||0;k+=V.offsetLeft||0;V=V.offsetParent;}while(V);return [k,o];}};Object.extend(Object.extend(Slider.prototype,Abstract.prototype),{initialize:function(V,o){this.scrolling=false;this.wrapper=$(V);this.scroller=$$("div#"+this.wrapper.id+" div.scroller")[0];this.options=Object.extend({duration:1,debug:false},o||{});this.sections=$$("div#"+this.wrapper.id+" div.section");this.section_ids=this.mapSectionIds();this.current;this.setupControls();},mapSectionIds:function(){array=[];for(i=0;i<this.sections.length;i++){array.push(this.sections[i].id);}return array;},setupControls:function(){controls=$$("#"+this.wrapper.id+" div.controls a");if(this.options.debug){console.log("Controls:",controls);}for(i=0;i<controls.length;i++){control=controls[i];if(this.options.debug){console.log("control:",control);}Event.observe(control,"click",this.handleControlClick.bindAsEventListener(this));}},handleControlClick:function(o){element=Event.findElement(o,"a");if(this.options.debug){console.log("event:",o);console.log("element:",element);}if(this.scrolling){this.scrolling.cancel();}this.scroller.background="#efefef";this.moveTo(element.href.split("#")[1],this.scroller,{duration:this.options.duration});Event.stop(o);},moveTo:function(r,o,G){this.current=r;G=Object.extend({duration:1},G||{});Position_new.prepare_new();var l=Position_new.cumulativeOffset_new(o)[0];var V=Position_new.cumulativeOffset_new(o)[1];var W=Position_new.cumulativeOffset_new($(r))[0];var k=Position_new.cumulativeOffset_new($(r))[1];this.scrolling=new Effect.Scroll(o,{duration:G.duration,x:(W-l),y:(k-V)});return false;},next:function(){if(this.current){currentIndex=this.section_ids.indexOf(this.current);if(currentIndex==(this.sections.length-1)){nextSection=this.sections[0];}else{nextSection=this.sections[currentIndex+1];}}else{nextSection=this.sections[1];}this.moveTo(nextSection.id,this.scroller,{duration:this.options.duration});},previous:function(){if(this.current){currentIndex=this.section_ids.indexOf(this.current);if(currentIndex==0){prevSection=this.sections[this.sections.length-1];}else{prevSection=this.sections[currentIndex-1];}}else{prevSection=this.sections[this.sections.length-1];}this.moveTo(prevSection.id,this.scroller,{duration:this.options.duration});}});Effect.Scroll=Class.create();Object.extend(Object.extend(Effect.Scroll.prototype,Effect.Base.prototype),{initialize:function(V){this.element=$(V);var o=Object.extend({x:0,y:0,mode:"absolute"},arguments[1]||{});this.start(o);},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;}else{}},update:function(o){this.element.scrollLeft=this.options.x*o+this.originalLeft;this.element.scrollTop=this.options.y*o+this.originalTop;}});