	var ciffer = /^\d*$/; 
	function tvingCifre(feltObj){

		if (ciffer.test(feltObj.value)) {
			// alt er ok
		} else {
			var til = "";
			var fra = feltObj.value;
			for (var i=0; fra.length>i; i++ ) 
				if ( ciffer.test( fra.charAt(i) ) )
					til += fra.charAt(i);
			feltObj.value = til;
		}
	}

	function validateEmail(email){
		if (email.length == 0){
			return false;
		}
		found = false;
		for (i=0; i < email.length; i=i+1) {
			if (email.charAt(i) == "@") {
				var num = i;
				found = true;
			}
		} //slut for
		if (found == false) {
		  return false;
		} else {
			//@fundet på plads num.
			num++;
			komma1found = false;
			for (num; num < email.length; num++){
				if(email.charAt(num) == "."){
					komma1found = true;
					var num2 = num;
				}
			}
			if (komma1found == false){
				return false;
			} else {
				//tester for tegn efter komma.
				var t = email.length -3;
				if (num2 > t){
					return false;
				}
			}
		}
		return true;
	}//end function
	
	function popupHelp(helpId){
		var url = "help.php?helpId="+helpId;
		window.open(url,"PopUpHelp"+helpId,"width=20,height=20,left=20,top=20,toolbar=no,location=no,directories=no,status=no,scrollbars=yes");
	}

	function validateNyhedsbrev(){
		var f = document.forms.formNewsletter;

		if (f.email.value == "Indtast e-mail..." || f.email.value == ""){
			alert("Indtast venligst e-mail");	
			return false;
		}
	
		if (! validateEmail(f.email.value)){
			alert("Den indtastede e-mail er ikke korrekt. \nPrøv venligst igen.");	
			f.email.focus();
			return false;
		}

		return true;
	}

	var nlFirst = true;
	function nlRemText(){
		if (nlFirst){
			document.forms.formNewsletter.email.value = "";
			nlFirst = false;
		}
	}


	function randomNum(nr) {
		return parseInt((Math.random() * nr) + 1);
	}

	function setOpacity(obj, opacity) {
	  opacity = (opacity == 100)?99.999:opacity;
	   // IE/Win
	  obj.style.filter = "alpha(opacity:"+opacity+")";
	   // Safari<1.2, Konqueror
	  obj.style.KHTMLOpacity = opacity/100;
	   // Older Mozilla and Firefox
	  obj.style.MozOpacity = opacity/100;
	   // Safari 1.2, newer Firefox and Mozilla, CSS3
	  obj.style.opacity = opacity/100;
	}

	function fadeOut(objId,opacity) {
//		alert("jker")
 		$("#"+objId).fadeOut(1500);
	  /*if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity >= 10) {
		  setOpacity(obj, opacity);
		  opacity -= 10;
		  window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 50);
		} 
	  }*/
	}

	function fadeIn(objId,opacity) {
	 
 	//	$("#"+objId).css("opacity","100");
		$("#"+objId).css("display","none");
// 		$("#"+objId).hide();

 		$("#"+objId).fadeIn(2000);
// 		$("#"+objId).slideDown(1500);
	/*	
	  if (document.getElementById) {
		obj = document.getElementById(objId);
		if (obj != null){
			if (opacity <= 100) {
			
			  setOpacity(obj, opacity);
			  opacity += 10;
			  window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
			}
		}
	  }*/
	}



	function float_menu(startY,topHoejde) {
		var ns = (navigator.appName.indexOf("Netscape") != -1);
		var d = document;
		function ml(id)	{
			var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
			if(d.layers)el.style=el;
			el.sP=function(y){this.style.top=y;};
			//el.x = startX;
			el.y = startY;
			return el;
		}
		
		window.stayTopLeft=function(){
			if (okToScroll){
				var pY = ns ? pageYOffset : document.body.scrollTop;

				if (((pY + startY - ftlObj.y)/8) < topHoejde) {
					ftlObj.y += (pY + startY - ftlObj.y)/8;
				}
				
				ftlObj.sP(ftlObj.y);
				setTimeout("stayTopLeft()", 10);
			}
		}

	ftlObj = ml("menubox");
	stayTopLeft();
	}

	function fadeInBlock(){
		if (curBlock != "-1"){
			for (var i = 0;i <=billedeArray[curBlock].length -1;i = i+2){
				if (billedeArray[curBlock][i+1] == 1){
					var fadeBillede = "billede_" + billedeArray[curBlock][i];
					fadeIn(fadeBillede,10);	
				}
			}
		}
	}	
	
	function fadeOutBlock(){
		if (curBlock != "-1"){
			for (var i = 0;i <=billedeArray[curBlock].length -1;i = i+2){
				if (billedeArray[curBlock][i+1] == 1){
					var fadeBillede = "billede_" + billedeArray[curBlock][i];
					fadeOut(fadeBillede,100);	
				}
			}
		}
	}

	function updateBlocks(){

		for (var j = 0;j <= billedeArray.length -1; j++){
			var billedeBlock = "billedeBlock_" + j;
			var fb = "billedeblock_" + j;
			var objB = document.getElementById(fb);

			if (parseInt(curBlock) == parseInt(j)){
				objB.style.display = 'block';
			
				//sætter baggrundsbillede
				if (billedeBGArray[j][1] == 1){
					//fade
					$("#bgfadediv").css('background-color', '#'+billedeBGArray[j][4]) ;		
					$("#bgfadediv").show();
					$("#bgfadediv").fadeOut(1500);
				}
				
				//skifter kun hvis der er en url
				if (billedeBGArray[j][0] != '')	{
					$("#body").css("background-image","url("+billedeBGArray[j][0]+")");
				}
				//skifter kun hvis der er en farve
				if (billedeBGArray[j][5] != '')	{
					$("#body").css("background-color","#"+billedeBGArray[j][5]);
				}

					
				
				
			} else {
				objB.style.display = 'none';			
			}
		}

		fadeInBlock();

	}
	
	function billedeNext(){
		if (curBlock != "-1"){

			if (curBlock == billedeArray.length -1){//hvis sidste
				curBlock = 0;
			} else {
				curBlock++;		
			}
			
	

			updateBlocks();
			updateBilledePile();
			updateTekst();
		}
	}

	function billedePrev(){
	
		if (curBlock == 0){//hvis første
			curBlock =  billedeArray.length -1;
		} else {
			curBlock--;		
		}



		updateBlocks();
		updateBilledePile();
		updateTekst();

	}

	
	function updateBilledePile(){
		if (curBlock != "-1"){
			if (visBilledePile == true){		

				if (billedeArray.length > 1){
					if (curBlock == 0){//hvis første
						document.getElementById("billedeFrem").style.display = 'block';
						document.getElementById("billedeTilbage").style.display = 'none';
					} else if (curBlock == billedeArray.length -1)  {//hvis sidste
						document.getElementById("billedeFrem").style.display = 'none';
						document.getElementById("billedeTilbage").style.display = 'block';
					} else {
						document.getElementById("billedeFrem").style.display = 'block';
						document.getElementById("billedeTilbage").style.display = 'block';
					}
				} 
			} else {
				document.getElementById("billedeFrem").style.display = 'none';
				document.getElementById("billedeTilbage").style.display = 'none';
			}
		}
	}

	function updateTekstPile(){
			if (tekstArray.length > 1){
				if (curTekst == 0){//hvis første
					document.getElementById("tekstFrem").style.display = 'block';
					document.getElementById("tekstTilbage").style.display = 'none';
				} else if (curTekst == tekstArray.length -1)  {//hvis sidste
					document.getElementById("tekstFrem").style.display = 'none';
					document.getElementById("tekstTilbage").style.display = 'block';
				} else {
					document.getElementById("tekstFrem").style.display = 'block';
					document.getElementById("tekstTilbage").style.display = 'block';
				}
			} 
	
	}

	function updateTekst(){
		if (tekstArray.length > 0){
			document.getElementById("tekstblock").innerHTML = tekstArray[curTekst];
		}
		if (tekstBilledeArray[curBlock]){
			document.getElementById("tekstblock").innerHTML = tekstBilledeArray[curBlock];
		}
	}

	function tekstPrev(){
		if (curTekst == 0){//hvis sidste
			curTekst =  tekstArray.length -1;
		} else {
			curTekst--;		
		}
		updateTekst();
		updateTekstPile();
	}
	function tekstNext(){
		if (curTekst == tekstArray.length -1){//hvis sidste
			curTekst = 0;
		} else {
			curTekst++;		
		}
		updateTekst();
		updateTekstPile();
	}

	function tekstGoto(nr){
		
		curTekst = nr -1;
		updateTekst();
		updateTekstPile();
	}


	function killEnter(evt)	{
		if(evt.keyCode == 13 || evt.which == 13){
			return false;
		}
		return true;
	}



	function slideshow(antSek){
		billedeNext();
		window.setTimeout("slideshow("+antSek+")",antSek);
	}

	function insertQT(bredde,hoejde,farveBg,filnavn){
		
		document.write ("<OBJECT CLASSID=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" WIDTH=\""+bredde+"\" HEIGHT=\""+hoejde+"\" CODEBASE=\"http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0\">");
		document.write ("<PARAM NAME=\"controller\" VALUE=\"TRUE\">");	
			document.write ("<PARAM NAME=\"type\" VALUE=\"video/quicktime\">");
			document.write ("<PARAM NAME=\"autoplay\" VALUE=\"true\">");
			document.write ("<PARAM NAME=\"bgcolor\" VALUE=\""+farveBg+"\">");
			document.write ("<PARAM NAME=\"src\" VALUE=\"upl/images/"+filnavn+"\">");
			document.write ("<param name=\"wmode\" value=\"transparent\">");
			document.write ("<PARAM NAME=\"pluginspage\" VALUE=\"http://www.apple.com/quicktime/download/index.html\">");
			document.write ("<EMBED width=\""+bredde+"\" height=\""+hoejde+"\" CONTROLLER=\"TRUE\" SRC=\"upl/images/"+filnavn+"\" type=\"video/quicktime\" wmode=\"transparent\" BGCOLOR=\""+farveBg+"\" BORDER=\"0\" PLUGINSPAGE=\"http://www.apple.com/quicktime/download/index.html\"></EMBED></OBJECT>");

	}


	function insertFlash(bredde,hoejde,farveBg,filnavn){
		

		document.write ("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" WIDTH=\""+bredde+"\" HEIGHT=\""+hoejde+"\">");
		document.write ("<param name=\"movie\" value=\"upl/images/"+filnavn+"\" />");
		document.write ("<param name=\"bgcolor\" value=\""+farveBg+"\" />");
		document.write ("<param name=\"menu\" value=\"false\" />");
		document.write ("<param name=\"quality\" value=\"high\" />");
		document.write ("<param name=\"wmode\" value=\"transparent\">");
		document.write ("<param name=\"salign\" value=\"tl\" />");
		document.write ("<embed src=\"upl/images/"+filnavn+"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" menu=\"false\" quality=\"high\" WIDTH=\""+bredde+"\" HEIGHT=\""+hoejde+"\"></embed></object>");
	}


	function popupLatest(){
		var winleft = (screen.width - 650) / 2;
		var winUp = (screen.height - 600) / 2;		
		window.open("index.php?show=popSenesteNyhedsbrev","popupSenesteNl","width=650,height=600,left="+winleft+",top="+winUp+",toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=yes");
	}

	function getVar(name) {
         get_string = document.location.search;         
         return_value = '';
         
         do { //This loop is made to catch all instances of any get variable.
            name_index = get_string.indexOf(name + '=');
            
            if(name_index != -1)
              {
              get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
              
              end_of_value = get_string.indexOf('&');
              if(end_of_value != -1)                
                value = get_string.substr(0, end_of_value);                
              else                
                value = get_string;                
                
              if(return_value == '' || value == '')
                 return_value += value;
              else
                 return_value += ', ' + value;
              }
            } while(name_index != -1)
            
         //Restores all the blank spaces.
         space = return_value.indexOf('+');
         while(space != -1)
              { 
              return_value = return_value.substr(0, space) + ' ' + 
              return_value.substr(space + 1, return_value.length);
							 
              space = return_value.indexOf('+');
              }
          
         return(return_value);        
	}