function val(who){
      var alertxt="";
      var selchecked = undefined;
       
      if(who.answer != undefined && who.answer.value=="") alertxt += "- Resposta\n";
       
       
      //Verificação dos radio buttons 
      if(who.selection != undefined){
          selchecked=false;
          $('input[@name=selection]').each(function(){
            if($(this).attr('checked'))selchecked = true;
          });	
      }
      
      if(selchecked == false) alertxt+="- Escolha única\n";
      
      
      //Campos de texto vazios
      if (who.names != undefined && who.names.value=="") alertxt+="- Nome (campo vazio)\n";
      if (who.address != undefined && who.address.value=="") alertxt+="- Morada (campo vazio)\n";
      if (who.cp1 != undefined && who.cp1.value=="" || who.cp2.value=="") alertxt+="- Código Postal (campo 1) (campo vazio)\n";
      if (who.cp2 != undefined && who.cp2.value=="") alertxt+="- Código Postal (campo 2) (campo vazio)\n";
      if (who.city != undefined && who.city.value=="" ) alertxt+="- Localidade (campo vazio)\n";
      if (who.phone != undefined && who.phone.value=="" ) alertxt+="- Telefone (campo vazio)\n";
      if (who.id_c != undefined && who.id_c.value=="" ) alertxt+="- BI (campo vazio)\n";
      if (who.email != undefined && who.email.value=="") alertxt+="- Email (campo vazio)\n";
      if (who.birthdate != undefined && who.birthdate.value=="") alertxt+="- Data de nascimento (campo vazio)\n";       
       
       
      //Teste com expressões regulares para campos com nomenclaturas muito específicas.
      if (who.email != undefined){  
        var emailVal = who.email.value;
  			var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  			if (!(filter.test(emailVal))) {
  			  alertxt += "- Email (formato: xxx@xxx.xx)\n";
  			}
			}
			
      if (who.birthdate != undefined){  
        var re = /^\d{4}\-\d{1,2}\-\d{1,2}$/;
        if (!re.test(who.birthdate.value)) alertxt+="- Data de nascimento (aaaa-mm-dd)\n";
      }   
      
      if (who.cp1 != undefined){
        var cp1Test = /^\d{4}$/;
        if (!cp1Test.test(who.cp1.value)) alertxt+="- Código postal (campo 1) (4 dígitos)\n";
      }
      
      if (who.cp2 != undefined){
        var cp2Test = /^\d{3}$/;
        if (!cp2Test.test(who.cp2.value)) alertxt+="- Código postal (campo 2) (3 dígitos)\n";
      }
      
      if (who.phone != undefined){
        var phoneTest = /^(\+){0,1}((\d{9})|(\d{12}))$/;
        if (!phoneTest.test(who.phone.value)) alertxt+="- Telefone (9 ou 12 dígitos)\n";
      }
      
      if (who.id_c != undefined){
        var biTest = /^\d{1,9}$/;
        if (!biTest.test(who.id_c.value)) alertxt+="- B.I. (máx. 9 dígitos)\n";
      }
       
      //Checkbox de termos e condições 
      if (who.agree.checked == false ) alertxt+="- Para participar no passatempo deverá aceitar as condições\n";       
       
       
      //Verificação de eventuais erros prévios
      if (alertxt=="") {
        return true;
      }else {
        window.alert("Por favor, preencha os seguintes campos obrigatórios:\n\n" + alertxt);
        return false;
      }
}

function fyoung_val(who){
	var alertxt="";
      var selchecked = undefined;
       
      if(who.answer != undefined && who.answer.value=="") alertxt += "- Resposta\n";
       
       
      //Verificação dos radio buttons 
      if(who.selection != undefined){
          selchecked=false;
          $('input[@name=selection]').each(function(){
            if($(this).attr('checked'))selchecked = true;
          });
      }
      
      if(selchecked == false) alertxt+="- Escolha única\n";
	  
	  
      //Campos de texto vazios
      if (who.names != undefined && who.names.value=="") alertxt+="- Nome (campo vazio)\n";
      if (who.address != undefined && who.address.value=="") alertxt+="- Morada (campo vazio)\n";
      if (who.cp1 != undefined && who.cp1.value=="" || who.cp2.value=="") alertxt+="- Código Postal (campo 1) (campo vazio)\n";
      if (who.cp2 != undefined && who.cp2.value=="") alertxt+="- Código Postal (campo 2) (campo vazio)\n";
      if (who.city != undefined && who.city.value=="" ) alertxt+="- Localidade (campo vazio)\n";
      if (who.phone != undefined && who.phone.value=="" ) alertxt+="- Telefone (campo vazio)\n";
	  if (who.bi != undefined && who.bi.value=="" ) alertxt+="- BI (campo vazio)\n";
      if (who.email != undefined && who.email.value=="") alertxt+="- Email (campo vazio)\n";	  
      if (who.birthdate != undefined && who.birthdate.value=="") alertxt+="- Data de nascimento (campo vazio)\n";

	  if($('input[@name=own_car]:checked').val() == 1){
		  if(who.car_brand != undefined && who.car_brand.value == "")  alertxt+="- Marca do Automóvel (campo vazio)\n";
	  }

	    
	  if (who.promo_code != undefined && who.promo_code.value=="") alertxt+="- Código Promocional (campo vazio)\n";

       
      //Teste com expressões regulares para campos com nomenclaturas muito específicas.
      if (who.email != undefined){  
        var emailVal = who.email.value;
  			var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  			if (!(filter.test(emailVal))) {
  			  alertxt += "- Email (formato: xxx@xxx.xx)\n";
  			}
			}
			
      if (who.birthdate != undefined){  
        var re = /^\d{4}\-\d{1,2}\-\d{1,2}$/;
        if (!re.test(who.birthdate.value)) alertxt+="- Data de nascimento (aaaa-mm-dd)\n";
      }   
      
      if (who.cp1 != undefined){
        var cp1Test = /^\d{4}$/;
        if (!cp1Test.test(who.cp1.value)) alertxt+="- Código postal (campo 1) (4 dígitos)\n";
      }
      
      if (who.cp2 != undefined){
        var cp2Test = /^\d{3}$/;
        if (!cp2Test.test(who.cp2.value)) alertxt+="- Código postal (campo 2) (3 dígitos)\n";
      }
      
      if (who.phone != undefined){
        var phoneTest = /^(\+){0,1}((\d{9})|(\d{12}))$/;
        if (!phoneTest.test(who.phone.value)) alertxt+="- Telefone (9 ou 12 dígitos)\n";
      }
	  
	  if (who.bi != undefined){
        var biTest = /^\d{1,9}$/;
        if (!biTest.test(who.bi.value)) alertxt+="- B.I. (máx. 9 dígitos)\n";
      }
		
	  if(who.promo_code != undefined){
		var promoTest = /^\d{6}$/;
		if(!promoTest.test(who.promo_code.value)) alertxt += "- Código Promocional (6 dígitos)\n";
	  }
       
      //Checkbox de termos e condições 
      if (who.agree.checked == false ) alertxt+="- Para participar no passatempo deverá aceitar as condições\n";       
       
       
      //Verificação de eventuais erros prévios
      if (alertxt=="") {
        return true;
      }else {
        window.alert("Por favor, preencha os seguintes campos obrigatórios:\n\n" + alertxt);
        return false;
      }
	
	
}
