



/* Argument base:    string, indicates the type of
                     base system.
   Argument indexed: 1 or 0, indicates whether or not
                     to index.
   Result: a taxsystem structure, representing
   a base (pre-Budget) tax system of the appropriate kind.
*/
function makeBaseSystem( base, indexed )
{
	//alert( 'base=|'+base+'| indexed=|'+indexed+'| ' );
        if( "BASE1" == base ){ // include preannounced gains/losses
		if( indexed == 1 ){ // ignore indexation
                        //alert( 'makeIndexedDayBefore' );
			return makeIndexedDayBefore();
		} else {  // allow indexation
                        //alert( 'makeNonIndexedDayBefore' );
			return makeNonIndexedDayBefore();
		}
	} else {  // ignore preannounced gains/losses
		if( indexed == 1 ){
                        //alert( 'makeNonIndexedPreAnnounced' );
			return makeIndexedPreAnnounced();
		} else {
                        //alert( 'makeNonIndexedPreAnnounced' );
			return makeNonIndexedPreAnnounced();
		}
	}
}


/* Result: a taxsystem structure, representing
           the post-Budget tax system.

   !!! Same as base pro tem.
*/
function makeNewSystem( )
{
  sys = {
        personalAllowance:4615.0/52.0, 
        ageAllowance1:6610.0/52.0, 
        ageAllowance2:6720.0/52.0, 
        MCA1:5465.0 * 0.1 /52.0, 
        MCA2:5535.0 * 0.1 /52.0, 
        ageAllowanceTaper:0.50, 
        ageAllowanceThreshold:18300.0/52.0, 
        savingsRate:0.20, 
        itRates: new Array( 0.10, 0.22, 0.40 ),
        itBands: new Array( 1960/52.0, 30500/52.0, 99999999999 ),
        niInRates: new Array( 0.0, 0.11, 0.01 ),
        niOutRates: new Array( 0.0, 0.094, 0.01 ),
        niBands: new Array( 89.0, 595.0, 999999999999 ),
        niClass4: new Array( 0.0, 0.08, 0.01 ),
        niClass2:2.0,
        niLel: 77,
        beer:0.01,  /** just the extra per pint, bottle etc **/
        wine:0.04, 
        spirits:0.0, 
        petrol:0.0128, 
        fags:0.08
        
  }
  return sys;
}


/* Result: a taxsystem structure, representing
           a pre-Budget system indexed.

  Statutory indexation is 1.7%. for it, 2.4 for indir
*/
function makeIndexedDayBefore()
{
   var sys = {
	personalAllowance:4695.0/52.0, 
        ageAllowance1:6210.0/52.0, 
        ageAllowance2:6480.0/52.0, 
        MCA1:5565.0 * 0.1 /52.0, 
        MCA2:5635.0 * 0.1 /52.0, 
        ageAllowanceTaper:0.50, 
        ageAllowanceThreshold:18300.0/52.0, 
        savingsRate:0.20, 
        itRates: new Array( 0.10, 0.22, 0.40 ),
        itBands: new Array( 1960/52.0, 30500/52.0, 99999999999 ),
        niInRates: new Array( 0.0, 0.10, 0.00 ),
        niOutRates: new Array( 0.0, 0.084, 0.00 ),
        niBands: new Array( 90.50, 595.0, 999999999999 ),
        niClass4: new Array( 0.0, 0.07, 0.0 ),
        niClass2:2.0,
        niLel: 78,
        beer:0.01,  /** just the extra per pint, bottle etc **/
        wine:0.04, 
        spirits:0.16, 
        petrol:0.0128, 
        fags:0.08   
   }
   return sys;
}
 

/* Result: a taxsystem structure, representing
           a pre-Budget system non-indexed.
*/
function makeNonIndexedDayBefore(){
  var sys = {
	personalAllowance:4615.0/52.0, 
        ageAllowance1:6100.0/52.0, 
        ageAllowance2:6370.0/52.0, 
        MCA1:5465.0 * 0.1 /52.0, 
        MCA2:5535.0 * 0.1 /52.0, 
        ageAllowanceTaper:0.50, 
        ageAllowanceThreshold:17900.0/52.0, 
        savingsRate:0.20, 
        itRates: new Array( 0.10, 0.22, 0.40 ),
        itBands: new Array( 1920/52.0, 29900/52.0, 99999999999 ),
        niInRates: new Array( 0.0, 0.10, 0.00 ),
        niOutRates: new Array( 0.0, 0.084, 0.00 ),
        niBands: new Array( 89.0, 585.0, 999999999999 ),
        niClass4: new Array( 0.0, 0.07, 0.0 ),
        niClass2:2.0 , 
        niLel: 77,
        beer:0.0,  /** just the extra per pint, bottle etc **/
        wine:0.0, 
        spirits:0.0, 
        petrol:0.0, 
        fags:0.0
	}
  return sys;
}
 

/* Result: a taxsystem structure, representing
           a pre-Budget system indexed
           that incorporates the pre-announced
           changes.
*/
function makeIndexedPreAnnounced( )
{
  var sys = {
	personalAllowance:4615.0/52.0, 
        ageAllowance1:6610.0/52.0, 
        ageAllowance2:6720.0/52.0, 
        MCA1:5565.0 * 0.1 /52.0, 
        MCA2:5635.0 * 0.1 /52.0, 
        ageAllowanceTaper:0.50, 
        ageAllowanceThreshold:18300.0/52.0, 
        savingsRate:0.20, 
        itRates: new Array( 0.10, 0.22, 0.40 ),
        itBands: new Array( 1960.0/52.0, 30500.0/52.0, 9999999999.99 ),
	niInRates: new Array( 0.0, 0.11, 0.01 ),
        niOutRates: new Array( 0.0, 0.094, 0.01 ),
        niBands: new Array( 89, 595.0, 999999999999 ),
        niClass4: new Array( 0.0, 0.08, 0.01 ),
        niClass2:2.0 , 
        niLel: 77,
        beer:0.01,  /** just the extra per pint, bottle etc **/
        wine:0.04, 
        spirits:0.16, 
        petrol:0.0128, 
        fags:0.08
  }
  return sys;
}


/* Result: a taxsystem structure, representing
           a pre-Budget system non-indexed
           that incorporates the pre-announced
           changes.
*/
function makeNonIndexedPreAnnounced( )
{
  var sys = {
        personalAllowance:4615.0/52.0, 
        ageAllowance1:6610.0/52.0, 
        ageAllowance2:6720.0/52.0, 
        MCA1:5465.0 * 0.1 /52.0, 
        MCA2:5535.0 * 0.1 /52.0, 
        ageAllowanceTaper:0.50, 
        ageAllowanceThreshold:18300.0/52.0, 
        savingsRate:0.20, 
        itRates: new Array( 0.10, 0.22, 0.40 ),
        itBands: new Array( 1920/52.0, 29900/52.0, 99999999999 ),
        niInRates: new Array( 0.0, 0.11, 0.01 ),
        niOutRates: new Array( 0.0, 0.094, 0.01 ),
        niBands: new Array( 89.0, 595.0, 999999999999 ),
        niClass4: new Array( 0.0, 0.07, 0.0 ),
        niClass2:2.0 , 
        beer:0.0,  /** just the extra per pint, bottle etc **/
        wine:0.0, 
        spirits:0.0, 
        petrol:0.0, 
        fags:0.0
  }
  return sys;
}





