function setCurrentDate()
{
  var currentDate = new Date();

  document.dateForm.year.selectedIndex = 0;
  document.dateForm.month.selectedIndex = currentDate.getMonth();

  setDays();  
  document.dateForm.day.selectedIndex = currentDate.getDate() - 1;
}

function setDays() {

  var y = document.dateForm.year.options[document.dateForm.year.selectedIndex].value;
  var m = document.dateForm.month.selectedIndex;
  var d;

  if ( (m == 3) || (m == 5) || (m == 8) || (m == 10) ) {
    days = 30;
  }
  else if (m == 1) {
    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 > document.dateForm.day.length) {
    for (i = document.dateForm.day.length; i < days; i++) {
      document.dateForm.day.length = days;
      document.dateForm.day.options[i].text = i + 1;
      document.dateForm.day.options[i].value = i + 1;
    }
  }

  if (days < document.dateForm.day.length) {
    document.dateForm.day.length = days;
    if (document.dateForm.day.selectedIndex == -1) 
      document.dateForm.day.selectedIndex = days - 1;
  }

}
