function validar(formulario) {

valor = document.getElementById("Name").value;
valor2 = document.getElementById("Surnames").value;
valor3 = document.getElementById("Email").value;
valor4 = document.getElementById("Email2").value;
valor5 = document.getElementById("Telephone").value;
valor6 = document.getElementById("ArrivingDate").value;
valor7 = document.getElementById("AirCompany").value;
//valor8 = document.getElementById("ArrivingTime").value;
valor9 = document.getElementById("Origin").value;
valor10 = document.getElementById("Flightnumber").value;

valor14 = document.getElementById("HotelAddress").value;
valor15 = document.getElementById("wheelchair");
valor16 = document.getElementById("DepartingDay").value;
//valor17 = document.getElementById("Pickuptime").value;
valor18 = document.getElementById("FlightNumberReturn").value;



// Name-----------------------------------------
if( valor == null || valor.length == 0 || /^\s+$/.test(valor) || !/^[A-Za-z\ñ\Ñ\á\é\í\ó\ú\Á\É\Í\Ó\Ú\ä\ë\ï\ö\ü\Ä\Ë\Ï\Ö\Ü\ç\Ç\_\-\.\s\xF1\xD1]+$/.test(valor)) {
	alert("Please insert a valid Name.");
    reserva.Name.focus();
  return false;
}
// Surname-----------------------------------------
if( valor2 == null || valor2.length == 0 || /^\s+$/.test(valor2) || !/^[A-Za-z\ñ\Ñ\á\é\í\ó\ú\Á\É\Í\Ó\Ú\ä\ë\ï\ö\ü\Ä\Ë\Ï\Ö\Ü\ç\Ç\_\-\.\s\xF1\xD1]+$/.test(valor2) ) {
	alert("Please insert a valid Surnames.");
    reserva.Surnames.focus();
  return false;
}
// Email-----------------------------------------
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(valor3) == false) {
   alert("Please insert a valid E-mail.");
   reserva.Email.focus();
  return false;
}
   
if (valor4 != valor3){
	alert("The E-mail and Confirm E-mail must be the same.");
    reserva.Email2.focus();
  return false;
}
// Phone-----------------------------------------
if(isNaN(valor5) || valor5 == null || valor5.length == 0 || /^\s+$/.test(valor5)) {
	alert("Please insert Phone number (WITHOUT SPACES)");
    reserva.Telephone.focus();
  return false;
}
// Arriving--------------------------------------
 
var fecha_actual = new Date()  
var dia = fecha_actual.getDate()  
var mes = fecha_actual.getMonth() + 1  
var anio = fecha_actual.getFullYear()
 if (mes < 10)  
        mes = '0' + mes  
  
    if (dia < 10)  
        dia = '0' + dia 

var actualDate = dia + "/" + mes + "/" + anio;

 if (valor6.length !=10) {
	alert("Please insert a valid Arriving Date.");
    reserva.ArrivingDate.focus();
return false;
}

d1=valor6.charAt(0) // d
d2=valor6.charAt(1) // d
s1=valor6.charAt(2) // /
m1=valor6.charAt(3) // m
m2=valor6.charAt(4) // m
s2=valor6.charAt(5) // /
y1=valor6.charAt(6) // y
y2=valor6.charAt(7) // y
y3=valor6.charAt(8) // y
y4=valor6.charAt(9) // y


d1ac=actualDate.charAt(0) // d
d2ac=actualDate.charAt(1) // d
s1ac=actualDate.charAt(2) // /
m1ac=actualDate.charAt(3) // m
m2ac=actualDate.charAt(4) // m
s2ac=actualDate.charAt(5) // /
y1ac=actualDate.charAt(6) // y
y2ac=actualDate.charAt(7) // y
y3ac=actualDate.charAt(8) // y
y4ac=actualDate.charAt(9) // y


// ---------------------comparar

var fechaActualFormat = y1ac+y2ac+y3ac+y4ac+m1ac+m2ac+d1ac+d2ac
var fechaValor6Format = y1+y2+y3+y4+m1+m2+d1+d2

 if (fechaValor6Format < fechaActualFormat) {
	alert("Please insert a valid Arriving Date");
    reserva.ArrivingDate.focus();
return false;
}
// --------------------


if (isNaN(d1) || isNaN(d2) || isNaN(m1) || isNaN(m2) || isNaN(y1) || isNaN(y2) || isNaN(y3) || isNaN(y4) ){
	alert("Please insert a valid Arriving Date (dd/mm/yyyy).-CCCC");
    reserva.ArrivingDate.focus();
return false;
}

if ((d1==0 && d2==0) || (m1==0 && m2==0) || (y1==0 && y2==0) && (y3==0 && y4==0)){
	alert("Please insert a valid Arriving Date.-DDDD");
    reserva.ArrivingDate.focus();
return false;
}

if ((d1+d2 > 31) ||( m1+m2>12)){
	alert("Please insert a valid Arriving Date.-EEEE");
	reserva.ArrivingDate.focus();
return false;
}


// Air Company--------------------------------------

if( valor7 == null || valor7.length == 0 || /^\s+$/.test(valor7)) {
	alert("Please insert Air Company.");
    reserva.AirCompany.focus();
  return false;
}

// Time -------------------------------------------
valor20 = document.getElementById("hrA").selectedIndex;
if( valor20 == null || valor20 == 0 ) {
	alert("Please select Arriving Time (Hour). ");
	reserva.hrA.focus();
  return false;
}

valor21 = document.getElementById("minA").selectedIndex;
if( valor21 == null || valor21 == 0 ) {
	alert("Please select Arriving Time (Minutes). ");
	reserva.minA.focus();
  return false;
}

