//Input Variables
var doc_phys, doc_baby, doc_diag, doc_special, mammogram, xray, emerg, PSA_test;
var immunization, cholesterol, chiropractic, mat_norm, mat_ces, colonoscopy, emerg, two_day_hospital
var drug_ret_gen, drug_ret_pref, drug_ret_nonpref
var drug_mo_gen, drug_mo_pref, drug_mo_nonpref; 
var other_exp, cvg, emp_class, medicare_type, income, num_depends;
				
// Output Variables for medical costs
var T_HMO_deduct_disp, HI_HMO_deduct_disp, SE_PPOIN_deduct_disp, SE_PPOOUT_deduct_disp;
var HI_PPOIN_deduct_disp, HI_PPOOUT_deduct_disp;

var T_HMO_copay_disp, HI_HMO_copay_disp, SE_PPOIN_copay_disp, SE_PPOOUT_copay_disp;
var HI_PPOIN_copay_disp, HI_PPOOUT_copay_disp;

var T_HMO_coin_disp, HI_HMO_coin_disp, SE_PPOIN_coin_disp, SE_PPOOUT_coin_disp;
var HI_PPOIN_coin_disp, HI_PPOOUT_coin_disp;

var T_HMO_enc_disp, HI_HMO_enc_disp, SE_PPOIN_enc_disp, SE_PPOOUT_enc_disp;
var HI_PPOIN_enc_disp, HI_PPOOUT_enc_disp;

var T_HMO_oopre_disp, HI_HMO_oopre_disp, SE_PPOIN_oopre_disp, SE_PPOOUT_oopre_disp;
var HI_PPOIN_oopre_disp, HI_PPOOUT_oopre_disp;

var T_HMO_prem_disp, HI_HMO_prem_disp, SE_PPOIN_prem_disp, SE_PPOOUT_prem_disp;
var HI_PPOIN_prem_disp, HI_PPOOUT_prem_disp;

var T_HMO_oopost_disp, HI_HMO_oopost_disp, SE_PPOIN_oopost_disp, SE_PPOOUT_oopost_disp;
var HI_PPOIN_oopost_disp, HI_PPOOUT_oopost_disp;

var HSA_PPOIN_TOTPROJ_disp, HSA_PPOOUT_TOTPROJ_disp, HSA_HMO_TOTPROJ_disp;
var HSA_PPOIN_STATE_disp, HSA_PPOOUT_STATE_disp, HSA_HMO_STATE_disp;
var HSA_PPOIN_EMP_disp, HSA_PPOOUT_EMP_disp, HSA_HMO_EMP_disp;
var HSA_PPOIN_ROLL_disp, HSA_PPOOUT_ROLL_disp, HSA_HMO_ROLL_disp;
var HSA_PPOIN_SAVINGS_disp, HSA_PPOOUT_SAVINGS_disp, HSA_HMO_SAVINGS_disp;


var nc_expnc_disp, tsave;

//main functions ------------------------------------------------------------------------------
function ResolveContributuions ()//Selects the proper contribution rate for display/calculation
{
	if (emp_class == 0 || emp_class == 5){
		state_contrib_GROUP1 = active_ft_PPO_HMO_STATE[cvg] * 12;
		enrolee_contrib_GROUP1 = active_ft_PPO_HMO_ENROLEE[cvg] * 12;
		state_contrib_GROUP2 = active_ft_HI_STATE[cvg] * 12;
		enrolee_contrib_GROUP2 = active_ft_HI_ENROLEE[cvg] * 12;
		}
	else if (emp_class == 1 || emp_class == 2 || emp_class == 4){
		state_contrib_GROUP1 = payall_PPO_HMO_STATE[cvg] * 12;
		enrolee_contrib_GROUP1 = payall_PPO_HMO_ENROLEE[cvg] * 12;
		state_contrib_GROUP2 = payall_HI_STATE[cvg] * 12;
		enrolee_contrib_GROUP2 = payall_HI_ENROLEE[cvg] * 12;
		}
	else if (emp_class == 3){
		state_contrib_GROUP1 = active_pt_PPO_HMO_STATE[cvg] * 12;
		enrolee_contrib_GROUP1 = active_pt_PPO_HMO_ENROLEE[cvg] * 12;
		state_contrib_GROUP2 = active_pt_HI_STATE[cvg] * 12;
		enrolee_contrib_GROUP2 = active_pt_HI_ENROLEE[cvg] * 12;
		}
	else if (emp_class == 6){
		state_contrib_GROUP1 = early_retiree_PPO_HMO_STATE[cvg] * 12;
		enrolee_contrib_GROUP1 = early_retiree_PPO_HMO_ENROLEE[cvg] * 12;
		state_contrib_GROUP2 = early_retiree_HI_STATE[cvg] * 12;
		enrolee_contrib_GROUP2 = early_retiree_HI_ENROLEE[cvg] * 12;
		}
	else if (emp_class == 7){
		state_contrib_GROUP1 = COBRA_PPO_HMO_STATE[cvg] * 12;
		enrolee_contrib_GROUP1 = COBRA_PPO_HMO_ENROLEE[cvg] * 12;
		state_contrib_GROUP2 = COBRA_HI_STATE[cvg] * 12;
		enrolee_contrib_GROUP2 = COBRA_HI_ENROLEE[cvg] * 12;
		}						
	else{
		state_contrib_GROUP1 = medicare_PPO_HMO_STATE[medicare_type] * 12;
		enrolee_contrib_GROUP1 = medicare_PPO_HMO_ENROLEE[medicare_type] * 12;
		state_contrib_GROUP2 = medicare_HI_STATE[medicare_type] * 12;
		enrolee_contrib_GROUP2 = medicare_HI_ENROLEE[medicare_type] * 12;
	}
}

//---------------------------------------------------------------------------------------------------------

