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

txp = typ = offX = offY = 0;
lighting = 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) {
        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 fadein(cName) {

    if (navigator.appName == "Microsoft Internet Explorer") {
        if (lighting <= 100) {
            document.all[cName].filters['alpha'].opacity = lighting;
            lighting = lighting + 20;
            clearTimeout(lcount);
            lcount = setTimeout("fadein('" + cName + "')", 100);
        } else clearTimeout(lcount);
    } else if ((navigator.appName == "Netscape") && document.getElementById && (navigator.userAgent.indexOf("Safari") < 0)) {
        if (lighting <= 100) {
            document.getElementById(cName).style.MozOpacity = lighting / 100;
            lighting = lighting + 20;
            clearTimeout(lcount);
            lcount = setTimeout("fadein('" + cName + "')", 100);
        } else clearTimeout(lcount);
    } else if ((navigator.appName == "Opera") && document.getElementById || (navigator.userAgent.indexOf("Safari") > 0)) {
        if (lighting <= 100) {
            document.getElementById(cName).style.opacity = lighting / 100;
            lighting = lighting + 20;
            clearTimeout(lcount);
            lcount = setTimeout("fadein('" + cName + "')", 100);
        } else clearTimeout(lcount);
    } else return;
}

function fadeout(cName) {

    if (navigator.appName == "Microsoft Internet Explorer") {
        if (lighting >= 0) {
            document.all[cName].filters['alpha'].opacity = lighting;
            lighting = lighting - 20;
            clearTimeout(lcount);
            lcount = setTimeout("fadeout('" + cName + "')", 100);
        } else clearTimeout(lcount);
    } else if ((navigator.appName == "Netscape") && document.getElementById && (navigator.userAgent.indexOf("Safari") < 0)) {
        if (lighting >= 0) {
            document.getElementById(cName).style.MozOpacity = lighting / 100;
            lighting = lighting - 20;
            clearTimeout(lcount);
            lcount = setTimeout("fadeout('" + cName + "')", 100);
        } else clearTimeout(lcount);
    } else if ((navigator.appName == "Opera") && document.getElementById || (navigator.userAgent.indexOf("Safari") > 0)) {
        if (lighting >= 0) {
            document.getElementById(cName).style.opacity = lighting / 100;
            lighting = lighting - 20;
            clearTimeout(lcount);
            lcount = setTimeout("fadeout('" + cName + "')", 100);
        } else clearTimeout(lcount);
    } else return;
}

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

    if (chipOBJ.visibility == "visible" || chipOBJ.visibility == "show") {
        return;
    }


    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;
        document.getElementById(cName).style.opacity = 0;
        chipOBJ.visibility = "visible";
        lighting = 0;
        fadein(cName);
    } 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;
        document.all[cName].style.filter = 'alpha(opacity=0)';
        chipOBJ.visibility = "visible";
        lighting = 0;
        fadein(cName);
    } 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;
        document.all[cName].style.filter = 'alpha(opacity=0)';
        chipOBJ.visibility = "visible";
        lighting = 0;
        fadein(cName);
    } else if (ie8 || 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;
        chipOBJ.top = chipYpos;
        document.all[cName].style.filter = 'alpha(opacity=0)';
        chipOBJ.visibility = "visible";
        lighting = 0;
        fadein(cName);
    } 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';
        document.getElementById(cName).style.MozOpacity = 0;
        chipOBJ.visibility = "visible";
        lighting = 0;
        fadein(cName);
    } 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';
        document.getElementById(cName).style.MozOpacity = 0;
        chipOBJ.visibility = "visible";
        lighting = 0;
        fadein(cName);
    } else {
        offX = txp;
        offY = typ;
        txs = window.innerWidtht;
        tys = window.innerHeight;
        chipXpos = offX - 200;
        chipYpos = offY + 30;
        poscheck();
        chipOBJ.left = chipXpos;
        chipOBJ.top = chipYpos;
        chipOBJ.visibility = "show";
    }
    clearTimeout(tcount);
    tcount = setTimeout("fadeout('" + cName + "')", 15000);
}

function hideChipHelp(cName) {
    lighting = 0;
    clearTimeout(lcount);
    clearTimeout(tcount);
    if (ie4 || ie5 || ie8 || ns6 || op) {
        chipOBJ.visibility = "hidden";
    } else if (ns4) {
        chipOBJ.visibility = "hide";
    }
}