<!-- Begin
function calculate()
{
	var p	= makenum( document.loandata.price.value );
	document.loandata.price.value = p;
	var r	= document.loandata.rate.value /100 /12;
	var t	= ( makenum( document.loandata.term.value ) * 12);
	
	// calculate monthly payment
	var x = Math.pow( 1+r, t );
	var mo_pymt = round( (p*x*r)/(x-1) );

	// check if answer is finite, display if true
	if( !isNaN( mo_pymt ) && ( mo_pymt != Number.POSITIVE_INFINITY ) &&
									 ( mo_pymt != Number.NEGATIVE_INFINITY ))
	{
		document.loandata.payment.value = mo_pymt;
	}
	else { // otherwise is invalid
		mo_pymt = "";
	}

} // End function calculate

// parse input to remove non-numeric chars in dollar entries
function makenum( innum ){
	var tempnum = "";

	for( i=0; i <= innum.length-1; i++) {
		if( innum.charAt(i) == "." )
				break;
		else if( !isNaN( innum.charAt(i) ))
			tempnum += ( innum.charAt(i) );
	}
	return tempnum;
} // end function makenum

// round numbers to two decimal places
function round( x ) {
	return Math.round(x*100)/100;
}
//  End -->
