//Front end validation of registration form fields (specifically for JS Landing Page)
function validFormFields() {
	//Grab field values from F form
	var strFirstName = document.JSLandingReg.FFirstName.value;
	var strLastName = document.JSLandingReg.FLastName.value;
	var strEmail = document.JSLandingReg.FEAdd.value;
	var strIndustry = document.JSLandingReg.FCareerFocus1.value;
	var strJobTitle = document.JSLandingReg.FTitle.value;
	var strPostalCode = document.JSLandingReg.FZipCode.value;
	var strNewsletter = valButton(document.JSLandingReg.FNewsletter);
	//Start checking lengths of fields (lengths equal to those accepted by DB fields)
	var bAlertThrown = !(validFieldLength(strFirstName, "first name", 1, 50));
	if (!bAlertThrown) { bAlertThrown = !(validFieldLength(strLastName, "last name", 1, 50)); }
	if (!bAlertThrown) { bAlertThrown = !(validFieldLength(strEmail, "email", 1, 100)); }
	if (!bAlertThrown) { bAlertThrown = !(validFieldLength(strJobTitle, "job title", 1, 100)); }
	if (!bAlertThrown) { bAlertThrown = !(validFieldLength(strPostalCode, "postal code", 1, 10)); }
	//Verify first name, last name, and job title fields were actually filled out (rather than containing default content)
	if (!bAlertThrown) {
		if (strFirstName == 'First Name') {
			alert("Please verify that you have entered a first name.")
			bAlertThrown = true;
		}
	}
	if (!bAlertThrown) {
		if (strLastName == 'Last Name') {
			alert("Please verify that you have entered a last name.")
			bAlertThrown = true;
		}
	}
	//Verify industry value
	if (!bAlertThrown) {
		if (strIndustry == 174) {
			alert("Please select your industry focus from the drop down list provided.");
			bAlertThrown = true;
		}
	}
	if (!bAlertThrown) {
		if (strJobTitle == 'Job Title / Position') {
			alert("Please verify that you have entered a job title / position.")
			bAlertThrown = true;
		}
	}
	//Check email validity
	if (!bAlertThrown) { bAlertThrown = !(validateEmail(document.JSLandingReg.FEAdd)); }
	//Verify newsletter radio button has a selected item
	if (!bAlertThrown) {
		if (strNewsletter == null) {
			alert("Please select whether or not you would like to receive the career newsletter.")
			bAlertThrown = true;
		}
	}
	return (!bAlertThrown);
}

//On click of the submit button, validate fields and then submit them to action page
function submitTasks() {
	var bValidFormInput = validFormFields();
	if (bValidFormInput) {
		document.JSLandingReg.submit();
		return true;
	} else {
		return false;
	}
}
