// JavaScript Document

var Svar_string = ""

function flexform(alarm){
	send_url="/css/flexform.asp"
	if(testform()){
		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.notat.value.length <= 1){ Re = false; alertColor("notat"); };
	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);
};

