/**                 
 * Report for the "Savings Goal" calculator
 * @author Andy Tong             
 *
 * @see "Savings.cfm"
 */
if (Calculators == undefined) {
	var Calculators = {};
}
if (Calculators.report == undefined) {
	Calculators.report = {};
}

/**                 
 * @param savings      [calculator.loan.Statement]   savings statement
 * @param comparison   [calculator.loan.Statement]   comparison savings statement
 * @param calculated   [calculator.loan.Statement]   statement if goal is to be reached
 * @param goal         [calculator.type.Money]       savings goal
 */
Calculators.report.SavingsGoalReport = function SavingsGoalReport(savings, comparison, calculated, goal) {
	this.getBody = function() {
		var years = savings.getYears();
		var body = [];
		body.push('        <table style="width: 100%; border-collapse: collapse; border-spacing: 0;">\n');
		body.push('            <tr>\n');
		body.push('                <td><b>Year</b></td>\n');
		body.push('                <td><b>Investing ' + savings.getSavings().formatted() + ' monthly</b></td>\n');
		body.push('                <td><b>Investing ' + comparison.getSavings().formatted() + ' monthly</b></td>\n');
		body.push('                <td><b>Investing ' + calculated.getSavings().formatted() + ' monthly</b></td>\n');
		body.push('            </tr>\n');
		
		for (var year = 0; year <= years; ++year) {
			if (year % 2 == 0) {
				body.push("      <tr class=\"highlightStripe\">\n");
			} else {
				body.push('            <tr>\n');
			}
			body.push('                <td>' + year + '</td>\n');
			body.push('                <td>' + savings.getYearlyStatement(year).getBalance().formatted() + '</td>\n');
			body.push('                <td>' + comparison.getYearlyStatement(year).getBalance().formatted() + '</td>\n');
			body.push('                <td>' + calculated.getYearlyStatement(year).getBalance().formatted() + '</td>\n');
			body.push('            </tr>\n');	
		}
		body.push('      </table>')
		return body.join("");
	}
	
	this.getTitle = function() {
		return "Investment Needed to Achieve Goal Report";
	}
}

Calculators.report.SavingsGoalReport.prototype = new Calculators.report.Report();
