
/*depedencies
<dependencies>
    <item note = "this script utilizes the function GetMouseCoordinates in shared.js" domain = "sabreindustriesinc.com" name = "Shared.js">2</item>
</dependencies>
dependencies*/


/*
EXAMPLE IMPLEMENTATION
<ElementThatNeedsToolTip onmousemove = \"ToolTip.Move(event, 'id of tool tip. SEE NOTES');\" onmouseover = \"ToolTip.Show(event, 'id of tool tip', 'tool tip text', 'class name for the tool tip container element');\" onmouseout = \"ToolTip.Hide('id of tool tip');\" />
*/


// ID IS NOT REQUIRED IF ALL TOOLTIPS WILL USE THE SAME CONTAINER ELEMENT
function ToolTip() { }
ToolTip.DefaultID = "divToolTip";

ToolTip.Move = function(evt, ID) {

    //var div = this.GetDiv(ID, null);
    var div = document.getElementById(ID == null ? this.DefaultID : ID);
    if (div == null) { return; }
    var coords = Shared.GetMouseCoordinates(evt);
    div.style.left = (coords.x).toString() + "px";
    div.style.top = (coords.y + 10).toString() + "px";
}

ToolTip.Show = function(evt, ID, Content, ClassName) {

    if (ID == null) { ID = this.DefaultID; }

    var div = document.getElementById(ID);
    if (div == null) {

        div = document.createElement("DIV");
        div.id = ID;
        if (ClassName != null) { div.className = ClassName; }
        document.body.appendChild(div);

    }
    
    if (Content != null) { div.innerHTML = Content; }
    this.Move(evt, ID);
    div.style.visibility = "visible";

}

ToolTip.Hide = function(ID) {

    var div = document.getElementById(ID == null ? this.DefaultID : ID);
    if (div == null) { return; }
    div.style.visibility = "hidden";

}