  // initialize
  var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
  var lastDayOfTheMonths = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  var dateCount = 1;

  // get today's date
  var today = new Date();

  // extract month from today's date
  var month = today.getMonth();

  // extract date from today's date
  var day = today.getDate();

  // extract year from today's date
  var year = today.getFullYear();

  // if today is in February, see if we need to add another day for leap year.
  if (1 == month)
    if (((year % 100 != 0) && (year % 4 == 0)) || (year % 400 == 0))
      lastDayOfTheMonths[1] = 29;

  // write out the current calendar month using a table
  document.write('<table id="calendar">' +
		 '<caption id="calendar-caption">' + monthNames[month] + ' ' + year + '</caption>' +
		 '<thead><tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr></thead>' +
		 '<tbody>');

  // reset date to the 1st of the month
  today.setDate(1);

  // get day of the week the 1st of the month falls on
  var dayOfTheWeek = today.getDay();

  do
  {
    // start row
    document.write('<tr>');

    // fill in the cells
    for (i = 0; i < 7; ++i)
      if ((dayOfTheWeek <= 0) && (dateCount <= lastDayOfTheMonths[month]))
      {
	if (dateCount == day)
	  document.write('<td id="today">' + dateCount + '</td>');
	else
	  document.write('<td>' + dateCount + '</td>');

	++dateCount;
      }
      else
      {
	document.write('<td>&nbsp;</td>');
	--dayOfTheWeek;
      }

    // end row
    document.write('</tr>');
  }
  while (dateCount <= lastDayOfTheMonths[month]);

  document.write('</tbody>' +
		 '<tfoot><tr><td>');
