function slide_produit(objet , compteur_inverse)
{
	compteur_inverse--;
	var objet_suivant = $(objet).next();
	/*$(objet).animate({"left": "-=156px"}, 1);
	$(objet).animate({"z-index": compteur_inverse}, 1);*/
	$(objet).css("left", "-156px");
	$(objet).css("z-index", compteur_inverse);
	$(objet).show(); 
	$(objet).animate({"left": "+=156px"}, 300);
	$(objet).addClass("rectanglefumer");
	if(compteur_inverse)
	{
	setTimeout(function() { 
		slide_produit(objet_suivant , compteur_inverse); 
		}, 300 ); 
	}

}

function change_couleur(couleur1, couleur2, compteur)
{
	compteur--;
	if(compteur % 2)
	$(".clignote").css("background", couleur1);
	else
	$(".clignote").css("background", couleur2);

	if(compteur)
	{
		setTimeout(function() { 
		  change_couleur(couleur1, couleur2, compteur); 
		}, 400 );
	}
}

$(document).ready(function() 
{
	hs.graphicsDir = './lib/highslide/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.wrapperClassName = 'dark borderless floating-caption';
	hs.fadeInOut = true;
	hs.dimmingOpacity = .75;
	hs.showCredits = false;
	

	$('.popup_modele').hide();
	$('.listeproduit').hide();
	$('.detail_legende').hide();
	$('.checkbox_perso').fadeTo(0,0,'');
	
	
	$('.checkbox_label').click(function(){
		if($('input', this).attr("checked") == "1")
		{
			$('img', this).attr("src", "./images/case_1.gif");
		}
		else
		{
			$('img', this).attr("src", "./images/case_0.gif");
		}
	});
	/*$('.vignetemodele').click(function(){
		$('.popup_modele').hide();
		$(this).next('.popup_modele').show();
	});
*/

	$('.diaporama img').hide();
		
	$('.listeproduit').hover(function(){
			$('.rectanglefumer').fadeTo(0, 0.8, '' );
		$(this).fadeTo(0, 1, '' );
	},function(){
	});
	
	$('#les_produits').hover(function(){
	},function(){
			$('.rectanglefumer').fadeTo(0, 1, '' );
	});
	
	window.onload = function () {
	
	var un_produit = $('.listeproduit').slice(0,1);
	
	slide_produit(un_produit , 6);
	/*
	$('.listeproduit').animate({"left": "-=156px"}, 1);
	$('.listeproduit').show();
	$('.listeproduit').animate({"left": "+=156px"}, 1500);
	*/

	change_couleur("#7F9215", "#687554", 100);
	
	
	   $('.diaporama').cycle(
		{
			fx:     'fade', 
			speed:   6000, 
			timeout: 3000
		});

		$('.diaporama img').show();
	}
});

