function amort() { 
	var mpr=parseFloat(document.getElementById("AvgRate").value);
	var bal =parseFloat(document.getElementById("TotalDebt").value); 
	if (isNaN(bal)) window.alert('The "Your Total Debt" value is not valid.');	
	if (isNaN(mpr)) window.alert('The "Average Annual Percentage Rate" value is not valid.');	

	if (!isNaN(bal) && !isNaN(mpr)) {
		var mpr, minpmtrate, bal, intr, tint, tpmt; intr = tint = tpmt = 0.0; 
		var mpr = mpr / 1200.0; 
		var minpmtrate = 0.025; 
		for(var i=1; bal > 1; i++) { 

			pmt = minpmtrate * bal; 
			intr = mpr * bal; 
			tint += intr; 
			if(pmt > 15.0) { 
				bal = bal - pmt; 
			} else { 
				if(bal < 15.0) { 
					bal = 0; 
				} else { 
					bal = bal - 15.0; 
					pmt = 15.0; 
				} 
			} 
			tpmt += pmt; 
			bal += intr; 
			
		} 
		
		var tmp_int = new String(); 
		tmp_int = "" + tint; 
		var pos=0, count=0; 
		while(tmp_int.substring(pos-1,pos) != ".") { 
			pos +=1; count +=1; 
		} 
		while(pos < (count + 2)) { 
			pos += 1; 
		} 
		var print_tmp=tmp_int.substring(0,pos);
		document.getElementById("TotalInterest").value = print_tmp; 
		document.getElementById("TotalMonths").value = i; 
	}
}
