//scripts for the FMEC web site
//created by Nancy Snow/Iris NetWare

function sendSubmission(form) {

//check that the status has been provided
	//first, set status variable from radio button input 
	var myStatus = "";

	for (var i = 0; i < form.status.length; i++) {
		if (form.status[i].checked) {
			myStatus = form.status[i].value;
		}
	}

	//next, check that the status is not blank
	if (myStatus == "") {
		alert("Please provide your status and resubmit.");
		form.status[0].focus();
		return false;
	}

	//finally, check that the "Other" text box has been completed
	if (( myStatus == "other" ) && (form.OtherStatus.value == "")) {
		alert("Please describe your status and resubmit.");
		form.OtherStatus.focus();
		form.OtherStatus.select();
		return false;
	}

//check that the salutation has been provided
	//first, set status variable from radio button input 
	var mySalutation = "";

	for (var i = 0; i < form.salutation.length; i++) {
		if (form.salutation[i].checked) {
			mySalutation = form.salutation[i].value;
		}
	}

	//next, check that the category is not blank
	if (mySalutation == "") {
		alert("Please provide the salutation to be used in correspondence and resubmit.");
		form.salutation[0].focus();
		return false;
	}


//check for complete author information
	if (form.firstName.value == "") {
		alert("Please provide the name of the primary author and resubmit.");
		form.firstName.focus();
		form.firstName.select();
		return false;
	}

	if (form.lastName.value == "") {
		alert("Please provide the last name of the primary author and resubmit.");
		form.lastNameDegree.focus();
		form.lastNameDegree.select();
		return false;
	}

	if (form.degree.value == "") {
		alert("Please provide the degree of the primary author and resubmit. Entries such as 'MD', 'RN', or 'MSIV' are expected.");
		form.degree.focus();
		form.degree.select();
		return false;
	}

	if (form.institution.value == "") {
		alert("Please provide the institution or affiliation of the primary author and resubmit.");
		form.institution.focus();
		form.institution.select();
		return false;
	}

	if (form.department.value == "") {
		alert("Please provide the department of the primary author and resubmit.");
		form.department.focus();
		form.department.select();
		return false;
	}

	if (form.address1.value == "") {
		alert("Please provide the mailing address of the primary author and resubmit.");
		form.address1.focus();
		form.address1.select();
		return false;
	}

	if (form.city.value == "") {
		alert("Please provide the city of the primary author and resubmit.");
		form.city.focus();
		form.city.select();
		return false;
	}

	if (form.state.value == "") {
		alert("Please provide the state of the primary author and resubmit.");
		form.state.focus();
		form.state.select();
		return false;
	}

	if (form.zip.value == "") {
		alert("Please provide the Zip code of the primary author and resubmit.");
		form.zip.focus();
		form.zip.select();
		return false;
	}

//validate the first author's work phone number
	re = /^\(\d{3}\)\d{3}\-\d{4}$/;
	if (!re.test(form.workPhone.value)) {
		alert("Please enter a phone number in the format '(555)123-4567' (no spaces) and resubmit.");
		form.workPhone.focus();
		form.workPhone.select();
		return false;
	}

//validate the first author's fax number
	if ((form.fax.value > "") && (!re.test(form.fax.value))) {
		alert("Please enter a fax number in the format '(555)123-4567' (no spaces) and resubmit.");
		form.fax.focus();
		form.fax.select();
		return false;
	}

//validate the first author's e-mail address
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,5})+$/;
	if (!re.test(form.email.value)) {
		alert("Please enter a complete e-mail address for the primary author and resubmit.");
		form.email.focus();
		form.email.select();
		return false;
	}

//validate the second author's e-mail address
	if (!(form.author2Email.value == "") && (!re.test(form.author2Email.value))) {
		alert("Please enter a complete e-mail address for the second author and resubmit.");
		form.author2Email.focus();
		form.author2Email.select();
		return false;
	}

	
//validate the third author's e-mail address
	if (!(form.author3Email.value == "") && (!re.test(form.author3Email.value))) {
		alert("Please enter a complete e-mail address for the third author and resubmit.");
		form.author3Email.focus();
		form.author3Email.select();
		return false;
	}

//validate the fourth author's e-mail address
	if (!(form.author4Email.value == "") && (!re.test(form.author4Email.value))) {
		alert("Please enter a complete e-mail address for the fourth author and resubmit.");
		form.author4Email.focus();
		form.author4Email.select();
		return false;
	}

//validate the fifth author's e-mail address
	if (!(form.author5Email.value == "") && (!re.test(form.author5Email.value))) {
		alert("Please enter a complete e-mail address for the fifrth author and resubmit.");
		form.author5Email.focus();
		form.author5Email.select();
		return false;
	}

//check that the category has been provided
	//first, set status variable from radio button input 
	var myCategory = "";

	for (var i = 0; i < form.submissionCategory.length; i++) {
		if (form.submissionCategory[i].checked) {
			myCategory = form.submissionCategory[i].value;
		}
	}

	//next, check that the category is not blank
	if (myCategory == "") {
		alert("Please provide the category for this presentation and resubmit.");
		form.submissionCategory[0].focus();
		return false;
	}

//check for a title
	if (form.itemTitle.value == "") {
		alert("Please provide the title of the presentation and resubmit.");
		form.itemTitle.focus();
		form.itemTitle.select();
		return false;
	}

