var timr   = null;
var dohide = false;
var clearcount = 0;

function menuAction(item)
{
	dohide = false;
	showSubMenu(item);
	return false;
}

function parGetWidth(item)
{
	var par, itemz, i, w;
	w = 0;

	for (i=1; i<item.length; i++)
	{
		itemz   = item.substring(0, i);
		par	= document.getElementById('m' + itemz);
		w 	+= par.offsetWidth;
	}

	return w;
}

function showSubMenu(item)
{
	hideAllNot(item);

	var itemref, i, itempar;

	for (i=1; i<=item.length; i++)
	{
		itempar = item.substring(0, i);
		itemref = document.getElementById('menu' + itempar);
		if (itemref == null) return;

		if (navigator.userAgent.indexOf("Netscape6/6.0") != -1)
		{
		}

		itemref.style.display = 'block';
	}
}

function hideSubMenu(item)
{
	var itemref   = document.getElementById('menu' + item);
	if (itemref == null) return;

	itemref.style.display = 'none';
}

function hideAllNot(item)
{
	var x = item.substring(0, 1);

	if (x != '2') hideSubMenu('2');
	if (x != '3') hideSubMenu('3');
	if (x != '5') hideSubMenu('5');
}

function hideAll()
{
	clearcount--;
	if (clearcount > 0) return;
	clearcount = 0;

	if (dohide == true) {hideAllNot('0'); dohide = false;}

	if (timr != null)
	{
		clearTimeout(timr);
		timr = null;
	}
}

function timeHide()
{
	clearcount++;
	dohide = true;
	timr   = setTimeout("hideAll()", 500);
	return false;
}
