if (Calculators == undefined) {
	var Calculators = {};
}
if (Calculators.loan == undefined) {
	Calculators.loan = {};
}

Calculators.loan.StatementWithPMI = function StatementWithPMI(statement, appraisedAmount, loanAmount, pmi) {
	this.statement = statement;
	this.loanAmount = loanAmount;
	this.appraisedAmount = appraisedAmount;
	this.pmi = null;
	if (pmi) {
		this.pmi = new Calculators.type.Money(pmi);
	}
	else {
		if (this.statement.getBalance().getAmount() > (0.80 * this.appraisedAmount.getAmount())) {
			this.pmi = new Calculators.type.Money(0.005 * this.loanAmount.getAmount() / 12);
		}
		else {
			if ((this.statement.getBalance().getAmount() + this.statement.getPrincipal().getAmount()) >
			(0.80 * this.appraisedAmount.getAmount())) {
				this.pmi = new Calculators.type.Money(0.005 * this.loanAmount.getAmount() / 12);
				//alert(this.pmi.getAmount());
			}
			else {
				this.pmi = new Calculators.type.Money(0.00);
			}
		}
	}
	
	this.getBalance = function() {
		return this.statement.balance;
	}
	
	this.getInterest = function() {
		return this.statement.interest;
	}
	
	this.getPrincipal = function() {
		return this.statement.principal;
	}
	
	this.getPayment = function() {
		return this.statement.getPayment();
	}
	
	this.getPMI = function() {
		return this.pmi;
	}
	
	this.toString = function() {
//		alert(statement.getBalance().getAmount() + " > " + (0.80 * this.loanAmount.getAmount()));
		return "interest: " + this.getInterest().formatted() + "; principal: " + 
			this.getPrincipal().formatted() + "; balance: " + this.getBalance().formatted() +
			"; PMI: " + this.getPMI().formatted();
	}
}

