﻿//<![CDATA[
/*
  if (top.location != self.location) 
	{
    top.location = self.location;
	}
*/	
var objLoad = new Array();
window.onload = OnloadHandler
function LoadQue( strCall ) { objLoad[ objLoad.length ] = strCall; }
function OnloadHandler()
{
	for( var i=0; i < objLoad.length; i++ )
	{
		eval( objLoad[i] );
	}
}
function Kontrol(tekst, url)
	{
	if (confirm(tekst)) document.location.href = url ;
	}
	
function K(p, s)
	{
	document.location.href = '/default.aspx?s=' + s ;
	return false;
	}	
	
function setCss(css, dage)
	{
	SetClientCookie ('Css', css, dage);
	document.location.href = document.location.href ;
	return false ;	
	}	
	
function NW(url,h,w)
	{
	var winl = (screen.width - w) / 2; 
	var wint = (screen.height - h) / 2; 
	var win = window.open(url,'','height='+h+',width='+w+',top='+wint+',left='+winl+',toolbar=no,status=no,location=no,titlebar=no,scrollbars=yes,menubar=no,resizable=yes')
	if (parseInt(navigator.appVersion) >= 4) win.window.focus(); 
	}
	
var cookieEnabled=(navigator.cookieEnabled)? true : false
if (typeof(navigator.cookieEnabled) == "undefined" && !cookieEnabled)
	{ 
	document.cookie="testcookie"
	cookieEnabled=(document.cookie=="testcookie")? true : false
	document.cookie=""
	}
	
function SetClientCookie(NameOfCookie, value, expiredays) 
{
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); 
}	

function GetClientCoookie(cookiename) 
{
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length; 
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}
function SetCookie(name, value, on)
	{
	if (cookieEnabled)
		{
		var c = GetCookie(name);
		var i = c.indexOf(value);
		if (on)
			{
			if (i == -1) document.cookie = name + '=' + escape (c + value + '-') ;	
			}
		else
			{
			if (i > -1)	document.cookie = name + '=' + escape (c.substring(0, i) + c.substring(i+value.length+1)) ;
			}
		}
	}	
	
function getCookieVal (offset) 
   {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr+1));
   }
   
function GetCookie (name) 
   {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) 
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break; 
      }
   return '';
   }
//moduler
function Hide(name, value)
	{
	var c = GetCookie(name);
	if (c.indexOf('MQ'+value) == -1)
		{
		SetCookie (name, 'MQ'+value, true);
		SetCookie (name, 'Table'+value, true);
		}
	}	
	
function GetId(id, getbyId)
{
	if (getbyId)
		return (document.all)?document.all(id):document.getElementById(id);
	else
		return (document.all)?document.all(id):document.getElementByName(id);
}

function setValue(id,value)
{
var o = GetId(id,true);
if (o) o.value = value;
}
	
function SetMenu(id,cl,topCl)
{
	var e = GetId(id,true);
	if (e) 
		{
		e.className = cl ;
		if (topCl.length > 0)
			{
			var t = GetId('st'+e.lang,true);			
			if (t) t.className = topCl ;
			}
		return true;
		}
	else
		return false;
}
	
function SetMenuV(m,menuid)

{
	var s = getQueryValue('s'); 
	/* Ekstra test pga. - hvis gruppe og ingen undersider */
	if (!SetMenu('st'+menuid+'m'+m,'TPunktValgt','')) SetMenu('st'+menuid+'m0','TPunktValgt','')
//	SetMenu('sp'+s+'m'+m,'TaktuelPic','TPunktValgt');
	SetMenu('sv'+s+'m'+m,'Taktuel','TPunktValgt');
}

function SetMenuL2(m,menuid)
{
	var s = getQueryValue('s'); 
/*	SetMenu('sp'+s+'m'+m,'aktuelSidePic','');
	SetMenu('sv'+s+'m'+m,'aktuelSide','');
*/	
	SetMenu('sv'+s+'m'+m,'aktSide1','');
	SetMenu('st'+menuid+'m0','TPunktValgt','');

}

function SetMenuV2(m,menuid)
{
	var s = getQueryValue('s'); 
	SetMenu('svt'+s+'m'+m,'aktVandretSide','');
	SetMenu('st'+menuid+'m0','TPunktValgt','');

}


function SetMenu3(id,cl,test)
{
	var e = GetId(id,true);
	if (e) 
		{
		e.className = cl ;
		if (test)
			{
			t = GetId('st'+e.lang,true);			
			if (t) t.className = 'GrpAkt2' ;
			t = GetId('t'+e.lang,true);			
			if (t) t.className = 'SubMenu2' ;
			}
		}
}

function SetMenuL3(m)
{
	var s = getQueryValue('s'); 
	SetMenu3('sv'+s+'m'+m,'aktSide2',true);
	SetMenu3('st'+s+'m'+m,'GrpAkt2',false);
}

function L3(id)
{
	var e = GetId(id,true);
	if (e) 
		{
		if (e.className == 'hide')
			e.className = 'SubMenu2';
		else
			e.className = 'hide';
		}
	return false;
}


