dt_mill_calculate = function()
{
	var savings, deposits, rate, age;
	try
	{
		savings = DT_F.getFormFloat( "dt_mill_savings", "Please enter your current savings", "Please enter your current savings as a number" );
		if ( savings < 0 ) {
			throw("Please enter a current savings >= 0");
		}
		if ( savings >= 1000000 ) {
			throw("You are already a millionaire.  Congrats!");
		}
		deposits = DT_F.getFormFloat( "dt_mill_deposits", "Please enter the amount of your yearly deposits", "Please enter your yearly deposits as a number" );
		if ( deposits < 0 ) {
			throw("Please enter yearly deposits >= 0");
		}
		rate = DT_F.getFormFloat( "dt_mill_rate", "Please enter the rate of return for your savings", "Please enter, as a number, the rate of return for your savings" );
		if ( rate < -100 ) {
			throw("Please enter a rate of return >= -100%");
		}
		age = DT_F.getFormInt( "dt_mill_age", "Please enter your current age", "Please enter your current age as a number", "Your current age was rounded to " );
		if ( age < 0 ) {
			throw("Please enter a current age >= 0");
		}
	}
	catch ( err )
	{
		alert(err);
		return;
	}

	var r = 1 + (rate / 100);
	var money = savings;
	 
	var years = 0;
	var table = [];
	var results = [];

	table.push("<table cellpadding='0' cellspacing='0'>");
	table.push("<tr><th>Age</th><th>Net Worth</th></tr>");
	table.push("<tr><td class=\"c\">" + age + "</td><td class=\"r\">" + DT_F.formatDollars(money) + "</td></tr>");
	while ( money < 1000000 && years < 100 )
	{
		money = ( money * r ) + deposits;
		years++;
		if ( years <= 10 ) {
			table.push("<tr><td class=\"c\">" + (age+years) + "</td><td class=\"r\">" + DT_F.formatDollars(money) + "</td></tr>");
		}
	}
	table.push("</table>");

	if ( money < 1000000 ) {
		results.push("At this rate, you won't be a millionaire in the next 100 years. Sorry.");
	}
	else {
		results.push("You will be a millionaire in " + years + " years, at the age of " + (age + years) + ".");
	}

	if ( years > 10 ) {
		results.push("<br><br>Here is how your net worth will grow over the first 10 years:<br>");
	}
	else {
		results.push("<br><br>Here is how your net worth will grow over time:<br><br>");
	}

	var x = document.getElementById("dt_mill_results");
	x.innerHTML = results.join('') + " " + table.join('');
	x.style.display = "block";
};
