function checkForValidRole()
{
	var boolRBChecked;
	for (var i = 0; i < 5; i++) {
		if (document.form1_role_form.form1_role[i].checked){
			boolRBChecked = true;
		}
	}

	if (!boolRBChecked) {
		alert('You must select a role before proceeding.');
		return false;
	}
	return true;
}

function checkContactInfo()
{
	var errorMsg = "";
	var errorDisplay = "The following problems were ";
	errorDisplay += "encountered with your submission:";
	
	if (document.form2_contact_info_form.form2_last_name.value == "") {
		errorMsg += "\n - You must fill in your last name";
	}
	
	if (document.form2_contact_info_form.form2_first_name.value == "") {
		errorMsg += "\n - You must fill in your first name";
	}
	
	if (document.form2_contact_info_form.form2_organization_firm.value == "") {
		errorMsg += "\n - You must specify the name of ";
		errorMsg += "the firm or organization for which you work"; 
	}
	
	if (document.form2_contact_info_form.form2_street_address.value == "") {
		errorMsg += "\n - You must specify your street address.";
	}
	
	if (document.form2_contact_info_form.form2_city.value == "") {
		errorMsg += "\n - You must specify your city.";
	}
	
	if (document.form2_contact_info_form.form2_county.value == "") {
		errorMsg += "\n - You must specify your county.";
	}
	
	if (document.form2_contact_info_form.form2_zip.value == "") {
		errorMsg += "\n - You must specify your zip code.";
	}
	
	if (document.form2_contact_info_form.form2_telephone.value == "") {
		errorMsg += "\n - You must specify your telephone number.";
	}
	
	if (document.form2_contact_info_form.form2_wheelchair_access.options[document.form2_contact_info_form.form2_wheelchair_access.selectedIndex].value == "Yes or No") {
		errorMsg += "\n - You must specify whether your location is wheelchair accessible.";
	}
	
	if (errorMsg != "") {
		alert(errorDisplay + errorMsg);
		return false;
	}
	
	return true;
}
//Form Four All
function checkInteger(fieldName)
{
	if (isNaN(fieldName.value)) {
		alert("Field requires an integer value.");
		fieldName.value = 0;
		fieldName.focus();
	}
}

//Form Four Mediator
function buildTotalM(fieldName)
{
	checkInteger(fieldName);
	form4AddUpTotalMediator();
}

function form4AddUpTotalMediator()
{
	var currentTotal = 0;
	
	if (!isNaN(document.form4_profile.form4_ttlHrs_basicMediation.value)) {
		currentTotal += Number(document.form4_profile.form4_ttlHrs_basicMediation.value);
	}
	
	if (!isNaN(document.form4_profile.form4_ttlHrs_custodyTraining.value)) {
		currentTotal += Number(document.form4_profile.form4_ttlHrs_custodyTraining.value);
	}
	
	if (!isNaN(document.form4_profile.form4_ttlHrs_maritalProperty.value)) {
		currentTotal += Number(document.form4_profile.form4_ttlHrs_maritalProperty.value);
	}
	
	if (!isNaN(document.form4_profile.form4_ttlHrs_advMediation.value)) {
		currentTotal += Number(document.form4_profile.form4_ttlHrs_advMediation.value);
	}
	
	if (!isNaN(document.form4_profile.form4_ttlHrs_otherADR.value)) {
		currentTotal += Number(document.form4_profile.form4_ttlHrs_otherADR.value);
	}
		
	document.form4_profile.form4_ttlHrs_ofTraining.value = Number(currentTotal);
}

//Validate Mediator Form
function validateMediatorForm4()
{
	finalIntegerCheckMediatorForm4();
	checkTotalsMediator();
}


function checkTotalsMediator()
{
	var message = "You do not meet the minimum training requirements. ";
	message += "You may volunteer for the pro-bono panel ";
	message += "if you have fewer than 40 hours of training. ";
	message += "If you have any questions about this policy, please contact ";
	message += "Roger Wolf at the Center for Dispute Resolution 410-706-3836."; 
	
	if (document.form4_profile.form4_ttlHrs_basicMediation.value < 40) 
	{
	alert(message); 
	}
}

