<!--
// you may use/modify this code, but please give credit as a courtesy
// script by Arash Ramin (http://www.digitalroom.net)


function setCurrentDate() {
  // changes the date selector menus to the current date
  var currentDate = new Date();

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

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

function setDays() {

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

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

  
  // if (days in new month < current days) then we must delete the extra days
  if (days < document.the_form.day.length) {
    document.the_form.day.length = days;
    if (document.the_form.day.selectedIndex == -1) 
      document.the_form.day.selectedIndex = days - 1;
  }

}


//-->