/*
**  Utilisation de la librairie jQuery
**  http://docs.jquery.com/Downloading_jQuery#Download_jQuery
*/
jQuery.noConflict();

jQuery(document).ready(function($){

    /* placeHolder */

        var valuePlaceHolder = new Array();
        
        $('.placeHolder').each(function(index) {
            
            valuePlaceHolder[index] = $(this).attr('value');

            $(this).focus(function () {
                if (this.value == valuePlaceHolder[index]) this.value = '';
            }).blur(function () {
                if (this.value == '') this.value = valuePlaceHolder[index];
            });
        });
        
    /* Menu classique déroulant */

        /*
        $('#mainNav>li').hover(function() {
            $(this).addClass('jHover');
            $(this).find('ul').delay(100).slideDown();
        }, function() {
            $(this).removeClass('jHover');
            $(this).find('ul').stop(true, true).slideUp();
        });

        $('#mainNav>li>a').focus(function() {
            $('#mainNav>li').removeClass('jHover').find('ul').hide();
            $(this).parent().addClass('jHover').find('ul').show();
        });

        $('#container a, #header .barreLangues a').focus(function() {
            $('#mainNav>li').removeClass('jHover');
        });
        */
    
    /* Gestion des onglets de navigation */
    
    
        /*
        if ( $("#content .onglets li a.current").length ) // si on a un onglet activé par défaut on l'affiche
        {
            $("#content .contentOnglets>li:not(:eq("+$("#content .onglets").show().find("li a.current").parent().index()+"))").hide();
        }
        else // sinon on affiche le 1er onglet
        {
            $("#content .onglets").show().find("li:first a").addClass("current");
            $("#content .contentOnglets>li:not(:first)").hide();
        }
        
        
        if ($.browser.msie && $.browser.version.substr(0,1) == 6) {
            
            // Corrige probleme de calcul de hauteur sur IE6 (footer tjs en bas)
            $('#global').height($('#global').height());
            $('#global').height('100%');
            
            // Fixbug sur select
            $(".btLightbox").click(function(){ $("select").hide(); });
            $(".lightBox .fermer a").click(function(){ $("select").show(); });
            
        }
        
        
        $("#content .onglets li").delegate("a", "click", function(e){
        
            $(this).parent().parent().find("a.current").removeClass("current");
            
            $("#content .contentOnglets>li:visible").hide();        
            $("#content .contentOnglets>li:eq("+$(this).addClass("current").parent().index()+")").show();
            
            this.blur();
            e.preventDefault();
        });
        */
        
    /* Exemple lancement Carousel */
        /*
        $('.carousel').carouselSlide({
            manual: true, 
            auto: false,
            speed: 1000,
            item_deplace: 1,
            vertical: false,
            pagination: false
        });
        
        $('.carousel .item a').click(function(e) {
        
            // alert($(this).attr('href').substr(-3)); // fonctionne différement sous IE et firefox...
            
            // variante
            var myString = $(this).attr('href').toLowerCase();
            var myStringLength = myString.length;

            if ( myString.substring(myStringLength-3, myStringLength) == 'flv' ) // si c un flv
            {
                $(this).closest('.carousel').find('.apercuCarousel a').hide();
                $(this).closest('.carousel').find('#blocVideo').show();
            
                var srcFlv = $(this).attr('href').replace('/flash/', ''); // .replace('/flash/', '') a retirer pour mise en ligne
                
                var flashvars = {
                  flv: srcFlv,
                  autoplay: "1",
                  autoload: "1",
                  margin: "0",
                  showvolume: "1",
                  showstop: "1",
                  showtime: "1",
                  width: "242",
                  height: "190"
                };

                var params = {
                  allowFullScreen: "true",
                  wmode: "transparent"
                };
                var attributes = {};
                
                swfobject.embedSWF("flash/player_flv.swf", "blocVideo", "242", "190", "9.0.0","flash/expressInstall.swf", flashvars, params, attributes);
            }
            else
            {
                $(this).closest('.carousel').find('.apercuCarousel a').show();
                $(this).closest('.carousel').find('#blocVideo').hide();

                $(this).closest('.carousel').find('.apercuCarousel a').attr('href',$(this).attr('href')).find('img').attr('src',$(this).attr('href')).attr('alt',$(this).attr('title'));
            }
            
            this.blur();
            e.preventDefault();
        });
        
        */
    
    
    /* Gestion de la toolbar taille texte et impression */
    
        
        $('#content .barreOutils .imprim').click(function (e) {
            window.print();
            e.preventDefault();
        });
        
    /* Gestion des lightbox */
    
    /*
    // Gère l'affichage des photos en grands // le each évite les boutons prev et next sur les carousels sessions
    $('#content .carousel').each(function() { $(this).find('.apercuCarousel a').lightBox(); });
    */
    
    /* Lightbox **/

        $(".btLightbox").click(function(){
            $("#overlayLightbox").show();
            $("#"+$(this).attr('rel')+"Box").show();
            this.blur();
            return false;
        });

        $(".lightBox .fermer a, #overlayLightbox").click(function(){
            $("#overlayLightbox").hide();
            $("body>.lightBox:visible").hide();
            
            this.blur();
            return false;
        });
    
    
    /* Ajustement hauteur page automatique */
    
        /*
        $(window).bind('load resize',function() {
            $('#global').height($(window).height());
        });
        */


}); /* jQuery end */

/**
// Debug mode
**
function log($message) {
    if (console && console.log)
        console.log($message);
    else
        alert($message);
}

function info($message) {
    if (console && console.info)
        console.info($message);
    else
        alert($message);
}

function warn($message) {
    if (console && console.warn)
        console.warn($message);
    else
        alert($message);
}

function error($message) {
    if (console && console.error)
        console.error($message);
    else
        alert($message);
}
/* Debug end */
