
(function($) {

	$.fn.easySlider = function(options){

		// default configuration properties
		var defaults = {
			prevId: 		'prevBtn',
			prevText: 		'Previous',
			nextId: 		'nextBtn',
			nextText: 		'Next',
			orientation:	'', //  'vertical' is optional;
			speed: 			900
		};

		var options = $.extend(defaults, options);

		return this.each(function() {
			obj = $(this);
                        var es = 3;
			var s = $("li", obj).length / es;
			var w = $("li", obj).width() * es;
			var h = obj.height();
			var ts = (s - ($(this).width() / w));
			var t = 0;
			var vertical = (options.orientation == 'vertical');
			$("ul", obj).css('width',s*w);
			if(!vertical) $("li", obj).css('float','left');
			//$("#"+options.prevId).hide();
			//$("#"+options.nextId).hide();
			$("#"+options.nextId).click(function(){
                                if (t < ts)
                                    animate("next");
				//if (t>=ts) $(this).fadeOut();
				//$("#"+options.prevId).fadeIn();
			});
			$("#"+options.prevId).click(function(){
                                if (t > 0)
                                    animate("prev");
				//if (t<=0) $(this).fadeOut();
				//$("#"+options.nextId).fadeIn();
			});
			function animate(dir){
				if(dir == "next"){
					t = (t>=ts) ? ts : t + 1;
				} else {
					t = (t<=0) ? 0 : t - 1;
				};
				if(!vertical) {
					p = (t * w * - 1);
					$("ul",obj).animate(
						{ marginLeft: p },
						options.speed
					);
				} else {
					p = (t*h*-1);
					$("ul",obj).animate(
						{ marginTop: p },
						options.speed
					);
				}
			};
			//if(s>1) $("#"+options.nextId).fadeIn();
		});

	};

})(jQuery);

$("#scrollListAnim").easySlider({
        prevText: 'Précédent',
            prevId: 'scrollButtonLeft',
            nextId: 'scrollButtonRight',
            }
    );