function controleer(form,boodschap,emailerror){		
	waarde = 1;
	email = 1;
	txtemail = "";
	for(i=0;i<form.length;i++){			
			div = "div" + form.elements[i].name;
			divexist = document.getElementById(div);
			if(divexist != null){
				if(form.elements[i].value == ""){
							document.getElementById(div).style.color = "red";
							waarde = 0;
				}else{
							document.getElementById(div).style.fontWeight = "normal";
							document.getElementById(div).style.color = "black";
				}
			}				
			if(div == "divemailadres"){
					txtemail = form.elements[i].value;
			}
			
	}
		if(txtemail != ""){
			if(check_email(txtemail) == -1){					
				document.getElementById("divemailadres").style.fontWeight = "normal";
				document.getElementById("divemailadres").style.color = "black";
			}else{
				document.getElementById("divemailadres").style.color = "red";					
				alert(emailerror);
				waarde = 2;
				email = 0;
			}
		}

			
		
	if(waarde==1){			
			form.submit();
	}else{
			if( waarde == 0){
			alert(boodschap);
			}
	}
}


function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}	
	} 
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}
