// JavaScript Document
function validar_recogida_aeropuerto(){
	
	with(document.frm_recogida_aeropuerto) {
		
		if (txt_nombre.value == ''){
			
			alert("Debes ingresar el nombre");
			txt_nombre.focus();
			txt_nombre.style.background="#92ADDA";
			return false;
			
		}
		
		if (txt_apellido.value == ''){
			
			alert("Debes ingresar el apellido");
			txt_apellido.focus();
			txt_apellido.style.background="#92ADDA";
			return false;
			
		}
		
		if (txt_email.value == ''){
			
			alert("Debes ingresar un e-mail correcto");
			txt_email.focus();
			txt_email.style.background="#92ADDA";
			return false;
			
		}else{
			patron = /^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
			if (patron.test(txt_email.value)==false){
				alert("El e-mail introducido es incorrecto");
				txt_email.focus();
				txt_email.style.background="#92ADDA";
				return false;
			}
			
		}/**/
		
	
		if (lst_aeropuerto.value == '0'){
			alert("Debes seleccionar un aeropuerto");
			lst_aeropuerto.focus();
			lst_aeropuerto.style.background="#92ADDA";
			return false;
			
		}
			
		if (txt_vuelo.value == ''){
			
			alert("Debes ingresar el vuelo");
			txt_vuelo.focus();
			txt_vuelo.style.background="#92ADDA";
			return false;
			
		}
		
		//validacion de la fecha
		if (txt_dia.value == ''){
			
			alert("Debes ingresar un dia correcto");
			txt_dia.focus();
			txt_dia.style.background="#92ADDA";
			return false;
			
		}else{
			patron = /^(0?[1-9]|1[0-9]|2|2[0-9]|3[0-1])$/;
			if (patron.test(txt_dia.value)==false){
				alert("El dia introducido es incorrecto");
				txt_dia.focus();
				txt_dia.style.background="#92ADDA";
				return false;
			}
			
		}
		
		if (txt_mes.value == ''){
			
			alert("Debes ingresar un mes correcto");
			txt_mes.focus();
			txt_mes.style.background="#92ADDA";
			return false;
			
		}else{
			patron = /^(0?[1-9]|1[0-2])$/;
			if (patron.test(txt_mes.value)==false){
				alert("El mes introducido es incorrecto");
				txt_mes.focus();
				txt_mes.style.background="#92ADDA";
				return false;
			}
			
		}
		
		if (txt_anyo.value == ''){
			
			alert("Debes ingresar un año correcto");
			txt_anyo.focus();
			txt_anyo.style.background="#92ADDA";
			return false;
			
		}else{
			patron = /^(20[0-9][0-9])$/;
			if (patron.test(txt_anyo.value)==false){
				alert("El año introducido es incorrecto");
				txt_anyo.focus();
				txt_anyo.style.background="#92ADDA";
				return false;
			}
			
		}
		
		//fin de validación de la fecha
		
		if (txt_hora_llegada.value == ''){
			
			alert("Debes ingresar una hora de llegada");
			txt_hora_llegada.focus();
			txt_hora_llegada.style.background="#92ADDA";
			return false;
			
		}else{
		//	patron2=/^(0[1-9]|1\d|2[0-3]):([0-5]\d):([0-5]\d)$/; <<-- patron con segundos incluidos
			patron=/^(0[1-9]|1\d|2[0-3]):([0-5]\d)$/;
			if (patron.test(txt_hora_llegada.value)==false){
				alert("La hora introducida es incorrecta");
				txt_hora_llegada.focus();
				txt_hora_llegada.style.background="#92ADDA";
				return false;
			}
		}
		
		if (txt_adultos.value == ''){
			
			alert("Debes ingresar un número de adultos");
			txt_adultos.focus();
			txt_adultos.style.background="#92ADDA";
			return false;
			
		}
		
		if (txt_ninyos.value == ''){
			
			alert("Debes ingresar un número de niños");
			txt_ninyos.focus();
			txt_ninyos.style.background="#92ADDA";
			return false;
			
		}
		
		if (chk_transporte_privado.checked==false && chk_transporte_colectivo.checked==false){
			alert("Debes seleccionar una opción");
			chk_transporte_privado.focus();
			chk_transporte_colectivo.focus();
			chk_transporte_privado.style.background="#92ADDA";
			chk_transporte_colectivo.style.background="#92ADDA";
			return false;
		}
		
		
//		action="formulario2_enviar.php";
//		submit();

	
	} // fin de with
	return true;
	
} //fin de validación d recogida de aeropuerto


function validar_libro(param){
                     
    with(document.frm_librovisitas) {
                    
       
       if (nombre.value == ''){
                    
            alert("Debes introducir el nombre");
            nombre.focus();
            nombre.style.background="#92ADDA";
            return false;
            
        }
        
        if (email.value != ''){
            patron = /^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
            if (patron.test(email.value)==false){
                alert("El email introducido es incorrecto");
                email.focus();
                email.style.background="#FFF2F2";
                return false;
            }
        }
        
        if (comentario.value == ''){
                    
            alert("Debes introducir un comentario");
            comentario.focus();
            comentario.style.background="#92ADDA";
            return false;
            
        }
        
        if (txt_captcha.value == ''){
                    
            alert("Código vacío");
            txt_captcha.focus();
            txt_captcha.style.background="#92ADDA";
            return false;
            
        }   
            
                                                                      
    } // fin de with
    return true;
    
} 

/*function validar_captcha(mens)
{   

    if (mens == 0)
    {
        alert ('Código incorrecto');
        //document.getElementById('captcha_input').focus();
        
        return false;
    }
    
}*/

