// JavaScript Document

function emailvalidation(entered, alertbox)
   {
     with (entered)
     {
       apos=value.indexOf("@");
       dotpos=value.lastIndexOf(".");
       lastpos=value.length-1;
       if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2) 
       {  if (alertbox) 
          { alert(alertbox);} 
          return false;
       }
       else {return true;}
     }
   }


   function emptyvalidation(entered, alertbox)
   {
     with (entered)
     {
       if (value==null || value=="")
       { if (alertbox!="") 
         {alert(alertbox);} 
         return false;
       }
       else {return true;}
     }
   }
   
   function check(thisform)
   {
     with (thisform)
     {
       if (emptyvalidation(emailadres,"Vergeet niet je emailadres in te vullen !")==false) 
       { emailadres.focus(); 
         return false;
       }
       else 
       { if (emailvalidation(emailadres,"Ongeldig emailadres ingevuld !")==false) 
         { emailadres.focus(); 
           return false;
         }
         else 
         { 
           return true;
         }
       }
     }
   }

  function checker(thisform)
  {

    with (thisform)
    {
       if (emptyvalidation(naam,"Vergeet niet je naam in te vullen.")==false) { naam.focus(); return false;};

       if (emptyvalidation(plaats,"Vergeet niet je woonplaats in te vullen.")==false) { plaats.focus(); return false;};

       emailadres.value = emailadres.value.replace(" ", "");
       if (emptyvalidation(emailadres,"Vergeet niet je e-mailadres in te vullen.")==false) {
         emailadres.focus(); return false;
       } else {
           if (emailvalidation(emailadres,"Vul een geldig e-mailadres in.")==false) { emailadres.focus(); return false;}
       }

       if (emptyvalidation(idee,"Vergeet niet je idee/suggestie in te vullen.")==false) { idee.focus(); return false;};

    };

    return true;
  };
  
  function checkerCamping(thisform)
  {

    with (thisform)
    {
       	if (emptyvalidation(naam,"Vergeet niet je naam in te vullen.")==false) { naam.focus(); return false;};

       	if (emptyvalidation(adres,"Vergeet niet je adres in te vullen.")==false) { adres.focus(); return false;};
		
		postcode.value = postcode.value.replace(" ", "");
		if (emptyvalidation(postcode,"Vergeet niet je postcode in te vullen.")==false) 
		{
			postcode.focus(); return false;
		}
		else
		{
			var re=RegExp("^[0-9][0-9][0-9][0-9] ?[A-Z][A-Z]$","gi");
			if(!re.test(postcode.value))
			{
				alert("Vul een geldige postcode in (1234AB)");
				postcode.focus(); return false;
			}
		}
		
       	if (emptyvalidation(plaats,"Vergeet niet je woonplaats in te vullen.")==false) { plaats.focus(); return false;};
		 
		emailadres.value = emailadres.value.replace(" ", "");
		if (emptyvalidation(emailadres,"Vergeet niet je e-mailadres in te vullen.")==false) {
		 emailadres.focus(); return false;
		} else {
		   if (emailvalidation(emailadres,"Vul een geldig e-mailadres in.")==false) { emailadres.focus(); return false;}
		}
		
		if (emptyvalidation(idee,"Vergeet niet je idee/suggestie in te vullen.")==false) { idee.focus(); return false;};

    };

    return true;
  };
