﻿function zitemanCheckChildNode(oObject)
{
	var returnValue = false;
	if (typeof(oObject.childNodes[0]) != 'undefined')
		if (oObject.childNodes[0] != null)
			returnValue = true;
	return returnValue;
}


function zitemanMenuGetObject(strMenuID, strObjectID)
{
	var menuopeninframe = eval("menuBehaviour" + strMenuID + "['openinframe']");
	if (window.parent.top.document.getElementsByTagName("FRAMESET").length == 0)
		menuopeninframe = "True";
		
	if(menuopeninframe == "False")
	{
		if (eval("menuBehaviour" + strMenuID + "['targetframe']") == "-1")
		{
			var menuTarget = eval("menuBehaviour" + strMenuID + "['target']");
			var aFrame = zitemanMenuFindTargetFrame(menuTarget);
			eval("menuBehaviour" + strMenuID + "['mainframe'] = '" + aFrame[0] + "';");
			eval("menuBehaviour" + strMenuID + "['targetframe'] = '" + aFrame[1] + "';");
		}
		var strMainFrame = eval("menuBehaviour" + strMenuID + "['mainframe']");
		var strTargetFrame = eval("menuBehaviour" + strMenuID + "['targetframe']");
		if (strMainFrame)
		{
			var oObject = null;
			if (typeof(window.parent.top.frames[strTargetFrame]) != 'undefined')
			{
				try{
					var oObject = window.parent.top.frames[strTargetFrame].document.getElementById(strObjectID);
				} catch(e) {
					var oObject = null;
				}
			}
			if (!oObject)
			{
				try{
				var oObject = window.parent.top.frames[strMainFrame].document.getElementById(strObjectID);
				} catch(e) {
					var oObject = null;
				}
			}
		} else {
			eval("menuBehaviour" + strMenuID + "['openinframe'] = 'True';");
			var oObject = document.getElementById(strObjectID);
		}
	} else {
		var oObject = document.getElementById(strObjectID);
		if (oObject)
		{
			var strParentId = oObject.parentNode.getAttribute("id");
			if (strParentId)
			{
				if (strParentId.indexOf('old') > -1)
				{
					strParentId = strParentId.replace('_old','');
					var oParent = document.getElementById(strParentId);
					for (var x=0; x<oParent.childNodes.length; x++)
					{
						if(oParent.childNodes[x].getAttribute("id") == strObjectID)
							var oObject = oParent.childNodes[x];
					}
				}
			}
		}
		
	}
	return oObject;
}

function zitemanMenuBuildImageRepeat(strRepeat)
{
	var cssRepeat = '';
	if (strRepeat == '' || strRepeat == 'norepeat')
		cssRepeat = 'no-repeat';
	if (strRepeat == 'x')
		cssRepeat = 'repeat-x';
	if (strRepeat == 'y')
		cssRepeat = 'repeat-y';
	if (strRepeat == 'xy')
		cssRepeat = 'repeat';
	return cssRepeat;
}
	
function zitemanMenuBuildImagePosition(strPosition)
{
	var aPosition = strPosition.split('_');
	var hPos = '';
	if (aPosition[0] == '1')
		hPos = 'top';
	if (aPosition[0] == '2')
		hPos = 'center';
	if (aPosition[0] == '3')
		hPos = 'bottom';

	var vPos = '';
	if (aPosition[1] == '1')
		vPos = 'left';
	if (aPosition[1] == '2')
		vPos = 'center';
	if (aPosition[1] == '3')
		vPos = 'right';
			
	return hPos + ' ' + vPos;
}

function zitemanMenuSetProperties(strMenuID, oObject, aList, strSetDirection, strMethod)
{
	var strMenuType = eval("menuBehaviour" + strMenuID + "['menutype']");
	var iIndex = 0;
	if (strMethod == 'normal')
		iIndex = 0;
	else if (strMethod == 'selected')
		iIndex = 1;
	else
		iIndex = 2;
	
	var isOpen = false;	
	var strIsSelected = oObject.getAttribute("isselected");
	
	if ((strIsSelected == 'true') && (strMethod == 'normal'))
		iIndex = 1;
	
	if ((strIsSelected != 'true') && (strMethod == 'normal') && (oObject.getAttribute("status") == 'open'))
		isOpen = true;

	/* safari check */
	if (!oObject.childNodes[0].childNodes[0])
	{
		var oSingleLevel = oObject.children[0];
		var oSetObject = oObject.children[0].children[0];
	} else {
		var oSingleLevel = oObject.childNodes[0];
		var oSetObject = oObject.childNodes[0].childNodes[0];
	}

	/* hent indstillinger for punkt */
	/* BORDER */

	var aBorderSettings = aList[0].split('::');
	if (eval("typeof(menu" + strMenuID + "['" + aBorderSettings[0] + "']['border'])") != 'undefined')
	{
		var strBorder = eval("menu" + strMenuID + "['" + aBorderSettings[0] + "']['border']");
		if (strBorder)
		{
			var aBorder = strBorder.split("::")[iIndex].split(";");

			if (aBorder.length == 2)
			{
				/* kun en indstilling dvs. none */
				oObject.childNodes[0].style.border = aBorder[0].split(":")[1].split("//")[0];
			} else {
				var isCollapse = eval("menuBehaviour" + strMenuID + "['bordercollapse']");
				for (var runBorder=0; runBorder<aBorder.length; runBorder++)
				{
					if (aBorder[runBorder] != '')
					{
						var aSetting = aBorder[runBorder].split("//");
						var aCurrent = aSetting[0].split(':');
						if (isCollapse == "True" && parseInt(aBorderSettings[1]) != 0)
						{
							
							if (strSetDirection == "right")
							{
								
								if (aCurrent[0] == 'border-Left')
								{
									var aTmp = aCurrent[1].split(" ");
									aCurrent[1] = aTmp[1] + ' none ' + aTmp[3];
								}
							} else {
								if (aCurrent[0] == 'border-Top')
								{
									/* 
										check for ASP menu 
										Hvis det er en ASP menu, og den logiske parent til valgt punkt er åben
										så skal menuen stadig have sin top border
									*/
									if (oObject.getAttribute("writecollapseborder") != "true")
									{
										var aTmp = aCurrent[1].split(" ");
										aCurrent[1] = aTmp[1] + ' none ' + aTmp[3];
									}
								}
							}
						}
						eval('oSingleLevel.style.' + aCurrent[0].replace('-','') + ' = "' + aCurrent[1] + '";');
					}
				}
			}
		}	
	}	

	/* BACKGROUND */
	if (eval("typeof(menu" + strMenuID + "['" + aList[1] + "']['background'])") != 'undefined')
	{
		var strBackground = eval("menu" + strMenuID + "['" + aList[1] + "']['background']");
		var aBackground = strBackground.split('::')[iIndex].split(',');
		if (aBackground[0] == '')
		{
			/* slet baggrundsbillede */
			if (oObject.style.backgroundRepeat != '')
			{
				//oObject.style.backgroundAttachment = "";
				oObject.style.backgroundImage = "";
				oObject.style.backgroundPosition = "";
				oObject.style.backgroundPositionX = "";
				oObject.style.backgroundPositionY = "";
				oObject.style.backgroundRepeat = "";
			}
		} else {
			//oObject.style.backgroundAttachment = 'fixed';
			oObject.style.backgroundImage = 'url(' + aBackground[0] + ')';
			oObject.style.backgroundPosition = zitemanMenuBuildImagePosition(aBackground[3]);
			oObject.style.backgroundRepeat = zitemanMenuBuildImageRepeat(aBackground[2]);
			//RESET BACKGROUND TO CORRECT IE7 IMG ERROR
			oObject.style.backgroundColor = '#ffffff';
		}
		oObject.style.backgroundColor = aBackground[1];
	}

	/* MARGIN */
	var iMarginSubWidth = 0;
	var iMarginSubHeight = 0;
	
	/* safari fejl check */
	if (!oSetObject.childNodes[0].childNodes[0].childNodes[1])
	{
		var oAlign = oSetObject.children[0].children[0].children[1];
	} else {
		var oAlign = oSetObject.childNodes[0].childNodes[0].childNodes[1];
	}
	if (eval("typeof(menu" + strMenuID + "['" + aList[2] + "']['margin'])") != 'undefined')
	{
		var strMargin = eval("menu" + strMenuID + "['" + aList[2] + "']['margin']");
		if (typeof(strMargin) != 'undefined')
		{
			var aMargin = strMargin.split('::')[iIndex].split(',');

			if (parseInt(aMargin[0]))
				iMarginSubWidth -= parseInt(aMargin[0]);
			if (parseInt(aMargin[1]))
				iMarginSubWidth -= parseInt(aMargin[1]);
			if (parseInt(aMargin[2]))
				iMarginSubHeight -= parseInt(aMargin[2]);
			if (parseInt(aMargin[3]))
				iMarginSubHeight -= parseInt(aMargin[3]);
							
			oSetObject.style.marginLeft = aMargin[0];
			oSetObject.style.marginRight = aMargin[1];
			oSetObject.style.marginTop = aMargin[2];
			oSetObject.style.marginBottom = aMargin[3];

			oAlign.align = aMargin[4];
			oAlign.vAlign = aMargin[5];
		}
	}

	/* GRAPHICS */
	var showIndication = true;
	if (aList[4] != '')
	{
		if (eval("typeof(menu" + strMenuID + "['" + aList[4] + "'])") != 'undefined')
		{
			var strGraphics = eval("menu" + strMenuID + "['" + aList[4] + "']['graphics']");
			if (typeof(strGraphics) != 'undefined')
			{
				var strGraphics = strGraphics.split('::')[iIndex];
				if (strGraphics != 'none' && strGraphics != '')
					showIndication = false;
				if (strGraphics != 'none')
				{
					if (strMenuType == 'DHTML')
					{
						/* safari check*/
						if (!oSetObject.childNodes[0].childNodes[0].childNodes[1])
						{
							var oLink = oSetObject.children[0].children[0].children[1];
						} else {
							var oLink = oSetObject.childNodes[0].childNodes[0].childNodes[1];
						}
					} else {
						if (!oSetObject.childNodes[0].childNodes[0].childNodes[1].childNodes[0])
						{
							var oLink = oSetObject.children[0].children[0].children[1].children[0];
						} else {
							var oLink = oSetObject.childNodes[0].childNodes[0].childNodes[1].childNodes[0];
						}
						
					}
					/* opdater grafik visning */
					if (strGraphics != '')
					{
						var found = false;
						if (oLink.childNodes.length > 0)
						{
							if (oLink.childNodes[0].tagName == 'IMG')
							{
								if (oLink.childNodes[0].src != strGraphics)
								{
									oLink.childNodes[0].src = strGraphics;
									found = true;
								}
							}
						}
						if (!found)
						{
							oLink.innerHTML = '<img border="0" src="' + strGraphics + '">';
						}
					} else {
						if (oLink.innerHTML != oObject.className)
							oLink.innerHTML = oObject.className;
					}
				}
			}
		}
	}

	/* INDICATION */
	if (eval("typeof(menu" + strMenuID + "['" + aList[3] + "']['indication'])") != 'undefined')
	{
		var strIndication = eval("menu" + strMenuID + "['" + aList[3] + "']['indication']");
		var marginIndex = iIndex;
		if (isOpen)
			marginIndex = 3;
		var aIndication = strIndication.split('::')[marginIndex].split(',');

		/* safari check*/
		if (!oSetObject.childNodes[0].childNodes[0].childNodes[0])
		{
			var oIndicationLeft = oSetObject.children[0].children[0].children[0];
			var oIndicationRight = oSetObject.children[0].children[0].children[2];
		} else {
			var oIndicationLeft = oSetObject.childNodes[0].childNodes[0].childNodes[0];
			var oIndicationRight = oSetObject.childNodes[0].childNodes[0].childNodes[2];
		}

		if (showIndication)
		{
			if (aIndication[0] == '' && zitemanCheckChildNode(oIndicationLeft))
				oIndicationLeft.innerHTML = '';
			if (aIndication[0] != '' && zitemanCheckChildNode(oIndicationLeft))
			{
				/* safari check */
				var oImg = oIndicationLeft.childNodes[0];
				if (oImg)
				{
					oImg.src = aIndication[0];
					oImg.hspace = aIndication[1];
					oImg.vspace = aIndication[2];
				}
			}
			if (aIndication[0] != '' && zitemanCheckChildNode(oIndicationLeft) == false)
				oIndicationLeft.innerHTML = '<img src="' + aIndication[0] + '" hSpace="' + aIndication[1] + '" vSpace="' + aIndication[2] + '" border="0" />';

			if (aIndication[3] == '' && zitemanCheckChildNode(oIndicationRight))
				oIndicationLeft.innerHTML = '';
			if (aIndication[3] != '' && zitemanCheckChildNode(oIndicationRight))
			{
				var oImg = oIndicationRight.childNodes[0];
				if (oImg)
				{
					oImg.src = aIndication[3];
					oImg.hspace = aIndication[4];
					oImg.vspace = aIndication[5];
				}
			}
			if (aIndication[3] != '' && zitemanCheckChildNode(oIndicationRight) == false)
				oIndicationRight.innerHTML = '<img src="' + aIndication[3] + '" hSpace="' + aIndication[4] + '" vSpace="' + aIndication[5] + '" border="0" />';
		} else {
			if (zitemanCheckChildNode(oIndicationLeft))
				oIndicationLeft.innerHTML = '';
			if (zitemanCheckChildNode(oIndicationRight))
				oIndicationRight.innerHTML = '';
		}
	}

	/* DIMENSION */
	if (eval("typeof(menu" + strMenuID + "['" + aList[5] + "']['dimension'])") != 'undefined')
	{
		var strDimension = eval("menu" + strMenuID + "['" + aList[5] + "']['dimension']");
		var aDimensions = strDimension.split('::')[iIndex].split(',');
		if (aDimensions[0] == 'false')
		{
			var zitemanHeight = parseInt(aDimensions[2]);
			var zitemanWidth = parseInt(aDimensions[1]);
			
			/* check border collapse */
			var strCollapse = eval("menuBehaviour" + strMenuID + "['bordercollapse']");
			var iAddHeight = 0;
			var iAddWidth = 0;
			if (strCollapse == "True")
			{
				var strBorder = null;
				if (strSetDirection == 'right' && oObject.parentNode.offsetLeft == 0)
				{
					strBorder = oSingleLevel.style.borderRight;
				}
				if (strSetDirection == 'down' && oObject.offsetTop == 0)
				{
					strBorder = oSingleLevel.style.borderBottom;
				}
				if (strBorder)
				{
					var aAdd = strBorder.split("px")[0].split(" ");
					if (strSetDirection == "down")
					{
						iAddHeight = parseInt(aAdd[aAdd.length-1]);
					} else {
						iAddWidth = parseInt(aAdd[aAdd.length-1]);
					}
				}
			}
			zitemanWidth += iAddWidth;
			zitemanHeight += iAddHeight;
			
			if (parseInt(zitemanWidth) != parseInt(oObject.style.width))
			{
				oObject.style.width = zitemanWidth;
				oSingleLevel.style.width = zitemanWidth;
				oSetObject.width = zitemanWidth + iMarginSubWidth;
			}
			if (parseInt(zitemanHeight) != parseInt(oObject.style.height))
			{
				oObject.style.height = zitemanHeight;
				oSingleLevel.style.height = zitemanHeight;
				oSetObject.height = zitemanHeight + iMarginSubHeight;
			}
			
		}
	}

	/* link klasse */
	if (strMenuType == 'DHTML')
	{
		/* aParam 8 = text */
		if (eval("typeof(menu" + strMenuID + "['" + aList[9] + "']['text'])") != 'undefined')
		{
			var strTextList = eval("menu" + strMenuID + "['" + aList[9] + "']['text']");
			var aText = strTextList.split('::')[iIndex].split(',');
		
			/* safari check */
			if (!oSetObject.childNodes[0].childNodes[0].childNodes[1])
			{
				var oTd = oSetObject.children[0].children[0].children[1];
			} else {
				var oTd = oSetObject.childNodes[0].childNodes[0].childNodes[1];
			}
			if (oTd.style.fontFamily != aText[0])
				oTd.style.fontFamily = aText[0];

			if (oTd.style.fontSize != aText[1])
				oTd.style.fontSize = aText[1];

			if (oTd.style.color != aText[2])
				oTd.style.color = aText[2];

			var strFontWeight = aText[3];
			if (strFontWeight == 'selected')
				strFontWeight = 'normal';
					
			var strFontStyle = aText[4];
			if (strFontStyle == 'selected')
				strFontStyle = 'normal';
				
			if (oTd.style.fontWeight != strFontWeight)
				oTd.style.fontWeight = strFontWeight;

			if (oTd.style.fontStyle != strFontStyle)
				oTd.style.fontStyle = strFontStyle;
		
			var aTextDecoration = aText[5].split(' ');
			var setString = aTextDecoration[0];
			if (aTextDecoration[1] != '')
				setString += ' ' + aTextDecoration[1];
			if (aTextDecoration[2] != '')
				setString += ' ' + aTextDecoration[2];
			if (oTd.style.textDecoration != setString)
				oTd.style.textDecoration = setString;
		}			
	} else {
		var strClassName = oSingleLevel.className;
		if (oObject.getAttribute("isselected") == 'true' || strMethod == 'selected')
		{
			if (strClassName.indexOf("selected") == -1)
				strClassName += 'selected';
				
			if (oSingleLevel.className != strClassName)
				oSingleLevel.className = strClassName;
			
			if (typeof(oObject.setActive) == 'string')
			{
				oObject.setActive();
			} else {
				try{
					oObject.setActive();
				} catch(e){
				}
			}
		} else {
			if (strClassName.indexOf("selected") > -1)
				strClassName = strClassName.replace('selected','');
			if (oSingleLevel.className != strClassName)
				oSingleLevel.className = strClassName;
		}
	}
	return true;
}

