/****************************************************************************************
 * Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com) *
 * This notice MUST stay intact for legal use                                           *
 * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code             *
 ****************************************************************************************/

var offsetXPt    = -35;   // X offset of the tooltip
var offsetYPt    =  25;   // Y offset of the tooltip
var xLeftShift   =   5;   // Left shift for the X offset of the tooltip
var xRightShift  =  59;   // Right shift for the X offset of the tooltip
var yShift       = -20;   // Shift for the Y offset of the tooltip

var defaultWidth = "300px";   // Default width of the tooltip

var ie  = document.all;
var ns6 = document.getElementById && !document.all;

var enableTooltip = false;

if (ie || ns6)
   var tooltipObj = document.all?document.all["Tooltip"]:document.getElementById?document.getElementById("Tooltip"):"";

function ieTrueBody()
{
   return (document.compatMode && (document.compatMode != "BackCompat"))?document.documentElement:document.body;
}

function showTooltip(aTooltip, aColor, aWidth)
{
   if (ns6 || ie)
   {
      if (typeof(aWidth) != "undefined")
         tooltipObj.style.width = aWidth+"px";
      else
         tooltipObj.style.width = defaultWidth;

      if ((typeof(aColor) != "undefined") && (aColor != ""))
         tooltipObj.style.backgroundColor = aColor;

      tooltipObj.innerHTML = aTooltip;

      enableTooltip = true;

      return false;
   }
}

function positionTooltip(aTooltip)
{
   if (enableTooltip)
   {
      var crtX = ns6?aTooltip.pageX:event.clientX+ieTrueBody().scrollLeft;
      var crtY = ns6?aTooltip.pageY:event.clientY+ieTrueBody().scrollTop;

      // Find out how close the mouse is to the corner of the window

      var rightEdge  = (ie && !window.opera)?ieTrueBody().clientWidth-event.clientX-offsetXPt:window.innerWidth-aTooltip.clientX-offsetXPt;
      var bottomEdge = (ie && !window.opera)?ieTrueBody().clientHeight-event.clientY-offsetYPt:window.innerHeight-aTooltip.clientY-offsetYPt-5;

      var leftEdge = (offsetXPt < 0)?offsetXPt*-1:-1000;

      // If the horizontal distance isn't enough to accomodate the
      // width of the tooltip

      if (rightEdge < tooltipObj.offsetWidth+25)
         // Move the horizontal position of the tooltip to the left

         tooltipObj.style.left = ie?ieTrueBody().scrollLeft+event.clientX-(tooltipObj.offsetWidth-rightEdge+xRightShift)+"px":window.pageXOffset+aTooltip.clientX-(tooltipObj.offsetWidth-rightEdge+xRightShift)+"px";
      else if (crtX < leftEdge+xLeftShift)
         tooltipObj.style.left = xLeftShift+"px";
      else
         // Position the horizontal position of the tooltip where the
         // mouse is positioned

         tooltipObj.style.left = crtX+offsetXPt+"px";

      // Same concept with the vertical position

      if (bottomEdge < tooltipObj.offsetHeight)
         tooltipObj.style.top = ie?ieTrueBody().scrollTop+event.clientY-tooltipObj.offsetHeight-offsetYPt-yShift+"px":window.pageYOffset+aTooltip.clientY-tooltipObj.offsetHeight-offsetYPt-yShift+"px";
      else
         tooltipObj.style.top = crtY+offsetYPt+"px";

      tooltipObj.style.visibility = "visible";
   }
}

function hideTooltip()
{
   if (ns6 || ie)
   {
      enableTooltip = false;

      tooltipObj.style.visibility      = "hidden";
      tooltipObj.style.left            = "-1000px";
      tooltipObj.style.backgroundColor = "";
      tooltipObj.style.width           = "";
   }
}

document.onmousemove = positionTooltip;

