function ProgramChange() {
	var theform = document.RequestInfoForm;
	theform.boolProgramChange.value = 1;
	theform.submit();
}

function CampusChange() {
	var theform = document.RequestInfoForm;
	theform.boolCampusChange.value = 1;
	theform.submit();
}

function CountryChange() {
	var theform = document.RequestInfoForm;
	if ((theform.Country.options[theform.Country.selectedIndex].value == "US") || (theform.Country.options[theform.Country.selectedIndex].value == "CA")) {
		theform.State.options[0].text="";
		theform.State.disabled=false;
		theform.Province.value="select above";
		theform.Province.disabled=true;
		if ((theform.State.selectedIndex == 0) && (theform.Country.options[theform.Country.selectedIndex].value == "CA")) {
			theform.State.selectedIndex=66;
		}
	}
	else if (theform.Country.options[theform.Country.selectedIndex].value == "") {
		theform.State.disabled=false;
		theform.Province.disabled=false;
		if (theform.Province.value == "select above") theform.Province.value="";
	}
	else {
		theform.State.options[0].text="type below";
		theform.State.selectedIndex=0;
		theform.State.disabled=true;
		if (theform.Province.value == "select above") theform.Province.value="";
		theform.Province.disabled=false;
	}
	// catch unaccepted countries
	if (theform.Country.options[theform.Country.selectedIndex].value == "XX") {
		alert('Sorry, this offer currently applies only to the countries of residence listed.');
		theform.Country.focus();
	}
}

function checkRequestInfoForm(theform) {
	
	// flag user submit
	theform.boolUserSubmit.value = 1;
	
	// validate program selection
	var obj = theform.DegreeProgramID;
	if (obj.options[obj.selectedIndex].value == 0 || obj.options[obj.selectedIndex].value == '') {
		alert('Please select a Program of interest.');
		obj.focus();
		return false;
	}

	var cid = theform.CollegeID;
	if (cid.options[cid.selectedIndex].value == 0 || cid.options[cid.selectedIndex].value == '') {
		alert('Please select a Campus Location.');
		cid.focus();
		return false;
	}
	
	// validate YearHSGED selection
	var obj = theform.YearHSGED;
	var selectedYearHSGED = obj.options[obj.selectedIndex].value;
	if (selectedYearHSGED != '') {
		if (!checkYearHSGED(selectedYearHSGED)) {
			alert('We\'re sorry, Westwood College is unable to accept inquiries from candidates graduating high school '+selectedYearHSGED+' or later.');
			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.Address1.required = true;
	theform.Address1.requiredError = 'The Street Address field must be filled in.';
	
	theform.City.required = true;
	theform.City.requiredError = 'The City field must be filled in.';
	
	theform.Country.required = true;
	theform.Country.requiredError = 'A Country must be selected.';
	theform.Country.disallowEmptyValue = true;
	theform.Country.disallowEmptyValueError = 'A Country must be selected.';
	
	if ((theform.Country.options[theform.Country.selectedIndex].value == "US") || (theform.Country.options[theform.Country.selectedIndex].value == "CA")) {
		theform.State.required = true;
		theform.State.requiredError = 'A State must be selected.';
		theform.State.disallowEmptyValue = true;
		theform.State.disallowEmptyValueError = 'A State/Province must be selected.';
		theform.Province.required = false;
	}
	else {
		theform.Province.required = true;
		theform.Province.requiredError = 'The State/Province field must be filled in.';
		theform.State.required = false;
		theform.State.disallowEmptyValue = false;
	}
	
	if (theform.Country.options[theform.Country.selectedIndex].value == "US") {
		theform.Zip.pattern = 'zipcode';
		theform.Zip.patternError = 'The US Zip Code entered is not valid (must be exactly 5 numeric digits).';
	}
	else if (theform.Country.options[theform.Country.selectedIndex].value == "CA") {
		theform.Zip.pattern = 'postal code';
		theform.Zip.patternError = 'The Canadian Postal Code entered is not valid (use ANA NAN or ANA-NAN format).';
	}
	else {
		theform.Zip.required = true;
		theform.Zip.requiredError = 'The Zip/Postal Code field must be filled in.';
		theform.Zip.pattern = '';
	}
	
	if ((theform.Country.options[theform.Country.selectedIndex].value == "US") || (theform.Country.options[theform.Country.selectedIndex].value == "CA")) {
		theform.DaytimePhone.pattern = 'us phone number';
		theform.DaytimePhone.patternError = 'The Daytime Phone number is not valid.';
	}
	else {
		theform.DaytimePhone.required = true;
		theform.DaytimePhone.requiredError = 'The Daytime Phone number field must be filled in.';
		theform.DaytimePhone.pattern = '';
	}
	
	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;
}