// div: onmouseover="textObj = getElementById('navigationText23'); textObj.style.color = 'black';this.style.background = 'silver';this.style.cursor='hand';
// div: onmouseout="textObj = getElementById('navigationText23'); textObj.style.paddingLeft = '8px';textObj.style.fontFamily = 'Verdana';textObj.style.fontWeight = 'bold';textObj.style.fontSize = '12px';textObj.style.color = '#6f625a';this.style.background = 'white';this.style.cursor='default';

var navigationFlag = 0;
var navigationHide = new Array();
var navigationSelection = '';
var navigationRightMost = 0;
var navigationMenuScrolled = false;
var hideTimeout = 1900;

function navigationMenuHideAll(exceptions, scrollBack, caller) {
	nohide = exceptions.split(";");
	for (i in nohide) {
		navigationMenuHideArr[nohide[i]] = false;
	}
	for (i in navigationMenuHideArr) {
		if (navigationMenuHideArr[i])
			navigationElementHide('navigationMenu'+i, scrollBack, caller);
		else
			navigationMenuHideArr[i] = true;
	}
}
function navigationMenuShow(menu_id, ancestors, caller) {
	setTimeout('_navigationMenuShow("' + menu_id +'", "' + ancestors + '", "' + navigationSelection + '", "' + caller + '")', 250);
}
function _navigationMenuShow(menu_id, ancestors, selection, caller) {
	if (navigationSelection != selection)
		return;

	if (menu_id != '') {
		navigationMenuHideAll(ancestors, false, null);
		pos = navigationElementCache(menu_id);
		//alert(menu_id);
		eTop = pos[0];
		eLeft = pos[1];
		eWidth = pos[2];
		eHeight = pos[3];
		wTop = getWindowTop();
		wLeft = getWindowLeft();
		wWidth = getWindowWidth();
		wHeight = getWindowHeight();
		if (eLeft + eWidth > wLeft + wWidth)
			wLeft+= (eLeft + eWidth) - (wLeft + wWidth) + 10;
		if (eLeft + eWidth > navigationRightMost)
			navigationRightMost = eLeft + eWidth;
		if (wLeft > 0)
			navigationMenuScrolled = true;
		window.scrollTo(wLeft, wTop);
        //alert(menu_id);
		elementShow(menu_id);
	}
	else {
		navigationMenuHideAll(ancestors, true, caller);
	}
}
function navigationMenuHide(menu_id) {
	navigationHide [navigationHide.length] = menu_id;
}
function navigationMenuIn(selection) {
	navigationSelection = selection;
	//alert(navigationSelection);
	navigationFlag ++;
	//window.status = navigationFlag;
}
function navigationMenuOut() {
	navigationSelection = "out";
	setTimeout('_navigationMenuOut()', hideTimeout)
}
function _navigationMenuOut() {
	navigationFlag --;
	//window.status = navigationFlag;
	if (navigationFlag == 0) {
		for (i in navigationHide) {
			navigationElementHide(navigationHide[i], true, 'timeout');
		}
		navigationHide = new Array();
	}
}
function navigationElementHide(menu_id, scrollBack, caller) {
/*	if (menu_id == 'navigationMenu1') {
		itemObj = getElementById('navigationItem28703');
		textObj = getElementById('navigationText28703');
		textObj.style.paddingLeft = '8px';
		textObj.style.fontFamily = 'Verdana';
		textObj.style.fontWeight = 'bold';
		textObj.style.fontSize = '12px';
		textObj.style.color = '#6f625a';
		itemObj.style.background = 'white';
	} */
	if (menu_id == 'navigationMenu' + navigationRootMenu)
		return;

	elementHide(menu_id);
	if (scrollBack) {
		if (caller == 'timeout') {
			navigationRightMost = 0;
			if (navigationMenuScrolled) {
				window.scrollTo(0, 0);
				navigationMenuScrolled = false;
			}
		}
		else {
			//alert('caller: ' + caller);
			callerPos = navigationElementCache(caller);
			cTop = callerPos[0];
			cLeft = callerPos[1];
			cWidth = callerPos[2];
			cHeight = callerPos[3];
	
			pos = navigationElementCache(menu_id);
			eTop = pos[0];
			eLeft = pos[1];
			eWidth = pos[2];
			eHeight = pos[3];
			wTop = getWindowTop();
			wLeft = getWindowLeft();
			wWidth = getWindowWidth();
			wHeight = getWindowHeight();
			if (eLeft + eWidth == navigationRightMost && cLeft + cWidth != navigationRightMost) {
				wLeft = wLeft - eWidth + 10;
				navigationRightMost= wLeft;
			}
			if (wLeft < 0)
				wLeft = 0;
			window.scrollTo(wLeft, wTop);
		}
	}
}
function navigationElementCache(menu_id) {
	return navigationCache[menu_id];
	//if (menu_id == 'navigationMenu0') return new Array(50, 0, 121, 167);
	//if (menu_id == 'navigationMenu1') return new Array(146, 123, 180, 71);
}

