function setCurrentDate(suffix) {
  // changes the date selector menus to the current date
  var currentDate = new Date();
  document.getElementById('year' + suffix).selectedIndex = 0;
  document.getElementById('month' + suffix).selectedIndex = currentDate.getMonth();
  setDays(suffix);
  document.getElementById('day' + suffix).selectedIndex = currentDate.getDate() - 1;
}

function setDays(suffix) {
  var y = document.getElementById('year' + suffix).options[document.getElementById('year' + suffix).selectedIndex].value;
  var m = document.getElementById('month' + suffix).options[document.getElementById('month' + suffix).selectedIndex].value;
  var d;
  // find number of days in current month
  if ( (m == 4) || (m == 6) || (m == 9) || (m == 11) ) {
    days = 30;
  }
  else if (m == 2) {
    // check for leapyear - Any year divisible by 4, except those divisible by 100 (but NOT 400)
    if ( (Math.floor(y/4) == (y/4)) && ((Math.floor(y/100) != (y/100)) || (Math.floor(y/400) == (y/400))) )
      days = 29
    else
      days = 28
  }
  else {
    days = 31;
  }
  // if (days in new month > current days) then we must add the extra days
  if (days > document.getElementById('day' + suffix).length) {
    for (i = document.getElementById('day' + suffix).length; i < days; i++) {
      document.getElementById('day' + suffix).length = days;
      document.getElementById('day' + suffix).options[i].text = i + 1;
      document.getElementById('day' + suffix).options[i].value = i + 1;
    }
  }
  // if (days in new month < current days) then we must delete the extra days
  if (days < document.getElementById('day' + suffix).length) {
    document.getElementById('day' + suffix).length = days;
    if (document.getElementById('day' + suffix).selectedIndex == -1) 
      document.getElementById('day' + suffix).selectedIndex = days - 1;
  }
}