﻿
    function findPos(obj) {

        //Find the coordinants of the help icon and include the screen width.

        // Abbreviations:
        // cL = the top left position of the obj.
        // cT = the top position of the obj.
        // sW = the total screen width.
        // obj = the object sent to this script.

        var cL = cT = sW = 0;

        if (obj.offsetParent) {
 
            do {
                cL += obj.offsetLeft;
                cT += obj.offsetTop;
                sW = obj.clientWidth;
                obj = obj.offsetParent;
                
            } while (obj != null && obj.nodeName != 'HTML');
            if (obj != null) {
                cL += obj.offsetLeft;
                cT += obj.offsetTop;
                sW = obj.clientWidth;
            }

        }
        return [cL, cT, sW];
    }

    function hH() { 
    
        // Hide the help panel.

        // Abbreviations:
        // hPU = The help panel.

        var hPU = gHPU();
        hPU.style.visibility = "hidden";
        hPU.style.display = "none";
    }

    function sHlp(hiaID, tHB) {

        // Show the help panel.

        // Abbreviations:
        // tHB & tHBx = the help button.
        // a = an array of coordinants from findPos().
        // cL = the top left position of the obj.
        // cT = the top position of the obj.
        // sW = the total screen width.
        // rS = the area (in pixels) of the screen to the right of cL.
        // hPU = the help panel.
        // sLeft = the top left position to set the help panel to.
        // sTop = the top position to set the help panel to.
        // hiaID = the help item ID.

        var tHBx = tHB;
        var a = findPos(tHBx);
        var cL = a[0];
        var cT = a[1];
        var sW = a[2];

        var rS = (sW - cL);

        gIB().innerHTML = "<img src='../../../Systems/Graphics/clockLoader.gif' border='0'>";

        var hPU = gHPU();

        if (cL < rS) {
        
                // show it on the right of the help icon.

            var sLeft = (cL + 25) + "px";
            hPU.style.width = Math.floor(rS * .50);

        } else {

            // show it on the left of the help icon.

            var sLeft = (cL - (Math.floor(cL * .50) + 15)) + "px";
            hPU.style.width = Math.floor(cL * .50);
            
        }

        cB1.PerformCallback(hiaID);    // This is the callback.

        var sTop = (cT + 10) + "px";

        hPU.style.visibility = "visible";
        hPU.style.display = "block";
        hPU.style.position = "absolute";
        hPU.style.top = sTop;
        hPU.style.left = sLeft;
        
    }

    function gIB() {
        // Get the div that will hold the results. (<span id="iB" ></span> below)
        return document.getElementById("iB");
    }

    function gHPU() {
        // Get the help panel itself. (<div id="hPU" ... below)
        return document.getElementById("hPU");
    }
