var theform = document.RequestInfoForm;

function clearField(fVal) {
	fVal.value = "";
}

function checkF1() {
	var fVal1 = document.RequestInfoForm.FirstName.value;
	if (fVal1 == '') {
		document.RequestInfoForm.FirstName.value = 'First Name';
	}
}
function checkF2() {
	var fVal2 = document.RequestInfoForm.LastName.value;
	if (fVal2 == '') {
		document.RequestInfoForm.LastName.value = 'Last Name';
	}
}
function checkF3() {
	var fVal3 = document.RequestInfoForm.Email.value;
	if (fVal3 == '') {
		document.RequestInfoForm.Email.value = 'E-Mail Address';
	}
}
function checkF4() {
	var fVal4 = document.RequestInfoForm.DaytimePhone.value;
	if (fVal4 == '') {
		document.RequestInfoForm.DaytimePhone.value = 'Primary Telephone';
	}
}
function checkF5() {
	var fVal5 = document.RequestInfoForm.Zip.value;
	if (fVal5 == '') {
		document.RequestInfoForm.Zip.value = 'Zip/Postal';
	}
}

function checkRequestInfoForm(theform) {
	// flag user submit
	theform.boolUserSubmit.value = 1;

	// validate program selection
	var obj = document.getElementById("DegreeProgramID");
	
	if (obj.value == 0 || obj.value == '' || obj.value == -1 ) {
		alert('Please select a Program of interest.');
		obj.focus();
		return false;
	}

	// validate YearHSGED selection
	var obj = theform.YearHSGED;
	var selectedYearHSGED = obj.options[obj.selectedIndex].value;
	if (selectedYearHSGED != '') {
		if (!checkYearHSGED(selectedYearHSGED)) {
			alert('Thank you very much for your interest in Redstone College.  We appreciate your inquiry.  However, at this time we are unable to accept requests for information from students with a graduation date of '+selectedYearHSGED+' or later.  We would like to encourage you to speak with your advisor about when a Redstone Representative will be presenting at your school this year.  We visit many high schools around the United States and we would look forward to meeting you then and answering any questions you may have about Redstone.');
			obj.focus();
			return false;
		}
	}
	
	theform.FirstName.required = true;
	theform.FirstName.requiredError = 'The First Name field must be filled in.';
	
	theform.LastName.required = true;
	theform.LastName.requiredError = 'The Last Name field must be filled in.';
	
	theform.Email.required = true;
	theform.Email.requiredError = 'The Email field must be filled in.';
	
	theform.Email.pattern = 'email';
	theform.Email.patternError = 'The Email address entered is not valid.';
	
	theform.Zip.required = true;
	theform.Zip.requiredError = 'The Zip/Postal Code field must be filled in.';
	
	theform.Zip.pattern = 'zipcode';
	theform.Zip.patternError = 'The US Zip Code entered is not valid (must be exactly 5 numeric digits).';
	
	theform.DaytimePhone.required = true;
	theform.DaytimePhone.requiredError = 'The Daytime Phone number field must be filled in.';
	theform.DaytimePhone.pattern = 'us phone number';
	theform.DaytimePhone.patternError = 'The Daytime Phone number is not valid.';
	
	theform.YearHSGED.required = true;
	theform.YearHSGED.requiredError = 'A year of high school graduation or GED completion must be selected.';
	theform.YearHSGED.disallowEmptyValue = true;
	theform.YearHSGED.disallowEmptyValueError = 'A year of high school graduation or GED completion must be selected.';
	
	var errors = getFormErrors(theform);
	if (errors.length > 0) {
		var errorMessage = 'The form was not submitted due to the following problem' + ((errors.length > 1) ? 's' : '') + ':\n\n';
		for (var errorIndex = 0; errorIndex < errors.length; errorIndex++) {
			errorMessage += '* ' + errors[errorIndex] + '\n';
		}
		errorMessage += '\nPlease fix ' + ((errors.length > 1) ? 'these' : 'this') + ' problem' + ((errors.length > 1) ? 's' : '') + ' and resubmit the form.';
		alert(errorMessage);
		theform.boolUserSubmit.value = 0;
		return false;
	}
	
	// disable all buttons to avoid multi-submit
	//disableButtons(theform);
	
	// no errors: return true
	
	return true;
}