/**
* @author H.-Gerd Rosarius
*/
var subMenuNodes = new Hash();

function selectSubMenuItem(menu, parent, id) {

	if (menu != null) {
		// Remove underline style from all top navigation links
		var menuNode = document.getElementById(menu);		
		if (menuNode != null) {
			var nodeList = menuNode.getElementsByTagName("a");
			for (var i = 0; i < nodeList.length; i++) {
				nodeList[i].style.textDecoration = "none";
			}
		}
	}

	// Set underline style at the top navigation link that was hovered	
	var selectedMainMenuItem = document.getElementById(parent);
	if (selectedMainMenuItem != null) {
		selectedMainMenuItem.style.textDecoration = "underline";
	}

	// In this code section we make sub-menu visible that is related
	// to the chosen top-menu item.

	// Get the <div>-elements for the submenu...
	var divElement = document.getElementById("nav_sub");
	if (divElement == null) {
		alert("ERROR - Layer for submenu not found.");
		return;
	}

	// Get all <ul>-elements, clone them and add them to a hashtable (key=id, value=node's deep clone).
	// We only do this if the hashtable isn't filled already.
	var ulList = divElement.getElementsByTagName("ul");
	if (subMenuNodes.length == 0) {	
		for (var i = 0; i < ulList.length; i++) {
			var ulElement = ulList[i];
			var clonedUlElement = ulElement.cloneNode(true);
			clonedUlElement.style.lineHeight = "16px";
			subMenuNodes.setItem(ulElement.getAttribute("id"), clonedUlElement);
		}
	}

	// Then remove all <ul>-elements from the DOM
	while (ulList.length > 0) {
		divElement.removeChild(ulList[0]);
	}

	// Lookup the selected submenu-item.
	var child = subMenuNodes.getItem(id);
	// If we successfully find it...
	if (child != null) {
		// ... add it to the DOM again and make it visible ...
		divElement.appendChild(child);	
		divElement.style.visibility = "visible";
		child.style.height = "20px";
		child.style.visibility = "visible";
	}	
	else {
		// ... or make the <div>-element for the submenu invisible.
		divElement.style.visibility = "hidden";
	}
}

/**
* Pop-Up für den Pegelstand am Kemnader See
*/
function riverstage(href) {
	newWindow = window.open(href, "Popup", "width=755,height=375,left=100,top=200");
	newWindow.focus();
}

