function openprint (file) {
	width = 700;
	height = 500;
	leftmargin = 100;
	topmargin = 50;
	statusbar = "no";
	toolbar = "yes";
	menubar = "yes";
	title = "printing";
    window.open(file,title,'width='+width+',height='+height+',left='+leftmargin+',top='+topmargin+',scrollbars=yes,status='+statusbar+',toolbar='+toolbar+',menubar='+menubar);
}

function openhelp (key) {
	width = 450;
	height = 350;
	leftmargin = 150;
	topmargin = 100;
	statusbar = "no";
	toolbar = "no";
	menubar = "no";
	title = "helpwindow";
	url = "help." + key;
    helpwindow = window.open(url,title,'width='+width+',height='+height+',left='+leftmargin+',top='+topmargin+',scrollbars=yes,status='+statusbar+',toolbar='+toolbar+',menubar='+menubar);
	helpwindow.focus();
}

function opengeneratorhelp (type_id,key) {
	width = 450;
	height = 350;
	leftmargin = 150;
	topmargin = 100;
	statusbar = "no";
	toolbar = "no";
	menubar = "no";
	title = "helpwindow";
	url = "module.php?mod=generator&op=generator_help&type_id=" + type_id + "&key=" + key;
    helpwindow = window.open(url,title,'width='+width+',height='+height+',left='+leftmargin+',top='+topmargin+',scrollbars=yes,status='+statusbar+',toolbar='+toolbar+',menubar='+menubar);
	helpwindow.focus();
}

function showimage(file) {
	if (file) {
		window.open("image_popup.html?file="+ file,"imagepopup","width=400,height=400,left=100,top=100");
	} else {
		return false;
	}
}
		
function cm_bwcheck(){
	//In theory we should use object detection, but this script needs work-arounds for almost every browser...
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent.toLowerCase()
	this.dom=document.getElementById?1:0
	this.ns4=(!this.dom && document.layers)?1:0;
	this.op=window.opera 
	this.moz=(this.agent.indexOf("gecko")>-1 || window.sidebar)
	this.ie=this.agent.indexOf("msie")>-1 && !this.op
	if(this.op){
		this.op5=(this.agent.indexOf("opera 5")>-1 || this.agent.indexOf("opera/5")>-1)
		this.op6=(this.agent.indexOf("opera 6")>-1 || this.agent.indexOf("opera/6")>-1)
		this.op7=this.dom&&!this.op5&&!this.op6 //So all higher opera versions will use it
	}else if(this.moz) this.ns6 = 1
	else if(this.ie){
		this.ie4 = !this.dom && document.all
  	this.ie5 = (this.agent.indexOf("msie 5")>-1)
  	this.ie55 = (this.ie5 && this.agent.indexOf("msie 5.5")>-1)
  	this.ie6 = this.dom && !this.ie4 && !this.ie5 && ! this.ie55
	}
	this.mac=(this.agent.indexOf("mac")>-1)
	this.safari=(this.agent.indexOf("safari")>-1)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.op5 || this.op6 || this.op7)
  this.usedom= this.ns6||this.op7//Use dom creation
  this.reuse = this.ie||this.op7||this.usedom //Reuse layers
  this.px=this.dom&&!this.op5?"px":""
	return this
}
var bw=new cm_bwcheck()

function menuHide(id) {
  if (bw.ie4){
    document.all[id].style.display = 'none';
    return false;
  } else if (bw.dom) {
    document.getElementById(id).style.display = 'none';
    return false;
  }
}

function menuShow(id) {
  if (bw.ie4){
    document.all[id].style.display = '';
    return false;
  } else if (bw.dom) {
    document.getElementById(id).style.display = 'block';
    return false;
  }
}

