 $(document).ready(function() {

        $(".main_image .desc").show(); //afficher la description de l'image
        //$("a.collapse").toggleClass("show");
        //$(".main_image .block").slideToggle();
        $(".main_image .block").animate({ opacity: 0.85 }, 1 ); //transparence

        //Action sur les miniatures
        $(".image_thumb ul li:first").addClass('active');
        $(".image_thumb ul li").live('click',function(e){

			pageTracker._trackEvent("jeu", "affichage", $(this).find('img').attr("alt")); // ça c'est juste pour moi ;

            //Set Variables
            var imgAlt = $(this).find('img').attr("alt"); //recupere l'attribut alt de l'image
            var imgTitle = $(this).find('a').attr("href"); //recupere l'url de l'image
            var imgDesc = $(this).find('.block').html(); 	//recupere le code HTML de l'element (class) 'block'
            var imgDescHeight = $(".main_image").find('.block').height();	//Calcul la hauteur de l'element (class) 'block' (la hauteur depend de ce qui se trouve dans le block ; plus loin je fixe cette hauteur à 140px)

			if ($(this).is(".active")) {  //si la miniature est deja selectionnée...

				return false; // ... rien ne se passe...

			} else {  //...sinon...
                //..affichage des images
				$('.main_image img').hide(500);
                $(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
                    $(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 ).height(140);
                    //$(".main_image img").attr({ src: imgTitle , alt: imgAlt}); // affichage de l'image correspondante

					img = new Image();
					img.onload = function(){
						$('.main_image img').attr({ src: img.src , alt: imgAlt}).show(1000).show(1000);
					}
					img.src = imgTitle;

					/********************/		//test
				    /*$('.main_image img').load(function () {
				        //$('.main_image img').attr({ src : imgTitle});
					}).attr({ src: imgTitle , alt: imgAlt}).show(1000);*/
					/********************/
                });
            }

            $(".image_thumb ul li").removeClass('active'); //enleve la class 'active' de toutes les listes
            $(this).addClass('active');  //ajoute la class 'active' à la liste selectionnée
            return false;

        }) .hover(function(){
            $(this).addClass('hover');
        }, function() {
            $(this).removeClass('hover');
        });

        //Afficher / masquer les infos
        $("a.collapse").click(function(){
            $(".main_image .block").slideToggle();
            $("a.collapse").toggleClass("show");
        });


		$('.gallerie_jeu').live('click',function(e){
			e.preventDefault();
			var dossier = (this.hash).substr(1); //alert(dossier);
			$('.main_image .block')
				.animate({ opacity: 1,	height:($('.main_image').height()) }, 250 )
				.append('<div id="captures_img"></div><span><a id="fermer_gal" href="">fermer la gallerie</a></span>');

				//$('#captures_img').load('img/captures/gallerie_img.php');
				$.post('img/captures/gallerie_img.php', {dossier :dossier},function(data) {
					$('#captures_img').html(data);
				});
		});

		$('#fermer_gal').live('click',function(e){
			e.preventDefault();
			$(".main_image .block").animate({ opacity: 0.85,	height:'140px' }, 250 );
		});


		/** test ^^
		$(".image_thumb ul li").live('click',function(e){
			e.preventDefault();
			pageTracker._trackEvent("jeu", "affichage", $(this).find('img').attr("alt"));
		});
		**/


});