function add_one(id, flag){
  if (flag == true){
   document.getElementById('input_'+id).value = 1;
  } else {
   document.getElementById('input_'+id).value = 0;
  }
}

function clean_checkbox(id){
  if (document.getElementById('input_'+id).value == 0) {
    document.getElementById('checkbox_'+id).checked = false;
  }
}

function set_send_data(flag){
  if (flag){  
    document.getElementById('email_send_from').value = document.getElementById('email').value; 
    document.getElementById('email_send_name').value = document.getElementById('first_name').value;  
  
    document.getElementById('send_to_aweber').submit();  
 }   
}

function check(registration)
{
  
        if (document.registration.confirm_order.checked == false)
				  {
					   alert("Je moet eerst het product selecteren en daaronder de bestelling bevestigen.");
					   document.registration.confirm_order.focus();
						send_flag = false;
            return false;
				  }
          			     
			if (document.registration.last_name.value <= 0)
  		{
				 	alert("Vul je achternaam in.");
					document.registration.last_name.focus();
          send_flag = false;     
					return false;
			} 
				
			
			if ((document.registration.first_name.length < 2) || (document.registration.first_name.length > 50))
			{
				   error = "The Name is the wrong length.\n";
				   document.registration.first_name.focus();
				   send_flag = false;
				   return false;
    	}                         

/*   	                    
      var iChars = "' '";		
  		for (var i = 0; i < document.registration.first_name.value.length; i++) 
			{
				if (iChars.indexOf(document.registration.first_name.value.charAt(i)) != -1) {
				alert ("Your Name has special character");
				return false;
				}
 			}
      	
				
			if (document.registration.dob.value<=0)
  				{
				 	alert("Please Enter Date of Birth. ");
					document.registration.dob.focus();
					return false;
			    }					 

			if (document.registration.dob.checked == false)
				  {
					   alert("Je moet akkoord gaan met de algemene voorwaarden en minstens 18 jaar zijn om te kunnen bestellen.");
					   document.registration.dob.focus();
						return false;
				  }		
*/				
        if (document.registration.address.value <= 0)
  				{
				 	alert("Vul je adres in. ");
					document.registration.address.focus();
					send_flag = false;
					return false;
			    }	
			
      	if (document.registration.postcode.value <= 0)
  				{
				 	alert("Vul de postcode in. ");
					document.registration.postcode.focus();
					send_flag = false;
					return false;
			    }	

    		if (document.registration.city.value<=0)
  				{
				 	alert("Vul de plaats in. ");
					document.registration.city.focus();
					send_flag = false;
					return false;
			    }	

         if (document.registration.country_id.value < 1)
  				{
				 	alert("Vul het land in. ");
					document.registration.country_id.focus();
					send_flag = false;
					return false;
			    }	
				 
         if (document.registration.country.value < 1)
  			 {
				 	alert("Vul het land in. ");
					document.registration.country.focus();
					send_flag = false;
					return false;
			   }	
				
				 	  
			// Email Validation
				if (document.registration.email.value<=0)
				  {
					   alert("Vul je e-mail adres in.");
					   document.registration.email.focus();
					   send_flag = false;
						return false;
				  }
				var emailStr = document.registration.email.value;
				if(document.registration.email.value.length >= 1)
				{
						var emailPat = 	/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3})$/;
	
						var matchArray = emailStr.match(emailPat);
						if (matchArray == null) 
						{
							alert("Je emailadres lijkt onjuist. Controleer het adres en vul dit opnieuw in.");
							document.registration.email.focus();
							return false;
						}
	
				}
				
				if (document.registration.email1.value<=0)
				{
					 alert("Vul nogmaals je e-mail adres in.");
				     document.registration.email1.focus();
				     send_flag = false;
				      return false;
			    }  
				 if (document.registration.email.value !=document.registration.email1.value)
				 {
						 alert("De twee e-mail adressen zijn niet gelijk. Controleer deze svp.");
						 document.registration.email1.focus();
						 send_flag = false;
						 return false;
				 }	
				
				
				
	
	
			// Password Validation
				 if (document.registration.phone.value<=0)
 				 {
					   alert("Vul je telefoonnummer in.");
				 	   document.registration.phone.focus();
				 	   send_flag = false;
				       return false;
			     }   
	  			if (document.registration.agree.checked == false)
				  {
					   alert("Je moet onze algemene voorwaarden accepteren.");
					   document.registration.agree.focus();
					   send_flag = false;
						return false;
				  }

return true;
} 