/* Methoder til DHTML funktionallitet */
function zitemanMenuOpenMenu(strMenuID, strObjectID, strSetDirection, oObject, bIsSub)
{
	if (iPageContext == 1 || iPageContext == 7)
	{
		/* Hent behaviours for nuværende menu */
		var menutype = eval("menuBehaviour" + strMenuID + "['menutype']");
		if (menutype == "DHTML")
		{
			zitemanMenuPlaceDiv(strMenuID, strObjectID, strSetDirection, oObject, bIsSub);
		} else {
			eval("menuBehaviour" + strMenuID + "['currentSplitID'] = '" + strObjectID + "';");
			
			// sæt select status
			zitemanMenuSelectItem(strMenuID, strObjectID, strSetDirection);
			// check split
			var aspBehaviour = eval("menuBehaviour" + strMenuID + "['aspbehaviour'];");
			if (aspBehaviour == 'open_one')
			{
				zitemanMenuCloseAll(strMenuID, strMenuID + strObjectID);
			} else {
				zitemanMenuAddMenu(strMenuID, strMenuID + strObjectID);
			}
			zitemanMenuSetOpenStatus(strMenuID);
			zitemanMenuRunMenu(strMenuID, eval("menuBehaviour" + strMenuID + "['currentshow'];"), 'block', true);
			zitemanMenuShowAllSplit(strMenuID, strObjectID);
			if (typeof(zitemanUpdateMenuParams) != 'undefined')
				zitemanUpdateMenuParams();
		}
	}
	return;
}

function zitemanMenuSetOpenStatus(strMenuID)
{
	var currentList = eval("menuBehaviour" + strMenuID + "['currentshow'];");
	if (currentList != '')
	{
		var aList = currentList.split(',');
		for (var runList=0; runList<aList.length - 1; runList++)
		{
			var oChildObject = document.getElementById(aList[runList] + '_child');
			if (oChildObject)
			{
				if (oChildObject.style.display == 'block')
				{
					/* sæt "open" status på parent object */
					var oParent = document.getElementById(aList[runList]);
					oParent.setAttribute("status", "open");
				}
			}
					
		}
	}
	return;
}
		
function zitemanMenuMouseover(strMenuID, strObjectID, strSetDirection)
{
	if (iPageContext == 1 || iPageContext == 7)
	{
		/* Find indstillinger for punkt */
		var strList = eval("menuobject" + strMenuID + "['" + strObjectID + "']");
		if (strList != '')
		{
			var aList = strList.split(",");
			var oObject = zitemanMenuGetObject(strMenuID, strMenuID + strObjectID);
			if (oObject)
			{
				var runUpdate = true;
				//Check fra til context
				try{
					var oToElement = event.fromElement;
					if (oToElement.tagName == 'TD')
						oToElement = zitemanMenuGetPrevDiv(oToElement);
					if (oToElement.tagName == 'A')
						oToElement = zitemanMenuGetPrevDiv(oToElement);
					if (oToElement.getAttribute("id") == '')
						oToElement = zitemanMenuGetPrevDiv(oToElement);
						
					if (oToElement.id == oObject.id)
						runUpdate = false;
				} catch(e) {
					runUpdate = true;
				}

				if (runUpdate)
				{
					zitemanMenuSetProperties(strMenuID, oObject, aList, strSetDirection, "mouseover");
				}
			}
		}
	}
	return;
}

function zitemanMenuMouseout(strMenuID, strObjectID, strSetDirection)
{
	if (iPageContext == 1 || iPageContext == 7)
	{
		/* Find indstillinger for punkt */
		var strList = eval("menuobject" + strMenuID + "['" + strObjectID + "']");
		if (strList != '')
		{
			var aList = strList.split(",");
			var oObject = zitemanMenuGetObject(strMenuID, strMenuID + strObjectID);
			if (oObject)
			{
				var runUpdate = true;
				//Check fra til context
				try{
					var oToElement = event.toElement;
					if (oToElement.tagName == 'TD')
						oToElement = zitemanMenuGetPrevDiv(oToElement);
					if (oToElement.tagName == 'A')
						oToElement = zitemanMenuGetPrevDiv(oToElement);
					if (oToElement.getAttribute("id") == '')
						oToElement = zitemanMenuGetPrevDiv(oToElement);
					
					if (oToElement.id == oObject.id)
					{
						runUpdate = false;
					}
				} catch(e) {
					runUpdate = true;
				}

				if (runUpdate)
				{
					zitemanMenuSetProperties(strMenuID, oObject, aList, strSetDirection, "normal");
				}
			}
		}
	}
	return;
}

