// displays a "speech bubble" tooltip on mouseover of a particular object
// document must have a hidden <div id='tooltip'> to manipulate

var ttTimer = null;
var ttDelay = 500; 		// 500 ms delay on hover

// position the tooltip over element
function startToolTip(ele, ttText)
{
	// clear timer if we get next onmouseover event before onmouseout
	clearTimeout(ttTimer);
	ttTimer = null;

	// subtract the centered container offset
	containerOffset = document.getElementById('container').offsetLeft;

	newX = findPosX(ele) + 40 - containerOffset +  "px";

	
	newY = findPosY(ele) - 90 + "px";

	// escape single quotes in tool tip text
	safeText = new String(ttText);
	safeText = safeText.replace(/'/g, "\\'");
	
	ttTimer = setTimeout('drawToolTip(\'' + safeText + '\',' +
						 '\'' + newX + '\'' + ',\'' + newY + '\')', 
						 ttDelay);	

}

function drawToolTip(ttText, newX, newY)
{
	tt = document.getElementById('tooltip');

	if (tt.style.display == 'none')
	{
		ttTextDiv = document.getElementById('tiptext');
		tt.style.left = newX;
		tt.style.top = newY;
		ttTextDiv.innerHTML = ttText;

		tt.style.display = 'block';
		//new Effect.AppearFast(tt);
	}	
}

function endToolTip()
{
	clearTimeout(ttTimer);
	ttTimer = null;

	tt = document.getElementById('tooltip');

	if (tt)
		tt.style.display = 'none';
}
