
function taxAndDiscount( obj, iItems, fRate, fDiscountedBasket, bIncludeInTotal, bDisplayAsAbsolute, bIncludeDelivery ){

  if( obj.value != '' )
    var aCourier = obj.value.split( "|" );
  else
    var aCourier = Array( '0.00', '0.00' );

  var fDeliveryCost = Math.abs( aCourier[1] );

  gEBI( "summaryCost" ).innerHTML = fix( fDiscountedBasket + fDeliveryCost );
  if(gEBI("taxCost")){
    if(bIncludeInTotal){
      if(bIncludeDelivery){
        var fTax = ( fDiscountedBasket + fDeliveryCost ) * fRate / 100;
      }else{
        var fTax = fDiscountedBasket * fRate / 100;
      }
    }else{
      var fTmult = 100/( 100 + fRate );
      if(bIncludeDelivery){
        var fTax = ( fDiscountedBasket + fDeliveryCost ) - ( fTmult * ( fDiscountedBasket + fDeliveryCost ));
      }else{
        var fTax = fDiscountedBasket - ( fTmult * fDiscountedBasket );
      }
    }     
    gEBI( "taxCost" ).innerHTML = fix( fTax );
    if(bIncludeInTotal){
      gEBI( "summaryCost" ).innerHTML = fix( fDiscountedBasket + fDeliveryCost + parseFloat(gEBI( "taxCost" ).innerHTML) );
    }
    if(bDisplayAsAbsolute && fTax < 0){
      gEBI( "taxCost" ).innerHTML = gEBI( "taxCost" ).innerHTML.substring(1);
    }
    document.form['fTax'].value = gEBI( "taxCost" ).innerHTML;
  }

  gEBI( "deliveryCost" ).innerHTML = fix( fDeliveryCost );
  document.form['fDelivery'].value = gEBI( "deliveryCost" ).innerHTML;
  document.form['fSummary'].value = gEBI( "summaryCost" ).innerHTML;
} // end function taxAndDiscount