function retrieveInput (form) // Input values from form	
{	
doc_phys = parseInput(form.doc_phys.value);
	doc_baby = parseInput(form.doc_baby.value);
	doc_diag = parseInput(form.doc_diag.value);
	doc_special = parseInput(form.doc_special.value);
	mammogram = parseInput(form.mammogram.value);
	xray = parseInput(form.xray.value);
	PSA_test = parseInput(form.PSA_test.value);
	immunization = parseInput(form.immunization.value);
	cholesterol = parseInput(form.cholesterol.value);chiropractic
	chiropractic = parseInput(form.chiropractic.value);
	mat_norm = parseInput(form.mat_norm.value);
	mat_ces = parseInput(form.mat_ces.value);
	colonoscopy = parseInput(form.colonoscopy.value);
	emerg = parseInput(form.emerg.value);
	two_day_hospital = parseInput(form.two_day_hospital.value);
	drug_ret_gen = parseInput(form.drug_ret_gen.value);
	drug_ret_pref = parseInput(form.drug_ret_pref.value);
	drug_ret_nonpref = parseInput(form.drug_ret_nonpref.value);
	drug_mo_gen = parseInput(form.drug_mo_gen.value);
	drug_mo_pref = parseInput(form.drug_mo_pref.value);
	drug_mo_nonpref = parseInput(form.drug_mo_nonpref.value);
	other_exp = parseInput(form.other_exp.value);
	income = parseInput(form.income.value);
	num_depends = parseInput(form.num_depends.value);
}

//---------------------------------------------------------------------------------------------------------

function totalUtil (form)
{	var indexnum = 0;
	//Total Utilization Amount -- no coverage
	nc_expnc_disp = (doc_phys*doc_phys_amt[indexnum]) +
						    (doc_baby*doc_baby_amt[indexnum]) + 
						  	(doc_diag*doc_diag_amt[indexnum]) + 
			       			(doc_special*doc_special_amt[indexnum]) + 
			       			(mammogram*mammogram_amt[indexnum]) + 
			       			(xray*xray_amt[indexnum]) +  
			       			(PSA_test*PSA_test_amt[indexnum]) + 
			       			(immunization*immunization_amt[indexnum]) + 							
			       			(cholesterol*cholesterol_amt[indexnum]) + 
			       			(chiropractic*chiropractic_amt[indexnum]) + 														
			       			(mat_norm*mat_norm_amt[indexnum]) + 
			       			(mat_ces*mat_ces_amt[indexnum]) +
			       			(colonoscopy*colonoscopy_amt[indexnum]) +							
			       			(emerg*emerg_amt[indexnum]) +
			       			(two_day_hospital*two_day_hospital_amt[indexnum]) +														 
			       			(drug_ret_gen*drug_ret_gen_amt[indexnum]) + 
			       			(drug_ret_pref*drug_ret_pref_amt[indexnum]) + 
			       			(drug_ret_nonpref*drug_ret_nonpref_amt[indexnum]) + 
			       			(drug_mo_gen*drug_mo_gen_amt[indexnum]) + 
			       			(drug_mo_pref*drug_mo_pref_amt[indexnum]) + 
			       			(drug_mo_nonpref*drug_mo_nonpref_amt[indexnum]) + other_exp;
			       
	form.nc_expnc.value = format(nc_expnc_disp,2);			       
			       
}

//---------------------------------------------------------------------------------------------------------

function T_HMO_Calc (form)
{	var indexnum = 1;
	
	//Traditional HMO Calculations
	T_HMO_deduct_disp = 0;
	T_HMO_copay_disp = 0;
	T_HMO_coin_disp = 0;
	T_HMO_enc_disp = 0;
	T_HMO_oopre_disp = 0;
	T_HMO_prem_disp = enrolee_contrib_GROUP1;
	T_HMO_oopost_disp = 0;
	
//Calculate Traditional HMO Services Copays	
	T_HMO_copay_disp = (doc_diag*doc_diag_amt[indexnum]) +
			       			(doc_special*doc_special_amt[indexnum]) + 
							(chiropractic*chiropractic_amt[indexnum]) +
			       			(mat_norm*mat_norm_amt[indexnum]) + 
			       			(mat_ces*mat_ces_amt[indexnum]) +			
			       			(emerg*emerg_amt[indexnum]) +
			       			(two_day_hospital*two_day_hospital_amt[indexnum]) +														 
			       			(drug_ret_gen*drug_ret_gen_amt[indexnum]) + 
			       			(drug_ret_pref*drug_ret_pref_amt[indexnum]) + 
			       			(drug_ret_nonpref*drug_ret_nonpref_amt[indexnum]) + 
			       			(drug_mo_gen*drug_mo_gen_amt[indexnum]) + 
			       			(drug_mo_pref*drug_mo_pref_amt[indexnum]) + 
			       			(drug_mo_nonpref*drug_mo_nonpref_amt[indexnum]);
	
	T_HMO_oopre_disp = T_HMO_deduct_disp + T_HMO_copay_disp + T_HMO_coin_disp + T_HMO_enc_disp;
	
	T_HMO_oopost_disp = T_HMO_oopre_disp + T_HMO_prem_disp;
	
	form.T_HMO_deduct.value = format(T_HMO_deduct_disp,2);
	form.T_HMO_copay.value = format(T_HMO_copay_disp,2);
	form.T_HMO_coin.value = format(T_HMO_coin_disp,2);
	form.T_HMO_enc.value = format(T_HMO_enc_disp,2);
	form.T_HMO_oop_pre.value = format(T_HMO_oopre_disp,2);
	form.T_HMO_prem.value = format(T_HMO_prem_disp,2);
	form.T_HMO_oop_post.value = format(T_HMO_oopost_disp,2);
}

//---------------------------------------------------------------------------------------------------------

