//\ Tooltip lib version 1.0
//\ Copyright 2002 by Lisa Patacchiola, all rights reserved
//\
//\ By Lisa Patacchiola, lword@world.std.com
//\ version history:
//\ 4/20/2002: First version is uploaded
//\ 6/29/2008: Fixed a typo in the writeLayer function
//\ 6/30/2008: More changes for Firefox
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//\ To use: make a <div> named tipLayer
//\         call showToolTip(tip) onMouseOver
//\         call hideToolTip() onMouseOut
//\////////////////////////////////////////////////////////////////
var clockID = 0;
var mouse_x = 0;
var mouse_y = 0;

//only need to call this once, to start up mouseTracking
function init() {
	if (document.layers) 
        {
        document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove=mousemove;
        }
        else {
        document.onmousemove=mousemove;
        }
}
function mousemove(e) {

     if (!e)
     {
        e = window.event;
     }
     if (document.layers) {mouse_x=e.pageX; mouse_y=e.pageY}
     else if (e.pageX)
     {
        mouse_x=e.pageX;
        mouse_y=e.pageY;
     }
     else if (e.clientX)
     {
     mouse_x = e.clientX + document.body.scrollLeft;
     mouse_y = e.clientY + document.body.scrollRight;
     }
        
}

// write the tooltip to the approp layer
function writeLayer(id, message)
{
   if (document.layers)
   {
     document.layers[id].document.write(message);
     document.layers[id].document.close();
   }
   else if (document.all)
      {
        eval("document.all."+id+".innerHTML='"+message+"'");
      }
      else {
         document.getElementById(id).innerHTML = message;
      }
}

// move the tooltip under the players mouse
function moveLayer(id)
{
  if (document.all)
  {
     eval(id + ".style.pixelTop = event.clientY + document.body.scrollTop + 10");
     eval(id + ".style.pixelLeft = event.clientX + document.body.scrollLeft + 10");
  } else if (document.layers)
         {
            eval("document."+id+".top = mouse_y + 10");  
            eval("document."+id+".left = mouse_x + 10");  
         }
  else {
      document.getElementById(id).style.top = mouse_y + 10;
      document.getElementById(id).style.left = mouse_x + 10;
  }

}

// show the tooltip
function showToolTip( tip )
{
   var showItem;
   init();
   showItem ="<TABLE BGCOLOR=\"FFAAEE\" BORDER=\"1\"><TR><TD>" + tip + "</TD></TR></TABLE>";
   writeLayer('tipLayer', showItem);
   moveLayer('tipLayer');
   startTimer();
}

// start the timer (will shut off tooltip after ~4 seconds)
function startTimer()
{
   if (clockID)
   {
      clearTimeout(clockID);
      clockID = 0;
   }
   clockID = setTimeout('hideToolTip()', 4000);
}
// hide the currently shown tooltip
function hideToolTip()
{
   if (clockID)
   {
      clearTimeout(clockID);
      clockID = 0;
   }
   writeLayer('tipLayer', ' ');
}