function zitemanMenuHideMenu(strMenuID, menuID)
{
	var oObject = zitemanMenuGetObject(strMenuID, menuID + 'sub');
	if (oObject)
	{
		/* skjul alle dropareas */
		/* Check for IE funktionallitet */
		var bIsIE = false;
		if (typeof(oObject.getBoundingClientRect) != 'undefined')
		{
			bIsIE = true;
		}
		if (bIsIE)
		{
			var menuopeninframe = eval("menuBehaviour" + strMenuID + "['openinframe']");
			if (menuopeninframe == 'False')
			{
				var strTargetFrame = eval("menuBehaviour" + strMenuID + "['targetframe']");
				var aDropareas = window.parent.top.frames[strTargetFrame].document.getElementsByTagName("SELECT");
			} else {
				var aDropareas = document.getElementsByTagName("SELECT");
			}

			for (var runDrop=0; runDrop<aDropareas.length; runDrop++)
			{
				if (aDropareas[runDrop].style.visibility == 'hidden')
				{
					if (aDropareas[runDrop].getAttribute("disableById"))
					{
						var aId = aDropareas[runDrop].getAttribute("disableById").split(',');
						var strNewList = '';
						for (var iRun=0; iRun<aId.length - 1; iRun++)
						{
							if ((aId[iRun] != menuID) && (aId[iRun] != menuID + 'sub'))
							{
								strNewList += aId[iRun] +',';
							}
						}
						
						if (strNewList != '')
						{
							aDropareas[runDrop].setAttribute("disableById", strNewList);
						} else {
							aDropareas[runDrop].style.visibility = 'visible';
							aDropareas[runDrop].removeAttribute("disableById");
						}
					} else {
						aDropareas[runDrop].style.visibility = 'visible';
					}
				}
			}
		}
		oObject.style.display = 'none';
	}
	return;
}

var closeMenu = false;

function zitemanMenuCheckCurrentShow(strMenuID, objectID)
{
	var currentShow = eval('menuBehaviour' + strMenuID + '["currentshow"];');
	var myCurrentShow = currentShow;
	if (myCurrentShow != '')
	{	
		var newShow = '';
		var parentID = 'test';
		var runObjectID = objectID;
		if (runObjectID != '') 
		{
			while(parentID)
			{
				var oObject = zitemanMenuGetObject(strMenuID, runObjectID);
				var oParent = zitemanMenuGetPrevDiv(oObject);
				var parentID = null;
				if (oParent.getAttribute("id") && oParent.getAttribute("id").indexOf("sub") > 0)
					var parentID = oParent.getAttribute("id").split("sub")[0];
				
				newShow = runObjectID + ':' + newShow;
				if (parentID)
				{
					runObjectID = parentID;
				}
			}
		}
		var aCurrentShow = myCurrentShow.split(':');
		var aNewShow = newShow.split(':');
		for (var x=0; x<aCurrentShow.length-1; x++)
		{
			var found = false;
			for (var y=0; y<aNewShow.length-1; y++)
			{
				if (aNewShow[y] == aCurrentShow[x])
					found = true;
			}
			if (!found)
			{
				currentDirection = '';
				zitemanMenuReRun = 0;
				zitemanMenuHideMenu(strMenuID, aCurrentShow[x]);
			}
		}
		myCurrentShow = newShow;
		currentShow = newShow;
	} else {
		currentDirection = '';
		zitemanMenuReRun = 0;
		currentShow = objectID + ':';
	}
	
	if (currentShow == '')
	{
		var menuopeninframe = eval("menuBehaviour" + strMenuID + "['openinframe']");
		if (window.parent.top.document.getElementsByTagName("FRAMESET").length == 0)
			menuopeninframe = "True";
		
		if(menuopeninframe == "False")
		{
			var strTargetFrame = eval("menuBehaviour" + strMenuID + "['targetframe']");
			try {
				var aDropareas = window.parent.top.frames[strTargetFrame].document.getElementsByTagName("SELECT");
			} catch(e) {
				var aDropareas = new Array();
			}
		} else {
			var aDropareas = document.getElementsByTagName("SELECT");
		}
		
		for (var runDrop=0; runDrop<aDropareas.length; runDrop++)
		{
			aDropareas[runDrop].style.visibility = 'visible';
			aDropareas[runDrop].removeAttribute("disableById");
		}
	}
	eval('menuBehaviour' + strMenuID + '["currentshow"] = "' + currentShow + '"');
	return;
}
		
function zitemanMenuNoClose(strMenuID)
{
	eval('menuBehaviour' + strMenuID + '["checkclose"] = "0";');
	return;
}

function zitemanMenucheckClose(strMenuID)
{
	eval('menuBehaviour' + strMenuID + '["checkclose"] = "1";');
	setTimeout("zitemanMenuReCheckClose('" + strMenuID + "')", 1000);
	return;
}

function zitemanMenuReCheckClose(strMenuID)
{
	if (eval('menuBehaviour' + strMenuID + '["checkclose"]') == '1')
	{
		zitemanMenuCheckCurrentShow(strMenuID, '');
	}
	return;
}

function zitemanMenuAppendDiv(strHtml)
{
	var oDiv = document.createElement("DIV");
	oDiv.innerHTML = strHtml;
	var returnValue = false;
	
	try{
		returnValue = true;
		document.body.appendChild(oDiv);
	} catch(e) {
		returnValue = false;
	}
	return returnValue;
}

var strUserAgent = navigator.userAgent;
function zitemanMenuAppendStyles(strStyles)
{
	var run = true;
	if ((strUserAgent.indexOf("MSIE") > -1 && strUserAgent.indexOf("Mac") > -1))
		run = false;
	if ((strUserAgent.indexOf("Safari") == -1) && (run))
	{
		document.body.innerHTML += "<style>" + strStyles + "</style>";
	}
	return;
}


