function test(src) {
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,9}$/;
  return regex.test(src);
}

function esFechaValida(fecha){
    if (fecha != undefined && fecha.value != "" ){
        if (!/^\d{2}\/\d{2}\/\d{4}$/.test(fecha.value)){            
            return false;
        }
        var dia  =  parseInt(fecha.value.substring(0,2),10);
        var mes  =  parseInt(fecha.value.substring(3,5),10);
        var anio =  parseInt(fecha.value.substring(6),10);
 
    switch(mes){
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
            numDias=31;

            break;
        case 4: case 6: case 9: case 11:
            numDias=30;
            break;
        case 2:
            if (comprobarSiBisisesto(anio)){ numDias=29 }else{ numDias=28};
            break;
        default:            
            return false;
    }
 
        if (dia>numDias || dia==0){           
            return false;
        }
        return true;
    }
}
 
function comprobarSiBisisesto(anio){
if ( ( anio % 100 != 0) && ((anio % 4 == 0) || (anio % 400 == 0))) {
    return true;
    }
else {
    return false;
    }
}

function verificar() {
	var mensaje=''
	var focus=0
	if ($('nombre').value.length<=1) {
		mensaje+='\n- Enter your First Name'
		if(focus==0) $('nombre').focus()
		var focus=1
	}	
	if ($('apellido').value.length<=1) {
		mensaje+='\n- Enter your Last Name'
		if(focus==0) $('apellido').focus()
		var focus=1
	}
	if ($('pais')) {
		if ($('pais').value.length<=3) {
			mensaje+='\n- Enter your country'
			if(focus==0) $('pais').focus()
			var focus=1
		}	
	}
	if (!test($('email').value)) {		
		mensaje += '\n- Enter a valid email address'
		if(focus==0) $('email').focus()
		var focus=1
	}	
	if ($('remail')) {
		if ($('remail').value!='') {
			if (!test($('remail').value)) {
				mensaje += '\n- Enter a valid confirmation email address';
				if(focus==0) $('remail').focus()
				var focus=1
			}
			else {
				if ($('remail').value != $('email').value) {
					mensaje += '\n The email and confirmation email addresses must be the same';
					if(focus==0) $('remail').focus()
					var focus=1
				}
			}
		}
	}		
	if ($('pasajero')) {		
		if ($('pasajero').value.length<=1) {			
			mensaje+='\n- Enter the Passenger\'s Name'			
			if(focus==0) $('pasajero').focus()
			var focus=1
		}
	}
	
	if ($('adultos')) {
		tagEl = $('adultos').get('tag')
		switch(tagEl){			
			case "input":
				if ($('adultos').value=='') {
					mensaje+='\n- Enter the number of passengers'
					if(focus==0) $('adultos').focus()
					var focus=1
				}
			break
		}
	}
	
	$$('.edad').each(function(campo) {	
		if (campo.name.contains('edadnino')){
			if (campo.value.length < 1)
				mensaje += '\n- ' + campo.alt + ' is not valid';
			if(focus==0) campo.focus()
			focus=1
		}
	});	
	
	if ($('checkin')) {
		if($('checkin').value.length <= 1){		
			mensaje+='\n- Enter a valid start date';
			if(focus==0) $('checkin').focus();
			var focus=1
		}
	}
	if ($('checkout')) {
		if($('checkout').value.length <= 1){		
			mensaje+='\n- Enter a valid end date';
			if(focus==0) $('checkout').focus();
			var focus=1
		}
	}

	if ($('origen')) {
		if($('origen').value.length <= 1){		
			mensaje+='\n- Enter a valid Pickup location';
			if(focus==0) $('origen').focus();
			var focus=1
		}
	}
	if ($('destino')) {
		if($('destino').value.length <= 1){		
			mensaje+='\n- Enter a valid Destination';
			if(focus==0) $('destino').focus();
			var focus=1
		}
	}
	
	if ($('terminos_condiciones')){
		if ($('terminos_condiciones').checked === false) {
			mensaje+='\n- You must accept the terms and conditions of sale';
		}
	}



	if (mensaje=='')
		document.formulario.submit()
	else {
		mensaje = 'Please, correct the following errors:' + mensaje
		alert(mensaje);
		return false;
	}
}

