<!--
function stripNonNumerics(formField)
{

	for(var n=0; n<document.cashflow.elements.length; n++){
		if(document.cashflow.elements[n].name==formField){
			//move form field value to a working variable
			var workValue=parseFloat(document.forms[0].elements[n].value);

			//loop through the working variable removing any non-numeric characters
		    for (var i=1; i<=workValue.length ; i++)
			{
				if ((workValue.charAt(i-1) != "0") &&
					(workValue.charAt(i-1) != "1") &&
					(workValue.charAt(i-1) != "2") &&
					(workValue.charAt(i-1) != "3") &&
					(workValue.charAt(i-1) != "4") &&
					(workValue.charAt(i-1) != "5") &&
					(workValue.charAt(i-1) != "6") &&
					(workValue.charAt(i-1) != "7") &&
					(workValue.charAt(i-1) != "8") &&
					(workValue.charAt(i-1) != "9")){
					workValue=workValue.substring(0,i-1) + workValue.substring(i,workValue.length)
					i=0
				}
			}
			
			//if what's left of the working variable is not a number (NaN)
			//then clear the form field, 
			//otherwise set the form field to the value of the working variable    
			if (isNaN(workValue)){
				document.cashflow.elements[n].value = "";
			}else{	
		        document.cashflow.elements[n].value = workValue;	
			}
		
		    //now call the function to recalculate the entire form
			calcFields();
		}
	}
}

