var activeSubmenuIndex = -1;
var delayedHideSubmenuIndex = -1;
var hideSubmenuTimeout = null;
function showSm( index )
{
	var sm = document.getElementById( 'sm' + index );
	if( sm != null )
	{
		if ( ( index != activeSubmenuIndex ) && ( activeSubmenuIndex >= 0 ) )
			hideSm( activeSubmenuIndex );
	
		if ( index == delayedHideSubmenuIndex )
		{
			clearTimeout( hideSubmenuTimeout );
			hideSubmenuTimeout = null;
		}
	
	
		if ( sm.style.display != 'block' )
		{
			activeSubmenuIndex = index;
			sm.style.display = 'block';
		}
	}
}
function hideSm( index )
{
	if ( index >= 0 )
	{
		var sm = document.getElementById( 'sm' + index );
		if ( sm.style.display == 'block' )
		{
			sm.style.display = 'none';
			if ( activeSubmenuIndex == index )
				activeSubmenuIndex = -1;
		}
	}
}

function delayedHideSm( index )
{
	if ( activeSubmenuIndex == index )
	{
		delayedHideSubmenuIndex = index;
		clearTimeout( hideSubmenuTimeout ); // cancel previous
		/*hideSubmenuTimeout = setTimeout( 'hideSm(' + index + ')', 800 );*/
		hideSubmenuTimeout = setTimeout( 'hideSm(' + index + ')', 10 );
	}
}

var activeSubSubmenuIndex = -1;
var delayedHideSubSubmenuIndex = -1;
var hideSubSubmenuTimeout = null;
function showSubSm( index )
{
	var sm = document.getElementById( 'subSm' + index );

	if ( ( index != activeSubSubmenuIndex ) && ( activeSubSubmenuIndex >= 0 ) )
		hideSubSm( activeSubSubmenuIndex );

	if ( index == delayedHideSubSubmenuIndex )
	{
		clearTimeout( hideSubSubmenuTimeout );
		hideSubSubmenuTimeout = null;
	}

	if ( sm.style.display != 'block' )
	{
		activeSubSubmenuIndex = index;
		sm.style.display = 'block';
	}
}
function hideSubSm( index )
{
	if ( index >= 0 )
	{
		var sm = document.getElementById( 'subSm' + index );
		if ( sm.style.display == 'block' )
		{
			sm.style.display = 'none';
			if ( activeSubSubmenuIndex == index )
				activeSubSubmenuIndex = -1;
		}
	}
}

function delayedHideSubSm( index )
{
	if ( activeSubSubmenuIndex == index )
	{
		delayedHideSubSubmenuIndex = index;
		clearTimeout( hideSubSubmenuTimeout ); // cancel previous
		/*hideSubmenuTimeout = setTimeout( 'hideSm(' + index + ')', 800 );*/
		hideSubSubmenuTimeout = setTimeout( 'hideSubSm(' + index + ')', 10 );
	}
}