/*************************************************************************
This code is from Dynamic Web Coding at dyn-web.com
Copyright 2003-5 by Sharon Paine 
See Terms of Use at www.dyn-web.com/bus/terms.html
regarding conditions under which you may use this code.
This notice must be retained in the code as is!
*************************************************************************/

var myTips = new Array();

// adjust horizontal and vertical offsets here
// (distance from mouseover event which activates tooltip)
Tooltip.offX = 4;  
Tooltip.offY = 4;
Tooltip.followMouse = false;  // must be turned off for hover-tip 

function doTooltip(e, msg) 
{
	if (typeof Tooltip == "undefined" || !Tooltip.ready ) return;
	Tooltip.clearTimer();
	var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
	if (tip && tip.onmouseout == null ) 
	{
	  tip.onmouseout = Tooltip.tipOutCheck;
	  tip.onmouseover = Tooltip.clearTimer;
	}
	Tooltip.show(e, msg);
}

function hideTip() 
{
	if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
	Tooltip.timerId = setTimeout("Tooltip.hide()", 300);
}

Tooltip.tipOutCheck = function(e) 
{
	e = dw_event.DOMit(e);
	// is element moused into contained by tooltip?
	var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
	if ( this != toEl && !contained(toEl, this) ) Tooltip.hide();
}

// returns true of oNode is contained by oCont (container)
function contained(oNode, oCont) 
{
	if (!oNode) return; // in case alt-tab away while hovering (prevent error)
	while ( oNode = oNode.parentNode ) if ( oNode == oCont ) return true;
	return false;
}

Tooltip.timerId = 0;
Tooltip.clearTimer = function() 
{
	if (Tooltip.timerId) { clearTimeout(Tooltip.timerId); Tooltip.timerId = 0; }
}

Tooltip.unHookHover = function () 
{
	var tip = document.getElementById? document.getElementById(Tooltip.tipID): null;
	if (tip) {
		tip.onmouseover = null; 
		tip.onmouseout = null;
		tip = null;
	}
}

dw_event.add(window, "unload", Tooltip.unHookHover, true);
