
			
var ie = navigator.appName.indexOf("Microsoft") != -1;
var mac = navigator.appVersion.indexOf("Mac") != -1
var dom = document.getElementById ? true:false;
var nn4 = document.layers ? true:false;
var width;
var height;
var fullVersion  = 0; 
var majorVersion = 0;
var nAgt = navigator.userAgent;

if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
	fullVersion  = parseFloat(nAgt.substring(verOffset+5));
	majorVersion = parseInt(''+fullVersion);
}

function inet_resize() {
	if (ie) {
		height = document.body.clientHeight;
		width = document.body.clientWidth;
	} else {
		width = window.innerWidth;
		height = window.innerHeight;
	}
	
	cheight = height-155;
	
	if (cheight < inet_content_minheight) {
		cheight = inet_content_minheight;
	}
	if (cheight > inet_content_maxheight)
	{
		cheight = inet_content_maxheight;
	}
	document.getElementById("inet_content").style.height = cheight + "px";
	document.getElementById("inet_prod_area").style.height = (cheight - 20) + "px";
	
}

function inet_checkSize() {
	if (ie) {
		cwidth = document.body.clientHeight;
		cheight = document.body.clientWidth;
	} else {
		cwidth = window.innerWidth;
		cheight = window.innerHeight;
	}

   if (width != cwidth) {
	  inet_resize();
   } else if (height != cheight) {
	  inet_resize();
   }
   
   window.setTimeout( "inet_checkSize()", 500);
}

function inet_resize_init() {
	if ((mac) && (!nn4)) {
		width = window.innerWidth;
		height = window.innerHeight;
		inet_resize()
		window.setTimeout( "inet_checkSize()", 500);
	} else {
		inet_resize();
	}
}


function inet_open_win() {
	if (ua["dom"]) {
		var url = "";
		var target = "";

		var attributes = "";


		if (arguments.length > 0) {
			url = arguments[0];
		}

		//Target attribute:
		if (arguments.length > 1) {
			target = arguments[1];
		}
			
		//Optional attributes:
		if (arguments.length > 2) {
			attributes = arguments[2];
		}
	
		win = window.open(url, target, attributes);
		win.focus();
		return false;
	}
}


function inet_pop_win(pageToLoad, winName, width, height, center, ramme) {
	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
		}
	width = width + ramme * 2
	args = "width=" + width + "," 
	+ "height=" + height + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=0,"
	+ "scrollbars=0,"
	+ "status=0," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "left=" + xposition + ","
	+ "top=" + yposition;

	window.open(pageToLoad+"&ramme="+ramme,winName,args );
}


function inet_pop_cal(pageToLoad, winName, width, height, center) {
	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
		}

	args = "width=" + width + "," 
	+ "height=" + height + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=0,"
	+ "scrollbars=0,"
	+ "status=0," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "left=" + xposition + ","
	+ "top=" + yposition;

	window.open(pageToLoad,winName,args );
}


function toggleMenuLink(obj) {
	parobj = obj.parentNode;

	parclasses = parobj.className.split(" ");

	for (i=0; i<parclasses.length; i++) {
		if (parclasses[i] == "closed") {
			parclasses[i] = "open";
			parobj.className = parclasses.join(" ");
			i = parclasses.length;
		}
		else if (parclasses[i] == "open") {
			parclasses[i] = "closed";
			parobj.className = parclasses.join(" ");


			i = parclasses.length;


		}
	}

	return false;
}


