/*------------Formvalidation JS by MaO---------*/
function toonFout(foutboodschap) {
      if (foutboodschap != "") {
	    alert(foutboodschap);
	  }
   }

//////////TEST NAAM////////////////
   function testvoornaam() {
     if (document.contactform.voornaam.value == "") {
	     document.getElementById('voornaam').style.backgroundColor = "#FF33CC";
	     return " - geen voornaam ingevuld\n";
	 }
	 else
	     document.getElementById('voornaam').style.backgroundColor = "#CCCCCC";
	    return "";
   }
   
      function testachternaam() {
     if (document.contactform.achternaam.value == "") {
	     document.getElementById('achternaam').style.backgroundColor = "#FF33CC";
	     return " - geen achternaam ingevuld\n";
	 }
	 else
	     document.getElementById('achternaam').style.backgroundColor = "#CCCCCC";
	    return "";
   }
   
      function teststraat() {
     if (document.contactform.straat.value == "") {
	     document.getElementById('straat').style.backgroundColor = "#FF33CC";
	     return " - geen straat ingevuld\n";
	 }
	 else
	     document.getElementById('straat').style.backgroundColor = "#CCCCCC";
	    return "";
   }
   
      function testnummer() {
     if (document.contactform.nummer.value == "") {
	     document.getElementById('nummer').style.backgroundColor = "#FF33CC";
	     return " - geen nummer ingevuld\n";
	 }
	 else
	     document.getElementById('nummer').style.backgroundColor = "#CCCCCC";
	    return "";
   }
   
      function testpostcode() {
     if (document.contactform.postcode.value == "") {
	     document.getElementById('postcode').style.backgroundColor = "#FF33CC";
	     return " - geen postcode ingevuld\n";
	 }
	 else
	     document.getElementById('postcode').style.backgroundColor = "#CCCCCC";
	    return "";
   }
   
      function testgemeente() {
     if (document.contactform.gemeente.value == "") {
	     document.getElementById('gemeente').style.backgroundColor = "#FF33CC";
	     return " - geen gemeente ingevuld\n";
	 }
	 else
	     document.getElementById('gemeente').style.backgroundColor = "#CCCCCC";
	    return "";
   }
   
      function testtel() {
     if (document.contactform.tel.value == "") {
	     document.getElementById('tel').style.backgroundColor = "#FF33CC";
	     return " - geen telefoonnummer ingevuld\n";
	 }
	 else
	     document.getElementById('tel').style.backgroundColor = "#CCCCCC";
	    return "";
   }
         function testfax() {
     if (document.contactform.fax.value == "") {
	     document.getElementById('fax').style.backgroundColor = "#FF33CC";
	     return " - geen faxnummer ingevuld\n";
	 }
	 else
	     document.getElementById('fax').style.backgroundColor = "#CCCCCC";
	    return "";
   }
   
      function testbericht() {
     if (document.contactform.bericht.value == "") {
	     document.getElementById('bericht').style.backgroundColor = "#FF33CC";
	     return " - geen bericht toegevoegd\n";
	 }
	 else
	     document.getElementById('bericht').style.backgroundColor = "#CCCCCC";
	    return "";
   }
   //////////////////////////
   
   
       
    function testemail() {
     if (document.contactform.email.value == "") {
	     document.getElementById('email').style.backgroundColor = "#FF33CC";
	     return " - geen E-mailadres ingevuld\n";
	 }
	 else
	     document.getElementById('email').style.backgroundColor = "#CCCCCC";
	    return "";
   }
    
 //////////////////////////////////////////////////////////
 //////////////Mailvalidatie///////////////////////////////
 //////////////////////////////////////////////////////////  
   
   function mailValidatie(name, color){
	 
if(document.contactform.email.value.length == ""){
	document.getElementById('email').style.backgroundColor = "#FF33CC";	
	return " - geen correct e-mailadres ingevuld\n";
		 } 

atteken = document.contactform.email.value.indexOf("@")
puntteken = document.contactform.email.value.lastIndexOf(".")

	if (atteken<1||puntteken-atteken<2){
	document.getElementById('email').style.backgroundColor = "#FF33CC";
	return " - geen correct e-mailadres ingevuld\n";
	}
	else {
	 document.getElementById('email').style.backgroundColor = "#CCCCCC";
	return "";
	}
}
   
////////////////////////
////////////////////////
/////alles testen///////
////////////////////////
 function testAlles() {
      var fout = testvoornaam() + testachternaam() + testgemeente() + testtel() + mailValidatie() + testbericht();
	  if (fout == "") {
	      return true;
	  }
	  else {
	      alert("Gelieve het formulier volledig in te vullen:\n" + fout);
		  return false;
	  }
   }   
