var timeout_tt;
var hw_tooltip = true;
function hw_show_tooltip(show, mode, title, content, ref, params) {
	if (!hw_tooltip) return;
	if (params) eval('('+params+')');
	if (!ref) 
	{
		tt_x = mouse_x+15;
		tt_y = mouse_y+10;
		
	}
	else
	{
		pos = findPos(ref);
		tt_x = pos[0]+10;
		tt_y = pos[1]+ref.offsetHeight+10;
	}
	if (show) 
	{
		tooltip_style = document.getElementById('hw_tooltip').style;
		tooltip_style.display = 'block';
		if (timeout_tt) clearTimeout(timeout_tt);
		if (mode=='init') 
		{
			if (title) document.getElementById('hw_tooltip_title').innerHTML = title;
			if (content) document.getElementById('hw_tooltip_body').innerHTML = content;
			tooltip_style.top=tt_y+"px";
			tooltip_style.left=tt_x+"px";
		}
		else if (mode=='timeout') timeout_tt = setTimeout('hw_show_tooltip(false)', 200);
//		else if (timeout_tt) clearTimeout(timeout_tt);
	}
	else 
	{
		document.getElementById('hw_tooltip').style.display = 'none';
		if (timeout_tt) clearTimeout(timeout_tt);
	}
}	

//thanks to http://www.quirksmode.org
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}