function HI_HMO_Calc (form)
{	var indexnum = 2;
	
	//Health Investor HMO Calculations
	HI_HMO_deduct_disp = 0;
	HI_HMO_copay_disp = 0;
	HI_HMO_coin_disp = 0;
	HI_HMO_enc_disp = 0;
	HI_HMO_oopre_disp = 0;
	HI_HMO_prem_disp = enrolee_contrib_GROUP2;
	HI_HMO_oopost_disp = 0;
	
	HI_HMO_deduct_disp = 	(doc_diag*doc_diag_amt[indexnum]) + 
			       			(doc_special*doc_special_amt[indexnum]) + 
							(chiropractic*chiropractic_amt[indexnum]) + 														
			       			(mat_norm*mat_norm_amt[indexnum]) + 
			       			(mat_ces*mat_ces_amt[indexnum]) +							
			       			(emerg*emerg_amt[indexnum]) +
			       			(two_day_hospital*two_day_hospital_amt[indexnum]) +
							other_exp;
	
	HI_HMO_mamm_deduct_svcs = (mammogram*mammogram_amt[7]);												 	
							
	rx_gen_and_formulary = 	(drug_ret_gen*drug_ret_gen_amt[indexnum]) + 
			       			(drug_ret_pref*drug_ret_pref_amt[indexnum]) + 
			       			(drug_mo_gen*drug_mo_gen_amt[indexnum]) + 
			       			(drug_mo_pref*drug_mo_pref_amt[indexnum]);
							
	rx_non_formulary = 		(drug_ret_nonpref*drug_ret_nonpref_amt[indexnum]) + 
			       			(drug_mo_nonpref*drug_mo_nonpref_amt[indexnum]);							
							
	   //has the deductable been met with only services?
   if (HI_HMO_deduct_disp >= HI_HMO_deductibles[cvg]){
       // if yes - coinsurance is applied
   		HI_HMO_coin_disp = (HI_HMO_deduct_disp - HI_HMO_deductibles[cvg]) * HI_HMO_coinsurance;//services percentage
		HI_HMO_coin_disp += rx_gen_and_formulary * HI_HMO_rx_gen_and_f_coinsurance;//generic/formulary rx percentage
		HI_HMO_coin_disp += rx_non_formulary * HI_HMO_rx_nf_coinsurance;//non-formulary rx percentage
		HI_HMO_deduct_disp = HI_HMO_deductibles[cvg];
	}	
   else if (HI_HMO_deduct_disp + rx_gen_and_formulary >= HI_HMO_deductibles[cvg]){
        //has the deductable been met with services + generic and formulary rx?
		HI_HMO_coin_disp += (HI_HMO_deduct_disp + rx_gen_and_formulary - HI_HMO_deductibles[cvg]) * HI_HMO_rx_gen_and_f_coinsurance;//generic/formulary rx percentage
		HI_HMO_coin_disp += rx_non_formulary * HI_HMO_rx_nf_coinsurance;//non-formulary rx percentage
		HI_HMO_deduct_disp = HI_HMO_deductibles[cvg];		   
	}
   else if (HI_HMO_deduct_disp + rx_gen_and_formulary + rx_non_formulary >= HI_HMO_deductibles[cvg]){
        //has the deductable been met with services + generic and formulary + non-formulary rx?
		HI_HMO_coin_disp += (HI_HMO_deduct_disp + rx_gen_and_formulary + rx_non_formulary- HI_HMO_deductibles[cvg]) * 
		                     HI_HMO_rx_nf_coinsurance;//non-formulary rx percentage
		HI_HMO_deduct_disp = HI_HMO_deductibles[cvg];		   
	}
	else if (HI_HMO_deduct_disp + rx_gen_and_formulary + rx_non_formulary + HI_HMO_mamm_deduct_svcs >= HI_HMO_deductibles[cvg]){
        //has the deductable been met with services + generic and formulary + non-formulary rx + mammogram?
		HI_HMO_coin_disp += 0;// any left over cost for mammogram after deductible has been met is zero
		HI_HMO_deduct_disp = HI_HMO_deductibles[cvg];		   
	}	   
	else{		   
		HI_HMO_deduct_disp += rx_gen_and_formulary + rx_non_formulary + HI_HMO_mamm_deduct_svcs;
   }	
   
 	//has the out of pocket maximum been met?
	//**note**there are no copays for this plan
	//**note**the OOP max does not include the deductable
	if(HI_HMO_coin_disp > HI_HMO_oopmax[cvg]){
		HI_HMO_coin_disp = HI_HMO_oopmax[cvg];
	}

	HI_HMO_oopre_disp =  HI_HMO_deduct_disp + HI_HMO_copay_disp + HI_HMO_coin_disp + HI_HMO_enc_disp;
	
	HI_HMO_oopost_disp = HI_HMO_oopre_disp + HI_HMO_prem_disp;
	
	form.HI_HMO_deduct.value = format(HI_HMO_deduct_disp,2);
	form.HI_HMO_copay.value = format(HI_HMO_copay_disp,2);
	form.HI_HMO_coin.value = format(HI_HMO_coin_disp,2);
	form.HI_HMO_enc.value = format(HI_HMO_enc_disp,2);
	form.HI_HMO_oop_pre.value = format(HI_HMO_oopre_disp,2);
	form.HI_HMO_prem.value = format(HI_HMO_prem_disp,2);
	form.HI_HMO_oop_post.value = format(HI_HMO_oopost_disp,2);		
}

//---------------------------------------------------------------------------------------------------------

