/*********************************************************
   2000 Individual Income Tax Calculation
   usage:  federalTax = calcSingle( taxableincome );
   usage:  federalTax = calcMarried( taxableincome );
	 usage:  federalTax = calcFederalTax( taxableIncome, married );
	 Copyright 2000 Mark E. Gunnison
  *********************************************************/

function calcFederalTax( taxableIncome, married )
{
var fedTax = 0;


 			if (married == 1)
			 	fedTax = calcMarried( taxableIncome );
			else
				fedTax = calcSingle( taxableIncome );

			return (fedTax);
}	
	
	
function calcSingle( taxableIncomeR )
{
   var fedTax = 0;

     taxableIncomeR = roundIncome(taxableIncomeR);

     if (taxableIncomeR<26250)
          fedTax = taxableIncomeR*.15;

     if (taxableIncomeR>=26250 && taxableIncomeR<63550)
          fedTax = ((taxableIncomeR-26250)*.28)+3862.5;

     if (taxableIncomeR>=63550 && taxableIncomeR<132600)
          fedTax = ((taxableIncomeR-63550)*.31)+14138.5;

     if (taxableIncomeR>=132600 && taxableIncomeR<288350)
          fedTax = ((taxableIncomeR-132600)*.36)+35156.5;

     if (taxableIncomeR>=288350)
          fedTax = ((taxableIncomeR-288350)*.396)+90200.5;

     if (fedTax < 0)
          fedTax = 0;

     fedTax = Math.round(fedTax);
		 
		 return( fedTax );
}

function calcMarried( taxableIncomeR )
{

  var fedTax = 0;

     taxableIncomeR = roundIncome(taxableIncomeR);

     if (taxableIncomeR<43850)
          fedTax = taxableIncomeR*.15;

     if (taxableIncomeR>=43850 && taxableIncomeR<105950)
          fedTax = ((taxableIncomeR-43850)*.28)+6457.5;

     if (taxableIncomeR>=105950 && taxableIncomeR<161450)
          fedTax = ((taxableIncomeR-105950)*.31)+23537.5;

     if (taxableIncomeR>=161450 && taxableIncomeR<288350)
          fedTax = ((taxableIncomeR-161450)*.36)+40432.5;

     if (taxableIncomeR>=288350)
          fedTax = ((taxableIncomeR-288350)*.396)+85288.5;

     if (fedTax < 0)
          fedTax = 0;

     fedTax = Math.round(fedTax);
		 
		 
 		 return( fedTax );
}

/***************** Round to amount used by the IRS in their table ************************/
function roundIncome(taxableIncomeR)
{
var taxableIncome = 0;
taxableIncome = taxableIncomeR;


        if (taxableIncome<3000 && taxableIncome>0)       //use IRS rounding for table
	{

                taxableIncomeR = Math.floor(taxableIncome/100);  // round to 100
                taxableIncomeR = taxableIncomeR*100;

                if (taxableIncome - taxableIncomeR < 25)
                        taxableIncomeR += 13;
                if (taxableIncome - taxableIncomeR >= 25 && taxableIncome - taxableIncomeR < 50)
                        taxableIncomeR += 38;
                if (taxableIncome - taxableIncomeR >= 50 && taxableIncome - taxableIncomeR < 75)
                        taxableIncomeR += 63;
                if (taxableIncome - taxableIncomeR >= 75 && taxableIncome - taxableIncomeR < 100)
                        taxableIncomeR += 88;

	}


        if (taxableIncome<100000 && taxableIncome>=3000)       //use IRS rounding for table
	{

                taxableIncomeR = Math.floor(taxableIncome/100);  // round to 100
                taxableIncomeR = taxableIncomeR*100;

                if (taxableIncome - taxableIncomeR < 50)
			taxableIncomeR += 25;
		else	
			taxableIncomeR += 75;
	}

	return( taxableIncomeR );
	
}
