var i = 0; // interest
var m = 0; // months
var f = 0; // factor
var den = 0; 
var s = "0"; // string
var d = 0; // decimal place
function CalcA() {
	if(document.calform.interest.value=="" || document.calform.months.value=="" || document.calform.payment.value=="") {
		alert("Please fill in all fields.");
	}else { 
		if(document.calform.period.options[1].selected == true) {
			m = document.calform.months.value * 12;
		}else {
			m = document.calform.months.value;
		} 
		i = Math.pow(((document.calform.interest.value/100)+1),.0833333)-1;
		den = i / (i+1);
		f = Math.pow((i+1),m)-1;
		f /= den;
		f *= document.calform.payment.value;
		d = String(f).indexOf(".");
		s = String(f).substring(0,(d+3));
		document.calform.total.value = + s;  
	}
}