function incidentform(theForm) {
	var why = "";

		//why += isEmpty(theForm.reporting_person.value, "Reporting Person");
		//if (why != "") {
		//	alert(why);
		//	theForm.reporting_person.focus();
		//	return false;
		//}
		why += isEmpty(theForm.date_reported.value, "Date Reported");
		if (why != "") {
			alert(why);
			theForm.date_reported.focus();
			return false;
		}
		why += checkDropdown(theForm.report_type.value, "Type of report");
		if (why != "") {
			alert(why);
			theForm.report_type.focus();
			return false;
		}
		why += checkDropdown(theForm.concerns.value, "This Report Concerns");
		if (why != "") {
			alert(why);
			theForm.concerns.focus();
			return false;
		}
		why += checkDropdown(theForm.op_safety_issue.value, "Operational or Safety Issues");
		if (why != "") {
			alert(why);
			theForm.op_safety_issue.focus();
			return false;
		}
		//why += checkRadio(theForm.resulted_injury.value, "Resulted in Injury");
		//if (why != "") {
		//	alert(why);
		//	theForm.resulted_injury.focus();
		//	return false;
		//}
		//why += checkRadio(theForm.property_damage.value, "Property Damage");
		//if (why != "") {
		//	alert(why);
		//	theForm.property_damage.focus();
		//	return false;
		//}
		//why += checkRadio(theForm.false_indication.value, "False indication Involved");
		//if (why != "") {
		//	alert(why);
		//	theForm.false_indication.focus();
		//	return false;
		//}
		//why += checkRadio(theForm.maintenance_factor.value, "If Yes, Was Aircraft Maintenance a Factor");
		//if (why != "") {
		//	alert(why);
		//	theForm.maintenance_factor.focus();
		//	return false;
		//}
		//why += checkRadio(theForm.component_failure.value, "If Yes, Did a Component Fail");
		//if (why != "") {
		//	alert(why);
		//	theForm.component_failure.focus();
		//	return false;
		//}
		//why += checkRadio(theForm.equip_design.value, "If Yes, Was Equipment Design a Factor");
		//if (why != "") {
		//	alert(why);
		//	theForm.equip_design.focus();
		//	return false;
		//}
		why += isEmpty(theForm.rate.value, "How do you rate the risk of this incident");
		if (why != "") {
			alert(why);
			theForm.rate.focus();
			return false;
		}
		why += isEmpty(theForm.incident_details.value, "Incident Details as per Person Submitting the Report");
		if (why != "") {
			alert(why);
			theForm.incident_details.focus();
			return false;
		}
		//why += isEmpty(theForm.imm_temp_controls.value, "Immediate/Temporary Controls");
		//if (why != "") {
		//	alert(why);
		//	theForm.imm_temp_controls.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.witness.value, "Witness");
		//if (why != "") {
		//	alert(why);
		//	theForm.witness.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.sequence.value, "Sequence of Events");
		//if (why != "") {
		//	alert(why);
		//	theForm.sequence.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.witness_statements.value, "Witness Statements");
		//if (why != "") {
		//	alert(why);
		//	theForm.witness_statements.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.imm_contri_factors.value, "Immediate Contributing Factors");
		//if (why != "") {
		//	alert(why);
		//	theForm.imm_contri_factors.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.under_contri_factors.value, "Underlying Contributing Factors");
		//if (why != "") {
		//	alert(why);
		//	theForm.under_contri_factors.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.recommendations.value, "Recommendations");
		//if (why != "") {
		//	alert(why);
		//	theForm.recommendations.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.human_factors.value, "Human performance issues or deficiencies associated with this incident");
		//if (why != "") {
		//	alert(why);
		//	theForm.human_factors.focus();
		//	return false;
	    //	}
		//why += checkDropdown(theForm.division.value, "Division");
		//if (why != "") {
		//	alert(why);
		//	theForm.division.focus();
		//	return false;
		//}
		//why += checkDropdown(theForm.department_risk.value, "Department");
		//if (why != "") {
		//	alert(why);
		//	theForm.department_risk.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.ops_base.value, "Ops Base");
		//if (why != "") {
		//	alert(why);
		//	theForm.ops_base.focus();
		//	return false;
		//}
		//why += checkDropdown(theForm.affiliation.value, "Affiliation");
		//if (why != "") {
		//	alert(why);
		//	theForm.affiliation.focus();
		//	return false;
		//}
		//why += checkRadio(theForm.external_reportable.value, "External Reportable");
		//if (why != "") {
		//	alert(why);
		//	theForm.external_reportable.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.rate_how.value, "How do you rate the risk of this incident");
		//if (why != "") {
		//	alert(why);
		//	theForm.rate_how.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.risk_level02.value, "Risk Level");
		//if (why != "") {
		//	alert(why);
		//	theForm.risk_level02.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.associated_hazards.value, "Associated Hazard");
		//if (why != "") {
		//	alert(why);
		//	theForm.associated_hazards.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.rating_descp.value, "Rating &amp; Description");
		//if (why != "") {
		//	alert(why);
		//	theForm.rating_descp.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.open_actions.value, "Open Actions");
		//if (why != "") {
		//	alert(why);
		//	theForm.open_actions.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.due_date_descp.value, "Due Date & Description");
		//if (why != "") {
		//	alert(why);
		//	theForm.due_date_descp.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.closed_actions.value, "Closed Actions");
		//if (why != "") {
		//	alert(why);
		//	theForm.closed_actions.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.close_date_descp.value, "Close Date & Description");
		//if (why != "") {
		//	alert(why);
		//	theForm.close_date_descp.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.base_saf_rep.value, "Investigator");
		//if (why != "") {
		//	alert(why);
		//	theForm.base_saf_rep.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.base_saf_rep_sign.value, "Name");
		//if (why != "") {
		//	alert(why);
		//	theForm.base_saf_rep_sign.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.base_saf_rep_date.value, "Date");
		//if (why != "") {
		//	alert(why);
		//	theForm.base_saf_rep_date.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.internal_authorisor.value, "Internal Authorisor");
		//if (why != "") {
		//	alert(why);
		//	theForm.internal_authorisor.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.internal_authorisor_sign.value, "Name");
		//if (why != "") {
		//	alert(why);
		//	theForm.internal_authorisor_sign.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.internal_authorisor_date.value, "Date");
		//if (why != "") {
		//	alert(why);
		//	theForm.internal_authorisor_date.focus();
		//	return false;
		//}
		//why += isEmpty(theForm.internal_authorisor_position.value, "Position");
		//if (why != "") {
		//	alert(why);
		//	theForm.internal_authorisor_position.focus();
		//	return false;
		//}

//		if (document.theForm.agreeTerms.checked) {
//				var checkvalueB = theForm.agreeTerms.value;
//		} 
//    why += checkCheckBoxB(checkvalueB);
//		 if (why != "") {
//       alert(why);
//			 document.theForm.agreeTerms.focus();
//       return false;
//    }

	return true;
}


