function setDays(yearListName, monthListName, dayListName) {
	var year;
	var dt;
	var month;

	month = document.getElementById(monthListName).value;
	
	if (yearListName == null) {
		dt = new Date();
		year = dt.getFullYear();
		// if month isn't passed in and if month chosen is less than the current month, assume we're discussing next year
		if ((month - 1) < dt.getMonth())
		{
			year++;
		}
	}
	else {
		year = document.getElementById(yearListName).value;
	}

	

	dayCount = 28;

	if (monthHasNumberOfDays(year, month, 31)) {
		dayCount = 31;
	}
	else if (monthHasNumberOfDays(year, month, 30)) {
		dayCount = 30;
	}
	else if (monthHasNumberOfDays(year, month, 29)) {
		dayCount = 29;
	}

	fillDays(dayCount, dayListName);
}

function fillDays(dayCount, dayListName) {
	elem = document.getElementById(dayListName);
	elem.length = dayCount;

	for (i=1; i<=dayCount; i++) {
		elem[i - 1].text = i;
		elem[i - 1].value = i;	
	}
}

function monthHasNumberOfDays(yr, mn, days) {
  	return new Date(yr ,mn - 1, days).getDate() == days;
}