function checkAnswers04(theform) {
	incorrect = false;
	wrongOnes = "";
	promptString = "\n Click on OK and try again.";

	if (theform.radio1[2].checked == false) {
		incorrect = true;
		wrongOnes += "1";         
	}
	if (theform.radio2[0].checked == false) {
		incorrect = true;
		wrongOnes += "2";         
	}
	
	if (incorrect) {
		if (wrongOnes.length == 1) {
			res = "Answer " + wrongOnes + " is incorrect. " + promptString;
		}
		else {
			res = "Answers ";
			for (i=0; i < wrongOnes.length; i++) {
				if (i != wrongOnes.length - 1) {
					res += wrongOnes.charAt(i) + ", ";
				} else {
					res = res.substring(0, res.length-2);
					res += " and " + wrongOnes.charAt(i) + " are wrong.  " + promptString;
				}
			}
		}
		alert(res);
		return false;
	} 
	else {
		alert("Good, your answers are Correct");
		return true;
	}                 
}

function checkAnswers04a(theform) {
    incorrect = false;
    wrongOnes = "";
    if (theform.radio1[1].checked == false) {
        wrongOnes += "1";
        incorrect = true;
    }
	
    promptString = "\nClick on OK to try again.";
    if (incorrect) {
        if (wrongOnes.length == 1) {
            res = "Incorrect.  Note that the stream is flowing toward you."
              
        } else {
            res = "Answers ";
            for (i=0; i < wrongOnes.length; i++) {
                if (i != wrongOnes.length - 1) {
                    res += wrongOnes.charAt(i) + ", ";
                } else {
                    res = res.substring(0, res.length-2);
                    res += " and " + wrongOnes.charAt(i)
                        + " are wrong. "
                        + promptString;
                }
            }
        }
                alert(res);
        return false;
    } else {
        alert("That's right. Since the stream is flowing towards you, Side B is the left side.");
        return true;
    }
}
function checkAnswers07a(theform) {
    incorrect = false;
    wrongOnes = "";
    if (theform.radio1[0].checked == false) {
        wrongOnes += "1";
        incorrect = true;
    }
    promptString = "\nClick on OK to try again.";
    if (incorrect) {
        if (wrongOnes.length == 1) {
            res = "Sorry, your answer is wrong."
                + promptString;
        } else {
            res = "Answers ";
            for (i=0; i < wrongOnes.length; i++) {
                if (i != wrongOnes.length - 1) {
                    res += wrongOnes.charAt(i) + ", ";
                } else {
                    res = res.substring(0, res.length-2);
                    res += " and " + wrongOnes.charAt(i)
                        + " are wrong. "
                        + promptString;
                }
            }
        }
                alert(res);
        return false;
    } else {
        alert("Very Good! Stream velocity is greatest near its surface.");
        return true;
    }
}

function checkAnswers07b1(theform) {
	incorrect = false;
	wrongOnes = "";
	promptString = "\n\nClick on OK to try again.";

	names = new Array("0.1 D", "0.4 D", "0.6 D", "0.8D");

	if ((theform.answer13.value > 12.31) || (theform.answer13.value < 11.7)) {
		incorrect = true;
		wrongOnes += "0";         
	}
	if ((theform.answer23.value > 14.31) || (theform.answer23.value < 13.75)) {
		incorrect = true;
		wrongOnes += "1";
	} 
	if ((theform.answer33.value > 17.61) || (theform.answer33.value < 16.89)) {
		incorrect = true;
		wrongOnes += "2";         
	}
	if ((theform.answer43.value > 30.01) || (theform.answer43.value < 29.01)) {
		incorrect = true;
		wrongOnes += "3";
	}

	if (incorrect) {
		if (wrongOnes.length == 1) {
			res = "The average time for " + names[wrongOnes] + " is not accurate, please remeasure. " +
				promptString;
		} else {
			res = "The average times for ";
			for (i=0; i < wrongOnes.length; i++) {
				if (i != wrongOnes.length - 1) {
					res += names[wrongOnes.charAt(i)] + ", ";
				} else {
					res = res.substring(0, res.length-2);
					res += " and " + names[wrongOnes.charAt(i)] + " are not accurate, please remeasure.  " +
						promptString;
				}
			}
		}
		alert(res);
		return false;
	} 
	else {
		alert("Good. The average time values are correct, or close enough.");
		return true;
	}                 
}