function finalIntegerCheckMediatorForm4()
{
	var errorMsg = "";
	var errorDisplay = "The following problems were ";
	errorDisplay += "encountered with your submission:";
	
	if (isNaN(document.form4_profile.form4_prcnt_mediation_exp.value)) {
		errorMsg += '\n	- You must enter an integer in the "% Mediation" field.';
	}
	
	
	if (isNaN(document.form4_profile.form4_ttlHrs_basicMediation.value)) {
		errorMsg += '\n	- You must enter an integer in the "Total # Hours basic mediation" field';
	}
	
	if (isNaN(document.form4_profile.form4_ttlHrs_custodyTraining.value)) {
		errorMsg += '\n	- You must enter an integer in the "Total # Hours custody training" field';
	}
	
	if (isNaN(document.form4_profile.form4_ttlHrs_maritalProperty.value)) {
		errorMsg += '\n	- You must enter an integer in the "Total # Hours marital property" field';
	}
	
	if (isNaN(document.form4_profile.form4_ttlHrs_advMediation.value)) {
		errorMsg += '\n	- You must enter an integer in the "Total # Hours advanced mediation training" field';
	}
	
	if (isNaN(document.form4_profile.form4_ttlHrs_otherADR.value)) {
		errorMsg += '\n	- You must enter an integer in the "Total # Hours Other ADR training" field';
	}	
	
	if (errorMsg != "") {
		alert(errorDisplay + errorMsg);
		return false;
	}
	
	return true;
}

//Form 4 Arbitrator

function buildTotalA(fieldName)
{
	checkInteger(fieldName);
	form4AddUpTotalArbitrator();
}

function form4AddUpTotalArbitrator() {
	var currentTotal = 0;
	
	currentTotal += Number(document.form4_profile.form4_ttlHrs_custodyTraining.value);
	currentTotal += Number(document.form4_profile.form4_ttlHrs_maritalProperty.value);
	currentTotal += Number(document.form4_profile.form4_ttlHrs_arbitration.value);
	currentTotal += Number(document.form4_profile.form4_ttlHrs_otherADR.value);
	document.form4_profile.form4_ttlHrs_ofTraining.value = Number(currentTotal);
}

//Validate Arbitrator Form
function validateArbitratorForm4() {
	var bOk = false;
	var i = 0;
	
	form4AddUpTotalArbitrator();
	for (i=0; i<document.form4_profile.form4_numCases_arbitrated.length; i++) {
		if (document.form4_profile.form4_numCases_arbitrated[i].checked) {
			bOk = true;
			break;
		}
	}
	
	if (!bOk) {
		alert("Please select the number of cases you have Arbitrated in the last 5 years.");
		return false;
	} else if (document.form4_profile.form4_ttlHrs_arbitration.value < 8 && (i == 0 || i == 1)) {
		var message = "You do not meet the minimum training requirements. ";
		message += "You may volunteer for the pro-bono panel ";
		message += "if you have fewer than 40 hours of training. ";
		message += "If you have any questions about this policy, please contact ";
		message += "Roger Wolf at the Center for Dispute Resolution 410-706-3836."; 
		alert(message);
		return true;
	} else {
		return true;
	}
}

//Form 4 SCF

function buildTotalSCF(fieldName)
{
	checkInteger(fieldName);
	form4AddUpTotalSCF();
}

function form4AddUpTotalSCF()
{
	var currentTotal = 0;
	
	if (!isNaN(document.form4_profile.form4_ttlHrs_settleConf.value)) {
		currentTotal += Number(document.form4_profile.form4_ttlHrs_settleConf.value);
	}
	
	if (!isNaN(document.form4_profile.form4_ttlHrs_otherADR.value)) {
		currentTotal += Number(document.form4_profile.form4_ttlHrs_otherADR.value);
	}
		
	document.form4_profile.form4_ttlHrs_ofTraining.value = Number(currentTotal);
}