var zitemanMenuReRun = 0;
function zitemanMenuPlaceDiv(strMenuID, strObjectID, strSetDirection, oObject, bIsSub)
{
	/* hvor skal vi åbne menuen */
	var menuopeninframe = eval("menuBehaviour" + strMenuID + "['openinframe']");
	if (window.parent.top.document.getElementsByTagName("FRAMESET").length == 0)
		menuopeninframe = "True";

	var menuTarget = eval("menuBehaviour" + strMenuID + "['target']");
	if (menuopeninframe == 'False' && !bIsSub)
	{
		if (eval("menuBehaviour" + strMenuID + "['targetframe']") == "-1")
		{
			var aFrame = zitemanMenuFindTargetFrame(menuTarget);
			eval("menuBehaviour" + strMenuID + "['mainframe'] = '" + aFrame[0] + "';");
			eval("menuBehaviour" + strMenuID + "['targetframe'] = '" + aFrame[1] + "';");
		}
		/* check target frame */
		var strTargetFrame = eval("menuBehaviour" + strMenuID + "['targetframe']");
		if (typeof(window.parent.top.frames[strTargetFrame]) == 'undefined')
		{
			return false;
		}
	}

	if (menuopeninframe == 'False')
	{
		var strMainFrame = eval("menuBehaviour" + strMenuID + "['mainframe']");
		var strTargetFrame = eval("menuBehaviour" + strMenuID + "['targetframe']");
		var oSubObject = null;
		/* check om sub menu ligger i Target frame */
		if (strMainFrame != null)
		{
			/* CHECK FRAME STATUS */
			if (typeof(window.parent.top.frames[strTargetFrame]) != 'undefined')
			{
				try{
					if (typeof(window.parent.top.frames[strTargetFrame].document.readyState) != 'undefined')
					{
						if (window.parent.top.frames[strTargetFrame].document.readyState != 'complete')
							return false;
					}
				} catch(e) {
					// Ved fejl i readyState, skal vi retunere
					return false;
				}
			}

			if (bIsSub)
			{
				try{
					var oObject = window.parent.top.frames[strTargetFrame].document.getElementById(oObject.getAttribute("id"));
				} catch(e) {
					var oObject = null;
				}
			}

			try{
				var oSubObject = window.parent.top.frames[strTargetFrame].document.getElementById(oObject.getAttribute("id") + 'sub');
			} catch(e) {
				var oSubObject = null;
			}
		} else {
			eval("menuBehaviour" + strMenuID + "['openinframe'] = 'True';");
			try{
				var oSubObject = document.getElementById(oObject.getAttribute("id") + 'sub');
			} catch(e) {
				var oSubObject = null;
			}
		}

		if (!oSubObject)
		{
			// kopier subobject til target frame
			var oCopyObject = window.parent.top.frames[strMainFrame].document.getElementById(oObject.getAttribute("id") + 'sub');
			if (oCopyObject)
			{
				var oDiv = document.createElement("DIV");
				oDiv.appendChild(oCopyObject.cloneNode(true));

				try {
					var bIsValid = window.parent.top.frames[strTargetFrame].zitemanMenuAppendDiv(oDiv.innerHTML);
				} catch(e) {
					var bIsValid = false;
				}
				if (bIsValid)
				{
					var oSubObject = window.parent.top.frames[strTargetFrame].document.getElementById(oObject.getAttribute("id") + 'sub');
					if (bIsSub)
					{
						var oObject = window.parent.top.frames[strTargetFrame].document.getElementById(oObject.getAttribute("id"));
					}
					oSubObject.style.display = 'block';
					oSubObject.style.display = 'none';
				}
				
			}
		}
	} else {
		/* flyt sub object */
		var oSubObject = document.getElementById(oObject.getAttribute("id") + 'sub');
		if (oSubObject)
		{
			
			if (oSubObject.parentNode.tagName != 'BODY' && oSubObject.childNodes.length != 0)
			{
				var oParent = oSubObject.parentNode;
				
				var oDiv = document.createElement("DIV");
				oDiv.appendChild(oSubObject.cloneNode(true));
				oDiv.childNodes[0].setAttribute("id", oSubObject.getAttribute("id") + "_old");
				oParent.appendChild(oDiv.childNodes[0]);
				
				document.body.appendChild(oSubObject);
			}
			var oSubObject = document.getElementById(oObject.getAttribute("id") + 'sub');

			if (oSubObject.childNodes.length == 0)
				oSubObject = null;
		} 
	}

	zitemanMenuCheckCurrentShow(strMenuID, oObject.getAttribute("id"));
	var oMenuBoks = null;

	if (oSubObject)
	{
		if (!bIsSub)
		{
			var aOpen = eval("menuBehaviour" + strMenuID + "['sublevel1'];").split(',');
		} else {
			var aOpen = eval("menuBehaviour" + strMenuID + "['sublevel2'];").split(',');
		}
		var openMarginLeft = parseInt(aOpen[0]);
		var openMarginTop = parseInt(aOpen[1]);

		if (menuopeninframe == 'False')
		{
			var aSize = zitemanMenuGetFrameHeightWidth(window.parent.top.frames[strTargetFrame]);
			var aScroll = zitemanMenuGetFrameScroll(window.parent.top.frames[strMainFrame]);
			var aScroll1 = zitemanMenuGetFrameScroll(window.parent.top.frames[strTargetFrame]);
			var childScrollLeft = aScroll1[0];
			var childScrollTop = aScroll1[1];
			var myClientWidth = aSize[0] + childScrollLeft;
			var myClientHeight = aSize[1] + childScrollTop;
			var parentScrollLeft = aScroll[0];
			var parentScrollTop = aScroll[1];
			
		} else {
			var aSize = zitemanMenuGetFrameHeightWidth(self);
			var aScroll1 = zitemanMenuGetFrameScroll(self);
			var childScrollLeft = aScroll1[0];
			var childScrollTop = aScroll1[1];
			var myClientWidth = aSize[0] + childScrollLeft;
			var myClientHeight = aSize[1] + childScrollTop;
			var parentScrollLeft = 0;
			var parentScrollTop = 0;
		}

		var baseDirection = eval("menuBehaviour" + strMenuID + "['subdirection1'];");
		if (bIsSub)
		{
			var checkDirection = eval("menuBehaviour" + strMenuID + "['subdirection2'];");
			var myParent = zitemanMenuGetPrevDiv(oObject);
			if (myParent.getAttribute("mydirection"))
			{
				var strTmp = myParent.getAttribute("mydirection");
				var isValid = false;
				if (checkDirection == 'down' || checkDirection == 'up')
				{
					if (strTmp == 'down' || strTmp == 'up')
						isValid = true;
					
				} else {
					if (strTmp == 'left' || strTmp == 'right')
						isValid = true;
				}
				if (isValid)
				{
					checkDirection = myParent.getAttribute("mydirection");
				}
			}

		} else {
			var checkDirection = eval("menuBehaviour" + strMenuID + "['subdirection1'];");
			if (zitemanMenuReRun == 0)
				currentDirection = '';
		}
					
		if (currentDirection != '')
			checkDirection = currentDirection;
		
		/* check for MENU boks */
		
		/* hent menuobject */
		var oMenuObject = zitemanMenuGetPrevDiv(oObject);
		var addBoksTop = 0;
		var addBoksLeft = 0;
		if (zitemanMenuGetPrevDiv(oMenuObject))
		{
			var iFrameSet = window.parent.top.document.getElementsByTagName("FRAMESET").length;

			oMenuBoks = zitemanMenuGetPrevDiv(oMenuObject);
			var oTmp = oMenuBoks;

			while (oTmp)
			{
				if (oTmp.tagName != 'TR' && oTmp.tagName != 'TBODY')
				{
				if (iFrameSet != 0)
					addBoksTop += oTmp.offsetTop;
				addBoksLeft += oTmp.offsetLeft;
				}
				oTmp = oTmp.offsetParent;
			}
			if (iFrameSet == 0 || typeof(oMenuBoks.getClientRects) == 'undefined')
				addBoksTop = oMenuBoks.offsetTop;
			//addBoksLeft = oMenuBoks.offsetLeft;
			//Hent scroll
			addBoksLeft -= parseInt(oMenuBoks.scrollLeft);
			addBoksTop -= parseInt(oMenuBoks.scrollTop);
		}
		var menuScrollLeft = oMenuObject.scrollLeft;
		var menuScrollTop = oMenuObject.scrollTop;
		var menuLeftPos = 0;
		var menuTopPos = oMenuObject.offsetTop;
		
		if (menuopeninframe == 'False' && !bIsSub)
		{
			menuLeftPos += childScrollLeft;
			menuTopPos += childScrollTop;
			if (checkDirection == 'down' || checkDirection == 'up')
			{
				menuTopPos = childScrollTop;
				menuLeftPos -= parentScrollLeft;
				menuLeftPos += addBoksLeft;
				if (checkDirection == 'up')
				{
					menuTopPos += myClientHeight;
				}
			}
			if (checkDirection == 'right' || checkDirection == 'left')
			{
				menuLeftPos = childScrollLeft;
				menuTopPos -= parentScrollTop;
				menuTopPos += addBoksTop;
			}
		} else {
			/* GET MENU BOKS OFFSET */
			if (oMenuBoks)
			{
    			if (parseInt(oMenuBoks.style.paddingLeft) && !bIsSub)
	    		{
		    		menuLeftPos = parseInt(oMenuBoks.style.paddingLeft);
			    }
			}
		}
		var hasCheckedMenu = false;
		if (menuopeninframe != 'False')
		{
			hasCheckedMenu = true;
			menuLeftPos += addBoksLeft;
			menuTopPos += addBoksTop;
		}
		if (typeof(oMenuObject.offsetTop) == 'undefined')
		{
			zitemanMenuOpenMenu(strMenuID, strObjectID, strSetDirection, oObject, bIsSub);
			return false;
		}

		
		var oParent = zitemanMenuGetBase(oObject);
		if (!oParent)
		{
			var oParent = oObject;
			if (oParent.parentNode && bIsSub)
				oParent = oParent.parentNode;
			
		}
		
		if (menuopeninframe == 'False' && !bIsSub)
		{
			var parentLeftPos = oParent.offsetLeft;
			if (oParent.parentNode.parentNode.parentNode.parentNode)
			{
				parentLeftPos += oParent.parentNode.parentNode.parentNode.parentNode.offsetLeft;
			}
			var parentTopPos = oParent.offsetTop;
			var parentHeight = 0;
			var	parentWidth = 0;
		} else {
			var parentLeftPos = oParent.offsetLeft;
			var parentTopPos = oObject.offsetTop;
			var parentHeight = oObject.offsetHeight;
			var	parentWidth = oObject.offsetWidth;
			var iFrameSet = window.parent.top.document.getElementsByTagName("FRAMESET").length;
			if (iFrameSet == 0)
			{
				//Get pagebody offset position
				var addOffsetLeft = 0;
				var addOffsetTop = 0;
				if (!bIsSub)
				{
					var oMenuParent = zitemanMenuGetPrevDiv(zitemanMenuGetPrevDiv(oMenuBoks));
					if (oMenuParent)
					{
						while (oMenuParent)
						{
							if (oMenuParent.tagName != 'TR' && oMenuParent.tagName != 'TBODY')
							{
								addOffsetTop += oMenuParent.offsetTop;
								addOffsetLeft += oMenuParent.offsetLeft;
							}
							oMenuParent = oMenuParent.offsetParent;
						}
					}
					if (hasCheckedMenu)
					{
						//check for overflow auto
						var oMenuParent = zitemanMenuGetPrevDiv(zitemanMenuGetPrevDiv(oMenuBoks));
						if (oMenuParent)
						{
							if (oMenuParent.style.overflow == 'auto')
							{
								//parentTopPos += addOffsetTop;
								//parentLeftPos += addOffsetLeft;
							}
						}
					}
					if (!hasCheckedMenu)
					{
						//parentTopPos += addOffsetTop;
						//parentLeftPos += addOffsetLeft;
					}
				}
			}
		}
		
		//if (menuopeninframe == 'False')
			oSubObject.style.display = 'block';
			
		var subWidth = oSubObject.offsetWidth;
		var subHeight = oSubObject.offsetHeight;

		//if (menuopeninframe == 'False')
			oSubObject.style.display = 'none';

		var calcLeft = 0;
		var calcTop = 0;
		
		/* check for border collapse */
		var iCollapseBorderTop = 0;
		var iCollapseBorderBottom = 0;
		var iCollapseBorderLeft = 0;
		var iCollapseBorderRight = 0;
		var iCollapseWithBorderTop = 0;
		var iCollapseWithBorderBottom = 0;
		var iCollapseWithBorderLeft = 0;
		var iCollapseWithBorderRight = 0;

		var isCollapse = eval("menuBehaviour" + strMenuID + "['bordercollapse']");
		if (isCollapse == "True")
		{
			/* Hardcode index til mouseover effekt */
			var iIndex = 2;
			/* Find indstillinger for punkt */
			var strList = eval("menuobject" + strMenuID + "['" + strObjectID + "']");
			if (strList != '')
			{
				var aList = strList.split(",");
				var aBorderSettings = aList[0].split('::');
				var strBorder = eval("menu" + strMenuID + "['" + aBorderSettings[0] + "']['border']");
				if (strBorder)
				{
					var aBorder = strBorder.split("::")[iIndex].split(";");
					if (aBorder.length != 2)
					{
						if (typeof(oObject.childNodes[0].style) == 'undefined')
						{
							var oSingleLevel = oObject.children[0];
						} else {
							var oSingleLevel = oObject.childNodes[0];
						}
						
						var aBorderLeft = new Array();
						aBorderLeft[0] = oSingleLevel.style.borderLeftColor;
						aBorderLeft[1] = oSingleLevel.style.borderLeftWidth;
						aBorderLeft[2] = oSingleLevel.style.borderLeftStyle;
						if (aBorder[0].split(':')[1].split('//')[0].split(' ')[2].toLowerCase() != 'none')
						{
							var bSetBorder = true;
							if (aBorderLeft.length == 3)
								if (aBorderLeft[2].toLowerCase() != 'none')
									bSetBorder = false;
							if (bSetBorder)
								iCollapseBorderLeft = parseInt(aBorderLeft[1].replace('px',''));
							else
								iCollapseWithBorderLeft = parseInt(aBorderLeft[1].replace('px',''));
						}
						var aBorderRight = new Array();
						aBorderRight[0] = oSingleLevel.style.borderRightColor;
						aBorderRight[1] = oSingleLevel.style.borderRightWidth;
						aBorderRight[2] = oSingleLevel.style.borderRightStyle;
						if (aBorder[1].split(':')[1].split('//')[0].split(' ')[2].toLowerCase() != 'none')
						{
							var bSetBorder = true;
							if (aBorderRight.length == 3)
								if (aBorderRight[2].toLowerCase() != 'none')
									bSetBorder = false;
							if (bSetBorder)
								iCollapseBorderRight = parseInt(aBorderRight[1].replace('px',''));
							else
								iCollapseWithBorderRight = parseInt(aBorderRight[1].replace('px',''));
						}
						var aBorderTop = new Array();
						aBorderTop[0] = oSingleLevel.style.borderTopColor;
						aBorderTop[1] = oSingleLevel.style.borderTopWidth;
						aBorderTop[2] = oSingleLevel.style.borderTopStyle;
						if (aBorder[2].split(':')[1].split('//')[0].split(' ')[2].toLowerCase() != 'none')
						{
							var bSetBorder = true;
							if (aBorderTop.length == 3)
								if (aBorderTop[2].toLowerCase() != 'none')
									bSetBorder = false;
							if (bSetBorder)
								iCollapseBorderTop = parseInt(aBorderTop[1].replace('px',''));
							else
								iCollapseWithBorderTop = parseInt(aBorderTop[1].replace('px',''));
						}
						var aBorderBottom = new Array();
						aBorderBottom[0] = oSingleLevel.style.borderBottomColor;
						aBorderBottom[1] = oSingleLevel.style.borderBottomWidth;
						aBorderBottom[2] = oSingleLevel.style.borderBottomStyle;
						if (aBorder[3].split(':')[1].split('//')[0].split(' ')[2].toLowerCase() != 'none')
						{
							var bSetBorder = true;
							if (aBorderBottom.length == 3)
								if (aBorderBottom[2].toLowerCase() != 'none')
									bSetBorder = false;
							if (bSetBorder)
								iCollapseBorderBottom = parseInt(aBorderBottom[1].replace('px',''));
							else
								iCollapseWithBorderBottom = parseInt(aBorderBottom[1].replace('px',''));
						}
					}
				}
			}
		}
		
		var iSubPosition = 0;
		if (menuopeninframe == 'False' || window.parent.top.document.getElementsByTagName("FRAMESET").length == 0)
		{
			iSubPosition = 2;
		}
		switch(checkDirection)
		{
			case 'left':
				
				if (menuopeninframe == 'False' && !bIsSub)
				{
					parentLeftPos = myClientWidth;
					menuLeftPos = 0;
					calcLeft = parentLeftPos + menuLeftPos - (subWidth + openMarginLeft) - childScrollLeft;
					calcTop = parentTopPos + menuTopPos + openMarginTop - iCollapseBorderTop;
					if (typeof(oObject.getClientRects) != 'undefined' && menuopeninframe != 'False')
					{
						var oCheckBounding = oObject.getBoundingClientRect();
						var oCheckBounding = oObject.getBoundingClientRect();
						
						calcLeft = parseInt(oCheckBounding.left) - iSubPosition + childScrollLeft - parseInt((parseInt(oCheckBounding.right) - parseInt(oCheckBounding.left)) + openMarginLeft);
						calcTop = parseInt(oCheckBounding.top) - iSubPosition + parseInt(openMarginTop)  + childScrollTop - iCollapseBorderTop;
					}
				} else {
					calcLeft = parentLeftPos + menuLeftPos - (subWidth + openMarginLeft) + iCollapseWithBorderLeft;
					calcTop = parentTopPos + menuTopPos + openMarginTop - iCollapseBorderTop;
					if (typeof(oObject.getClientRects) != 'undefined' && menuopeninframe != 'False')
					{
						var oCheckBounding = oObject.getBoundingClientRect();
						var oCheckBounding = oObject.getBoundingClientRect();
						calcLeft = parseInt(oCheckBounding.left) - iSubPosition + childScrollLeft - parseInt((parseInt(oCheckBounding.right) - parseInt(oCheckBounding.left)) + openMarginLeft) + iCollapseWithBorderLeft;
						calcTop = parseInt(oCheckBounding.top) - iSubPosition + parseInt(openMarginTop)  + childScrollTop - iCollapseBorderTop;
					}
					if (baseDirection == 'up')
					{
						calcTop += parentHeight - subHeight;
					}
				}

				if (calcLeft < 0)
				{
					if (zitemanMenuReRun < 3)
					{
						currentDirection = 'right';
						zitemanMenuReRun++;
						zitemanMenuOpenMenu(strMenuID, strObjectID, strSetDirection, oObject, bIsSub);
						return false;
					}
					break;
				}
				if (subHeight + calcTop > myClientHeight)
				{
					var newHeight = calcTop - ((calcTop+subHeight) - myClientHeight);
					if (newHeight < childScrollTop)
						newHeight = childScrollTop;
					calcTop = newHeight;
				}
				break;
			case 'right':
				if (menuopeninframe == 'False' && !bIsSub)
				{
					parentLeftPos = 0;
					menuLeftPos = 0;
					parentWidth = 0;
					calcLeft = parentLeftPos + menuLeftPos + parentWidth + openMarginLeft + childScrollLeft;
					calcTop = parentTopPos + menuTopPos + openMarginTop - iCollapseBorderTop;
					if (typeof(oObject.getClientRects) != 'undefined' && menuopeninframe != 'False')
					{
						var oCheckBounding = oObject.getBoundingClientRect();
						var oCheckBounding = oObject.getBoundingClientRect();
						calcLeft = parseInt(oCheckBounding.left) - iSubPosition + parseInt(openMarginLeft)  + childScrollLeft + parseInt(parentWidth);
						calcTop = parseInt(oCheckBounding.top) - iSubPosition + parseInt(openMarginTop)  + childScrollTop - iCollapseBorderTop;
					}
				} else {
					calcLeft = parentLeftPos + menuLeftPos + parentWidth + openMarginLeft - iCollapseWithBorderRight;
					calcTop = parentTopPos + menuTopPos + openMarginTop - iCollapseBorderTop;
					if (typeof(oObject.getClientRects) != 'undefined' && menuopeninframe != 'False')
					{
						var oCheckBounding = oObject.getBoundingClientRect();
						var oCheckBounding = oObject.getBoundingClientRect();
						calcLeft = parseInt(oCheckBounding.left) - iSubPosition + parseInt(openMarginLeft) + childScrollLeft + parseInt(parentWidth) - iCollapseWithBorderRight;
						calcTop = parseInt(oCheckBounding.top) - iSubPosition + parseInt(openMarginTop)  + childScrollTop - iCollapseBorderTop;
					}
					if (baseDirection == 'up')
					{
						calcTop += parentHeight - subHeight;
					}
				}
				if (calcLeft + subWidth > myClientWidth)
				{
					if (zitemanMenuReRun < 3)
					{
						currentDirection = 'left';
						zitemanMenuReRun++;
						zitemanMenuOpenMenu(strMenuID, strObjectID, strSetDirection, oObject, bIsSub);
						return false;
					}
					break;
				}
				if (subHeight + calcTop > myClientHeight)
				{
					var newHeight = calcTop - ((calcTop+subHeight) - myClientHeight);
					if (newHeight < childScrollTop)
						newHeight = childScrollTop;
					calcTop = newHeight;
				}
				break;
			case 'up':
				calcLeft = parentLeftPos + menuLeftPos + openMarginLeft;
				if (menuopeninframe == 'False' && !bIsSub)
				{
					calcTop = parentTopPos + menuTopPos + openMarginTop - subHeight - childScrollTop;
				} else {
					calcTop = parentTopPos + menuTopPos + openMarginTop - subHeight - childScrollTop + iCollapseWithBorderTop;
				}
				if (typeof(oObject.getClientRects) != 'undefined' && menuopeninframe != 'False')
				{
					var oCheckBounding = oObject.getBoundingClientRect();
					var oCheckBounding = oObject.getBoundingClientRect();
					
					calcLeft = parseInt(oCheckBounding.left) - iSubPosition + parseInt(openMarginLeft) + childScrollLeft;
					if (menuopeninframe == 'False' && !bIsSub)
					{
						calcTop = parseInt(oCheckBounding.top) - iSubPosition + parseInt(openMarginTop)  + childScrollTop - parseInt(subHeight);
					} else {
						calcTop = parseInt(oCheckBounding.top) - iSubPosition + parseInt(openMarginTop)  + childScrollTop - parseInt(subHeight) + iCollapseWithBorderTop;
					}
				}
				break;
			case 'down':
				calcLeft = parentLeftPos + menuLeftPos + openMarginLeft - iCollapseBorderLeft;
				if (menuopeninframe == 'False' && !bIsSub)
				{
					calcTop = parentTopPos + parentHeight + menuTopPos + openMarginTop;
				} else {
					calcTop = parentTopPos + parentHeight + menuTopPos + openMarginTop - iCollapseWithBorderBottom;
				}
				if (typeof(oObject.getClientRects) != 'undefined' && menuopeninframe != 'False')
				{
					var oCheckBounding = oObject.getBoundingClientRect();
					var oCheckBounding = oObject.getBoundingClientRect();
					
					calcLeft = parseInt(oCheckBounding.left) - iSubPosition + parseInt(openMarginLeft) + childScrollLeft - iCollapseBorderLeft;
					if (menuopeninframe == 'False' && !bIsSub)
					{
						calcTop = parseInt(oCheckBounding.top) - iSubPosition + parseInt(parentHeight) + parseInt(openMarginTop) + childScrollTop;
					} else {
						calcTop = parseInt(oCheckBounding.top) - iSubPosition + parseInt(parentHeight) + parseInt(openMarginTop) + childScrollTop - iCollapseWithBorderBottom;
					}
				}

				break;
		}
		oSubObject.setAttribute("mydirection", checkDirection);
		oSubObject.style.left = calcLeft;
		oSubObject.style.top = calcTop;
		oSubObject.style.display = 'block';
		
		
		/* skjul alle dropareas */
		/* Check for IE funktionallitet */
		var bIsIE = false;
		if (typeof(oSubObject.getBoundingClientRect) != 'undefined')
		{
			var oMenuRects = oSubObject.getBoundingClientRect();
			bIsIE = true;
		}
		
		if (menuopeninframe == 'False')
		{
			var aDropareas = window.parent.top.frames[strTargetFrame].document.getElementsByTagName("SELECT");
		} else {
			var aDropareas = document.getElementsByTagName("SELECT");
		}
		
		for (var runDrop=0; runDrop<aDropareas.length; runDrop++)
		{
			if (bIsIE)
			{
				if (aDropareas[runDrop].style.visibility != 'hidden')
				{
					/* Calc position of menu */
					var oDropRects = aDropareas[runDrop].getBoundingClientRect();

					if ((oMenuRects.left <= oDropRects.right) && (oMenuRects.right >= oDropRects.left))
						if ((oMenuRects.top <= oDropRects.bottom) && (oMenuRects.bottom >= oDropRects.top))
						{
							aDropareas[runDrop].style.visibility = 'hidden';
							if (aDropareas[runDrop].getAttribute("disableById"))
							{
								aDropareas[runDrop].setAttribute("disableById", aDropareas[runDrop].getAttribute("disableById") + oSubObject.getAttribute("id") + ',');
							} else {
								aDropareas[runDrop].setAttribute("disableById", oSubObject.getAttribute("id") + ',');
							}
						}
				}
			} else {
				aDropareas[runDrop].style.visibility = 'hidden';
			}
		}
	}
	return;
}


