//var SelectedMenuItem;
//var childrenShown;
//var bgColor_std = "#EBC885";
//var bgColor_tLvl = "#FFF6DC";
//var oldBg;
//var oldFg;

//function initMenu(_id){
//	for(i=0; i<Menu.length ; i++){
//		tmpMenuItem = Menu[i];
//		if (getMenuItemParentId(tmpMenuItem)=="0"){
//			visibility(getMenuItemId(tmpMenuItem),"BLOCK");
//			className(getMenuItemId(tmpMenuItem),"active");
//			backgroundColor(getMenuItemId(tmpMenuItem),bgColor_std);
//			SetMenuHeader(tmpMenuItem);
//		}
//	}
//	childrenShown = false;
//	if (_id)
//		SelectedMenuItem = getMenuItem(_id)
//	else
//		SelectedMenuItem = Menu[0];
//	fontWeight(getMenuItemId(SelectedMenuItem),"bold");
//	className(getMenuItemId(SelectedMenuItem),"parent");
//	SetMenuHeader(SelectedMenuItem);
//	fNavigate(getMenuItemId(SelectedMenuItem));
//	oldBg=null;
//}

//function doSubClick(aId){
//	navigate("show.aspx?id=" + aId + "&type=" + "MENUARTICLES");
//}

//function doOver(aId){
//	oldBg=document.getElementById("TD_" + aId).style.backgroundColor
//	document.getElementById("TD_" + aId).style.backgroundColor="#F0F0E8";
//	document.getElementById("TDa_" + aId).style.backgroundColor="#F0F0E8";

//	oldFg=document.getElementById("TD_" + aId).getElementsByTagName("SPAN")[0].style.color
//    var coll = document.getElementById("TD_" + aId).getElementsByTagName("SPAN");
//    if (coll!=null){
//      for (i=0; i<coll.length; i++) 
//        coll[i].style.color='#834143';
//    }
//    var coll = document.getElementById("TDa_" + aId).getElementsByTagName("SPAN");
//    if (coll!=null){
//      for (i=0; i<coll.length; i++) 
//        coll[i].style.color='#834143';
//    }
//}

//function doOut(aId){
//	document.getElementById("TD_" + aId).style.backgroundColor=oldBg;
//	document.getElementById("TDa_" + aId).style.backgroundColor=oldBg;

//    var coll = document.getElementById("TD_" + aId).getElementsByTagName("SPAN");
//    if (coll!=null){
//      for (i=0; i<coll.length; i++) 
//        coll[i].style.color=oldFg;
//    }
//    var coll = document.getElementById("TDa_" + aId).getElementsByTagName("SPAN");
//    if (coll!=null){
//      for (i=0; i<coll.length; i++) 
//        coll[i].style.color=oldFg;
//    }
//}

function doNavigate(sType,sId,bShowIn,sName){
	if (bShowIn){
		if (sType=="menu")
			doClick(sId);
		else{
			sNav = "show.aspx?id=" + sId + "&type=" + "ARTICLE";
			showArt_border(sNav,sName);
	}	}
	else {
		if (sType=="menu")
			doClick(sId);
		else{
			sNav = "show.aspx?id=" + sId + "&type=" + "ARTICLE";
			showArt_border(sNav,sName);
}	}	}
	
//function fNavigate(){
//	if (getMenuItemArticleCount(SelectedMenuItem)>0){
//		if(getMenuItemChildCount(SelectedMenuItem)>0){
//			sNav = "show.aspx?id=" + getMenuItemId(SelectedMenuItem) + "&type=" + "MENUARTICLES";
//			showArt_border(sNav, getMenuItemName(SelectedMenuItem));
//		}
//		else{
//			sNav = "show.aspx?id=" + getMenuItemId(SelectedMenuItem) + "&type=" + "MENUARTICLES";
//			showArt_border(sNav, getMenuItemName(SelectedMenuItem));
//		}
//	}
//}

//function fOpenPage(aPage){
//	showArt_border(aPage);
//}

function setTitle(sTitle){
	document.getElementById("main_frame_titleHeader").innerText=sTitle;
}

function showArt_border(sNav,sMenuName){
	//if (sMenuName != "ARTIKELLINK")
	//	document.getElementById("main_frame_titleHeader").innerHTML=sMenuName;
	document.frames[0].navigate(sNav);
}

function showArt_noborder(sNav){
	//document.getElementById("main_frame_titleHeader").innerHTML=sMenuName;
	document.frames[0].navigate(sNav);
}

//function SetChildren(){
//	if (getMenuItemChildCount(SelectedMenuItem)>0){
//		for(i=0; i<Menu.length ; i++){
//			tmpMenuItem = Menu[i]
//			if (getMenuItemParentId(tmpMenuItem)==getMenuItemId(SelectedMenuItem)){
//				visibility(getMenuItemId(tmpMenuItem),"BLOCK");
//				className(getMenuItemId(tmpMenuItem),"active")
//				backgroundColor(getMenuItemId(tmpMenuItem),bgColor_tLvl)
//}	}	}	}

