
vitrine = {

		// *********** CONFIGURATION ****************

		Dure :			400,
		clavier : 		false,
		easing :		"easeInOutQuint",

		// ***********  VARIABLES *******************

		Elem :    		null,
		nbElem:   		null,
		Width:			null,
		position: 		0,
		compteur:		0,
		
		// ***********  FONCTIONS *******************		
	
		
		/*
		Fonction initialisation du caroussel
		@param Elem : l'id de la div qui regroupe tout le caroussel
		*/

		init : function(Elem){
			jQuery.easing.def = this.easing;
			this.Elem = $(Elem);
			this.nbElem = this.Elem.find(".page").length;// On d&eacute;termine combien on a d'&eacute;l&eacute;ment dans le caroussel
			// On calcul la taille de chaque slide suivant leur taille et les margin
			this.Width = this.Elem.find(".page").width();
			if(parseInt(this.Elem.find(".page").css("margin-left"))){
				this.Width += parseInt(this.Elem.find(".page").css("margin-left"));
				
			}
			if(parseInt(this.Elem.find(".page").css("margin-right"))){
				this.Width += parseInt(this.Elem.find(".page").css("margin-right"));
			}
			if(parseInt(this.Elem.find(".page").css("padding-right"))){
				this.Width += parseInt(this.Elem.find(".page").css("padding-right"));
			}
			if(parseInt(this.Elem.find(".page").css("padding-left"))){
				this.Width += parseInt(this.Elem.find(".page").css("padding-left"));
			}
			active=true;
			
			//Les fonctions clique sur les boutons
			this.Elem.find('a.suivant').click(function(){
				if(active){
					vitrine.suivant();
				}
			});
			this.Elem.find('a.precedent').click(function(){
				if(active){
					vitrine.precedent();
				}
			});
			
			if(this.clavier){
				$(document).keydown(function(e){
					if (e.keyCode == 39) {
						mini_car.suivant();
					}

					if (e.keyCode == 37) {
						mini_car.precedent();
 					}
 				});  
 			}
		},
		
		suivant : function(){
			this.compteur++;
			active=false;
			this.Elem.find('a.precedent').fadeIn();
			if(this.compteur+1>=this.nbElem){this.Elem.find('a.suivant').fadeOut();}
			positionX = -(this.Width)*this.compteur;// on calcul la position
			this.Elem.find('.guide').animate({
				'left': positionX
			},this.Dure,function(){active=true});
		},
		
		precedent : function(){
			this.compteur--;
			active=false;
			this.Elem.find('a.suivant').fadeIn();
			if(this.compteur-1<=-1){
				this.Elem.find('a.precedent').fadeOut();
			}
			positionX = -(this.Width)*this.compteur;// on calcul la position
			this.Elem.find('.guide').animate({
				'left': positionX
			},this.Dure,function(){active=true});
		}
	
	}


$(function(){
	vitrine.init('#vitrine_thematique');
});

