
function ridimensiona(altezza, larghezza, ratio) {
    var alt;
    var lar;
    var x = 0;
    var y = 0;
    var spazio_verticale;

    lar = ($(window).width() < larghezza) ? larghezza : $(window).width();
    alt = ($(window).height() < altezza) ? altezza : $(window).height();

    //alert(lar + " " + alt);

    spazio_verticale = $(window).height() - 122;
    $("#container").css("width", $(window).width() + "px");
    $("#container").css("height", spazio_verticale + "px");
    $("#contenitoregallery").css("height", "0px");
    $("#contenitoregallery").css("height", "0px");
    $("#contenitoregallery").hide();
    //$("#box]").css("width", (($(window).width() > 800) ? 800 : $(window).width()) + "px");
    //$("#box]").css("height", ((spazio_verticale-80>600) ? 600 : spazio_verticale-80) + "px");

    var spaziovideo = ((spazio_verticale - 70) > 520 ? 520 : spazio_verticale - 70);
    $("#tabVideoCentro").css("height", spaziovideo + "px");
    $("#frameVideo").attr("height", spaziovideo);
    if (($(window).width() / $(window).height()) > ratio) {
        //ORIZZONTALE

        alt = parseInt(lar / ratio);
        //  alert("oriz " + lar + " " + alt);


        if (alt > ($(window).height())) {
            y = parseInt(((alt - spazio_verticale) / 2) - 64);
        }
        //alert(y);
        var f = document.getElementById("dissolvenza");
        if (f != null) {
            f.width = lar;
            f.height = alt;
            f.style.top = ((y <= 0) ? "0" : "-" + y) + "px";
            f.style.left = "0px";
        }
        else {
            $("#contenitore").css("width", $(window).width() + "px");
            $("#contenitore").css("height", spazio_verticale + "px");

        }

        var f = document.getElementById("dissolvenza2");
        if (f != null) {
            f.width = lar;
            f.height = alt;
        }

        $("img[id$='imgSfondo']").css("width", lar + "px");
        $("img[id$='imgSfondo']").css("height", alt + "px");
        $("img[id$='imgSfondo']").css("top", ((y <= 0) ? "0" : "-" + y) + "px");
        $("img[id$='imgSfondo']").css("left", "0px");

    }
    else {
        //VERTICALE
        lar = parseInt(alt * ratio);
        //alert("vert " + lar + " " + alt);

        if (lar > ($(window).width())) {
            x = parseInt(((lar - $(window).width()) / 2));
        }
        // alert(x);
        var f = document.getElementById("dissolvenza");
        if (f != null) {
            f.width = lar + "px";
            f.height = alt + "px";
            f.style.top = "0px";
            f.style.left = ((x <= 0) ? "0" : "-" + x) + "px";
        }
        else {
            $("#contenitore").css("width", $(window).width() + "px");
            $("#contenitore").css("height", spazio_verticale + "px");

        }
        var f = document.getElementById("dissolvenza2");
        if (f != null) {
            f.width = lar;
            f.height = alt;
        }
    }
    $("img[id$='imgSfondo']").css("width", lar + "px");
    $("img[id$='imgSfondo']").css("height", alt + "px");
    $("img[id$='imgSfondo']").css("left", ((x <= 0) ? "0" : "-" + x) + "px");
    $("img[id$='imgSfondo']").css("top", "0px");

}


function ridimensionagallery(altezza, larghezza, ratio) {
    var alt;
    var lar;
    var x = 0;
    var y = 0;
    var spazio_verticale;

    lar = ($(window).width() < larghezza) ? larghezza : $(window).width();
    alt = ($(window).height() < altezza) ? altezza : $(window).height();

    //alert(lar + " " + alt);

    spazio_verticale = $(window).height() - 122;
    //$("#gallery").css("width", $(window).width() + "px");
   // $("#contenitoregallery").css("width", "100%");
   // $("#contenitoregallery").css("height", spazio_verticale + "px");
    $("#contenitore").css("width", "0px");
    $("#contenitore").css("height", "0px");
    $("#container").css("width", "0px");
    $("#container").css("height", "0px");
    $("#contenitoregallery").show();
    //$("#box]").css("width", (($(window).width() > 800) ? 800 : $(window).width()) + "px");
    //$("#box]").css("height", ((spazio_verticale-80>600) ? 600 : spazio_verticale-80) + "px");

    var spaziovideo = ((spazio_verticale - 70) > 520 ? 520 : spazio_verticale - 70);
    $("#tabVideoCentro").css("height", spaziovideo + "px");
    $("#frameVideo").attr("height", spaziovideo);
   

}						