function StartOp()
{
	CloseIt('FQ');
}

function CloseIt(name)
	{
	if (cookieEnabled)
		{
		var r = GetClientCoookie('Refresh');
		if (r == 'Ja') 
			{
			SetClientCookie('Refresh', 'Nej', -1) 			
			document.location.reload(true);
			}
		var c = GetCookie(name);
		if (c != '')
			{
			var Rows = document.getElementsByTagName('div');
			for (var i=0; i<Rows.length; i++) 
				{
				if (Rows.item(i).id.substring(0,5) == 'Table')
					{
					if (c.indexOf(Rows.item(i).id) != -1) VirsaVersa(name, Rows.item(i).id,false);
					}
				}	
			}
		}
	}	   
function VirsaVersa(name, value, c)
	{
	if (value != '')
		{
		var myElement = GetId(value,true);
		if (myElement)
			{
			if (myElement.className)
				{
				var myPic = GetId(value+'I',true);
				if (myPic)
					{
					var myPrn = GetId(value+'P',true);
					var stname = myElement.className
					if (stname.substring(0,5) == 'Modul')
						{
						myPic.className = "Maaben";
						myElement.className = stname.replace(/Modul /,"MUsynlig ");
						if (myPrn) myPrn.style.visibility = 'hidden';
						if (c) SetCookie (name, value, true);
						}
					else
						{
						myPic.className = "Mluk";
						myElement.className = stname.replace(/MUsynlig /,"Modul ");
						if (myPrn) myPrn.style.visibility = 'visible';
						if (c) SetCookie (name, value, false);
						}
					}
				} 
			}						
		} 
	}
function getQueryValue(name) 
		{
		var value = "";
		if ( (i=location.search.indexOf('?'+name))==-1 && (i=location.search.indexOf('&'+name,3))==-1 )
			return null;
		else
			i += name.length+2;
			if ( (j=location.search.indexOf("&",i))!=-1 )
				value = location.search.substring(i,j);
			else
				value = location.search.substring(i,location.search.length);
			for ( i=0; i<value.length; i++ )
				if ( value.charAt(i)=='+' )	value = value.substring(0,i)+' '+value.substring(i+1,value.length);
			return unescape(value);
		}

var IE6 = (navigator.userAgent.indexOf('MSIE 6') != -1);
var oldMenu = null ;	
var delay_hide = 2650 ;

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

function timoutnow()
{
	if (oldMenu != null)
		{
		clear_timeout();
		var show = GetId('menu'+oldMenu,true);
		show.style.display = 'none';

		if (IE6)
			{
			var overID = oldMenu + "_over";
			var fram = GetId(overID,true);
			fram.style.display = 'none';
			}

		oldMenu = null ;
		}
}

function timeout()
{
	delayhide = setTimeout("timoutnow()",delay_hide)
}

function clear_timeout()
{
	if (window.delayhide) clearTimeout(delayhide)
}

function menu(caller,id,aktion)
	{
	if (oldMenu != null) 
		{
		if (oldMenu == id )
			clear_timeout();
		else
			timoutnow();
		}
		
	var bId = 'menu' + id;
	var show = GetId(bId,true);

	show.style.display = aktion;
	show.style.left = findPosX(caller) + "px" ;	
	show.style.top = findPosY(caller) + 20 + "px" ;	
	
	var screenW = null;
	var moz = 0 ;

	if (document.all && typeof document.body.scrollTop != "undefined")
		{ // IE model
		var ieBox = document.compatMode != "CSS1Compat";
		var cont = ieBox ? document.body : document.documentElement;
		screenW = cont.clientWidth ;
		getWidth = show.offsetWidth ;
		}
	else 
		{
		screenW = window.innerWidth ;
		moz = 27 ; /* Dårlig løsning - NN/MOZ */
		getWidth = document.defaultView.getComputedStyle(show,null).getPropertyValue('width') ;
		}

	getWidth = parseInt(getWidth);
//	alert(getWidth);
	
	if ((parseInt(show.style.left)+getWidth+moz) >= screenW)
		{
		if (parseInt(moz) > 0)
			show.style.left = (parseInt(show.style.left) - 113) + "px" ;
		else
			show.style.left = (screenW - getWidth) + "px" ;
		}
	oldMenu = id;

	if (IE6)  // Pga. z-index fejl i IE når dropdown mm.
		{
		var overID = id + "_over";
		if (!document.getElementById(overID)) 
			{
			document.body.insertAdjacentHTML("beforeEnd","<iframe id='" + overID + "' src='about:blank' style='position:absolute;left:0px;top:0x;z-index:499;display:none' scrolling='no' frameborder='0'></iframe>");		
			}
		var overs = document.getElementById(overID).style;
		overs.top = show.style.top;
		overs.left = show.style.left;
		overs.width = show.offsetWidth;
		overs.height = show.offsetHeight;
		overs.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
		overs.display = 'block';
		}
	}
	