/*
//********************************************************
//
//	Javascript menu funktioner
// Inspiration fra tv2.dk's menu -> "Nap den blot - men skriv lige i din kode hvor du har den fra! :-) "
//				
//********************************************************


// *** Browser mumbo jumbo***
	var isIE4 = (document.all)
	var isNS4 = (document.layers)
	var isNS6 = document.getElementById
	var isMac = (navigator.appVersion.indexOf("Mac")!=-1)
	var W3C=DOM=!!document.getElementById

// *** Globals *** No custom settings here! Keep hands off
	var menuID = 0								// ID of the current open menu
	var menuTimer = null					// Will be set to with a timeout to automaticaly close the menu
	var freeze = false						// Bool to "freeze" menu.


// *** Show a menu
	function menu_Show(menuNr) {
			menuID=menuNr
			//Hide all
			for(i=1;i<=menuCount;i++)
				menu_ShowHide(i,false)	
			clearTimeout(menuTimer)
			if(!(menuID==0)) {
				menu_ShowHide(menuID,true)
			}
			freeze = false;
			form_showHide(false);
	}
	
// *** Hide a menu
	function menu_Hide(menuNr){
		clearTimeout(menuTimer)
		menu_ShowHide(menuNr,false)
		form_showHide(true);
	}

// *** Change visibility of menu
function menu_ShowHide(id,state){
	var offsetH = calcOffsetH();
	if(isNS4)
		eval("document.menu"+id).visibility=(state)?"show":"hide"
	else if(isNS6){
		menu = document.getElementById("menu"+id)
		menu.style.left = offsetH + menuPositionH[id-1]
		menu.style.top = menuPositionV[id-1]
		menu.onmouseover = menu_MouseOver
		menu.onmouseout = menu_MouseOut
		menu.style.visibility=(state)?"visible":"hidden"
	}
	else{
		eval("menu"+id).style.visibility=(state)?"visible":"hidden"
		eval("menu"+id).style.zIndex=50
	}
}

// *** Mouse over : Stop "hide menu" timer
function menu_MouseOver() {
	clearTimeout(menuTimer)
}

// *** Mouse out : Start "hide menu" timer
function menu_MouseOut(){
	if(!freeze)
		menuTimer = setTimeout("menu_Hide("+menuID+")",400)
}

// *** Initialize. Set Z-index and position menus
	function initialize() {
		if(isIE4&&!isMac) {
			for(i=0;i<document.all.length;i++) {
				element = document.all(i)
				zIndex_max = Math.max(element.style.zIndex,zIndex_max)
			}
			zIndex_max++
		}
		reposition();
		reClip();
	}

// *** Calculate offsetH
function calcOffsetH() {
	//windowW=isNS4?window.innerWidth-16:window.innerWidth?window.innerWidth:isMac?document.body.offsetWidth:document.body.offsetWidth-20
	//return(windowW<siteWidth)?0:Math.floor(eval((windowW-siteWidth)/2))	
	return 0
}

// *** Set position of menus
	function reposition() {
		var offsetH = calcOffsetH();
		if(isNS4) {
			for(i=1;i<=menuCount;i++) {
				eval("document.menu"+i).moveTo(offsetH+menuPositionH[i-1],menuPositionV[i-1]);
			}
		} else { //if(!isNS6)
			for(i=1;i<=menuCount;i++) {
				currentMenu = eval("menu"+i);
				currentMenu.style.pixelLeft = offsetH+menuPositionH[i-1];
				currentMenu.style.pixelTop = menuPositionV[i-1];
				currentMenu.style.zIndex = zIndex_max;
			}
		}
		
		//Set font/cell size of menu
		
	}

// *** get element
function getElement(id){
	return W3C?document.getElementById(id):
		isIE4?document.all[id]:
		isNS4?document[id]:false;
}

// *** show/hide form elements
function form_showHide(state){
	var div
	if(isNS4){
		if(div=getElement("menuFormNS")) {
			div.visibility=state?"show":"hide"
		}
	}else{	
		for(var i=1;div=getElement("menuForm"+i);i++){		
			div.style.visibility=state?"visible":"hidden"
		}
	}
}

// *** Set clipping of menus (used for dynamic menus)
	function reClip() {
		if(isNS4) {
			for(i=1;i<=menuCount;i++) {
				menuHeight = (menuVariantV+(menuSubmenuCount[i-1]*menuCellSize));
				eval("document.menu"+i).clip.top = 0;
				eval("document.menu"+i).clip.right = menuCellWidth;
				eval("document.menu"+i).clip.bottom = menuHeight;
				eval("document.menu"+i).clip.left = 0;
			}
		} else { //if(!isNS6)
			for(i=1;i<=menuCount;i++) {
				menuHeight = (menuVariantV+(menuSubmenuCount[i-1]*menuCellSize));
				currentMenu = eval("menu"+i);
				currentMenu.style.clip = "rect(0px " + menuCellWidth + "px " + menuHeight + "px 0px)";
			}
		}
	}

function menuPunkt(menuHTML) {
	var HTML = ""
	if(isNS4) {
		HTML = "&nbsp;<a class=menuLines onmouseover=menu_MouseOver() target=_top href=" + menuHTML + "</a>"
	} else {
		HTML = "<a class=menuLink onmouseover=menu_MouseOver() target=_top href=" + menuHTML + "</a>"
	}
	return HTML;
}

function createMenu(menuNr, menuWidth, menuPunkter, menuCount) {
	var head = "<div id=menu" + menuNr + "><table width="+menuWidth+" border=0 cellspacing=0 cellpadding=1><tr><td class=mbg align=center valign=center><table width="+(menuWidth-2)+" border=0 cellspacing=0 cellpadding=0><tr><td class=menuIndhold>"
	var tail = "</td></tr></table></td></tr></table></div>"
	var body = ""
	
	for(i=0;i<menuPunkter.length;i++) {
			body += menuPunkter[i]
	}
	
	if(menuToptype) {
		menuPositionV[menuNr-1] = menuOffsetV;
	} else {
		menuOffset = menuOffsetV - (menuVariantV+(menuCount*menuCellSize));
		menuPositionV[menuNr-1] = menuOffset;
	}
	
	menuSubmenuCount[menuNr-1] = menuCount;
	
	document.write(head + body + tail)
	
}

*/

