﻿function ShowHelp(divId, divWidth, e) {
    if (!e) {
        e = window.event;
    }

    showHideHelpDiv(divId, divWidth, true, e);
}

function showHideHelpDiv(divId, divWidth, visible, e) {
    var d = document.getElementById(divId);

    if (d == null) {
        return;
    }

    if (visible) {
        if (divWidth && divWidth > 0) {
            d.style.width = divWidth + "px";
        }
        else {
            // Set the default width (this is the current div width defined in the css).
            divWidth = 300;
        }

        if (e) {
            // We suppose that the help is on the main div, should cee how to make it work for all divs...
            var mainDiv = document.getElementById("mainDiv");

            var left = GetLeftLocationForDiv(e.clientX + 15, divWidth, mainDiv);

            if (left > -1) {
                // Set the DIV to be at the mouse position
                d.style.left = left + "px";
            }

            var top = e.clientY;
            if (mainDiv != null)
                top = top - mainDiv.offsetTop;

            d.style.top = top + "px";
        }

        d.style.display = "block";
    }
    else {
        d.style.display = "none";
    }
}