function getMortgage(a,n,p)
		{
			if (document.getElementById('TermYear').checked)
			{
			n = n * 12;
			}

			var i=0;
			var sATline="";
			var oMortgageTable=document.getElementById("mortgagetable");
			oMortgageTable.style.visibility="visible";

			/* Calculate amortization and write table to text area **/
			
var payment = getPayment(a,n,p);
			
oMortgageTable.value = "Your monthly payment for a " + n + " month loan at " + p + "% would be " + (Math.round(payment*100)/100);
		}

	function getPayment(a,n,p) {
		
/* Calculates the monthly payment from annual percentage rate, term of loan in months and loan amount. */

		var acc=0;
		var base = 1 + p/1200;
		for (i=1;i<=n;i++)
			{ acc += Math.pow(base,-i); }
		return a/acc;
	}
	function CheckYears()
	{
		document.getElementById('TermMonth').checked = "";
	}
	function CheckMonths()
	{
		document.getElementById('TermYear').checked = "";
	}

//functions have been created which are called from the <BODY>, each refer to the form, textbox and the value contained as well as calling Math methods for each.

function CalcChSign(input) {
if(input.value.substring(0, 1) == "-")
input.value = input.value.substring(1, input.value.length)
else
input.value = "-" + input.value
}

function DeleteChar(input) {
input.value = input.value.substring(0,input.value.length - 1)
}
function Reset(input) {
input.value = ""
}
function Display1(input) {
input.value += "1"
		
}
function Display2(input) {
input.value += "2"
}
function Display3(input) {
input.value += "3"
}
function Display4(input) {
input.value += "4"
}
function Display5(input) {
input.value += "5"
}
function Display6(input) {
input.value += "6"
}
function Display7(input) {
input.value += "7"
}
function Display8(input) {
input.value += "8"
}
function Display9(input) {
input.value += "9"
}
function Display0(input) {
input.value += "0"
}
function DisplayPt(input) {
input.value += "."
}
function DisplayDiv(input) {
input.value += "/"
}
function DisplayMult(input) {
input.value += "*"
}
function DisplayPlus(input) {
input.value += "+"
}
function DisplayMinus(input) {
input.value += "-"
}

function CalcResult(form) {
form.input.value = eval(form.input.value);
}

