$(document).ready(function(){
	s2 = new slider("#galerie2");
	s3 = new slider("#galerie3");
	s4 = new slider("#galerie4"); 
});
slider=function(id){
	var self = this;
	this.div=$(id);
	this.slider=this.div.find(".slider");
	this.largeurCache=this.div.width();
	this.largeur=0;
	this.div.find('img').each(function(){
		self.largeur+=$(this).width();
		self.largeur+=parseInt($(this).css("margin-left"));
		self.largeur+=parseInt($(this).css("margin-right"));
	});
	this.prec=this.div.find(".precedent");
	this.suiv=this.div.find(".suivant");
	this.saut=this.largeurCache/(dist);
	this.nbEtapes=Math.ceil(this.largeur/this.saut -this.largeurCache/this.saut);
	this.courant=0;
	this.suiv.mouseover(function(){
		if(self.courant<=self.nbEtapes){
			self.courant++;
			self.slider.animate({
				left: -self.courant*self.saut
			}, 1000);
		}
		else{
			
		}
	});
	this.prec.mouseover(function(){
		if(self.courant>0){
			self.courant--;
			self.slider.animate({
				left: -self.courant*self.saut
			}, 1000);
		}
	});
}