// tool handler for tooltips

// These variables will hold the current mouse pointer position.
var mouseX = 0;
var mouseY = 0;

// Set up event capturing.
if (isMinNS4)
  document.captureEvents(Event.MOUSEMOVE);
  document.onmousemove = getMousePosition;

function getMousePosition(e) {
  // Save cursor position using browser-specific code.

  if (isMinNS4) {
    mouseX = e.pageX;
    mouseY = e.pageY;
  }
  if (isMinIE4) {
    mouseX = event.clientX + document.body.scrollLeft;
    mouseY = event.clientY + document.body.scrollTop;
  }
  return true;
}

// Timing in msec and positioning constants for tool tip display.

var toolTipWait = 1000;    // Delay before showing tool tip.
var toolTipShow = 5000;    // Time to keep tool tip active.
var toolTipxOff =    0;    // Horizontal distance from mouse.
var toolTipyOff =   20;    // Vertical distance from mouse.

function startToolTip(name) {
  var tip = getHandle(name);

  // Clear out any pending timer.

  if (tip.timerID)
    clearTimeout(tip.timerID);

  // Set timer to show tool tip.

  tip.timerID = setTimeout('showToolTip("' + name + '")', toolTipWait);
}

function showToolTip(name) {
  var tip = getHandle(name);
  
  // Clear out any pending timer.

  if (tip.timerID)
    clearTimeout(tip.timerID);

  // Position and show the tool tip.

  moveLayerTo(tip, mouseX + toolTipxOff, mouseY + toolTipyOff);
  showLayer(tip);
        
  // Set timer to hide the tool tip after a delay.

  tip.timerID = setTimeout('hideToolTip("' + name + '")', toolTipShow);
}

function hideToolTip(name) {
  var tip = getHandle(name);
  
  // Clear out any pending timer.

  if (tip.timerID)
    clearTimeout(tip.timerID);

  hideLayer(tip);
}

function getHandle(name) {
  // Get a handle to the named tool tip using browser-specific code.
  
  if (isMinNS4)
    return(document.layers[name]);
  if (isMinIE4) {
    var block = eval('document.all.' + name);
    return(block);
  }
}