function SE_PPOIN_Calc (form)
{	var indexnum = 3;
	//State Employee PPO in network Calculations
	SE_PPOIN_deduct_disp = 0;
	SE_PPOIN_copay_disp = 0;
	SE_PPOIN_coin_disp = 0;
	SE_PPOIN_enc_disp = 0;
	SE_PPOIN_oopre_disp = 0;
	SE_PPOIN_prem_disp = enrolee_contrib_GROUP1;
	SE_PPOIN_oopost_disp = 0;
	

	//**note** none of these amounts apply towards the OOP maximum or the deductable
	SE_PPOIN_copay_disp =  	(doc_diag*doc_diag_amt[indexnum]) + 
			       			(doc_special*doc_special_amt[indexnum]) +
							(chiropractic*chiropractic_amt[indexnum]) + 				
			       			(emerg*emerg_amt[indexnum]) +
			       			(two_day_hospital*two_day_hospital_amt[indexnum]) +														 
			       			(drug_ret_gen*drug_ret_gen_amt[indexnum]) + 
			       			(drug_ret_pref*drug_ret_pref_amt[indexnum]) + 
			       			(drug_ret_nonpref*drug_ret_nonpref_amt[indexnum]) + 
			       			(drug_mo_gen*drug_mo_gen_amt[indexnum]) + 
			       			(drug_mo_pref*drug_mo_pref_amt[indexnum]) + 
			       			(drug_mo_nonpref*drug_mo_nonpref_amt[indexnum]);
							
							
	SE_PPOIN_deduct_disp =  (emerg * SE_PPOIN_emerg) + 
							(mat_norm*mat_norm_amt[indexnum]) + 
			       			(mat_ces*mat_ces_amt[indexnum]) +
   					 		other_exp;
	
	SE_PPOIN_mamm_deduct_svcs = (mammogram*mammogram_amt[7]);						
	
	//calculates the portion of a two day hospital stay to which coinsurance must be immediately applied						
   SE_PPOIN_special_hospital =	two_day_hospital * SE_PPOIN_hospital * SE_PPOIN_coinsurance;
      
   //has the deductable been met?
   if (SE_PPOIN_deduct_disp >= SE_PPOIN_deductibles[cvg]){// if yes - coinsurance is applied
   		SE_PPOIN_coin_disp = ((SE_PPOIN_deduct_disp - SE_PPOIN_deductibles[cvg]) * SE_PPOIN_coinsurance) + SE_PPOIN_special_hospital;
		SE_PPOIN_deduct_disp = SE_PPOIN_deductibles[cvg];
	}
	else if (SE_PPOIN_deduct_disp + SE_PPOIN_mamm_deduct_svcs >= SE_PPOIN_deductibles[cvg]){// if yes - coinsurance is applied
   		SE_PPOIN_coin_disp = 0 + SE_PPOIN_special_hospital;
		SE_PPOIN_deduct_disp = SE_PPOIN_deductibles[cvg];
	}	
   else {// if no - coinsurance remains the same
   		SE_PPOIN_coin_disp = SE_PPOIN_special_hospital;
		SE_PPOIN_deduct_disp += SE_PPOIN_mamm_deduct_svcs;
   }
	
	
	//is coinsurance amount greater that the out of pocket maximum? if yes display the out of pocket maximum
	//**note** no copay amounts in this particular plan apply to the out of pocket maximum
	if(SE_PPOIN_coin_disp > SE_PPOIN_oopmax[cvg]){
		SE_PPOIN_coin_disp = SE_PPOIN_oopmax[cvg];
	}
	
	SE_PPOIN_oopre_disp = SE_PPOIN_deduct_disp + SE_PPOIN_copay_disp + SE_PPOIN_coin_disp + SE_PPOIN_enc_disp;
	
	SE_PPOIN_oopost_disp = SE_PPOIN_oopre_disp + SE_PPOIN_prem_disp;
	
	form.SE_PPOIN_deduct.value = format(SE_PPOIN_deduct_disp,2);
	form.SE_PPOIN_copay.value = format(SE_PPOIN_copay_disp,2);
	form.SE_PPOIN_coin.value = format(SE_PPOIN_coin_disp,2);
	form.SE_PPOIN_enc.value = format(SE_PPOIN_enc_disp,2);
	form.SE_PPOIN_oop_pre.value = format(SE_PPOIN_oopre_disp,2);
	form.SE_PPOIN_prem.value = format(SE_PPOIN_prem_disp,2);
	form.SE_PPOIN_oop_post.value = format(SE_PPOIN_oopost_disp,2);
}

//---------------------------------------------------------------------------------------------------------

function SE_PPOOUT_Calc (form)
{	var indexnum = 4;
	//State Employee PPO out of network Calculations
	SE_PPOOUT_deduct_disp = 0;
	SE_PPOOUT_copay_disp = 0;
	SE_PPOOUT_coin_disp = 0;
	SE_PPOOUT_enc_disp = 0;
	SE_PPOOUT_oopre_disp = 0;
	SE_PPOOUT_prem_disp = enrolee_contrib_GROUP1;
	SE_PPOOUT_oopost_disp = 0;
	

	//**note** none of these amounts apply towards the OOP maximum or the deductable
	SE_PPOOUT_copay_disp =  (two_day_hospital*two_day_hospital_amt[indexnum]);
	
							
	SE_PPOOUT_deduct_disp = (doc_diag*doc_diag_amt[indexnum]) + 
			       			(doc_special*doc_special_amt[indexnum]) + 
			       			(chiropractic*chiropractic_amt[indexnum]) + 														
			       			(mat_norm*mat_norm_amt[indexnum]) + 
			       			(mat_ces*mat_ces_amt[indexnum])+
							(emerg*emerg_amt[indexnum]) +
							 other_exp;
							
	SE_PPOOUT_prevcare = (doc_phys*doc_phys_amt[indexnum]) +
							(doc_baby*doc_baby_amt[indexnum]) +
			       			(mammogram*mammogram_amt[indexnum]) + 
			       			(xray*xray_amt[indexnum]) +  
			       			(PSA_test*PSA_test_amt[indexnum]) + 
			       			(immunization*immunization_amt[indexnum]) + 							
			       			(cholesterol*cholesterol_amt[indexnum]) + 
			       			(colonoscopy*colonoscopy_amt[indexnum]);							
							
	
	//calculates the portion of a two day hospital stay to which coinsurance must be immediately applied						
   SE_PPOOUT_special_hospital =	two_day_hospital*SE_PPOOUT_hospital * SE_PPOOUT_coinsurance;
   
 
    //has the deductable been met with preventative care services only?
   if (SE_PPOOUT_prevcare >= SE_PPOOUT_deductibles[cvg]){// if yes - coinsurance is applied both non-prev and prev amounts																							
   		SE_PPOOUT_coin_disp = (SE_PPOOUT_prevcare - SE_PPOOUT_deductibles[cvg]) * SE_PPOOUT_prevcare_coinsurance;
		SE_PPOOUT_coin_disp += SE_PPOOUT_deduct_disp * SE_PPOOUT_coinsurance;
		SE_PPOOUT_coin_disp += SE_PPOOUT_special_hospital;
		SE_PPOOUT_deduct_disp = SE_PPOOUT_deductibles[cvg];
	}
	else if (SE_PPOOUT_prevcare + SE_PPOOUT_deduct_disp >= SE_PPOOUT_deductibles[cvg]){//has the deductable been met with preventative care services + non-preventative care services?
  		SE_PPOOUT_coin_disp = (SE_PPOOUT_prevcare + SE_PPOOUT_deduct_disp - SE_PPOOUT_deductibles[cvg]) * SE_PPOOUT_coinsurance;
		SE_PPOOUT_coin_disp += SE_PPOOUT_special_hospital;
		SE_PPOOUT_deduct_disp = SE_PPOOUT_deductibles[cvg];			
	}	
   else {// if no - coinsurance remains the same
   		SE_PPOOUT_deduct_disp += SE_PPOOUT_prevcare;
   		SE_PPOOUT_coin_disp = SE_PPOOUT_special_hospital;		
   }
	
	
	//is coinsurance amount greater that the out of pocket maximum? if yes display the out of pocket maximum
	//**note** no copay amounts in this particular plan apply to the out of pocket maximum
	if(SE_PPOOUT_coin_disp > SE_PPOOUT_oopmax[cvg]){
		SE_PPOOUT_coin_disp = SE_PPOOUT_oopmax[cvg];
	}
	
	
	SE_PPOOUT_enc_disp = 	(drug_ret_gen*drug_ret_gen_amt[indexnum]) + 
			    			(drug_ret_pref*drug_ret_pref_amt[indexnum]) + 
			    			(drug_ret_nonpref*drug_ret_nonpref_amt[indexnum]) +
							(drug_mo_gen*drug_mo_gen_amt[indexnum]) + 
			       			(drug_mo_pref*drug_mo_pref_amt[indexnum]) + 
			       			(drug_mo_nonpref*drug_mo_nonpref_amt[indexnum]);
	
	SE_PPOOUT_oopre_disp = SE_PPOOUT_deduct_disp + SE_PPOOUT_copay_disp + SE_PPOOUT_coin_disp + SE_PPOOUT_enc_disp;
	
	SE_PPOOUT_oopost_disp = SE_PPOOUT_oopre_disp + SE_PPOOUT_prem_disp;
	
	form.SE_PPOOUT_deduct.value = format(SE_PPOOUT_deduct_disp,2);
	form.SE_PPOOUT_copay.value = format(SE_PPOOUT_copay_disp,2);
	form.SE_PPOOUT_coin.value = format(SE_PPOOUT_coin_disp,2);
	form.SE_PPOOUT_enc.value = format(SE_PPOOUT_enc_disp,2);
	form.SE_PPOOUT_oop_pre.value = format(SE_PPOOUT_oopre_disp,2);
	form.SE_PPOOUT_prem.value = format(SE_PPOOUT_prem_disp,2);
	form.SE_PPOOUT_oop_post.value = format(SE_PPOOUT_oopost_disp,2);
}

