<!--
function MortgageCalculate() {
	form = document.forms [0];
	LoanAmount = form.LoanAmount.value*1;
	if (LoanAmount < 5000 ) {
		window.alert('Minimum loan amount for this calculator is 5000.');
		form.LoanAmount.value = 5000;
		LoanAmount = 5000;
	}
	DownPayment = form.DownPayment.value*1;
	if (DownPayment == "")  {
		DownPayment = 0;
	}
	if (DownPayment < 0)  {
		window.alert('Down payments must be greater than or equal to 0.');
		form.DownPayment.value = 0;
		DownPayment = 0;
	}
	if (DownPayment >= LoanAmount)  {
		window.alert('Down payments must be less than the loan amount. This will be reset to 25% of the loan.');
		form.DownPayment.value = LoanAmount/4;
		DownPayment = LoanAmount/4;
	}
	AnnualInterestRate = form.InterestRate.value*1;
	if (AnnualInterestRate <= 3 || AnnualInterestRate >= 15)  {
		window.alert('The annual interest rate for this calculator must be in the range of 3-15%.');
		form.InterestRate.value = 5;
		AnnualInterestRate = 5;
	}
	AnnualInterestRate = AnnualInterestRate/100;
	Years = form.NumberOfYears.value;
	if (Years <= 5 || Years >= 35)  {
		window.alert('The loan period for this calculator must be in the range of 5-35 years.');
		form.NumberOfYears.value = 25;
		Years= 25;
	}
	MonthRate = AnnualInterestRate/12;
	NumPayments = Years*12;
	Prin = LoanAmount-DownPayment;
	MonthInterest = Math.floor((Prin*MonthRate)*100)/100;
	MonthPayment = Math.floor((Prin*MonthRate)/(1-Math.pow((1+MonthRate),(-1*NumPayments)))*100)/100;
	form.MonthlyInterest.value = MonthInterest;
	form.MonthlyPayment.value = MonthPayment;
}
//-->