function checkAnswers07b2(theform) {
	incorrect = false;
	wrongOnes = "";
	promptString = "\n Click on OK and try again.";

	names = new Array("0.1 D", "0.4 D", "0.6 D", "0.8 D");
	if ((theform.answer1D.value > 0.43) || (theform.answer1D.value < 0.41)) {
		incorrect = true;
		wrongOnes += "0";         
	}
	if ((theform.answer4D.value > 0.361) || (theform.answer4D.value < 0.349)) {
		incorrect = true;
		wrongOnes += "1";
	} 
	if ((theform.answer6D.value > 0.291) || (theform.answer6D.value < 0.289)) {
		incorrect = true;
		wrongOnes += "2";         
	}
	if ((theform.answer8D.value > 0.181) || (theform.answer8D.value < 0.159)) {
		incorrect = true;
		wrongOnes += "3";
	}
	
	if (incorrect) {
		if (wrongOnes.length == 1) {
			res = "Your velocity for " + names[wrongOnes] + " is incorrect. " +
				promptString;
		} else {
			res = "Your velocities for ";
			for (i=0; i < wrongOnes.length; i++) {
				if (i != wrongOnes.length - 1) {
					res += names[wrongOnes.charAt(i)] + ", ";
				} else {
					res = res.substring(0, res.length-2);
					res += " and " + names[wrongOnes.charAt(i)] + " are wrong.  " +
						promptString;
				}
			}
		}
		alert(res);
		return false;
	} 
	else {
		alert("Good! Your average time values are correct.");
		return true;
	}                 
}



function checkAnswers07c(theform) {
	incorrect = false;
	promptString = "\n Click on OK and try again.";

	if ((theform.answeri2.value > 0.30) || (theform.answeri2.value < 0.28)) {
		incorrect = true;
	}
	
	if (incorrect) {
		res = "Your answer is incorrect. " + promptString;
		alert(res);
		return false;
	} else {
		alert("Your answer is correct.");
		return true;
	}                 
}


function checkAnswers07d(theform) {
	incorrect = false;
	wrongOnes = "";
	promptString = "\n Click on OK and try again.";


	if (theform.answer32.value != 0.6){
		incorrect = true;
	}

	if (incorrect) {
		res = "Answer is Incorrect. " + promptString;
		alert(res);
		return false;
	} else {
		alert("Answer is Correct");
		return true;
	}                 
}
function checkAnswers07d1(theform) {
	incorrect = false;
	wrongOnes = "";
	promptString = "\n Click on OK and try again.";


	if (theform.answer1.value != 7.5){
		incorrect = true;
	}
	if (theform.answer2.value !=1.2 ){
		incorrect = true;
	}

	if (incorrect) {
		res = "At least one answer is incorrect. " + promptString;
		alert(res);
		return false;
	} else {
		alert("Answers are Correct.  Don't forget the importance of the six tenths rule!");
		return true;
	}                 
}

function checkAnswers08a(theform) {
	incorrect = false;
	wrongOnes = "";

	if ((theform.answer1.value > .16) || (theform.answer1.value < 0.14)) {
		incorrect = true;
		wrongOnes += "1";         
	}
	if (theform.radio1[2].checked == false) {
		wrongOnes += "2";
		incorrect = true;
	}


	promptString = "\nClick on OK to try again.";

	if (incorrect) {
		if (wrongOnes.length == 1) {
			res = "Answer " + wrongOnes + " is incorrect. "
				+ promptString;
		} else {
			res = "Answers ";
			for (i=0; i < wrongOnes.length; i++) {
				if (i != wrongOnes.length - 1) {
					res += wrongOnes.charAt(i) + ", ";
				} else {
					res = res.substring(0, res.length-2);
					res += " and " + wrongOnes.charAt(i)
						+ " are wrong. "
						+ promptString;
				}
			}
		}
		alert(res);
		return false;
	} else {
		alert("Good! Your answers are Correct");
		return true;
	}

}



