/********************************************************************************************
    Dynamic List Menu Functions
*********************************************************************************************/


/********************************************************************************************
    ToolTips Functions
*********************************************************************************************/


var tt_offsetxpoint=-60; //Customize x offset of tooltip
var tt_offsetypoint=20; //Customize y offset of tooltip
var tt_ie=document.all;
var tt_ns6=document.getElementById && !document.all;
var tt_enabletip=false;
if (tt_ie||tt_ns6)
    var tt_tipobj=document.all? document.all["TOOLTIPS"] : document.getElementById? document.getElementById("TOOLTIPS") : "";

function tt_ietruebody(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function tt_positiontip(e){
    if (tt_enabletip){
        var tt_curX=(tt_ns6)?e.pageX : event.x+tt_ietruebody().scrollLeft;
        var tt_curY=(tt_ns6)?e.pageY : event.y+tt_ietruebody().scrollTop;
        //Find out how close the mouse is to the corner of the window
        var tt_rightedge=tt_ie&&!window.opera? tt_ietruebody().clientWidth-event.clientX-tt_offsetxpoint : window.innerWidth-e.clientX-tt_offsetxpoint-20
        var tt_bottomedge=tt_ie&&!window.opera? tt_ietruebody().clientHeight-event.clientY-tt_offsetypoint : window.innerHeight-e.clientY-tt_offsetypoint-20

        var tt_leftedge=(tt_offsetxpoint<0)? tt_offsetxpoint*(-1) : -1000

        //if the horizontal distance isn't enough to accomodate the width of the context menu
        if (tt_rightedge<tt_tipobj.offsetWidth)
            //move the horizontal position of the menu to the left by it's width
            tt_tipobj.style.left=tt_ie? tt_ietruebody().scrollLeft+event.clientX-tt_tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tt_tipobj.offsetWidth+"px"
        else if (tt_curX<tt_leftedge)
            tt_tipobj.style.left="5px"
        else
            //position the horizontal position of the menu where the mouse is positioned
            tt_tipobj.style.left=tt_curX+tt_offsetxpoint+"px"

        //same concept with the vertical position
        if (tt_bottomedge<tt_tipobj.offsetHeight)
            tt_tipobj.style.top=tt_ie? tt_ietruebody().scrollTop+event.clientY-tt_tipobj.offsetHeight-tt_offsetypoint+"px" : window.pageYOffset+e.clientY-tt_tipobj.offsetHeight-tt_offsetypoint+"px"
        else
            tt_tipobj.style.top=tt_curY+tt_offsetypoint+"px"
            tt_tipobj.style.visibility="visible"
    }
}

function showToolTip(thetext, thecolor, thewidth){
    if (tt_ns6||tt_ie){
        tt_tipobj.innerHTML=thetext;
        tt_enabletip=true;
        return false;
    }
}

function hideToolTip(){
    if (tt_ns6||tt_ie){
        tt_enabletip=false;
        tt_tipobj.style.visibility="hidden";
        tt_tipobj.style.left="-1000px";
        tt_tipobj.style.backgroundColor='';
        tt_tipobj.style.width='';
    }
}

document.onmousemove = tt_positiontip;
