var myMode, H, G;
var chipOBJ = "",
    txp, typ, txs, tys, chipXpos, chipYpos, offX, offY, tcount;
var ie9 = (document.documentMode == 9);
var ie8 = (document.documentMode == 8);
var op = window.opera;
var ns4 = (document.layers && !ie8 && !ie9 && !op);
var ie4 = (document.all && !document.getElementById && !ie8 && !ie9 && !op);
var ie5 = (document.all && document.getElementById && !ie8 && !ie9 && !op);
var ns6 = (!document.all && document.getElementById && !ie8 && !ie9 && !op);

txp = typ = offX = offY = 0;

if (document.compatMode == 'CSS1Compat') {
    myMode = "H";
} else {
    myMode = "G";
}

window.onerror = eno;
document.onmousemove = m_pos;

function eno() {
    return true;
}

function m_pos(e) {
    if (ie4 || ie5 || ie8) {
        txp = event.x;
        typ = event.y;
    }
    if (ns4 || ns6 || op || ie9) {
        txp = e.pageX;
        typ = e.pageY;
    }
    if (txp < 0) {
        txp = 0;
    }
    if (typ < 0) {
        typ = 0;
    }
    return true;
}

function poscheck() {
    if (txs < chipXpos + 400) {
        chipXpos = txs - 410;
    }
    if (chipXpos < 0) {
        chipXpos = 0;
    }

    if (tys < chipYpos - offY + 220) {
        chipYpos = chipYpos - 280;
    } else {
        chipYpos = chipYpos + 10;
    }
    if (chipYpos < 0) {
        chipYpos = 0;
    }
    return;
}

function showChipHelp(cName) {
    if (ie4 || ie5) {
        chipOBJ = document.all[cName].style;
    } else if (ns4) {
        chipOBJ = document.layers[cName];
    } else if (ns6 || ie8 || ie9 || op) {
        chipOBJ = document.getElementById(cName).style;
    }

    if (chipOBJ.visibility == "visible" || chipOBJ.visibility == "show") {
        chipXpos = 0;txs = 0;offX = 0;
        chipYpos = 0;tys = 0;offY = 0;
        return;
    }


    if (ie8 || ie9 && myMode == "H") {
        offX = document.documentElement.scrollLeft;
        offY = document.documentElement.scrollTop;
        txs = document.documentElement.clientWidth;
        tys = document.documentElement.clientHeight;
        chipXpos = txp - 200;
        chipYpos = typ + 30;
        poscheck();
        chipOBJ.left = chipXpos + 'px';
        chipOBJ.top = chipYpos + 'px';
        chipOBJ.visibility = "visible";
        tcount = setTimeout("hideChipHelp('" + cName + "')", 15000);
    } else if (ie8 || ie9 && myMode == "G") {
        offX = document.documentElement.scrollLeft;
        offY = document.documentElement.scrollTop;
        txs = document.documentElement.clientWidth;
        tys = document.documentElement.clientHeight;
        chipXpos = txp - 200;
        chipYpos = typ + 30;
        poscheck();
        chipOBJ.left = chipXpos + 'px';
        chipOBJ.top = chipYpos + 'px';
        chipOBJ.visibility = "visible";
        tcount = setTimeout("hideChipHelp('" + cName + "')", 15000);
    } else if (window.innerHeight && ie5) {
        offX = document.documentElement.scrollLeft;
        offY = document.documentElement.scrollTop;
        txs = window.innerWidtht;
        tys = window.innerHeight;
        chipXpos = txp - 200 + offX;
        chipYpos = typ + offY;
        poscheck();
        chipOBJ.left = chipXpos;
        chipOBJ.top = chipYpos;
        chipOBJ.visibility = "visible";
        tcount = setTimeout("hideChipHelp('" + cName + "')", 15000);
    } else if (op) {
        offX = document.documentElement.scrollLeft;
        offY = document.documentElement.scrollTop;
        txs = document.documentElement.clientWidth;
        tys = document.documentElement.clientHeight;
        chipXpos = txp - 200 + offX;
        chipYpos = typ + 30;
        poscheck();
        chipOBJ.left = chipXpos + 'px';
        chipOBJ.top = chipYpos + 'px';
        chipOBJ.visibility = "visible";
        tcount = setTimeout("hideChipHelp('" + cName + "')", 15000);
    } else if (!window.innerHeight && (ie4 || ie5) && myMode == "H") {
        offX = document.documentElement.scrollLeft;
        offY = document.documentElement.scrollTop;
        txs = document.documentElement.clientWidth;
        tys = document.documentElement.clientHeight;
        chipXpos = txp - 200 + offX;
        chipYpos = typ + offY;
        poscheck();
        chipOBJ.left = chipXpos;
        chipOBJ.top = chipYpos;
        chipOBJ.visibility = "visible";
        tcount = setTimeout("hideChipHelp('" + cName + "')", 15000);
    } else if (!window.innerHeight && (ie4 || ie5) && myMode == "G") {
        offX = document.body.scrollLeft;
        offY = document.body.scrollTop;
        txs = document.body.clientWidth;
        tys = document.body.clientHeight;
        chipXpos = txp - 200 + offX;
        chipYpos = typ + offY;
        poscheck();
        chipOBJ.left = chipXpos;
        chipOBJ.top = chipYpos;
        chipOBJ.visibility = "visible";
        tcount = setTimeout("hideChipHelp('" + cName + "')", 15000);
    } else if (ns6 && myMode == "H") {
        offX = window.scrollX;
        offY = window.scrollY;
        txs = window.innerWidtht;
        tys = window.innerHeight;
        chipXpos = txp - 200;
        chipYpos = typ + 30;
        poscheck();
        chipOBJ.left = chipXpos + 'px';
        chipOBJ.top = chipYpos + 'px';
        chipOBJ.visibility = "visible";
        tcount = setTimeout("hideChipHelp('" + cName + "')", 15000);
    } else if (ns6 && myMode == "G") {
        offX = window.scrollX;
        offY = window.scrollY;
        txs = window.innerWidtht;
        tys = window.innerHeight;
        chipXpos = txp - 200;
        chipYpos = typ + 30;
        poscheck();
        chipOBJ.left = chipXpos + 'px';
        chipOBJ.top = chipYpos + 'px';
        chipOBJ.visibility = "visible";
        tcount = setTimeout("hideChipHelp('" + cName + "')", 15000);
    } else {
        offX = document.documentElement.scrollLeft;
        offY = document.documentElement.scrollTop;
        txs = document.documentElement.clientWidth;
        tys = document.documentElement.clientHeight;
        chipXpos = txp - 200;
        chipYpos = typ + 30;
        poscheck();
        chipOBJ.left = chipXpos + 'px';
        chipOBJ.top = chipYpos + 'px';
        chipOBJ.visibility = "visible";
        tcount = setTimeout("hideChipHelp('" + cName + "')", 15000);
    }
    chipXpos = 0;txs = 0;offX = 0;
    chipYpos = 0;tys = 0;offY = 0;
}

function hideChipHelp(cName) {
    if (ie4 || ie5 || ie8 || ie9 || ns6 || op) {
        chipOBJ.visibility = "hidden";
    } else if (ns4) {
        chipOBJ.visibility = "hide";
    }
    chipXpos = 0;txs = 0;offX = 0;
    chipYpos = 0;tys = 0;offY = 0;
    clearTimeout(tcount);
}