//check for an abstract
	if (form.myAbstract.value == "") {
		alert("Please provide an abstract for the presentation and resubmit.");
		form.myAbstract.focus();
		form.myAbstract.select();
		return false;
	}

}


function sendEvaluation( form ) {


//check that the numeric ratings have been provided
var fieldValue;

	//set status variable from radio button input 
	fieldValue = "";
	for (var i = 0; i < form.classLevel.length; i++) {
		if (form.classLevel[i].checked) {
			fieldValue = form.classLevel[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide your class level and resubmit.");
		form.classLevel[0].focus();
		return false;
	}

	//set status variable from radio button input 
	fieldValue = "";
	for (var i = 0; i < form.attendance.length; i++) {
		if (form.attendance[i].checked) {
			fieldValue = form.attendance[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide the number of times you've attended this meeting and resubmit.");
		form.attendance[0].focus();
		return false;
	}

	//set status variable from radio button input 
	fieldValue = "";
	for (var i = 0; i < form.awareness.length; i++) {
		if (form.awareness[i].checked) {
			fieldValue = form.awareness[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide a rating where indicated and resubmit.");
		form.awareness[0].focus();
		return false;
	}

	//set status variable from radio button input 
	fieldValue = "";
	for (var i = 0; i < form.differentiate.length; i++) {
		if (form.differentiate[i].checked) {
			fieldValue = form.differentiate[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide a rating where indicated and resubmit.");
		form.differentiate[0].focus();
		return false;
	}

	//set status variable from radio button input 
	fieldValue = "";
	for (var i = 0; i < form.understandRole.length; i++) {
		if (form.understandRole[i].checked) {
			fieldValue = form.understandRole[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide a rating where indicated and resubmit.");
		form.understandRole[0].focus();
		return false;
	}

	//set status variable from radio button input 
	fieldValue = "";

	for (var i = 0; i < form.understandCareer.length; i++) {
		if (form.understandCareer[i].checked) {
			fieldValue = form.understandCareer[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide a rating where indicated and resubmit.");
		form.understandCareer[0].focus();
		return false;
	}

	//set status variable from radio button input 
	fieldValue = "";

	for (var i = 0; i < form.discussFP.length; i++) {
		if (form.discussFP[i].checked) {
			fieldValue = form.discussFP[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide a rating where indicated and resubmit.");
		form.discussFP[0].focus();
		return false;
	}

	//set status variable from radio button input 
	fieldValue = "";

	for (var i = 0; i < form.supportFP.length; i++) {
		if (form.supportFP[i].checked) {
			fieldValue = form.supportFP[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide a rating where indicated and resubmit.");
		form.supportFP[0].focus();
		return false;
	}

	//set status variable from radio button input 
	fieldValue = "";

	for (var i = 0; i < form.residencies.length; i++) {
		if (form.residencies[i].checked) {
			fieldValue = form.residencies[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide a rating where indicated and resubmit.");
		form.residencies[0].focus();
		return false;
	}

	//set status variable from radio button input 
	var fieldValue = "";

	for (var i = 0; i < form.resources.length; i++) {
		if (form.resources[i].checked) {
			fieldValue = form.resources[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide a rating where indicated and resubmit.");
		form.resources[0].focus();
		return false;
	}

}

function sendScholarship (form) {

//check that critical field information has been provided
var fieldValue;

	//check that the student's name is not blank
	fieldValue = form.studentFirstName.value
	if (fieldValue == "") {
		alert("Please provide your first name.");
		form.studentFirstName.focus();
		return false;
	}

	fieldValue = form.studentLastName.value
	if (fieldValue == "") {
		alert("Please provide your last name.");
		form.studentLastName.focus();
		return false;
	}

	fieldValue = form.medicalSchool.value
	if (fieldValue == "") {
		alert("Please provide the name of your medical school.");
		form.medicalSchool.focus();
		return false;
	}

	//set status variable from radio button input 
	fieldValue = "";
	for (var i = 0; i < form.classLevel.length; i++) {
		if (form.classLevel[i].checked) {
			fieldValue = form.classLevel[i].value;
		}
	}

	//check that the category is not blank
	if (fieldValue == "") {
		alert("Please provide your class level.");
		form.classLevel[0].focus();
		return false;
	}


	//check that the mailing address is not blank
	fieldValue = form.streetAddress.value
	if (fieldValue == "") {
		alert("Please provide your mailing address.");
		form.streetAddress.focus();
		return false;
	}

	//check that the city is not blank
	fieldValue = form.city.value
	if (fieldValue == "") {
		alert("Please provide your city.");
		form.city.focus();
		return false;
	}

	//check that the state is not blank
	fieldValue = form.state.value
	if (fieldValue == "") {
		alert("Please provide your state.");
		form.state.focus();
		return false;
	}


	//check that the Zip code is not blank
	fieldValue = form.zip.value
	if (fieldValue == "") {
		alert("Please provide your Zip code.");
		form.zip.focus();
		return false;
	}

	//check that the phone number is not blank
	fieldValue = form.phone.value
	if (fieldValue == "") {
		alert("Please provide your phone number.");
		form.phone.focus();
		return false;
	}

	//check that the email address is not blank
	fieldValue = form.email.value
	if (fieldValue == "") {
		alert("Please provide your email address.");
		form.email.focus();
		return false;
	}


}