var lastMenu;
var x1;
var x2;
var y1;
var y2;

window.onerror=new Function("return true");

function showMenu(id)
{
	var menuanchor;
	var menu;
	
	menuanchor = document.getElementById('menuAnchor_' + id);	
	menu = document.getElementById('menu_' + id).style;
	
	menu.left = calculateSumOffset(menuanchor, 'offsetLeft');			
	menu.top = calculateSumOffset(menuanchor, 'offsetTop') + menuanchor.offsetHeight + 4;
	
	menu.visibility = 'visible';
		
	if (lastMenu != null && lastMenu != menu) hideAll();
	x1 = parseInt(menu.left);	
	y1 = calculateSumOffset(menuanchor, 'offsetTop')
	x2 = x1 + parseInt(menu.width);
	y2 = y1 + menuanchor.offsetHeight + 4 + parseInt(menu.height);		
	lastMenu = menu;	
}

function hideAll()
{
	if (lastMenu != null) { lastMenu.visibility = 'hidden'; };
}

function updateIt(e)
{			
	if (e != null || window.event != null)
	{				
		if (e != null) 
		{		
			var x = e.clientX;
			var y = e.clientY;		
		}
		else
		{
			var x = window.event.clientX;
			var y = window.event.clientY;				
		}
		
		if (x > x2 || x < x1) hideAll();
		else if (y > y2 || y < y1) hideAll();
	};
}

function calculateSumOffset(idItem, offsetName)
{
	var totalOffset = 0;
	var item = eval('idItem');
	do
	{
		totalOffset += eval('item.' + offsetName);
		item = eval('item.offsetParent');
	} while (item != null);
	return totalOffset;
}

function openDialog(url, height, width)
{
	var left
	var top
	
	left = (screen.width / 2) - (width / 2);
	top = (screen.height / 2) - (height / 2);
	window.open(url,'message','toolbar=no,menus=no,address=no,status=no,scrollbars=yes,width='+width+',height='+height+',left='+left+',top='+top+',resizable=yes');
}

hideAll();
if (document.body != null)
{
	document.body.onclick=hideAll;
	document.body.onscroll=hideAll;
	document.body.onmousemove=updateIt;
	updateIt();
};
//setTimeout('updateIt()', 200);

