function mouseFollowerContainer()
  {
  this.topOffset = 0;
  this.leftOffset = 0;
  this.domRoot = null;
  }

function mouseFollower()
  {
  this.containers = new Array();
//  attachNodeEvent(window, 'load', );
  app.addOnload(new objfn('postPageload', this));

  this.previousTopOffset = 0;
  this.previousLeftOffset = 0;

  }

mouseFollower.prototype.postPageload = function()
  {
  attachNodeEvent(document.body, 'mousemove', new objfn('bodyMouseMoveReader', this));
  }

mouseFollower.prototype.bodyMouseMoveReader = function(evnt)
  {
  if (evnt == null)
    {
    evnt = event;
    }

  var topDiff = document.body.scrollTop;
  if (topDiff == 0 && document.documentElement.scrollTop != null)
    {
    topDiff = document.documentElement.scrollTop;
    }
  var topOffset = evnt['clientY']+topDiff;
  var leftOffset = evnt['clientX'];

  this.setOffsets(topOffset, leftOffset);

  this.previousTopOffset = topOffset;
  this.previousLeftOffset = leftOffset;
  }

mouseFollower.prototype.setOffsets = function(topOffset, leftOffset)
  {
  for(var i = 0; i < this.containers.length; i++)
    {
    if (this.containers[i] != null)
      {
      this.containers[i].domRoot.style['top'] = (topOffset+this.containers[i].topOffset) + 'px';
      this.containers[i].domRoot.style['left'] = (leftOffset+this.containers[i].leftOffset) + 'px';
      }
    }
  }


mouseFollower.prototype.addContainer = function(container)
  {
  var freeIndex = this.containers.length;

  for(var i = 0; i < this.containers.length; i++)
    {
    if (this.containers[i] == null)
      {
      freeIndex = i;
      break;
      }
    }
  document.body.appendChild(container.domRoot);
  this.containers[freeIndex] = container;

  this.setOffsets(this.previousTopOffset, this.previousLeftOffset);

  return freeIndex;
  }

mouseFollower.prototype.removeContainer = function(index)
  {
  this.containers[index].domRoot.parentNode.removeChild(this.containers[index].domRoot);
  this.containers[index] = null;
  }


var mouseFollower = new mouseFollower();

function toolTipManager()
  {

  var parent = this;
  var onpageload = function(evnt)
    {
    parent.postPageload(evnt);
    }
  attachNodeEvent(window, 'load', onpageload);

  this.showing = false;
  this.nodeObj = null;
  }

toolTipManager.prototype.postPageload = function(evnt)
  {
  if (evnt == null)
    {
    evnt = event;
    }

  var parent = this;
/*
  var onmousemoveFn = function(evnt)
    {
//    alert('hey');
    parent.bodyMouseMoveReader(evnt);
    }
*/
  this.nodeObj = document.createElement('div');
  this.nodeObj.className = "tooltip_textbox";
  this.nodeObj.style['visibility'] = 'hidden';
  this.nodeObj.style['display'] = 'none';
  document.body.appendChild(this.nodeObj);

  var mfc = new mouseFollowerContainer();
  mfc.leftOffset = 15
  mfc.domRoot = this.nodeObj;

  mouseFollower.addContainer(mfc);
//  attachNodeEvent(document.body, 'mousemove', onmousemoveFn);
  }
/*
toolTipManager.prototype.bodyMouseMoveReader = function(evnt)
  {
//  if (!this.showing) {return;}
  if (evnt == null)
    {
    evnt = event;
    }
  var topDiff = document.body.scrollTop;

  if (topDiff == 0 && document.documentElement.scrollTop != null)
    {
    topDiff = document.documentElement.scrollTop;
    }
  this.nodeObj.style['top'] = (evnt['clientY']+topDiff) + 'px';
  this.nodeObj.style['left'] = (evnt['clientX']+15) + 'px';
  }
*/

toolTipManager.prototype.set = function(text)
  {
  if (this.nodeObj == null)
    {
    return;
    }
  this.showing = true;
  while (this.nodeObj.childNodes.length != 0)
    this.nodeObj.removeChild(this.nodeObj.childNodes[0]);
  this.nodeObj.appendChild(document.createTextNode(text));
  this.nodeObj.style['visibility'] = 'visible';
  this.nodeObj.style['display'] = 'block';
  }

toolTipManager.prototype.clear = function()
  {
  if (this.nodeObj == null)
    {
    return;
    }
  this.showing = false;
  this.nodeObj.style['visibility'] = 'hidden';
  this.nodeObj.style['display'] = 'none';
  }

var ttManager = new toolTipManager();
