function checkEmail(stringToTest) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(stringToTest)){
		return true;
	} else {
		return false;
	}
}

function onSubmitApplyJob() {
	try {
		var text = "";
		var focus = "";
		document.getElementById("submit").disabled = "disabled";

		jobtitle = document.forms.jobForm.jobTitle;
		if (jobtitle.options[jobtitle.selectedIndex].value == "") {
			text += "\r\nDu har ikke valgt hvilket stilling du s\u00F8ger";
			if (focus == "") { focus = ""; }
		}
		if (document.forms.jobForm.fullName.value.length < 5) {
			text += "\r\nDu har ikke udfyldt dit navn";
			if (focus == "") { focus = "fullName"; }
		}
		if (document.forms.jobForm.address.value.length < 5) {
			text += "\r\nDu har ikke udfyldt din adresse";
			if (focus == "") { focus = "address"; }
		}
		if (document.forms.jobForm.city.value.length < 3) {
			text += "\r\nDu har ikke udfyldt dit postnr. og by";
			if (focus == "") { focus = "city"; }
		}
		if (document.forms.jobForm.phoneNum.value.length < 8) {
			text += "\r\nDu har ikke udfyldt dit telefonnummer";
			if (focus == "") { focus = "phoneNum"; }
		}
		if (!checkEmail(document.forms.jobForm.email.value)) {
			text += "\r\nDu har ikke udfyldt din email";
			if (focus == "") { focus = "email"; }
		}
		if (document.forms.jobForm.birthday.value.length < 5) {
			text += "\r\nDu har ikke udfyldt din f\u00F8dselsdag";
			if (focus == "") { focus = "birthday"; }
		}

		if (text != "") {
			document.getElementById("submit").disabled = '';
			if (focus != "") {
				var y = eval('document.forms.jobForm.' + focus);
				y.select();
				y.focus();
			}
			alert("Der er f\u00F8lgende fejl, som skal rettes inden du kan gemme:\r\n" + text)
			return false
		} else {
			return true
		}
	} catch (e) {
		return false;
	}
}

function onSubmitEmailNewsletter() {
	try {
		var text = "";
		var focus = "";

		if (document.forms.form1.RecipientName.value.length < 2) {
			text += "\r\nDu har ikke udfyldt dit navn";
			if (focus == "") { focus = "RecipientName"; }
		}
		if (!checkEmail(document.forms.form1.RecipientEmail.value)) {
			text += "\r\nDu har ikke udfyldt din email";
			if (focus == "") { focus = "RecipientEmail"; }
		}

		if (text != "") {
			if (focus != "") {
				var y = eval('document.forms.form1.' + focus);
				y.select();
				y.focus();
			}
			alert("Der er f\u00F8lgende fejl, som skal rettes inden du kan gemme:\r\n" + text)
			return false
		} else {
			return true
		}
	} catch (e) {
		return false;
	}
}

function onSubmitNetShop() {
	try {
		var text = "";
		var focus = "";
		if (document.forms.form1.Navn.value.length == 0){
			text += "\r\nDu skal udfylde feltet firmanavn";
			if (focus == "") { focus = "Navn"; }
		}
		if (document.forms.form1.att.value.length == 0){
			text += "\r\nDu skal udfylde feltet attention";
			if (focus == "") { focus = "att"; }
		}
		if (document.forms.form1.kundenr.value.length == 0){
			text += "\r\nDu skal udfylde feltet kundenr";
			if (focus == "") { focus = "kundenr"; }
		}

		if (text != "") {
			if (focus != "") {
				var y = eval('document.forms.form1.' + focus);
				y.select();
				y.focus();
			}
			alert("Der er f\u00F8lgende fejl, som skal rettes inden du kan gemme:\r\n" + text)
			return false
		} else {
			return true
		}
	} catch (e) {
		return false;
	}
}

function onSubmitNewCustomer() {
	try {
		var text = "";
		var focus = "";
		if (document.forms.form1.Navn.value.length == 0){
			text += "\r\nDu skal udfylde feltet firmanavn";
			if (focus == "") { focus = "Navn"; }
		}
		if (document.forms.form1.att.value.length == 0){
			text += "\r\nDu skal udfylde feltet attention";
			if (focus == "") { focus = "att"; }
		}
		if (document.forms.form1.adresse.value.length == 0){
			text += "\r\nDu skal udfylde feltet adresse";
			if (focus == "") { focus = "adresse"; }
		}
		if (document.forms.form1.postby.value.length == 0){
			text += "\r\nDu skal udfylde feltet postnummer og by";
			if (focus == "") { focus = "postby"; }
		}
		if (document.forms.form1.telefon.value.length == 0){
			text += "\r\nDu skal udfylde feltet telefonnummer";
			if (focus == "") { focus = "telefon"; }
		}		
		if (document.forms.form1.spisning.value.length == 0){
			text += "\r\nDu skal udfylde feltet antal bespisninger";
			if (focus == "") { focus = "spisning"; }
		}
		if (text != "") {
			if (focus != "") {
				var y = eval('document.forms.form1.' + focus);
				y.select();
				y.focus();
			}
			alert("Der er f\u00F8lgende fejl, som skal rettes inden du kan gemme:\r\n" + text)
			return false
		} else {
			return true
		}
	} catch (e) {
		return false;
	}
		
}

function onLoadNewCustomer() {
	document.forms.form1.Navn.focus()
}	

function mail (initialer, domaene) {
	window.location='mailto:'+initialer+'@'+domaene;
}