// JavaScript Document to validate CFF Non Financial Application

   //function-set field checker for submit button
   //checks to make sure certain fields are completed
   function CheckBox(){
   var addForm = document.cff_program;

      <!--Section Two Volunteer Request / COMPLETE-->
   if (addForm.StartMonth.value != "" || addForm.StartDay.value != "" || addForm.StartYear.value != "" || addForm.EndMonth.value != "" || addForm.EndDay.value != "" || addForm.EndYear.value != "" || addForm.EventStartTime.value !="" || addForm.EventEndTime.value !="" || addForm.NumberOfVolunteers.value !="" || addForm.ProjectLocation.value !="" || addForm.IndividualsImpacted.value !="" || addForm.ActivityDescription.value !="" || addForm.EnvironmentAndSafetyConcerns.value !="" || addForm.Insurance[0].checked || addForm.Insurance[1].checked || addForm.VolunteerAge[0].checked || addForm.InsuranceComment.value !="" || addForm.EquipmentRequest.value !=""){
 addForm.VolunteerAssistance.checked=true;
      }
   <!--Section Three Computer Request / COMPLETE-->
if (addForm.ComputersUtilized.value != "" || addForm.DesktopQuantity.value != "" || addForm.LaptopQuantity.value != "" || addForm.PrinterQuantity.value != ""){
    addForm.RequestingComputers.checked=true;
	   }
  }

   function Checker(){
	CheckBox();
   	var addForm = document.cff_program;
	var sErrorMsg = "";

   	if (addForm.VolunteerAssistance.checked ){

			if (addForm.StartMonth.value == ""){
				sErrorMsg += "o Section 2 Start month\n";
      		}
      		if (addForm.StartDay.value == ""){
				sErrorMsg += "o Section 2 Start day\n";
      		}
      		if (addForm.StartYear.value == ""){
				sErrorMsg += "o Section 2 Start year\n";
      		}
      		if (addForm.EndMonth.value == ""){
				sErrorMsg += "o Section 2 End month\n";
      		}
      		if (addForm.EndDay.value == ""){
				sErrorMsg += "o Section 2 End day\n";
      		}
      		if (addForm.EndYear.value == ""){
				sErrorMsg += "o Section 2 End year\n";
      		}
      		if (addForm.EventStartTime.value == ""){
				sErrorMsg += "o Section 2 Start time\n";
      		}
      		if (addForm.EventEndTime.value == ""){
				sErrorMsg += "o Section 2 End time\n";
      		}
      		if (addForm.NumberOfVolunteers.value == ""){
				sErrorMsg += "o Section 2 Number of volunteers needed\n";
      		}
      		if (addForm.ProjectLocation.value == ""){
				sErrorMsg += "o Section 2 Project location\n";
      		}
      		if (addForm.ActivityDescription.value == ""){
				sErrorMsg += "o Section 2 Activity description\n";
      		}
      		if (addForm.EnvironmentAndSafetyConcerns.value == ""){
				sErrorMsg += "o Section 2 Environment and safety concerns\n";
      		}
			if (addForm.IndividualsImpacted.value == ""){
				sErrorMsg += "o Section 2 Number of individuals impacted\n";
      		}
      		if (addForm.EquipmentRequest.value == ""){
				sErrorMsg += "o Section 2 Equipment request\n";
      		}
    		if (!addForm.Insurance[0].checked && !addForm.Insurance[1].checked){
				sErrorMsg += "o Section 2 Insurance Check\n";
			}
			if (!addForm.VolunteerAge[0].checked && !addForm.VolunteerAge[1].checked && !addForm.VolunteerAge[2].checked && !addForm.VolunteerAge[3].checked && !addForm.VolunteerAge[4].checked){
				sErrorMsg += "o Section 2 Volunteer Age Check\n";
			}
			if (addForm.Insurance[0].checked){
      			if (addForm.InsuranceComment.value == ""){
					sErrorMsg += "o Section 2 Insurance Comment\n";
				}
			}
}

   	if (addForm.RequestingComputers.checked ){

      		if (addForm.ComputersUtilized.value == ""){
				sErrorMsg += "o Section 3 Computers utilized?\n";
			}
			addForm.DesktopQuantity.value=addForm.DesktopQuantity.value.replace(/\s/g,"");
			if (addForm.DesktopQuantity.value =="" || isNaN(addForm.DesktopQuantity.value)){
				 sErrorMsg += "o Section 3 Desktop Quantity must be numeric\n";
			}
			addForm.PrinterQuantity.value=addForm.PrinterQuantity.value.replace(/\s/g,"");
			if (addForm.PrinterQuantity.value =="" || isNaN(addForm.PrinterQuantity.value)){
				 sErrorMsg += "o Section 3 Printer Quantity must be numeric\n";
			}
			addForm.LaptopQuantity.value=addForm.LaptopQuantity.value.replace(/\s/g,"");
			if (addForm.LaptopQuantity.value =="" || isNaN(addForm.LaptopQuantity.value)){
				 sErrorMsg += "o Section 3 Laptop Quantity must be numeric\n";
			}

			if (addForm.DesktopQuantity.value =="0" && addForm.PrinterQuantity.value =="0" && addForm.LaptopQuantity.value =="0" ){
				sErrorMsg += "o Section 3 Choose computer quantity\n";
			}
    	}
	if (!sErrorMsg == "") {
		alert ("Please fill in all missing fields for the items you requested:\n\n" + sErrorMsg);
		return false;
	}
	else {
		return true;
	}

   }

