function validateForm()
{
    var blnCorrect = true;
    var strErrorMsg = "Some fields are missing or incorrect:\n";
    
    var strDeparureAirport = document.getElementById("departureAirport_SEARCH").value;
    var strDestinationAirport = document.getElementById("destinationAirport_SEARCH").value;
    var strDepartureDate = document.getElementById("departureDate").value;
    var strReturnDate = document.getElementById("returnDate").value;
    
    var vandaag = new Date();
    var month = vandaag.getMonth() + 1;
    var day = vandaag.getDate();
    var year = vandaag.getFullYear();
    
    day = day < 10 ? "0" + day : day;
    month = month < 10 ? "0" + month : month;

    
    var vandaag = day + "/"+ month + "/" + year;

    
    if (strDeparureAirport == ""){
        blnCorrect = false;
        strErrorMsg += "- Departure airport is missing or incorrect.\n";
    }else{
    
    }
    
    if (strDestinationAirport == ""){
        blnCorrect = false;
        strErrorMsg += "- Destination airport is missing or incorrect.\n";
    }
    
    if (strDepartureDate == ""){
        blnCorrect = false;
        strErrorMsg += "- Departure date is missing or incorrect.\n";
    }else{
        if(!validateDate(strDepartureDate)){
            blnCorrect = false;
            strErrorMsg += "- Return date is missing or incorrect.\n";
        }else{
            if (DateToInt(strDepartureDate) < DateToInt(vandaag)){
                blnCorrect = false;
                strErrorMsg += "- 'Departure date is in the past.\n";
            }
        }
    }
    
    if (strReturnDate == ""){
        blnCorrect = false;
        strErrorMsg += "- Return date is missing or incorrect.\n";
    }else{
        if(!validateDate(strReturnDate)){
            blnCorrect = false;
            strErrorMsg += "- Return date is missing or incorrect.\n";
        }else{
            if (DateToInt(strReturnDate) < DateToInt(vandaag)){
                blnCorrect = false;
                strErrorMsg += "- 'Retunr date is in the past.\n";
            }
            
            if (DateToInt(strReturnDate) < DateToInt(strDepartureDate)){
                blnCorrect = false;
                strErrorMsg += "- 'Return date can not preceed the departure date' zijn.\n";
            }
        }
    }
    
    if (blnCorrect){
        ShowWaitLayer();
        
        document.formulierQuickSearch.submit();
    }else{
        alert(strErrorMsg);
    }
}

function validateDate(date){
  var dateSplit = date.split('/');
  
  var year = dateSplit[2];
  var month= dateSplit[1];
  var day = dateSplit[0];
  
  //Month argument must be in the range 1 - 12
  month = month - 1;  // javascript month range : 0- 11
  var tempDate = new Date(year,month,day);
  
  if ((year == getYear(tempDate.getYear())) && (month == tempDate.getMonth()) && (day == tempDate.getDate()))
      return true;
  else
     return false
  }
  
  function getYear(d) { 
  return (d < 1000) ? d + 1900 : d;
  }
  
  function DateToInt(datestring)
  {
    var arrDate = datestring.split("/");
    
    return arrDate[2] + arrDate[1] + arrDate[0];
  }