//---------------------------------------------------------------------------------------------------------

function HI_PPOIN_Calc (form)
{	var indexnum = 5;
	
	//Health Investor HMO Calculations
	HI_PPOIN_deduct_disp = 0;
	HI_PPOIN_copay_disp = 0;
	HI_PPOIN_coin_disp = 0;
	HI_PPOIN_enc_disp = 0;
	HI_PPOIN_oopre_disp = 0;
	HI_PPOIN_prem_disp = enrolee_contrib_GROUP2;
	HI_PPOIN_oopost_disp = 0;
	
	HI_PPOIN_deduct_disp = 	(doc_diag*doc_diag_amt[indexnum]) + 
			       			(doc_special*doc_special_amt[indexnum]) + 
							(chiropractic*chiropractic_amt[indexnum]) + 														
			       			(mat_norm*mat_norm_amt[indexnum]) + 
			       			(mat_ces*mat_ces_amt[indexnum]) +							
			       			(emerg*emerg_amt[indexnum]) +
			       			(two_day_hospital*two_day_hospital_amt[indexnum]) +
							 other_exp;
							
	HI_PPOIN_mamm_deduct_svcs = (mammogram*mammogram_amt[7]);
	
	rx_gen_and_formulary = 	(drug_ret_gen*drug_ret_gen_amt[indexnum]) + 
			       			(drug_ret_pref*drug_ret_pref_amt[indexnum]) + 
			       			(drug_mo_gen*drug_mo_gen_amt[indexnum]) + 
			       			(drug_mo_pref*drug_mo_pref_amt[indexnum]);
							
	rx_non_formulary = 		(drug_ret_nonpref*drug_ret_nonpref_amt[indexnum]) + 
			       			(drug_mo_nonpref*drug_mo_nonpref_amt[indexnum]);							
							
	   //has the deductable been met with only services?
   if (HI_PPOIN_deduct_disp >= HI_PPOIN_deductibles[cvg]){
       // if yes - coinsurance is applied
   		HI_PPOIN_coin_disp = (HI_PPOIN_deduct_disp - HI_PPOIN_deductibles[cvg]) * HI_PPOIN_coinsurance;//services percentage
		HI_PPOIN_coin_disp += rx_gen_and_formulary * HI_PPOIN_rx_gen_and_f_coinsurance;//generic/formulary rx percentage
		HI_PPOIN_coin_disp += rx_non_formulary * HI_PPOIN_rx_nf_coinsurance;//non-formulary rx percentage
		HI_PPOIN_deduct_disp = HI_PPOIN_deductibles[cvg];
	}	
   else if (HI_PPOIN_deduct_disp + rx_gen_and_formulary >= HI_PPOIN_deductibles[cvg]){
        //has the deductable been met with services + generic and formulary rx?
		HI_PPOIN_coin_disp += (HI_PPOIN_deduct_disp + rx_gen_and_formulary - HI_PPOIN_deductibles[cvg]) * HI_PPOIN_rx_gen_and_f_coinsurance;//generic/formulary rx percentage
		HI_PPOIN_coin_disp += rx_non_formulary * HI_PPOIN_rx_nf_coinsurance;//non-formulary rx percentage
		HI_PPOIN_deduct_disp = HI_PPOIN_deductibles[cvg];		   
	}
   else if (HI_PPOIN_deduct_disp + rx_gen_and_formulary + rx_non_formulary >= HI_PPOIN_deductibles[cvg]){
        //has the deductable been met with services + generic and formulary + non-formulary rx?
		HI_PPOIN_coin_disp += (HI_PPOIN_deduct_disp + rx_gen_and_formulary + rx_non_formulary- HI_PPOIN_deductibles[cvg]) * 
		                     HI_PPOIN_rx_nf_coinsurance;//non-formulary rx percentage
		HI_PPOIN_deduct_disp = HI_PPOIN_deductibles[cvg];		   
	}
	else if (HI_PPOIN_deduct_disp + rx_gen_and_formulary + rx_non_formulary + HI_PPOIN_mamm_deduct_svcs >= HI_PPOIN_deductibles[cvg]){
        //has the deductable been met with services + generic and formulary + non-formulary rx?
		HI_PPOIN_coin_disp += 0;//any left over cost for mammogram after deductible has been met is zero
		HI_PPOIN_deduct_disp = HI_PPOIN_deductibles[cvg];  		   
	}	   
	else{		   
		HI_PPOIN_deduct_disp += rx_gen_and_formulary + rx_non_formulary + HI_PPOIN_mamm_deduct_svcs;
   }	
   
 	//has the out of pocket maximum been met?
	//**note**there are no copays for this plan
	//**note**the OOP max does not include the deductable
	if(HI_PPOIN_coin_disp > HI_PPOIN_oopmax[cvg]){
		HI_PPOIN_coin_disp = HI_PPOIN_oopmax[cvg];
	}
	
	HI_PPOIN_oopre_disp =  HI_PPOIN_deduct_disp + HI_PPOIN_copay_disp + HI_PPOIN_coin_disp + HI_PPOIN_enc_disp;
	
	HI_PPOIN_oopost_disp = HI_PPOIN_oopre_disp + HI_PPOIN_prem_disp;
	
	form.HI_PPOIN_deduct.value = format(HI_PPOIN_deduct_disp,2);
	form.HI_PPOIN_copay.value = format(HI_PPOIN_copay_disp,2);
	form.HI_PPOIN_coin.value = format(HI_PPOIN_coin_disp,2);
	form.HI_PPOIN_enc.value = format(HI_PPOIN_enc_disp,2);
	form.HI_PPOIN_oop_pre.value = format(HI_PPOIN_oopre_disp,2);
	form.HI_PPOIN_prem.value = format(HI_PPOIN_prem_disp,2);
	form.HI_PPOIN_oop_post.value = format(HI_PPOIN_oopost_disp,2);		
}