function calcFields() 
{ 

   var mortgage = parseFloat(document.cashflow.mortgage.value);
   if (isNaN(mortgage)) mortgage = 0;
   
   var assoc_due = parseFloat(document.cashflow.assoc_due.value);
   if (isNaN(assoc_due)) assoc_due = 0;

   var home_insurance = parseFloat(document.cashflow.home_insurance.value);
   if (isNaN(home_insurance)) home_insurance = 0;

   var total_housing = mortgage + assoc_due + home_insurance;
   document.cashflow.total_housing.value = Math.round(100*total_housing )/100;


   var car_loan = parseFloat(document.cashflow.car_loan.value);
   if (isNaN(car_loan)) car_loan = 0;

   var car_insurance = parseFloat(document.cashflow.car_insurance.value);
   if (isNaN(car_insurance)) car_insurance = 0;

   var car_maintenance = parseFloat(document.cashflow.car_maintenance.value);
   if (isNaN(car_maintenance)) car_maintenance = 0;

   var parking = parseFloat(document.cashflow.parking.value);
   if (isNaN(parking)) parking = 0;

   var gas = parseFloat(document.cashflow.gas.value);
   if (isNaN(gas)) gas = 0;

   var auto_other = parseFloat(document.cashflow.auto_other.value);
   if (isNaN(auto_other)) auto_other = 0;

   var total_auto = car_loan  + car_insurance + car_maintenance + parking + gas + auto_other;
   document.cashflow.total_auto.value = Math.round(100*total_auto)/100;


   var health_insurance = parseFloat(document.cashflow.health_insurance.value);
   if (isNaN(health_insurance)) health_insurance = 0;

   var disability_insurance = parseFloat(document.cashflow.disability_insurance.value);
   if (isNaN(disability_insurance)) disability_insurance = 0;

   var life_insurance = parseFloat(document.cashflow.life_insurance.value);
   if (isNaN(life_insurance)) life_insurance = 0;

   var total_insurance = health_insurance + disability_insurance + life_insurance;
   document.cashflow.total_insurance.value = Math.round(100*total_insurance)/100;


   var children_education = parseFloat(document.cashflow.children_education.value);
   if (isNaN(children_education)) children_education = 0;

   var adult_education = parseFloat(document.cashflow.adult_education.value);
   if (isNaN(adult_education)) adult_education = 0;

   var student_loans = parseFloat(document.cashflow.student_loans.value);
   if (isNaN(student_loans)) student_loans = 0;

   var education_other = parseFloat(document.cashflow.education_other.value);
   if (isNaN(education_other)) education_other = 0;

   var total_education = children_education  + adult_education + student_loans + education_other;
   document.cashflow.total_education.value = Math.round(100*total_education)/100;

   var eatout = parseFloat(document.cashflow.eatout.value);
   if (isNaN(eatout)) eatout = 0;

   var groceries = parseFloat(document.cashflow.groceries.value);
   if (isNaN(groceries)) groceries = 0;

   var total_food = eatout + groceries;
   document.cashflow.total_food.value = Math.round(100*total_food)/100;


   var cleaning = parseFloat(document.cashflow.cleaning.value);
   if (isNaN(cleaning)) cleaning = 0;

   var landscaping = parseFloat(document.cashflow.landscaping.value);
   if (isNaN(landscaping)) landscaping = 0;

   var repair = parseFloat(document.cashflow.repair.value);
   if (isNaN(repair)) repair = 0;

   var utilities = parseFloat(document.cashflow.utilities.value);
   if (isNaN(utilities)) utilities = 0;

   var house_other = parseFloat(document.cashflow.house_other.value);
   if (isNaN(house_other)) house_other = 0;

   var total_home = cleaning  + landscaping + repair + utilities + house_other;
   document.cashflow.total_home.value = Math.round(100*total_home)/100;


   var clothing = parseFloat(document.cashflow.clothing.value);
   if (isNaN(clothing)) clothing = 0;

   var cosmetics = parseFloat(document.cashflow.cosmetics.value);
   if (isNaN(cosmetics)) cosmetics = 0;

   var health_club = parseFloat(document.cashflow.health_club.value);
   if (isNaN(health_club)) health_club = 0;

   var entertainment = parseFloat(document.cashflow.entertainment.value);
   if (isNaN(entertainment)) entertainment = 0;

   var vacations = parseFloat(document.cashflow.vacations.value);
   if (isNaN(vacations)) vacations = 0;

   var gifts = parseFloat(document.cashflow.gifts.value);
   if (isNaN(gifts)) gifts = 0;

   var personal_other = parseFloat(document.cashflow.personal_other.value);
   if (isNaN(personal_other)) personal_other = 0;

   var total_personal = clothing  + cosmetics + health_club + health_insurance + entertainment + vacations + gifts + personal_other;
   document.cashflow.total_personal.value = Math.round(100*total_personal)/100;


   var taxes = parseFloat(document.cashflow.taxes.value);
   if (isNaN(taxes)) taxes = 0;

   var total_housing = parseFloat(document.cashflow.total_housing.value);
   if (isNaN(total_housing)) total_housing = 0;

   var total_auto = parseFloat(document.cashflow.total_auto.value);
   if (isNaN(total_auto)) total_auto = 0;

   var total_insurance = parseFloat(document.cashflow.total_insurance.value);
   if (isNaN(total_insurance)) total_insurance = 0;

   var total_education = parseFloat(document.cashflow.total_education.value);
   if (isNaN(total_education)) total_education = 0;

   var total_home = parseFloat(document.cashflow.total_home.value);
   if (isNaN(total_home)) total_home = 0;

   var total_food = parseFloat(document.cashflow.total_food.value);
   if (isNaN(total_food)) total_food = 0;

   var total_personal = parseFloat(document.cashflow.total_personal.value);
   if (isNaN(total_personal)) total_personal = 0;


   var misc = parseFloat(document.cashflow.misc.value);
   if (isNaN(misc)) misc = 0;	

   var total_expenses = taxes + total_housing + total_auto + total_insurance + total_education + total_home + total_food + total_personal + misc;
   document.cashflow.total_expenses.value = Math.round(100*total_expenses)/100;
   
   var total_expenses = parseFloat(document.cashflow.total_expenses.value);
   if (isNaN(total_expenses)) total_expenses = 0;
   document.cashflow.murphy_factor.value = Math.round(100*total_expenses * 1.1)/100;
 
   var murphy_factor = parseFloat(document.cashflow.murphy_factor.value);
   if (isNaN(murphy_factor)) murphy_factor = 0;
   var income = parseFloat(document.cashflow.income.value);
   if (isNaN(income)) income = 0;
   var net_cashflow = income - murphy_factor;
   document.cashflow.net_cashflow.value = Math.round(100*net_cashflow)/100;
}



//-->
