$(document).ready(function(){
	s_syst = new slider_syst("#conteneur_systemes");
});

var slider_syst = function(id){
	var self = this;
	this.div = $(id);
	this.largeurCache = this.div.width();
	this.largeur=-10000;
	this.div.find('div').each(function(){
		self.largeur+=$(this).width();
		self.largeur+=40;
	});
	this.largeur-=64;
	this.largeur-=120;
	this.slider = this.div.find(".slider_syst");
	this.prec = this.div.find(".prec_syst");
	this.suiv = this.div.find(".suiv_syst");
	this.lien1 = this.div.find(".lien1");
	this.lien2 = this.div.find(".lien2");
	this.lien3 = this.div.find(".lien3");
	
	this.saut = 612;
	this.nombre_saut = 1;
	this.courant=0;
	
	this.suiv.click(function(){
		if(self.courant<=self.nombre_saut)
		{
			self.courant++;
			self.slider.animate({
				left:40-(self.courant*self.saut)
			},1000);
		}
	});
	
	this.prec.click(function(){
		if(self.courant>0)
		{
			self.courant--;
			self.slider.animate({
				left:40-(self.courant*self.saut)
			},1000);
		}
	});
	
	this.lien1.click(function(){
		if(self.courant>0)
		{
			nbrSaut = self.courant;
			for(i=0;i<nbrSaut;i++){
				self.courant--;
				self.slider.animate({
					left:40-(self.courant*self.saut)
				},1000);
			}
		}
	});
	
	this.lien2.click(function(){
		if(self.courant<1)
		{
			nbrSaut = 1-self.courant;
			for(i=0;i<nbrSaut;i++){
				self.courant++;
				self.slider.animate({
					left:40-(self.courant*self.saut)
				},1000);
			}
		}
		if(self.courant>1)
		{
			nbrSaut = self.courant-1;
			for(i=0;i<nbrSaut;i++){
				self.courant--;
				self.slider.animate({
					left:40-(self.courant*self.saut)
				},1000);
			}
		}
	});
	
	this.lien3.click(function(){
		if(self.courant<2)
		{
			nbrSaut = 2-self.courant;
			for(i=0;i<nbrSaut;i++){
				self.courant++;
				self.slider.animate({
					left:40-(self.courant*self.saut)
				},1000);
			}
		}
		if(self.courant>2)
		{
			nbrSaut = self.courant-2;
			for(i=0;i<nbrSaut;i++){
				self.courant--;
				self.slider.animate({
					left:40-(self.courant*self.saut)
				},1000);
			}
		}
	});
}
