// stuff for managing the popups used on various pages (eg, smsa/cmx2)

var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

var mx, my, hover;

function getMouseXY(e) {
    if (IE) {
        mx = event.clientX + document.body.scrollLeft;
        my = event.clientY + document.body.scrollTop;
    }
    else {  // grab the x-y pos.s if browser is NS
        mx = e.pageX;
        my = e.pageY;
    }
    if (mx < 0) mx = 0;
    if (my < 0) my = 0;

    if (hover && hover.style.visibility == "visible") reposHover();

    return true;
}

function setHover(state, div) {
    if (div) hover = document.getElementById(div + "hover");
    if (state) reposHover();
    hover.style.visibility = state ? "visible" : "hidden";
}

function reposHover() {
    var width = IE ? document.body.clientWidth : window.innerWidth;
    
    if (mx + 250 + (15 * 2) + (IE ? 0 : 20) > width ) {
        hover.style.left = width - 250 - 15 - (IE ? 0 : 20);
    }
    else {
        hover.style.left = mx + 15;
    }
    hover.style.top = my + 15;
}


