function updateDaysList() 
{

	// get each of the data inputs
	var monthslist = document.getElementById('month');
	var dayslist = document.getElementById('day');
	var yearinput = document.getElementById('year');

	// get the days in the selected month
		// populate the days of the month
	var daysinmonth = 31;

	// remember that months go 0-11
	switch(monthslist.selectedIndex)
	{
		// 30 days have september, april, june, and november
		case 3:
		case 5:
		case 8:
		case 10:
			daysinmonth = 30;
			break;
		// except for february which has 28 and no more, until come leap year, add one more
		case 1:
			if (yearinput.value % 4) { daysinmonth = 28; }
			else { daysinmonth = 29; }
			break;
		// all the rest have 31
		default:
			daysinmonth = 31;
			break;
	}
	
	// if there are too many days in the list, remove the ones at the end
	while (dayslist.length > daysinmonth) {
		dayslist.remove(dayslist.length - 1);	
	}
	
	while (dayslist.length < daysinmonth) {
		dopt = document.createElement('option');
		dopt.text = dayslist.length + 1;
		dayslist.add(dopt, null);
	}
	
		
}

function initializeForm( m, d, y, ad, abbr, py, auc)
{
	// get the form objects
	var monthslist = document.getElementById('month');
	var dayslist = document.getElementById('day');
	var yearinput = document.getElementById('year');
	
	var abbrbox = document.getElementById('abbr');
	var pybox = document.getElementById('printyear');
	var aucbox = document.getElementById('auc');

	// variable to get the default date variables
	var today = new Date();

	// set some default vals
	if (typeof(m) == 'undefined') { m = today.getMonth(); }
	if (typeof(d) == 'undefined') { d = today.getDate(); }
	if (typeof(y) == 'undefined') { y = today.getFullYear(); }

	if (typeof(ad) == 'undefined') { ad = 1; }
	if (typeof(abbr) == 'undefined') { abbr = 0; }
	if (typeof(py) == 'undefined') { py = 1; }
	if (typeof(auc) == 'undefined') { auc = 0; }
	
	// Initialize the month and year
	monthslist.selectedIndex = m;
	yearinput.value = y;
	
	// populate the days of the month
	updateDaysList();
	
	// Set the day to the current date
	// remember that the drop list indexes at 0
	dayslist.selectedIndex = d - 1;
	
	// initialize the options
	abbrbox.checked = abbr;
	pybox.checked = py;
	aucbox.checked = auc;
			
}