/**** INIT ****/

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != "function") {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function checkHpbkFrm() {
	missinginfo = "";
	
	if (document.hpb.name.value == "") {
	missinginfo += "\n     -  Navn";
	}
	if (document.hpb.addr.value == "") {
	missinginfo += "\n     -  Adresse";
	}
	var r, re;
	var s = document.hpb.zip.value;
	re = /\D/g;    //Create regular expression pattern.
	r = s.match(re);
	//if ((document.hpb.zip.value == "") || 
	//(r != null)) {
	//missinginfo += "\n     -  Postnr.";
	//}
	if (document.hpb.city.value == "") {
	missinginfo += "\n     -  By";
	}
	if ((document.hpb.mail.value == "") || 
	(document.hpb.mail.value.indexOf('@') == -1) || 
	(document.hpb.mail.value.indexOf('.') == -1)) {
	missinginfo += "\n     -  Email";
	}
	if (document.hpb.tele.value == "") {
	missinginfo += "\n     -  Tlf.";
	}
	if (document.hpb.date.value == "" || document.hpb.date.value == "Dato") {
	missinginfo += "\n     -  Dato";
	}
	if (document.hpb.hour.value == "") {
	missinginfo += "\n     -  Time";
	}
	if (document.hpb.hptype_id.value == "") {
	missinginfo += "\n     -  Type";
	}
	if (missinginfo != "") {
	missinginfo = "Der er fejl i \n" + 
	missinginfo + "\n\nRet fejl & tryk  Send  igen ";
	alert(missinginfo);
	return false;
	}
	else {
		document.hpb.btn_submit.disabled=true;
		return true;
	}
}

function checkCustFrm() {
	missinginfo = "";
	
	if (document.form_eshptrans.eshpcustomer_name.value == "") {
	missinginfo += "\n     -  Navn";
	}
	if (document.form_eshptrans.eshpcustomer_address1.value == "") {
	missinginfo += "\n     -  Adresse";
	}
	//var r, re;
	//var s = document.form_eshptrans.eshpcustomer_zip.value;
	//re = /\D/g;    //Create regular expression pattern.
	//r = s.match(re);
	//if ((document.form_eshptrans.eshpcustomer_zip.value == "") || 
	//(r != null)) {
	//missinginfo += "\n     -  Postnr.";
	//}
	if (document.form_eshptrans.eshpcustomer_city.value == "") {
	missinginfo += "\n     -  By";
	}
					
	if (missinginfo != "") {
	missinginfo = "Der er fejl i \n" + 
	missinginfo + "\n\nRet fejl & tryk  Send  igen ";
	alert(missinginfo);
	return false;
	}
	else return true;
}

function checkEventFrm() {
	missinginfo = "";

	if (document.hpb.durat.value < 1) {
	missinginfo += "\n     -  Timer";
	}

	if (document.hpb.type_id.value == "") {
	missinginfo += "\n     -  Type";
	}

	if (missinginfo != "") {
	missinginfo = "Der er fejl i \n" + 
	missinginfo + "\n\nRet fejl & gem igen ";
	alert(missinginfo);
	return false;
	}
	else return true;
}

function confirmHp() {
	if (document.hpb.state_id.value < 3 || document.hpb.state_id.value == 13) {
		document.hpb.state_id.value = 3;
	}
	document.hpb.conf.value = 1;
	document.hpb.submit();
}

function declineHp() {
	document.hpb.state_id.value = 11;
	document.hpb.decl.value = 1;
	document.hpb.submit();
}

function changedHp() {
	document.hpb.changed.value = 1;
}

function deleteparty(url) {
	if (confirm('Bekræft at du vil slette')) {
		window.location = url;
	}
}

function deleteeshporder(url, invoice_id) {
	if (confirm('Ordren med fakturanr. '+invoice_id+' vil blive slettet permanent! Vil du fortsætte?')) {
		window.location = url;
	}
}

function paytype(id) {
	if (id == 1) {
		document.forms["form_eshptrans"].action = 'https://securepayment.inet-designer.dk/relay2.asp';
	}
	else {
		document.forms["form_eshptrans"].action = 'idd'+id+'.asp';
	}
	
}



function validatepay() {
	var pay = document.getElementById("pay_form");
	var err_mes = "";

	pay.cardnumber.value = pay.cardnumber1.value+pay.cardnumber2.value+pay.cardnumber3.value+pay.cardnumber4.value
	if (pay.cardnumber.value.length!=16) {
		err_mes += "\nFejl i kortnummer"
	} 
	if (pay.cvd.value.length!=3) {
		err_mes += "\nFejl i kontrolcifre"
	}

	if (err_mes!="") {
		alert(err_mes);
		return false
	} else {
		pay.cardnumber1.value = "";
		pay.cardnumber2.value = "";
		pay.cardnumber3.value = "";
		pay.cardnumber4.value = "";
		return true
	}
}

function setcursorpay(i) {
	var pay = document.getElementById("pay_form");
	if (eval("pay.cardnumber"+i).value.length>=4) {
		switch(i) {
			case 1 :
				pay.cardnumber2.focus();
				break;
			case 2 :
				pay.cardnumber3.focus();
				break;
			case 3 :
				pay.cardnumber4.focus();
				break;
			case 4 :
				pay.cvd.focus();
				break;
		}
	}
}

function set_height(diva, divb, offset, styl) {
	var div_a, div_b, div_a_height, div_b_height;
	
	if (document.getElementById(diva) == null || document.getElementById(divb) == null) return;

	div_a = document.getElementById(diva);
	div_b = document.getElementById(divb);
	
	if(div_a.offsetHeight){ 
		div_a_height = div_a.offsetHeight;
	}
	else if(div_a.style.pixelHeight){ 
		 div_a_height = div_a.style.pixelHeight; 
	}
	else return;

	div_b_height = div_a_height - offset;
	
	if (ie && majorVersion == 6) {
		if (styl == 1) {
			div_b_height = div_b_height - 1;
		}
		div_b.style.height = div_b_height+"px";
	} else {
		div_b.style.minHeight = div_b_height+"px";
	}
}


function set_heights(divaa, divbb, offset, c, styl) {
	var div_aa, div_bb;
	for (var i = 1; i <= 10; i++) {
		div_aa = divaa+"_"+ i;
		div_bb = divbb+"_"+ i;
		set_height(div_aa, div_bb, offset, styl);
	}
}

function checkTT() {
	var tt_len = document.ttFrm.tt.value.length;
	var inv_len = document.ttFrm.eshpinvoice_id.value.length;
	if (tt_len != 13) {
		alert("Track & Trace nr. skal være 13 tegn!\nDu har indtastet "+tt_len+" tegn.");
		return false;
	}
	if (inv_len > 0 && inv_len != 5) {
		alert("Faktura nr. skal være 5 tegn!\nDu har indtastet "+inv_len+" tegn.");
		return false;
	}
	else return true;
}

function togglePickup() {
	document.form_eshptrans.eshpcart.value = '';
	document.form_eshptrans.submit();
}

function limitstate(state_id, form_field, list_allow) {
	var arr_allow = list_allow.split(",");
	var sel = form_field;
	var inc_state = sel.value;
	var allow_change = false;

	for (i = 0; i < arr_allow.length; i++) {
		if (arr_allow[i] == inc_state) {
			allow_change = true;
			break;
		}
	}
	
	if (allow_change) {
		sel.value = inc_state;
	}
	else {
		sel.value = state_id;
	}

	return false;

	//alert(cur_state_id+"#"+inc_state_id);
}