// function til at køre onload
function start(){
 // slideshowet i toppen
 // runSlideShow();

 // retter højden til på begge spalter
 /*
 h = document.getElementById('spalte_midt').scrollHeight;
 document.getElementById('spalte_venstre').style.height = h;
 document.getElementById('spalte_hoejre').style.height = h;
 */
}

// funktion til brug ved baggrundsbanner
function baggrundsbanner(){
// foobar = document.body.clientHeight;
//	foobar = foobar + getScrollHeight();
             foobar = getDocHeight();
	document.getElementById('bannere_udenom_baggrund').style.height = foobar + 'px';
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

// funktion til at læse cookie
function hent_cookie(name){
 var cname = name + "=";               
 var dc = document.cookie;             
 if (dc.length > 0) {              
  begin = dc.indexOf(cname);       
  if (begin != -1) {           
   begin += cname.length;       
  end = dc.indexOf(";", begin);
  if (end == -1) end = dc.length;
   return unescape(dc.substring(begin, end));
  } 
 }
 return null;
}

// funktion til at skrive cookie
function saet_cookie(name, value, expires, path, domain, secure) {
 document.cookie = name + "=" + escape(value) + 
 ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
 ((path == null) ? "" : "; path=" + path) +
 ((domain == null) ? "" : "; domain=" + domain) +
 ((secure == null) ? "" : "; secure");
}

// funktion til at slette cookie
function slet_cookie (name,path,domain) {
 if (hent_cookie(name)) {
 document.cookie = name + "=" +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  "; expires=Thu, 01-Jan-70 00:00:01 GMT";
 }
}

// funktion til at validere formularer
function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- feltet '+nm+' skal indeholde en e-mailadresse.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- feltet '+nm+' skal indeholde et tal.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- feltet '+nm+' skal indeholde et tal imellem '+min+' og '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- feltet '+nm+' skal udfyldes.\n'; }
  } 
	if (errors) {
	 alert('Følgende fejl opstod:\n'+errors);
	} else {
	 return true;
	}
}

// funktion til jump-menuer
function MM_jumpMenu(targ,selObj,restore){ //v3.0
 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
 if (restore) selObj.selectedIndex=0;
}

// funktion til at åbne popups
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// funktion til at åbne popups
function PopWin(url,w,h) { 
 leftPos = Math.round((screen.availWidth-w)/2); 
 topPos = Math.round((screen.availHeight-h)/2); 
 window.open (url,'Popup','width='+w+',height='+h+',left='+leftPos+',top='+topPos+', toolbar=no,menubar=no,location=no, scrollbars=no,resizeable=no'); 
}

function skift_tipenven(){
 if(document.getElementById('tipenven').style.display == 'none'){
  document.getElementById('tipenven').style.display = 'block';
 } else {
  document.getElementById('tipenven').style.display = 'none';
 }
}

// set menu max when the menu is being printed
 function showMenu(id) {
  var d = document.getElementById(id);
	for (var i = 1; i<=100; i++) {
		if (document.getElementById('srom'+i)) {document.getElementById('srom'+i).style.display='none';}
	}
  if (d) {d.style.display='block';}
  }
  
  function ctrl_itemPartner(name, imgPath) {
	document[name].src = imgPath;
 }
 
 function addClick( id ){
	xajax_addClick( id );
 }
