
var MintelTooltip = 
{
    addTooltip: function( ev, callback_data )
    {
       var tt = new YAHOO.widget.Tooltip( callback_data.tooltip_id, callback_data.tooltip_config ); 
       if( callback_data.custom_class )
           YAHOO.util.Dom.addClass( callback_data.tooltip_id, callback_data.custom_class );
    }
}

/**
 * I prefer my own version of this function - which also moves the tooltip left and right to
 * try and avoid the tooltip overlapping the mouse pointer.
 */
YAHOO.widget.Tooltip.prototype.preventOverlap = function(pageX, pageY) {

  var height = this.element.offsetHeight;

  var elementRegion = YAHOO.util.Dom.getRegion(this.element);

  elementRegion.top -= 5;
  elementRegion.left -= 5;
  elementRegion.right += 5;
  elementRegion.bottom += 5;

  var mousePoint = new YAHOO.util.Point(pageX, pageY);

  if (elementRegion.contains(mousePoint)) {
    this.cfg.setProperty("y", (pageY-height-5));
  }

  elementRegion = YAHOO.util.Dom.getRegion(this.element);

  elementRegion.left -= 5;
  elementRegion.right += 5;
  if (elementRegion.contains(mousePoint)) {
    var clientWidth = YAHOO.util.Dom.getClientWidth();
    var width = elementRegion.right - elementRegion.left;
    if ( width < (clientWidth - pageX) )
    {
      //there's space to fit the tooltip to the right of the mouse pointer  
      this.cfg.setProperty("x", (pageX + 2));
    }
    else if ( width < pageX )
    {
      //we can put it to the left of the mouse pointer
      this.cfg.setProperty("x", (pageX - width - 5));
    }
  }
};

// NOTE: Version 2.3.0 of YUI added shadow to YAHOO.widget.Tooltip
// class. This was causing a rendering problem in IE. The following
// line disables the shadow by overriding the method where it is being
// created. See here for more info:
// http://developer.yahoo.com/yui/build/container/README
YAHOO.widget.Tooltip.prototype.onRender = function () {};
