// JavaScript Document

<!--

function calc(){
// Gathers field information
var f1 = validNum(document.productForm.elements['field1'].value);
var f2 = validNum(document.productForm.elements['field2'].value);
var f3 = validNum(document.productForm.elements['field3'].value);
var f4 = validNum(document.productForm.elements['field4'].value);
var f5 = validNum(document.productForm.elements['field5'].value);

// Calculates Information
var subtotal = f1 + f2 + f3 + f4 + f5;
var tps_tax = (0.05 * subtotal);
var subtotaltps = tps_tax + subtotal;
var tvq_tax = (0.075 * subtotaltps);
var total = tvq_tax + subtotaltps;

// Post totals
document.productForm.elements['subtotal'].value = subtotal.toFixed(2);
document.productForm.elements['tps_tax'].value = tps_tax.toFixed(2);
document.productForm.elements['subtotaltps'].value = subtotaltps.toFixed(2);
document.productForm.elements['tvq_tax'].value = tvq_tax.toFixed(2);
document.productForm.elements['total'].value = total.toFixed(2);
}

// Makes sure variable is a number
function validNum(nmbr){
// forces variable into integer type
nmbr = (nmbr * 1);

// Checks if variable is Not a Number
if(!isNaN(nmbr))
// If a number, return value
return nmbr;
else
// If not a number, return zero
return 0;
}
-->
