﻿function MenuFolderClick(strBranch)
{
	var objEntry = document.getElementById( 'entry_' + strBranch );
	var objContainer = document.getElementById( 'container_' + strBranch );
	
	if ( objEntry )
	{
		objEntry.className = objEntry.className.indexOf( 'closed' ) >= 0 ? objEntry.className.replace( 'closed', 'open' ) : objEntry.className.replace( 'open', 'closed' );
	}
	
	if ( objContainer )
	{
		objContainer.className = objContainer.className == 'containeropen' ? 'containerclosed' : 'containeropen';
	}
}		


function MenuInit( strID, bCurrent )
{
	if ( strID != null )
	{
		var objLink = document.getElementById( "link_" + strID );
		var objEntry = document.getElementById( "entry_" + strID );
		
		if ( objLink )
		{
			objLink.className = objLink.className.indexOf( 'notselected' ) >= 0 ? objLink.className.replace( 'notselected', 'selected' ) : objLink.className.replace( 'selected', 'notselected' );
		}
		
		if ( objEntry )
		{
			objEntry.className = objEntry.className.indexOf( 'closed' ) >= 0 ? objEntry.className.replace( 'closed', 'open' ) : objEntry.className.replace( 'open', 'closed' );			

			var objParent = objEntry.parentNode;
			var ok = true;
			while ( ok && objParent != null )
			{				
				if ( objParent.tagName.toLowerCase() == "div" )
				{
					if ( objParent.id.indexOf( "container_" ) >= 0 )
					{
						objParent.className = objParent.className == 'containeropen' ? 'containerclosed' : 'containeropen';
						
						var entryid = objParent.id.substring(10);
						var objFolderentry = document.getElementById( "entry_" + entryid );
						if ( objFolderentry )
						{
							objFolderentry.className = objFolderentry.className.indexOf( 'closed' ) >= 0 ? objFolderentry.className.replace( 'closed', 'open' ) : objFolderentry.className.replace( 'open', 'closed' );
						}
					}
					else
					{
						ok = objParent.id != "sitemenu";
					}					
				}
				objParent = objParent.parentNode;
			} 
		}
	}
}