var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.getElementById) ? true : false;

//alert ("ns4 = '" + ns4 + "'\nns6 = '" + ns6 + "'\nie4 = '" + ie4 + "'\nie5 = '" + ie5 + "'\n"); 
var information = "";

offsetX = 0;
offsetY = 20;
var toolTipSTYLE="";
function initToolTips()
{
  if(ns4||ns6||ie4||ie5)
  {
    if(ns4) toolTipSTYLE = document.tooltip;
    else if(ns6||ie5) toolTipSTYLE = document.getElementById("tooltip").style;
    else if(ie4) toolTipSTYLE = document.all.tooltip.style;
    if(ns4) document.captureEvents(Event.MOUSEMOVE);
    else
    {
      toolTipSTYLE.visibility = "visible";
      toolTipSTYLE.display = "none";
    }
    document.onmousemove = moveToMouseLoc;
  }

}

function toolTip(word, xinformation, darkcolor, lightcolor)
{
  if(toolTip.arguments.length < 2) // hide
  {
    if(ns4) toolTipSTYLE.visibility = "hidden";
    else toolTipSTYLE.display = "none";
  }
  else // show
  {
    if (xinformation != "")
    {
      if (ns4) {
	  eval("information = document." + xinformation + ".innerHTML;");
      } else if (ns6) {
  	  eval("information = document.getElementById(\"" + xinformation + "\").innerHTML;");
      } else if (ie4) {
	  eval("information = document.all." + xinformation + ".innerHTML;");
      } else if (ie5) {
  	  eval("information = document.getElementById(\"" + xinformation + "\").innerHTML;");
      }
    }
    msg = information;

    if(!darkcolor) darkcolor = "#792412";
    if(!lightcolor) lightcolor= "#FFFFCC";
	if(ns4||ns6||ie5)
	{
      twidth = window.innerWidth - parseInt(toolTipSTYLE.left) - 10;
	}
	else
	{
      twidth = document.body.clientWidth - parseInt(toolTipSTYLE.left) - 10;
	}
	if (isNaN(twidth) || (twidth >= 300)) twidth = 300; 
    var content =
      '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + darkcolor + '"><td>' + 
      '<table border="0" cellspacing="0" cellpadding="2" bgcolor="' + darkcolor + '"><td width="1"></td><td>' +
      '<font face="Verdana, Arial, Helvetica, sans-serif" color="' + lightcolor + '" size="2">' + word + '</font></td></td></table>' +
      '<table border="0" cellspacing="0" cellpadding="2" bgcolor="' + lightcolor + '" width="' + twidth + '"><td width="1"></td><td>' + 
      '<font face="Verdana, Arial, Helvetica, sans-serif" color="' + darkcolor + '" size="2">' + msg + '</font></td></table></td></table>';
    if(ns4)
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    if(ns6||ie5)
    {
      document.getElementById("tooltip").innerHTML = content;
      toolTipSTYLE.display='block';
    }
    if(ie4)
    {
      document.all("tooltip").innerHTML=content;
      toolTipSTYLE.display='block';
    }
  }
}
function moveToMouseLoc(e)
{
  if(ns4||ns6)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else
  {
    x = event.x + document.body.scrollLeft;
    y = event.y + document.body.scrollTop;
  }
  toolTipSTYLE.left = x + offsetX;
  toolTipSTYLE.top = y + offsetY;
  return true;
}
initToolTips();

