	/*
	 * SETTINGS
	 */
	var NH_elemMoveStep = 15; /* PX to move for each step during movement */
	var NH_elemMoveDelay = 50; /* mSecs to delay between each step during movement */
	var NH_elemTopMarginOffset = 20; /* PX left always visible of the moving UL */
	var NH_checkMovingAgainDelay = 250; /* mSecs to sleep for status checks */
	var NH_inactiveTop = 120; /* Top-Value for non-active Elements */

	/* global definitions */
	var NH_isIE = document.all?true:false
	var NH_mouseCoordX = 0; /* store mouse X */
	var NH_mouseCoordY = 0; /* store mouse Y */
	var NH_elementStatus = new Array(); /* form: [numeric key] => 	["name"] = id of element
																	["status"] = current status (can be "moving", "opened", "closed" 
																	["child"] = id of list-element to move (contains the notation for top-position
																	["subchild"] = id of UL-Element containing the height of submenu-entries 
																	["subchildheight"] = value of submenu-entry-height*/
	var NH_parentElements = new Array();
	
	// This function checks whether mouse is still inside an element
	function mouseInElement(strElementID, arrayPos)
		{
		positioningElement = document.getElementById(NH_elementStatus[arrayPos]["child"]).offsetParent.id;
		elementHorizontalAreaMin = 	document.getElementById(positioningElement).offsetLeft + 
									document.getElementById(NH_elementStatus[arrayPos]["child"]).offsetLeft + 
									document.body.scrollLeft;
									
		elementVerticalAreaMin = 	document.getElementById(positioningElement).offsetTop + 
									document.getElementById(NH_elementStatus[arrayPos]["child"]).offsetTop +
									document.body.scrollTop;
									
		elementHorizontalAreaMax = 	document.getElementById(positioningElement).offsetLeft + 
									document.getElementById(NH_elementStatus[arrayPos]["child"]).offsetWidth + 
									document.getElementById(NH_elementStatus[arrayPos]["child"]).offsetLeft + 
									document.body.scrollLeft - 2;
									
		elementVerticalAreaMax = 	document.getElementById(positioningElement).offsetTop +
									document.getElementById(NH_elementStatus[arrayPos]["child"]).offsetHeight +
									document.getElementById(NH_elementStatus[arrayPos]["child"]).offsetTop + 
									document.body.scrollTop;
		
		if ((NH_mouseCoordX <= elementHorizontalAreaMin) || (NH_mouseCoordX >= elementHorizontalAreaMax) || (NH_mouseCoordY <= elementVerticalAreaMin) || (NH_mouseCoordY >= elementVerticalAreaMax))
			{
			return false;
			}
		else return true;
		}
	
	
	// Scroll up element by calling itself again and again until the Element has reached its correct position
	function openElement(strElementID, arrayPos)
		{
		NH_elementStatus[arrayPos]["status"] = "moving";
		singleStep = NH_elementStatus[arrayPos]["subchildheight"] / NH_elemMoveStep;
		currentPosition = document.getElementById(NH_elementStatus[arrayPos]["child"]).offsetTop;
		newPos = currentPosition - singleStep;
		document.getElementById(NH_elementStatus[arrayPos]["child"]).style.top = newPos +"Px";
		if (newPos >= (NH_inactiveTop - NH_elementStatus[arrayPos]["subchildheight"]))
			{
			setTimeout("openElement('"+strElementID+"',"+arrayPos+")",NH_elemMoveDelay);
			}
		else 
			{
			document.getElementById(NH_elementStatus[arrayPos]["child"]).style.top = NH_inactiveTop - NH_elementStatus[arrayPos]["subchildheight"] +"Px";
			NH_elementStatus[arrayPos]["status"] = "opened";
			}
		}
		
		
	// Scroll down element by calling itself again and again until the Element has reached its original position	
	function closeElement(strElementID, arrayPos)
		{
		NH_elementStatus[arrayPos]["status"] = "moving";
		singleStep = NH_elementStatus[arrayPos]["subchildheight"] / NH_elemMoveStep;
		currentPosition = document.getElementById(NH_elementStatus[arrayPos]["child"]).offsetTop;
		newPos = currentPosition + singleStep;
		document.getElementById(NH_elementStatus[arrayPos]["child"]).style.top = newPos +"Px";
		if (newPos <= NH_inactiveTop)
			{
			setTimeout("closeElement('"+strElementID+"',"+arrayPos+")",NH_elemMoveDelay);
			}
		else 
			{
			document.getElementById(NH_elementStatus[arrayPos]["child"]).style.top = NH_inactiveTop+"Px";
			NH_elementStatus[arrayPos]["status"] = "closed";
			}
		}	

	// Handle the onmouseover-event
	function mouseOverAction(strElementID)
		{
		// we need to do that in a for-statement since IE even in V8 cant handle "for each"-statements 
		for (intCounter = 0; intCounter < NH_elementStatus.length; intCounter++)
			{
			
			if (NH_elementStatus[intCounter]["child"] == strElementID)
				{
				if (NH_elementStatus[intCounter]["status"] == "closed") openElement(strElementID, intCounter);
				}
			}
		}

	// Handle the onmouseout-event
	function mouseOutAction(strElementID)
		{
		// Again we need to do that in a for-statement
		for (intCounter = 0; intCounter < NH_elementStatus.length; intCounter++)
			{
			
			if (NH_elementStatus[intCounter]["child"] == strElementID)
				{
				if ((NH_elementStatus[intCounter]["status"] == "opened") && (!mouseInElement(strElementID, intCounter))) closeElement(strElementID, intCounter);
				}
			}
		setTimeout("mouseOutAction('"+strElementID+"')",1000);
		}

	/* Auxiliary function to receive data about Mousepositions */
	function NH_getMousePosition(e) {
	    if (NH_isIE) {
			NH_mouseCoordX = event.clientX + document.body.scrollLeft;
			NH_mouseCoordY = event.clientY + document.body.scrollTop;
	    } else {
			NH_mouseCoordX = e.pageX;
			NH_mouseCoordY = e.pageY;
	    }
	    if (NH_mouseCoordX < 0) { NH_mouseCoordX = 0; }
	    if (NH_mouseCoordY < 0) { NH_mouseCoordY = 0; }
	    return true;
	}

	// Function to initialize animation. Reads the reguired element-id and their current status
	function initMenuAnimation(strParentElementID)
		{
		allChilds = document.getElementById(strParentElementID).childNodes;
		// Again a for-statement (did i mention i really dont like IE)
		for (intCounter = 0; intCounter < allChilds.length; intCounter++)
			{
			child = allChilds[intCounter];
			var childDescriptor = ""+child+"";
			var childIsList = childDescriptor.search(/LUList/);
			if (childIsList != -1)
				{
				child.id = "test"+intCounter;
				NH_parentElements.push(child.id);
				}
			}
		// Oh come one, "for" again ...
		for (intCounter = 0; intCounter < NH_parentElements.length; intCounter++)
			{
			NH_elementStatus[intCounter] = new Object();
			NH_elementStatus[intCounter]["name"] = NH_parentElements[intCounter];
			
			children = document.getElementById(NH_parentElements[intCounter]).childNodes;
			// Unbelievable
			for (y=0; y <= children.length; y++)
				{
				childDesc = ""+children[y]+"";
				hasChildren = childDesc.search(/HTMLLI/);
				if (hasChildren != -1) 
					{
					NH_elementStatus[intCounter]["child"] = children[y].id;
					subChilds = document.getElementById(NH_elementStatus[intCounter]["child"]).childNodes;
					// Oh my god ...
					for (z = 0; z < subChilds.length; z++)
						{
						subchildDesc = ""+subChilds[z]+"";
						hasSubChildren = subchildDesc.search(/HTMLUList/);
						if (hasSubChildren != - 1) 
							{
							NH_elementStatus[intCounter]["subchild"] = subChilds[z].id;
							NH_elementStatus[intCounter]["subchildheight"] = document.getElementById(subChilds[z].id).offsetHeight;
							}
						}
					if (document.getElementById(children[y].id).offsetTop != NH_inactiveTop) NH_elementStatus[intCounter]["status"] = "opened";
					else NH_elementStatus[intCounter]["status"] = "closed";
					}
				}
			}
		if (window.addEventListener) 
			{
	    	window.addEventListener('mousemove', NH_getMousePosition, true);
	    	} 
		else 
			{
	    	if (!NH_isIE) 
				{
				document.captureEvents(Event.MOUSEMOVE);
				}
			}
		document.onmousemove = NH_getMousePosition;
		}
		