//---------------------------------------------------------------------------------------------------------

function HI_PPOOUT_Calc (form)
{	var indexnum = 6;
	//Health Investor PPO out of network Calculations
	HI_PPOOUT_deduct_disp = 0;
	HI_PPOOUT_copay_disp = 0;
	HI_PPOOUT_coin_disp = 0;
	HI_PPOOUT_enc_disp = 0;
	HI_PPOOUT_oopre_disp = 0;
	HI_PPOOUT_prem_disp = enrolee_contrib_GROUP2;
	HI_PPOOUT_oopost_disp = 0;
	

	//calculate copays
	HI_PPOOUT_copay_disp =  (two_day_hospital*two_day_hospital_amt[indexnum]);
	
	//calculate coinsurance						
	HI_PPOOUT_deduct_disp = (doc_diag*doc_diag_amt[indexnum]) + 
			       			(doc_special*doc_special_amt[indexnum]) + 
			       			(chiropractic*chiropractic_amt[indexnum]) + 														
			       			(mat_norm*mat_norm_amt[indexnum]) + 
			       			(mat_ces*mat_ces_amt[indexnum])+
							(emerg*emerg_amt[indexnum]) + 
							 other_exp;
							
	
	HI_PPOOUT_prevcare = (doc_phys*doc_phys_amt[indexnum]) +
							(doc_baby*doc_baby_amt[indexnum]) +
			       			(mammogram*mammogram_amt[indexnum]) + 
			       			(xray*xray_amt[indexnum]) +  
			       			(PSA_test*PSA_test_amt[indexnum]) + 
			       			(immunization*immunization_amt[indexnum]) + 							
			       			(cholesterol*cholesterol_amt[indexnum]) + 
			       			(colonoscopy*colonoscopy_amt[indexnum]);							
							
	
	//calculates the portion of a two day hospital stay to which coinsurance must be immediately applied						
   HI_PPOOUT_special_hospital =	two_day_hospital*HI_PPOOUT_hospital * HI_PPOOUT_coinsurance;
   
   //has the deductable been met with copay + non-preventative care services only?
   if (HI_PPOOUT_deduct_disp >= HI_PPOOUT_deductibles[cvg]){// if yes - coinsurance is applied both non-prev and prev amounts																							
   		HI_PPOOUT_coin_disp = (HI_PPOOUT_deduct_disp - HI_PPOOUT_deductibles[cvg]) * HI_PPOOUT_coinsurance;
		HI_PPOOUT_coin_disp += HI_PPOOUT_prevcare * HI_PPOOUT_prevcare_coinsurance;
		HI_PPOOUT_coin_disp += HI_PPOOUT_special_hospital;
		HI_PPOOUT_deduct_disp = HI_PPOOUT_deductibles[cvg];
	}
	else if (HI_PPOOUT_deduct_disp + HI_PPOOUT_prevcare >= HI_PPOOUT_deductibles[cvg]){//has the deductable been met with copay + non-preventative care services + preventative care services?
			// if yes - prev coinsurance is applied to prev amounts
  		HI_PPOOUT_coin_disp = (HI_PPOOUT_deduct_disp + HI_PPOOUT_prevcare - HI_PPOOUT_deductibles[cvg]) * HI_PPOOUT_prevcare_coinsurance;
		HI_PPOOUT_coin_disp += HI_PPOOUT_special_hospital;
		HI_PPOOUT_deduct_disp = HI_PPOOUT_deductibles[cvg];			
	}	
   else {// if no - coinsurance remains the same
		HI_PPOOUT_deduct_disp = HI_PPOOUT_deduct_disp + HI_PPOOUT_prevcare;
   		HI_PPOOUT_coin_disp = HI_PPOOUT_special_hospital;		
   }
		
	//is coinsurance amount greater that the out of pocket maximum? if yes display the out of pocket maximum
	//**note** no copay amounts in this particular plan apply to the out of pocket maximum
	if(HI_PPOOUT_coin_disp > HI_PPOOUT_oopmax[cvg]){
		HI_PPOOUT_coin_disp = HI_PPOOUT_oopmax[cvg];
	}
	
	HI_PPOOUT_enc_disp = 	(drug_mo_gen*drug_mo_gen_amt[indexnum]) + 
			       			(drug_mo_pref*drug_mo_pref_amt[indexnum]) + 
			       			(drug_mo_nonpref*drug_mo_nonpref_amt[indexnum]) +
							(drug_ret_gen*drug_ret_gen_amt[indexnum]) + 
			       			(drug_ret_pref*drug_ret_pref_amt[indexnum]) + 
			       			(drug_ret_nonpref*drug_ret_nonpref_amt[indexnum]);
	
	HI_PPOOUT_oopre_disp = HI_PPOOUT_deduct_disp + HI_PPOOUT_copay_disp + HI_PPOOUT_coin_disp + HI_PPOOUT_enc_disp;
	
	HI_PPOOUT_oopost_disp = HI_PPOOUT_oopre_disp + HI_PPOOUT_prem_disp;
	
	form.HI_PPOOUT_deduct.value = format(HI_PPOOUT_deduct_disp,2);
	form.HI_PPOOUT_copay.value = format(HI_PPOOUT_copay_disp,2);
	form.HI_PPOOUT_coin.value = format(HI_PPOOUT_coin_disp,2);
	form.HI_PPOOUT_enc.value = format(HI_PPOOUT_enc_disp,2);
	form.HI_PPOOUT_oop_pre.value = format(HI_PPOOUT_oopre_disp,2);
	form.HI_PPOOUT_prem.value = format(HI_PPOOUT_prem_disp,2);
	form.HI_PPOOUT_oop_post.value = format(HI_PPOOUT_oopost_disp,2);
}

