﻿
function setContentSize() 
{
    var iMinHeight = 878;
    var iScrollDiff = 501;
    var iScrollMin = 377;
    var iScrollMax = 400;

    if ($(window).width() < 1024 || $(window).height() < 768) 
    {
        iResolution = 1024; /* 1024 */
        $("#stylesheet").attr("href", "css/" + iProjektID + "/1024.css");

        // Flash im Contentmodul
        $(".divContentFlash").css("width", 303).css("height", 215);

        $("#objFlash").attr("width", 296);
        $("#objFlash").attr("height", 215);
        $("#objEmbed").attr("width", 296);
        $("#objEmbed").attr("height", 215);

        /* Newsboxen */
        $(".divNewsBox img").attr("src", function (i, a) 
        {
            if (typeof (a) != 'undefined' && a.indexOf("urlImageResize") > -1) 
            {
                if (typeof ($(".divNews img").attr("src")) != 'undefined') 
                {
                    a = addParamToUrl(a, "h", "121", false);
                    if (a.indexOf("mode=big") > -1) 
                    {
                        a = addParamToUrl(a, "w", "82", false);
                    }
                }
                else
                {
                    a = addParamToUrl(a, "h", "106", false);
                    if (a.indexOf("mode=big") > -1) 
                    {
                        a = addParamToUrl(a, "w", "71", false);
                    }
                }

                $(this).attr("src", a);
            }
        });

        /* Header - Flash */
        $(".divStartseite #objFlash").attr("width", 780);
        $(".divStartseite #objEmbed").attr("width", 780);
        $(".divStartseite #objFlash").attr("height", 389);
        $(".divStartseite #objEmbed").attr("height", 389);

        /* Newsboxen - Flash */
        if (typeof ($(".divNews img").attr("src")) != 'undefined') {
            /* Startseite */
            $(".divNewsBox #objFlash").attr("width", 257);
            $(".divNewsBox #objEmbed").attr("width", 257);
            $(".divNewsBox #objFlash").attr("height", 121);
            $(".divNewsBox #objEmbed").attr("height", 121);
        }
        else {
            /* Sonstige */
            $(".divNewsBox #objFlash").attr("width", 223);
            $(".divNewsBox #objEmbed").attr("width", 223);
            $(".divNewsBox #objFlash").attr("height", 106);
            $(".divNewsBox #objEmbed").attr("height", 106);
        }

        /* Bilder */
        $(".divContent img").attr("src", function (i, a) 
        {           
            if (a.indexOf("Icons") > -1) 
            {
                a = addParamToUrl(a, "w", "164", false);
                a = addParamToUrl(a, "h", "109", false);
            }

            if (a.indexOf("gutschein") > -1) { $(this).attr("width", 531); }

            if (typeof (a) != 'undefined' && a.indexOf("urlImageResize") > -1) 
            {
                if (a.indexOf("contentbilder/") > -1) {
                    a = addParamToUrl(a, "w", "158", false);
                    a = addParamToUrl(a, "h", "105", false);
                }

                if (a.indexOf("pluginProduktpalette/") > -1) 
                {
                    a = addParamToUrl(a, "w", "150", false);
                    a = addParamToUrl(a, "h", "76", false);
                }

                if (a.indexOf("pressefederer/") > -1) 
                {
                    if (i == 0) {
                        a = addParamToUrl(a, "w", "139", false);
                        a = addParamToUrl(a, "h", "194", false);
                    }
                    else {
                        a = addParamToUrl(a, "w", "67", false);
                        a = addParamToUrl(a, "h", "93", false);
                    }
                }                

                $(this).attr("src", a);
            }
        });

        /* Flyer-Bilder */
        $(".divFlyer img").attr("src", function (i, a) 
        {
            if (typeof (a) != 'undefined' && a.indexOf("urlImageResize") > -1) 
            {
                if (a.indexOf("contentbilder/") > -1) 
                {
                    a = addParamToUrl(a, "w", "66", false);
                    a = addParamToUrl(a, "h", "0", false);
                }

                $(this).attr("src", a);
            }
        });

        /* Content */
        $(".divBilder").attr("id", function (i, a) 
        {
            if ($("#" + a).children().length > 1)
                 { $("#" + a).width(493).height(120); }
            else { $("#" + a).width(180); }
        });

        /* Kontakt */
        if (iProjektID == 128) 
        {
            $("#MainContent_txtStrasse").width(333);
            $("#MainContent_txtMessage").width(333).height(73);
        }
        else 
        {
            $("#MainContent_txtStrasse").width(494);
            $("#MainContent_txtMessage").width(494).height(24);
        }

        iMinHeight = 600;
        iScrollDiff = 345;
        iScrollMin = 255;
        iScrollMax = 270;
    }
    else 
    {
        iResolution = 1280; /* 1280 */
        $("#stylesheet").attr("href", "css/" + iProjektID + "/style.css");

        // Flash in Contentmodul
        $(".divContentFlash").css("width", 443).css("height", 307);

        $(".divContent #objFlash").attr("width", 423);
        $(".divContent #objFlash").attr("height", 307);
        $(".divContent #objEmbed").attr("width", 423);
        $(".divContent #objEmbed").attr("height", 307);

        /* Newsboxen */
        $(".divNewsBox img").attr("src", function (i, a) 
        {
            if (typeof (a) != 'undefined' && a.indexOf("urlImageResize") > -1) 
            {
                if (typeof ($(".divNews img").attr("src")) != 'undefined') 
                {
                    a = addParamToUrl(a, "h", "173", false);
                    if (a.indexOf("mode=big") > -1) 
                    {
                        a = addParamToUrl(a, "w", "118", false);
                    }
                }
                else
                {
                    a = addParamToUrl(a, "h", "152", false);
                    if (a.indexOf("mode=big") > -1) 
                    {
                        a = addParamToUrl(a, "w", "102", false);
                    }
                }

                $(this).attr("src", a);
            }
        });

        /* Header - Flash */
        $(".divStartseite #objFlash").attr("width", 1115);
        $(".divStartseite #objEmbed").attr("width", 1115);
        $(".divStartseite #objFlash").attr("height", 558);
        $(".divStartseite #objEmbed").attr("height", 558);

        /* Newsboxen - Flash */
        if (typeof ($(".divNews img").attr("src")) != 'undefined') 
        {
            /* Startseite */
            $(".divNewsBox #objFlash").attr("width", 367);
            $(".divNewsBox #objEmbed").attr("width", 367);
            $(".divNewsBox #objFlash").attr("height", 173);
            $(".divNewsBox #objEmbed").attr("height", 173);
        }
        else 
        {
            /* Sonstige */
            $(".divNewsBox #objFlash").attr("width", 319);
            $(".divNewsBox #objEmbed").attr("width", 319);
            $(".divNewsBox #objFlash").attr("height", 152);
            $(".divNewsBox #objEmbed").attr("height", 152);
        }

        /* Bilder */
        $(".divContent img").attr("src", function (i, a) 
        {
            if (a.indexOf("gutschein") > -1) { $(this).attr("width", 759); }

            if (typeof (a) != 'undefined' && a.indexOf("urlImageResize") > -1) 
            {
                if (a.indexOf("contentbilder/") > -1) {
                    a = addParamToUrl(a, "w", "234", false);
                    a = addParamToUrl(a, "h", "156", false);
                }

                if (a.indexOf("pluginProduktpalette/") > -1) {
                    a = addParamToUrl(a, "w", "215", false);
                    a = addParamToUrl(a, "h", "122", false);
                }

                if (a.indexOf("pressefederer/") > -1) {
                    if (i == 0) {
                        a = addParamToUrl(a, "w", "199", false);
                        a = addParamToUrl(a, "h", "277", false);
                    }
                    else {
                        a = addParamToUrl(a, "w", "96", false);
                        a = addParamToUrl(a, "h", "0", false);
                    }
                }

                $(this).attr("src", a);
            }
        });

        /* Flyer-Bilder */
        $(".divFlyer img").attr("src", function (i, a) {
            if (typeof (a) != 'undefined' && a.indexOf("urlImageResize") > -1) {
                if (a.indexOf("contentbilder/") > -1) {
                    a = addParamToUrl(a, "w", "98", false);
                    a = addParamToUrl(a, "h", "0", false);
                }

                $(this).attr("src", a);
            }
        });

        /* Content */
        $(".divBilder").attr("id", function (i, a) {
            if ($("#" + a).children().length > 1)
                 { $("#" + a).width(720).height(170); }
            else { $("#" + a).width(255); }
        });

        /* Kontakt */
        if (iProjektID == 128) {
            $("#MainContent_txtStrasse").width(476);
            $("#MainContent_txtMessage").width(476).height(104);
        }
        else {
            $("#MainContent_txtStrasse").width(533);
            $("#MainContent_txtMessage").width(533).height(104);
        }
    }

    $(".divContentMaster").css("height", $(window).height() - $(".divHeader").height());

    /* Newsboxen - Blur positionierung */
    if (iProjektID == "128") {
        var top = "115px"; var topBox = "130px";

        if ($(window).width() < 1024 || $(window).height() < 768) {
            top = "81px"; topBox = "93px";
        }

        /* Wenn Startseite */
        if ($(".divNews").html() != null) { top = topBox; }

        $(".divBlur").css("top", top);

        $('#divNewsClipBox').hover(
                function () { $(".divBlur").animate({ top: '0px' }, { queue: false, duration: 500 }); },
                function () { $(".divBlur").animate({ top: top }, { queue: false, duration: 500 }); }
            );
    }
    else {
        var top = "122px"; var topBox = "139px";

        if ($(window).width() < 1024 || $(window).height() < 768) {
            top = "85px"; topBox = "97px";
        }

        if ($(".divSlogan img").attr("src").indexOf("Gross") > -1) { top = topBox; }

        $(".divBlur").css("top", top);

        $('#divNewsbox1').hover
            (
               function () { $("#divBlur1").animate({ top: '-1px' }, { queue: false, duration: 500 }); },
               function () { $("#divBlur1").animate({ top: top }, { queue: false, duration: 500 }); }
            );

        $('#divNewsbox2').hover
            (
                function () { $("#divBlur2").animate({ top: '-1px' }, { queue: false, duration: 500 }); },
                function () { $("#divBlur2").animate({ top: top }, { queue: false, duration: 500 }); }
            );

        $('#divNewsbox3').hover
            (
                function () { $("#divBlur3").animate({ top: '-1px' }, { queue: false, duration: 500 }); },
                function () { $("#divBlur3").animate({ top: top }, { queue: false, duration: 500 }); }
            );
    }

    /* Lageplan */
    try { changeLageplanReiter(iLageplanIndex); } catch (err) { }

    /* Scrollbalken */
    $(".divScrollbar").css("height", $(window).height() - iScrollDiff);

    // Wenn (Scrollbar < Min) => An Newsboxen angleichen
    if ($(".divScrollbar").height() < iScrollMax) { $(".divScrollbar").css("height", iScrollMin); }

    if ($(window).height() < iMinHeight) {
        // Braucht kein Scrollbalken
        $(".divScrollbar").css("overflow", "hidden");
        $(".divScrollbar").css("height", "auto");
    }
    else {
        // Braucht Scrollbalken
        if ($(".divScrollbar").css("overflow") == "hidden") {
            $(".divScrollbar").css("overflow", "auto");
            $(".divScrollbar").css("height", iScrollMin);
        }
    }

    if (window.navigator.appVersion.indexOf("MSIE 7.0") > -1) {
        $(".divScrollbar").height($(".divScrollbar").height() + 3);
    }

    if (iResolution == 1024 && window.location.href.indexOf("kontakt.aspx") > -1) 
    {
        if ($(".divScrollbar").height() > 355 || $(".divScrollbar").css("overflow") == "hidden")
             { $(".divScrollbar .divLinks").css("padding", "10px 10px 0px 10px"); }
        else { $(".divScrollbar .divLinks").css("padding", "10px 0px 0px 5px"); }

        $(".divScrollbar").css("overflow") == "hidden";
    }

    if (iMobile == 1 ||
           window.location.href.indexOf("lageplan.aspx") > -1 ||
           window.location.href.indexOf("oeffnungszeiten.aspx") > -1 ||
          (window.location.href.indexOf("kontakt.aspx") > -1 && iProjektID == 134)) {
        // Braucht kein Scrollbalken
        $(".divScrollbar").css("overflow", "hidden");
        $(".divScrollbar").css("height", "auto");
    }
}
