<!-- 
function W(S){document.write(S);}
function WM(M, S){
	W("<OPTION VALUE=");W(M);
	if(nowMonth == M){
		W(" SELECTED>");W(S);
	}
	else{ 
		W(">");W(S);
	}
}
function WY(Y, S){
	W("<OPTION VALUE=");W(Y);
	if(nowYear == Y){
		W(" SELECTED>");W(S);
	}
	else{ 
		W(">");W(S);
	}
}
function W_Opts(n){
	for (i=2;i<n;i++){
		W("<OPTION VALUE=\""+i+"\"");W(">"+i) ;
	}
}

var nowMonth = "";
var nowDay = "";
var nowYear = "";

var now = new Date();
var newMonth = now.getMonth() + 1;

if ((varPostedDay>0) && (varPostedMonth>0) && (varPostedYear>0)) {
	nowMonth = varPostedMonth;
	nowDay = varPostedDay;
	nowYear = varPostedYear;
}
else {
	nowMonth = newMonth;
	nowDay = now.getDate();
	nowYear = now.getFullYear();
}	


nowFullYear=now.getFullYear();
nowFullYear1=nowFullYear+1;
nowFullYear2=nowFullYear+2;

var elements = document.forms["form1"].elements;

// Y
W("<SELECT NAME='lstYr' ID='lstYr' onchange='fDataValidations(elements.lstYr.value, elements.lstMth.value, elements.lstDay.value, elements.lstNoNights.value)'>");
WY(nowFullYear,nowFullYear);WY(nowFullYear1,nowFullYear1);WY(nowFullYear2,nowFullYear2);W("</SELECT>");

// M
W("<SELECT NAME='lstMth' ID='lstMth' onchange='fDataValidations(elements.lstYr.value, elements.lstMth.value, elements.lstDay.value, elements.lstNoNights.value)'>");
WM(1,"Jan.");WM(2,"Feb.");WM(3,"March");WM(4,"April");WM(5,"May");WM(6,"June");WM(7,"July");WM(8,"Aug.");WM(9,"Sept.");WM(10,"Oct.");WM(11,"Nov.");WM(12,"Dec.");
W("</SELECT>");
// D
//W("<SELECT NAME='lstDay' onchange='fDataValidations(document.all.lstYr.value, document.all.lstMth.value, document.all.lstDay.value, document.all.lstNoNights.value)'><OPTION VALUE='1'");
W("<SELECT NAME='lstDay' ID='lstDay' onchange='fDataValidations(elements.lstYr.value, elements.lstMth.value, elements.lstDay.value, elements.lstNoNights.value)'>");
for (i=1;i<32;i++) {
	W("<OPTION VALUE=\""+i+"\"");
	if (nowDay == i) { W(" SELECTED>"+i) } else { W(">"+i) }
}
W("</SELECT>");

W("<script language='JavaScript'>")
W("var NumDayThisMonth=fGetDaysInMonth(nowMonth,now.getFullYear());");
W("RemoveDaysInSelBox(NumDayThisMonth);");
W("AddDaysToSelBox(NumDayThisMonth);");
//W("AddExtraDays(18);");
//W("fDaysAhead(document.all.lstYr.value, document.all.lstMth.value, document.all.lstDay.value, document.all.lstNoNights.value);");
W("</SCRIPT>");

