function roundoff(amount) {
return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount);
}

function total(what,number) {
var grandTotal = 0;
for (var i=0;i<number;i++) {
if (what.elements['ratio' + i].value == '')
what.elements['ratio' + i].value = '0.00'; // fix for Opera.

what.elements['subtotal' + i].value=(what.elements['A' + i].value - 0) * (what.elements['ratio' + i].value - 0);
if (what.elements['A' + i].value == "0")
what.elements['subtotal' + i].value = "0.00";

subtotal=what.elements['subtotal' + i].value
grandTotal += (what.elements['ratio' + i].value - 0) * (what.elements['A' + i].value - 0);
}

subtotal=roundoff(Math.round(subtotal*Math.pow(10,2))/Math.pow(10,2));
what.grandTotal.value = roundoff(Math.round(grandTotal*Math.pow(10,2))/Math.pow(10,2));

	if (grandTotal >= 12) {
		alert ("Your answers to the Self Assessment suggest that you would benefit from a thorough hearing screening.  Press OK to enter your contact information and have us contact you to schedule a complimentary hearing evaluation.")
		location = "/Contact_Us/";
		}
	else if (grandTotal < 12 && grandTotal > 0) {
		//alert ("smaller than 5, but greater than 0")
	
		input_box=confirm("Your answers to the Self Assessment suggest that you may benefit from a thorough hearing screening.  If you would like to receive more information about our Office and AudigyCertified Professionals, please press OK.");
			if (input_box==true) { 
				location = "/Contact_Us/";
				}
			else {
				//alert ("You clicked cancel");
				}
		}
	else if (grandTotal == 0) {
		alert ("Congratulations! Your hearing health appears to be excellent.")
		}
	else {
		alert ("It appears that not all questions have been answered yet. Please check and complete the missing questions.")
	}
}