numberOfSlides = 0 ;
var currentPosition = 0;
var intervalSS = 0 ;
var interval = 8000;	 // temps de défilé des images
var defautPosition = 24; // à changer pour recaler le bouton

$(document).ready(function(){
						   
	
	var buttonsGallery = $(".buttonsGallery a") ;
	numberOfSlides = buttonsGallery.length;
	buttonsGallery.click(
		function (){
			clearInterval(intervalSS);
			
			new_position = defautPosition * this.rel ;
			xpoz = new_position + "px" ;
			$("#buttonsGalleryOn").animate({left: xpoz}, 500 );
			
			currentPosition = this.rel ;
			
			$(".galleryImage").fadeOut();
			var idSlide = "#ajaxGal_" + this.rel ;
			$(idSlide).fadeIn();
			intervalSS = setInterval("playSlideShow()",interval);
			return false ;
		}
	);
	
	
	
	intervalSS = setInterval("playSlideShow()",interval);
	
	
});



function playSlideShow() 
{	
		var buttonsGallery = $(".buttonsGallery a") ;
		numberOfSlides = buttonsGallery.length-1;
		if(currentPosition < numberOfSlides )
		{
			currentPosition++ ;
		}
		else {
			currentPosition = 0;
		}
		
		new_position = defautPosition * currentPosition ;
		xpoz = new_position + "px" ;
		$("#buttonsGalleryOn").animate({left: xpoz}, 500 );
		
		$(".galleryImage").fadeOut() ;
		$("#ajaxGal_"+currentPosition).fadeIn("slow") ;
}



