$(document).ready(function() {
        //Précharge l'image de loading
        var imgChargement = new Image();
        imgChargement.src = "/ressources/images/loading.gif";
            
        //Click sur une image miniature => afiche la grande dans l'emplacement prévu
        $("#imgMiniatures a").click(function() {
            //Récupère le margin-topde l'img
            var marginTop = $("#imgGrande img").css("margin-top");
            
            //Affiche une img d'attente (en la centrant verticalement)
            $("#imgGrande img").attr("src", imgChargement.src);
            //$("#imgGrande img").css("margin-top", "200px");
            
            //Précharge l'img à afficher. Quand elle est fini de charger (onload) => affichage
            var img = new Image();
            img.src = $(this).attr("href");
            img.onload = function() {
                $("#imgGrande img").css("margin-top", marginTop);
                $("#imgGrande img").attr("src", img.src);
            }

             //$("#imgGrande img").attr("src", $(this).attr("href"));
            return false;
        });
	
        $("a[rel=fancy]").fancybox({
            'transitionIn'	: 'none',
            'transitionOut'     : 'none',
            'titlePosition' 	: 'over',
            'titleFormat'	: function(title, currentArray, currentIndex, currentOpts) {
                    return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
                }
        });

        $("#imgGrande a").tooltip({track: true, showURL: false});
        
        $("#imprimer").click(function() {
           window.print();
           return false;
        });
});