//function SetSisters(ParentId){
//	for(i=0; i<Menu.length ; i++){
//		tmpMenuItem = Menu[i];
//		if (getMenuItemParentId(tmpMenuItem)==ParentId){
//			visibility(getMenuItemId(tmpMenuItem),"BLOCK");
//			if (getMenuItemLevel(tmpMenuItem)==1){
//				// level 1 er altid mørk
//				backgroundColor(getMenuItemId(tmpMenuItem),bgColor_std)
//			}
//			else if ((getMenuItemLevel(tmpMenuItem)==getMenuItemLevel(SelectedMenuItem))&&(getMenuItemChildCount(SelectedMenuItem)<1)){
//				// hvis samme level som selected og selected ikke har børn : lys
//				backgroundColor(getMenuItemId(tmpMenuItem),bgColor_tLvl)
//				className(getMenuItemId(tmpMenuItem),"active")
//			}
//			else if ((getMenuItemLevel(tmpMenuItem)==getMenuItemLevel(SelectedMenuItem))&&(getMenuItemChildCount(SelectedMenuItem)>0)){
//				// hvis samme level som selected og selected har børn : mørk
//				backgroundColor(getMenuItemId(tmpMenuItem),bgColor_std)
//			}
//			else if (getMenuItemLevel(tmpMenuItem)<getMenuItemLevel(SelectedMenuItem)){
//				// lavere level end selected : mørk
//				backgroundColor(getMenuItemId(tmpMenuItem),bgColor_std)
//			}
//			else{
//				backgroundColor(getMenuItemId(tmpMenuItem),bgColor_tLvl)
//				className(getMenuItemId(tmpMenuItem),"active")
//}	}	}	}

//function SetParents(ParentId){
//	if (ParentId != "0"){
//		SetSisters(getMenuItemParentId(getMenuItem(ParentId)))
//		SetParents(getMenuItemParentId(getMenuItem(ParentId)))
//		className(ParentId,"parent")
//}	}

//function showSpan(obj_id){
//	CloseAll();
//	document.getElementById("span"+obj_id).style.display='inline';
//	if (document.getElementById("trindhold") != null){
//		if (document.getElementById("shownews") != null){
//			document.getElementById('shownews').height=document.getElementById('trindhold').offsetHeight;
//		}
//	}
//}

function init_shownews(){
	//CloseAll();
	//document.all.span" & myMenuItem._menuItemId & ".style.display='inline';
	//document.getElementById("span"+obj_id).style.display='inline';
	if (document.getElementById("trindhold") != null){
		if (document.getElementById("shownews") != null){
			document.getElementById('shownews').height=document.getElementById('trindhold').offsetHeight;
		}
	}
}

//function CloseAll(){
//        var coll = document.all.tags('SPAN');
//        if (coll!=null){
//          for (i=0; i<coll.length; i++) 
//            if(coll[i].id.substr(0,4)=='span'){
//              coll[i].style.display='none';
//            }
//        }
//}

//function SetMenuHeader(aMenuItem){
	//if ((document.getElementById("menuHeader_image").background != getMenuHeader_image(aMenuItem))||(document.getElementById("menuHeader_text").innerText != getMenuHeader_text(aMenuItem))) {
	//	document.getElementById("menuHeader_image").background = getMenuHeader_image(aMenuItem);
	//	document.getElementById("menuHeader_text").innerText = getMenuHeader_text(aMenuItem);
	//}
//}

function backgroundColor(aId,backgroundColor){
	document.getElementById("TD_" + aId).style.backgroundColor=backgroundColor;
	document.getElementById("TDa_" + aId).style.backgroundColor=backgroundColor;
}

function fontWeight(aId,fontWeight){
	document.getElementById("TD_" + aId).style.fontWeight=fontWeight;
	document.getElementById("TDa_" + aId).style.fontWeight=fontWeight;
}

function className(aId,className){
	document.getElementById("TD_" + aId).className=className;
	document.getElementById("TDa_" + aId).className=className;
}

function visibility(aId,display){
	document.getElementById(aId).style.display=display;
}

function getMenuItemId(MenuItem){
	return MenuItem[0]
}

function getMenuItemName(MenuItem){
	return MenuItem[1]
}

function getMenuItemParentId(MenuItem){
	return MenuItem[2]
}

function getMenuItemLevel(MenuItem){
	return MenuItem[3]
}

function getMenuItemChildCount(MenuItem){
	return MenuItem[4]
}

function getMenuHeader_text(MenuItem){
	return MenuItem[5]
}
function getMenuHeader_image(MenuItem){
	return ("doc/images/menuHeader/" + MenuItem[6])
}

