
var S2HorizontalScroller=Class.create({initialize:function(container,table,elementClass){this.container=container;this.table=table;this.elementClass=elementClass;},init:function(){this.container=$(this.container);if(!this.container){return;}
this.containerWidth=this.container.getWidth();this.table=$(this.table);this.nbElements=this.table.select("td").length;this.elementWidth=this.container.down("."+this.elementClass).getWidth();this.observeElements();},observeElements:function(){Event.observe("leftArrow","click",function(){this.scrollServiceProviders(1)}.bind(this))
Event.observe("rightArrow","click",function(){this.scrollServiceProviders(-1)}.bind(this))},scrollServiceProviders:function(dir){var offset_x=this.elementWidth*dir;if(this.isScrollAllowed(dir)){var dur=this.elementWidth*0.005;new Effect.Move(this.table,{x:offset_x,y:0,duration:dur,queue:{position:'end',scope:"scrollerTable",limit:1}});}},isScrollAllowed:function(dir){if(dir<0){return Math.abs(this.table.offsetLeft)<this.elementWidth*(this.nbElements-1);}
else{return this.table.offsetLeft<0}}});