var bStandardsCompliantMode

function convertStyleAttribute(sAttribute)
{
    var nPos;
    var sAttr = sAttribute;
    var sTemp;
    var bFirst = true;

    while ((nPos = sAttr.indexOf('-')) != -1)
    {
        if (bFirst)
        {
            sTemp = sAttr.substr(0, nPos).toLowerCase();
            bFirst = false;
        }
        else
            sTemp = sAttr.substr(0, nPos);

        sTemp += sAttr.substr(nPos+1,1).toUpperCase() + sAttr.substr(nPos+2).toLowerCase();
        sAttr = sTemp;
    }
    return(sAttr);
}

function setStyleAttribute(oElement, sAttribute, sValue)
{
    eval('oElement.style.' + convertStyleAttribute(sAttribute) + '=\'' + sValue + '\';');
}

function getStyleAttribute(oElement, sAttribute)
{
    if (typeof(oElement.currentStyle) != 'undefined')
        return(oElement.currentStyle.getAttribute(convertStyleAttribute(sAttribute)));
    else
        return(document.defaultView.getComputedStyle(oElement,null).getPropertyValue(sAttribute));
}

function setAbsoluteWidth(oElement, nValue)
{
    var nRealWidth = nValue;

    if (bStandardsCompliantMode)
    {
        nRealWidth -= parseInt(getStyleAttribute(oElement, 'border-left-width'));
        nRealWidth -= parseInt(getStyleAttribute(oElement, 'border-right-width'));
        nRealWidth -= parseInt(getStyleAttribute(oElement, 'padding-left'));
        nRealWidth -= parseInt(getStyleAttribute(oElement, 'padding-right'));
    }
    setStyleAttribute(oElement, 'width', nRealWidth + 'px');
}

function setAbsoluteHeight(oElement, nValue)
{
    var nRealHeight = nValue;

    if (bStandardsCompliantMode)
    {
        nRealHeight -= parseInt(getStyleAttribute(oElement, 'border-top-width'));
        nRealHeight -= parseInt(getStyleAttribute(oElement, 'border-bottom-width'));
        nRealHeight -= parseInt(getStyleAttribute(oElement, 'padding-top'));
        nRealHeight -= parseInt(getStyleAttribute(oElement, 'padding-bottom'));
    }
    setStyleAttribute(oElement, 'height', nRealHeight + 'px');
}

function getAbsoluteWidth(oElement)
{
    var nRealWidth;

    nRealWidth = parseInt(getStyleAttribute(oElement, 'width'));
    if (isNaN(nRealWidth)) nRealWidth = 0;
    if (bStandardsCompliantMode)
    {
        nRealWidth += parseInt(getStyleAttribute(oElement, 'border-left-width'));
        nRealWidth += parseInt(getStyleAttribute(oElement, 'border-right-width'));
        nRealWidth += parseInt(getStyleAttribute(oElement, 'padding-left'));
        nRealWidth += parseInt(getStyleAttribute(oElement, 'padding-right'));
    }

    return(nRealWidth);
}

function getAbsoluteHeight(oElement)
{
    var nRealHeight;

    nRealHeight = parseInt(getStyleAttribute(oElement, 'height'));
    if (isNaN(nRealHeight)) nRealHeight = 0;
    if (bStandardsCompliantMode)
    {
        nRealHeight += parseInt(getStyleAttribute(oElement, 'border-top-width'));
        nRealHeight += parseInt(getStyleAttribute(oElement, 'border-bottom-width'));
        nRealHeight += parseInt(getStyleAttribute(oElement, 'padding-top'));
        nRealHeight += parseInt(getStyleAttribute(oElement, 'padding-bottom'));
    }
    return(nRealHeight);
}

function determineMode()
{
    var oElem
    var nWidth = 100;
    var nHeight = 100;
    var nNewWidth;
    var nNewHeight;

    if (typeof(bStandardsCompliantMode) == 'undefined')
    {
        oElem = document.createElement('DIV');
        this.setStyleAttribute(oElem, 'position', 'relative');
        this.setStyleAttribute(oElem, 'border', '1px');
        this.setStyleAttribute(oElem, 'padding', '1px');
        this.setStyleAttribute(oElem, 'width', nWidth + 'px');
        this.setStyleAttribute(oElem, 'height', nHeight + 'px');
        this.setStyleAttribute(oElem, 'font-size', '1pt');
        this.setStyleAttribute(oElem, 'visibility', 'hidden');
        oElem = document.body.appendChild(oElem);
        nNewWidth = oElem.offsetWidth;
        nNewHeight = oElem.offsetHeight;
        bStandardsCompliantMode = (nWidth != nNewWidth || nHeight != nNewHeight);
        document.body.removeChild(oElem);
    }
}

function isStandardsCompliant()
{
    determineMode();
    return(bStandardsCompliantMode);
}
