function DynamicForm(shouldValidate, defaultDate){	//alert("shouldValidate");	this.shouldValidate = shouldValidate;	this.defaultDate = defaultDate;	this.fName;	this.mName;	this.dName;	this.yName;		this.setFields = function(finalName, monthField, dayField, yearField)	{		this.fName = finalName;		this.mName = monthField;		this.dName = dayField;		this.yName = yearField;		//alert("this.dName");	}	this.monthArray = new Array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");		this.makeMonths = function()	{		var firstOption = new Option("Month", "");		this.mName.options[0] = firstOption;		for(var i=1; i<this.monthArray.length; i++)		{			var optionObject = new Option(this.monthArray[i], i);			this.mName.options[i] = optionObject;		}	}		this.getDays = function(theMonth)	{		if(theMonth==1||theMonth==3||theMonth==5||theMonth==7||theMonth==8||theMonth==10||theMonth==12)		{			this.changeDays(31);		}		else if(theMonth==2)		{			this.changeDays(29);		}		else		{			this.changeDays(30);		}	}	this.changeDays = function(numDays)	{		this.dName.options.length=0;;		var firstOption = new Option("Day","");		this.dName.options[0]=firstOption;		for(var i=1; i<=numDays; i++)		{			var optionObject = new Option(i,i);			this.dName.options[i] = optionObject;   		}	}		this.formatNumber = function(theNumber)	{		var tempNum = parseInt(theNumber);		if(tempNum<10)		{			return "0"+tempNum;		}		else		{			return tempNum;		}	}		this.isPast = function(theDate)	{		var MONTHADJUSTER = 1; //fixes bug that spits out one lower than current month		var isOk = true;		var rightNow = new Date();		var currentDay = rightNow.getFullYear().toString();		currentDay += this.formatNumber(rightNow.getMonth()+MONTHADJUSTER);		currentDay += this.formatNumber(rightNow.getDate());		var numDate = parseInt(theDate);		var todayNum = parseInt(currentDay);		//alert(rightNow.getDate());		//alert("Today: "+todayNum+" Selected Date: "+numDate);		if(numDate>todayNum)		{			alert("You must pick a day in the past.");			isOk = false;		}		return isOk;	}		this.makeDate = function(isDateOnly)	{		var tempLocation;		var doSubmit = true;		var theDay = this.dName.options[this.dName.selectedIndex].value;		var theMonth = this.mName.options[this.mName.selectedIndex].value;		var theYear = this.yName.options[this.yName.selectedIndex].value;		this.fName.value = theYear + this.formatNumber(theMonth) + this.formatNumber(theDay);		if(isDateOnly)		{			//alert("condition meet");			location.href = "/apps/pbcs.dll/section?category=today&Date="+this.fName.value;			return;		}				if(this.shouldValidate)		{			//alert(this.shouldValidate);			doSubmit = this.isPast(this.fName.value);		}		if(doSubmit)		{			if(location.href.indexOf('&Date')!=-1)			{				////alert(location.href.indexOf('&Date'));				tempLocation = location.href.substring(0, location.href.indexOf('&Date'));				//////alert(tempLocation);				location.href = tempLocation+"&Date="+this.fName.value;			}			else			{				location.href+="&Date="+this.fName.value;			}		}			}	this.makeYear = function()	{		var theDate = new Date();		var startYear = 2002;		var currentYear = theDate.getFullYear();		var lookBack = currentYear - startYear;		this.yName.options.length=0;		var firstOption = new Option("Year","");		this.yName.options[0]=firstOption;		for(var i=0; i<=lookBack; i++)		{			var optionObject = new Option(startYear+i,startYear+i);			this.yName.options[i+1] = optionObject; 		}	}}
