function domath(f) {
// The {+} operator has two possible meanings
// in JavaScript. For numbers, it's add, but
// for Strings, it's concatenate. JavaScript
// default datatype for the input values
// (explicit in the declaration {type="text"})
// is String. In order that the {+} operation
// be evaluated as numeric addition, instead
// of String concatenation, try to force an
// explicit type conversion of the value, e.g.,
// call either parseInt() or parseFloat() on
// each value. Note that the parser doesn't
// have to resolve any ambiguity for the
// operations {-}, {*}, and {/}, since these
// operators don't have alternative, String
// related evaluations.
var a = parseInt( f.chemical.value );
var b = parseInt( f.transport.value );
var c = parseInt( f.training.value );
var d = parseInt( f.accidents.value );

// check to verify that the values COULD be
// converted - if any is Not a Number, give
// error message and exit
if (isNaN(a) || isNaN(b) || isNaN(c) || isNaN(d)) {
alert( 'entries must be a numbers - try again' );
return;
}
// since we didn't exit for a NaN condition,
// report the sum
f.cost_chemicals.value = ( a + b + c + d );
f.cost_lotus.value = ( a * '0.372');
f.savings.value = ((a + b + c + d)) - (a * '0.372');
}

