// <script>

function formchecker(theForm) {
	var allvalid = true;
	var alertstr = "";
	var validstr = "All form data is correct.\n\n";
	var num_of_elements = theForm.length;
	var radio_selected = 0;
	var checkbox_selected = false;
	
	for (var i=0; i<num_of_elements; i++) {
		var theElement = theForm.elements[i];
		var element_type = theElement.type;
		var element_name = theElement.name;
		var element_value = theElement.value;

// Check all text boxes and text area boxes and drop down lists
		if (element_value.length == 0) {
				alertstr += "" + element_name + " is missing.\n\n";
				allvalid = false;
			}
			
// Check Radio buttons ...
		if (element_type == "radio" ) {
			if (theElement.checked == true) {
				radio_selected += 1;
			}
			if (theElement.checked == false) {
				radio_selected += 0;
			}
		}

// Check Buttons ...
		if (element_type == "button") {
			// Don't check buttons - use the onClick event to invoke functions.
		}

 	// .... End of loop through form elements ....
	}

 // Chevk for any unchecked radio buttons ....
 
	if (radio_selected < 4) {
		alertstr += "One or more radio buttons have not been selected.\n\n";
		allvalid = false;
	}

	
 // Check accuracy of email address ....
 
	txt=document.usam.email.value;
	
	if (txt.indexOf("@")<3){
		alertstr += "Your email address seems wrong. Please check the prefix and '@' sign.\n\n";
		allvalid = false;
   }
   
   txt=document.usam.email.value;
   
	if ((txt.indexOf(".com")<5)&&(txt.indexOf(".org")<5)&&(txt.indexOf(".gov")<5)&&(txt.indexOf(".net")<5)&&(txt.indexOf(".mil")<5)&&(txt.indexOf(".edu")<5)){
		alertstr += "Your email seems wrong. Please check the suffix for accuracy. (It should include a .com, .edu, .net, .org, .gov or .mil)\n\n";
		allvalid = false;
   }
   

// All elements checked - now determine if form is OK ...
	if (allvalid) {
		return true;
	} else {
		alert (alertstr);
		return false;
	}
}	