function validateSCFForm4()
{
	var errorMsg = "";
	var errorDisplay = "The following problems were ";
	errorDisplay += "encountered with your submission:";
	
	if (isNaN(document.form4_profile.form4_prcnt_settlementConf_exp.value)) {
		errorMsg += '\n	- You must enter an integer in the "% of practice for Settlement Conference Facilitation" field.';
	}
	
	if (isNaN(document.form4_profile.form4_ttlHrs_settleConf.value)) {
		errorMsg += '\n	- You must enter an integer in the "Total # Hours settlement conference facilitator training" field';
	}
	
	if (isNaN(document.form4_profile.form4_ttlHrs_otherADR.value)) {
		errorMsg += '\n	- You must enter an integer in the "Total # Hours Other ADR training" field';
	}	
	if (errorMsg != "") {
		alert(errorDisplay + errorMsg);
		return false;
	}
	
	return true;
}
//Form 4 LGF

function buildTotalLGF(fieldName)
{
	checkInteger(fieldName);
	form4AddUpTotalLGF();
}

function form4AddUpTotalLGF()
{
	var currentTotal = 0;
	
	if (!isNaN(document.form4_profile.form4_ttlHrs_lrgGrpFacil.value)) {
		currentTotal += Number(document.form4_profile.form4_ttlHrs_lrgGrpFacil.value);
	}
	
	if (!isNaN(document.form4_profile.form4_ttlHrs_otherADR.value)) {
		currentTotal += Number(document.form4_profile.form4_ttlHrs_otherADR.value);
	}
		
	document.form4_profile.form4_ttlHrs_ofTraining.value = Number(currentTotal);
}

function validateLGFForm4()
{
	var errorMsg = "";
	var errorDisplay = "The following problems were ";
	errorDisplay += "encountered with your submission:";
	
	if (isNaN(document.form4_profile.form4_prcnt_lrgGrpFacil_exp.value)) {
		errorMsg += '\n	- You must enter an integer in the "% of practice for Large Group Dispute Resolution Facilitation" field.';
	}
	
	if (isNaN(document.form4_profile.form4_ttlHrs_lrgGrpFacil.value)) {
		errorMsg += '\n	- You must enter an integer in the "Total # Hours Large Group Dispute Resolution facilitator training" field';
	}
	
	if (isNaN(document.form4_profile.form4_ttlHrs_otherADR.value)) {
		errorMsg += '\n	- You must enter an integer in the "Total # Hours Other ADR training" field';
	}	
	if (errorMsg != "") {
		alert(errorDisplay + errorMsg);
		return false;
	}
	
	return true;
}
//Form 4 Trainers
//Not Required

//Form 6 Validation 
//function checkContentAreas()
//{
//} 

// Pro Bono Validation
function flagDisqualifyingQuantities()
{
	var message = "Please note: You do not meet the minimum case requirements. ";
	message += "You may volunteer for the ";
	message += "pro-bono panel if you have fewer than 4 cases ";
	message += "that you have mediated or arbitrated in the past 5 years.  ";
	message += "You will be given an opportunity to volunteer for the ";
	message += "pro-bono panel later in this process.  If you choose not ";
	message += "to participate in the pro-bono panel, your entry will be ";
	message += "disqualified.  ";
	message += "If you have any questions about this policy, please contact ";
	message += "Roger Wolf at the Center for Dispute Resolution 410-706-3836."; 
	
	alert(message);
}


function validateAdditiveSearchForm()
{
	if (
		String(document.form1.type_of_practice.options[document.form1.type_of_practice.selectedIndex].value).match(/-- Select Specialty --/)
		&& String(document.form1.county_of_practice.options[document.form1.county_of_practice.selectedIndex].value).match(/-- Select County --/)
		&& String(document.form1.content_areas.options[document.form1.content_areas.selectedIndex].value).match(/-- Select Topic --/)
		&& document.form1.wheelchair_access.checked == 0
		
		) {
		
			alert ("You must select at least one field to use this form\n");
			return false;
		}
}

