// JavaScript Document

var Svar_string = ""

function tjek(send_url){
if(tester(send_url)){
		if(confirm("Send")){sendud(send_url);}
	}else{
		alert("Udfyld felterne: \n"+Svar_string);
	}
}
function tjekform(send_url){
if(testermail(send_url)){
		if(confirm("Send")){sendud(send_url);}
	}else{
		alert("Udfyld felterne: \n"+Svar_string);
	}
}

function sendud(send_url){
	document.MailForm.action=send_url;
	window.setTimeout('outrun();',200);
}

function outrun(){
document.MailForm.submit();
}

function tester(send_url){
	var Re = true
		Svar_string = ""
		if (document.MailForm.Navn.value == ""){Re = false;alertColor("Navn");};
		if ((!MailCheck(document.MailForm.Email.value) && document.MailForm.Email.value != "" ) || (document.MailForm.Email.value == "" && document.MailForm.Telefon.value.length == "")){Re = false;alertColor("Email");};
		if ((document.MailForm.Telefon.value.length <= 6 && document.MailForm.Telefon.value != "" ) || (document.MailForm.Email.value == "" && document.MailForm.Telefon.value.length == "")){Re = false;alertColor("Telefon"); };
		if (document.MailForm.Type0.value.length <= 1){ Re = false; alertColor("Type0"); };
	return Re
}
function testermail(send_url){
	var Re = true
		Svar_string = ""
		if (document.MailForm.Navn.value == ""){Re = false;alertColor("Navn");};
		if (!MailCheck(document.MailForm.Email.value)){Re = false;alertColor("Email");};
		if (document.MailForm.Emne.value == ""){Re = false;alertColor("Emne");};
		if (document.MailForm.Besked.value.length <= 1){ Re = false; alertColor("Besked"); };
	return Re
}

function MailCheck(email) {
	var tx = /^[\w\.æ.ø.å.-]+@[\w\.æ.ø.å.-]+\.\w+\w+$/i;
	return tx.test(email)
}


function alertColor(navn){
	document.getElementById(navn).style.border = 'solid 1px #ff0000';
	document.getElementById(navn).style.background = '#e2bb77';
//	timer = setTimeout("document.getElementById('"+navn+"').style.border = 'solid 1px #807058';",2000);
	timer = setTimeout("document.getElementById('"+navn+"').style.border = 'solid 1px #888888';",5000);
	timer = setTimeout("document.getElementById('"+navn+"').style.background = '#ffffff';",5000);
};

