var current	= null;
var default_id = null;
var timeout = 0;

function showsubitem(item_id)
{
	if (timeout)
		clearTimeout(timeout);
	
	subitems = $('submenu').immediateDescendants();
	
	for(i=0;i<subitems.length;i++)
	{
		
		if($(subitems[i].id).style.display == 'block')
		{
			$(subitems[i].id).style.display = 'none';
		}
	} 

	$('sub_' + item_id).style.display = 'block';
	current = item_id;
}

function hidesubitem(item_id)
{
	if (default_id !== null && item_id != default_id)
		timeout = setTimeout("hide()", 500);
}

function hide()
{
	if ($('sub_' + current))
		$('sub_' + current).style.display = 'none';
		
	$('sub_' + default_id).style.display = 'block';
}

function showitem()
{
	if (timeout)
		clearTimeout(timeout);
}

function hideitem()
{
	if (default_id !== null && current != default_id)
		timeout = setTimeout("hide()", 500);
}
