var iboxDoc;
var iboxStyle;
var iboxSetupTimer = null;
var setupEvntX;
var setupEvntY;
var setupOrd;
var iboxTimer = null;

function setupIBox(evnt, txtord) {
//  save event info.  Tried saving the event and got zeros for X and Y
  if (navigator.appName == "Netscape") {
    setupEvntX = evnt.pageX;
    setupEvntY = evnt.pageY;
  } else {
    setupEvntX = evnt.clientX;
    setupEvntY = evnt.clientY;
  }
  setupOrd = txtord;
  if (setupOrd < firstSlowBox) {
    iboxSetupTimer = setTimeout ("showIBox ()", 1000);
  } else {
    iboxSetupTimer = setTimeout ("showIBox ()", 3000);
  }
}

function timeoutIBox() {
  iboxTimer = null;
  hideIBox ();
}

function showIBox() {
var txtord = setupOrd;
  iboxSetupTimer = null;
  if (document.getElementById) {
    iboxDoc = document.getElementById("ibox");
    if (document.getElementById("iboxtext").firstChild) {
      document.getElementById("iboxtext").firstChild.nodeValue=imsgs[txtord];
      if (iboxDoc.style) {
        iboxStyle = iboxDoc.style;
        if (navigator.appName == "Netscape") {
          iboxStyle.top = setupEvntY + 5;
          iboxStyle.left = setupEvntX - 10;
        } else {
          if (self.pageYOffset) { // all except Explorer (untested - netscape not here...)
            iboxStyle.top = self.pageYOffset + setupEvntY + 5;
            iboxStyle.left = self.pageXOffset + setupEvntX - 10;
          } else if (document.documentElement &&
                     document.documentElement.scrollTop) {  // Explorer 6 Strict
            iboxStyle.top = document.documentElement.scrollTop + setupEvntY + 5;
            iboxStyle.left = document.documentElement.scrollLeft + setupEvntX - 10;
          } else if (document.body) {  // all other Explorers (tested on ie5)
            iboxStyle.top = document.body.scrollTop + setupEvntY + 5;
            iboxStyle.left = document.body.scrollLeft + setupEvntX - 10;
          }
        }
        iboxStyle.visibility = 'visible';
        iboxTimer = setTimeout ("timeoutIBox ()", 4500);
      }
    }
  } else if (document.layers) {
    var msg = '<table border="0" width="140" bgcolor="#000080" cellpadding="1" cellspacing="0">';
    msg = msg + '<tr><td><table border="0" bgcolor="#FFFFFF" cellpadding="4" cellspacing="0">';
    msg = msg + '<tr><td><font size="1">' + imsgs[txtord] + '</font></td></tr></table></td></tr></table>';
    iboxDoc = document.ibox.document;
    iboxDoc.write(msg);
    iboxDoc.close();
    iboxStyle = document.ibox;
    iboxStyle.top = setupEvntY + 5;
    iboxStyle.left = setupEvntX - 10;
    iboxStyle.visibility = 'visible';
    iboxTimer = setTimeout ("timeoutIBox ()", 5000);
  }
}

function hideIBox() {
  if (iboxSetupTimer) {
    clearTimeout (iboxSetupTimer);
    iboxSetupTimer = null;
    return;
  }
  if (document.getElementById) {
    iboxDoc = document.getElementById("ibox");
    if (iboxDoc.style) {
      iboxStyle = iboxDoc.style;
      iboxStyle.visibility = 'hidden';
    }
  } else if (document.layers) {
    iboxDoc = document.ibox.document;
    iboxStyle = document.ibox;
    iboxStyle.visibility = 'hidden';
  }
  if (iboxTimer) {
    clearTimeout (iboxTimer);
    iboxTimer = null;
  }
}

