function getDestinations()
{
	var allMainDivs = new Array();
	var allDls = document.getElementsByTagName("dl");
	for(var i = 0; i < allDls.length; i++)
	{
		var allNaviDivIDs = new Array();
		allNaviDivIDs[i] = allDls[i].parentNode.id;
		
		allMainDivs[i] = document.getElementById(allNaviDivIDs[i]).parentNode.id;
	}
	
	return allMainDivs;
}
function findMenu(menuID)	// return the menu node, null when not found
{
	var section = document.getElementById(menuID);
	if(!section.hasChildNodes())
		return null;
		
	var menu = null;
	for(var i = 0; i < section.childNodes.length; i++)
	{
		var child = section.childNodes[i];
		if(child.className == "navigation")
		{
			// <dl> is the parent node of all submenus, so it is the menu node
			menu = child.getElementsByTagName("dl")[0];	// there is only one <dl> in each menu
		}
	}
	return menu;
}
function toogleSubMenuState(menuID, subMenuID)
{
	// find menu
	var menu = findMenu(menuID);
	if(!menu)
		return;
	
	// find the submenu and chance his state   	
	var ddElems = menu.getElementsByTagName("dd");	// search all submenus (<dd>'s)
	for(var m = 0; m < ddElems.length; m++)
	{
		if(ddElems[m].id == subMenuID)
		{
			if(ddElems[m].style.display == "none")
			{	// submenu is invisible, so show it
				ddElems[m].style.display = "block";
			}
			else
			{	// submenu is visible, so hide it
				ddElems[m].style.display = "none";
			}
			return;
		}
	}
}
function klapp(dtElement) //toogleSubMenuStateAndHideOthers
{
	menuID = dtElement.parentNode.parentNode.parentNode.id;
	//alert(menuID);
	subMenuClass = dtElement.className + "_menu";
	//subMenuID = dtElement.nextSibling.nextSibling.id;
	//subMenuID = dtElement.lastChild;
	//alert(subMenuID);
	
	// find menu
	var menu = findMenu(menuID);
	if(!menu)
		return;
	
	
	// find the submenu and chance his state and hide all other submenus
	var ddElems = menu.getElementsByTagName("dd");	// search all submenus (<dd>'s)
	for(var m = 0; m < ddElems.length; m++)
	{
		if(ddElems[m].className == subMenuClass)
		{
			// setting "display: none;" in the .css file hide the submenu on the startuptime
			// BUT does set ddElems[m].style.display to "" and not "none", so test for both
			if((ddElems[m].style.display == "none") || (ddElems[m].style.display == ""))
			{	// submenu is invisible, so show it
				ddElems[m].style.display = "block";
			}
			else
			{	// submenu is visible, so hide it
				ddElems[m].style.display = "none";
			}
		}
		else
		{	// hide all other submenus
			ddElems[m].style.display = "none";
		}
	}
	var dstMenus = new Array();
	//alert(getDestinations());
	dstMenus = getDestinations();
	transferMenuState(menuID, dstMenus);
}
function hideAllSubMenus(menuID)
{
	// find menu
	var menu = findMenu(menuID);
	if(!menu)
		return;
	
	// find all submenus and hide all
	var ddElems = menu.getElementsByTagName("dd");	// search all submenus (<dd>'s)
	for(var m = 0; m < ddElems.length; m++)
	{
		ddElems[m].style.display = "none";
	}
}
function transferMenuState(srcMenuID, dstMenuIDs)
{
	// find source menu	
	var srcMenu = findMenu(srcMenuID);
	if(!srcMenu)
		return;
	
	// find destination menu
	
	for(var k = 0; k < dstMenuIDs.length; k++)
	{
		//alert(dstMenuIDs[k]);
		var dstMenu = findMenu(dstMenuIDs[k]);
		if(!dstMenu)
			return;
			
		// copy the states
		var srcDdElems = srcMenu.getElementsByTagName("dd");	// search all source submenus (<dd>'s)
		var dstDdElems = dstMenu.getElementsByTagName("dd");	// search all destination submenus (<dd>'s)
		for(var i = 0; i < srcDdElems.length; i++)	// in source and destination are the same count of elems
		{
			dstDdElems[i].style.display = srcDdElems[i].style.display;
		}
	}
}