/*if( valor8 == null || valor8.length == 0 || /^\s+$/.test(valor8)) {
	alert("Please insert Arriving Time.");
    reserva.ArrivingTime.focus();
	return false;
}
if (valor8.length!=5) {
	alert("Please insert Arriving Time using the format HH:MM");
    reserva.ArrivingTime.focus();
	return false;
}

a=valor8.charAt(0) //<=2
b=valor8.charAt(1) //<4
c=valor8.charAt(2) //:
d=valor8.charAt(3) //<=5
e=valor8.charAt(4) //x

if (isNaN(a) || isNaN(b) || isNaN(d) || isNaN(e)) {
	alert("Please insert Arriving Time using the format HH:MM");
    reserva.ArrivingTime.focus();
	return false;
}
if (/^\s+$/.test(a) || /^\s+$/.test(b) || /^\s+$/.test(d) || /^\s+$/.test(e)) {
	alert("Please insert Arriving Time using the format HH:MM");
    reserva.ArrivingTime.focus();
	return false;
}
if ((a==2 && b>4) || (a>2) || a==0 && b==0) {
	alert("Invalid value for hours: please use from 01 to 24");
    reserva.ArrivingTime.focus();
	return false;
}
if (d>5) {
	alert("Invalid value for minutes: please use from 00 to 59");
    reserva.ArrivingTime.focus();
	return false;	
}
if (c!=":") {
	alert("Please insert Arriving Time using the format HH:MM");
    reserva.ArrivingTime.focus();
	return false;
}*/
// Air Origin--------------------------------------

if( valor9 == null || valor9.length == 0 || /^\s+$/.test(valor9)) {
	alert("Please insert Origin.");
    reserva.Origin.focus();
  return false;
}

// Flight Number--------------------------------------

if( valor10 == null || valor10.length == 0 || /^\s+$/.test(valor10)) {
	alert("Please insert Flight number.");
    reserva.Flightnumber.focus();
  return false;
}

// Passenger--------------------------------------

valor11 = document.getElementById("Passenger").selectedIndex;
if( valor11 == null || valor11 == 0 ) {
	alert("Please select number of passengers.");
	reserva.Passenger.focus();
  return false;
}

// Luggage--------------------------------------

valor12 = document.getElementById("Luggage").selectedIndex;
if( valor12 == null || valor12 == 0 ) {
	alert("Please select number of Luggage.");
	reserva.Luggage.focus();
  return false;
}

// Destiny--------------------------------------

valor13 = document.getElementById("Destiny").selectedIndex;
if( valor13 == null || valor13 == 0 ) {
	alert("Please select Destiny.");
	reserva.Destiny.focus();
  return false;
}

// Hotel--------------------------------------

if( valor14 == null || valor14.length == 0 || /^\s+$/.test(valor14)) {
	alert("Please insert Hotel or Address.");
    reserva.HotelAddress.focus();
  return false;
}

// Eurotaxi--------------------------------------

if (valor11 >= 5 && valor15.checked){
	alert("Eurotaxi only available until 4 passenger");
  return false;
}

// Departing Day ----------------------------------

valor22 = document.getElementById("hrAR").selectedIndex;
valor23 = document.getElementById("minAR").selectedIndex;

if((valor16 == null || valor16.length == 0 || /^\s+$/.test(valor16)) && (valor18 == null || valor18.length == 0 || /^\s+$/.test(valor18)) && (valor22=="") && (valor23=="")){
	  return true;
}



if (valor16.length !=10) {
	alert("Please insert a valid Departing Date.");
    reserva.DepartingDay.focus();
return false;
}


dr1=valor16.charAt(0) // d
dr2=valor16.charAt(1) // d
sr1=valor16.charAt(2) // /
mr1=valor16.charAt(3) // m
mr2=valor16.charAt(4) // m
sr2=valor16.charAt(5) // /
yr1=valor16.charAt(6) // y
yr2=valor16.charAt(7) // y
yr3=valor16.charAt(8) // y
yr4=valor16.charAt(9) // y

// ---------------------comparar

var fechaValor16Format = yr1+yr2+yr3+yr4+mr1+mr2+dr1+dr2

 if (fechaValor16Format < fechaValor6Format) {
	alert("Please insert a valid Departing Date.");
    reserva.DepartingDay.focus();
return false;
}
// --------------------

if (isNaN(dr1) || isNaN(dr2) || isNaN(mr1) || isNaN(mr2) || isNaN(yr1) || isNaN(yr2) || isNaN(yr3) || isNaN(yr4) ){
	alert("Please insert a valid Departing Date (dd/mm/yyyy).");
    reserva.DepartingDay.focus();
return false;
}

if ((dr1==0 && dr2==0) || (mr1==0 && mr2==0) || (yr1==0 && yr2==0) && (yr3==0 && yr4==0)){
	alert("Please insert a valid Departing Date.");
    reserva.DepartingDay.focus();
return false;
}

if ((dr1+dr2 > 31) || ( mr1+mr2>12)){
	alert("Please insert a valid Departing Date.");
	reserva.DepartingDay.focus();
return false;
}

// Time -------------------------------------------
if( valor22 == null || valor22 == 0 ) {
	alert("Please select Pick-up Time (Hour). ");
	reserva.hrAR.focus();
  return false;
}

if( valor23 == null || valor23 == 0 ) {
	alert("Please select Pick-up Time (Minutes). ");
	reserva.minAR.focus();
  return false;
}


// Flight Number--------------------------------------

if( valor18 == null || valor18.length == 0 || /^\s+$/.test(valor18)) {
	alert("Please insert Flight number Return.");
    reserva.FlightNumberReturn.focus();
  return false;
}

}