function fGetDaysInMonth(iMonth, iYear){
	var dPrevDate = new Date(iYear, iMonth, 0);
	return dPrevDate.getDate();
}
<!-- JC dynamic option box! -->
function AddExtraDays(iDays){
	var days = elements.lstNoNights;
	days.options.length=iDays;
	for(var i=9; i<iDays; i++){
		lastoption = new Option();  
      	days.options[i] = lastoption;
      	days.options[i].text = 1+i;	
      	days.options[i].value= 1+i;
	}
}
function RemoveDaysInSelBox(iDayInThisMonth){
	var days = elements.lstDay;
	var days_removed =0;
   for(var i=31; i>=iDayInThisMonth; --i){
   		if(days.options[i]!=null){
   			if(days_removed==0){days_removed=1;}
   			days.options[i]=null;
   		}
   }
   return days_removed;
}
function AddDaysToSelBox(iDayInThisMonth){
      var days = elements.lstDay;
      var lastoption;
      for(var i=28; i<iDayInThisMonth; i++){
      		if(days.options[i]==null){
      			lastoption = new Option();
      			days.options[i] = lastoption;
      			days.options[i].text=i+1;
      			days.options[i].value=i+1;
      		}
      }
}
function fDataValidations(iYear, iMonth, iDay, iAddDays){
	var dCurDate = new Date();
	var currentDay = dCurDate.getDate();
	var currentMonth = dCurDate.getMonth()+1;
	var currentYear = dCurDate.getFullYear();
	var dateInvalid=-1;//unknown
	if(currentYear>iYear){
		dateInvalid = 1; //invalid date
	}
	else{
		if(currentYear<iYear)
		{
			dateInvalid = 0;	//valid date 
		}
		else	//currentYear=iYear
		{
			if(currentMonth>iMonth){dateInvalid = 1;}
			else{
				if(currentMonth<iMonth)
				{
					dateInvalid = 0; //active
				}
				else
				{
					dateInvalid = -1;//to be decided
				}
			}
		}
	}
	if((dateInvalid==1)||((dateInvalid==-1)&&(iDay<currentDay))){
		alert("Invalid date selected.");
		elements.lstDay.options[dCurDate.getDate()-1].selected = true;
		elements.lstMth.options[dCurDate.getMonth()].selected = true;
		for (i = 0; i < elements.lstYr.length; i++){
			if (elements.lstYr.options[i].value == dCurDate.getFullYear())
			elements.lstYr.options[i].selected = true;
		}
		var NumDayThisMonth=fGetDaysInMonth(iMonth,iYear);
		if(RemoveDaysInSelBox(NumDayThisMonth)){
			if(iDay>NumDayThisMonth){
				iDay=1;
				elements.lstDay.options.selected = true;
			}
		}
		AddDaysToSelBox(NumDayThisMonth);
		fDaysAhead(currentYear, currentMonth, currentDay, iAddDays);
		return;
	}
	fDaysAhead(iYear, iMonth, iDay, iAddDays);
}
function fDaysAhead(iYear, iMonth, iDay, iAddDays){
	var NumDayThisMonth=fGetDaysInMonth(iMonth,iYear);
	if(RemoveDaysInSelBox(NumDayThisMonth)){
	if(iDay>NumDayThisMonth){
		iDay=1;
		elements.lstDay.options.selected = true;
	}
}
AddDaysToSelBox(NumDayThisMonth);
var AddDays = eval(iAddDays);  //  How many days ahead of the current date
TDate = new Date(iYear, iMonth-1, iDay);
TDay = new Array('Sunday', 'Monday', 'Tuesday', 
'Wednesday', 'Thursday', 'Friday', 'Saturday');
TMonth = new Array('January', 'February', 'March', 
'April', 'May','June', 'July', 'August', 'September', 
'October', 'November', 'December');
MonthDays = new Array('31', '28', '31', '30', 
'31', '30', '31', '31', '30', '31', '30', '31');
function isLeapYear (Year) {
if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
return true;
} 
else {
return false;
   }
}
CurYear = TDate.getFullYear();
if (CurYear < 2000)   
CurYear = CurYear + 1900; 
CurMonth = TDate.getMonth();
CurDayOw = TDate.getDay();
//document.all.result.value=iDay;
CurDay = TDate.getDate();
month = TMonth[CurMonth];
if (month == 'February')  {
if (((CurYear % 4)==0) && ((CurYear % 100)!=0) || ((CurYear %
400)==0)) {
MonthDays[1] = 29;
}
else {
MonthDays[1] = 28;
   }
}
days = MonthDays[CurMonth];
CurDay += AddDays;
if (CurDay > days) {
if (CurMonth == 11) {
CurMonth = 0;
month = TMonth[CurMonth];
CurYear = CurYear + 1
}
else {
month = TMonth[CurMonth+1];
}
CurDay = CurDay - days;
}
CurDayOw += AddDays;
function adjustDay (cday) {
if (cday > 6) {
cday -= 6;
CurDayOw = TDay[cday-1];
adjustDay(cday-1);
}
else {
CurDayOw = TDay[cday];
return true;
   }
}
adjustDay(CurDayOw);
TheDate  = CurDayOw + ', ';
TheDate += month + ' ';
TheDate += CurDay + ', ';

}
function fIsEmpty(s){return ((s==null)||(s.length==0));}


//-->