function menuChange(id,sid) {
  var id = ""+id+"";
  var sid = ""+sid+"";
  var i = 0;
  var s = 0;
  if (bw.ie4) {
    while (document.all['menu'+i]) { 
      if (id == i) {
 	    if (document.all['menu'+i].style.display == '') {
		  menuHide('menu'+i);
		} else {
		  menuShow('menu'+i);
		}
      } else {
		menuHide('menu'+i);
      }
  	  i++;
	}
	if (sid.length > 0) {
	while (document.all['submenu'+s]) { 
	  if (sid == s) {
		if (document.all['submenu'+s].style.display == '') {
		  menuHide('submenu'+s);
		} else {
		  menuShow('menu'+id);	
		  menuShow('submenu'+s);
		}
	  } else {
		menuHide('submenu'+s);
	  }
	  s++;
	}
	}
  } else if (bw.dom) {
    while (document.getElementById('menu'+i)) { 
      if (id == i) {
 	    if (document.getElementById('menu'+i).style.display == '') {
		  menuHide('menu'+i);
		} else {
		  menuShow('menu'+i);
		}
      } else {
		menuHide('menu'+i);
      }
  	  i++;
	}
	if (sid.length > 0) {
    while (document.getElementById('submenu'+s)) { 
      if (sid == s) {
 	    if (document.getElementById('submenu'+s).style.display == '') {
		  menuHide('submenu'+s);
		} else {
		  menuShow('menu'+id);	
		  menuShow('submenu'+s);
		}
      } else {
		menuHide('submenu'+s);
      }
  	  s++;
	}
	}
  }
}

function menuHideAll(id) {
  var i = 1;
  if (bw.ie4) {
    while (document.all['menu'+i]) { 
      menuHide(i);
 	  i++;
	}
  } else if (bw.dom) {
    while (document.getElementById('menu'+i)) { 
      menuHide(i);
	  i++;
    }
  }
}

function changeCase(obj) {
	var temp = obj.value.substring(0,1);
	var temp2 = obj.value.substring(1,obj.value.length);	
	obj.value = temp.toUpperCase() + temp2;
}

// Opens new window for payment
function openpay(mode) {
	if (mode == 1){
		width = 725;
		height = 550;
	} else {
		width = 775;
		height = 550;
	}
	leftmargin = 25;
	topmargin = 25;
	statusbar = "yes";
	toolbar = "no";
	menubar = "no";
	resizable = "yes";
	title = "paywindow";
	paywindow = window.open('./tpl/empty.html',title,'width='+width+',height='+height+',left='+leftmargin+',top='+topmargin+',scrollbars=yes,status='+statusbar+',toolbar='+toolbar+',menubar='+menubar+',resizable='+resizable);
}

function opentracktrace () {
	width = 550;
	height = 350;
	leftmargin = 100;
	topmargin = 100;
	statusbar = "no";
	toolbar = "no";
	menubar = "no";
	title = "winTracknTrace";
    winTracknTrace = window.open('./tpl/blank.html',title,'width='+width+',height='+height+',left='+leftmargin+',top='+topmargin+',scrollbars=yes,status='+statusbar+',toolbar='+toolbar+',menubar='+menubar);
	window.winTracknTrace.focus();
}

function submitform(frm,op) {
	frm.op.value = op;
	frm.submit();
}


function check_decimal(field,name) {
	var reg_dec = /^([0-9,]+)$/;
	var error = false;
	if (!reg_dec.test(field)) {
		alert('Feltet "' + name + '" er ikke udfyldt korrekt. Det må kun indeholdene tallene 0-9 og ,!');
		return false;
	} else {
		return true;
	}
}

function check_num(field,name) {
	var reg_num = /^([0-9]+)$/;
	var error = false;
	if (!reg_num.test(field)) {
		alert('Feltet "' + name + '" er ikke udfyldt korrekt. Det må kun indeholdene tallene 0-9!');
		return false;
	} else {
		return true;
	}
}
	
function check_date(field,name) {
	var reg_date = /^([0-9]{2})+\-([0-9]{2})+\-([0-9]{4})$/;
	var error = false;
	if (!reg_date.test(field)) {
		error = true;
	} else {
		if ((field.substring(0,2) == "00") || (field.substring(0,2) > 31))
			error = true;
		if ((field.substring(3,5) == "00") || (field.substring(3,5) > 12))
			error = true;
		if (field.substring(6,10) < 2000)
			error = true;
	}
	if (error) {
		alert('Feltet "' + name + '" er ikke udfyldt korrekt. Mindst et af følgende kriterier er ikke overholdt:\n\n'+
		  '  - datoen skal være i formatet DD-MM-ÅÅÅÅ\n\n  - DD skal være tal mellem 01 og 31, begge inclusive\n\n'+
		  '  - MM skal være tal mellem 01 og 12, begge inclusive\n\n  - ÅÅÅÅ skal være et tal større end 2000');
		return false;
	} else {
		return true;
	}
}

