(function($) {
$(document).ready(function() {
	$("#galerie").hide();
	setTimeout("message();",5000);
});
$(document).ready(function(){
			$("ul.thumb li").hover(function() {
	$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
			marginTop: '-75px', /* The next 4 lines will vertically align this image */ 
			marginLeft: '-75px',
			top: '50%',
			left: '50%',
			width: '120px', /* Set new width */
			height: '120px', /* Set new height */
			padding: '10px'
		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

	} , function() {
	$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
	$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
			marginTop: '0', /* Set alignment back to default */
			marginLeft: '0',
			top: '0',
			left: '0',
			width: '60px', /* Set width back to default */
			height: '60px', /* Set height back to default */
			padding: '5px'
		}, 400);
});
$("ul.thumb li a").click(function() {
			
			var mainImage = $(this).attr("href"); //Find Image Name
			var title1= $(this).attr("title")
			$("#main_view img").attr({ src: mainImage });
			$("#main_view img").attr({ alt: title1 });
			$("#main_view img").attr({ title: title1 });
			$("#main_view a").attr({ href: mainImage });
			$("#main_view a").attr({ title: title1 });
			return false;		
			});
$('#galerie1').fadeIn("slow");
$("#flechePrevious").hide();
//compter le nombre d'image dans la galerie
var nbGaleries=0;
$(".imagedanslagalerie").each(function(i){
   nbGaleries=nbGaleries+1;
});
nbGaleries=Math.ceil(nbGaleries/9);
for(var i=2;i<=nbGaleries;i++)
{
$('#galerie'+i).hide();
}
$("#flecheNext").click(function () {
//recuperation du current visible
var currentGalerie= $('.current:visible').attr("id");
			$('#'+currentGalerie).hide();
			currentGalerie=parseInt(currentGalerie.replace("galerie",""));
			if(currentGalerie<nbGaleries){
				currentGalerie=currentGalerie+1;
			}
			else{
				currentGalerie=1;
			}
			$('#galerie'+currentGalerie).fadeIn("slow");
			$("#flechePrevious").show();
			if(currentGalerie==nbGaleries)
			{
				$("#flecheNext").hide();
			}

});
$("#flechePrevious").click(function () {
			var currentGalerie= $('.current:visible').attr("id");
			$('#'+currentGalerie).hide();
			currentGalerie=parseInt(currentGalerie.replace("galerie",""));
			if(currentGalerie>1){
				currentGalerie=currentGalerie-1;
			}
			else{
				currentGalerie=nbGaleries;
			}
			$('#galerie'+currentGalerie).fadeIn("slow");
			$("#flecheNext").show();
			if(currentGalerie==1)
			{
				$("#flechePrevious").hide();
			}
});
	});

})(jQuery);
function message() {
$("#galerie").fadeTo(1,0.1).slideDown("show").fadeTo(1000,1);
}
