// Copyright (c) 2003-2004 by UriSoft
// TopicHints for Invision Power Board v2.0F
window.onerror = null;
var dom = (document.getElementById) ? true : false;
var nn4 = (document.layers) ? true : false;
var ie = (document.all) ? true : false;
var ie4 = (!dom && ie) ? true : false;
var moz = (dom && (navigator.appName=="Netscape")) ? true : false;
var opr = (dom && window.opera) ? true : false;
var op7 = false;
if (opr) {
ua = navigator.userAgent;
opisp = ua.indexOf("Opera");
if (opisp >= 0) {
 opisp+=6;
 op7 = ( (ua.charAt(opisp)>6 && ua.charAt(opisp)<=9) || (ua.charAt(opisp)==1) ) ? true : false;
}
}
var hintsObj = null;
var oCanvas = document.getElementsByTagName((document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY")[0];
// ALL
function setObjectContents(Obj,Contents) {
  if (dom)
    document.getElementById(Obj).innerHTML = Contents;
  else if (nn4) {
    document.layers[Obj].document.open();
    document.layers[Obj].document.write(Contents);
    document.layers[Obj].document.close();
  }
  else if (ie4)
    document.all[Obj].innerHTML = Contents;
}
function showHints(obj,head,text,width) {
  if ((opr && !op7) || (text == ""))
    return;
  contents = '<table width=' + width + ' class="ns1"><tr><th class="c slr srr sbr">' +
             head +
             '</td></tr><tr><td class="l slr srr str">' +
             text +
             '</td></tr></table>';
  hintsObj = obj;
  setObjectContents('hints',contents);
  // for Netscape, Mozilla and Opera
  if (nn4 || moz || op7) {
    document.captureEvents(Event.MOUSEMOVE);
    document.captureEvents(Event.MOUSEOUT);
    document.onmousemove = moveHintsN;
    document.onmouseout = hideHintsN;
    return;
  }
  // for IE
  if (dom || ie) {
    moveHints();
    if (dom)
      document.getElementById('hints').style.visibility = "visible";
    else if (ie4)
      document.all['hints'].style.visibility = "visible";
  }
}

function getHintObj () {
        if (nn4) return document.layers['hints'];
        if (moz || op7)  return document.getElementById('hints');
        if (dom)  return document.getElementById('hints');
        if (ie4)  return document.all['hints'];
        return null;
}

function checkX (x) {
        var w_wdt = oCanvas.clientWidth ? oCanvas.clientWidth + oCanvas.scrollLeft : window.innerWidth + window.pageXOffset;
        var t_wdt = getHintObj().offsetWidth;
        return (x + t_wdt > w_wdt) ? x-t_wdt +30 : x;
}

function checkY (y) {
        var w_hgt=window.innerHeight ? window.innerHeight + window.pageYOffset : oCanvas.clientHeight + oCanvas.scrollTop;
        var t_hgt=getHintObj().offsetHeight;
        return (y + t_hgt > w_hgt) ? w_hgt-t_hgt -3 : y;
}

// Netscape, Mozilla and Opera
function moveHintsN(e) {

        if (hintsObj == null) return;
        if (nn4) {
                xoff=checkX(e.pageX + 10);
                yoff=checkY(e.pageY + 10);
                document.layers['hints'].left = xoff;
                document.layers['hints'].top = yoff;
                document.layers['hints'].visibility = "show"
        } else if (moz || op7) {
                xoff=checkX(window.pageXOffset + e.clientX + 10);
                yoff=checkY(window.pageYOffset + e.clientY + 10);
                document.getElementById('hints').style.left = xoff + "px";
                document.getElementById('hints').style.top = yoff + "px";
                document.getElementById('hints').style.visibility = "visible";
        }
}

function hideHintsN(e) {

        if (hintsObj == null) return;
        document.releaseEvents(Event.MOUSEMOVE);
        document.releaseEvents(Event.MOUSEOUT);
        document.onmousemove = null;
        document.onmouseout = null;
           if (nn4) {
                document.layers['hints'].visibility = "hide";
                document.layers['hints'].left = 0;
                document.layers['hints'].top = 0;
    } else if (moz || op7) document.getElementById('hints').style.visibility = "hidden";
    hintsObj = null;
}


// IE
function moveHints() {

        if (opr || moz || nn4 || (hintsObj == null)) return;


    xoff = 0;
    yoff = 0;
        if (dom || ie) {
                if (dom) q = document.getElementById(hintsObj);
                else q = document.all[hintsObj];
                while (q) {
                        xoff += q.offsetLeft;
                        yoff += q.offsetTop;
                        q = q.offsetParent;
                }
                xoff += window.event.offsetX + 10;
                yoff += window.event.offsetY + 10;
        }

        xoff=checkX(xoff);
        yoff=checkY(yoff);

    if (dom) {
                document.getElementById('hints').style.left = xoff;
                document.getElementById('hints').style.top = yoff;
        } else if (ie4) {
                document.all['hints'].style.left = xoff;
                document.all['hints'].style.top = yoff;
        }
}

function hideHints() {

        if (opr || moz || nn4 || (hintsObj == null)) return;

        if (dom) document.getElementById('hints').style.visibility = "hidden";
                else if (ie4) document.all['hints'].style.visibility = "hidden";
    hintsObj = null;
}
