LBBC=Class.create(Abstract,{initialize:function(scroller,slides,controls,options){this.scrolling=false;this.scroller=$(scroller);this.slides=slides;this.controls=controls;this.current=null;this.options=Object.extend({duration:1,auto:true,frequency:3,visibleSlides:1,jumperClassName:'hpp_carousel_jumper',selectedClassName:'hpp_carousel_selected',circular:true},options||{});if(this.options.effect=='fade'){this.options.circular=true}this.slides.each(function(slide,index){slide._index=index});if(this.controls){this.controls.invoke('observe','click',this.click.bind(this))}if(this.options.auto){this.start()}if(this.options.initial){var initialIndex=this.slides.indexOf($(this.options.initial));if(initialIndex>(this.options.visibleSlides-1)&&this.options.visibleSlides>1){if(initialIndex>this.slides.length-(this.options.visibleSlides+1)){initialIndex=this.slides.length-this.options.visibleSlides}}this.moveTo(this.slides[initialIndex])}},click:function(event){this.stop();var element=event.findElement('a');if(!element.hasClassName(this.options.disabledClassName)){if(element.hasClassName(this.options.controlClassName)){eval("this."+element.rel+"()")}else if(element.hasClassName(this.options.jumperClassName)){this.moveTo(element.rel);if(this.options.selectedClassName){this.controls.invoke('removeClassName',this.options.selectedClassName);element.addClassName(this.options.selectedClassName)}}}this.deactC()},moveTo:function(element){if(this.options.beforeMove&&(typeof this.options.beforeMove=='function')){this.options.beforeMove(element)}this.previous=this.current?this.current:this.slides[0];this.current=$(element);var scrollerOffset=this.scroller.cumulativeOffset();var elementOffset=this.current.cumulativeOffset();if(this.current._index>0){var xCoOrd=this.current._index*this.current.getWidth()}else{var xCoOrd=0}if(this.scrolling){this.scrolling.cancel()}var transition=Effect.Transitions.sinoidal;this.scrolling=new Effect.sScroll(this.scroller,{duration:this.options.duration,x:(xCoOrd),y:(elementOffset[1]-scrollerOffset[1]),transition:transition,afterFinish:(function(){if(this.controls){this.actC()}if(this.options.afterMove&&(typeof this.options.afterMove=='function')){this.options.afterMove()}this.scrolling=false}).bind(this)});return false},prv:function(){if(this.current){var currentIndex=this.current._index;var prevIndex=(currentIndex==0)?(this.options.circular?this.slides.length-1:0):currentIndex-1}else{var prevIndex=(this.options.circular?this.slides.length-1:0)}if(prevIndex==(this.slides.length-1)&&this.options.circular&&this.options.effect!='fade'){this.scroller.scrollLeft=(this.slides.length-1)*this.slides.fst().getWidth();this.scroller.scrollTop=(this.slides.length-1)*this.slides.fst().getHeight();prevIndex=this.slides.length-2}this.moveTo(this.slides[prevIndex])},nxt:function(){if(this.current){var currentIndex=this.current._index;var nextIndex=(this.slides.length-1==currentIndex)?(this.options.circular?0:currentIndex):currentIndex+1}else{var nextIndex=1}if(nextIndex>this.slides.length-(this.options.visibleSlides+1)){nextIndex=this.slides.length-this.options.visibleSlides}if(this.options.circular&&this.options.effect!='fade'&&(this.slides.length==currentIndex+1)){nextIndex=0}this.moveTo(this.slides[nextIndex])},fst:function(){this.moveTo(this.slides[0])},lst:function(){this.moveTo(this.slides[this.slides.length-1])},stop:function(){if(this.timer){clearTimeout(this.timer)}},start:function(){this.pUpd()},pUpd:function(){if(this.timer!=null){clearTimeout(this.timer);this.nxt()}this.timer=setTimeout(this.pUpd.bind(this),this.options.frequency*1000)},deactC:function(){this.controls.invoke('addClassName',this.options.disabledClassName)},actC:function(){this.controls.invoke('removeClassName',this.options.disabledClassName)}});Effect.sScroll=Class.create();Object.extend(Object.extend(Effect.sScroll.prototype,Effect.Base.prototype),{initialize:function(element){this.element=$(element);var options=Object.extend({x:0,y:0,mode:'absolute'},arguments[1]||{});this.start(options)},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(position){this.element.scrollLeft=this.options.x*position+this.originalLeft;this.element.scrollTop=this.options.y*position+this.originalTop}});
