// JavaScript Document
<!-- Freshwater Fish

function calcPike() {
	var lengthEntry = parseInt(document.calculator.pikelength.value)
	if (isNaN(lengthEntry)) {
		alert("Try entering the length again.");
    }
    document.calculator.pikeweight.value = eval((document.calculator.pikelength.value) * (document.calculator.pikelength.value) * (document.calculator.pikelength.value) / 3500);
}

function calcWalleye() {
	var lengthEntry = parseInt(document.calculator.walleyelength.value)
	if (isNaN(lengthEntry)) {
		alert("Try entering the length again.");
		}
	document.calculator.walleyeweight.value = eval((document.calculator.walleyelength.value) * (document.calculator.walleyelength.value) * (document.calculator.walleyelength.value) / 2700);
	}
	
function calcSunfish() {
	var lengthEntry = parseInt(document.calculator.sunfishlength.value)
	if (isNaN(lengthEntry)) {
		alert("Try entering the length again.");
		}
	document.calculator.sunfishweight.value = eval((document.calculator.sunfishlength.value) * (document.calculator.sunfishlength.value) * (document.calculator.sunfishlength.value) / 1200);
	}

function calcBass() {
	var lengthEntry = parseInt(document.calculator.basslength.value)
	var girthEntry = parseInt(document.calculator.bassgirth.value)
	if (isNaN(lengthEntry)) {
		alert("Try entering the length again.");
		}
	if (isNaN(girthEntry)) {
		alert("Try entering the girth again.");
		}
	document.calculator.bassweight.value = eval((document.calculator.basslength.value) * (document.calculator.basslength.value) * (document.calculator.bassgirth.value) / 1200);	
	}
	
function calcTrout() {
	var lengthEntry = parseInt(document.calculator.troutlength.value)
	var girthEntry = parseInt(document.calculator.troutgirth.value)
	if (isNaN(lengthEntry)) {
		alert("Try entering the length again.");
		}
	if (isNaN(girthEntry)) {
		alert("Try entering the girth again.");
		}
	document.calculator.troutweight.value = eval((document.calculator.troutlength.value) * (document.calculator.troutgirth.value) * (document.calculator.troutgirth.value) / 800);		
	}
//-->
<!-- Freshwater Fish

function checkNumber(input, min, max, msg) {
msg = msg + " field has invalid data: " + input.value;
var str = input.value;
for (var i = 0; i < str.length; i++) {
var ch = str.substring(i, i + 1)
if ((ch < "0" || "9" < ch) && ch != '.') {
alert(msg);
return false;
}
}
var num = 0 + str
if (num < min || max < num) {
alert(msg + " not in range [" + min + ".." + max + "]");
return false;
}
input.value = str;
return true;
}
function computeField(input) {
if (input.value != null && input.value.length != 0)
input.value = "" + eval(input.value);
computeForm(input.form);
}
function computeForm(form) {
if ((form.length.value == null || form.length.value.length == 0) ||
(form.girth.value == null || form.girth.value.length == 0)) {
return;
}
if (!checkNumber(form.length, 1, 10000, "Length") ||
!checkNumber(form.girth, 1, 2000, "Girth")) {
form.weight.value = "Invalid";
return;
}
var i = form.girth.value;
var k = form.length.value;
form.weight.value = (i * i * k) / (800)
}
function clearForm(form) {
form.length.value = "";
form.girth.value = "";
form.weight.value = "";
}

//--->