/* Henter parent DIV tag, til nuværende object */
function zitemanMenuGetPrevDiv(oObject)
{
    if (oObject)
    {
	    var oParent = oObject.parentNode;
	} else {
	    var oParent = null;
	}
    if (oParent)
    {
	    while (oParent.tagName != 'DIV' && oParent.tagName != 'BODY')
    	    oParent = oParent.parentNode;
				
	    if (oParent.tagName == 'BODY')
    	    oParent = null;
    }
    return oParent;
}

function zitemanMenuGetBase(oObjectFound)
{
	var oParent = oObjectFound.parentNode;
	while (oParent.getAttribute("id") != 'base' && oParent.tagName != 'BODY')
		oParent = oParent.parentNode;
				
	if (oParent.tagName == 'BODY')
		oParent = null;
	return oParent;
}
				
/* Henter næste menu parent, for nuværende object */
function zitemanMenuGetMenuParent(oObject)
{
	var oParent = zitemanMenuGetPrevDiv(oObject);
	if (oParent)
	{
		/* check for MENU parent */
		if (zitemanMenuGetChildID(oParent) == '')
			oParent = null;
	}
	return oParent;
}

function zitemanMenuRemoveChilds(strMenuID, idref, remove)
{
	var menuopenid = eval("menuBehaviour" + strMenuID + "['currentshow'];");
	var aMenu = menuopenid.split(',');
	
	var globalFound = false;
	for (var runX=0; runX<aMenu.length-1; runX++)
	{
		/* find ud af om id, er child til vores nuværende idref */
		var oParent = zitemanMenuGetMenuParent(document.getElementById(aMenu[runX]));
		var found = false;
		while(oParent && !found)
		{
			if (zitemanMenuGetChildID(oParent) == idref)
			{
				found = true;
				globalFound = true;
			}
			oParent = zitemanMenuGetMenuParent(oParent);
		}
				
		if (found)
		{
			if (remove)
				menuopenid = zitemanMenuRemoveMenuID(menuopenid, aMenu[runX]);
		}
	}
	eval("menuBehaviour" + strMenuID + "['currentshow'] = '" + menuopenid + "';");
	return globalFound;
}
		
