
<!-- hide code from old browsers...

// COPYRIGHT NOTICE                                                         
// Copyright 2000 Joshua W. Coffield  All Rights Reserved.

// Script may be used and modified free of charge by anyone so long as this 
// copyright notice and the comments above remain intact.  By using this code you agree 
// to indemnify Joshua W. Coffield from any liability that might arise from it's use.   

function prequal() {
	var Income = (document.mortgage.salary.value);
	var Expense = (document.mortgage.obligations.value);
	var HomeFees = (document.mortgage.home_fees.value);
   	var Rate = (document.mortgage.rate.value);
	if (Rate>1) {
		Rate = Rate / 100
		}
	var Term = (document.mortgage.term.value);
	var HomeExpense = .38*(Income);
	var MonthlyPayment = HomeExpense - Expense - HomeFees;
	var Principalx = Math.pow((1+Rate/12),(Term*12));
	var Principaly = 1-(1/Principalx);
	var Principalz = Principaly/(Rate/12);
	var Principal = Principalz*MonthlyPayment;

	document.mortgage.pv.value = calcRound(Principal);
}

function round(x) {
	return Math.round(x*100)/100;
}

function calcRound(num) {
   result="$"+Math.floor(num)+"." 
   n = result.length
   if (num>1000 && num<999999) {  
     result="$"+result.substring(1,n-4)+","+result.substring(n-4,n)
   }
   if (num>1000000) {  
     result = "$"+result.substring(1,n-7)+","+result.substring(n-7,n-4)+","+result.substring(n-4,n)
   }
   var cents=100*(num-Math.floor(num))+0.5
   cents = Math.round(cents)

	if (cents<10) {
		cents = "0" + cents
	}      
	if (cents>99) {
		cents = "99"
	}      

   result = result + cents
   return(result)
}

function help() {
	text = ("<HEAD><TITLE>About This Calculator</TITLE></HEAD>");
	text = (text + "<BODY BGCOLOR = '#FFFFFF'><BR><BR>");
	text = (text + "<CENTER><FONT SIZE=+2><B>About the<BR>Mortgage Loan Prequalifier Calculator</B></FONT></CENTER>");
	text = (text + "<BR><BR><FONT SIZE=-1><UL><LI>This Calculator calculates how much of a Mortgage ");
	text = (text + "loan you can afford given income, expenses, expected rate, and expected housing fees.</LI>");
	text = (text + "<LI>This Calculator is for estimate purposes only.  This is not intended ");
	text = (text + "to be a substitute for talking with your Credit Union Representative and should ");
	text = (text + "not be considered an offer.</LI><LI>This calculator uses");
	text = (text + " Javascript.  If your browser doesn't support Javascript you will need to upgrade.");
	text = (text + "</LI>");
	text = (text + "</UL></FONT></BODY>");
	msgWindow = window.open("","displayWindow","toolbar=no,width=500,height=300,directories=no,status=no,scrollbars=yes,resize=no,menubar=yes")
		msgWindow.document.write(text)
		msgWindow.document.close()
}	
	
	
	
//-->