$(document).ready(function(){
    // Mode compatible avec Mootools
    //jQuery.noConflict();
    // On cache toutes les images de type : diaporama, extrait de gallerie, grille d'image
    $(".IMG-Grille,.IllustrationDroite,#JournalGallerie img").css({'opacity':0,'visibility':'visible'});
    // Boucle sur les images pour gérer le chargement
    $("img").each(function(index,el){
        if (el.complete){
            $(this).animate({ opacity: 1 }, 1500);
        } else {
            $(el).load(function(){
            	$(this).animate({ opacity: 1 }, 1500);
            });
        }
    });

    // Tooltip sur le pied de page
    $("#PiedDePage>p>a[title]").tooltip({
        // place tooltip on the right edge
        position: "center right",
        // a little tweaking of the position
        offset: [0, 0],
        // use the built-in fadeIn/fadeOut effect
        effect: "fade",
        // use this single tooltip element
        tip: '#tooltip'
    });

    // Effet sur les images du menu général
    $('.MenuNB').hover(function(){$(this).stop().animate({ opacity: 0 }, 100);}, function() {$(this).stop().animate({ opacity: 1 }, 1500);});
    // Affichage des bulles sur les éléments du menu
     $(".MenuImage[title]").tooltip({
        // place tooltip on the right edge
         position: "center left",
        // a little tweaking of the position
         offset: [0, 0],
        // use the built-in fadeIn/fadeOut effect
         effect: "fade",
        // use this single tooltip element
         tip: '#tooltip-menu'
     });
// 
    // Présentation sous forme de diapo automatique (slider)
    if ($("#slider").length!=0){
        $('#slider').s3Slider({
           timeOut: 3000
        });
    }

    // LES GRAINES/PLANTES DÉCHETS
    if ($(".IMGGraine").length!=0){
        // Effet sur les images des graines
        $('.IMGGraine').hover(function(){$(this).stop().animate({ opacity: 0 }, 1000);}, function() {$(this).stop().animate({ opacity: 1 }, 1000);});
        // Affichage des bulles sur les éléments du menu
        $(".IMGGraine[title]").tooltip({
            // place tooltip on the right edge
            position: "bottom center",
            // a little tweaking of the position
            offset: [0, 0],
            // use the built-in fadeIn/fadeOut effect
            effect: "fade",
            // use this single tooltip element
            tip: '#tooltip'
        });
    }


    // CARNET DE BORD
    if ($(".IllustrationDroite").length!=0){
        // Affichage des bulles sur les éléments du menu
        $(".IllustrationDroite[title]").tooltip({
            // place tooltip on the right edge
            position: "bottom center",
            // a little tweaking of the position
            offset: [0, 0],
            // use the built-in fadeIn/fadeOut effect
            effect: "fade",
            // use this single tooltip element
            tip: '#tooltip'
        });
        
        // Effet de survol de l'aperçu dans les news
        $('.IllustrationDroite').hover(function(){$(this).stop().animate({ opacity: 0.5 }, 100);}, function() {$(this).stop().animate({ opacity: 1 }, 1000);});
    }


    // GRILLE D'IMAGES
    if ($("#UL-Grille").length!=0){
        // Affichage des bulles sur les éléments du menu
        $(".A-Grille[title]").tooltip({
            // place tooltip on the right edge
            position: "top center",
            // a little tweaking of the position
            offset: [30, 0],
            // use the built-in fadeIn/fadeOut effect
            effect: "fade",
            // use this single tooltip element
            tip: '#tooltip'
        });
        $('.A-Grille').hover(function(){$(">img",this).stop().animate({ opacity: 0.5 }, 100);}, function() {$(">img",this).stop().animate({ opacity: 1 }, 1000);});

        // Overlay pour présentation de la gallerie
        $("#UL-Grille a").overlay({
            // each trigger uses the same overlay with the id "gallery"
            target: '#OverlayGallery',
            // optional exposing effect
            expose: 'black'
        // let the gallery plugin do its magic!
        }).gallery({
            // the plugin accepts its own set of configuration options
            speed: 800,
            template:'<strong>${title}</strong>'
        });
    }

    // DEMARCHE / CONTACT
    if ($("#FloatRight").length!=0){
        // Affichage des bulles sur les éléments du menu
        $("#FloatRight[title]").tooltip({
            // place tooltip on the right edge
            position: "bottom center",
            // a little tweaking of the position
            offset: [0, 0],
            // use the built-in fadeIn/fadeOut effect
            effect: "fade",
            // use this single tooltip element
            tip: '#tooltip'
        });
        $("#DossierArtistique a[title]").tooltip({
            // place tooltip on the right edge
            position: "bottom center",
            // a little tweaking of the position
            offset: [0, 0],
            // use the built-in fadeIn/fadeOut effect
            effect: "fade",
            // use this single tooltip element
            tip: '#tooltip'
        });
    }

});

