function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; 
	document.MM_sr=new Array; 
	for(i=0; i<(a.length-2); i+=3)
		if ((x=MM_findObj(a[i]))!=null) {
			document.MM_sr[j++]=x; 
			if(!x.oSrc) x.oSrc=x.src; 
			x.src=a[i+2];
		}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; 
  for (i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; 
	n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x=d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); 
  return x;
}

function validateAndSearch() {
	//var emailPattern=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;		
	var oFrm = document.frmSearch;
	var Search = oFrm.inpSearch.value;

	if (Search.Trim().length == 0) {
		alert("Søgefeltet skal være udfyldt!");
		return false;		
	}
//	oFrm.action += "?Action=send";
	oFrm.submit();
	return true;
}

function IsIe()
{
	var n=navigator.appName
	//alert('n: ' + n);
	//var ns=(n=="Netscape")
	var ie=(n=="Microsoft Internet Explorer")
	
	if (ie) return true
		else return false;
}

function WriteCSSInclude(Path)
{
	if (IsIe()) 		
		document.write('<link rel="STYLESHEET" type="text/css" href="' + Path + 'ie.css">');
	else
		document.write('<link rel="STYLESHEET" type="text/css" href="' + Path + 'ns.css">');
}

function wr(s) {
	document.write(s);
}

function gotoPageOnParentWindow2(sPage,sXtraParm) {
	var oTop;
	
	if (window.top) {
		if (window.top != null) {
	
		var oTop = window.top;

		oTop.location = sPage + sXtraParm;

		}
	}
}function gotoPageOnParentWindow(sPage,lSi,lSu,sM,sLpp,sXtraParm) {
	var oTop;
	
	if (window.top) {
		if (window.top != null) {
	
		var oTop = window.top;

		oTop.location = sPage + "?SI=" + lSi + "&SU=" + lSu + "&m=" + sM + "&lpp=" + sLpp + sXtraParm;

		return true;
		}
	}
}function gotoPage(sFormname,sPage,lSi,lSu,sM,sLpp,sXtraParm) {
	var oFrm;
	eval("oFrm = document." + sFormname + ";");
	oFrm.action = sPage + "?SI=" + lSi + "&SU=" + lSu + "&m=" + sM + "&lpp=" + sLpp + sXtraParm;
	oFrm.submit();
	return true;
}function switch2className(Item,classname) {	if (Item) {		getElement( Item ).className = classname;//		document.getElementById(Item).className = classname;
	}}function switch2CssClass(id,classname) {	if (id) {		id.className = classname;
	}}function makevisible(Item) {	if (Item) {		getElement( Item ).style.visibility = 'visible';//		document.getElementById(Item).style.visibility = 'visible';		
	}}function makehidden(Item) {	if (Item) {		getElement( Item ).style.visibility = 'hidden';//		document.getElementById(Item).style.visibility = 'hidden';
	}}

function NewWindow (mypage, myname, w, h) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ', scrollbars=yes, resizable=yes';
	if (myname == ''){ myname = '_blank'}
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function startBrowser(page) {
	
  var s = "newwindow = window.open(page,'ekvator','screenX=0,left=0,screenY=0,top=0,width=" + 
			(screen.width-5) + ",height=" + (screen.height-5) + 
			",menubar=no,resizable=yes,titlebar=no,alwaysRaised=yes,status=no,scrollbars=no,fullscreen=0');";
  eval(s); 
  if (document.layers) 
   {
  	setTimeout('newwindow.focus()',20);
   }
   else
   {
  	newwindow.focus();	
   }
}

function trim_string() {
	var ichar, icount;
	var strValue = this;
	ichar = strValue.length - 1;
	icount = -1;
	while (strValue.charAt(ichar)==' ' && ichar > icount)
		--ichar;
	if (ichar!=(strValue.length-1))
		strValue = strValue.slice(0,ichar+1);
	ichar = 0;
	icount = strValue.length - 1;
	while (strValue.charAt(ichar)==' ' && ichar < icount)
		++ichar;
	if (ichar!=0)
		strValue = strValue.slice(ichar,strValue.length);
	return strValue;
}
// Extend the string object to include a trim function
String.prototype.Trim = trim_string;

function insertML2Data(ix) {
	var elem = getElement( "MenuLevel2" );
	if (elem) {
		elem.innerHTML = MenuLevel2Data[ix];
	}
}

function restoreML2Data() {
	var elem = getElement( "MenuLevel2" );
	if (elem) {
		elem.innerHTML = oldMenuLevel2Data;
	}
}

function getElement( nameStr ) {
  if ( document.getElementById ) return document.getElementById( nameStr ); // DOM
  if ( document.all ) return document.all[ nameStr ];  // IE4
  return null;  // sorry, no NS4.
}; //end getElement( string ) -> HTML element

function getColWidth(minColWidth,centerWidth,minPageWidth) {
	var colWidth = Math.round(((getPageWidth(minPageWidth) - centerWidth)/2) - 0.5);
	if (colWidth > minColWidth) {
		return colWidth;
	}
	else return minColWidth;
}

function getPageWidth(minWidth) {
	var windowWidth = Math.round((getWindowWidth()/2) - 0.5) * 2;
//	var windowWidth = getWindowWidth();
	if (windowWidth > minWidth) {
		return windowWidth;
	}
	else return minWidth;
}

function getWindowWidth() {
	// determine current document window width
	var iWinWidth;
	if (window.innerWidth) { // NS4, NS6 and Opera
		iWinWidth = window.innerWidth;
		}
	else if (document.documentElement && document.documentElement.clientWidth) { // IE6 in standards compliant mode
		iWinWidth = document.documentElement.clientWidth; 
		}
	else if (document.body) { // IE4+
		iWinWidth = document.body.clientWidth; 
		}
	else {return 0;}

	return iWinWidth;
}

function getPageHeight(minHeight) {
	var windowHeight = Math.round((getWindowHeight()/2) - 0.5) * 2;
	if (windowHeight > minHeight) {
		return windowHeight;
	}
	else return minHeight;
}

function getWindowHeight() {
	// determine current document window height
	var iWinHeight;
	if (window.innerHeight) { // NS4, NS6 and Opera
		iWinHeight = window.innerHeight;
		}
	else if (document.documentElement && document.documentElement.clientHeight) { // IE6 in standards compliant mode
		iWinHeight = document.documentElement.clientHeight; 
		}
	else if (document.body) { // IE4+
		iWinHeight = document.body.clientHeight; 
		}
	else {return 0;}

	return iWinHeight;
}

function getBannerHeight(minBannerHeight,bodyHeight,minPageHeight) {
	var bannerHeight = Math.round(((getPageHeight(minPageHeight) - bodyHeight)/2) - 0.5);
	if (bannerHeight > minBannerHeight) {
		return bannerHeight;
	}
	else return minBannerHeight;
}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

// PreloadImages
function PreloadImages() 
{
	var d = document; 
	if (d.images) { 
	if(!d._p) d._p = new Array();
	var i, j=d._p.length, a=PreloadImages.arguments; 
	for (i=0; i<a.length; i++)
		if (a[i].indexOf("#") != 0) {
    		d._p[j] = new Image; 
    		d._p[j++].src = a[i];
		}
	}
}

// Waits ms milliseconds
function wait(ms)
{
	if (ms > 0) setTimeout('wait(0)', ms);
}
