var atipobj="";
var attip_OfsX=20; //Customize x offset of tooltip
var attip_OfsY=20; //Customize y offset of tooltip
var attip_w=250;
var attip_h=350;
var attip_ie=document.all;
var attip_ns6=document.getElementById && !document.all;
var attip_ena=false;
var l=0;
var t=0;

if (attip_ie||attip_ns6)
{
    var atipobj=document.all? document.all["apttip"] : document.getElementById? document.getElementById("apttip") : "";
}
function attip_ietruebody()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function attip_shw(num,lan,w,h)
{
    if (attip_ns6||attip_ie)
    {
        attip_Fill(num,lan,w,h);
        attip_ena=true;
        return false;
    }
}
function attip_Fill(num,lan,w,h)
{
    if (attip_ns6||attip_ie)
    {
        if (typeof wid!="undefined") atipobj.style.width=wid+"px";
//        if (typeof col!="undefined" && col!="") atipobj.style.backgroundColor=col;

        attip_w=w;
        attip_h=h;
        
        Apt_Shw(num,lan);
        
        attip_ena=true;
        return false;
    }
}

function attip_pos(e)
{
    if (attip_ena)
    {
        
        var curX=(attip_ns6)?e.pageX : event.x+attip_ietruebody().scrollLeft;
        var curY=(attip_ns6)?e.pageY : event.y+attip_ietruebody().scrollTop;

        //Find out how close the mouse is to the corner of the window
        var rightedge=attip_ie&&!window.opera? attip_ietruebody().clientWidth-event.clientX-attip_OfsX : window.innerWidth-e.clientX-attip_OfsX;
        var bottomedge=attip_ie&&!window.opera? attip_ietruebody().cltHeight-event.clientY-attip_OfsY : window.innerHeight-e.clientY-attip_OfsY;
        
        var leftedge=(attip_OfsX<0)? attip_OfsX*(-1) : -1000;
        
        //if the horizontal distance isn't enough to accomodate the width of the context menu
        if (rightedge<attip_w)
        {
        //move the horizontal position of the menu to the left by it's width
            l=attip_ie? attip_ietruebody().scrollLeft+event.clientX-attip_w+"px" : window.pageXOffset+e.clientX-attip_w+"px";
        }
        else
        {
             if (curX<leftedge)
               l="5px"
            else
               l=curX+attip_OfsX+"px"; //position the horizontal position of the menu where the mouse is positioned
        }
        
        //same concept with the vertical position
        if (bottomedge<attip_h)
            t=attip_ie? attip_ietruebody().scrollTop+event.clientY-attip_h+"px" : window.pageYOffset+e.clientY-attip_h+"px";
        else
        {
             if (curY<0)
               l="5px"
            else
                t=(curY+attip_OfsY)+"px";
        }
//document.getElementById("sta").value="t="+t+"  l="+l;
        atipobj.style.left=l;
        atipobj.style.top=t;
        atipobj.style.visibility="visible";
    }
}

function attip_hid()
{
    if (attip_ns6||attip_ie)
    {
        attip_ena=false;
        atipobj.style.visibility="hidden";
        atipobj.style.left="-1000px";
        atipobj.style.backgroundColor='';
        //atipobj.style.width='';
    }
}

document.onmousemove=attip_pos;