function validateAdditiveSearchForm3()
{
	if (
		String(document.form3.type_of_practice.options[document.form3.type_of_practice.selectedIndex].value).match(/-- Select Specialty --/)
		&& String(document.form3.county_of_practice.options[document.form3.county_of_practice.selectedIndex].value).match(/-- Select County --/)
		&& String(document.form3.content_areas.options[document.form3.content_areas.selectedIndex].value).match(/-- Select Topic --/)
		&& document.form3.pro_bono_panel.checked == 0
		
		) {
		
			alert ("You must select at least one field to use this form\n");
			return false;
		}
}

function generateDate()
{
	var d			= new Date();
	var month		= d.getMonth();
	var day			= d.getDay();
	var year		= d.getFullYear();
	var fullDate	= day + "/" + month + "/" + year;
	return fullDate;
}

function checkCountyInfo()
{
	var boolCountyChecked;
	for (var i = 0; i < 24; i++) {
		if (document.form10_county_form.form10_county[i].checked){
			boolCountyChecked = true;
		}
	}

	if (!boolCountyChecked) {
		alert('You must select a county before proceeding.');
		return false;
	}
	return true;
}

// Form 9 - Optional Co-Mediation Page
function checkReferences()
{
	var errorMsg = "";
	var errorDisplay = "The following problems were ";
	errorDisplay += "encountered with your submission:";
	
	if (document.form9_references_form.form9_provideReferencesEmail.options[document.form9_references_form.form9_provideReferencesEmail.selectedIndex].value == "Yes or No") {
		errorMsg += "\n - You must specify whether you are willing to provide references by email.";
	}
	
	if (document.form9_references_form.form9_provideReferencesPhone.options[document.form9_references_form.form9_provideReferencesPhone.selectedIndex].value == "Yes or No") {
		errorMsg += "\n - You must specify whether you are willing to provide references by phone.";
	}
	
	if (errorMsg != "") {
		alert(errorDisplay + errorMsg);
		return false;
	}
	
	return true;
}
function checkPracticeStatement()
{
	var errorMsg = "";
	var errorDisplay = "The following problems were ";
	errorDisplay += "encountered with your submission:";
	
	if (document.form7_practice_statement.form7_practiceStatement.value == "") {
		errorMsg += "\n - You must complete the Statement of Practice and Qualifications";
	}
	
	
	if (errorMsg != "") {
		alert(errorDisplay + errorMsg);
		return false;
	}
	
	return true;
}

