addLoadEvent(function() {
	var anchors = document.getElementsByTagName("a"); 
	for (var i=0; i<anchors.length; i++) { 
		var anchor = anchors[i]; 
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank"; 
		}
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "popup") {
			anchor.onclick = function () { 
				window.open(this.href,'mywindow','width=450,height=600');
				return false;
			}
		}
	} 
})

addLoadEvent(function() {
	if (typeof sIFR == "function") {
		sIFR.replaceElement("h1", named({sFlashSrc:"http://workforceinfo.preationdev.com/flash/avenirRoman.swf", sColor:"#333333", sWmode:"transparent"}));
		sIFR.replaceElement("h2", named({sFlashSrc:"http://workforceinfo.preationdev.com/flash/avenirRoman.swf", sColor:"#666666", sWmode:"transparent"}));
		sIFR.replaceElement("#mainText p", named({sFlashSrc:"http://workforceinfo.preationdev.com/flash/avenirRoman.swf", sColor:"#ffffff", sWmode:"transparent"}));
	};
})

addLoadEvent(function() {
	if (document.getElementById('calculateMonthlyPaymentForm')) {
		document.getElementById('numYears').onchange = function () { 
			calculateMonthlyPayment('numYears','interestRate','loanAmount','monthlyPayment');
		}
		document.getElementById('interestRate').value = formatPercentage(document.getElementById('interestRate').value);
		document.getElementById('interestRate').onchange = function () { 
			calculateMonthlyPayment('numYears','interestRate','loanAmount','monthlyPayment');
		}
		document.getElementById('interestRate').onblur = function () { 
			this.value = formatPercentage(this.value);
		}
		document.getElementById('loanAmount').value = formatCurrency(document.getElementById('loanAmount').value);
		document.getElementById('loanAmount').onchange = function () { 
			calculateMonthlyPayment('numYears','interestRate','loanAmount','monthlyPayment');
		}
		document.getElementById('loanAmount').onblur = function () { 
			this.value = formatCurrency(this.value);
		}
		document.getElementById('calculateMonthlyPaymentButton').onclick = function () { 
			calculateMonthlyPayment('numYears','interestRate','loanAmount','monthlyPayment');
		}
	}
	if (document.getElementById('calculateLoanAmountForm')) {
		document.getElementById('interestRate2').value = formatPercentage(document.getElementById('interestRate2').value);
		document.getElementById('interestRate2').onchange = function () { 
			calculateMortgageAmount('interestRate2','monthlyPayment2','loanAmount2');
		}
		document.getElementById('interestRate2').onblur = function () { 
			this.value = formatPercentage(this.value);
		}
		document.getElementById('monthlyPayment2').value = formatCurrency(document.getElementById('monthlyPayment2').value);
		document.getElementById('monthlyPayment2').onchange = function () { 
			calculateMortgageAmount('interestRate2','monthlyPayment2','loanAmount2');
		}
		document.getElementById('monthlyPayment2').onblur = function () { 
			this.value = formatCurrency(this.value);
		}
		document.getElementById('calculateLoanAmountButton').onclick = function () { 
			calculateMortgageAmount('interestRate2','monthlyPayment2','loanAmount2');
		}
	}
})