/* Main metoden, til at styrer "ASP" funktionallitet i menuen: et niveau åbent adgangen */
function zitemanMenuCloseAll(strMenuID, idref)
{
	var oldList = eval("menuBehaviour" + strMenuID + "['currentshow'];");
	if (eval("menuBehaviour" + strMenuID + "['currentshow'];").indexOf(idref) > -1)
	{
		/* find evt. parent ID */
		var oParent = zitemanMenuGetMenuParent(document.getElementById(idref));
		if (oParent)
		{
			var childID = zitemanMenuGetChildID(oParent);
			if (childID != '')
				eval("menuBehaviour" + strMenuID + "['currentshow'] = '" + childID + ",';");
		} else {
			eval("menuBehaviour" + strMenuID + "['currentshow'] = '';");
		}
	} else {
		/* check status */
		var oSub = document.getElementById(idref + '_child');
		eval("menuBehaviour" + strMenuID + "['currentshow'] = '';");
		if (oSub)
		{
			if (oSub.style.display == 'none')
				eval("menuBehaviour" + strMenuID + "['currentshow'] = '" + idref + ",';");
		}
	}
	zitemanMenuRunMenu(strMenuID, oldList, 'none', true);
	return;
}
		
		
/* Main metode, til at styrer "ASP" funktionallitet i menuen: hold flere niveauer åben adgangen */
function zitemanMenuAddMenu(strMenuID, idref)
{
	var oldList = eval("menuBehaviour" + strMenuID + "['currentshow'];");
	/* tilføj menu til "open" strukturen */
			
	/* FIND EVT. PARENT ID */
	var oSub = document.getElementById(idref);
	var oParent = zitemanMenuGetMenuParent(oSub);
	var parentID = '';
	if (oParent)
	{
		parentID = zitemanMenuGetChildID(oParent);
		var TmpMenuopenid = zitemanMenuRemoveMenuID(eval("menuBehaviour" + strMenuID + "['currentshow'];"), parentID);
		eval("menuBehaviour" + strMenuID + "['currentshow'] = '" + TmpMenuopenid + "'");
	}
			
	/* FIND EVT. CHILD ID */
	var hadChildren = zitemanMenuRemoveChilds(strMenuID, idref, true);
	/* SKAL ID'EN TILFØJES ELLER FJERNES */
	if (eval("menuBehaviour" + strMenuID + "['currentshow'];").indexOf(idref) > -1)
	{
		var TmpMenuopenid = zitemanMenuRemoveMenuID(eval("menuBehaviour" + strMenuID + "['currentshow'];"), idref);
		eval("menuBehaviour" + strMenuID + "['currentshow'] = '" + TmpMenuopenid + "'");
		if (parentID != '')
		{
			/* check for åbne børn, for denne parentid */
			if (!zitemanMenuRemoveChilds(strMenuID, parentID, false))
				eval("menuBehaviour" + strMenuID + "['currentshow'] += '" + parentID + ",';");
		}
	} else {
		if (hadChildren && parentID == '')
		{
		}else{
			eval("menuBehaviour" + strMenuID + "['currentshow'] += '" + idref + ",';");
		}
	}
			
	/* RYD OP I MENUEN */	
	zitemanMenuRunMenu(strMenuID, oldList, 'none', true);
	return;
}
		
/* Standard funktion, som viser/skjuler en given menu struktur på baggrund af en menuliste */
function zitemanMenuRunMenu(strMenuID, menuList, action, runBack)
{
	var aMenu = menuList.split(',');
	for (var x=0; x<aMenu.length-1; x++)
	{
		var oObject = document.getElementById(aMenu[x]);
		if (oObject)
		{
		    /* MENUPOINT */
		    var bRunObject = true;
		    if (eval("menuBehaviour" + strMenuID + "['menuusestartlevel']") == 'true')
		    {
		        if (oObject.getAttribute("dontdisplay") == "true")
		        {
		            oObject.style.display = 'none';
		            var oSub = document.getElementById(aMenu[x] + '_child');
		            if (oSub)
		                oSub.style.display = 'none';
		            bRunObject = false;
		        }
		    }

	        /* check for siblings */
	        try{
		        var oNextSibling = oObject.nextSibling.nextSibling;
	        } catch(e) {
		        var oNextSibling = null;
	        }
	        if (oNextSibling)
	        {
	            var bShowBorderCollapseObject = true;
	            if (oNextSibling.getAttribute("dontdisplay") == "true")
	            {
	                bShowBorderCollapseObject = false;
	            }
		        if (action == 'none')
		        {
			        oNextSibling.removeAttribute("writecollapseborder");
		        } else {
			        oNextSibling.setAttribute("writecollapseborder", "true");
		        }
		        var strList = eval("menuobject" + strMenuID + "['" + oNextSibling.id.replace(strMenuID, '') + "']");
		        if (typeof(strList) != 'undefined')
		        {
			        var aList = strList.split(",");
			        if (bShowBorderCollapseObject)
			        {
			            zitemanMenuSetProperties(strMenuID, oNextSibling, aList, "down", "normal");
			        }
		        }
	        } else {
	            if (bRunObject)
	            {
	                var bShowBorderCollapseObject = true;
		            if (action == 'none')
		            {
			            oObject.removeAttribute("writecollapseborder");
		            } else {
			            oObject.setAttribute("writecollapseborder", "true");
		            }
		            var strList = eval("menuobject" + strMenuID + "['" + oObject.id.replace(strMenuID, '') + "']");
		            if (typeof(strList) != 'undefined')
		            {
			            var aList = strList.split(",");
		                zitemanMenuSetProperties(strMenuID, oObject, aList, "down", "normal");
		            }
	            }
	        }
	        
		    if (bRunObject)
		    {
			    if (action == 'none')
				    oObject.removeAttribute("status");
			    else
				    oObject.setAttribute("status", "open");

			    var oSub = document.getElementById(aMenu[x] + '_child');
    			
			    if (oSub)
			    {
				    oSub.style.display = action;
				    if (runBack)
				    {
					    var oParent = zitemanMenuGetMenuParent(oSub);
					    while (oParent)
					    {
						    var oObject = document.getElementById(zitemanMenuGetChildID(oParent));
						    if (action == 'none')
							    oObject.removeAttribute("status");
						    else
							    oObject.setAttribute("status", "open");
						    oParent.style.display = action;
						    oParent = zitemanMenuGetMenuParent(oParent);
    						
						    /* check for siblings */
						    try{
							    var oNextSibling = oObject.nextSibling.nextSibling;
						    } catch(e) {
							    var oNextSibling = null;
						    }

						    if (oNextSibling)
						    {
							    if (action == 'none')
							    {
								    oNextSibling.removeAttribute("writecollapseborder");
							    } else {
								    oNextSibling.setAttribute("writecollapseborder", "true");
							    }
							    var strList = eval("menuobject" + strMenuID + "['" + oNextSibling.id.replace(strMenuID, '') + "']");
							    if (typeof(strList) != 'undefined')
							    {
								    var aList = strList.split(",");
								    zitemanMenuSetProperties(strMenuID, oNextSibling, aList, "down", "normal");
							    }
						    }
					    }
				    }
				}
			} 
			/* END IF */
		}
		
	}
	return;
}


function zitemanMenuGetChildID(oObject)
{
	var childID = '';
	var strID = oObject.getAttribute("id");
	var aID = strID.split("_child");
	if (aID.length == 2)
	{
		childID = aID[0];
	}
	return childID;
}

/* Fjerner en menuid, fra en kommasepareret liste */
function zitemanMenuRemoveMenuID(idList, idref)
{
	var aMenu = idList.split(idref + ',');
	var nyListe = '';
	for (var x=0; x<aMenu.length; x++)
		nyListe += aMenu[x];
	return nyListe;
}

/**********************/
/* Genrisk frame kode */
/**********************/
function zitemanMenuFindFrame(frameArray, screenX, screenY)
{
	var found = -1;
	for (var x=0; x<frameArray.length; x++)
	{
		if (found == -1)
		{
					
			var myLeft = frameArray[x]["offsetx"];
			var myTop = frameArray[x]["offsety"];
			var myWidth = frameArray[x]["sizex"];
			var myHeight = frameArray[x]["sizey"];
			if ((myLeft <= screenX) && (parseInt(myLeft+myWidth) > screenX))
				if ((myTop <= screenY) && (parseInt(myTop+myHeight) > screenY))
					found = x;
		}
	}
				
	return found;
}

function zitemanMenuGetFrameSize(oFrame)
{
	var x,y;
	if (oFrame.innerHeight)
	{
		x = oFrame.innerWidth;
		y = oFrame.innerHeight;
	} else if (oFrame.document.documentElement && oFrame.document.documentElement.clientHeight)	{
		x = oFrame.document.documentElement.clientWidth;
		y = oFrame.document.documentElement.clientHeight;
	} else if (oFrame.document.body) {
		x = oFrame.document.body.clientWidth;
		y = oFrame.document.body.clientHeight;
	}

	var aSize = new Array();
	aSize[0] = x;
	aSize[1] = y;
	return aSize;
}
		
function zitemanMenuCalcFrameSet(frameArray, oFrameSet, currentDirection, currentOffsetX, currentOffsetY)
{
	var childOffsetX = currentOffsetX;
	var childOffsetY = currentOffsetY;
	var baseX = 0; var baseY = 0;
	for (var run=0; run<oFrameSet.childNodes.length; run++)
	{
		var oNode = oFrameSet.childNodes[run];
		if (oNode.tagName == 'FRAME')
		{
			var oFrame = window.parent.top.frames[zitemanMenuFrameCount];
			var aSize = zitemanMenuGetFrameSize(oFrame);
					
			frameArray[zitemanMenuFrameCount] = new Array();
			frameArray[zitemanMenuFrameCount]["offsetx"] = childOffsetX;
			frameArray[zitemanMenuFrameCount]["offsety"] = childOffsetY;
			frameArray[zitemanMenuFrameCount]["sizex"] = aSize[0];
			frameArray[zitemanMenuFrameCount]["sizey"] = aSize[1];

			if (currentDirection == 'down')
			{
				if (parseInt(aSize[0]))
				{
					if (parseInt(aSize[0]) > parseInt(baseX))
					{
						baseX = aSize[0];
					}
				}
				childOffsetY += aSize[1];
			} else {
				if (parseInt(aSize[1]))
				{
					if (parseInt(aSize[1]) > parseInt(baseY))
					{
						baseY = aSize[1];
					}
				}
				childOffsetX += aSize[0];
			}

			zitemanMenuFrameCount++;

		}
		if (oNode.tagName == 'FRAMESET')
		{
			var tmpDirection = 'right'
			if (oNode.rows != '')
			{
				var tmpDirection = 'down';
				childOffsetX += zitemanMenuCalcFrameSet(frameArray, oNode, tmpDirection, childOffsetX, childOffsetY);
			} else {
				childOffsetY += zitemanMenuCalcFrameSet(frameArray, oNode, tmpDirection, childOffsetX, childOffsetY);
			}
					
		}
	}
	if (currentDirection == 'down')
	{
		var returnValue = baseX;
	} else {
		var returnValue = baseY;
	}
	return returnValue;
}
		
var zitemanMenuFrameCount = 0;
		
		
function zitemanMenuFindTargetFrame(strDirection)
{
	/* run frames */
	var screenHeight = window.screen.availHeight;
	var screenWidth = window.screen.availWidth;
	var offsetX = 0;
	var offsetY = 0;
	var frameArray = new Array();
	zitemanMenuFrameCount = 0;
			
	var oFrameset = window.parent.top.document.getElementsByTagName("FRAMESET")[0];
	
	if ((oFrameset) && (strDirection != ''))
	{
		var currentDirection = 'right'
		if (oFrameset.rows != '')
			var currentDirection = 'down';
		
		zitemanMenuCalcFrameSet(frameArray, oFrameset, currentDirection, 0, 0);

		var selfName = self.name;
		var menuFrame = -1;
		for (var x=0; x<window.parent.top.frames.length; x++)
		{
			if (window.parent.top.frames[x].name == selfName)
				menuFrame = x;
		}

		var targetX = frameArray[menuFrame]["offsetx"];
		var targetY = frameArray[menuFrame]["offsety"];
		if (strDirection == 'down')
		{
			targetY += frameArray[menuFrame]["sizey"] + 15;
			targetX += 20;
		}
		if (strDirection == 'up')
		{
			targetY -= 20;
			targetX += 20;
		}
		if (strDirection == 'right')
		{
			targetX += frameArray[menuFrame]["sizex"] + 15;
			targetY += 20;
		}
		if (strDirection == 'left')
		{
			targetX -= 20;
			targetY += 20;
		}

		var currentFrame = zitemanMenuFindFrame(frameArray, targetX, targetY);
		var aFrame = new Array();
		aFrame[0] = menuFrame;
		aFrame[1] = currentFrame;
	} else {
		var aFrame = new Array();
		aFrame[0] = null;
		aFrame[1] = null;
	}
	return aFrame;
}


/************************************/

