
function getViewableHeight()
{
    if( typeof( window.innerWidth ) == 'number' ) 
    {
        //Non-IE
        return window.innerHeight;
    } 
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
    {
        //IE 6+ in standards compliant mode
        return document.documentElement.clientHeight;
    } 
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
    {
        //IE 4 compatible
        return document.body.clientHeight;
    }
    return 0;
}

function centerObjInWindow(obj)
{
    obj.style.top = ((getViewableHeight()/2) - (obj.offsetHeight/2) + getScrollOffsetY()) + 'px';
    obj.style.left = ((getViewableWidth()/2) - (obj.offsetWidth/2) + getScrollOffsetX()) + 'px';    
}

function getViewableWidth()
{
    if( typeof( window.innerWidth ) == 'number' ) 
    {
        //Non-IE
        return window.innerWidth;
    } 
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
    {
        //IE 6+ in standards compliant mode
        return document.documentElement.clientWidth;
    } 
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
    {
        //IE 4 compatible
        return document.body.clientWidth;
    } 
    return 0;   
}


function getScrollOffsetX() 
{
    if( typeof( window.pageYOffset ) == 'number' ) 
    {
        //Netscape compliant
        return window.pageXOffset;
    } 
    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
    {
        //DOM compliant
        return document.body.scrollLeft;
    } 
    else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
    {
        //IE6 standards compliant mode
        return document.documentElement.scrollLeft;
    }
    return 0;
}

function getScrollOffsetY() 
{
    if( typeof( window.pageYOffset ) == 'number' ) 
    {
        //Netscape compliant
        return window.pageYOffset;
    } 
    else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
    {
        //DOM compliant
        return document.body.scrollTop;
    } 
    else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
    {
        //IE6 standards compliant mode
        return document.documentElement.scrollTop;
    }
    return 0;
}

function getMaxZIndex(o)
{
    var maxZIndex = 100;
    if(o.style && o.style.zIndex && o.style.zIndex > maxZIndex)
    {
        maxZIndex = o.style.zIndex;
    }    
    for(var i = 0; i < o.childNodes.length; i++)
    {
        var child = o.childNodes[i];
        var childZIndex = getMaxZIndex(child);
        if(childZIndex>maxZIndex)
        {
            maxZIndex = childZIndex;
        }
    }
    return maxZIndex;
}

