/****************************************************************
* Class ToolTip                                                 *
*                                                               *
* Properties: backColor                                         *
*               Input: (String)                                 *
*               Output: (String)                                *
*             borderColor                                       *
*               Input: (String)                                 *
*               Output: (String)                                *
*             foreColor                                         *
*               Input: (String)                                 *
*               Output: (String)                                *
* Methods: hide                                                 *
*            Input: -                                           *
*            Output: -                                          *
*          show                                                 *
*            Input: (str String, width Integer, height Integer) *
*            Output: -                                          *
****************************************************************/

function ToolTip()
{
  var divobj = new Object();

  var enabled;

  enabled = false;
  document.body.innerHTML += '<DIV ID=\"tooltip\"></DIV>';
  divobj = document.getElementById('tooltip');
  divobj.style.borderStyle = 'solid';
  divobj.style.borderWidth = '1px';
  divobj.style.padding = '1px';
  divobj.style.position = 'absolute';
  divobj.style.visibility = 'hidden';
  document.onmousedown = down;
  document.onmousemove = move;

  function down()
  {
    divobj.style.visibility = 'hidden';
  }

  function move(evt)
  {
    var left, top;
    if (enabled == true)
    {
      if (evt != null)
      {
        left = evt.pageX - 60;
        top = evt.pageY + 20;
      }
      else
      {
        left = event.x - 60;
        top = event.y + 20;
      }
      if (left < 0)
        divobj.style.left = '5px';
      else if ((left + divobj.offsetWidth) > document.body.clientWidth)
        divobj.style.left = (document.body.clientWidth - divobj.offsetWidth - 5) + 'px';
      else
        divobj.style.left = left + 'px';
      if ((top + divobj.offsetHeight) > document.body.clientHeight)
        divobj.style.top = (document.body.clientHeight - divobj.offsetHeight - 5) + 'px';
      else
        divobj.style.top = top + 'px';
      divobj.style.visibility = 'visible';
    }
    else
      divobj.style.visibility = 'hidden';
  }

  this.hide = function()
  {
    enabled = false;
  };

  this.show = function(str, width, height)
  {
    enabled = true;
    divobj.innerHTML = '&nbsp;' + str;
    divobj.style.background = this.backColor;
    divobj.style.borderColor = this.borderColor;
    divobj.style.color = this.foreColor;
    if ((document.all != null) && (window.external != undefined))
    {
      divobj.style.width = width + 'px';
      divobj.style.height = height + 'px';
    }
    else
    {
      divobj.style.width = (width - 4) + 'px';
      divobj.style.height = (height - 4) + 'px';
    }
  };
}