function zitemanMenuGetFrameHeightWidth(oFrame)
{
	var aSize = new Array();
	if (oFrame.innerHeight)
	{
		aSize[0] = oFrame.innerWidth;
		aSize[1] = oFrame.innerHeight;
	} else if (oFrame.document.documentElement && oFrame.document.documentElement.clientHeight)
	{
		aSize[0] = document.documentElement.clientWidth;
		aSize[1] = document.documentElement.clientHeight;
	} else if (document.body)
	{
		aSize[0] = oFrame.document.body.clientWidth;
		aSize[1] = oFrame.document.body.clientHeight;
	}
	return aSize;
}

function zitemanMenuGetFrameScroll(oFrame)
{
	var aSize = new Array();
	if (oFrame)
	{
		if (typeof(oFrame.pageYOffset) != 'undefined')
		{
			aSize[0] = oFrame.pageXOffset;
			aSize[1] = oFrame.pageYOffset;
		} else if (oFrame.document.documentElement && oFrame.document.documentElement.scrollTop)
		{
			aSize[0] = oFrame.document.documentElement.scrollLeft;
			aSize[1] = oFrame.document.documentElement.scrollTop;
		} else if (oFrame.document.body)
		{
			aSize[0] = oFrame.document.body.scrollLeft;
			aSize[1] = oFrame.document.body.scrollTop;
		}
	}
	return aSize;
}

/* funktionallitet til select/links og menuskift */
function zitemanMenuLoadPage(strMenuID, strObjectID, strLink, strTarget, strSetDirection)
{
	if (iPageContext == 1 || iPageContext == 7)
	{
		if (eval("typeof(menuBehaviour" + strMenuID + ")") != 'undefined')
		{
			eval("menuBehaviour" + strMenuID + "['currentSplitID'] = '" + strObjectID + "';");
			if (typeof(zitemanUpdateMenuParams) != 'undefined')
				zitemanUpdateMenuParams();
					
			/* set select status */
			zitemanMenuSelectItem(strMenuID, strObjectID, strSetDirection);
			if (strLink != '' && strLink != 'http://')
			{
				var strLocation = '';
				/* Find nuværende framebody */
				var oFrameset = window.parent.top.document.getElementsByTagName("FRAMESET")[0];
                if (strLink.indexOf('specielLink=')!= -1)
                {
                    strLink += '&speciellinkobjectid=' + currentShowPageID;
                }
				if (!oFrameset)
				{
					// intet frame set
					strLocation = 'document.location = \'' + strLink + '\'';
				} else {
					if (strTarget == 'FRAMEBODY')
					{
						strLocation = 'window.parent.' + contentFrame + '.document.location = \'' + strLink + '\'';
					} else {
					
						strLocation = 'window.parent.' + strTarget + '.document.location = \'' + strLink + '\'';
					}
				}
				/* luk nuværende menu */
				var menuType = eval('menuBehaviour' + strMenuID + '["menutype"]');
				if (menuType == 'DHTML')
				{
					zitemanMenuCheckCurrentShow(strMenuID, '');
				}
				
				try{
					setTimeout('try{eval("' + strLocation + '");}catch(e){var strNewEval = "' + strLocation + '";strNewEval = strNewEval.split("\'")[1];window.parent.top.location = strNewEval;}', 1);
				} catch(e) {
					var strNewEval = strLocation.split("'")[1];
					window.parent.top.location = strNewEval;
				}
			}
		}
		/*check split*/
		zitemanMenuShowAllSplit(strMenuID, strObjectID);
	}
	return true;
}

function zitemanMenuUnselect(strMenuID)
{
	/* find nuværende selected */
	if (eval("typeof(menuBehaviour" + strMenuID + ")") != 'undefined')
	{
		if (eval("typeof(menuBehaviour" + strMenuID + "['selected'])") != 'undefined')
		{
			/* fjern selection */
			var strOldObjectID = eval("menuBehaviour" + strMenuID + "['selected']");
			var strList = eval("menuobject" + strMenuID + "['" + strOldObjectID + "']");
			if (strList != '')
			{
				var aList = strList.split(",");
				var oOldObject = zitemanMenuGetObject(strMenuID, strMenuID + strOldObjectID)
				if (oOldObject)
				{
					oOldObject.setAttribute("isselected","false");
					var oldDirection = oOldObject.getAttribute("strSetDirection");
					
					zitemanMenuSetProperties(strMenuID, oOldObject, aList, oldDirection, "normal");
				}
			}
		}
	}
	return;
}

function zitemanMenuSelectItem(strMenuID, strObjectID, strSetDirection)
{
	zitemanMenuUnselect(strMenuID);
	
	if (eval("typeof(menuobject" + strMenuID + ")") != 'undefined')
	{
		if (eval("typeof(menuobject" + strMenuID + "['" + strObjectID + "'])") != 'undefined')
		{
			var strList = eval("menuobject" + strMenuID + "['" + strObjectID + "']");
			if (strList != '')
			{
				eval("menuBehaviour" + strMenuID + "['selected'] = '" + strObjectID + "'");
				var aList = strList.split(",");
				var oNewObject = zitemanMenuGetObject(strMenuID, strMenuID + strObjectID)
				if (oNewObject)
				{
					
					oNewObject.setAttribute("isselected","true");
					oNewObject.setAttribute("strSetDirection", strSetDirection);
					
					zitemanMenuSetProperties(strMenuID, oNewObject, aList, strSetDirection, "selected");
				}
			}
		}
	}	
	return true;
}

function zitemanMenuShowAllSplit(strMenuID, strObjectID)
{
	/* find menu block */
	var strBaseTarget = '';
	var oFrameset = window.parent.top.document.getElementsByTagName("FRAMESET")[0];
	if (oFrameset)
	{
		var oFrames = window.parent.top.frames;
		for (var runFrames=0; runFrames<oFrames.length; runFrames++)
		{
			if (eval("typeof(oFrames[" + runFrames + "].zitemanMenuGlobalListID)") != 'undefined')
			{
				var strBaseTarget = 'window.parent.top.frames[' + runFrames + '].';
				
				/* gennemløb frame */
				zitemanMenuCheckFrameForMenu(strBaseTarget, strObjectID);
			}
		}
	} else {
		if (eval("typeof(zitemanMenuGlobalListID)") != 'undefined')
		{
			zitemanMenuCheckFrameForMenu('', strObjectID);
		}
	}

	return;
}	

function zitemanMenuCheckFrameForMenu(strTargetFrame, strObjectID)
{
	var aZitemanGlobalList = eval(strTargetFrame + "zitemanMenuGlobalListID");
	for (var runMenu = 0; runMenu < aZitemanGlobalList.length; runMenu++)
	{
		var strMenuLayoutAndBlock = eval(strTargetFrame + "menuBehaviour" + aZitemanGlobalList[runMenu] + "['menulayoutandblock'];");
		var aMenu = strMenuLayoutAndBlock.split("#");

		var oFrameset = window.parent.top.document.getElementsByTagName("FRAMESET")[0];
		if (oFrameset)
		{
			var oFrames = window.parent.top.frames;
			for (var runFrames=0; runFrames<oFrames.length; runFrames++)
			{
				if (typeof(oFrames[runFrames].zitemanMenuGlobalList) != 'undefined')
				{
					if (typeof(oFrames[runFrames].zitemanMenuGlobalList[aMenu[0]]) != 'undefined')
					{
						var strSource = 'window.parent.top.frames[' + runFrames + '].';
						zitemanMenuShowSplit(aZitemanGlobalList[runMenu], strObjectID, aMenu, strSource, strTargetFrame);
					}
				}
			}
			
		} else {
			if (typeof(zitemanMenuGlobalList) != 'undefined')
			{
				if (typeof(zitemanMenuGlobalList[aMenu[0]]) != 'undefined')
				{
					var strSource = '';
					zitemanMenuShowSplit(aZitemanGlobalList[runMenu], strObjectID, aMenu, strSource, strTargetFrame);
				}
			}
		}
	}
	return;
}

function zitemanMenuShowSplit(strMenuID, strObjectID, aMenu, strSource, strBaseTarget)
{
	/* gennemløb funde menuer */
	for (var runMenu=0; runMenu<eval(strSource + "zitemanMenuGlobalList['" + aMenu[0] + "'].length"); runMenu++)
	{
		var strFoundMenu = eval(strSource + "zitemanMenuGlobalList['" + aMenu[0] + "'][" + runMenu + "]");
		if (strFoundMenu != strMenuID)
		{
			/* find start level for menu */
			var iMenuStart = parseInt(eval(strSource + "menuBehaviour" + strFoundMenu + "['startlevel'];"))-1;
			
			/* find relavant parentid */
			var strCurrentList = eval(strBaseTarget + "menuobject" + strMenuID + "['" + strObjectID + "'];");
			if (typeof(strCurrentList) == 'undefined')
			{
				/* get object parent */
				try{
					var strCurrentList = eval(strBaseTarget + "menuobject" + strFoundMenu + "['" + strObjectID + "'];");
				} catch(e) {
					return false;
				}
				
				if (typeof(strCurrentList) == 'undefined')
				{
					return false;
				}
			}

			var iLevel = parseInt(strCurrentList.split(",")[7]);
			var strParent = strCurrentList.split(",")[8];
			var iBaseLevel = iLevel;
			var strFoundObjectID = strObjectID;
			if (iLevel > iMenuStart)
			{
				/* spol tilbage */
				var iNewLevel = iLevel;
				var strNewParent = strParent;
				var checkParent = strParent;
				while (iNewLevel > iMenuStart)
				{
					checkParent = strNewParent;
					var checkList = eval(strBaseTarget + "menuobject" + strMenuID + "['" + checkParent + "'];");
					if (typeof(checkList) == 'undefined')
					{
						var checkList = eval(strBaseTarget + "menuobject" + strFoundMenu + "['" + checkParent + "'];");
					}
					
					if (typeof(checkList) == 'undefined')
					{
						return false;
					}
					var iNewLevel = parseInt(checkList.split(",")[7]);
					var strNewParent = checkList.split(",")[8];
				}
				strFoundObjectID = checkParent;
				iLevel = iNewLevel;
			}

			if (iLevel == iMenuStart)
			{
				/*gem nuværende menu*/
				if (typeof(eval(strSource + "menuBehaviour" + strFoundMenu + "['showsplit']")) != 'undefined')
				{
					var strOldSplit = eval(strSource + "menuBehaviour" + strFoundMenu + "['showsplit'];");
					var oOldSplit = eval(strSource + "document.getElementById('" + strOldSplit + "');");
					if (oOldSplit)
						oOldSplit.style.display = 'none';
				}
				var strOldSplit = eval(strSource + "menuBehaviour" + strFoundMenu + "['splitstart'];");
				var oOldSplit = eval(strSource + "document.getElementById('" + strFoundMenu + strOldSplit + "');");
				if (oOldSplit)
					oOldSplit.style.display = 'none';

				/*Vis ny menu */
				var oMenu = eval(strSource + "document.getElementById('" + strFoundMenu + strFoundObjectID + "');");
				if (oMenu)
				{
				    //alert('vis split: ' + strObjectID + ':' + strFoundObjectID + ':' + strFoundMenu +'\n' + oMenu.childNodes[0].getAttribute("id"));
				    /* VIS VI KUN SKAL VISE ET PUNKT (MENUPOINT)*/
				    var bHasMenuUseStartLevel = true;
				    if ((iBaseLevel-1) == iMenuStart)
				    {
				        if (eval(strSource + "menuBehaviour" + strFoundMenu + "['menuusestartlevel']") == 'true')
				        {
				            bHasMenuUseStartLevel = zitemanMenuUpdateMenuPointShow(strFoundMenu, strFoundMenu + '' + strObjectID, strSource);
				        }
				    } else {
				        if ((iBaseLevel-1) < iMenuStart)
				        {
    				        if (eval(strSource + "menuBehaviour" + strFoundMenu + "['menuusestartlevel']") == 'true')
	    			        {
		    		            bHasMenuUseStartLevel = false;
			    	        }
			    	    }
				    }
				    if (bHasMenuUseStartLevel)
				    {
					    oMenu.style.display = 'block';
					    eval(strSource + "menuBehaviour" + strFoundMenu + "['showsplit'] = '" + strFoundMenu + strFoundObjectID + "';");
					}
				}
			}
		}
	}
	return;
}

