
	function setRequiredFields()
	{
		//this code automatically popupulates all the forms with their required fields
		///forms = document.body.children.tags("FORM");
		forms = document.getElementsByTagName("FORM");
		for (formCount=0;formCount < forms.length;formCount++) {
			if (window.createPopup) {
				inputs = forms[formCount].tags("input");
			} else {
				inputs = forms[formCount].getElementsByTagName("input")
			}
			//inputs = forms[formCount].tags("input");
			var thisFormsRequiredIDs = new Array();
			for (inputCount=0;inputCount < inputs.length;inputCount++) {
				//alert(inputs[inputCount].name + "..." + inputs[inputCount].getAttribute("required"));
				if (inputs[inputCount].getAttribute("required") == ""){
					//alert(inputs[inputCount].name + " is required")
					thisFormsRequiredIDs.push(inputs[inputCount].name);
				}
				inputs[inputCount].id = inputs[inputCount].name;
			}
			forms[formCount].requiredIDs = thisFormsRequiredIDs;
		}
	}

	//this function makes sure all the required fields are filled
	function checkRequiredFields(thisForm)	{

		setRequiredFields();

		if (thisForm.studentEventKey)
		{
			if (thisForm.studentEventKey.options[thisForm.studentEventKey.selectedIndex].value == '')
			{
				alert('You must select a Conference.');
				thisForm.studentEventKey.focus();
				return false;
			}
		}

		if (thisForm.studentHighSchoolKey)
		{
			if (thisForm.studentHighSchoolKey.options[thisForm.studentHighSchoolKey.selectedIndex].value == '')
			{
				alert('You must select a high school.');
				thisForm.studentHighSchoolKey.focus();
				return false;
			}
		}

		//alert(thisForm.nyCounty);
		//alert(thisForm.ShippingState.value.toLowerCase() == 'ny');
		//get fields whose values are empty
		missingField = "";
		for (var i=0; i<thisForm.requiredIDs.length; i++) {
			//e = top.document.getElementById(thisForm.requiredIDs[i]);
			e = document.getElementById(thisForm.requiredIDs[i]);
			if (e.value == '') {
				missingField = e;
				break;
			}
		}
		
		if (missingField != "") {
			if (missingField.fullName) {
				alert("You must provide " + missingField.fullName + ".");
			}
			else {
				alert("You must provide a " + missingField.id + ".");			
			}
			
			missingField.focus();
			
			return false;
		}
		else {
		
			if (thisForm.Password && thisForm.Password2 &&
			 (thisForm.Password.value != thisForm.Password2.value) )
			{
				alert('Your confirmation password must match the original.');
				thisForm.Password2.focus();
				return false;
			}
			
			if (thisForm.creditCardExpMonth && thisForm.creditCardExpYear)
			{
				//get today's date, parse out year and month
				var thisDate = new Date();
				//alert("thisaDate: " + thisDate);
				var	thisYear = ''+thisDate.getYear();
				thisYear = thisYear.substr(2, 2);	//get last two digits of 4-digit year
				var thisMonth = thisDate.getMonth()+1;
				//compare today's date with selected expiration date
				previousYear = (parseInt(thisForm.creditCardExpYear.options[thisForm.creditCardExpYear.selectedIndex].value) < thisYear);
				previousMonth = ((parseInt(thisForm.creditCardExpYear.options[thisForm.creditCardExpYear.selectedIndex].value) == thisYear) && (thisForm.creditCardExpMonth.options[thisForm.creditCardExpMonth.selectedIndex].value < thisMonth));

				if (previousYear || previousMonth) {
					alert('Your credit card must have a future expiration date.');
					return false;
				}
			}

			if (thisForm.studentDateOfBirth)
			{
				var dateArray = thisForm.studentDateOfBirth.value.split('/');
				y = dateArray[2];
				m = dateArray[0];
				d = dateArray[1];
				if (checkDate(y, m, d) == false)
				{
					alert('You must enter a real date of birth.');
					thisForm.studentDateOfBirth.focus();
					return false;
				}
			}
			if (thisForm.advisorDateOfBirth)
			{
				var dateArray = thisForm.advisorDateOfBirth.value.split('/');
				y = dateArray[2];
				m = dateArray[0];
				d = dateArray[1];
				if (checkDate(y, m, d) == false)
				{
					alert('You must enter a real date of birth.');
					thisForm.advisorDateOfBirth.focus();
					return false;
				}
				
			}
			return true;
		}
	}
	
	function checkDate(year, month, date)
	{
		trialDate = new Date(month+'/'+date+'/'+year);
		if (trialDate.getMonth()+1 != month ||
			trialDate.getDate() != date ||
			trialDate.getYear() != year)
		{
			return false;
		}
		return true;
	}
