function updateTotals()
{
  var theForm = document.forms[1];
  var fedTax = getValue(theForm.federalTaxRate.value)/100;
  var stateTax = getValue(theForm.stateTaxRate.value)/100;
  ssTax =.0765;
  var taxRate = fedTax + stateTax + ssTax;

  //validate the form
  strErrors = validateForm(theForm);

  if(strErrors.length == 0)
  {
    //update Taxable Income
    theForm.woTaxIncome.value = formatCurrency(theForm.totalIncome.value);
    theForm.wTaxIncome.value = formatCurrency(parseFloat(getValue(theForm.totalIncome.value)) 
		- parseFloat(getValue(theForm.hlthDeductibles.value)) 	- parseFloat(getValue(theForm.hlthCopayments.value)) 
		- parseFloat(getValue(theForm.hlthOther.value)) 		- parseFloat(getValue(theForm.dentalExpenses.value))
		- parseFloat(getValue(theForm.visionExpenses.value)) 	- parseFloat(getValue(theForm.orthodontiaExpenses.value))		
		- parseFloat(getValue(theForm.drugExpenses.value)) 		- parseFloat(getValue(theForm.otherExpenses.value))	);

    //update taxes witheld
    theForm.woTaxWithheld.value = formatCurrency(getValue(theForm.woTaxIncome.value) * taxRate);
    theForm.wTaxWithheld.value = formatCurrency(getValue(theForm.wTaxIncome.value) * taxRate);

    //add up expenses
    theForm.woHlthCareExpenses.value = formatCurrency(getValue(theForm.hlthDeductibles.value) 		+ getValue(theForm.hlthCopayments.value) 
		+ getValue(theForm.hlthOther.value) 		+ getValue(theForm.dentalExpenses.value) 		+ getValue(theForm.visionExpenses.value)
		+ getValue(theForm.visionExpenses.value) 	+ getValue(theForm.orthodontiaExpenses.value) 	+ getValue(theForm.drugExpenses.value)
		+ getValue(theForm.otherExpenses.value));
    //theForm.hlthTotal.value = formatCurrency(getValue(theForm.hlthDeductibles.value) + getValue(theForm.hlthCopayments.value) + getValue(theForm.hlthOther.value));
  
    //update resulting take home pay
    theForm.woTakeHome.value = formatCurrency(getValue(theForm.woTaxIncome.value) 	- getValue(theForm.woTaxWithheld.value));
    theForm.wTakeHome.value = formatCurrency(getValue(theForm.wTaxIncome.value) 	- getValue(theForm.wTaxWithheld.value));

    //update disposable income
    theForm.woDisposableIncome.value = formatCurrency(getValue(theForm.woTakeHome.value) - getValue(theForm.woHlthCareExpenses.value));
    theForm.wDisposableIncome.value = formatCurrency(getValue(theForm.wTakeHome.value));

    //update difference in disposable income
    theForm.TaxSavings.value = formatCurrency(getValue(theForm.wDisposableIncome.value) - getValue(theForm.woDisposableIncome.value));

  }
  else
  {
  
    //clear out fields
    theForm.woTaxIncome.value = "";
    theForm.wTaxIncome.value = "";
    theForm.woTaxWithheld.value = "";
    theForm.wTaxWithheld.value = "";
    theForm.woHlthCareExpenses.value = "";
    theForm.woTakeHome.value = "";
    theForm.wTakeHome.value = "";
	theForm.woDisposableIncome.value = "";
	theForm.wDisposableIncome.value = "";
    theForm.TaxSavings.value = "";

    alert("The following fields need to be corrected:" + "\n" + strErrors);

  }
  
}

function updateHealthCareTotals()
{
  var theForm = document.forms[0];
//  theForm.hlthTotal.value = formatCurrency(getValue(theForm.hlthDeductibles.value) + getValue(theForm.hlthCopayments.value) + getValue(theForm.hlthOther.value));
  
}

function validateForm(theForm)
{
  var strResponse = "";
  
  //must enter total income
  if(getValue(theForm.totalIncome.value)<=0)
  {
    //blnValid = false;
    strResponse = ' - Total Income is required\n';
  }


  //contribution must be less than total income
  if(getValue(theForm.hlthDeductibles.value) 			+ getValue(theForm.hlthCopayments.value) 
		+ getValue(theForm.hlthOther.value) 			+ getValue(theForm.hlthDeductibles.value) 
		+ getValue(theForm.hlthCopayments.value) 		+ getValue(theForm.hlthOther.value)
		+ getValue(theForm.dentalExpenses.value) 		+ getValue(theForm.visionExpenses.value)
		+ getValue(theForm.orthodontiaExpenses.value) 	+ getValue(theForm.drugExpenses.value)
		+ getValue(theForm.otherExpenses.value) > getValue(theForm.totalIncome.value))
  {
    strResponse = strResponse + ' - Healthcare expenses must be less than total income\n';
  }

  //Federal Tax <= 40
  if(getValue(theForm.federalTaxRate.value)>40)
  {
    strResponse = strResponse + ' - Federal tax rate cannot be greater than 40%\n';
  }

  //State Tax <= 15
  if(getValue(theForm.stateTaxRate.value)>15)
  {
    strResponse = strResponse + ' - State tax rate cannot be greater than 15%\n';
  }

  return strResponse;

}