function validar1(f){
 if(f.ida[0].checked || f.ida[2].checked){
	 if(isNaN(f.pasajerosllegada.value) || escape(f.pasajerosllegada.value) < 1){
        if(lang == "en"){
            alert ("Enters the number of arrival passengers.");
        }
        else{
            alert("Ingrese el numero de pasajeros de llegada.");
        }
        f.pasajerosllegada.focus();
        return(false);       
    }
    if(f.fechallegada.value == "" || f.horallegada.value == ""){
        if(lang == "en"){
            alert ("Enter the date and time of arrival.");        
        }
        else{
            alert("Ingrese la fecha y hora de llegada.");
        }
        f.fechallegada.focus();
        return(false);
    }
}
    if(f.ida[1].checked || f.ida[2].checked){
        if(isNaN(f.pasajerossalida.value) || escape(f.pasajerossalida.value) < 1){
            if(lang == "en"){
            alert ("Enter the number of exit passengers. "); 
            }
            else{
                alert("Ingrese el numero de pasajeros de salida.");
            }
            f.pasajerossalida.focus();
            return(false);
        }
        if(f.fechasalida.value == "" || f.horasalida.value == ""){
            if(lang == "en"){
            alert ("Enter the date and time of departure."); 
            }
            else{
                alert("Ingrese la fecha y hora de salida.");
            }
            f.fechasalida.focus();
            return(false);
        }       
    }
    if(isNaN(f.palosgolf.value) || escape(f.palosgolf.value) < 0){
        if(lang == "en"){
            alert ("Enter I number of golf woods."); 
        }
        else{
            alert("Ingrese el numero de palos de golf.");
        }
        f.palosgolf.focus();
        return(false);       
    }
    if(isNaN(f.bicicletas.value) || escape(f.bicicletas.value) < 0){
        if(lang == "en"){
            alert ("Enter I number of bikes"); 
        }
        else{
            alert("Ingrese el numero de bicicletas.");
        }
        f.bicicletas.focus();
        return(false);       
    }    
}

function validar2(f){
    if(f.contacto.value == ""){
        if(lang == "en"){
            alert ("Enter the contact name."); 
        }
        else{
            alert("Ingrese el nombre de la persona de contacto");
        }
        f.contacto.focus();
        return(false);
    }
    if(f.telefono.value == ""){
        if(lang == "en"){
            alert ("Enter the contact phone."); 
        }
        else{
            alert("Ingrese el telefono de contacto.");
        }
        f.telefono.focus();
        return(false);
    }		 
	if(!isEmailAddress(f.mail)){   		
		if(lang == "en"){
            alert ("Enter a valid contact mail."); 
        }
        else{
            alert("Ingrese una dirección de correo válida"); 
        }
		f.mail.focus();
        return(false);
	}
	return(true);	
}

function cambiar_anterior(chk){
    document.getElementById('salida2').style.visibility = chk.value;
    document.getElementById('salida1').style.visibility = chk.value;
	if(chk.value == "hidden"){
		document.reserva.fechasalida.value = ""; 	
		document.reserva.horasalida.value = ""; 
	}
}
function cambiar1(chk){
    document.getElementById('salida2').style.visibility = 'hidden';
    document.getElementById('salida1').style.visibility = 'hidden';
	document.getElementById('llegada2').style.visibility = 'visible';
    document.getElementById('llegada1').style.visibility = 'visible';
	document.reserva.fechasalida.value = ""; 	
	document.reserva.horasalida.value = ""; 

}
function cambiar2(chk){
    document.getElementById('salida2').style.visibility = 'visible';
    document.getElementById('salida1').style.visibility = 'visible';
	document.getElementById('llegada2').style.visibility = 'hidden';
    document.getElementById('llegada1').style.visibility = 'hidden';
	document.reserva.fechallegada.value = ""; 	
	document.reserva.horallegada.value = ""; 
}

function cambiar3(chk){
    document.getElementById('salida2').style.visibility = 'visible';
    document.getElementById('salida1').style.visibility = 'visible';
	document.getElementById('llegada2').style.visibility = 'visible';
    document.getElementById('llegada1').style.visibility = 'visible';

}

function validarContacto(f){
    if(f.contacto.value == ""){
        if(lang == "en"){
            alert ("Enter the contact name."); 
        }
        else{
            alert("Ingrese el nombre de la persona de contacto");
        }
        f.contacto.focus();
        return(false);
    }
    if(f.telefono.value == ""){
        if(lang == "en"){
            alert ("Enter the contact phone."); 
        }
        else{
            alert("Ingrese el telefono de contacto.");
        }
        f.telefono.focus();
        return(false);
    }		 
	if(!isEmailAddress(f.mail)){ 
		if(lang == "en"){
            alert ("Enter a valid contact mail."); 
        }
        else{
            alert("Ingrese una dirección de correo válida"); 
        }
		f.mail.focus();
        return(false);
	}
	return(true);	
}			

function isEmailAddress(theElement){
	var s = theElement.value;
	var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if (s.length == 0 ) return true;
		if (filter.test(s))
			return true;
		else
			return false;
}

