$(document).ready(function() {
    // creation du style HR dans toutes les pages
    $('hr', 'body').each(function() {
        $(this).replaceWith('<div class="img-hr"></div>');
    });
    // lancement des hovers sur les accordeons
    $('.accordeonTitre').hover(function() {
        $(this).addClass('accordeonTitreHover');
    }, function() {
        $(this).removeClass('accordeonTitreHover');
    });

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

    // lancement des hovers sur les boutons de types ok
    $('.bouton_ok').hover(function() {
        $(this).attr('src', 'static/images/v2/commun/ok_on.gif');
    }, function() {
        $(this).attr('src', 'static/images/v2/commun/ok_off.gif');
    });

    $('#logo-bottom-sidebar').hover(function() {
        $(this).attr('src', 'static/images/v2/commun/logo-bottom-biennale_on.gif');
    }, function() {
        $(this).attr('src', 'static/images/v2/commun/logo-bottom-biennale.gif');
    });

    $('.print').hover(function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/print_on.gif');
    }, function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/print.gif');
    });

    $('.send_friend').hover(function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/send_on.gif');
    }, function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/send.gif');
    });

    $('.love').hover(function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/favorite_on.gif');
    }, function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/favorite.gif');
    });

    $('.facebook').hover(function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/facebook_on.gif');
    }, function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/facebook.gif');
    });

    $('.twitter').hover(function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/twitter_on.gif');
    }, function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/twitter.gif');
    });

    $('.you-tube').hover(function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/you-tube_on.gif');
    }, function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/you-tube.gif');
    });

    $('.video_externe a').hover(function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/puce_video_on.png');
    }, function() {
        $(this).find('img').attr('src', 'static/images/v2/commun/puce_video.png');
    });

    $('.img-diapo-v2').hover(function() {
        $(this).find('img.puce-galerie').attr('src', 'static/images/v2/commun/puce_galerie_on.png');
    }, function() {
        $(this).find('img.puce-galerie').attr('src', 'static/images/v2/commun/puce_galerie.png');
    });

    // calcul de la huateur du contenu pour positionner le logo biennale dans le right side
   // calculHauteurSidebar();

 // Configuration highslide
    $.extend(hs, {
        graphicsDir : base_url + 'static/highslide/graphics/',
        align : 'center',
        expandDuration : 0,
        restoreDuration: 0,
        enableKeyListener: false,
        dimmingOpacity : 0.75
    });
    if (language_js == 'fr') {
        $.extend(hs.lang, {
            loadingText :     'Chargement...',
            loadingTitle :    'Cliquer pour annuler',
            focusTitle :      'Cliquer pour amener au premier plan',
            fullExpandTitle : 'Afficher à la taille réelle',
            fullExpandText :  'Taille réelle',
            creditsText :     '',
            creditsTitle :    '',
            previousText :    'Précédent',
            previousTitle :   'Précédent (flèche gauche)',
            nextText :        'Suivant',
            nextTitle :       'Suivant (flèche droite)',
            moveTitle :       'Déplacer',
            moveText :        'Déplacer',
            closeText :       'Fermer',
            closeTitle :      'Fermer (esc ou Echap)',
            resizeTitle :     'Redimensionner',
            playText :        'Lancer',
            playTitle :       'Lancer le diaporama (barre d\'espace)',
            pauseText :       'Pause',
            pauseTitle :      'Suspendre le diaporama (barre d\'espace)',
            number :          'Image %1 sur %2',
            restoreTitle :    'Cliquer pour fermer l\'image, cliquer et faire glisser pour déplacer, utiliser les touches flèches droite et gauche pour suivant et précédent.'
        });
    }
    hs.registerOverlay({
        html: '<div class="closebutton_'+language_js+'" onclick="return hs.close(this)" title="' + hs.lang.closeText + '"></div>',
        position: 'top right',
        useOnHtml: true,
        fade: 0 // fading the semi-transparent overlay looks bad in IE
    });

});

function UserValidationNewsletter(theform) {
    $('#newsletter .message').html('');
    jQuery(theform).ajaxSubmit({
        success: function(data){
            if (data.substr(0, 7) == 'erreur=') {
                $('#newsletter .message').html(data.substr(7));
            } else {
                $('#newsletter input[name=mail]').val('');
                $(data).insertAfter('#newsletter').css({
                    position : 'relative',
                    top : '5px'
                });
            }
        }
    });
    return false;
}

function modifieHauteurSidebar() {
    setTimeout(calculHauteurSidebar, 300);
}

function calculHauteurSidebar() {
  /*  if ($('#right-side').height() > $('#left-side').height()) {
        $('#left-side').css({
            'height' : ($('#right-side').height())+'px'
        });
    } else if ($('#left-side').height() > 0) {
        Logger($('#left-side').height());
        $('#right-side').css({
            'height' : ($('#left-side').height())+'px'
        });
    }*/
}

$(function() {
    /*$('a.send_friend').fancybox({
        'overlayShow'   :   true,
        'titleShow'     :   true,
        'type'          :   'ajax',
        'titlePosition' :   'inside'
    });*/

    $('a.horaire').fancybox({
        'overlayShow'   :   true,
        'titleShow'     :   true,
        'type'          :   'ajax',
        'titlePosition' :   'inside'
    });

   /* $('a.votez').fancybox({
        'overlayShow'   :   true,
        'titleShow'     :   true,
        'type'          :   'ajax',
        'titlePosition' :   'inside'
    });*/
});
