dt_carloan_calculate = function()
{
	var price, down, rate, months;
	try
	{
		price = DT_F.getFormFloat( "dt_carloan_price", "Please enter the purchase price", "Please enter the purchase price as a number" );
		if ( price < 0 ) {
			throw("Please enter a purchase price >= 0");
		}
		down = DT_F.getFormFloat( "dt_carloan_down", "Please enter a down payment", "Please enter the down payment as a number" );	
		if ( down < 0 ) {
			throw("Please enter a down payment >= 0");
		}
		if ( down > price ) {
			throw("Your down payment is greater than your purchase price.  Therefore, you don't need a loan.");
		}
		rate = DT_F.getFormFloat( "dt_carloan_rate", "Please enter an interest rate", "Please enter the interest rate as a number" );
		if ( rate < 0 || rate > 40 ) {
			throw("Please enter an interest rate between 0% and 40%");
		}
		months = DT_F.getFormInt( "dt_carloan_months", "Please enter the term of your loan, in months", "Please enter the term of your loan, in months", "The term of your loan was rounded down to" );
		if ( months <= 0 || months > 360 ) {
			throw("Please enter an a loan term between 1 and 360 months");
		}
	}
	catch ( err )
	{
		alert(err);
		return;
	}

	var loanAmount = price - down;
	var payment = DT_F.calcPaymentMonths(loanAmount, months, rate);
	
	var x = document.getElementById("dt_carloan_results");

	var results = "The amount of your loan will be " + DT_F.formatDollars(loanAmount) + ".";

	results += "<br><br>Your monthly payment will be <b>" + DT_F.formatDollars(payment) + "</b>.";
	
	results += "<br><br>You will pay a total of " + DT_F.formatDollars(((payment * months) + down) - price) + " in interest.";
	
	x.innerHTML = results;
	x.style.display = "block";
}