function zitemanMenuUpdateMenuPointShow(sMenuID, sMenuPoint, strSource)
{
    var oNode = document.getElementById(sMenuPoint);
    var bIsValidSplit = false;
    if (oNode)
    {
        /* CHECK FOR TOP NIVEAU */
        var oRootNode = oNode.parentNode;
        var bCheck = true;
        var bIsParentStruct = false;
        var sParentStructID = '';
        while (bCheck)
        {
            if (oRootNode.parentNode.parentNode.tagName == 'DIV')
            {
                sParentStructID = oRootNode.getAttribute("id");
                if (sParentStructID.indexOf('_child') != -1)
                {
                    sParentStructID = sParentStructID.split('_child')[0];
                }
                bIsParentStruct = true;
                var oRootNode = oRootNode.parentNode;
            } else {
                bCheck = false;
            }
        }
        var oSubNodes = oRootNode.childNodes;

        /* FINDES DEN I LEVEL */
        var bFound = false;
        
        for (var runSub=0; runSub < oSubNodes.length; runSub++)
        {
            if (bIsParentStruct)
            {
                if (oSubNodes[runSub].getAttribute("id") == sParentStructID)
                    bFound = true;            
            } else {
                if (oSubNodes[runSub].getAttribute("id") == sMenuPoint)
                    bFound = true;            
            }

        }
        
        if (bFound)
        {
            var oFound = null;
            for (var runSub=0; runSub < oSubNodes.length; runSub++)
            {
                oSubNodes[runSub].removeAttribute('dontdisplay');
                if (oSubNodes[runSub].childNodes[0])
                {
                    oSubNodes[runSub].childNodes[0].removeAttribute('dontdisplay', 'true');
                }
                
                if (oSubNodes[runSub].getAttribute("id") != sMenuPoint && oSubNodes[runSub].getAttribute("id") != sParentStructID)
                {
                    if (oSubNodes[runSub].getAttribute("id") != sMenuPoint + '_child' && oSubNodes[runSub].getAttribute("id") != sParentStructID + '_child')
                    {
                        //alert('skjul andre noder:' + oSubNodes[runSub].outerHTML);
                        oSubNodes[runSub].style.display = 'none';
                        oSubNodes[runSub].setAttribute('dontdisplay', 'true');
                        if (oSubNodes[runSub].childNodes[0])
                        {
                            oSubNodes[runSub].childNodes[0].style.display = 'none';
                            oSubNodes[runSub].childNodes[0].setAttribute('dontdisplay', 'true');
                        }
                    }
                } else {
                    oFound = oSubNodes[runSub];
                }
            }
            if (oFound)
            {
                bIsValidSplit = true;
                var sOld = eval(strSource + "menuBehaviour" + sMenuID + "['currentmenupoint']");
                if (sOld != sMenuPoint && sOld != sParentStructID)
                {
                    /* Luk træ */
                    zitemanMenuCloseAll(sMenuID, sMenuPoint);
                }
                oFound.style.display = 'block';
                if (oFound.childNodes[0])
                {
                    oFound.childNodes[0].style.display = 'block';
                }
                var oChild = document.getElementById(oFound.getAttribute("id") + '_child');
                if (oChild)
                {
                    oChild.style.display = 'block';
                    if (oChild.childNodes[0])
                    {
                        oChild.childNodes[0].style.display = 'block';
                    }
                }
                eval(strSource + "menuBehaviour" + sMenuID + "['currentmenupoint'] = '" + sMenuPoint + "'"); 
                var sCurrentShow = eval("menuBehaviour" + sMenuID + "['currentshow'];");
                if (sCurrentShow.indexOf(sMenuPoint + ',') == -1)
                {
                    //alert('huh: ' + sCurrentShow + ':' + sMenuPoint + ':' + sCurrentShow.indexOf(sMenuPoint + ',') + ':');
                    sCurrentShow += sMenuPoint + ',';
                    eval("menuBehaviour" + sMenuID + "['currentshow'] = '" + sCurrentShow + "';");
                }
                zitemanMenuRunMenu(sMenuID, eval("menuBehaviour" + sMenuID + "['currentshow'];"), 'block', true);
            }
        }
    }
    return bIsValidSplit;
}

/**********************************************/
/******     MENU EMULATE ONCLICK     **********/
/**********************************************/
/*
	GENNEMLØB FOR MENUER
		Led efter menuobjectid som macther parameteren
			Hvis den ikke findes skal der skiftes til respektive contentsection
			slut
		find alle "parents" i fundne menuer
			find evt. indgangs punkter fra andre menu (hvis det er en split)
		opbyg menu parameter struktur (til fold ud)
		eksekver onclick
*/
function zitemanMenuEmulateClick(strObjectID)
{
	var strUpdateList = '';
	var strUpdateListDone = '';
	var iMenuItemCount = 0;
	var aList = zitemanMenuGetAllMenuFrames();
	for (var x=0; x<aList.length; x++)
	{
		var strTarget = '';
		if (aList[x] != 'NOFRAMES')
		{
			strTarget = aList[x];
		}
		var aZitemanGlobalList = eval(strTarget + 'zitemanMenuGlobalListID');
		for (var y=0; y<aZitemanGlobalList.length; y++)
		{
			/* UNSELECT MENU */
			eval(strTarget + "zitemanMenuUnselect('" + aZitemanGlobalList[y] + "')");

			/* CHECK FOR MENU */
			var oMenuItem = eval(strTarget + 'document.getElementById("' + aZitemanGlobalList[y] + strObjectID + '")');
			if (oMenuItem)
			{
				iMenuItemCount++;
				/* HVOR LIGGER PUNKTET */

				var strMenuType = eval(strTarget + 'menuBehaviour' + aZitemanGlobalList[y] + '["menutype"]');
				var strCurrentShow = eval(strTarget + 'menuBehaviour' + aZitemanGlobalList[y] + '["currentshow"]');
				var strMenuLayoutBlock = eval(strTarget + 'menuBehaviour' + aZitemanGlobalList[y] + '["menulayoutandblock"]').split('#')[1];
				eval(strTarget + 'zitemanMenuRunMenu("' + aZitemanGlobalList[y] + '", "' + strCurrentShow + '", "none", true)');
				strCurrentShow = '';
					
				/* SPOL MENU TILBAGE */
				var oParent = oMenuItem.parentNode;
				if (strMenuType == 'ASP')
				{
				    var sParent = '' + oParent.getAttribute('id');
					while(sParent.indexOf('_child') != -1)
					{
						/* UNDER MENU */
						strCurrentShow = sParent.replace('_child', '') + ',' + strCurrentShow;
						oParent = oParent.parentNode;
						var sParent = '' + oParent.getAttribute('id');
					}
				} else {
				    var sParent = '' + oParent.getAttribute('id');
					while(sParent.indexOf('sub') != -1)
					{
						/* UNDER MENU */
						oParent = oParent.parentNode;
						var sParent = '' + oParent.getAttribute('id');
					}
				
				}
				/* VIS KORREKT BLOCK */
				var sParent = '' + oParent.getAttribute('id');
				var strSplitStart = sParent.substring(aZitemanGlobalList[y].length, sParent);
				if (strSplitStart != '')
				{
					/*gem nuværende menu*/
					if (typeof(eval(strTarget + "menuBehaviour" + aZitemanGlobalList[y] + "['showsplit']")) != 'undefined')
					{
						var strOldSplit = eval(strTarget + "menuBehaviour" + aZitemanGlobalList[y] + "['showsplit'];");
						var oOldSplit = eval(strTarget + "document.getElementById('" + strOldSplit + "');");
						if (oOldSplit)
							oOldSplit.style.display = 'none';
					}
					var strOldSplit = eval(strTarget + "menuBehaviour" + aZitemanGlobalList[y] + "['splitstart'];");
					var oOldSplit = eval(strTarget + "document.getElementById('" + aZitemanGlobalList[y] + strOldSplit + "');");
					if (oOldSplit)
						oOldSplit.style.display = 'none';

					/*Vis ny menu */
					var oMenu = eval(strTarget + "document.getElementById('" + aZitemanGlobalList[y] + strSplitStart + "');");
					if (oMenu)
					{
						oMenu.style.display = 'block';
						eval(strTarget + "menuBehaviour" + aZitemanGlobalList[y] + "['showsplit'] = '" + aZitemanGlobalList[y] + strSplitStart + "';");
					}
				}
				
				if (strMenuType == 'ASP')
				{
					eval(strTarget + 'zitemanMenuRunMenu("' + aZitemanGlobalList[y] + '", "' + strCurrentShow + '", "block", true)');
					eval(strTarget + 'menuBehaviour' + aZitemanGlobalList[y] + '["currentshow"] = "' + strCurrentShow + '";');
				}
				
				strUpdateList += strTarget + "menuBehaviour" + aZitemanGlobalList[y] + "['currentSplitID'] = '" + strObjectID + "';" + "##";
				strUpdateListDone += strTarget + "menuBehaviour" + aZitemanGlobalList[y] + "['currentSplitID'] = null;" + "##";

				/* set select status */
				/* Hent retning på menuen */
				var strBaseDir = "down";
				var baseDirection = eval(strTarget + "menuBehaviour" + aZitemanGlobalList[y] + "['subdirection1'];");
				if (baseDirection == "down" || baseDirection == "up")
				{
					strBaseDir = "right";
				}
				eval(strTarget + "zitemanMenuSelectItem('" + aZitemanGlobalList[y] + "', '" + strObjectID + "', '" + strBaseDir + "')");

				/* CHECK FOR MENU SPLIT */
				eval(strTarget + "zitemanMenuShowAllSplit('" + aZitemanGlobalList[y] + "', '" + strObjectID + "')");
			} // if menuitem
		}
	}

	var aUList = strUpdateList.split("##");
	var aUListDone = strUpdateListDone.split("##");
	for(var x=0; x<aUList.length; x++)
	{
		eval(aUList[x]);
	}
	if (eval("typeof(" + strTarget + "zitemanUpdateMenuParams)") != 'undefined')
		eval(strTarget + "zitemanUpdateMenuParams()");
	for(var x=0; x<aUListDone.length; x++)
	{
		eval(aUListDone[x]);
	}
	return;
}


function zitemanMenuGetAllMenuFrames()
{
	var aReturn = new Array();
	/* find menu block */
	var strBaseTarget = '';
	var oFrameset = window.parent.top.document.getElementsByTagName("FRAMESET")[0];
	if (oFrameset)
	{
		var oFrames = window.parent.top.frames;
		for (var runFrames=0; runFrames<oFrames.length; runFrames++)
		{
			if (eval("typeof(oFrames[" + runFrames + "].zitemanMenuGlobalListID)") != 'undefined')
			{
				var strBaseTarget = 'window.parent.top.frames[' + runFrames + '].';
				aReturn[aReturn.length] = strBaseTarget;
			}
		}
	} else {
		if (eval("typeof(zitemanMenuGlobalListID)") != 'undefined')
		{
			aReturn[aReturn.length] = 'NOFRAMES';
		}
	}

	return aReturn;
}