var tooltip = null;
var result = null;

function showTooltip(obj, msg, offsetx, offsety) {
	if (tooltip==null) {
		tooltip = getObj('tooltip');
	}
	var x, y;
	if (tooltip!=null) {
		x = findPosX(obj);
		y = findPosY(obj);
		tooltip.style.top = y+offsetx;
		tooltip.style.left = x+offsety;
		tooltip.style.visibility = 'visible';
		tooltip.innerHTML = msg;
	}
}

function hideTooltip() {
	if (tooltip==null) {
		tooltip = getObj('tooltip');
	}
	if (tooltip!=null) {
		tooltip.style.visibility = 'hidden';
	}
}

function showResult(obj, msg, offsetx, offsety) {
	if (result==null) {
		result = getObj('result');
	}
	if (result!=null) {
		var x, y;
		x = findPosX(obj);
		y = findPosY(obj);
		result.style.top = y+offsety;
		result.style.left = x+offsetx;
		result.style.visibility = 'visible';
		result.innerHTML = msg;
	}
}

function hideResult() {
	if (result==null) {
		result = getObj('result');
	}
	if (result!=null) {
		result.style.visibility = 'hidden';
	}
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function getObj(name)
{
	if (document.getElementById)
	{
		if (document.getElementById(name)!=null) {
			return document.getElementById(name);
			return;
		}
	}
	else if (document.all)
	{
		if (document.all[name]!=null) {
			return document.all[name];
		}
	}
	else if (document.layers)
	{
		if (document.layers[name]!=null) {
			return document.layers[name];
		}
	}
	return null;
}