var defaultDaysInFuture = 5;

function drawDays() {
	for (var i=1; i<32; i++) {
		var xStr = i;
		xStr = xStr.toString();
		if (xStr.length == 1) {xStr = "0" + xStr;}
		document.write('<option value="' + xStr + '">' + xStr + '</option>');
	}
}

function drawMonthDesc() {
	for (var i=0; i<12; i++) document.write('<option value="' + MONTH_NAMES_SHORT[i] + '">' + MONTH_NAMES_LONG[i] + '</option>');
}

function drawMonthShort() {
	for (var i=0; i<12; i++) document.write('<option value="' + MONTH_NAMES_SHORT[i] + '">' + MONTH_NAMES_SHORT[i] + '</option>');
}


function drawMonths(prePop, daysInFuture, monthsAhead) {
	var localDaysInFuture = defaultDaysInFuture;
	if (typeof(daysInFuture) != "undefined") localDaysInFuture = parseInt(daysInFuture)
	if (typeof(prePop) == "undefined") {prePop = "";}
	if (typeof(monthsAhead) == "undefined") {monthsAhead = 12;}
	var selected = "", tempMonth = "", tempYear = "";
		var armonths=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	var curDate = new Date();
	curDate.setDate(1);
	if (prePop != "" && prePop.length == 4) {
		tempMonth = prePop.substr(0,2);
		tempMonth = Number(tempMonth);
		tempMonth --;
		tempMonth = tempMonth.toString();
		if(tempMonth.length == 1) {tempMonth = "0" + tempMonth;}
		tempYear = "20" + prePop.substr(2,2);
	} else {
		var tempDate = new Date();
		var date = tempDate.getDate();
		date += localDaysInFuture;
		tempDate.setDate(date);
		tempMonth = tempDate.getMonth();
		tempYear = tempDate.getFullYear();
	}
	for (var i=0; i<=monthsAhead; i++) {
		var curMonth = curDate.getMonth();
		var curMonthStr = curMonth + 1;
		curMonthStr = curMonthStr.toString();
		if(curMonthStr.length == 1) {curMonthStr = "0" + curMonthStr;}
		var curYear = curDate.getFullYear();
		curYear = curYear.toString();
		var curYearStr = curYear.substr(2,2);
		if(curYear == tempYear && curMonth == tempMonth) selected = 'selected';
		document.write('<option value = "' + armonths[curMonth] + sAppDateSeparator + curYear + '" ' + selected + '>' + armonths[curMonth] + ' ' + curYearStr + '</option>');
		curDate.setMonth(curDate.getMonth() + 1);
		selected = '';
	}
}

function DrawYears(anRange, asDirection, asField, asBlank) {
	var Base = new Date().getFullYear();
	var sPos = 0;
	if (asBlank == 'Y') {
		document.frmSubmit[asField].options[0] = new Option('Year', '');
		sPos = 1;
	}
	for (var j=0; j < anRange; j++) {
		if (asDirection == "+") {document.frmSubmit[asField].options[j + sPos] = new Option(Base + j, Base + j);} else {document.frmSubmit[asField].options[j + sPos] = new Option(Base - j, Base - j);}
	}
}

function DrawYearsSpan(anStart, anRange, asField, asBlank) {
	var Base = new Date().getFullYear();
	var sPos = 0;
	if (asBlank == 'Y') {document.frmSubmit[asField].options[0] = new Option('Year', '');sPos = 1;}
	Base-=anStart;
	for (var j=0; j < anRange; j++) {document.frmSubmit[asField].options[j + sPos] = new Option(Base + j, Base + j);}
}