//---------------------------------------------------------------------------------------------------------

function HSA_Table_Calc (form)
{
	if(emp_class == 8){
	//Results for Medicare Retirees or Surviving Spouse in Medicare
		form.HSA_HMO_TOTPROJ.value = format(HI_HMO_oopre_disp,2);
		form.HSA_HMO_STATE.value = format(0,2);
		form.HSA_HMO_EMP.value = format(0,2);		
		form.HSA_HMO_ROLL.value = format(0,2);
		form.HSA_HMO_SAVINGS.value = format(0,2);
		//-------		
		form.HSA_PPOIN_TOTPROJ.value = format(HI_PPOIN_oopre_disp,2);
		form.HSA_PPOIN_STATE.value = format(0,2);
		form.HSA_PPOIN_EMP.value = format(0,2);		
		form.HSA_PPOIN_ROLL.value = format(0,2);
		form.HSA_PPOIN_SAVINGS.value = format(0,2);
		//-------		
		form.HSA_PPOOUT_TOTPROJ.value = format(HI_PPOOUT_oopre_disp,2);
		form.HSA_PPOOUT_STATE.value = format(0,2);
		form.HSA_PPOOUT_EMP.value = format(0,2);				
		form.HSA_PPOOUT_ROLL.value = format(0,2);
		form.HSA_PPOOUT_SAVINGS.value = format(0,2);	
	}
	else if(emp_class == 6 || emp_class == 7){
	//Results for Early Retirees or Surviving Spouse, COBRA Participants
		state = ret_state_hsa[cvg]
		employee = ret_employee_hsa[cvg]
		
		form.HSA_HMO_TOTPROJ.value = format(HI_HMO_oopre_disp,2);
		form.HSA_HMO_STATE.value = format(state,2);
		form.HSA_HMO_EMP.value = format(employee,2);		
			if ((state + employee) - HI_HMO_oopre_disp >= 0){
				HI_HMO_ROLL = (state + employee) - HI_HMO_oopre_disp;
			}
			else{
				HI_HMO_ROLL = 0;
			}
		form.HSA_HMO_ROLL.value = format(HI_HMO_ROLL,2);
		HI_HMO_tsave = (calcFica (income) - calcFica (income-employee)) + (calcFedtax (income) - calcFedtax (income-employee));
		form.HSA_HMO_SAVINGS.value = format(HI_HMO_tsave,2);
		//-------		
		form.HSA_PPOIN_TOTPROJ.value = format(HI_PPOIN_oopre_disp,2);
		form.HSA_PPOIN_STATE.value = format(state,2);
		form.HSA_PPOIN_EMP.value = format(employee,2);
			if ((state + employee) - HI_PPOIN_oopre_disp >= 0){
				HI_PPOIN_ROLL = (state + employee) - HI_PPOIN_oopre_disp;
			}
			else{
				HI_PPOIN_ROLL = 0;
			}		
		form.HSA_PPOIN_ROLL.value = format(HI_PPOIN_ROLL,2);
		HSA_PPOIN_tsave = (calcFica (income) - calcFica (income-employee)) + (calcFedtax (income) - calcFedtax (income-employee));
		form.HSA_PPOIN_SAVINGS.value = format(HSA_PPOIN_tsave,2);
		//-------		
		form.HSA_PPOOUT_TOTPROJ.value = format(HI_PPOOUT_oopre_disp,2);
		form.HSA_PPOOUT_STATE.value = format(state,2);
		form.HSA_PPOOUT_EMP.value = format(employee,2);
			if ((state + employee) - HI_PPOOUT_oopre_disp >= 0){
				HI_PPOOUT_ROLL = (state + employee) - HI_PPOOUT_oopre_disp;
			}
			else{
				HI_PPOOUT_ROLL = 0;
			}				
		form.HSA_PPOOUT_ROLL.value = format(HI_PPOOUT_ROLL,2);
		HSA_PPOOUT_tsave = (calcFica (income) - calcFica (income-employee)) + (calcFedtax (income) - calcFedtax (income-employee));
		form.HSA_PPOOUT_SAVINGS.value = format(HSA_PPOOUT_tsave,2);	
	}
	else{
	//Results for Active Employees
		state = state_hsa[cvg]
		employee = employee_hsa[cvg]
		
		form.HSA_HMO_TOTPROJ.value = format(HI_HMO_oopre_disp,2);
		form.HSA_HMO_STATE.value = format(state,2);
		form.HSA_HMO_EMP.value = format(employee,2);		
			if ((state + employee) - HI_HMO_oopre_disp >= 0){
				HI_HMO_ROLL = (state + employee) - HI_HMO_oopre_disp;
			}
			else{
				HI_HMO_ROLL = 0;
			}
		form.HSA_HMO_ROLL.value = format(HI_HMO_ROLL,2);
		HI_HMO_tsave = (calcFica (income) - calcFica (income-employee)) + (calcFedtax (income) - calcFedtax (income-employee));
		form.HSA_HMO_SAVINGS.value = format(HI_HMO_tsave,2);
		//-------		
		form.HSA_PPOIN_TOTPROJ.value = format(HI_PPOIN_oopre_disp,2);
		form.HSA_PPOIN_STATE.value = format(state,2);
		form.HSA_PPOIN_EMP.value = format(employee,2);
			if ((state + employee) - HI_PPOIN_oopre_disp >= 0){
				HI_PPOIN_ROLL = (state + employee) - HI_PPOIN_oopre_disp;
			}
			else{
				HI_PPOIN_ROLL = 0;
			}		
		form.HSA_PPOIN_ROLL.value = format(HI_PPOIN_ROLL,2);
		HSA_PPOIN_tsave = (calcFica (income) - calcFica (income-employee)) + (calcFedtax (income) - calcFedtax (income-employee));
		form.HSA_PPOIN_SAVINGS.value = format(HSA_PPOIN_tsave,2);
		//-------		
		form.HSA_PPOOUT_TOTPROJ.value = format(HI_PPOOUT_oopre_disp,2);
		form.HSA_PPOOUT_STATE.value = format(state,2);
		form.HSA_PPOOUT_EMP.value = format(employee,2);
			if ((state + employee) - HI_PPOOUT_oopre_disp >= 0){
				HI_PPOOUT_ROLL = (state + employee) - HI_PPOOUT_oopre_disp;
			}
			else{
				HI_PPOOUT_ROLL = 0;
			}				
		form.HSA_PPOOUT_ROLL.value = format(HI_PPOOUT_ROLL,2);
		HSA_PPOOUT_tsave = (calcFica (income) - calcFica (income-employee)) + (calcFedtax (income) - calcFedtax (income-employee));
		form.HSA_PPOOUT_SAVINGS.value = format(HSA_PPOOUT_tsave,2);				
	}	
}