function check_time(field,name) {
	var reg_time = /^([0-9]{2})+\:([0-9]{2})+\-([0-9]{2}):([0-9]{2})$/;
	var error = false;

	if (!reg_time.test(field)) {
		error = true;
	} else {
		if ((field.substring(0,2) > 24) || (field.substring(6,2) > 24))
			error = true;
		if ((field.substring(3,2) > 59) || (field.substring(8,2) > 59))
			error = true;
	}

	if (error) {
		alert('Feltet "' + name + '" er ikke udfyldt korrekt. Mindst et af følgende kriterier er ikke overholdt:\n\n'+
		  '  - Tidspunktet skal være i formatet TT:MM-TT:MM\n\n  - TT skal være tal mellem 00 og 24, begge inclusive\n\n'+
		  '  - MM skal være tal mellem 00 og 59, begge inclusive');
		return false;
	} else {
		return true;
	}
}


function objHide(id) {
  if (bw.ie4){
    document.all[id].style.display = 'none';
    return false;
  } else if (bw.dom) {
    document.getElementById(id).style.display = 'none';
    return false;
  }
}

function objShow(id,mode) {
  var mode = (mode == undefined) ? 'block' : mode;	
  if (bw.ie4){
    document.all[id].style.display = '';
    return false;
  } else if (bw.dom) {
    document.getElementById(id).style.display = mode;
    return false;
  }
}

// Show confirm box, and redirect.
function confirmgo(url,msg) {
	if (confirm(msg)) {
		window.location.href = url;
	}
}



	function checkJavaSupport() {
		var result = {javaEnabled: false,javaVersion: '',javaVersionOk: false};
		if (typeof navigator != 'undefined' && typeof navigator.javaEnabled != 'undefined')
			result.javaEnabled = navigator.javaEnabled();
		else
			result.javaEnabled = 'unknown';
		if (navigator.javaEnabled() && typeof java != 'undefined') {
			result.javaVersion = java.lang.System.getProperty("java.version");
			if (result.javaVersion > '1.4')
				result.javaVersionOk = true;
			else
				result.javaVersionOk = false;
		}
		return result;
	}

		function loadJavaApplet(uploadURL,successURL,maxFileSize,fileFilterText,errorMsg,language) {
		var javaCheck = checkJavaSupport();
		var javaEnabled = javaCheck.javaEnabled;
		var javaVersion = javaCheck.javaVersion;
		var javaVersionOk = javaCheck.javaVersionOk;
		var maxByteSize = 250;
		var backgroundColor = "#ffffff";
		var fileFilter = fileFilterText + ": pdf";
		var disableDefaultFileFilter = "true";
		var language = (language) ? language : "da";
		var errorMsg = '<span style="color: #cc0000"><br />' + errorMsg + '</span><br /><br />';
		if (bw.ie && javaEnabled) {
			document.writeln(' \
				<applet name="uploadApplet" code="javaatwork.myuploader.UploadApplet.class" archive="myuploader-standard-signed-1.13.jar, labels.jar, labels_da.jar" width="400"  height="250"> \
				<param name="maxFileSize" value="' + maxFileSize + '"> \
				<param name="maxByteSize" value="' + maxByteSize + '"> \
   				<param name="uploadURL" value="' + uploadURL + '"> \
   				<param name="successURL" value="' + successURL + '"> \
   				<param name="backgroundColor" value="' + backgroundColor + '"> \
   				<param name="fileFilter" value="' + fileFilter + '"> \
   				<param name="disableDefaultFileFilter" value="' + disableDefaultFileFilter + '"> \
				<param name="language" value="+ language +"> \
				<param name="iconAdd" value="./powupload/images/pdf.gif"> \
				</applet>');
		} else if (javaEnabled && javaVersionOk) {
			document.writeln(' \
				<applet name="uploadApplet" code="javaatwork.myuploader.UploadApplet.class" archive="myuploader-standard-signed-1.13.jar, labels.jar, labels_da.jar" width="400"  height="250"> \
				<param name="maxFileSize" value="' + maxFileSize + '"> \
				<param name="maxByteSize" value="' + maxByteSize + '"> \
   				<param name="uploadURL" value="' + uploadURL + '"> \
   				<param name="successURL" value="' + successURL + '"> \
   				<param name="backgroundColor" value="' + backgroundColor + '"> \
   				<param name="fileFilter" value="' + fileFilter + '"> \
   				<param name="disableDefaultFileFilter" value="' + disableDefaultFileFilter + '"> \
				<param name="language" value="+ language +"> \
				<param name="iconAdd" value="./powupload/images/pdf.gif"> \
				<param name="showHTTPResponse" value="true"> \
				</applet>');
				
		} else if (bw.mac && bw.safari && javaEnabled) {
			document.writeln(' \
				<applet name="uploadApplet" code="javaatwork.myuploader.UploadApplet.class" archive="myuploader-standard-signed-1.13.jar, labels.jar, labels_da.jar" width="400"  height="250"> \
				<param name="maxFileSize" value="' + maxFileSize + '"> \
				<param name="maxByteSize" value="' + maxByteSize + '"> \
   				<param name="uploadURL" value="' + uploadURL + '"> \
   				<param name="successURL" value="' + successURL + '"> \
   				<param name="backgroundColor" value="' + backgroundColor + '"> \
   				<param name="fileFilter" value="' + fileFilter + '"> \
   				<param name="disableDefaultFileFilter" value="' + disableDefaultFileFilter + '"> \
				<param name="language" value="+ language +"> \
				<param name="iconAdd" value="./powupload/images/pdf.gif"> \
				<param name="showHTTPResponse" value="true"> \
				</applet>');
		} else {
			document.writeln(errorMsg);
		}
	}

	function ZipSearch(Frm,CityField,Country,ZipCode)
	{
		var ZipArray = new Array();
		switch(Country.toLowerCase())
		{
			case "danmark":
				ZipArray = ZipDK;
				break;
			case "grønland":
				ZipArray = ZipGL;
				break;
			case "færøerne":
				ZipArray = ZipFA;
				break;
			default:
				return false;
		}

		if (ZipCode.length > 0)
		{
			var Test = ZipCode.substring(0,1);
			if (Test == "0")
				ZipCode = ZipCode.substring(1);
			
			var City = ZipArray[ZipCode];
			if ((City != null) && (City.length > 0))
			{
				Frm[CityField].value = City;
			}
			else
				Frm[CityField].value = "";
		} 
		else
			return false;
	}

