// requires a <div id="popupbox"></div> somewhere in the document
// <style type="text/css">
// #popupbox{position: absolute;width: 150px;border: 2px solid black;padding: 2px;background-color: #CCFFFF;visibility: hidden;z-index: 99;filter: progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135);}
// </style>
// example use:
// <div onMouseover="showpopup('Test','beige',240)"; onMouseout="hidepopup()">Tregalis Software</div>

var popupXoffset=-62;
var popupYoffset=21;
var documentall=document.all;
var mongo=document.getElementById && !document.all;
var isvisible=false;
var popupobj;

function documentbody()
{
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function showpopup(message, backgroundcolor, width)
{
    if(!popupobj)
        popupobj = document.getElementById("popupbox");
    
    if (mongo||documentall)
    {
        if (typeof width!="undefined")
            popupobj.style.width=width+"px";

        if (typeof backgroundcolor!="undefined" && backgroundcolor!="")
            popupobj.style.backgroundColor=backgroundcolor;

        popupobj.innerHTML=message;
        isvisible=true;
        return false;
    }

}

function popupMouseMove(e)
{
    if (isvisible)
    {
        var sixteenth3=(mongo)?e.pageX : event.x+documentbody().scrollLeft;
        var seventeenth3=(mongo)?e.pageY : event.y+documentbody().scrollTop;
        var eighteenth3=documentall&&!window.opera? documentbody().clientWidth-event.clientX-popupXoffset : window.innerWidth-e.clientX-popupXoffset-20;
        var nineteenth3=documentall&&!window.opera? documentbody().clientHeight-event.clientY-popupYoffset : window.innerHeight-e.clientY-popupYoffset-20;
        var twentieth3=(popupXoffset<0)? popupXoffset*(-1) : -960;

        if (eighteenth3<popupobj.offsetWidth)
            popupobj.style.left=documentall? documentbody().scrollLeft+event.clientX-popupobj.offsetWidth+"px" : window.pageXOffset+e.clientX-popupobj.offsetWidth+"px";
        else if (sixteenth3<twentieth3)
            popupobj.style.left="5px";
        else
            popupobj.style.left=sixteenth3+popupXoffset+"px";

        if (nineteenth3<popupobj.offsetHeight)
            popupobj.style.top=documentall? documentbody().scrollTop+event.clientY-popupobj.offsetHeight-popupYoffset+"px" : window.pageYOffset+e.clientY-popupobj.offsetHeight-popupYoffset+"px";
        else
            popupobj.style.top=seventeenth3+popupYoffset+"px";
        popupobj.style.visibility="visible";
    }
}

function hidepopup()
{
    if (mongo||documentall)
    {
        isvisible=false;
        popupobj.style.visibility="hidden";
        popupobj.style.left="-1000px";
        popupobj.style.backgroundColor='';
        popupobj.style.width='';
    }
}

document.onmousemove=popupMouseMove;