//supporting functions ------------------------------------------------------------------------------

function calcFica (amount)
{	if (amount > SSlimit-1)
		return (SSlimit * SSpercent) + (MedicPercent * amount);
	else return (SSpercent+MedicPercent)*amount;
}

//------------------------------------------------------------------

function calcFedtax (amount)
{	var ret;
	
	amount = amount - personal_exempt[tax] - (num_depends*exempt_amt) - deduct[tax];
	if (amount < taxlimit1[tax])
		return taxPercent[0]*amount;
	else
		ret = taxPercent[0]*taxlimit1[tax];
		
	if (amount < taxlimit2[tax])
		return ret + (taxPercent[1]*(amount-taxlimit1[tax]));
	else
		ret = ret + (taxPercent[1]*(taxlimit2[tax]-taxlimit1[tax]));

	if (amount < taxlimit3[tax])
		return ret + (taxPercent[2]*(amount - taxlimit2[tax]));
	else
		ret = ret + (taxPercent[2]*(taxlimit3[tax] - taxlimit2[tax]));
	
	if (amount < taxlimit4[tax])
		return ret + (taxPercent[3]*(amount - taxlimit3[tax]));
	else
		ret = ret + (taxPercent[3]*(taxlimit4[tax] - taxlimit3[tax]));

	if (amount < taxlimit5[tax])
		return ret + (taxPercent[4]*(amount - taxlimit4[tax]));
	else
		ret = ret + (taxPercent[4]*(taxlimit5[tax] - taxlimit4[tax]));
		
	return ret + (taxPercent[5]*(amount - taxlimit5[tax]));
}

//------------------------------------------------------------------

function parseInput (field)
{	if (field.length==0)
		return 0;
	else return eval(field);
}

//------------------------------------------------------------------

function format(original_number, decimals) 
{	var result1 = original_number * Math.pow(10, decimals);
    var result2 = Math.round(result1);
    var result3 = result2 / Math.pow(10, decimals);
    return "$"+CommaFormatted(pad_with_zeros(result3, decimals));
}

//------------------------------------------------------------------

function pad_with_zeros(rounded_value, decimal_places) {

    // Convert the number to a string
    var value_string = rounded_value.toString()
    
    // Locate the decimal point
    var decimal_location = value_string.indexOf(".")

    // Is there a decimal point?
    if (decimal_location == -1) {
        
        // If no, then all decimal places will be padded with 0s
        decimal_part_length = 0
        
        // If decimal_places is greater than zero, tack on a decimal point
        value_string += decimal_places > 0 ? "." : ""
    }
    else {

        // If yes, then only the extra decimal places will be padded with 0s
        decimal_part_length = value_string.length - decimal_location - 1
    }
    
    // Calculate the number of decimal places that need to be padded with 0s
    var pad_total = decimal_places - decimal_part_length
    
    if (pad_total > 0) {
        
        // Pad the string with 0s
        for (var counter = 1; counter <= pad_total; counter++) 
            value_string += "0"
        }
    return value_string
}

//------------------------------------------------------------------

function CommaFormatted(amount)
{
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	if(d.length < 1) { amount = n; }
	else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}

//------------------------------------------------------------------

function formValidate(form)
{		
	if (form.coverage_lvl[1].selected){	
		cvg=0;
}	
	else if (form.coverage_lvl[2].selected){	
		cvg=1;
}				
	else{	
		alert ("Please select a level of coverage.");
		form.coverage_lvl.focus();
		return 0;
	}
	
	if(form.employee_class[0].checked){
		emp_class = 0;
	}
	else if (form.employee_class[1].checked){	
		emp_class = 1;
}
	else if (form.employee_class[2].checked){	
		emp_class = 2;
}		
	else if (form.employee_class[3].checked){	
		emp_class = 3;
}		
	else if (form.employee_class[4].checked){	
		emp_class = 4;
}		
	else if (form.employee_class[5].checked){	
		emp_class = 5;
}		
	else if (form.employee_class[6].checked){	
		emp_class = 6;
}
	else if (form.employee_class[7].checked){	
		emp_class = 7;
}
	else if (form.employee_class[8].checked){	
		emp_class = 8;
			if(form.eligibility[0].checked){
				medicare_type = 0;
			}
			else if (form.eligibility[1].checked){	
				medicare_type = 1;
			}
			else if (form.eligibility[2].checked){	
				medicare_type = 2;
			}	
			else {
				alert ("Please select a Medicare Retiree Eligibility Type.");
				form.coverage_lvl.focus();
				return 0;
			}								
	}
	else {
		alert ("Please select an Employment Classification.");
		form.coverage_lvl.focus();
		return 0;
	}		

	if (form.tax_stat[1].selected){
		tax=0;
}		
	else if (form.tax_stat[2].selected){
		tax=1;
}		
	else if (form.tax_stat[3].selected){
		tax=2;
}		
	else if (form.tax_stat[4].selected){
		tax=3;
}					
	else{	
		alert ("Please select a tax filing status.");
		form.tax_stat.focus();
		return 0;
	}

	if (form.num_depends.value == "")
	{	form.num_depends.value = "0";
	}
		
	if (form.income.value == "")
	{	alert ("Please enter your total annual income.");
		form.income.focus();
		return 0;
	}

	return 1;
	
}                           
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
