﻿// Designed Raj and SB
// page layout class designed on 14.1.09

function splatPageMetrics()
{
    var m = new Object();

    m.headerDiv = "contentDiv";
    m.footerDiv = "footer";

    m.width = 0;
    m.wWidth = 0; // window width
    m.height = 0;
    m.wHeight = 0; // window height
    m.leftMenuWidth = 0;

    m.headerHeight = 0;
    m.footerHeight = 0;
    m.contentHeight = 0;
    m.contentWidth = 0;

    m.getWindowSize = function()
    {
        var marginLeft = document.body.style.marginLeft;

        if (marginLeft == null || marginLeft == undefined || marginLeft == "")
        {
            marginLeft = document.body.leftMargin;

            if (marginLeft == undefined)
                marginLeft = "0px";
        }

        var marginRight = document.body.style.marginRight;

        if (marginRight == null || marginRight == undefined || marginRight == "")
        {
            marginRight = document.body.rightMargin;

            if (marginRight == undefined)
                marginRight = "0px";
        }

        var marginTop = document.body.style.marginTop;

        if (marginTop == null || marginTop == undefined || marginTop == "")
        {
            marginTop = document.body.topMargin;

            if (marginTop == undefined)
                marginTop = "0px";
        }

        var marginBottom = document.body.style.marginRight;

        if (marginBottom == null || marginBottom == undefined || marginBottom == "")
        {
            marginBottom = document.body.bottomMargin;

            if (marginBottom == undefined)
                marginBottom = "0px";
        }

        var marginWidth = Number(marginLeft.replace("px", "")) + Number(marginRight.replace("px", ""));
        var marginHeight = Number(marginTop.replace("px", "")) + Number(marginBottom.replace("px", ""));

        if (typeof (window.innerWidth) == "number")
        {
            //Non-IE
            m.width = window.innerWidth;
            m.height = window.innerHeight;
        }

        else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
        {
            //IE 6+ in 'standards compliant mode'
            m.width = document.documentElement.clientWidth;
            m.height = document.documentElement.clientHeight;
        }

        else if (document.body && (document.body.clientWidth || document.body.clientHeight))
        {
            //IE 4 compatible
            m.width = document.body.clientWidth;
            m.height = document.body.clientHeight;
        }

        m.wWidth = m.width;
        m.wHeight = m.height;

        m.width -= marginWidth;
        m.height -= marginHeight;
    }

    m.init = function()
    {
        //  get the windows metrics
        this.getWindowSize();

        // substracting the header and footer height to get the content                   
        m.contentHeight = m.height ;
        m.contentWidth = m.width;
    }

    return m;
}


//try
//{
//    progressBarObj.loaded(window.parent.SERVER + 'scripts/splatPageMetrics.js');
//}
//catch (err){}
