function submitForm() {
  var f = document.form;

  if (!checkdates()) {
    return false;
  }

  return true;
}

function checkdates() {

  df = document.form;

  day = df.nbday.value;
  month = df.nbmonth.value;
  year = df.nbyear.value;

  if (!ValidDate(day, month, year)) {
     alert("The date you have chosen looks incorrect.");
     return false;
   }

  userDate = new Date(year, month-1, day);
  if (!checkDate(userDate)) {
    return false;
  }

// Now check if it's the KKNK
  if (df.nbid.value == 61 || df.nbid.value == 105) {
    if (!(year == 2009 && (month == 3 || month == 4))) {
      alert("Besprekings net geldig vir feesperiode in April");
      return false;
    }
  }

  return true;

}

function ValidDate(day, month, year) {

  if ((month == 4)||(month==6)||(month==9)||(month==11)) {
    if (day > 30) {
      return false;
    } 
  } else if (month == 2) {
    if ((year - 1960) % 4 != 0) {
      if ( day > 28 ) {
        return false;
      }
    } else if ( day > 29 ) {
      return false;
    }
  }

  return true;
}

function checkDate(userdt) {
  dt = new Date();
  dt.setHours(0);
  dt.setMinutes(0);
  dt.setSeconds(0);
  dt.setMilliseconds(0);

  if (dt.getTime() > userdt.getTime()) {
    alert("You cannot choose a date earlier than today.");
    return false;
  } else {
    return true;
  }
}
