

// Checks for Contact Form

function sendContactForm(){
	var msg = "";
	String(document.forms['contact'].naam.value)=="" ? msg += "- Naam\n" : "";
	String(document.forms['contact'].emailadres.value)=="" ? msg += "- Emailadres\n" : "";
	if (msg != ""){
		msg = "Vul eerst onderstaande velden in:\n\n" + msg + "\nen probeer het daarna opnieuw.";
		alert (msg);
	}
	else{
		document.forms['contact'].submit();
	}
}


function CheckEmailaddress(ea){
	// assume address is valid
	valid = true;
	ea = ea.toLowerCase();

	// check email address syntax
	if(ea == null) valid = false;
	else if(ea.indexOf("@") < 2) valid = false;
	else if(ea.indexOf("@") != ea.lastIndexOf("@")) valid = false;
	else if(ea.length - ea.lastIndexOf(".") < 3) valid = false;
	else if(ea.substr(ea.indexOf("@")+1,ea.length-1).indexOf(".") < 2) valid = false;

	// make sure the last set set of chars only contain alpha chars
	s = ea.substr(ea.lastIndexOf(".")+1,ea.length-1);
	for(i = 0 ; i < s.length ; i++){
		if(s.charCodeAt(i) < 97 || s.charCodeAt(i) > 122) valid = false;
	}

	// make sure the chars before the @ are valid (charCodes 33-57,65-90,95,97-122)
	s = ea.substr(0,ea.indexOf("@"));
	for(i = 0 ; i < s.length ; i++){
		c = s.charCodeAt(i);
		if(c == 95 || (c >= 33 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122)) ;
		else {
			valid = false;
			break;
		}
	} 
	if (valid == false){
	msg = "Vul alstublieft een geldig e-mail adres in!";
		alert (msg);
	}
}



