// JavaScript Document


function calculate() {
	  var bChildCreditQualify = false;
      var formName = document.tre
	  
	  // Calculate your age.
	  var stDate = formName.dob.value;
	  var birth_day = parseInt(stDate.substring(0,2),10);
	  var birth_month = parseInt(stDate.substring(3,5),10);
	  var birth_year = parseInt(stDate.substring(6,10),10);
			
	  today_date = new Date();
	  today_year = today_date.getYear();
	  today_month = today_date.getMonth();
	  today_day = today_date.getDate();
	  age = (today_year + 1900) - birth_year;
	  if ( today_month < (birth_month - 1)) {
		age--;
	  }
	  if (((birth_month - 1) == today_month) && (today_day < birth_day)) { 
		age--;
	  }
	  if (age > 1900) {
		age -= 1900;
	  }
	  var age;
	  
	 // Calculate your spouse's age.
	  var stDateSpouse = formName.spouse_dob.value;
	  var birth_day_spouse = parseInt(stDateSpouse.substring(0,2),10);
	  var birth_month_spouse = parseInt(stDateSpouse.substring(3,5),10);
	  var birth_year_spouse = parseInt(stDateSpouse.substring(6,10),10);
			
	  today_date_spouse = new Date();
	  today_year_spouse = today_date_spouse.getYear();
	  today_month_spouse = today_date_spouse.getMonth();
	  today_day_spouse = today_date_spouse.getDate();
	  age_spouse = (today_year_spouse + 1900) - birth_year_spouse;
	  if ( today_month_spouse < (birth_month_spouse - 1)) {
		age_spouse--;
	  }
	  if (((birth_month_spouse - 1) == today_month_spouse) && (today_day_spouse < birth_day_spouse)) { 
		age_spouse--;
	  }
	  if (age_spouse > 1900) {
		age_spouse -= 1900;
	  }
	  var age_spouse;
	  
	  // Calculate exemption amount
	  switch(formName.status.value)
		{
		case "single":
			var exemptionAmount = 3700;
		  break;
		case "married":
			  var exemptionAmount = parseInt(3700 * 2);
		  break;
		case "hoh":
			var exemptionAmount = 3700;
		break;
		}

/* RETURNS EXEMPTION TOTAL FOR YOU AND YOUR SPOUSE *************************************************/	
var exemptions = ((parseInt(formName.ExemptionsUnderSeventeen.value) * (3700)) + (parseInt(formName.ExemptionsOverSixteen.value) * (3700))) + exemptionAmount;
/***************************************************************************************************/  
	  
/* START INCOME CALCULATIONS FOR YOU AND YOUR SPOUSE ***********************************************/

	  // Your income
	  var selfEmploymentEarnings = 0;
	  var selfEmploymentEarningsNetProfit = 0;
	  
	  var selfEmployedMiles = parseInt(formName.SelfEmployedMiles.value * .50);
	  var selfEmploymentEarnings = parseInt(formName.SelfEmployed.value - selfEmployedMiles);
	  
	  if (selfEmploymentEarnings <= 0 ) {
		  var selfEmploymentEarnings = 0;
	  }
	  
	  var selfEmploymentEarningsNetProfit = parseInt(selfEmploymentEarnings * .9235 * .153);
	  
	  // Calculate rental income
  	  if (parseInt(formName.RentalPropertyNet.value) < -25000) {
	  	var rentalProperty = -25000;
	  } else {
		var rentalProperty = parseInt(formName.RentalPropertyNet.value);
	  }
	  
	  
	  /* Calculate rental income
	  /* Need to figure out how to factor it based on agi prior to the agi calculation. Paradox.
  	  if (parseInt(formName.RentalPropertyNet.value) < -25000 && agi <= 100000) {
	  	var rentalProperty = -25000;
	  } else if (parseInt(formName.RentalPropertyNet.value) < -25000 && (agi > 100000 && agi <= 150000)) {
	  	var rentalProperty = parseInt(-25000 + ((agi - 100000) * .5));
	  } else {
		var rentalProperty = parseInt(formName.RentalPropertyNet.value);
	  }
	  */
	  
	  
	  var yourIncome = (parseInt(formName.Wage.value) + parseInt(formName.Interest.value) + parseInt(formName.StateRefund.value) + (parseInt(formName.Dividend.value)/* * .15 */) + parseInt(formName.AlimonyReceived.value) + selfEmploymentEarnings + parseInt(formName.UnemploymentIncome.value) + parseInt(formName.GamblingWinnings.value));
	  
	  // Check for spouse's income
	  var spouseSelfEmploymentEarnings = 0;
	  var spouseSelfEmploymentEarningsNetProfit = 0;
	   
	  var spouseSelfEmployedMiles = parseInt(formName.SpouseSelfEmployedMiles.value * .50);
	  var spouseSelfEmploymentEarnings = parseInt(formName.SpouseSelfEmployed.value - spouseSelfEmployedMiles);
	  
	  if (spouseSelfEmploymentEarnings <= 0 ) {
		  var spouseSelfEmploymentEarnings = 0;
	  }
	  
	  var spouseSelfEmploymentEarningsNetProfit = parseInt(spouseSelfEmploymentEarnings * .9235 * .153);
	  
	  var spouseIncome = (parseInt(formName.SpouseWage.value) + spouseSelfEmploymentEarnings + parseInt(formName.SpouseUnemploymentIncome.value) + parseInt(formName.SpouseInterest.value) + parseInt(formName.SpouseDividend.value));
		  
					  
	  // Calculates if long term capital gains has a penalty.
	  switch(formName.status.value)
		{
		case "single":
		  if (parseInt(formName.LongTermCapitalGains.value) > 0 && ((yourIncome + spouseIncome) > 34500)) {
			  var longTermCapitalGainsTax = parseInt(formName.LongTermCapitalGains.value) * .15;
			  var longTermCapitalGains = parseInt(formName.LongTermCapitalGains.value);
		  } else {
			  var longTermCapitalGainsTax = 0;
			  var longTermCapitalGains = 0;
		  }
		  break;
		case "married":
		  if (parseInt(formName.LongTermCapitalGains.value) > 0 && ((yourIncome + spouseIncome) > 69000)) {
			  var longTermCapitalGainsTax = parseInt(formName.LongTermCapitalGains.value) * .15;
			  var longTermCapitalGains = parseInt(formName.LongTermCapitalGains.value);
		  } else {
			  var longTermCapitalGainsTax = 0;
			  var longTermCapitalGains = 0;
		  }
		  break;	
		case "hoh":	 
		  if (parseInt(formName.LongTermCapitalGains.value) > 0 && ((yourIncome + spouseIncome) > 46250)) {
			  var longTermCapitalGainsTax = parseInt(formName.LongTermCapitalGains.value) * .15;
			  var longTermCapitalGains = parseInt(formName.LongTermCapitalGains.value);
		  } else {
			  var longTermCapitalGainsTax = 0;
			  var longTermCapitalGains = 0;
		  }
		  break;
	    } 
		  	 
	  // Calculates combined short and long term capital gains and checks for a capital loss.
	  var capitalLoss = parseInt(formName.ShortTermCapitalGains.value) + parseInt(formName.LongTermCapitalGains.value);
	  
	  // Limits the loss of combined short and long term capital gains to -3000
	  if (capitalLoss <= (-3000)) {
		  var capitalLoss = (-3000);
		  var shortTermCapitalGains = 0;
		  var longTermCapitalGains = 0;
	  } else {
		  var capitalLoss = 0;
		  var shortTermCapitalGains = parseInt(formName.ShortTermCapitalGains.value);
	  }
	  
	  // Calculates the early IRA withdrawal penalty.
	  var retirementDistributions = 0;
	  var retirementDistributionsPenalty = 0;
	  		
		switch(formName.Box7Form1099R.value)
		{
		case "0":
			var retirementDistributions = parseInt(formName.RetirementDistributions.value);
		  break;
		case "1":
			 switch(formName.status.value)
				{
				case "single":
				  if (age <= 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = parseInt(formName.RetirementDistributions.value * .1);
				  } else if (age > 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = 0;
				  }
				  break;
				case "married": 
				  if (age <= 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = parseInt(formName.RetirementDistributions.value * .1);
				  } else if (age > 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = 0;
				  } 
				  break;
				case "hoh":
				  if (age <= 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					   var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					   var retirementDistributionsPenalty = parseInt(formName.RetirementDistributions.value * .1);
				  } else if (age > 60 && parseInt(formName.RetirementDistributions.value) > 0){
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = 0;
				  }
				  break;
				}
		  break;
		case "2":
			var retirementDistributions = parseInt(formName.RetirementDistributions.value);
		  break;
		case "3":
			var retirementDistributions = parseInt(formName.RetirementDistributions.value);
		break;
		case "4":
			var retirementDistributions = parseInt(formName.RetirementDistributions.value);
		break;
		case "7":
			var retirementDistributions = parseInt(formName.RetirementDistributions.value);
		break;
		case "8":
			var retirementDistributions = parseInt(formName.RetirementDistributions.value);
		break;
		case "G":
			var retirementDistributions = 0;
		break;
		case "J":
			var retirementDistributions = parseInt(formName.RetirementDistributions.value);
		break;
		case "L":
			 switch(formName.status.value)
				{
				case "single":
				  if (age <= 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = parseInt(formName.RetirementDistributions.value * .1);
				  } else if (age > 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = 0;
				  }
				  break;
				case "married": 
				  if (age <= 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = parseInt(formName.RetirementDistributions.value * .1);
				  } else if (age > 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = 0;
				  }
				  break;
				case "hoh":
				  if (age <= 60 && parseInt(formName.RetirementDistributions.value) > 0) {
					   var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					   var retirementDistributionsPenalty = parseInt(formName.RetirementDistributions.value * .1);
				  } else if (age > 60 && parseInt(formName.RetirementDistributions.value) > 0){
					  var retirementDistributions = parseInt(formName.RetirementDistributions.value);
					  var retirementDistributionsPenalty = 0;
				  }
				  break;
				}
		  break;
		case "Q":
			var retirementDistributions = parseInt(formName.RetirementDistributions.value);
		break;
		case "T":
			var retirementDistributions = parseInt(formName.RetirementDistributions.value);
		break;
		}
		
		
		
		// Calculates the early Spouse IRA withdrawal penalty.	
		
			
		// Calculates the early IRA withdrawal penalty.	
		switch(formName.status.value)
				{
				case "single":
					var spouseRetirementDistributions = 0;
					var spouseRetirementDistributionsPenalty = 0;
				break;
				case "married":
					// var spouseRetirementDistributions = 0;
					// var spouseRetirementDistributionsPenalty = 0;
				
					switch(formName.SpouseBox7Form1099R.value)
							{
							case "0":
								var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
								var spouseRetirementDistributionsPenalty = 0;
							  break;
							case "1":
								 if (age_spouse <= 60 && parseInt(formName.SpouseRetirementDistributions.value) > 0) {
									  var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
									  var spouseRetirementDistributionsPenalty = parseInt(formName.SpouseRetirementDistributions.value * .1);
								  } else if (age_spouse > 60 && parseInt(formName.SpouseRetirementDistributions.value) > 0) {
									  var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
									  var spouseRetirementDistributionsPenalty = 0;
								  } 
							  break;
							case "2":
								var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
								var spouseRetirementDistributionsPenalty = 0;
							  break;
							case "3":
								var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
								var spouseRetirementDistributionsPenalty = 0;
							break;
							case "4":
								var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
								var spouseRetirementDistributionsPenalty = 0;
							break;
							case "7":
								var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
								var spouseRetirementDistributionsPenalty = 0;
							break;
							case "8":
								var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
								var spouseRetirementDistributionsPenalty = 0;
							break;
							case "G":
								var spouseRetirementDistributions = 0;
								var spouseRetirementDistributionsPenalty = 0;
							break;
							case "J":
								var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
								var spouseRetirementDistributionsPenalty = 0;
							break;
							case "L":
								 if (age_spouse <= 60 && parseInt(formName.SpouseRetirementDistributions.value) > 0) {
										  var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
										  var spouseRetirementDistributionsPenalty = parseInt(formName.SpouseRetirementDistributions.value * .1);
									  } else if (age_spouse > 60 && parseInt(formName.SpouseRetirementDistributions.value) > 0) {
										  var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
										  var spouseRetirementDistributionsPenalty = 0;
									  } 
							  break;
							case "Q":
								var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
								var spouseRetirementDistributionsPenalty = 0;
							break;
							case "T":
								var spouseRetirementDistributions = parseInt(formName.SpouseRetirementDistributions.value);
								var spouseRetirementDistributionsPenalty = 0;
							break;
							}				
					break;
				case "hoh":
					var spouseRetirementDistributions = 0;
					var spouseRetirementDistributionsPenalty = 0;
				break;
				}
		
	  
	  // Calculates the purchase cost of the rental property.
	  var rentalPropertyPurchase = parseInt(parseInt(formName.RentalProperty.value) * .8 * .0364);
	  
	  // Captures business income - MANY NOT BE NEEDED (Double-check)
	  // var businessIncome = parseInt(formName.BusinessIncome.value); This is not being used.
	  var businessIncome = 0;
	  			  
/* RETURNS TOTAL INCOME FOR YOU AND YOUR SPOUSE *****************************************************/
var income = parseInt(yourIncome + spouseIncome + capitalLoss + shortTermCapitalGains + retirementDistributions + spouseRetirementDistributions + rentalProperty - rentalPropertyPurchase + businessIncome);
/****************************************************************************************************/  
	  
	  
/* START INCOME ADJUSTMENT CALCULATIONS FOR YOU AND YOUR SPOUSE *************************************/	  

	  // Moving Expenses
	  var movingExpenses = parseInt(formName.MovingExpenses.value);
	  	
	  // Force IRA contribution to be at the limit or less depending on how much the user enters.
	  if (formName.TraditionalIRAW2.checked == false) {  
		  if (age < 50 && yourIncome <= 56000) {
			  if (parseInt(formName.TraditionalIRA.value) <= 5000) {
				var contribution = parseInt(formName.TraditionalIRA.value); 
			  } else {
				var contribution = 5000;
			  }
		  } else if (age > 50 && yourIncome <= 56000) {
			  if (parseInt(formName.TraditionalIRA.value) <= 6000) {
				var contribution = parseInt(formName.TraditionalIRA.value); 
			  } else {
				var contribution = 6000;
			  }
		  } else {
			  var contribution = 0;
		  }
	  } else if (formName.TraditionalIRAW2.checked == true) {  
			  var contribution = 0;
	  } 
	  
	  // Force spouse's IRA contribution to be at the limit or less depending on how much the user enters.
	  if (formName.SpouseTraditionalIRAW2.checked == false) {
	  // Force IRA contribution to be at the limit or less depending on how much the user enters.
		  if (age_spouse < 50 && spouseIncome <= 56000) {
			  if (parseInt(formName.SpouseTraditionalIRA.value) <= 5000) {
				var spouseContribution = parseInt(formName.SpouseTraditionalIRA.value); 
			  } else {
				var spouseContribution = 5000;
			  }
		  } else if (age_spouse > 50 && spouseIncome <= 56000) {
			  if (parseInt(formName.SpouseTraditionalIRA.value) <= 6000) {
				var spouseContribution = parseInt(formName.SpouseTraditionalIRA.value); 
			  } else {
				var spouseContribution = 6000;
			  }
		  } else {
			  var spouseContribution = 0;
		  }
	  } else if (formName.SpouseTraditionalIRAW2.checked == true) {  
			  var spouseContribution = 0;
	  } 
		  
		
	  // Captures alimony paid.
	  var alimonyPaid = parseInt(formName.AlimonyPaid.value);
	  
	  // Calculate the One Half Self-Employment Tax.
	  if (income >= 106800) {
			  var oneHalfSelfEmploymentTax = 0;
		  } else {
			  var oneHalfSelfEmploymentTax = parseInt(((selfEmploymentEarnings * .9235) * .153) * .5);
		  }
	  
	  // Checks and Calculate the One Half Self-Employment Tax for your spouse.
	  switch(formName.status.value)
		{
		case "single":
		  	var spouseOneHalfSelfEmploymentTax = 0;
		  break;
		case "married": 
		  if (spouseIncome >= 106800) {
			  var spouseOneHalfSelfEmploymentTax = 0;
		  } else {
			  var spouseOneHalfSelfEmploymentTax = parseInt(((spouseSelfEmploymentEarnings * .9235) * .153) * .5);
		  } 
		  break;
		case "hoh":
			var spouseOneHalfSelfEmploymentTax = 0;
		  break;
		}	
		
		var tuition = 0;
	  
	  // Calculates the amount of deduction for tuition and fees.
	  if (formName.CollegeAttend.checked == false && formName.CollegeAttendFirstFourYears.checked == false) {
	  switch(formName.status.value)
		{
		case "single":
		  if (income < 65000) {
			  if (parseInt(formName.Tuition.value) < 4000) {
			  	var tuition = parseInt(formName.Tuition.value);
			  } else {
			  	var tuition = 4000;
			  }
		  } else if (income >= 65000 && income <= 80000) {
			  if (parseInt(formName.Tuition.value) <= 2000) {
			  	var tuition = parseInt(formName.Tuition.value); 
			  } else {
			  	var tuition = 2000;
			  }
		  } else if (income > 80000) {
			  	var tuition = 0;
		  }
		  break;
		case "married":
			if (income < 130000) {
			  if (parseInt(formName.Tuition.value) <= 4000) {
			  	var tuition = parseInt(formName.Tuition.value);
			  } else {
			  	var tuition = 4000;
			  }
		  } else if (income >= 130000 && income <= 160000) {
			  if (parseInt(formName.Tuition.value) <= 2000) {
			  	var tuition = parseInt(formName.Tuition.value); 
			  } else {
			  	var tuition = 2000;
			  }
		  } else if (income > 160000) {
			  	var tuition = 0;
		  }
		  break;
		case "hoh":
		  if (income < 65000) {
			  if (parseInt(formName.Tuition.value) <= 4000) {
			  	var tuition = parseInt(formName.Tuition.value);
			  } else {
			  	var tuition = 4000;
			  }
		  } else if (income >= 65000 && income <= 80000) {
			  if (parseInt(formName.Tuition.value) <= 2000) {
			  	var tuition = parseInt(formName.Tuition.value); 
			  } else {
			  	var tuition = 2000;
			  }
		  } else if (income > 80000) {
			  	var tuition = 0;
		  }
		  break;
		}
	  }	
		  
/* RETURNS TOTAL INCOME ADJUSTMENTS FOR YOU AND YOUR SPOUSE *****************************************/
var adjustments = parseInt(movingExpenses + contribution + spouseContribution + alimonyPaid + oneHalfSelfEmploymentTax + spouseOneHalfSelfEmploymentTax + tuition);
/****************************************************************************************************/
	  
	
	  //var otherCredit = parseInt(formName.OtherCredits.value);
	  
	  
/* SET AGI FOR YOU AND YOUR SPOUSE ******************************************************************/
var agi = parseInt(income - adjustments);
/****************************************************************************************************/  

	  // Calculates social security liability.
	  var combinedIncome = agi + parseInt(formName.SocialSecurityIncome.value * .5);
	  switch(formName.status.value)
		{
		case "single":
		  if (agi >= 25000 && agi <= 34500) {
		  	  var socialSecurity = (parseInt(formName.SocialSecurityIncome.value) * .5);
			  var spouseSocialSecurity = 0;
	  	  } else if (agi > 34500) {
		  	  var socialSecurity = (parseInt(formName.SocialSecurityIncome.value) * .85);
			  var spouseSocialSecurity = 0;
	  	  } else {
			  var socialSecurity = 0;
			  var spouseSocialSecurity = 0;
		  }
		  break;
		case "married":
		  if (agi >= 32000 && agi <= 44000) {
		  	  var socialSecurity = (parseInt(formName.SocialSecurityIncome.value) * .5);
			  var spouseSocialSecurity = (parseInt(formName.SpouseSocialSecurityIncome.value) * .5);
	  	  } else if (agi > 44000) {
		  	  var socialSecurity = (parseInt(formName.SocialSecurityIncome.value) * .85);
			  var spouseSocialSecurity = (parseInt(formName.SpouseSocialSecurityIncome.value) * .85);
			  /*
			  var threshold = 32000;
			  var additionalThreshold = parseInt(12000 * .5);
			  var differenceInThreshold = threshold - additionalThreshold;
			  
			  var agiMinusThreshold = agi - 32000; // 16000
			  var num1 = parseInt((agiMinusThreshold - differenceInThreshold) * .85);  // 3400
			  
			  var socialSecurity = parseInt(num1 + additionalThreshold);
			  
			  */
			  
			 
			  
	  	  } else {
			  var socialSecurity = 0;
			  var spouseSocialSecurity = 0;
		  }
		  break;
		case "hoh":
		  if (agi >= 25000 && agi <= 34500) {
		  	  var socialSecurity = (parseInt(formName.SocialSecurityIncome.value) * .5);
			  var spouseSocialSecurity = 0;
	  	  } else if (agi > 34500) {
		  	  var socialSecurity = (parseInt(formName.SocialSecurityIncome.value) * .85);
			  var spouseSocialSecurity = 0;
	  	  } else {
			  var socialSecurity = 0;
			  var spouseSocialSecurity = 0;
		  }
		  break;
		}
	  
	  
/* START ITEMIZED DEDUCTIONS ************************************************************************/  
	  
	  // Add or removed the standard deduction and show/hide the itemized deduction pane.
	  switch(formName.status.value)
		{
		case "single":
		  if (age < 65) {
			  var single = 5800;
		  } else {
			  var single = 7100;
		  }
		  break;
		case "married": 
		  if (age < 65 && age_spouse < 65) {
			  var married = 11600;
		  } else if (age >= 65 && age_spouse >= 65) {
			  var married = 13600;
		  } else if (age >= 65 || age_spouse >= 65) {
			  var married = 12500;
		  }
		  break;
		case "hoh":
		  if (age < 65) {
			  var hoh = 8500;
		  } else {
			  var hoh = 9800;
		  }
		  break;
		}
				
		
	  // Calculates the itemized or standard deductions	  
	  if (formName.StandardDeduction.checked == false) {
		  var deductions = 0;
		  
		  // State Tax Withholdings
		  var stateTaxWithholdings = parseInt(formName.StateTaxWithholdings.value);
		  
		  // Estimated State Tax Withholdings
		  var estimatedStateTax = parseInt(formName.EstimatedStateTax.value);
		  
		  // Medical expensese
		  if (formName.MedicalExpenses.value != 0 && agi <= 50000) {
			  	var medicalExpenses = parseInt((formName.MedicalExpenses.value) - (agi * .075));
		  } else {
			  var medicalExpenses = 0;
		  }
		  
		  // Real Estate Taxes
		  var realEstateTaxes = parseInt(formName.RealEstateTaxes.value);
		  
		  // Vehicel Registration
		  var vehicleRegistration = parseInt(formName.VehicleRegistration.value);
		  
		  // Mortgage Interest
		  var mortgageInterest = parseInt(formName.MortgageInterest.value);
		  
		  // Mortgage insurance premiums
		  var mortgageInsurance = parseInt(formName.MortgageInsurance.value);
		  
		  // Donations
		  var donations = parseInt(formName.Donations.value);
		  
		  // Business miles drive for employer
		  if (formName.BusinessMilesDrivenForEmployer.value != 0) {
			  var businessMilesDrivenForEmployer = parseInt((formName.BusinessMilesDrivenForEmployer.value * .50) - (agi * .02));	  
		  } else {
			  var businessMilesDrivenForEmployer = 0;
		  }
		  
		  // Unreimbursed employee expenses
		  if (formName.UnreimbursedEmployeeExpenses.value != 0) {
			  var unreimbursedEmployeeExpenses = parseInt((formName.UnreimbursedEmployeeExpenses.value) - (agi * .02));
		  } else {
			  var unreimbursedEmployeeExpenses = 0;
		  }
		  
		  // Gambling Losses
		  if (parseInt(formName.GamblingWinnings.value) > parseInt(formName.GamblingLosses.value)) {
			  var gamblingLosses = parseInt(formName.GamblingLosses.value);
		  } else {
			  var gamblingLosses = parseInt(formName.GamblingWinnings.value);
		  }
		  
		  var deductions = (stateTaxWithholdings + estimatedStateTax + medicalExpenses + realEstateTaxes + vehicleRegistration + mortgageInterest + mortgageInsurance + donations + unreimbursedEmployeeExpenses + gamblingLosses + businessMilesDrivenForEmployer);
		  
	  } else { 	
		switch(formName.status.value)
		{
		case "single":
		  	var deductions = single;
		  break;
		case "married":
		  	var deductions = married;
		  break;
		case "hoh":
		  	var deductions = hoh;
		  break;
		}
	  }
	  	  	  
/* SET DEDUCTIONS FOR YOU AND YOUR SPOUSE ***********************************************************/
var deductions = parseInt(deductions);
/****************************************************************************************************/  

		  
/* START REFUNDABLE CREDITS *************************************************************************/	  

	  
	  var americanOpportunityCredit = 0;
	  var educationCredit = 0;
	  var nonQualifyingCredit = 0;
	  
	  if (formName.CollegeAttendFirstFourYears.checked == true && formName.CollegeAttend.checked == true) {
		switch(formName.status.value)
		{
		case "single":
			if (agi <= 90000) {
				if (parseInt(formName.College.value) <= 2000) {
					var americanOpportunityCreditTotal = parseInt(formName.College.value);
					var americanOpportunityCredit = parseInt(formName.College.value * .40);
					var educationCredit = parseInt(americanOpportunityCreditTotal - americanOpportunityCredit);
				} else if (parseInt(formName.College.value) > 2000 && parseInt(formName.College.value) <= 4000) {
					var americanOpportunityCreditTotal = parseInt(formName.College.value);
					var americanOpportunityCredit = parseInt((((formName.College.value - 2000) * .25) + 2000)  * .40);
					var educationCredit = parseInt(americanOpportunityCreditTotal - americanOpportunityCredit);
				} else if (parseInt(formName.College.value) > 4000) {
					var americanOpportunityCreditTotal = parseInt(formName.College.value);
					var americanOpportunityCredit = parseInt(2500 * .40);
					var educationCredit = parseInt(2500 - americanOpportunityCredit);
				} 
			} 
		  break;
		case "married":
		  	if (agi <= 180000) {
				if (parseInt(formName.College.value) <= 2000) {
					var americanOpportunityCreditTotal = parseInt(formName.College.value);
					var americanOpportunityCredit = parseInt(formName.College.value * .40);
					var educationCredit = parseInt(americanOpportunityCreditTotal - americanOpportunityCredit);
				} else if (parseInt(formName.College.value) > 2000 && parseInt(formName.College.value) <= 4000) {
					var americanOpportunityCreditTotal = parseInt(formName.College.value);
					var americanOpportunityCredit = parseInt((((formName.College.value - 2000) * .25) + 2000)  * .40);
					var educationCredit = parseInt(americanOpportunityCreditTotal - americanOpportunityCredit);
				} else if (parseInt(formName.College.value) > 4000) {
					var americanOpportunityCreditTotal = parseInt(formName.College.value);
					var americanOpportunityCredit = parseInt(2500 * .40);
					var educationCredit = parseInt(2500 - americanOpportunityCredit);
				}  
			} 
		  break;
		case "hoh":
		  	if (agi <= 90000) {
				if (parseInt(formName.College.value) <= 2000) {
					var americanOpportunityCreditTotal = parseInt(formName.College.value);
					var americanOpportunityCredit = parseInt(formName.College.value * .40);
					var educationCredit = parseInt(americanOpportunityCreditTotal - americanOpportunityCredit);
				} else if (parseInt(formName.College.value) > 2000 && parseInt(formName.College.value) <= 4000) {
					var americanOpportunityCreditTotal = parseInt(formName.College.value);
					var americanOpportunityCredit = parseInt((((formName.College.value - 2000) * .25) + 2000)  * .40);
					var educationCredit = parseInt(americanOpportunityCreditTotal - americanOpportunityCredit);
				} else if (parseInt(formName.College.value) > 4000) {
					var americanOpportunityCreditTotal = parseInt(formName.College.value);
					var americanOpportunityCredit = parseInt(2500 * .40);
					var educationCredit = parseInt(2500 - americanOpportunityCredit);
				}
			} 
		  break;
		}
		var americanOpportunityCredit = (parseInt(formName.CollegeAttendFirstFourYearsDependents.value) * americanOpportunityCredit);
	  } 
	  
	  // Earned Income Credit
	  // var investmentIncome = (parseInt(formName.Interest.value) + parseInt(formName.Dividend.value) + parseInt(formName.SpouseInterest.value) + parseInt(formName.SpouseDividend.value) + rentalProperty + shortTermCapitalGains + longTermCapitalGains);
	  
	  
	 switch(formName.EarnedIncomeCredit.value)
			{
			case "0":
				if (agi <= 10000 && ((age < 65 && age >= 25) || (age_spouse < 65 && age_spouse >= 25))) {
					var earnedIncomeCredit = 400;
				} else {
					var earnedIncomeCredit = 0;
				}
			  break;
			case "1":
				if (agi <= 10000 && ((age < 65 && age >= 25) || (age_spouse < 65 && age_spouse >= 25))) {
					var earnedIncomeCredit = 3000;
				} else if (agi > 10000 && agi <= 15000) {
					var earnedIncomeCredit = 3000;
				} else if (agi > 15000 && agi <= 20000) {
					var earnedIncomeCredit = 2500;
				} else if (agi > 20000 && agi <= 25000) {
					var earnedIncomeCredit = 2000;
				} else if (agi > 25000 && agi <= 30000) {
					var earnedIncomeCredit = 1000;
				} else {
					var earnedIncomeCredit = 0;
				}
			  break;
			case "2":
				if (agi <= 10000 && ((age < 65 && age >= 25) || (age_spouse < 65 && age_spouse >= 25))) {
					var earnedIncomeCredit = 4000;
				} else if (agi > 10000 && agi <= 15000) {
					var earnedIncomeCredit = 5000;
				} else if (agi > 15000 && agi <= 20000) {
					var earnedIncomeCredit = 4000;
				} else if (agi > 20000 && agi <= 25000) {
					var earnedIncomeCredit = 3000;
				} else if (agi > 25000 && agi <= 30000) {
					var earnedIncomeCredit = 2000;
				} else if (agi > 30000 && agi <= 35000) {
					var earnedIncomeCredit = 1500;
				} else if (agi > 35000 && agi <= 40000) {
					var earnedIncomeCredit = 1000;
				} else {
					var earnedIncomeCredit = 0;
				}
			  break;
			case "3":
				if (agi <= 10000 && ((age < 65 && age >= 25) || (age_spouse < 65 && age_spouse >= 25))) {
					var earnedIncomeCredit = 5000;
				} else if (agi > 10000 && agi <= 15000) {
					var earnedIncomeCredit = 5000;
				} else if (agi > 15000 && agi <= 20000) {
					var earnedIncomeCredit = 5000;
				} else if (agi > 20000 && agi <= 25000) {
					var earnedIncomeCredit = 4000;
				} else if (agi > 25000 && agi <= 30000) {
					var earnedIncomeCredit = 2000;
				} else if (agi > 30000 && agi <= 35000) {
					var earnedIncomeCredit = 1000;
				} else {
					var earnedIncomeCredit = 0;
				}
			  break;
			}
		
	  // Calculate the First-Time Home Buyer Credit
	  if (formName.BuyHome.checked == true && agi <= 125000) { 
	  	var firstTimeHomeBuyerCredit = parseInt(parseInt(formName.HomePurchasePrice.value) * .10);
	  
			if (formName.HomeThreeYearsPrevious.checked == false && formName.HomeFiveYearsPrevious.checked == false) {
				if (firstTimeHomeBuyerCredit <= 8000) {
					var firstTimeHomeBuyerCredit = parseInt(parseInt(formName.HomePurchasePrice.value) * .10);
				} else {
					var firstTimeHomeBuyerCredit = 8000;
				}
			} 
			
			if (formName.HomeThreeYearsPrevious.checked == true && formName.HomeFiveYearsPrevious.checked == false) {
					var firstTimeHomeBuyerCredit = 0;
			} 
			
			if (formName.HomeThreeYearsPrevious.checked == false && formName.HomeFiveYearsPrevious.checked == true) {
				if (firstTimeHomeBuyerCredit <= 8000) {
					var firstTimeHomeBuyerCredit = parseInt(parseInt(formName.HomePurchasePrice.value) * .10);
				} else {
					var firstTimeHomeBuyerCredit = 8000;
				}
			} 
			
			if (formName.HomeThreeYearsPrevious.checked == true && formName.HomeFiveYearsPrevious.checked == true) {
				if (firstTimeHomeBuyerCredit <= 6500) {
					var firstTimeHomeBuyerCredit = parseInt(parseInt(formName.HomePurchasePrice.value) * .10);
				} else {
					var firstTimeHomeBuyerCredit = 6500;
				}
			} 
	  }
	  if (formName.BuyHome.checked == false || agi > 125000) {
		var firstTimeHomeBuyerCredit = 0;
	  }
	  
	  
	  // Calculate Make Work Pay credit
	  var makeWorkPay = 0;
	  
	  switch(formName.status.value)
		{
		case "single":
			if (parseInt(formName.Wage.value) > 0) {
				if (agi <= 6451) {
					var makeWorkPay = agi * .062;
				} else if (agi <= 75000) {
					var makeWorkPay = 400;
				} else if ((agi > 75000 && agi <= 95000)) {
					var makeWorkPay = parseInt(400 - ((agi - 75000) * .02))
				} else {
					var makeWorkPay = 0;
				}
				if (agi < selfEmploymentEarnings && selfEmploymentEarnings >= 0) {
					if (selfEmploymentEarnings <= 6451) {
						var makeWorkPay = agi * .062;
					} else if (selfEmploymentEarnings <= 75000) {
						var makeWorkPay = 400;
					} else if ((selfEmploymentEarnings > 75000 && selfEmploymentEarnings <= 95000)) {
						var makeWorkPay = parseInt(400 - ((selfEmploymentEarnings - 75000) * .02))
					} else {
						var makeWorkPay = 0;
					}
				}
			}
		  break;
		case "married":
		  	if (parseInt(formName.Wage.value + formName.SpouseWage.value) > 0) {
				if (agi <= 12903) {
					var makeWorkPay = agi * .062;
				} else if (agi <= 150000) {
					var makeWorkPay = 800;
				} else if ((agi > 150000 && agi <= 190000)) {
					var makeWorkPay = parseInt(800 - ((agi - 150000) * .02));
				} else if ((selfEmploymentEarnings > 150000 && selfEmploymentEarnings <= 190000)) {
					var makeWorkPay = parseInt(800 - ((agi - 150000) * .02));
				} else {
					var makeWorkPay = 0;
				}
			} 
		  break;
		case "hoh":
		  	if (parseInt(formName.Wage.value) > 0) {
				if (agi <= 6451) {
					var makeWorkPay = agi * .062;
				} else if (agi <= 75000) {
					var makeWorkPay = 400;
				} else if ((agi > 75000 && agi <= 95000)) {
					var makeWorkPay = parseInt(400 - ((agi - 75000) * .02));
				} else if ((selfEmploymentEarnings > 75000 && selfEmploymentEarnings <= 95000)) {
					var makeWorkPay = parseInt(400 - ((selfEmploymentEarnings - 75000) * .02))
				} else {
					var makeWorkPay = 0;
				} 
			} 
		  break;
		}
		
		var makeWorkPay = 0; // This is set to zero to eleminate Make Work Pay from the calculation.

	  
/* SET REFUNDABLE CREDITS ***************************************************************************/
var refundableCredits = parseInt(americanOpportunityCredit + earnedIncomeCredit + firstTimeHomeBuyerCredit + makeWorkPay);
/****************************************************************************************************/


/* START NONREFUNDABLE CREDITS **********************************************************************/	  
	  
	  
	  // Child and dependent care expenses
	  var childCareExpenses = 0;
	  
	  switch(formName.ChildCareUnderThirteen.value)
		{
		case "0":
		  	var childCareExpenses = 0;
		  break;
		case "1":
			if (parseInt(formName.ChildCareExpenses.value) <= 3000) {
		  		var childCareExpenses = (parseInt(formName.ChildCareExpenses.value) * .20);
			} else {
				var childCareExpenses = 600;
			}
		  break;
		case "2":
		  	if (parseInt(formName.ChildCareExpenses.value) <= 6000) {
		  		var childCareExpenses = (parseInt(formName.ChildCareExpenses.value) * .20);
			} else {
				var childCareExpenses = 1200;
			}
		  break;
		default:
			var childCareExpenses = 0;
		}
				
	  // Child tax credit
	  switch(formName.status.value)
		{
		case "single":
			switch(formName.ExemptionsUnderSeventeen.value)
			{
			case "0":
				var childTaxCredit = 0;
			  break;
			case "1":
				if (agi <= 94000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "2":
				if (agi <= 114000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "3":
				if (agi <= 134000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "4":
				if (agi <= 154000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "5":
				if (agi <= 174000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			default:
				var childTaxCredit = 0;
			}
		  break;
		case "married":
			switch(formName.ExemptionsUnderSeventeen.value)
			{
			case "0":
				var childTaxCredit = 0;
			  break;
			case "1":
				if (agi <= 129000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "2":
				if (agi <= 149000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "3":
				if (agi <= 169000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "4":
				if (agi <= 189000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "5":
				if (agi <= 209000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			default:
				var childTaxCredit = 0;
			}
		  break;
		case "hoh":
			switch(formName.ExemptionsUnderSeventeen.value)
			{
			case "0":
				var childTaxCredit = 0;
			  break;
			case "1":
				if (agi <= 94000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "2":
				if (agi <= 114000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "3":
				if (agi <= 134000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "4":
				if (agi <= 154000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			case "5":
				if (agi <= 174000) {
					var childTaxCredit = (parseInt(formName.ExemptionsUnderSeventeen.value) * 1000);
				} else {
					var childTaxCredit = 0;
				}
			  break;
			default:
				var childTaxCredit = 0;
			}
		  break;
		}	
		
		
		// Calculate lifetime learning credit	
		var lifetimeLearningCredit = 0;
		
		if (formName.CollegeAttend.checked == true && formName.CollegeAttendFirstFourYears.checked == false) { 
			switch(formName.status.value)
			{
			case "single":
				if (agi <= 60000) {
					if (parseInt(formName.College.value) <= 10000) {
						var lifetimeLearningCredit = (parseInt(formName.College.value) * .20);
					} else {
						var lifetimeLearningCredit = 2000;
					}
				} 
			  break;
			case "married":
				if (agi <= 120000) {
					if (parseInt(formName.College.value) <= 10000) {
						var lifetimeLearningCredit = (parseInt(formName.College.value) * .20);
					} else {
						var lifetimeLearningCredit = 2000;
					}
				} 
			  break;
			case "hoh":
				if (agi <= 60000) {
					if (parseInt(formName.College.value) <= 10000) {
						var lifetimeLearningCredit = (parseInt(formName.College.value) * .20);
					} else {
						var lifetimeLearningCredit = 2000;
					}
				} 
			  break;
			}
		  }
		
/* SET NON REFUNDABLE CREDITS ***********************************************************************/
var nonRefundableCredits = parseInt(childCareExpenses + childTaxCredit + lifetimeLearningCredit + educationCredit);
/****************************************************************************************************/


/* SET TAXABLE INCOME CREDITS ***********************************************************************/
var taxableIncome = parseInt(agi - deductions - exemptions + socialSecurity + spouseSocialSecurity);

if (taxableIncome <= 0) {
	var taxableIncome = 0;
} 
/****************************************************************************************************/
		
	  
	  // Calculates the tax liability on taxable income
        switch(formName.status.value)
		{
		case "single":
            if (taxableIncome <= 8500) {
               var estimatedTax = (taxableIncome * .1);
            }
            else if (taxableIncome <= 34500) {
               var estimatedTax = ((taxableIncome * .15) - 425);
            }
            else if (taxableIncome <= 83600) {
               var estimatedTax = ((taxableIncome * .25) - 3875);
            }
            else if (taxableIncome <= 174400) {
               var estimatedTax = ((taxableIncome * .28) - 6383);
			}
            else if (taxableIncome <= 379150) {
               var estimatedTax = ((taxableIncome * .33) - 15103);
            }
            else {
               var estimatedTax = ((taxableIncome * .35) - 222686);
            }
          break;
		case "married":
            if (taxableIncome <= 17000) {
               var estimatedTax = (taxableIncome * .1);
            }
            else if (taxableIncome <= 69000) {
               var estimatedTax = (((taxableIncome) * .15) - 850);
            }
            else if (taxableIncome <= 139350) {
               var estimatedTax = (((taxableIncome) * .25) - 7750);
            }
            else if (taxableIncome <= 212300) {
               var estimatedTax = (((taxableIncome) * .28) - 11930.50);
			}
            else if (taxableIncome <= 379150) {
               var estimatedTax = (((taxableIncome) * .33) - 22545.50);
            }
            else {
               var estimatedTax = (((taxableIncome) * .35) - 30128.50);
            }
		  break;
		case "hoh":
            if (taxableIncome <= 12150) {
               var estimatedTax = (taxableIncome * .1);
            }
            else if (taxableIncome <= 46250) {
               var estimatedTax = (((taxableIncome) * .15) - 607.5);
            }
            else if (taxableIncome <= 119400) {
               var estimatedTax = (((taxableIncome) * .25) - 5232.50);
            }
            else if (taxableIncome <= 193350) {
               var estimatedTax = (((taxableIncome) * .28) - 8814.50);
			}
            else if (taxableIncome <= 379150) {
               var estimatedTax = (((taxableIncome) * .33) - 18482);
            }
            else {
               var estimatedTax = (((taxableIncome) * .35) - 26065);
            }
          break;
		}
		
	  // Calculates the estimated refund or liability	  
      var totTax = parseInt(estimatedTax - refundableCredits - nonRefundableCredits + longTermCapitalGainsTax);
      var taxWithheld = parseInt(formName.FederalTaxWithholdings.value);
      var estTaxPaid = parseInt(formName.EstimatedFederalTaxPayments.value);
      var totPaid = parseInt(estTaxPaid + taxWithheld);
      var total = parseInt(totPaid - totTax - selfEmploymentEarningsNetProfit - spouseSelfEmploymentEarningsNetProfit - retirementDistributionsPenalty - spouseRetirementDistributionsPenalty);
	  
	  
	  var finalIncome = "Income: $" + parseInt(income + socialSecurity + spouseSocialSecurity + longTermCapitalGains);
	  var finalIAdjustments = "Adjustments: $" + parseInt(adjustments);
	  var finalIAGI = "AGI: $" + parseInt(agi + socialSecurity + spouseSocialSecurity);
	  var finalDeductions = "Deductions: $" + parseInt(deductions);
	  var finalExemptions = "Exemptions: $" + parseInt(exemptions);
	  var finalNonrefundableCredits = "Nonrefundable Credits: $" + parseInt(nonRefundableCredits);
	  var finalSubtotal = "Taxable Income: $" + parseInt(taxableIncome);
	  var finalRefundableCredits = "Refundable Credits: $" + parseInt(refundableCredits);
	  var finalPayments = "Payments: $" + parseInt(taxWithheld + estTaxPaid);
	  var finalTax = Math.abs(total); 
	  
	  
	  if (total < 0) {
		  return finalResults = finalIncome + "<br />" + finalIAdjustments + "<br />" + finalIAGI + "<br />" + finalDeductions + "<br />" + finalExemptions + "<br /><hr size=\"1\" width=\"200\" noshade />" + finalSubtotal + "<br /><hr size=\"1\" width=\"200\" noshade />" + finalNonrefundableCredits + "<br />" + finalRefundableCredits + "<br />" + finalPayments + "<br />" + "<span class=\"tax-owed\">Tax Owed: $" + finalTax + "</span>"; 
	  } else if (total > 0) {
		  if (parseInt(income - adjustments - deductions - exemptions - nonRefundableCredits + socialSecurity + spouseSocialSecurity) <= 0) {
			  var finalTax = parseInt(totPaid + makeWorkPay);
		  }
		  return finalResults = finalIncome + "<br />" + finalIAdjustments + "<br />" + finalIAGI + "<br />" + finalDeductions + "<br />" + finalExemptions + "<br /><hr size=\"1\" width=\"200\" noshade />" + finalSubtotal + "<br /><hr size=\"1\" width=\"200\" noshade />" + finalNonrefundableCredits + "<br />" + finalRefundableCredits + "<br />" + finalPayments + "<br />" + "<span class=\"tax-refund\">Tax Refund: $" + finalTax + "</span>"; 
	  } else  {
		  return finalResults = "Please Enter Your Tax Information."; 
	  }
	  
   }
   function format(expr,decplaces) {
      var str = "" + Math.round(eval(expr) * Math.pow(10,decplaces))
      while (str.length <= decplaces) {
         str = "0" + str
      }
      var decpoint = str.length - decplaces
      return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
   }
   function dollarize(expr) {
     return "$" + format(expr,2)
   }
   function customDateString(oneDate) {
      var theYear = oneDate.getYear() + 2000
      return theYear
   }


