<!-- hide this script

// validate a user entered number.
function checkNumber(input,form1,form2)
{
	// blank field reset to default value.
	if (input.value=='') {
		input.value=input.defaultValue
	}

	// remove any user added commas
	input.value = strip_commas(input.value);

	// place a warning on the status line if the field contains invalid data
	status='';
	msg ="This field requires numeric 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 != '.') {
			input.focus()
			input.value="0";
			input.select()
			status=msg;
		}               
	}
	add_input(input,form1,form2)
}

function add_input(input,form1,form2) {
	var total1;
	total1=(form1.price.value*1)            
	form2.loan.value=(total1*1 -form2.down_payment.value)
}

// Make a number a nice comma delimited number.
function put_commas(input) {
	var result, len;
	input += "";

	// Locate the decimal point if any.
	len = input.indexOf(".");
	if (len == -1) {
		len = input.length;
		result = "";
	} else {
		result = input.substring(len, input.length);
	}

	// 3 characters at a time through the integer portion.
	while (len > 3) {
		result = input.substring(len-3, len) + result;
		result = "," + result;
		len -= 3;
	}

	// Add any remaining characters.
	result = input.substring(0, len) + result;
	return result;
}

// Remove all commas from a passed string.
function strip_commas(input) {
        var newnum;
        var ch;
        newnum ="";
        for(var i=0; i<input.length; i++) {
                ch = input.charAt(i);
                if(ch != ",") {
                        newnum += ch;
                }
        }
        return parseFloat(newnum);
}

function checkNumPeriods(input) {
        input.value = strip_commas(input.value);
        input.value = parseFloat(input.value);
//        input.value = parseInt(input.value);
        if(input.value == null ||          
         input.value.length == 0 ||
           input.value == "NaN") {
                input.value = "";
        }
        else {
                if(parseFloat(input.value) <= 0) {
                        input.value = "";
                }
        }
        calcMonthly(input.form);
        input.value = put_commas(input.value);
}

function checkTotal(input) {
        input.value = strip_commas(input.value);
        input.value = parseFloat(input.value);
        if(input.value == null ||          
         input.value.length == 0 ||
           input.value == "NaN") {
                input.value = "";
        }
        else {
                if(parseFloat(input.value) < 0) {
                        input.value = "";
                }
        }
        calcMonthly(input.form);
        input.value = put_commas(input.value);
}

// Verify the interest rate is a reasonable number, or set it to one.
function checkInterest(input) {
	input.value = parseFloat(input.value);
	if (input.value == null ||
	    input.value.length == 0 ||
	    input.value == "NaN" ||
	    input.value < 0 ||
	    input.value > 100) {
		input.value = 9;
	}
	calcMonthly(input.form);
}

function calcMonthly(input) {
        if(input.interest.value == "" || 
           input.nper.value == "" ||
           input.loan.value == "") {
                input.monthly.value = "";
        }
        else {
		i = strip_commas(input.interest.value) / 100;
                if( i > 0){
        	        i = i / 12;
                	n = strip_commas(input.nper.value) * 12;
	                tmp = (1/i) * (1 - Math.pow(1/(1+i), n));
	                tmp = strip_commas(input.loan.value) / tmp;
	                tmp = Math.round(tmp*100) / 100;
	                input.monthly.value = put_commas(tmp);
	                if(input.monthly.value == null ||          
	                 input.monthly.value.length == 0 ||
	                   input.monthly.value == "NaN") {
        	                input.total.value = "";
                	}
		} else {
			nummonths  = strip_commas(input.nper.value) * 12;
			loanamount = strip_commas(input.loan.value);
			
			monthlypayment = Math.round((loanamount / nummonths)*100) / 100;
			input.monthly.value = put_commas(monthlypayment);
		}

        }
}
function selectField(field)
{
        field.select()
}

// Reset the forms to default values.
function clearForm(form1,form2)
{
        form1.price.value = "0"
        form2.down_payment.value = "0"
        form2.loan.value = "0"
        form2.interest.value = "5.9"
        form2.nper.value = "4"
        form2.monthly.value = "0"
 }
// done hiding from old browsers -->