function getMenuItemArticleCount(MenuItem){
	return MenuItem[7]
}

function getMenuItem(aId){
	var i = 0; 
	var found = false;
	while((i<Menu.length)&&(!found)){ 
		if (aId == Menu[i][0]){
			found=true;
		}
		else{
			i+=1;
	}	}
	return Menu[i]
}

function getMenuItemByIndex(aIndex){
	return Menu[aIndex]
}

function focusOnError(obj)
	{
		obj.focus();
	}
	

function setHeightOnIframe(iframename)
{
  var h = document.body.scrollHeight + 25;

  if (window.parent.document.getElementById(iframename))
    window.parent.document.getElementById(iframename).style.height = h;
}



//function doPrint(){
//	var oRoot = window.document.frames[0].document;
//	var oNode = oRoot.createElement("<h2>")
//	oNode.innerText = document.getElementById("main_frame_titleHeader").innerText;
//	oRoot.insertBefore(oNode,oRoot.firstChild) 
//	window.document.frames[0].focus();
//	window.document.frames[0].print();
//	oRoot.removeChild(oNode)
//}

			function doPrint(){
				if (document.frames.length>0){
					if (document.getElementsByTagName('IFRAME').item(0).id!='shownews'){
						document.frames.item(0).window.focus();
						document.frames.item(0).window.print();
					}else{
						window.print();
					}
				}else{
					window.print();
				}
			}
			var pName='default.aspx'
			
			function doClick(sId){
				document.location.href='default.aspx?id=' + sId
			}

			function doSearch(searchStr){
				if (searchStr != '') {
					document.getElementById('srch').value = searchStr;
					Form1.submit();
				}
			}
			
			function doSubClick(aId){
				var mId = '<%=Request.querystring("id")%>';
				document.location.href=pName+'?id='+mId+'&ai=' + aId
			}
			
			//PopUp function, used in searchresult, together with a href and target=_blank
			function popupResult(url,width,height)
			{
				newwindow=window.open(url,'displayWindow','toolbar=0,resizable=1,directories=0,left=20,top=20,status=0,menubar=0,scrollbars=0,location=0,width='+width+',height='+height+'');
				if (window.focus) {newwindow.focus()}
				return false;
			}
			function popitupSmall(url)
			{
				newwindow=window.open(url,'displayWindow','toolbar=0,resizable=1,directories=0,status=0,menubar=0,scrollbars=1,location=0,width=800,height=600');
				if (window.focus) {newwindow.focus()}
				return false;
			}
			function popitup(url)
			{
				newwindow=window.open(url);
				if (window.focus) {newwindow.focus()}
				return false;
			}
			
			function calcHeight()
			{
				if( document.readyState != "complete")
				{
					alert('not ready');
					var dbSafety=window.setTimeout('calcHeight()', 3);
				}
				else
				{
					alert('Ready');
				}
				
				
				//find the height of the internal page
				var the_height = document.getElementById('show_frame').contentWindow.document.body.scrollHeight;

				alert(the_height);
				//change the height of the iframe
				document.getElementById('show_frame').height = the_height +1000;
				
				

				alert(document.getElementById('show_frame').height);
					
			//document.getElementById('show_frame')..scrolling=NO
			}
			
			function calcIframeHeight(iframe)
			{
				//find the height of the internal page
				var the_height = iframe.contentWindow.document.body.scrollHeight;
				
				//change the height of the iframe
				document.getElementById(iframe.id).height = the_height +50;			
			}
			
			/*function calcIframeHeight(iframename)
			{
			alert('START');
			alert(document.getElementById(iframename).id);
				if( document.readyState != "complete")
				{
					alert('readystate');
					var dbSafety=window.setTimeout('calcIframeHeight('''+iframename+''')', 3);
				}
				else
				{
				alert('test');
					if (iframename.contentWindow.document.readyState != "complete")
					{
						var dbSafety=window.setTimeout('calcIframeHeight('''+iframename+''')', 3);
					}
					else
					{
						window.clearTimeout(dbSafety);
						//find the height of the internal page
						var the_height = document.getElementById(iframename).contentWindow.document.body.scrollHeight;

						//change the height of the iframe
						document.getElementById(iframename).height = the_height;
					}
				}
				
					
			//document.getElementById('show_frame')..scrolling=NO
			}*/

/* used for TimePartner CMS */			
function enableRegistration()
{
	var regDiv = document.getElementById("tilmeldingDiv");
	var descDiv = document.getElementById("beskrivelseDiv");
	if (regDiv != null)
	{
		descDiv.style.display = "none";
		regDiv.style.display = "";
	}
}

function disableRegistration()
{
	var regDiv = document.getElementById("tilmeldingDiv");
	var descDiv = document.getElementById("beskrivelseDiv");
	if (regDiv != null)
	{
		descDiv.style.display = "";
		regDiv.style.display = "none";
	}
}
