Glider=Class.create();Object.extend(Object.extend(Glider.prototype,Abstract.prototype),{initialize:function(c,d){this.handStopped=false;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},d||{});this.sections.each(function(a,b){a._index=b});this.events={mouseover:this.pause.bind(this),mouseout:this.resume.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()}else{this.handStopped=true}},addObservers:function(){this.wrapper.observe("mouseover",this.events.mouseover);this.wrapper.observe("mouseout",this.events.mouseout);var g=this.wrapper.getElementsBySelector("div.sliderdescription");g.invoke("observe","mouseover",this.makeActive);g.invoke("observe","mouseout",this.makeInactive);var h=this.wrapper.getElementsBySelector("div.easyslidercontrol a.easyslidedirect");var l=this.wrapper.getElementsBySelector("div.easyslidercontrol a.easyslide-stop");l.invoke("observe","click",this.stop.bind(this));var i=this.wrapper.getElementsBySelector("div.easyslidercontrol a.easyslide-play");i.invoke("observe","click",this.start.bind(this));var j=this.wrapper.getElementsBySelector("a.easyslide-prev");j.invoke("observe","click",this.previous.bind(this));var k=this.wrapper.getElementsBySelector("a.easyslide-next");k.invoke("observe","click",this.next.bind(this))},numClick:function(c){var d=Event.findElement(c,"a");if(this.scrolling){this.scrolling.cancel()}this.moveTo(d.href.split("#")[1],this.scroller,{duration:this.options.duration});Event.stop(c);return false},micoNumClick:function(b){if(this.scrolling){this.scrolling.cancel()}this.moveTo("section"+b,this.scroller,{duration:this.options.duration});return false},moveTo:function(i,g,j){this.current=$(i);this.current=this.wrapper.select("#"+i)[0];Position.prepare();var h=Position.cumulativeOffset(g);var f=Position.cumulativeOffset(this.current);this.scrolling=new Effect.SmoothScroll(g,{duration:j.duration,x:(f[0]-h[0]),y:(f[1]-h[1])});if(typeof i=="object"){i=i.id}this.toggleControl($$('a[href="#'+i+'"]')[0]);return false},next:function(f){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].id,this.scroller,{duration:this.options.duration});if(f){Event.stop(f)}},previous:function(f){if(this.current){var e=this.current._index;var d=(e==0)?this.sections.length-1:e-1}else{var d=this.sections.length-1}this.moveTo(this.sections[d].id,this.scroller,{duration:this.options.duration});Event.stop(f)},makeActive:function(c){var d=Event.findElement(c,"div");d.addClassName("active")},makeInactive:function(c){var d=Event.findElement(c,"div");d.removeClassName("active")},toggleControl:function(b){if(!b){return false}$$(".easyslidercontrol a").invoke("removeClassName","active");b.addClassName("active")},stop:function(b){this.handStopped=true;clearTimeout(this.timer);Event.stop(b)},start:function(b){this.handStopped=false;this.periodicallyUpdate();if(b){Event.stop(b)}},pause:function(b){if(!this.handStopped){clearTimeout(this.timer);this.timer=null}Event.stop(b)},resume:function(b){if(!this.handStopped){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(c){this.element=$(c);var d=Object.extend({x:0,y:0,mode:"absolute"},arguments[1]||{});this.start(d)},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(b){this.element.scrollLeft=this.options.x*b+this.originalLeft;this.element.scrollTop=this.options.y*b+this.originalTop}});
