function ProgramChange() {
	var theform = document.RequestInfoForm;
	theform.boolProgramChange.value = 1;
	theform.boolUserSubmit.value = 0;
	theform.submit();
}

function CampusChange() {
	var theform = document.RequestInfoForm;
	theform.boolCampusChange.value = 1;
	theform.boolUserSubmit.value = 0;
	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;
	}
	
	// validate campus selection
	var obj = theform.CollegeID;
	if (obj.options[obj.selectedIndex].value == 0 || obj.options[obj.selectedIndex].value == '') {
		alert('Please select a Campus.');
		obj.focus();
		return false;
	}
	
	// validate YearHSGED selection
	var obj = theform.YearHSGED;
	var selectedYearHSGED = obj.options[obj.selectedIndex].value;
	if (selectedYearHSGED != '') {
		if (!checkYearHSGED(selectedYearHSGED)) {
			alert(getMessage(theform.CollegeID.value));
			obj.focus();
			return false;
		}
	}
	if (theform.TimeFrame!=undefined){
	// validate Time Frame selection
		if (theform.TimeFrame.options[theform.TimeFrame.selectedIndex].value=='') {
			alert('Please make a selection from the when are you interested in beginning classes area.');
			theform.TimeFrame.focus();
			return false;
		}
		
		if (!theform.AcceptAgreement.checked){
			alert('You must agree to be contacted by a Westwood College representative to discuss your options, please check the box.');
			theform.AcceptAgreement.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.';

	// validate education selection
	var obj = theform.education;
	if (obj.options[obj.selectedIndex].value == 0 || obj.options[obj.selectedIndex].value == '') {
		alert('Please select a Level of Education.');
		obj.focus();
		return false;
	}
	
	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;
}

//code to display a custom message for respondents who are too young based on the type of school
function getMessage(collegeID){
	var theform = document.RequestInfoForm;
	var obj = theform.YearHSGED;
	var selectedYearHSGED = obj.options[obj.selectedIndex].value;
	if (collegeID == '19'){ //online
		theMessage = 'Thank you very much for your interest in Westwood College Online.  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 Westwood 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 Westwood.';
	}
	else if (collegeID == '6'){ //aviation
		theMessage = '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 Westwood.';
	}
	else if (collegeID == '9'){ //aviation
		theMessage = '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 Westwood.';
	}
	else{ //tech
		theMessage = 'Thank you very much for your interest in Westwood 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 Westwood 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 Westwood.';
	}
	return theMessage;
}