function cancelKey(no)
   {
   if (window.event.keyCode == no) 
	{
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    if (no == 13) alert('Brug istedet <tab> for at gå til næste felt.');
	}
   }
   
function submitKey(no, id)
   {
   if (window.event.keyCode == no) 
	{
	document.getElementById(id).click(); 
	return false;
	}
   } 
   
function crTotab() { if (window.event.keyCode == 13) window.event.keyCode = 9; }
 
function toAnchor(hashValue)
{
	if(location.hash!=hashValue) 
     location.hash=hashValue; 
}

function setFocus(id, getbyId)
{
var e = GetId(id, getbyId);
if (e) e.focus();
}

function showError(msg)
{
alert(msg);
}

function leftTrim(sString) 
{
var s=sString;
while (s.substring(0,1) == ' ')
  {
  s = s.substring(1, s.length);
  }
return s;
}

function rightTrim(sString) 
{
var s=sString;
while (s.substring(s.length-1, s.length) == ' ')
  {
  s = s.substring(0,s.length-1);
  }
return s;
}

function Search(querystring)
{
  window.open('/service/kviksog.aspx?zoom_query=' + querystring + "", "_self", "");
}

function ValidateSearch(id)
{
  var textBox = id;

  if (textBox.value == "Søg her..." || textBox.value == null || textBox.value == "")
  { 
    return false;  
  }
  else
  {
    Search(textBox.value);
  }
}

function switchText(object, baseText, eventName)
{
  if (eventName == "blur")
  {
    if (object.value == "")
    {
    object.value = baseText;
    }
  }
  else
  {
    if (object.value == baseText)
    {
    object.value = "";
    }
  }
}

function centerWindow(Url,Titel) 
	{
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 640, yMax=480;

	var w= (xMax - 100);
	var h= (yMax - 100);
	
    var xOffset = (xMax - w)/2;
    var yOffset = (yMax - h)/2;
    
    window.open(Url,Titel,'scrollbars=yes,width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
	}

/* Vedr. udskrift */	
function Printer(ref,style) 
{
	var w=597;
	var h=450;
	var l=(self.screen.availWidth-w)/2;
	var t = (self.screen.availHeight - h) / 2;

	winPrint=window.open('','Nyt','location=0,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+w+',height='+h+',left='+l+',top='+t);
	var str = '<html><head><style type="text/css" media="print">#prn, #luk{display:none} body {background-color:#fff; margin:5px 5px 5px 5px; text-align: center; } body {font-family : Arial, Tahoma, Trebuchet, Verdana, Arial, Helvetica, sans-serif; font-size:12px;color:#000} .PrnForening * {color:#666666;font-weight:bold;font-size:14px} .Prnlinie {border-top:solid 1px black;padding:10px 5px 0 5px} .Prnlinie img {display:none} .ModulTitel {font-size:20px;font-weight:bold;padding-bottom:5px} a {text-decoration:none;color:black} a img {border:none} a:hover {text-decoration:none} p {margin: 0px 0px 4px 0px} small {font-size:9px;}</style><script type="text/javascript"> function myVoid() {window.focus();window.print();close();self.close();} </script></head><title>Udskrift</title><body><div class="Prnlinie">';
	/*
	if (window.print)		
		str+='<td id="ejprint" align="right"><a href="javascript: void 0" onclick="myVoid()"><IMG alt="Udskriv side" id="prn" hspace=0 src="/ikoner/print.gif" border=0></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript: " onclick="self.close();"><IMG alt="Luk vindue" id="luk" hspace=0 src="/ikoner/AfslutUd.gif" border=0 onmouseover="this.src=\'/ikoner/AfslutInd.gif\';" onmouseout="this.src=\'/ikoner/AfslutUd.gif\';"></a></td></tr></table><div class="Prnlinie">';
	else			
		str+='<td id="print"><a href="javascript: " onclick="self.close();"><IMG alt="Luk vindue" hspace=0 src="/ikoner/AfslutUd.gif" border=0 onmouseover="this.src=\'/ikoner/AfslutInd.gif\';" onmouseout="this.src=\'/ikoner/AfslutUd.gif\';"></a></td></tr></table><div class="Prnlinie">';
    */

	var table = '<table cellpadding="0" cellspacing="0">' + window.document.getElementById(ref).innerHTML + '</table>';
	var txt = table ; //xReplace(xReplace(xReplace(xReplace(xReplace(table,'class=ls','class=xx'),'class=rs','class=xx'),'class=bl','class=xx'),'class=bm','class=xx'),'class=br','class=xx');

	winPrint.document.write(str + txt + '</div></body></html>');
	
	winPrint.document.close();

	winPrint.focus();
	winPrint.print();
}	

// Afstemning - historik
function swapview(obj) {
    if (obj.style.display == 'none')
        obj.style.display = 'block';
    else
        obj.style.display = 'none';

    var a = '0';
    var o;

    while ((o = eval('document.getElementById(\'T' + a + '\')')) != null) {
        if (o != obj) o.style.display = 'none';
        a++;
    }
}
//]]>