var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
var ns4=document.layers

var posx;
var posy;

if (ns4 || ns6)
{
    window.captureEvents(Event.MOUSEMOVE);
    window.onmousemove = coordonnee;
}

function coordonnee(e)
{
    posx = e.pageX;
    posy = e.pageY;
}

function drc(titre,contenu)
{
    if (!document.all&&!document.getElementById&&!document.layers) return

    menuobj=ie4? document.all.popmenu : ns6? document.getElementById("popmenu") : ns4? document.popmenu : ""
    menuobj.thestyle=(ie4||ns6)? menuobj.style : menuobj

    var contenuHTML = '<table border="0" cellspacing="1" cellpadding="0" width="200" bgcolor="#FFFFFF">'
                        + '<tr color="#FFFFFF" bgcolor="#000000"><td width="198">' + titre + '</td></tr>'
                        + '<tr color="#000000" bgcolor="#FFFFFF"><td width="198">' +  contenu + '</td></tr>'
                        + '</table>';

    if (ie4||ns6)
        menuobj.innerHTML=contenuHTML
    else
    {
        menuobj.document.write('<div name="popmenu" width="200p">'+contenuHTML+'</div>')
        menuobj.document.close()
    }

    menuobj.contentwidth=(ie4||ns6)? menuobj.offsetWidth : menuobj.document.popmenu.document.width
    menuobj.contentheight=(ie4||ns6)? menuobj.offsetHeight : menuobj.document.popmenu.document.height
    eventX= ( ie4? event.clientX : (ns6||ns4) ? posx : 0 ) + 10
    eventY= ( ie4? event.clientY : (ns6||ns4) ? posy : 0 ) + 10

    //Find out how close the mouse is to the corner of the window
    var rightedge=ie4? document.body.clientWidth-eventX : window.innerWidth-eventX
    var bottomedge=ie4? document.body.clientHeight-eventY : ns6 ? document.body.clientHeight+window.pageYOffset-eventY : window.innerHeight-eventY

    //if the horizontal distance isn't enough to accomodate the width of the context menu
    //move the horizontal position of the menu to the left by it's width
    if (rightedge<menuobj.contentwidth)
    {
        eventX -= 20;

        menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX-menuobj.contentwidth : ns6? window.pageXOffset+eventX-menuobj.contentwidth : eventX-menuobj.contentwidth;
        menuobj.innerHTML += ""
    }
    else
    {
        menuobj.thestyle.left=ie4? document.body.scrollLeft+eventX : ns6? window.pageXOffset+eventX : eventX;
        menuobj.innerHTML += ""
    }

    //same concept with the vertical position
    if (bottomedge<menuobj.contentheight)
    {
        eventY -= 20;

        menuobj.thestyle.top=ie4? document.body.scrollTop+eventY-menuobj.contentheight : ns6? eventY-menuobj.contentheight : eventY-menuobj.contentheight;
        menuobj.innerHTML += ""
    }
    else
    {
        menuobj.thestyle.top=ie4? document.body.scrollTop+eventY : ns6? eventY : eventY
        menuobj.innerHTML += ""
    }

    menuobj.thestyle.visibility="visible"
    return false
}
function nd()
{
    if ( window.menuobj && (ie4||ns6||ns4) )
        menuobj.thestyle.visibility=(ie4||ns6)? "hidden" : "hide"
}

if (ie4||ns6) document.onclick=nd


