Object.extend(Event, {
	wheel:function (event){
        var delta = 0;
        if (event.wheelDelta) {
			delta = event.wheelDelta/120;
			if (window.opera) delta = -delta;
        } else if (event.detail) {
            delta = -event.detail/3;
        }
		if(navigator.userAgent.indexOf('Mac') != -1) delta = -delta; 	 
		return Math.round(delta);
	}
});

var ScrollHorizontal = Class.create();
ScrollHorizontal.prototype = {
	initialize: function(capture,track, duree, secExecution, pagination){
		this.capture = capture;
		this.duree = duree;
		this.secExecution = secExecution;
		this.pagination = pagination;
		this.nCell = 0;
		this.id = 1;
		this.po = 0;	
		this.px = $(this.capture).getWidth();
		this.pxH = $(this.capture).getHeight();
		this.track = $(track);
        this.handle = this.track.firstDescendant();
		this.handle.style.width=$('list-produit').offsetWidth/7+'px';
		this.slider = new Control.Slider(this.handle,this.track,{
            axis: 'horizontal',
            onSlide: this.move.bind(this),
            onChange: this.move.bind(this)
        });
		this.start();      
	},
	start: function(){		
		if ($(this.capture).scrollWidth <= $(this.capture).offsetWidth) {
			this.slider.setDisabled();
			this.track.hide();
		}									
		Event.observe($(this.capture), "mousewheel", this.wheelwheel.bind(this));		
		Event.observe($(this.capture), "DOMMouseScroll", this.wheelwheel.bind(this));				
	},
	move: function(value){	
		/*scrollLeft= Math.round(value/this.slider.maximum*($(this.capture).scrollWidth-$(this.capture).offsetWidth));
		new Effect.Move($('scroll'), { x: -scrollLeft, y: 0,mode:'absolute',duration: this.duree,transition: Effect.Transitions.sinoidal});
	*/
		$(this.capture).scrollLeft = Math.round(value/this.slider.maximum*($(this.capture).scrollWidth-$(this.capture).offsetWidth));
	},
	stopEvent:function(pE)
	{
	   if (!pE)
		 if (window.event)
		   pE = window.event;
		 else
		   return;
	  if (pE.cancelBubble != null)
		 pE.cancelBubble = true;
	  if (pE.stopPropagation)
		 pE.stopPropagation();
	  if (pE.preventDefault)
		 pE.preventDefault();
	} ,
	wheelwheel: function(e){
		this.event = e;
		this.stopEvent(e);
		if (Event.wheel(this.event) < 0){
			this.slider.setValueBy(-Event.wheel(this.event)/50);
			this.po=this.po-this.px;
			//this.move(this.po);
		}else{
			this.slider.setValueBy(-Event.wheel(this.event)/50);
			this.po=this.po+this.px;
			//this.move(this.po);
		}
	}
};		