var tooltip_id = "tooltip";
var tooltip_show_position = 'right';

function tooltip(message, opener, position, style)
{
	tooltip_show_position = position;
	
	$(tooltip_id).className = style?style:"tooltip";
	

	$(opener).onmouseout = new Function("tooltip_hide('" + opener + "')");
	document.body.onmousemove = tooltip_follow;
	$(tooltip_id).innerHTML = message;
}

function tooltip_follow(event)
{
	var event = event || window.event;
	
	var y = event.clientY;
	var x = event.clientX;

	$(tooltip_id).style.display = "block";
	if(tooltip_show_position == 'left')
	{
		$(tooltip_id).style.top = (y-5) + "px";
		$(tooltip_id).style.left = (x-510) + "px";	
		$(tooltip_id).style.textAlign = "right";		
	}
	else if(tooltip_show_position == 'top')
	{
		$(tooltip_id).style.top = (y-25) + "px";
		$(tooltip_id).style.left = (x-20) + "px";	
		$(tooltip_id).style.textAlign = "left";			
	}
	else if(tooltip_show_position == 'bottom')
	{
		$(tooltip_id).style.top = (y+25) + "px";
		$(tooltip_id).style.left = (x-20) + "px";	
		$(tooltip_id).style.textAlign = "left";			
	}
	else
	{
		$(tooltip_id).style.top = (y-5) + "px";
		$(tooltip_id).style.left = (x+15) + "px";		
		$(tooltip_id).style.textAlign = "left";	
	}
}

function tooltip_hide(opener)
{
	document.body.onmousemove = null;
	$(opener).onmouseout = null;
	$(tooltip_id).style.display = "none";	
}
