// const fails in IE4
var numberOfDaysToBookIntoFuture = 4;

function drawDays(prePop)
{
	var selected = "";
	var padDate = "";
	var date = "";
	if(typeof(prePop) == "undefined"){prePop = "";}
	if(prePop != "")
	{
		date = prePop;
	}
	else
	{
		var tempDate = new Date();
		date = tempDate.getDate();
		date += numberOfDaysToBookIntoFuture ;
		tempDate.setDate(date);
		date = tempDate.getDate();
	}

	for (var i=1; i<32; i++)
	{
		padDate = i;
		padDate = padDate.toString();
		if(padDate.length == 1){padDate = "0" + padDate;}
		if(i == date){selected = "selected";}
		document.write('<option value="'+padDate+'" '+ selected +'>'+padDate+'</option>');
		selected = '';
	}
}

function drawMonths(prePop)
{
	var selected = "";
	var tempMonth = "";
	var tempYear = "";
	var armonths=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
	if(typeof(prePop) == "undefined"){prePop = "";}
	var curDate = new Date();
	curDate.setDate(1);
	
	if(prePop != "" && prePop.length == 4)
	{
		tempMonth = prePop.substr(0,2);
		tempMonth = Number(tempMonth);
		// Decrement to concert vb array to jscript array
		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 += numberOfDaysToBookIntoFuture ;
		tempDate.setDate(date);
		tempMonth = tempDate.getMonth();
		tempYear = tempDate.getFullYear();
	}
	
	for (var i=0; i<13; 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(curYear.length -2,2);
		
		//alert("curYear="+curYear+",tempYear="+tempYear+",CurMonth="+curMonth+", tempMonth="+tempMonth);
		if(curYear == tempYear && curMonth == tempMonth)
		{
			selected = 'selected';
		}
		document.write('<option value="'+curMonthStr+'-'+curYear+'" ' + selected + '>'+armonths[curMonth]+' '+curYearStr+'</option>');
		curDate.setMonth(curDate.getMonth() + 1);
		selected = '';
	}
}
