$(function(){
    //Fancybox
    $("#participer_bouton, #details_des_prix").fancybox({
        'frameWidth': 502,
        'frameHeight': 500,
        'overlayShow': false
    });
    
    $("#comment_participer, #comment_participer_grossir, #comment_participer_2, #participer_bouton, #participer_bouton_2").fancybox({
        'frameWidth': 512,
        'frameHeight': 550,
        'fancy_inner_bgcolor': "#000",
        'overlayShow': false
    });

    $("#reglements").fancybox({
        'frameWidth': 512,
        'frameHeight': 500,
        'overlayShow': false
    });
    
    $(".lien_youtube").fancybox({
        'frameWidth': 565,
        'frameHeight': 345,
        'overlayShow': false
    })
});

var images = [];
function slideSwitch() {
    var active = $('#slideshow a.active');
    var next = '';
    
    if (active.next('a').length) {
        next = active.next('a');
    } else {
        next = $('#slideshow a:first');
    }

    if($.browser.msie){
        //Fix d'un bug d'IE8 qui affichait les photos plus longues même si ils sont cachés.
        $('#slideshow a').each(function(){
           $(this).hide().removeClass('active'); 
        });
    } else {
        active.hide().removeClass('active');
    }

    next.show().addClass('active');
    
    if (!images[next.children('img').attr('src')]) {
        images[next.children('img').attr('src')] = next.children('img').attr('height');
    }
    
    height = images[next.children('img').attr('src')];
    $('#slideshow').animate({height: height}, 1000);
}