var theMonths=new Array("January","February","March","April","May","June","July","August", "September","October","November","December");

function fillMonthYear() {
	if (!document.getElementById("date1")) return false;
	var selectMonthYear = document.getElementById("date1");
	var today=new Date();	
	var thisMonth=today.getMonth();
	var thisYear = today.getYear();
	if (thisYear >= 100 && thisYear <= 1999) {thisYear=thisYear + 1900}; //y2k check

	var monthYearSelect = document.createElement("select");
	
	for (i=0;i<24;i++) { // build options for select
		if (thisMonth+i>11 && thisMonth+i<24) {
			var showMonth = thisMonth+i-12;
		} else if (thisMonth+i>23) {
			var showMonth = thisMonth+i-24;
		} else {
			var showMonth = thisMonth+i;
		}

		if (showMonth==0 && i>0) {thisYear = thisYear+1;}

		var monthName = theMonths[showMonth];

		var newOption = document.createElement("option");
		if (i==0) newOption.setAttribute("selected","selected");
		newOption.setAttribute("value",(showMonth+1) + " " + thisYear);
		var newOptionText = document.createTextNode(monthName + " " + thisYear); // + "(thisMonth+i: " + (parseInt(thisMonth) + parseInt(i)) + ", i: " + i + ")"
		newOption.appendChild(newOptionText);
		selectMonthYear.appendChild(newOption);
	}
}

addLoadEvent(fillMonthYear);