(function($){$.fn.slidable=function(options){var ratio=3;var slideWidth=0;var slidableElement=this;$.slidable={defaults:{vitesse:1,width:960,height:230,shadow:true,shadowWidth:15,arrowsWidth:75,arrowsPosition:'out'}};var startScroll=function(dir){var x=slidableElement.css("left").replace(new RegExp("(px)","g"),"");var maxOffset=slidableElement.parent().width()-slideWidth;var v=0;if(dir>0){v=ratio*Math.abs(x)*options.vitesse;}else{v=ratio*(Math.abs(maxOffset)-Math.abs(x))*options.vitesse;}
var offset=(dir>0)?0:maxOffset;slidableElement.animate({"left":offset},v,'linear');};var options=$.extend({},$.slidable.defaults,options);slidableElement.children().each(function(){slideWidth+=parseInt($(this).width());});slidableElement.css({"position":"absolute","left":0,"top":0,"width":slideWidth});slidableElement.wrap('<div class="wrapper_'+slidableElement.attr("id")+'"/>');var container=slidableElement.parent();container.css({"overflow":"hidden","width":options.width,"height":options.height});slidableElement.wrap('<div class="viewport"/>');var viewport=slidableElement.parent();viewport.css({"position":"relative","float":"left","height":options.height,"width":options.width,"overflow":"hidden"});if(options.arrowsPosition=='out'){viewport.css("width",options.width-(options.arrowsWidth*2));}
var btnLeft=$('<div class="sliderButton left"></div>');btnLeft.css({"background-image":"url(leftArrow.png)"});if(options.arrowsPosition=='in'){btnLeft.css({"position":"absolute","width":options.arrowsWidth});}
btnLeft.mouseover(function(){startScroll(1);}).mouseout(function(){slidableElement.stop();});container.prepend(btnLeft);var btnRight=$('<div class="sliderButton right"></div>');btnRight.css({"background-image":"url(rightArrow.png)"});if(options.arrowsPosition=='in'){btnRight.css({"position":"absolute","width":options.arrowsWidth});}
btnRight.mouseover(function(){startScroll(-1);}).mouseout(function(){slidableElement.stop();});container.append(btnRight);container.find(".sliderButton").css({"float":"left","width":options.arrowsWidth,"height":options.height,"background-repeat":"no-repeat","background-position":"center center"});if(options.shadow){var leftShadow=$('<div class="sliderShadow"></div>');leftShadow.css({"background":"url(leftShadow.png)","left":0});viewport.prepend(leftShadow);var rightShadow=$('<div class="sliderShadow"></div>');rightShadow.css({"background":"url(rightShadow.png)","right":0});viewport.append(rightShadow);viewport.find(".sliderShadow").css({"position":"absolute","width":options.shadowWidth,"height":options.height,"z-index":10});}
return container;};})(jQuery);
