// centrage vertical du contenu
function centreVerticalcontenu() {
    var ContenuMarginTop = ($(".trame").height() - ($("#contenu").height())) / 2 - 50;

    if (ContenuMarginTop <= 0) {
        ContenuMarginTop = 1;
    }

    $("#contenu").stop(false, true).animate(
        { marginTop: ContenuMarginTop },
        "fast",
        "swing"
    );
}

function resize_viewport() {
    $("#borderL, #borderR").height($("#supersized").height());

    // redimensionne la trame
    supersized_height = $("#supersized").height();

    //Trame height = height du supersized (100%) - height du footer - height de la barre d'actu - height du menu top - position top du menu top (= son margin-top en fait), comme ça il est situé que sur le centre
    trame_height = supersized_height - $('#footer').height() - $('.actu_cont:first').height() - $('#menu_top').height() - $('#menu_top').offset().top;

    $(".trame").height(trame_height);

    if($('#google_map').length) {
        $("#google_map").height($("#supersized").height() - $("#google_map").offset().top - $("#footer").height());
        $("#google_map").width($("#supersized").width() - $("#borderL").width() - $("#borderR").width() + 5);
    }
    // centrage vertical du contenu
    centreVerticalcontenu();

    return false;
}

$(window).resize(resize_viewport);

$(document).ready(function () {
    /* galerie phototheque */
    $(".p_galerie_bg").hover(function () {
        $(this).find("h2").stop(false, true).animate(
            { bottom: 0 },
            "fast",
            "swing"
        );
    }, function () {
        $(this).find("h2").stop(false, true).animate(
            { bottom: -50 }, // what we are animating
            "fast", // how fast we are animating
            "swing"
        );
    });

    /* recherche concession */
    $("body").delegate(".js_radio", "click", function (event) {
        event.preventDefault();
        $(this).prev("input[type=radio]").click();
    });
});
