
// Fonction pour le slideshow en homepage
var zindex = 20;

function slideShow() {

	// Masquage des images
	$('#gallery .gallery-show').css("display","none");

	// Affichage de la première image
	$('#gallery .gallery-show:first').css("display", "block" );

	// Intervalle de changement
	setInterval('gallery()',6500);

}

function gallery() {

	if(zindex>9990) {
		zindex = 20;
		$('#gallery img').css("z-index",zindex);
	}
	zindex++;

	// Image courante
	var current = ($('#gallery .gallery-show.show')?  $('#gallery .gallery-show.show') : $('#gallery .gallery-show:first'));
	
	// $('#gallery .gallery-show.show img').click(function() { alert('arf'); gallery() });

	// Image suivante
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery .gallery-show:first') :current.next()) : $('#gallery .gallery-show:first'));

	// Effet de transition
	next.css("z-index",zindex);
	next.css({
	display: 'block',
	opacity: 0.0
	})
	.addClass('show')
	.animate({opacity: 1.0}, 1500, upd);

	// Disparition
	function upd() {
	current.css({display: 'none'}).removeClass('show');
	}

}

