﻿ScreenHelper = {
    "availWidth": function() {
        return window.innerWidth != null ?
                window.innerWidth : document.documentElement && document.documentElement.clientWidth ?
                    document.documentElement.clientWidth :
                        document.body != null ?
                            document.body.clientWidth : null;
    },
    "availHeight": function() {
        return window.innerHeight != null ?
                window.innerHeight : document.documentElement && document.documentElement.clientHeight ?
                    document.documentElement.clientHeight :
                            document.body != null ?
                                document.body.clientHeight : null;
    },
    "screenWidth": function() {
        return screen.width;
    },
    "screenHeight": function() {
        return screen.height;
    },
    'isIE': navigator.appName.indexOf("Explorer") != -1,
    'isFF': navigator.userAgent.toString().indexOf("Firefox") != -1,
    'isOP': navigator.userAgent.toString().indexOf("Opera") != -1,
    'isIE6': (navigator.userAgent.indexOf("MSIE") && navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE") + 5, navigator.userAgent.indexOf("MSIE") + 6) == "6"),
    'isIE7': (navigator.userAgent.indexOf("MSIE") && navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE") + 5, navigator.userAgent.indexOf("MSIE") + 6) == "7"),
    'IEVersion' : (navigator.userAgent.indexOf("MSIE") && navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE") + 5, navigator.userAgent.indexOf("MSIE") + 6))
}

ScreenAjust = {
    "ajust": function() {
        var availWidth = ScreenHelper.availWidth();
        var availHeight = ScreenHelper.availHeight();

        var elementLogo = document.getElementById("ctl00_imageBanner");
        elementLogo.style.width = availWidth - ((!ScreenHelper.isIE) ? 17 : 0) + "px";
        elementLogo.style.height = "100px";
        var marginLeft = 220;
        var elementPanelBannerNota = document.getElementById("tableBannerNota");
        if (elementPanelBannerNota != null) {
            elementPanelBannerNota.style.width = availWidth - ((ScreenHelper.isIE) ? ((ScreenHelper.IEVersion > "7") ? 365 : 378) : 388) + "px";
            if (ScreenHelper.isIE && ScreenHelper.IEVersion <= "7") {
                elementPanelBannerNota.style.marginLeft = "220px";
                marginLeft = "-220px";
            }
            else {
                elementPanelBannerNota.style.marginLeft = "210px";
                marginLeft = "-220px";
                document.getElementById("tdBordaEsquerdaBanner").style.width = "12px";
                document.getElementById("tdBordaDireitaBanner").style.width = "13px";
            }
        }

        var elementPanelRodape = document.getElementById("divRodape");
        if (elementPanelRodape != null) {
            //elementPanelRodape.style.marginLeft = marginLeft;
            elementPanelRodape.style.width = availWidth - ((!ScreenHelper.isIE) ? 27 : 10) + "px";
        }

        var elementLinhaSeparacaoConteudo = document.getElementById("linhaSeparacaoConteudo");
        if (elementLinhaSeparacaoConteudo != null)
            elementLinhaSeparacaoConteudo.style.width = availWidth - ((ScreenHelper.isIE) ? 378 : 395) + "px";
        var elementDivContentPlaceHolder = document.getElementById("divContentPlaceHolder");
        if (elementDivContentPlaceHolder != null) {
            elementDivContentPlaceHolder.style.width = availWidth - ((ScreenHelper.isIE) ? 378 : 395) + "px";
        }

        var elementImageLogoBoaNota = document.getElementById("ctl00_imageLogoBoaNota");

        if (ScreenHelper.screenWidth() == 800 || availWidth <= 800) {

            if (elementImageLogoBoaNota != null)
                elementImageLogoBoaNota.style.width = "200px";
        }
        else if (ScreenHelper.screenWidth() > 800 || availWidth > 800) {
            if (elementImageLogoBoaNota != null)
                elementImageLogoBoaNota.style.width = "257px";
        }

        var elementDuvidas = document.getElementById("ctl00_contentPlaceHolderConteudo_treeViewDuvidas");
        if (elementDuvidas != null)
            elementDuvidas.style.width = availWidth - 380 + "px";

    }
}
