// JavaScript Document
/* Contact Us Form ------------------ */

function validContact(contactForm) {
 	
   	/*---Name---------------------------------*/
  	if (contactForm.naam.value == '') {
		alert("Vul uw naam in a.u.b.");
		contactForm.naam.focus();
		return false;
	}

	if (contactForm.naam.value == 'Naam:'){
		alert("Vul uw naam in a.u.b.");
		contactForm.naam.focus();
		return false;
	}
	/*---Name---------------------------------*/
	
	
	
	/*---Email--------------------------------*/	
	if (contactForm.email.value == '') {
		alert("Vul uw email adres in a.u.b.");
		contactForm.email.focus();
		return false;
	}

	if (contactForm.email.value == 'Email:') {
		alert("Vul uw email adres in a.u.b.");
		contactForm.email.focus();
		return false;
	}
	
	if (!validEmail(contactForm.email.value)) {
		contactForm.email.focus();
		return false;
	}
	/*---Email--------------------------------*/
	
	

	/*---Tel----------------------------------*/	
	if (contactForm.tel.value == '') {
		alert("Vul uw telefoonnummer in a.u.b.");
		contactForm.tel.focus();
		return false;
	}

	if (contactForm.tel.value == 'Tel:'){
		alert("Vul uw telefoonnummer in a.u.b.");
		contactForm.tel.focus();
		return false;
	}
	
	if (!validNum(contactForm.tel.value)){
		alert("Vul uw telefoonnummer a.u.b. in zonder");
		contactForm.tel.focus();
		return false;
	}
	/*---Tel----------------------------------*/
	
	
	
	/*---bericht------------------------------*/
  	if (contactForm.bericht.value == '') {
		alert("Wat is uw bericht?");
		contactForm.bericht.focus();
		return false;
	}

	if (contactForm.bericht.value == 'Bericht:'){
		alert("Wat is uw bericht?");
		contactForm.bericht.focus();
		return false;
	}
	/*---bericht------------------------------*/
	

	return true;

	

}


function validValueScan(contactForm) {
	
  	if (contactForm.voorletters.value == '') {
		alert("Vul uw voorletters & naam in a.u.b.");
		contactForm.voorletters.focus();
		return false;
	}
	
	if (contactForm.functie.value == '') {
		alert("Vul uw functienaam in a.u.b.");
		contactForm.functie.focus();
		return false;
	}
	
	if (contactForm.postadres.value == '') {
		alert("Vul uw postadres in a.u.b.");
		contactForm.postadres.focus();
		return false;
	}
	

	if (contactForm.postcode.value == '') {
		alert("Vul uw postcode in a.u.b.");
		contactForm.postcode.focus();
		return false;
	}
		
	if (contactForm.plaats.value == '') {
		alert("Vul uw plaatsnaam in a.u.b.");
		contactForm.plaats.focus();
		return false;
	}
	

	if (contactForm.telefoonnummer.value == '') {
		alert("Vul uw telefoonnummer in a.u.b.");
		contactForm.telefoonnummer.focus();
		return false;
	}
	
	if (!validNum(contactForm.telefoonnummer.value)){
		alert("Vul uw telefoonnummer a.u.b. in zonder");
		contactForm.telefoonnummer.focus();
		return false;
	}

	if (contactForm.email.value == '') {
		alert("Vul uw email adres in a.u.b.");
		contactForm.email.focus();
		return false;
	}
	
	if (!validEmail(contactForm.email.value)) {
		contactForm.email.focus();
		return false;
	}
	
	if (contactForm.aantal.value == '') {
		alert("Hoeveel exemplaren?");
		contactForm.aantal.focus();
		return false;
	}
	
	
	
	return true;

}



// checks for valid telephone characters

function validNum(telno) {

	var pattern = "0123456789+-)(. ";
	var i = 0;

	do {
		var pos = 0;
		for ( var j = 0 ; j < pattern.length ; j++ )
			if ( telno.charAt(i) == pattern.charAt(j) )
				pos = 1;
		i++;
	}

	while ( pos == 1 && i < telno.length )

	if ( pos == 0 ) return false;
	return true;

}



// check email address pattern
function validEmail(addr) {

	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	if ( !regex.test(addr) ) {
		alert("Vul een volledig email adres in a.u.b.");
		return false;
	}
	return true;
}
