
var timeout = null;

function $_(id)
{
	return document.getElementById(id);
}

function init()
{
	var i = 1;
	while (true)
	{
		var p = $_('p' + i);
		var obj = $_('m' + i);
		if(!obj) break;
		p.style.top = parseInt(getTop(obj) + 20) + 'px';
		p.style.left = parseInt(getLeft(obj)) + 'px';
		i++;
	}
}

function getTop(obj)
{
	var result=obj.offsetTop;
	while((obj=obj.offsetParent)!=null)
	result+=obj.offsetTop;
	return result;
}

function getLeft(obj)
{
	var result=obj.offsetLeft;
	while((obj=obj.offsetParent)!=null)
	result+=obj.offsetLeft;
	return result;
}

function hide(id)
{
	$_('p' + id).style.visibility = 'hidden';
}

function show(id)
{	hide(1);
	hide(2);
	hide(3);
	hide(4);
	
	$_('p' + id).style.visibility = 'visible';

	
}

function clear()
{   

	if(timeout)
		clearTimeout(timeout);
}

function popup(id, state)
{
	if(state)
	{	
		clear();
		timeout = setTimeout("show('" + id + "')", 200); 
	}
	else
	{	
		timeout = setTimeout("hide('" + id + "')", 300);
	}
}

