/*

Copyright 2003-2005 Conclusive Systems, LLC
All code herein may not be reproduced in full or in part under penalty of law.

*/

var tooltip = {
  tid : 0,
  coords : {'x' : '', 'y' : ''},
  text : 0,
  min_width : 0,

  'show' : function(e, text, min_width)
  {
    /* check compatibility */
    if (!document.getElementById || !document.createElement) return false;
    /* make sure tooltip div exists */
    if (!document.getElementById('tooltip')) this.create();
    /* save information */
    this.coords = get_event_coordinates(e);
    this.text = text;
    this.min_width = min_width;
    /* delay the appearance (hover to show) */
    this.tid = setTimeout('tooltip.show2()', 700);
  },

  'show2' : function()
  {
    var div = document.getElementById('tooltip');
    /* position of tooltip */
    this.coords['x'] += 18;//offset the div from the mouse
    var document_width = (document.layers) ? document.width : document.body.clientWidth;
    if (document_width - this.coords['x'] < this.min_width) this.coords['x'] = Math.max(document_width - this.min_width, 0);//if needed, move the tooltip away from the screen's edge
    /* now actually position the tooltip */
    div.style.top = this.coords['y'] + 'px';
    div.style.left = this.coords['x'] + 'px';
    /* fill the tooltip */
    div.innerHTML = this.text;
    show(div);
  },

  'hide' : function()
  {
    if (!document.getElementById) return false;
    clearTimeout(this.tid);
    hide(document.getElementById('tooltip'));
  },

  /* creates the tooltip div */
  'create' : function()
  {
    var div = document.createElement('div');
    div.id = 'tooltip';
    div.style.display = 'none';
    div.style.position = 'absolute';
    div.style.zIndex = '10';
    div.style.backgroundColor = '#ffffff';
    div.style.border = '1px solid #000000';
    div.style.padding = '2px';
    div.style.cursor = 'help';
    document.body.appendChild(div);
  }
}