/*
	function loadJavaAppletPOW(uploadURL,successURL,maxFileSize,fileFilterText,errorMsg,language) {
		var javaCheck = checkJavaSupport();
		var javaEnabled = javaCheck.javaEnabled;
		var javaVersion = javaCheck.javaVersion;
		var javaVersionOk = javaCheck.javaVersionOk;
		var maxFileByteSize = 250 * 1000 * 1000;
		var maxTotalByteSize = 1000 * 1000 * 1000;
		var backgroundColor = "#ffffff";
		var fileFilter = fileFilterText + ": pdf";
		var disableDefaultFileFilter = "true";
		var language = (language) ? language : "da";
		var errorMsg = '<span style="color: #cc0000"><br />' + errorMsg + '</span><br /><br />';
		if (javaEnabled) {
			document.writeln(' \
				<applet code="com.elementit.JavaPowUpload.Manager" archive="./powupload/lib/JavaPowUpload.jar, ./powupload/lib/skinlf.jar, ./powupload/lib/commons-logging-1.1.jar, ./powupload/lib/commons-httpclient-3.1-rc1.jar, ./powupload/lib/commons-codec-1.3.jar" \
				width="600" height="400" name="JavaPowUpload" id="JavaPowUpload" mayscript="true" alt="" VIEWASTEXT> \
				<param name="Common.InternationalFile" value="./powupload/localization/Danish_v1.0_10.01.2008.xml"> \
				<param name="Common.ListArea.Row.File.IconUrl" value="./powupload/images/pdf.gif"> \
				<param name="Common.PropertiesFile" value="./powupload/properties.xml" /> \
				<param name="Upload.UploadUrl" value="' + uploadURL + '"> \
				<param name="Common.FinishUrl" value="' + successURL + '"> \
				<param name="Upload.FileFilter.MaxFileCount" value="' + maxFileSize + '"> \
				' + errorMsg + '</applet>');

			/*
			document.writeln(' \
				<applet code="persits.transfer.gui.UploadUI.class" archive="jupload/JUpload.jar" width="600" height="300" name="JUpload" mayscript"> \
				<param name="cabbase" value="jupload/JUpload.cab" /> \
				<param name="UploadURL" value="' + uploadURL + '"> \
				<param name="FinalURL" value="' + successURL + '"> \
				<param name="UseSockets" value="False" /> \
				<param name="MaxFileCount" value="' + maxFileSize + '"> \
				<param name="MaxFileSize" value="' + maxFileByteSize + '"> \
				<param name="MaxTotalSize" value="' + maxTotalByteSize + '"> \
				<param name="Filter1" value="PDF filer (*.pdf)"> \
				<param name="disableDefaultFileFilter" value="' + disableDefaultFileFilter + '"> \
				<param name="Language" value="' + language + '"> \
				<param name="FileIcon1" value="jupload\pdf.gif (pdf)"> \
				' + errorMsg + '</applet>');
			/*
			document.writeln(' \
				<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,2,0" height="250" width="400" type="application/x-java-applet" name="UploadApplet"> \
				<param name="code" value="javaatwork.myuploader.UploadApplet.class" /> \
				<param name="archive" value="myuploader-standard-signed-v13.jar, labels_da.jar" /> \
				<param name="name" value="UploadApplet" /> \
				<param name="uploadURL" value="' + uploadURL + '"> \
				<param name="successURL" value="' + successURL + '"> \
				<param name="maxFileSize" value="' + maxFileSize + '"> \
				<param name="maxByteSize" value="' + maxByteSize + '"> \
				<param name="backgroundColor" value="' + backgroundColor + '"> \
				<param name="fileFilter" value="' + fileFilter + '"> \
				<param name="disableDefaultFileFilter" value="' + disableDefaultFileFilter + '"> \
				<param name="language" value="' + language + '"> \
				<param name="type" value="application/x-java-applet;version=1.4.2"> \
				' + errorMsg + '</object>');
		} else if (javaEnabled && javaVersionOk) {
			document.writeln('<object classid="java:javaatwork.myuploader.UploadApplet.class" \
				type="application/x-java-applet;version=1.4.2" archive="myuploader-standard-signed-v13.jar, labels_da.jar" height="250" width="400" name="UploadApplet"> \
				<param name="name" value="UploadApplet" /> \
				<param name="uploadURL" value="' + uploadURL + '"> \
				<param name="successURL" value="' + successURL + '"> \
				<param name="maxFileSize" value="' + maxFileSize + '"> \
				<param name="maxByteSize" value="' + maxByteSize + '"> \
				<param name="backgroundColor" value="' + backgroundColor + '"> \
				<param name="fileFilter" value="' + fileFilter + '"> \
				<param name="disableDefaultFileFilter" value="' + disableDefaultFileFilter + '"> \
				<!--<param name="language" value="' + language + '">--> \
				<param name="type" value="application/x-java-applet;version=1.4.2"> \
				' + errorMsg + '</object>');
		} else if (bw.mac && bw.safari && javaEnabled) {
			document.writeln(' \
				<applet name="uploadApplet" code="javaatwork.myuploader.UploadApplet.class" archive="myuploader-standard-signed-v13.jar, labels_da.jar" width="400" height="250"> \
				<paam name="uploadURL" value="' + uploadURL + '"> \
				<param name="successURL" value="' + successURL + '"> \
				<param name="maxFileSize" value="' + maxFileSize + '"> \
				<param name="maxByteSize" value="' + maxByteSize + '"> \
				<param name="backgroundColor" value="' + backgroundColor + '"> \
				<param name="fileFilter" value="' + fileFilter + '"> \
				<param name="disableDefaultFileFilter" value="' + disableDefaultFileFilter + '"> \
				<param name="language" value="' + language + '"> \
				' + errorMsg + '</applet>');
		
		} else {
			document.writeln(errorMsg);
		}
	}
	*/