function GetOffset()
{
    if (document.SavedOffset)
        return document.SavedOffset;
    return 0;
}
function GetTopOffset()
{
    if (document.SavedTopOffset)
        return document.SavedTopOffset;
    return 20;
}
function SetTopOffset(n)
{
    document.SavedTopOffset = n;
}
function GetTooltip()
{
    if (! document.SavedTooltip)
        document.SavedTooltip = document.getElementById("tooltip");
    return document.SavedTooltip;
}
function SetParent(el)
{
    document.SavedParent = el;
}
function GetParent()
{
    return document.SavedParent;
}
function SetMessage(msg)
{
    document.SavedMessage = msg;
}
function GetMessage()
{
    return document.SavedMessage;
}
function Show(child, message, offset)
{
	//alert('Show Method');	
	
    SetParent(child.parentNode);
    SetMessage(message);
    if (offset) document.SavedOffset = offset;
    if (document.HideTimeout) clearTimeout(document.HideTimeout);
    document.ShowTimeout = setTimeout("ShowTooltip()", 300); 
}
function Hide()
{
    if (document.ShowTimeout) clearTimeout(document.ShowTimeout);
    document.HideTimeout = setTimeout("HideTooltip()", 100); 
}
function ShowTooltip()
{
    var tooltip = GetTooltip();
    var parent = GetParent();
    var message = GetMessage();
    if (tooltip && tooltip.firstChild && parent && message) 
    {
        tooltip.firstChild.innerHTML=message;
        tooltip.style.display="block"; 
        tooltip.style.left = findPosX(parent) + GetOffset() + "px";
        tooltip.style.top = findPosY(parent) - GetTopOffset() + "px";
    }
}
function HideTooltip()
{
    var tooltip = GetTooltip();
    if (tooltip && tooltip.firstChild) 
    {
        tooltip.firstChild.innerHTML="";
        tooltip.style.display="none"; 
    }
}

function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}