function checkAnswers08b(theform) {
	incorrect = false;
	wrongOnes = "";
	promptString = "\n Click on OK and try again.";

	if (theform.answer1.value != 0.75) {
		incorrect = true;
		wrongOnes += "1";         
	}
	if ((theform.answer2.value > .45) || (theform.answer2.value < 0.44)) {
		incorrect = true;
		wrongOnes += "2";         
	}	
	if (theform.answer3.value != 0.13) {
		incorrect = true;
		wrongOnes += "3";         
	}
	if (theform.answer4.value != 1.80) {
		incorrect = true;
		wrongOnes += "4";
	}
	if (theform.answer5.value != 10.6) {
		incorrect = true;
		wrongOnes += "5";
	}
	if (theform.answer6.value != 8.8) {
		incorrect = true;
		wrongOnes += "6";
	}

if ((theform.answer7.value > .86) || (theform.answer7.value < 0.85)) {
		incorrect = true;
		wrongOnes += "7";         
	}




	if (incorrect) {
		if (wrongOnes.length == 1) {
			res = "Answer " + wrongOnes + " is incorrect. " + promptString;
		}
		else {
			res = "Answers ";
			for (i=0; i < wrongOnes.length; i++) {
				if (i != wrongOnes.length - 1) {
					res += wrongOnes.charAt(i) + ", ";
				} else {
					res = res.substring(0, res.length-2);
					res += " and " + wrongOnes.charAt(i) + " are wrong.  " + promptString;
				}
			}
		}
		alert(res);
		return false;
	} 
	else {
		alert("Answers are Correct");
		return true;
	}                 
}

function checkAnswers09b(theform) {
	incorrect = false;
	wrongOnes = "";
	promptString = "\n Click on OK and try again.";

	if (theform.radio1[3].checked == false) {
		incorrect = true;
		wrongOnes += "1";         
	}
	if (theform.radio2[5].checked == false) {
		incorrect = true;
		wrongOnes += "2";         
	}
	if (theform.radio3[1].checked == false) {
		incorrect = true;
		wrongOnes += "3";         
	}
	if (theform.radio4[6].checked == false) {
		incorrect = true;
		wrongOnes += "4";         
	}
	if (theform.radio5[0].checked == false) {
		incorrect = true;
		wrongOnes += "5";         
	}
	if (theform.radio6[2].checked == false) {
		incorrect = true;
		wrongOnes += "6";         
	}
	if (theform.radio7[4].checked == false) {
		incorrect = true;
		wrongOnes += "7";         
	}
	if (incorrect) {
		if (wrongOnes.length == 1) {
			res = "Answer " + wrongOnes + " is incorrect. " + promptString;
		}
		else {
			res = "Answers ";
			for (i=0; i < wrongOnes.length; i++) {
				if (i != wrongOnes.length - 1) {
					res += wrongOnes.charAt(i) + ", ";
				} else {
					res = res.substring(0, res.length-2);
					res += " and " + wrongOnes.charAt(i) + " are wrong.  " + promptString;
				}
			}
		}
		alert(res);
		return false;
	} 
	else {
		alert("Answers are Correct");
		return true;
	}                 
}

function checkAnswers10b(theform) {
	incorrect = false;
	promptString = "\n Click on OK and try again.";

	if (theform.answer1.value != 1.5) {
		incorrect = true;
	}

	if (incorrect) {
		res = "Answer is incorrect. What is 1/20 of 30 meters?";
		alert(res);
		return false;
	} else {
		alert("That's correct. Now we shall compute the discharge for a more complicated looking stream. \n\nIMPORTANT:  The next page contains a LARGE Applet file.  \nIt may take a minute or two to download.  \n\nPLEASE BE PATIENT!");
		return true;
	}                 
}


function checkEntriesPreCert(theform) {
	wrongOnes = "";
	incorrect = false;
	promptString = "\n\nClick on OK to continue.";
	names = new Array("Name", "Institution", "Location");
	s = theform.name.value;
	if (noCharacter(s)) {
		incorrect = true;
		wrongOnes += "0";
	}
	s = theform.inst.value;
	if (noCharacter(s)) {
		incorrect = true;
		wrongOnes += "1";
	}
	s = theform.locat.value;
	if (noCharacter(s)) {
		incorrect = true;
		wrongOnes += "2";
	}
	if (incorrect) {
		if (wrongOnes.length == 1) {
			res = "You didn't enter anything in the " + names[wrongOnes] +
				" field. Please do so." + promptString;
		} else {
			res = "You didn't enter anything in the ";
			for (i=0; i < wrongOnes.length; i++) {
				if (i != wrongOnes.length - 1) {
					res += names[wrongOnes.charAt(i)] + ", ";
				} else {
					res = res.substring(0, res.length-2);
					res += " and " + names[wrongOnes.charAt(i)] +
						" fields. Please do so." + promptString;
				}
			}
		}
		alert(res);
		return false;
	} else {
		return true;
	}
}

function noCharacter(s) {
	for (i=0; i < s.length; i++) {
		if ((s.charAt(i) >= "A" && s.charAt(i) <= "Z") ||
				(s.charAt(i) >= "a" && s.charAt(i) <= "z")) {
			return false;
		}
	}
	return true;
}
