function FormButton1__onClick() {
// Check all fields have valid data //////////////////////////////////////

	if (SalePrice.getText() == "") 
		{
		window.alert("Please enter a Sales Price.");
		return;
		}

	if (LoanAmt.getText() == "")
		{
		window.alert("Please enter a Loan Amount.");
		return;
		}

	if (TermCombo.getSelectedText() == "--")
		{
		window.alert("Please choose a Loan Term.");
		return;
		}

	if (InterestRate.getText() == "")
		{
		window.alert("Please enter an Interest Rate.");
		return;
		}

	if (State.getSelectedText() == "--")
		{
		window.alert("Please choose a Property State.");
		return;
		}

	// Second Column /////////////////////////////////////////////////////////

	if (IncomeTax.getSelectedText() == "--")
		{
		window.alert("Please choose an Income Tax Bracket.");
		return;
		}
	
	if (FilingList.getSelectedText() == "--")
		{
		window.alert("Please choose a Tax Filing Status.");
		return;
		}
	
	if (MonthlyOwnCosts.getText() == "")
		{
		window.alert("Please enter an amount into Other Monthly Ownership Costs (or enter 0 for none).");
		return;
		}

	if (Years.getText() == "")
		{
		window.alert("Please enter the amount of years you wish to calculate over.");
		return;
		}

	if (CurRent.getText() == "")
		{
		window.alert("Please enter your current monthly rent.");
		return;
		}

	// End Field validation ////////////////////////////////////////////////////////

	var LoanAmount = PureNumber(LoanAmt.getText());
	var SalesPrice = PureNumber(SalePrice.getText());
	var Term = TermCombo.getSelectedText();
	var Rate = PureNumber(InterestRate.getText());
	var Payment = Pmt(Rate, Term, LoanAmount);
	var MoCosts = PureNumber(MonthlyOwnCosts.getText());
	var OtherThing = ((PureNumber(SalePrice.getText()) * 0.0225)/12);
	var CurMoRent = PureNumber(CurRent.getText());
	var RentalTerm = Years.getText();
	var FutureValue = fv(Rate, 12, (RentalTerm * 12), (Payment * -1), LoanAmount);
	var TotalPmtForTerm = ((RentalTerm * 12) * Payment) * -1;
	var TotalPrinciplePaid = (parseInt(LoanAmount * 10000) + parseInt(FutureValue * 10000)) / 10000;
	var TotalInterestPaid = (TotalPmtForTerm + TotalPrinciplePaid);
	var AvgIntYearly = (TotalInterestPaid / RentalTerm) * -1;
	var AvgIntMonthly = (AvgIntYearly / 12);
	var IncomeTaxBracket = (PureNumber(IncomeTax.getSelectedText())/100);
	var FilingStatus = FilingList.getSelectedValue()
	
	{
	Payment = parseInt(Payment * 10000);
	MoCosts = parseInt(MoCosts * 10000);
	OtherThing = parseInt(OtherThing * 10000);
	AvgIntMonthly = parseInt(AvgIntMonthly * 10000);
	SalesPrice = parseInt(SalesPrice * 10000);
	}

	var Total1 = ((Payment + MoCosts + OtherThing)/10000);
	var Total2 = (Total1 - parseInt(CurMoRent)) * -1;
	var IntDividedByTerm = ((TotalInterestPaid * -1) / RentalTerm);
	var SalesPriceTimesPropTax = ((SalesPrice * 0.019) / 10000);
	var Total3 = Total1 - (((IntDividedByTerm + SalesPriceTimesPropTax - FilingStatus) * IncomeTaxBracket) / 12);
	var Total4 = ((Total3 - CurMoRent) * -1);
	var Total5 = ((Total1 - Total3) * 12);
	var Total6 = (Total2 * 12);
	var Total7 = (Total5 + Total6);
	var CompoundedSavings
	
	//Mike comments from compunding attempt
	//TotalInvSavings = fv(0.045, 12, RentalTerm, (Total7 * -1), 0)
	//TotalInvSavings = Total7 * (((Math.pow(1.045, parseInt(RentalTerm)))-1)/0.045)		
	

	if (Total7 <= 0)
		{
		CompoundedSavings = (Total7 * RentalTerm);
		}
	else 
		{
		CompoundedSavings = Total7 * (((Math.pow(1.045, parseInt(RentalTerm)))-1)/0.045);
		}

	var Total8 = (TotalPrinciplePaid + CompoundedSavings);

	// Format variables to look like money ($0.00) //

	{
	Total1 = ToDollars(Total1);
	Total2 = ToDollars(Total2);
	Total3 = ToDollars(Total3);
	Total4 = ToDollars(Total4);	
	Total5 = ToDollars(Total5);
	Total6 = ToDollars(Total6);
	Total7 = ToDollars(Total7);
	Total8 = ToDollars(Total8);
	TotalPrinciplePaid = ToDollars(TotalPrinciplePaid);
	}

	// Place results out on form //
	
	{
	RentPmt.setText(ToDollars(parseInt(CurMoRent)));
	RentPmtTaxAdj.setText(ToDollars(parseInt(CurMoRent)));
	BuyPmt.setText(Total1);
	PmtCompare.setText(Total2);
	BuyPmtTaxAdj.setText(Total3);
	ComparePmtTaxAdj.setText(Total4);
	AnnualTaxSavings.setText(Total5);
	PaymentSavings.setText(Total6);
	TotalAnnualSavings.setText(Total7);
	TotalPrincipal.setText(TotalPrinciplePaid);
	TotalSavings.setText(Total8);
	//Edit1.setText(CompoundedSavings);//
	}
 }
function _FormButton1__onClick() { if (FormButton1) return FormButton1.onClick(); }

