//	Javascript class developped by Michaël Villar
//	http://www.nemstudio.com/
//	Require script.aculo.us library
//	Cette création est mise à disposition selon le Contrat Paternité-Partage des Conditions Initiales 
//	à l'Identique 2.0 Belgique disponible en ligne http://creativecommons.org/licenses/by-sa/2.0/be/ 
//	ou par courrier postal à Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

HSlider = Class.create();
HSlider.prototype = {
	box : Object,
	options : "",
	
	onResize : "",
	onMove : "",
	
	actualPosition : 0,
	actualX : 0,
	animating : false,
	
	initialize: function(box) {
		this.options = Object.extend({
			duration: 0.5,
			itemWidth: 100}, arguments[1] || {});
		
		this.box = box;
	},
	
	scrollTo: function(pos) {
		if (!this.animating) {
			this.animating = true;
			
			slidePos = pos - this.actualPosition;
			tox = slidePos * this.options.itemWidth;
		
			opt = this.options;
			opt.ref = this;
			opt.afterFinish = function() { this.ref.animating = false; }
			new Effect.MoveBy(this.box, 0, -tox, opt);
		
			this.actualPosition = pos;
		}
	},
	
	next: function() {
		this.scrollTo(this.actualPosition+1);
	},
	
	previous: function() {
		this.scrollTo(this.actualPosition-1);
	}
	
}

