function doTotal()
{
	var amount = document.getElementsByName("amount");
	var payment = document.getElementsByName("payment");
	var trate = parseInt(document.getElementById("appliedrate").value);
	var total = 0;
	var temp = 0;
	
	for(i=0;i<amount.length;i++)
	{
		temp = amount[i].value;
		if(temp.indexOf("$")>-1)
		{
			temp = parseFloat(temp.substr(temp.indexOf("$")+1));
		}
		total += parseFloat(temp);
		//alert(total);
	}
	document.getElementById("total_amount").value = total;
//	temp = (total * 1.01) / (30 * 12);
	var IR = trate/100/12;
	
//	temp = (Math.floor((total*IR)/(1-Math.pow(1+IR,(-1*360)))*100)/100)/360;
	temp = Math.floor((total*IR)/(1-Math.pow(1+IR,(-1*360)))*100)/100;
	temp = String(temp);
	if(temp.indexOf(".")>-1)
		temp = temp.substr(0,temp.indexOf(".")+3);
	document.getElementById("newPayment").value = temp;
	total = 0;
	for(i=0;i<payment.length;i++)
	{
		temp = payment[i].value;
		if(temp.indexOf("$")>-1)
		{
			temp = parseFloat(temp.substr(temp.indexOf("$")+1));
		}
		total += parseFloat(temp);
	}
	document.getElementById("total_payment").value = total;
	temp = parseFloat(total) - parseFloat(document.getElementById("newPayment").value);	
	temp = String(temp);
	if(temp.indexOf(".")>-1)
		temp = temp.substr(0,temp.indexOf(".")+3);
	document.getElementById("savings").value = temp;
}