function checkCheckBoxB(checkvalueB) {
var error = "";
   if (!(checkvalueB)) {
       error = "DO YOU AGREEE WITH OUR TERMS AND CONDITIONS\n";
    }
return error;
}

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}


// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a phone number.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.";
  
    }
    if (!(stripped.length == 10)) {
	error = "The phone number is the wrong length. Make sure you included an area code.\n";
    } 
return error;
}


// password - between 6-8 chars, uppercase, lowercase, and numeral

function checkPassword (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a password.\n";
}

    var illegalChars = /[\W_]/; // allow only letters and numbers
    
    if ((strng.length < 6) || (strng.length > 8)) {
       error = "The password is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
      error = "The password contains illegal characters.\n";
    } 
    else if (!((strng.search(/(a-z)+/)) && (strng.search(/(A-Z)+/)) && (strng.search(/(0-9)+/)))) {
       error = "The password must contain at least one uppercase letter, one lowercase letter, and one numeral.\n";
    }  
return error;    
}    


// username - 4-10 chars, uc, lc, and underscore only.

function checkUsername (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a username.\n";
}


    var illegalChars = /\W/; // allow letters, numbers, and underscores
    if ((strng.length < 4) || (strng.length > 10)) {
       error = "The username is the wrong length.\n";
    }
    else if (illegalChars.test(strng)) {
    error = "The username contains illegal characters.\n";
    } 
return error;
}       


// non-empty textbox

function isEmpty(strng, fldName) {
var error = "";
  if (strng.length == 0) {
     error = "The " + fldName + " field has not been filled in.\n"
  }
return error;	  
}

// was textbox altered

function isDifferent(strng) {
var error = ""; 
  if (strng != "Can\'t touch this!") {
     error = "You altered the inviolate text area.\n";
  }
return error;
}

// exactly one radio button is chosen

function checkRadio(checkvalue) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a radio button.\n";
    }
return error;
}

// valid selector from dropdown list

function checkDropdown(choice, fldName) {
var error = "";
    if (choice == 0) {
    error = "You didn't choose an option from the " + fldName + " drop-down list.\n";
    }    
return error;
}    


