var IE = document.all ? true : false;
var x, y, max_x;

if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = setMouseCoords;

function setMouseCoords(e) {
    if (IE)
    {
        x = event.clientX + document.body.scrollLeft;
        y = event.clientY + document.body.scrollTop;
    }
    else
    {
        x = e.pageX;
        y = e.pageY;
    }
    max_x = getPageWidth() - 440;
    if (x > max_x) { x = max_x; }
    if (x < 0) { x = 0; }
    if (y < 0) { y = 0; }
}

function showInfo(text) {
    if (typeof(text) != "undefined")
    {
        if (window.opera) height = getPageHeight();
        else if (IE) height = getWindowHeight() + getPageScrollY();
        else height = getWindowHeight();

        document.getElementById("info").style.top = "auto";
        document.getElementById("info").style.bottom = "auto";

        document.getElementById("info").innerHTML = text;
        document.getElementById("info").style.display = "block";
        if (y - getPageScrollY() < getWindowHeight() * 0.6) {
            document.getElementById("info").style.top = (y + 20) + "px";
        } else {
            document.getElementById("info").style.bottom = (height - y + 20) + "px";
        }
        document.getElementById("info").style.left = x + "px";
    }
}

function hideInfo() {
    document.getElementById("info").style.display = "none";
}

function getWindowWidth() {
    if (IE) return document.body.clientWidth;
    return window.innerWidth;
}
function getWindowHeight() {
    if (IE) return document.body.clientHeight;
    return window.innerHeight;
}
function getPageWidth() {
    if (IE) return document.body.scrollWidth;
    return document.width;
}
function getPageHeight() {
    if (IE) return document.body.scrollHeight;
    return document.height;
}
function getPageScrollX() {
    if (IE) return document.body.scrollLeft;
    return window.pageXOffset;
}
function getPageScrollY() {
    if (IE) return document.body.scrollTop;
    return window.pageYOffset;
}
