        
function validaFormReserva (idioma){
            
   //variables necesarias y cogemos los valores
    var nombre = document.getElementById('nombre').value;
    var telefono = document.getElementById('telefono').value;
    var email = document.getElementById('mail').value;
    var apell = document.getElementById('apell').value;
    var tipoVis = document.getElementById('reservar').value;
    var numPer = document.getElementById('num').value;
    var fecha = document.getElementById('fecha').value;
    var cp = document.getElementById('cp').value;
    var re = new RegExp (/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/);
    var men1, men2, men3, men4, men5, men6        
            
   //mensajes
   switch(idioma)
   {
     case "1":
        men1 = 'Debes completar los campos: nombre, apellidos, email, visita, personas y fecha para poder efectuar la reserva.';
        men2 = 'El campo no tiene la longitud adecuada';
        men3 = 'El email no parece correcto. Debe tener el siguiente formato: xxx@yyyyy';
        men4 = 'El numero de reservas no es valido';
        men5 = 'Formato de fecha incorrecto';
        men6 = 'Codigo postal no valido';
        break;    
      
    case "2":
        men1 = 'All fields marked with an asterisk (*) are required (first name, last name, email, tour, people and date)';
        men2 = 'Please check the length of this field';
        men3 = 'Please, check that you have entered a valid email';
        men4 = 'Please, check the field People';
        men5 = 'Please, check that you have entered a valid date';
        men6 = 'Please, check that you have entered a valid zip code';
        break;
      
    default:
        men1 = 'Debes completar los campos: nombre, apellidos, email, visita, personas y fecha para poder efectuar la reserva.';
        men2 = 'El campo no tiene la longitud adecuada';
        men3 = 'El email no parece correcto. Debe tener el siguiente formato: xxx@yyyyy';
        men4 = 'El numero de reservas no es valido';
        men5 = 'Formato de fecha incorrecto';
        men6 = 'Codigo postal no valido';
    }
            
            
    //Obligatorios: nombre, apellidos, comentario; todos
    //Obligatorios: telefono o mail; alguno de los dos por lo menos, para poder ponerse en contacto
    var num = parseInt(numPer);
    var cp2 = parseInt(cp);

    if ((apell == '') ||(nombre == '') || email=='' || fecha == '' || numPer == '' || tipoVis == '') {

       alert (men1);
       
       if (nombre == '') document.getElementById('nombre').focus();
       else
         if (apell == '') document.getElementById('apell').focus();
         else
            if (email == '') document.getElementById('mail').focus(); 
            else
               if (fecha == '') document.getElementById('fecha').focus();
               else
                  if (numPer == '') document.getElementById('num').focus();
                  
      return false;                  
    } 
    
    else {

       // comprobamos que el nombre tenga la longitud correcta
       if (nombre.length <1 || nombre.length > 150){
          alert(men2);
          document.getElementById('nombre').focus();
          document.getElementById('nombre').select();
          return false;
       }

       // comprobamos que los apellidos tengan la longitud correcta
      else 
         
         if(apell.length <1 || apell.length > 250){
            alert(mens2);
            document.getElementById('apell').focus();
            document.getElementById('apell').select();
            return false;            
         }

         // comprobamos que el telefono tenga la longitud correcta
         else 
            if(telefono.length > 25){
               alert(men3);
               document.getElementById('telefono').focus();
               document.getElementById('telefono').select();
               return false;
            }

            // comprobamos que la longitud del email sea la correcta
           else 
              if (email.length <1 || email.length > 150){
                 alert(men2);
                 document.getElementById('mail').focus();
                 document.getElementById('mail').select();
                 return false;                 
              }

              // comprobamos que el email tenga el formato correcto
              else 
                 if (!email.match(re)){
                    alert(men3);
                    document.getElementById('mail').focus();
                    document.getElementById('mail').select();
                    return false;                    
                 }

                 // comprobamos que el numero de personas sea el correcto

                 else 
                    //if (isNaN(num) || num<=0){
                    if (numPer == ''){
                       alert(men4);
                       document.getElementById('num').focus();
                       document.getElementById('num').select();
                       return false;
                    }

                    else 
                       if (!isDate(fecha,idioma)){
                          alert(men5);
                          document.getElementById('fecha').focus();
                          document.getElementById('fecha').select();
                          return false;
                       }

                       else 
                          if (cp != '' && isNaN(cp2)){
                             alert(men6);
                             document.getElementById('cp').focus();
                             document.getElementById('cp').select();
                             return false;
                          }


     }

     return true;

} 

