// Nov. 98 by Thomas Mai
var NS4=(document.layers), IE4=(document.all);
var fDHTML=(NS4||IE4);
var nHelpDelay=550, HelpID="", timerID=null, fWaiting=false;

function grabEv(e) {
  var x=0,y=0;
  (NS4) ? (x=e.pageX, y=e.pageY) : (x=event.clientX, y=event.clientY);

  newx = x;
  newy = y;
  HelpID='tipBox';
}


function showHelp(msg) {
  //if ((!fDHTML)||(id==HelpID)) return; // not version 4
  HelpID='tipBox';
  if (!fWaiting) {
    if (NS4) {document.captureEvents(Event.MOUSEMOVE);}
    document.onmousemove=grabEv;
    fWaiting=true;
    timerID=setTimeout("waitForHelp('"+msg+"')",nHelpDelay);
  }
}

function release() {
  return
  if (NS4) document.releaseEvents(Event.MOUSEMOVE);
}

function hideHelp() {
  if ((!fDHTML)||(HelpID=="")) return;
  if (timerID) {
    clearTimeout(timerID);
    timerID=null;
  }
  fWaiting=false;
  release();
  (document.layers) ? (document.layers[HelpID].visibility="hide") : (document.all[HelpID].style.visibility="hidden");
  HelpID="";
}

function waitForHelp(newmsg) {
  clearTimeout(timerID);
  timerID=null;
  fWaiting=false;
  release();
  tip  = "<table cellpadding=4 cellspacing=0 border=1 nowrap><tr><td bgcolor=#D4D4D4>"
  tip += "<font face='Arial, Helvetica, sans-serif' size=1>"
  tip += newmsg
  tip += "</font></td></tr></table>"

  // keep it inside the viewable area
  if ( newx <= 20 ) {
    newx=20
  }else if ( newx > (window.innerWidth - 80) ) {
    newx-=80
  }else{
    newx-=20
  }
  if ( newy > (window.innerHeight - 60) ) {
    newy-=50
  }else{
    newy+=30
  }

  if (NS4) { //NE
    document.layers["tipBox"].left=newx;
    document.layers["tipBox"].top=newy;
    document.layers["tipBox"].document.open
    document.layers["tipBox"].document.write(tip)
    document.layers["tipBox"].document.close()
    document.layers["tipBox"].visibility="show"
  }else{
    document.all['tipBox'].style.left=newx;
    document.all['tipBox'].style.top=newy;
    document.all['tipBox'].innerHTML = tip
    document.all['tipBox'].style.visibility="visible"
  }
}

