// Extended Tooltip Javascript by Stephen Chapman, Felgall Pty Ltd

var DH = 0;
var an = 0;
var al = 0;
var ai = 0;

if (document.getElementById) {
    ai = 1;
    DH = 1;
} else {
    if (document.all) {
        al = 1;
        DH = 1;
    } else {
        browserVersion = parseInt(navigator.appVersion);
        if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
            an = 1;
            DH = 1;
        }
    }
}
function fd(Id, wS) {
    if (ai) return wS ? document.getElementById(Id).style : document.getElementById(Id);
    if (al) return wS ? document.all[Id].style : document.all[Id];
    if (an) return document.layers[Id];
}
function GetParentWidth() {
    return window.innerWidth != null ? window.innerWidth : document.body.clientWidth != null ? document.body.clientWidth : null;
}
function GetMouseX(Ev) {
    if (Ev.pageX)
        return Ev.pageX;
    else if (Ev.clientX)
        return Ev.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    else return
        null;
}
function GetMouseY(Ev) {
    if (Ev.pageY)
        return Ev.pageY;
    else if (Ev.clientY)
        return Ev.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    else
        return null;
}
function ShowTip(Ev, Id) {
    if (DH) {
        var wp = GetParentWidth();
        ds = fd(Id,1);
        dm = fd(Id,0);
        st = ds.visibility;
        if (dm.offsetWidth)
            ew = dm.offsetWidth;
        else if (dm.clip.width)
            ew = dm.clip.width;
        if (st == "visible" || st == "show") {
            ds.visibility = "hidden";
        } else {
            tv = GetMouseY(Ev) + 20;
            lv = GetMouseX(Ev) - (ew/4);
            if (lv < 2)
                lv = 2;
            else if (lv + ew > wp)
                lv -= ew/2;
            if (!an) {
                lv += 'px';
                tv += 'px';
            }
            ds.left = lv;
            ds.top = tv;
            ds.visibility = "visible";
        }
    }
}