﻿// JScript File

function getElementHeight(element) {
  return(element.clientHeight);
}

function getElementWidth(element) {
  return(element.clientWidth);
}

function DL_GetElementLeft(eElement)
{
    if (!eElement && this)                    // if argument is invalid
    {                                         // (not specified, is null or is 0)
        eElement = this;                       // and function is a method
    }                                         // identify the element as the method owner

    var DL_bIE = document.all ? true : false; // initialize var to identify IE

    var nLeftPos = eElement.offsetLeft;       // initialize var to store calculations
    var eParElement = eElement.offsetParent;  // identify first offset parent element

    while (eParElement != null)
    {                                         // move up through element hierarchy
        if(DL_bIE)
        {
            if(eParElement.tagName == "TD")     // if parent a table cell, then...
            {
                nLeftPos += eParElement.clientLeft; // append cell border width to calcs
            }
        }

        nLeftPos += eParElement.offsetLeft;    // append left offset of parent
        eParElement = eParElement.offsetParent; // and move up the element hierarchy
    }                                         // until no more offset parents exist
    return nLeftPos;                          // return the number calculated
}

function DL_GetElementTop(eElement)
{
    if (!eElement && this)                    // if argument is invalid
    {                                         // (not specified, is null or is 0)
        eElement = this;                       // and function is a method
    }                                         // identify the element as the method owner

    var DL_bIE = document.all ? true : false; // initialize var to identify IE

    var nTopPos = eElement.offsetTop;       // initialize var to store calculations
    var eParElement = eElement.offsetParent;  // identify first offset parent element

    while (eParElement != null)
    {                                         // move up through element hierarchy
        if(DL_bIE)
        {
            if(eParElement.tagName == "TD")     // if parent a table cell, then...
            {
                nTopPos += eParElement.clientTop; // append cell border width to calcs
            }
        }

        nTopPos += eParElement.offsetTop;    // append top offset of parent
        eParElement = eParElement.offsetParent; // and move up the element hierarchy
    }                                         // until no more offset parents exist
    return nTopPos;                          // return the number calculated
}

function OpenToolTip(tipId, controlId, orientation)
{
    var tip = document.getElementById(tipId);
    var control = document.getElementById(controlId);
    
    if (!tip || !control)
        return;
        
    tip.style.top = (DL_GetElementTop(control) - 18) + 'px';
    
    tip.style.display = 'block';

    var left = ((orientation == 'dx') ? DL_GetElementLeft(control) + getElementWidth(control) + 10 : DL_GetElementLeft(control) - getElementWidth(tip) - 10);
    tip.style.left = left + 'px';

    DivSetVisible(true, tipId, orientation);
}

function CloseToolTip(tipId)
{
    var tip = document.getElementById(tipId);

    if (!tip)
        return;
        
    DivSetVisible(false, tipId);
    tip.style.display = 'none';
}

function DivSetVisible(state, popupId, orientation)
  {
   var DivRef = document.getElementById(popupId);
   var IfrRef = document.getElementById('DivShim');
   if(state)
   {
    IfrRef.style.width = DivRef.offsetWidth -9;
    IfrRef.style.height = DivRef.offsetHeight;
    IfrRef.style.top = DivRef.style.top;
    var left;
    if (orientation == 'dx')
    {
        var tmp = DivRef.style.left.replace('px', '');
        left = parseInt(tmp) + 9;
        left = left + 'px';
    }
    else
    {
        left = DivRef.style.left;
    }
    IfrRef.style.left = left;
    IfrRef.style.zIndex = DivRef.style.zIndex - 1;
    IfrRef.style.display = "block";
   }
   else
   {
    DivRef.style.display = "none";
    IfrRef.style.display = "none";
   }
  }
