﻿// Get header height.
function GetElementValue(name, type)
{
    var obj = document.getElementById(name);
    switch(type)
    {
        case "height":
            return GetElementHeight(obj);
        case "width":
            return GetElementWidth(obj);
        case "top":
            return GetElementTop(obj);
        case "bottom":
            return GetElementBottom(obj);
        case "right":
            return GetElementRight(obj);
        case "left":
            return GetElementLeft(obj);

    }
    return 0;
}

function GetElementHeight(obj)
{
    if(obj != null)
    {
        if(obj.style.height != null && obj.style.height != "")
        {
            return obj.style.height;        
        }
        if(obj.offsetHeight != null && obj.offsetHeight != "")
        {
            return obj.offsetHeight;
        }
        if(obj.clientHeight != null && obj.clientHeight != "")
        {
            return obj.clientHeight;
        }

        return 0;
    }
}

function GetElementWidth(obj)
{
    if(obj != null)
    {
        if(obj.style.width != null && obj.style.width != "")
        {
            return obj.style.width;        
        }
        if(obj.offsetWidth != null && obj.offsetWidth != "")
        {
            return obj.offsetWidth;
        }
        if(obj.clientWidth != null && obj.clientWidth != "")
        {
            return obj.clientWidth;
        }
        if(obj.scrollWidth != null && obj.scrollWidth != "")
        {
            return obj.scrollWidth;
        }
        return 0;
    }
}

function GetElementLeft(obj)
{
    if(obj != null)
    {
        if(obj.offsetLeft != null && obj.offsetLeft != "")
        {
            return obj.offsetLeft;
        }
        if(obj.style.left != null && obj.style.left != "")
        {
            return obj.style.left;
        }
        if(obj.clientLeft != null && obj.clientLeft != "")
        {
        
            alert(obj.clientLeft);
            return obj.clientLeft;
        }
        if(obj.scrollLeft != null && obj.scrollLeft != "")
        {
            return obj.scrollLeft;
        }
        return 0;
    }
}

function GetElementRight(obj)
{
    if(obj != null)
    {
        var left = GetElementLeft(obj);
        var width = GetElementWidth(obj);
        return left + width;
    }
    return 0;
}

function GetElementTop(obj)
{
    if(obj != null)
    {
        if(obj.offsetTop != null && obj.offsetTop != "")
        {
            return obj.offsetTop;
        }
        if(obj.style.top != null && obj.style.top != "")
        {
            return obj.style.top;
        }
        if(obj.clientTop != null && obj.clientTop != "")
        {
            return obj.clientTop;
        }
        if(obj.scrollTop != null && obj.scrollTop != "")
        {
            return obj.scrollTop;
        }
        return 0;
    }
}

function GetElementBottom(obj)
{
    if(obj != null)
    {
        var top = GetElementTop(obj);
        var height = GetElementHeight(obj);
        return top + height;
    }
    return 0;
}

