// ************* FINANCE FORM ADDING SCRIPT ***********

var aAssets = new Array("total_assets","home_value","invest_prop1","invest_prop2","invest_prop3","motor_vehicles","cash_savings","deposits_paid","shares","supertotal");

var aLiab = new Array("total_liabilities","amowe_totalmortgages","amowe_rent","amowe_lease","amowe_overdraft","amowe_totalcredit","amowe_personalloans","amowe_maintenance");

var aIncome_app1 = new Array("app1_totalincome","app1_salary","app1_otherincome","app1_investments","app1_rentalincome");

var aIncome_app2 = new Array("app2_totalincome","app2_salary","app2_otherincome","app2_investments","app2_rentalincome");

function calcSum(fields) // takes an array of field names, checks for NaNs, then calculates the sum and prints that value to the array idx 0
{
var iTotal = 0;
for (i = 1; i < fields.length; i++)
{
	if (isNaN(parseInt(document.getElementById("finan")[fields[i]].value)))
	{
		alert("Please use whole number amounts only, avoiding decimal places, commas and other non-numerical amounts characters. Leave a '0' if a value is not applicable."); break
	}
	else
	{
		iAddValue = (parseInt(document.getElementById("finan")[fields[i]].value));
		iTotal = iTotal + iAddValue;
		document.finan[(fields[0])].value = iTotal;
	}
}
//alert(iTotal);
}