//Form 6 Content Areas 
function checkForm() {
	with (document.forms[0]) {
		field5	= form6_desc_childCustody.value
		field6	= form6_childCustody_numCasesTotal.value
		field7	= form6_childCustody_numCasesMD.value
		field8	= form6_childCustody_numYears.value

		field9	= form6_desc_maritalProperty.value
		field10	= form6_maritalProperty_numCasesTotal.value
		field11 = form6_maritalProperty_numCasesMD.value
		field12 = form6_maritalProperty_numYears.value

		field13 = form6_desc_familyOther.value
		field14 = form6_familyOther_numCasesTotal.value
		field15 = form6_familyOther_numCasesMD.value
		field16 = form6_familyOther_numYears.value

		field17 = form6_desc_agriculture.value
		field18 = form6_agriculture_numCasesTotal.value
		field19 = form6_agriculture_numCasesMD.value
		field20 = form6_agriculture_numYears.value

		field21 = form6_desc_business.value
		field22 = form6_business_numCasesTotal.value
		field23 = form6_business_numCasesMD.value
		field24 = form6_business_numYears.value

		field25 = form6_desc_construction.value
		field26 = form6_construction_numCasesTotal.value
		field27 = form6_construction_numCasesMD.value
		field28 = form6_construction_numYears.value

		field29 = form6_desc_criminalMisdemeanors.value
		field30 = form6_criminalMisdemeanors_numCasesTotal.value
		field31 = form6_criminalMisdemeanors_numCasesMD.value
		field32 = form6_criminalMisdemeanors_numYears.value

		field33 = form6_desc_education.value
		field34 = form6_education_numCasesTotal.value
		field35 = form6_education_numCasesMD.value
		field36 = form6_education_numYears.value

		field37 = form6_desc_employment.value
		field38 = form6_employment_numCasesTotal.value
		field39 = form6_employment_numCasesMD.value
		field40 = form6_employment_numYears.value

		field41 = form6_desc_environment.value
		field42 = form6_environment_numCasesTotal.value
		field43 = form6_environment_numCasesMD.value
		field44 = form6_environment_numYears.value

		field45 = form6_desc_health.value
		field46 = form6_health_numCasesTotal.value
		field47 = form6_health_numCasesMD.value
		field48 = form6_health_numYears.value

		field49 = form6_desc_insPersonalInjury.value
		field50 = form6_insPersonalInjury_numCasesTotal.value
		field51 = form6_insPersonalInjury_numCasesMD.value
		field52 = form6_insPersonalInjury_numYears.value

		field53 = form6_desc_intellectualProperty.value
		field54 = form6_intellectualProperty_numCasesTotal.value
		field55 = form6_intellectualProperty_numCasesMD.value
		field56 = form6_intellectualProperty_numYears.value

		field57 = form6_desc_labor.value
		field58 = form6_labor_numCasesTotal.value
		field59 = form6_labor_numCasesMD.value
		field60 = form6_labor_numYears.value

		field61 = form6_desc_maritime.value
		field62 = form6_maritime_numCasesTotal.value
		field63 = form6_maritime_numCasesMD.value
		field64 = form6_maritime_numYears.value

		field65 = form6_desc_neighborhood.value
		field66 = form6_neighborhood_numCasesTotal.value
		field67 = form6_neighborhood_numCasesMD.value
		field68 = form6_neighborhood_numYears.value

		field69 = form6_desc_publicPolicy.value
		field70 = form6_publicPolicy_numCasesTotal.value
		field71 = form6_publicPolicy_numCasesMD.value
		field72 = form6_publicPolicy_numYears.value

		field73 = form6_desc_sciTech.value
		field74 = form6_sciTech_numCasesTotal.value
		field75 = form6_sciTech_numCasesMD.value
		field76 = form6_sciTech_numYears.value

		field77 = form6_desc_landlord.value
		field78 = form6_landlord_numCasesTotal.value
		field79 = form6_landlord_numCasesMD.value
		field80 = form6_landlord_numYears.value

		field81 = form6_desc_peaceorders.value
		field82 = form6_peaceorders_numCasesTotal.value
		field83 = form6_peaceorders_numCasesMD.value
		field84 = form6_peaceorders_numYears.value

		field85 = form6_desc_smallclaims.value
		field86 = form6_smallclaims_numCasesTotal.value
		field87 = form6_smallclaims_numCasesMD.value
		field88 = form6_smallclaims_numYears.value

		field89 = form6_desc_medicalmal.value
		field90 = form6_medicalmal_numCasesTotal.value
		field91 = form6_medicalmal_numCasesMD.value
		field92 = form6_medicalmal_numYears.value

		var i = 1
		var j = 2
		var k = 3
		var l = 4
		
		while (i < 93) {
			i += 4;
			j += 4;
			k += 4;
			l += 4;
			
			try 
			{
				if ((eval("field" + i) == "") && (eval("field" + j) == "") && (eval("field" + k) == "") && (eval("field" + l) == "")) {
					continue;
				} else if ((eval("field" + i) != "") && (eval("field" + j) != "") && (eval("field" + k) != "") && (eval("field" + l) != "")) { 
					continue;
				} else {
					alert ("Please complete all four fields of data");
					return false;
				}
			}
			catch (err) { var error = err; }
		}
		
		/*
		do {
			if ((eval("field" + i) == "") && (eval("field" + j) == "") && (eval("field" + k) == "") && (eval("field" + l) == "")) {
				return true
			} else if ((eval("field" + i) != "") && (eval("field" + j) != "") && (eval("field" + k) != "") && (eval("field" + l) != "")) { 
				return true
			} else {
				alert ("Please complete all four fields of data");
				return false
			}
			i = i + 4
			j = j + 4
			k = k + 4
			l = l + 4
		} while (i < 70)
		*/
	}
}

