dt_mtgcomp_calculate = function()
{
	var price, downpayment, rate15, rate30;
	try
	{
		price = DT_F.getFormFloat("dt_mtgcomp_purchaseprice", "Please enter the purchase price", "Please enter the  purchase price as a number" );
		if ( price < 0 ) {
			throw("Please enter a purchase price >= 0");
		}
		downpayment = DT_F.getFormFloat("dt_mtgcomp_down", "Please enter a down payment", "Please enter the down payment as a number" );
		if ( downpayment < 0 ) {
			throw("Please enter a down payment >= 0");
		}
		rate15 = DT_F.getFormFloat("dt_mtgcomp_rate15", "Please enter the 15-year interest rate", "Please enter the 15-year interest rate as a number" );
		if ( rate15 <= 0 || rate15 >= 30 ) {
			throw("Please enter a 15-year interest rate greater than 0 and less than 30");
		}
		rate30 = DT_F.getFormFloat("dt_mtgcomp_rate30", "Please enter the 30-year interest rate", "Please enter the 30-year interest rate as a number" );
		if ( rate30 <= 0 || rate30 >= 30 ) {
			throw("Please enter a 30-year interest rate greater than 0 and less than 30");
		}
	}
	catch ( err )
	{
		alert(err);
		return;
	}

	var loanamount = price - downpayment;
	var payment15 = DT_F.calcPayment(loanamount, 15*12, rate15);
	var payment30 = DT_F.calcPayment(loanamount, 30*12, rate30);
	var x = document.getElementById("dt_mtgcomp_results");
	results = 
	"Loan Amount: " + DT_F.formatDollars(loanamount) +
	"<br><br><table cellpadding='0' cellspacing='0'>" +
	"<tr><td class='c'></td><td class='c'>15-year</td><td class='c'>30-year</td></tr>" +
	"<tr><td>Monthly Payment</td><td class='d'>" + DT_F.formatDollars(payment15) + "</td><td class='d'>" + DT_F.formatDollars(payment30) + "</td></tr>" +
	"<tr><td>Total Payments</td><td class='d'>" + DT_F.formatDollars( payment15 * 15 * 12 ) + "</td><td class='d'>" + DT_F.formatDollars( payment30 * 30 * 12 ) + "</td></tr>" +
	"<tr><td>Total Interest</td><td class='d'>" + DT_F.formatDollars( payment15 * 15 * 12 - loanamount ) + "</td><td class='d'>" + DT_F.formatDollars( payment30 * 30 * 12 - loanamount ) + "</td></tr>" +
	"</table>";
	x.innerHTML = results;	x.style.display = "block";
};
