// JavaScript Document

var Svar_string = ""

function flexform(tjek){
	send_url="/css/flexform.asp"
	if (tjek == "" || tjek == undefined){tjek = "testform";}
	if(eval(tjek+"()")){
		if(document.MailForm._confirm){
			if(confirm(document.MailForm._confirm.value)){sendud(send_url);}
		}else{
			sendud(send_url);
		}
	}else{
		if(document.MailForm._alert){alert(document.MailForm._alert.value+" \n"+Svar_string);}
	}

}

function testform(){
	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 landing(){
	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 sendud(send_url){
	document.MailForm.action=send_url;
	window.setTimeout('outrun();',200);
}

function outrun(){
	document.MailForm.submit();
}

function MailCheck(email) {
	var tx = /^[\w\.æ.ø.å.-]+@[\w\.æ.ø.å.-]+\.\w+\w+$/i;
	return tx.test(email)
}

function alertColor(navn){
	document.getElementById(navn).className = 'FeldErr';
	timer = setTimeout("document.getElementById('"+navn+"').className = 'FeldOK';",5000);
};

