function fnRound(val, dig)
{
 var mul = 1;
 for(var i = 1; i <= dig; i++) mul = mul * 10;
 var res = Math.round(val*mul)/mul;
 return res;
}

function ReplaceCommaFloat(val)
{
  var re = /,/gi;
  if(val == '') val='0';
  var newval = val.replace(re, '.');
  var sep = newval.indexOf('.');
  if (sep < 0) return newval;
  else {
    var endsign = parseInt(sep) + 3;
    var resval = newval.slice(0, endsign);
    return resval;
  }
}

function ReplaceCommaInt(val)
{
  var re = /,/gi;
  if(val == '') val='0';
  var newval = val.replace(re, '.');
  var sep = newval.indexOf('.');
  if (sep < 0) return newval;
  else {
    var endsign = parseInt(sep);
    var resval = newval.slice(0, endsign);
    return resval;
  }
}

function CalcInsDebt(LAll, RAll)
{
  var d = parseFloat(RAll)-parseFloat(LAll);
  if (d < 0) return -d;
  else return 0;
}

function CalcFssDebt(LAll, RAll)
{
  var d = parseFloat(RAll)-parseFloat(LAll);
  if (d < 0) return 0;
  else return d;
}

//  ­ «®£ PHP-è­®© number_format, ¤®«¦­ë ¡ëâì ¯à®¨­¨æ¨ «¨§¨à®¢ ­ë ¢á¥ ¯ à ¬¥âàë
// ¢®§¢à é ¥â áâà®ªã
function number_format(number, decimals, dec_point, thousands_sep)
{
  var res = '';
  var tmp_num = String(fnRound(number, decimals));
  var a = tmp_num.split('.');
  var int_part = String(a[0]);
  var flt_part = '00';
  if(tmp_num.indexOf('.') != -1)
    flt_part = String(a[1]);
  var j = 0;
  for(var i = int_part.length-1; i >= 0; i--) {
    if( j == 3 ) {
      res = thousands_sep + res;
      j = 0;
    }
    res = int_part.charAt(i) + res;
    j++;
  }
  res = res + dec_point;
  res = res + flt_part;
  return res;
}

function CalcTax(S1, S2)
{
  var d = 0.01*2.9*(parseFloat(S1)-parseFloat(S2));
  if (d < 0) d = 0;
  var dc = window.top.document;
  dc.getElementById('esn_hint').innerHTML = number_format(d, 2, ',', ' ');
}

function CalcTax_2010()
{
  var dc = window.top.document;

  var base = parseFloat(dc.part1.S1.value) - parseFloat(dc.part1.S2.value) - 
    parseFloat(dc.part1.S3.value) - parseFloat(dc.part1.S4.value);
  
  var d = 0;

  switch (parseInt(dc.part1.TaxTypeP1.value))
  {
    case 41:
      d = fnRound(0.019 * base, 2);
      break;
    case 61:
    case 71:
      d = fnRound(0.029 * base, 2);
      break;
  }
  
  if (d < 0) d = 0;
    
  dc.getElementById('ch_hint').innerHTML = number_format(d, 2, ',', ' ');
}

function CalcTax_2011()
{
  var dc = window.top.document;

  var base = parseFloat(dc.part1.S1.value) - parseFloat(dc.part1.S2.value) - parseFloat(dc.part1.S4.value);
  
  var lS3 = parseFloat(dc.part1.S3.value); 

  var d = 0;

  switch (parseInt(dc.part1.TaxTypeP1.value))
  {
    case 32:
    case 41:
    case 61:
      d = fnRound(0.019 * base, 2);
      break;
    case 51:
    case 91:
    case 101:
      d = fnRound(0.02 * (base - lS3), 2);
      d = d + fnRound(0.019 * lS3, 2);
      break;
    case 71:
    case 111:
      d = fnRound(0.029 * (base - lS3), 2);
      d = d + fnRound(0.019 * lS3, 2);
      break;
    case 81:
      d = fnRound(0 * base, 2);
      break;
   }
  
  if (d < 0) d = 0;
    
  dc.getElementById('ch_hint').innerHTML = number_format(d, 2, ',', ' ');
}

function init()
{
  if (_SPAN != null && window.ActiveXObject) return 0;

  var dc = window.top.document;

  _SPAN  = null;
  _SCRPT = null;

  _SPAN = dc.createElement('SPAN');
  _SPAN.style.display = 'none';

  _SCRPT = dc.createElement('script');
  _SCRPT.language = 'JavaScript';

  dc.body.appendChild(_SPAN);
  _SPAN.appendChild(_SCRPT);

  return 0;
}

function run(service,callback)
{
  _DYN = true;
  _SPAN  = null;
  _SCRPT = null;
        
  init();

  var dt = new Date();
  var tm = dt.getTime();

  if (service == '' || callback == '') return -1;

  var url = service+'.php?tm='+tm+'&'+'callback='+callback+'&'+'pcnt='+(arguments.length-2);

  for(i = 2; i < arguments.length; i++) {
    url+='&p'+(i-2)+'='+arguments[i];
  }

  _SCRPT.src=url;
}

function dyn_callbackNS(s)
{
  var dc = window.top.document;
  var a = s.split(':');
  if( a[0] != '0' ) {
    dc.getElementById('clcT7R5C1').innerHTML = a[2];
    dc.getElementById('clcT7R6C1').innerHTML = a[3];
    dc.getElementById('clcT7R7C1').innerHTML = a[4];
  }
  else
    dc.getElementById('PaySumT7').innerHTML = a[1];
}

function getDataForNS(year,inc_date_d,inc_date_m,inc_date_y,rate_mis,rate_dec,rate_inc,year,quart,t1r3c2,c1,c2,c3,t1r5c2,i1,i2,i3,user,wRo)
{
  run('f4_dyn_calcns','dyn_callbackNS',year,inc_date_d,inc_date_m,inc_date_y,rate_mis,rate_dec,rate_inc,year,quart,t1r3c2,c1,c2,c3,t1r5c2,i1,i2,i3,user,wRo);
}

function dyn_callbackDelDebtP1(s)
{
  var dc = window.top.document;
  dc.getElementById('DebtDelayed').innerHTML = s;
}

function getDataForDelDebtP1(year,quart,s2r1,ch1,ch2,n1,n2,s2r2,nre1,nre2,s2f1,s2f2,s2n1,s2n2,s2r19,re1,re2,pay1,pay2,pay3,pay4,insdebt,pinsdebt,pfssdebt)
{
  run('f4_dyn_deldebt_p1','dyn_callbackDelDebtP1',year,quart,s2r1,ch1,ch2,n1,n2,s2r2,nre1,nre2,s2f1,s2f2,s2n1,s2n2,s2r19,re1,re2,pay1,pay2,pay3,pay4,insdebt,pinsdebt,pfssdebt);
}

function dyn_callbackDelDebtP3(s)
{
  var dc = window.top.document;
  dc.getElementById('DebtDelayed').innerHTML = s;
}

function getDataForDelDebtP3(year,quart,t7r1c1,t7r5c1,t7r6c1,t7r19c1,t7r23c1,t7r24c1,t7r29c1,t7r30c1,t7r31c1,pt7r34c1,pt7r18c1)
{
  run('f4_dyn_deldebt_p3','dyn_callbackDelDebtP3',year,quart,t7r1c1,t7r5c1,t7r6c1,t7r19c1,t7r23c1,t7r24c1,t7r29c1,t7r30c1,t7r31c1,pt7r34c1,pt7r18c1);
}

function dyn_callback(s)
{
  var a = s.split(':');
  var class_dest = 'ID_RISC_' + a[0];
  var rate_dest = 'RATE_MIS_' + a[0];
  var dc = window.top.document;
  dc.getElementById(class_dest).value=a[1];
  dc.getElementById(rate_dest).value=a[2];
  if( (a[1]==0) && (a[2]==0) )
    alert('Äëÿ ââåäåííîãî ÎÊÂÝÄà íå íàéäåí êëàññ ðèñêà è ñòðàõîâîé òàðèô!');
}

function getData(src,okv)
{
  run('okvtorisc','dyn_callback',src,okv);
}

function chkOkved(okv_cnt)
{
  for(var i = 0; i < okv_cnt; i++) {
    var okv_fld = 'OKVED_' + i;
    var dc = window.top.document;
    if( dc.getElementById(okv_fld).value == '' ) 
      return false;
  }
  return true;
}

function checkf4rep(sname, sid, y, q, chk_user, wRo )
{
  if (document.all) {
    topoffset=document.body.scrollTop;
    leftoffset=document.body.scrollLeft;
  } 
  else {
    topoffset=pageYOffset;
    leftoffset=pageXOffset;
  }

  newtop=((getClientHeight()-400)/2)+topoffset;
  newleft=getClientWidth()-600;

  move_div('helpdiv', newtop, newleft)
  doc = window.top.document;
  //show_dhtml_popup('help', 'service4106.php?nl=1&YEAR_NUM='+y+'&QUART_NUM='+q+'&'+sname+'='+sid+'&chk_user='+chk_user+'&wRo='+wRo+'&js_show=1');
  help1.Show('/service4106.php?nl=1&YEAR_NUM='+y+'&QUART_NUM='+q+'&'+sname+'='+sid+'&chk_user='+chk_user+'&wRo='+wRo+'&js_show=1');

}

function checkf4free(sname, sid, y)
{
  if (document.all) {
    topoffset=document.body.scrollTop;
    leftoffset=document.body.scrollLeft;
  } 
  else {
    topoffset=pageYOffset;
    leftoffset=pageXOffset;
  }

  newtop=((getClientHeight()-400)/2)+topoffset;
  newleft=getClientWidth()-600;

  move_div('helpdiv', newtop, newleft)
  doc = window.top.document;
  help1.Show('/service5106.php?nl=1&YEAR_NUM='+y+'&'+sname+'='+sid+'&js_show=1');
}

function CalcReCharge()
{
  var dc = window.top.document;
  var ReCharge = "0,00", FssD = 0, FssR = 0, d = 0;
  
  if(parseFloat(dc.part1.FssDebt.value) > 0) 
  {
    FssD = parseFloat(dc.part1.pqFssDebt.value) - parseFloat(dc.part1.pqInsDebt.value);
    if(FssD > 0)
      FssR = FssD - parseFloat(dc.part1.pqS2R18.value);
    else
      FssR = 0;

    FssD = FssD + (parseFloat(dc.part1.Re1.value) + parseFloat(dc.part1.S2R29.value)) -
        (parseFloat(dc.part1.Ch1.value) + parseFloat(dc.part1.NRe1.value) + parseFloat(dc.part1.N1.value) + parseFloat(dc.part1.S2F1.value));

    if(FssD > 0)
    {
      FssR = FssR - parseFloat(dc.part1.S2F1.value);
      d = parseFloat(dc.part1.Re1.value) - (parseFloat(dc.part1.Ch1.value) + parseFloat(dc.part1.NRe1.value) + parseFloat(dc.part1.N1.value));

      if(d > 0)
        FssR = FssR + d;

      FssR = Math.min(FssR, FssD);
    }  
    else
      FssR = 0;

    FssD = FssD + (parseFloat(dc.part1.Re2.value) + parseFloat(dc.part1.S2R30.value)) -
        (parseFloat(dc.part1.Ch2.value) + parseFloat(dc.part1.NRe2.value) + parseFloat(dc.part1.N2.value) + parseFloat(dc.part1.S2F2.value));

    if(FssD > 0)
    {
      FssR = FssR - parseFloat(dc.part1.S2F2.value);

      d = parseFloat(dc.part1.Re2.value) - (parseFloat(dc.part1.Ch2.value) + parseFloat(dc.part1.NRe2.value) + parseFloat(dc.part1.N2.value));

      if(d > 0)
        FssR = FssR + d;
  
      FssR = Math.min(FssR, FssD);
    }
    else
      FssR = 0;

    FssD = FssD + (parseFloat(dc.part1.Re3.value) + parseFloat(dc.part1.S2R26.value)) -
        (parseFloat(dc.part1.Ch3.value) + parseFloat(dc.part1.S2R13.value) + parseFloat(dc.part1.N3.value) + parseFloat(dc.part1.S2R16.value));

    if(FssD > 0)
    {
      FssR = FssR - parseFloat(dc.part1.S2R16.value);

      d = parseFloat(dc.part1.Re3.value) - (parseFloat(dc.part1.Ch3.value) + parseFloat(dc.part1.S2R13.value) + parseFloat(dc.part1.N3.value));

      if(d > 0)
        FssR = FssR + d;

      FssR = Math.min(FssR, FssD);
    }
    else
      FssR = 0;

    if(FssR < 0)
      FssR = 0;

    FssR = Math.min(FssR, parseFloat(dc.part1.FssDebt.value));
    dc.part1.S2R18.value = fnRound(parseFloat(dc.part1.FssDebt.value) - FssR, 2);
    CalcDebtsP1();
    ReCharge = number_format(fnRound(parseFloat(dc.part1.FssDebt.value) - FssR, 2), 2, ',', ' ');
  }
  dc.getElementById('ReCharge').innerHTML = ReCharge;
}

function CalcDebtsP1()
{
  var dc = window.top.document;
  dc.part1.InsDebt.value = fnRound( CalcInsDebt(dc.part1.LAll.value, dc.part1.RAll.value), 2 ); 
  dc.part1.FssDebt.value = fnRound( CalcFssDebt(dc.part1.LAll.value, dc.part1.RAll.value), 2 ); 
  dc.part1.FssPartLast.value = fnRound( parseFloat(dc.part1.FssDebt.value) - parseFloat(dc.part1.S2R18.value), 2 );
}

function CalcLAllP1()
{
  var dc = window.top.document;
  dc.part1.LAll.value = fnRound( parseFloat(dc.part1.S2R1.value)   + 
                                 parseFloat(dc.part1.S2R2.value)   + 
                                 parseFloat(dc.part1.Charge.value) + 
                                 parseFloat(dc.part1.NAct.value)   + 
                                 parseFloat(dc.part1.NRe.value)    +
                                 parseFloat(dc.part1.S2F.value)    +
                                 parseFloat(dc.part1.S2N.value), 
                             2 ); 
  CalcDebtsP1();
}

function CalcLAllP1_2010()
{
  var dc = window.top.document;
  dc.part1.LAll.value = fnRound( parseFloat(dc.part1.S2R1.value)   + 
                                 parseFloat(dc.part1.Charge.value) + 
                                 parseFloat(dc.part1.NAct.value)   + 
                                 parseFloat(dc.part1.S2R2.value)   + 
                                 parseFloat(dc.part1.NRe.value)    +
                                 parseFloat(dc.part1.S2F.value)    +
                                 parseFloat(dc.part1.S2N.value), 
                             2 ); 
  CalcDebtsP1();
}

function SumChargeP1()
{
  var dc = window.top.document;
  dc.part1.ChSum.value = fnRound( parseFloat(dc.part1.Ch1.value) + 
                                  parseFloat(dc.part1.Ch2.value) + 
                                  parseFloat(dc.part1.Ch3.value),
                              2 ); 
  dc.part1.Charge.value = fnRound( parseFloat(dc.part1.ChSum.value) + 
                                   parseFloat(dc.part1.S2R3.value), 
                               2 );
}

function SumNActP1()
{
  var dc = window.top.document;
  dc.part1.NSum.value = fnRound( parseFloat(dc.part1.N1.value) + 
                                 parseFloat(dc.part1.N2.value) +
                                 parseFloat(dc.part1.N3.value), 
                             2 ); 
  dc.part1.NAct.value = fnRound( parseFloat(dc.part1.NSum.value) +
                                 parseFloat(dc.part1.N0.value), 
                             2 );
}

function SumNReP1()
{
  var dc = window.top.document;
  dc.part1.NReSum.value = fnRound( parseFloat(dc.part1.NRe1.value) +
                                   parseFloat(dc.part1.NRe2.value) + 
                                   parseFloat(dc.part1.S2R13.value), 
                               2 ); 
  dc.part1.NRe.value = fnRound( parseFloat(dc.part1.NReSum.value) +
                                parseFloat(dc.part1.NRe0.value), 
                            2 );
}

function SumS2FP1()
{
  var dc = window.top.document;
  dc.part1.S2FSum.value = fnRound( parseFloat(dc.part1.S2F1.value) +
                                   parseFloat(dc.part1.S2F2.value) + 
                                   parseFloat(dc.part1.S2R16.value), 
                               2 ); 
  dc.part1.S2F.value = fnRound( parseFloat(dc.part1.S2FSum.value) +
                                parseFloat(dc.part1.S2F0.value), 
                            2 );
}

function SumS2NP1()
{
  var dc = window.top.document;
  dc.part1.S2NSum.value = fnRound( parseFloat(dc.part1.S2N1.value) +
                                   parseFloat(dc.part1.S2N2.value) +
                                   parseFloat(dc.part1.S2N3.value),
                               2 ); 
  dc.part1.S2N.value = fnRound( parseFloat(dc.part1.S2NSum.value) +
                                parseFloat(dc.part1.S2N0.value),
                            2 );
}

function CalcRAllP1()
{
  var dc = window.top.document;
  dc.part1.RAll.value = fnRound( parseFloat(dc.part1.S2R19.value)  + 
                                 parseFloat(dc.part1.Reckon.value) + 
                                 parseFloat(dc.part1.Pay.value),
                             2 ); 
  CalcDebtsP1();
}

function CalcRAllP1_2010()
{
  var dc = window.top.document;
  dc.part1.RAll.value = fnRound( parseFloat(dc.part1.S2R19.value)  + 
                                 parseFloat(dc.part1.Reckon.value) + 
                                 parseFloat(dc.part1.Pay.value)    +
                                 parseFloat(dc.part1.S2R32.value),
                             2 ); 
  CalcDebtsP1();
}

function SumReckonP1()
{
  var dc = window.top.document;
  dc.part1.ReckonSum.value = fnRound( parseFloat(dc.part1.Re1.value) +
                                      parseFloat(dc.part1.Re2.value) +
                                      parseFloat(dc.part1.Re3.value),
                                  2 ); 
  dc.part1.Reckon.value = fnRound( parseFloat(dc.part1.ReckonSum.value) + 
                                   parseFloat(dc.part1.S2R21.value),
                               2 );
}

function SumPayP1()
{
  var dc = window.top.document;
  dc.part1.PaySum.value = fnRound( parseFloat(dc.part1.S2R29.value) + 
                                   parseFloat(dc.part1.S2R30.value) +
                                   parseFloat(dc.part1.S2R26.value),
                               2 );
  dc.part1.Pay.value = fnRound( parseFloat(dc.part1.PaySum.value) + 
                                parseFloat(dc.part1.S2R27.value),
                            2 );
}

function SumT3C4()
{
  var dc = window.top.document;
  dc.part1.S3R10C2.value = fnRound( parseFloat(dc.part1.S3R1C2.value) + 
                                    parseFloat(dc.part1.S3R4C2.value) +
                                    parseFloat(dc.part1.S3R7C2.value) +
                                    parseFloat(dc.part1.S3R6C2.value) +
                                    parseFloat(dc.part1.S3R8C2.value) +
                                    parseFloat(dc.part1.S3R3C2.value) +
                                    parseFloat(dc.part1.S3R5C2.value) /*+
                                    parseFloat(dc.part1.S3R26C2.value)*/,
                                2 ); 
  dc.part1.S3R21C2.value = fnRound( parseFloat(dc.part1.S3R18C2.value) +
                                    parseFloat(dc.part1.S3R17C2.value) +
                                    parseFloat(dc.part1.S3R24C2.value) +
                                    parseFloat(dc.part1.S3R12C2.value),
                                2 );
  dc.part1.S3R23C2.value = fnRound( parseFloat(dc.part1.S3R10C2.value) +
                                    parseFloat(dc.part1.S3R21C2.value),
                                2 );
}

function SumT3C5()
{
  var dc = window.top.document;
  dc.part1.S3R10C3.value = fnRound( parseFloat(dc.part1.S3R1C3.value) +
                                    parseFloat(dc.part1.S3R4C3.value) +
                                    parseFloat(dc.part1.S3R7C3.value) +
                                    parseFloat(dc.part1.S3R8C3.value),
                                2 ); 
  dc.part1.S3R23C3.value = dc.part1.S3R10C3.value;
}

function SumT3C3_2010()
{
  var dc = window.top.document;
  dc.part1.S3R10C1.value = fnRound( parseInt(dc.part1.S3R1C1.value) + 
                                    parseInt(dc.part1.S3R4C1.value) +
                                    parseInt(dc.part1.S3R5C1.value) +
                                    parseInt(dc.part1.S3R6C1.value) +
                                    parseInt(dc.part1.S3R7C1.value) +
                                    parseInt(dc.part1.S3R3C1.value) +
                                    parseInt(dc.part1.S3R8C1.value),
                                2 ); 
}

function SumT3C3_2011()
{
/*
  var dc = window.top.document;
  dc.part1.S3R10C1.value = fnRound( parseInt(dc.part1.S3R1C1.value) + 
                                    parseInt(dc.part1.S3R4C1.value) +
                                    parseInt(dc.part1.S3R5C1.value) +
                                    parseInt(dc.part1.S3R6C1.value) +
                                    parseInt(dc.part1.S3R7C1.value) +
                                    parseInt(dc.part1.S3R3C1.value) +
                                    parseInt(dc.part1.S3R8C1.value),
                                2 ); 
*/
}


function SumT3C4_2010()
{
  var dc = window.top.document;
  dc.part1.S3R10C2.value = fnRound( parseFloat(dc.part1.S3R1C2.value) + 
                                    parseFloat(dc.part1.S3R4C2.value) +
                                    parseFloat(dc.part1.S3R5C2.value) +
                                    parseFloat(dc.part1.S3R6C2.value) +
                                    parseFloat(dc.part1.S3R7C2.value) +
                                    parseFloat(dc.part1.S3R3C2.value) +
                                    parseFloat(dc.part1.S3R8C2.value),
                                2 ); 
}


function SumT3C4_2011()
{
  var dc = window.top.document;
  dc.part1.S3R10C2.value = fnRound( parseFloat(dc.part1.S3R1C2.value) + 
                                    parseFloat(dc.part1.S3R4C2.value) +
                                    parseFloat(dc.part1.S3R5C2.value) +
                                    parseFloat(dc.part1.S3R6C2.value) +
                                    parseFloat(dc.part1.S3R7C2.value) +
                                    parseFloat(dc.part1.S3R3C2.value) +
                                    parseFloat(dc.part1.S3R8C2.value),
                                2 ); 
}

function SumT3C5_2010()
{
  var dc = window.top.document;
  dc.part1.S3R10C3.value = fnRound( parseFloat(dc.part1.S3R1C3.value) +
                                    parseFloat(dc.part1.S3R4C3.value) +
                                    parseFloat(dc.part1.S3R7C3.value) +
                                    parseFloat(dc.part1.S3R3C3.value) +
                                    parseFloat(dc.part1.S3R8C3.value),
                                2 ); 
}

function SumT3C5_2011()
{
  var dc = window.top.document;
  dc.part1.S3R10C3.value = fnRound( parseFloat(dc.part1.S3R1C3.value) +
                                    parseFloat(dc.part1.S3R4C3.value) +
                                    parseFloat(dc.part1.S3R7C3.value) +
                                    parseFloat(dc.part1.S3R3C3.value) +
                                    parseFloat(dc.part1.S3R8C3.value),
                                2 ); 
}

function SumS3R7C1P1()
{
  var dc = window.top.document;
  dc.part1.S3R75C1.value = parseInt(dc.part1.S3R71C1.value) + 
                           parseInt(dc.part1.S3R72C1.value);
  dc.part1.S3R76C1.value = parseInt(dc.part1.S3R73C1.value) + 
                           parseInt(dc.part1.S3R74C1.value); 
  dc.part1.S3R7C1.value  = parseInt(dc.part1.S3R75C1.value) +
                           parseInt(dc.part1.S3R76C1.value);
}

function SumS3R7C1P1_2011()
{
  var dc = window.top.document;
  dc.part1.S3R7C1.value = parseInt(dc.part1.S3R71C1.value) + 
                           parseInt(dc.part1.S3R72C1.value);
}

function SumS3R7C2P1()
{
  var dc = window.top.document;
  dc.part1.S3R75C2.value = fnRound( parseFloat(dc.part1.S3R71C2.value) + 
                                    parseFloat(dc.part1.S3R72C2.value),
                                2 );
  dc.part1.S3R76C2.value = fnRound( parseFloat(dc.part1.S3R73C2.value) + 
                                    parseFloat(dc.part1.S3R74C2.value),
                                2 );
  dc.part1.S3R7C2.value = fnRound( parseFloat(dc.part1.S3R75C2.value) + 
                                   parseFloat(dc.part1.S3R76C2.value),
                               2 );
}

function SumS3R7C2P1_2011()
{
  var dc = window.top.document;
  dc.part1.S3R7C2.value = fnRound( parseFloat(dc.part1.S3R71C2.value) + 
                                    parseFloat(dc.part1.S3R72C2.value),
                                2 );
}


function SumS3R7C3P1()
{
  var dc = window.top.document;
  dc.part1.S3R75C3.value = fnRound( parseFloat(dc.part1.S3R71C3.value) + 
                                    parseFloat(dc.part1.S3R72C3.value),
                                2 );
  dc.part1.S3R76C3.value = fnRound( parseFloat(dc.part1.S3R73C3.value) + 
                                    parseFloat(dc.part1.S3R74C3.value),
                                2 );
  dc.part1.S3R7C3.value = fnRound( parseFloat(dc.part1.S3R75C3.value) + 
                                   parseFloat(dc.part1.S3R76C3.value),
                               2 );
}

function SumS3R7C3P1_2011()
{
  var dc = window.top.document;
  dc.part1.S3R7C3.value = fnRound( parseFloat(dc.part1.S3R71C3.value) + 
                                    parseFloat(dc.part1.S3R72C3.value),
                                2 );
}


function SumS3R10C2N()
{
  var dc = window.top.document;
  dc.part1.S3R10C2N.value = fnRound( parseFloat(dc.part1.S3R1C2N.value) + 
                                     parseFloat(dc.part1.S3R4C2N.value) +
                                     parseFloat(dc.part1.S3R7C2N.value),
                                2 );
}

function CalcDebtsP2()
{
  var dc = window.top.document;
  dc.part2.T2R34C1.value = fnRound( CalcInsDebt(dc.part2.LAll.value, dc.part2.RAll.value), 2 ); 
  dc.part2.T2R18C1.value = fnRound( CalcFssDebt(dc.part2.LAll.value, dc.part2.RAll.value), 2 );
}

function CalcDebtsP2_2010()
{
  var dc = window.top.document;
  dc.part2.T2R18C1.value = fnRound( CalcFssDebt(dc.part2.T2R16C1.value, dc.part2.RAll.value), 2 );
}

function CalcLAllP2()
{
  var dc = window.top.document;
  dc.part2.LAll.value = fnRound( parseFloat(dc.part2.T2R1C1.value) +
                                 parseFloat(dc.part2.T2R16C1.value),
                             2 ); 
  CalcDebtsP2();
}

function CalcRAllP2()
{
  var dc = window.top.document;
  dc.part2.RAll.value = fnRound( parseFloat(dc.part2.T2R19C1.value) +
                                 parseFloat(dc.part2.T2R25C1.value) +
                                 parseFloat(dc.part2.T2R31C1.value),
                             2 );
  CalcDebtsP2();
}

function CalcRAllP2_2010()
{
  var dc = window.top.document;
  dc.part2.RAll.value = fnRound( parseFloat(dc.part2.T2R19C1.value) +
                                 parseFloat(dc.part2.T2R25C1.value),
                             2 );
  CalcDebtsP2_2010();
}

function SumT6C4()
{
  var dc = window.top.document;
  dc.part2.T3R10C2.value = fnRound( parseFloat(dc.part2.T3R1C2.value) +
                                    parseFloat(dc.part2.T3R4C2.value) +
                                    parseFloat(dc.part2.T3R7C2.value) +
                                    parseFloat(dc.part2.T3R6C2.value) +
                                    parseFloat(dc.part2.T3R8C2.value) +
                                    parseFloat(dc.part2.T3R3C2.value) +
                                    parseFloat(dc.part2.T3R5C2.value) /*+
                                    parseFloat(dc.part2.T3R26C2.value)*/,
                                2 ); 
  dc.part2.T3R21C2.value = fnRound( parseFloat(dc.part2.T3R18C2.value) + 
                                    parseFloat(dc.part2.T3R17C2.value) +
                                    parseFloat(dc.part2.T3R24C2.value) +
                                    parseFloat(dc.part2.T3R12C2.value),
                                2 ); 
  dc.part2.T3R23C2.value = fnRound( parseFloat(dc.part2.T3R10C2.value) +
                                    parseFloat(dc.part2.T3R21C2.value),
                                2 );
}

function SumT6C5()
{
  var dc = window.top.document;
  dc.part2.T3R10C3.value = fnRound( parseFloat(dc.part2.T3R1C3.value) +
                                    parseFloat(dc.part2.T3R4C3.value) +
                                    parseFloat(dc.part2.T3R7C3.value) +
                                    parseFloat(dc.part2.T3R8C3.value),
                                2 );
  dc.part2.T3R23C3.value = dc.part2.T3R10C3.value;
}

function SumT6C3_2010()
{
  var dc = window.top.document;
  dc.part2.T3R10C1.value = fnRound( parseInt(dc.part2.T3R1C1.value) + 
                                    parseInt(dc.part2.T3R4C1.value) +
                                    parseInt(dc.part2.T3R5C1.value) +
                                    parseInt(dc.part2.T3R6C1.value) +
                                    parseInt(dc.part2.T3R7C1.value) +
                                    parseInt(dc.part2.T3R3C1.value) +
                                    parseInt(dc.part2.T3R8C1.value),
                                2 ); 
}

function SumT6C4_2010()
{
  var dc = window.top.document;
  dc.part2.T3R10C2.value = fnRound( parseFloat(dc.part2.T3R1C2.value) + 
                                    parseFloat(dc.part2.T3R4C2.value) +
                                    parseFloat(dc.part2.T3R5C2.value) +
                                    parseFloat(dc.part2.T3R6C2.value) +
                                    parseFloat(dc.part2.T3R7C2.value) +
                                    parseFloat(dc.part2.T3R3C2.value) +
                                    parseFloat(dc.part2.T3R8C2.value),
                                2 ); 
}

function SumT6C5_2010()
{
  var dc = window.top.document;
  dc.part2.T3R10C3.value = fnRound( parseFloat(dc.part2.T3R1C3.value) +
                                    parseFloat(dc.part2.T3R4C3.value) +
                                    parseFloat(dc.part2.T3R7C3.value) +
                                    parseFloat(dc.part2.T3R3C3.value) +
                                    parseFloat(dc.part2.T3R8C3.value),
                                2 ); 
}

function SumT3R7C1P2()
{
  var dc = window.top.document;
  dc.part2.T3R7C1.value = parseInt(dc.part2.T3R71C1.value) +
                          parseInt(dc.part2.T3R72C1.value);
}

function SumT3R7C2P2()
{
  var dc = window.top.document;
  dc.part2.T3R7C2.value = fnRound( parseFloat(dc.part2.T3R71C2.value) +
                                   parseFloat(dc.part2.T3R72C2.value),
                               2 );
}

function SumT3R7C3P2()
{
  var dc = window.top.document;
  dc.part2.T3R7C3.value = fnRound( parseFloat(dc.part2.T3R71C3.value) +
                                   parseFloat(dc.part2.T3R72C3.value),
                               2 );
}

function SumT3R7C1P2_2010()
{
  var dc = window.top.document;
  dc.part2.T3R75C1.value = parseInt(dc.part2.T3R71C1.value) + 
                           parseInt(dc.part2.T3R72C1.value);
  dc.part2.T3R76C1.value = parseInt(dc.part2.T3R73C1.value) + 
                           parseInt(dc.part2.T3R74C1.value); 
  dc.part2.T3R7C1.value  = parseInt(dc.part2.T3R75C1.value) +
                           parseInt(dc.part2.T3R76C1.value);
}

function SumT3R7C2P2_2010()
{
  var dc = window.top.document;
  dc.part2.T3R75C2.value = parseFloat(dc.part2.T3R71C2.value) + 
                           parseFloat(dc.part2.T3R72C2.value);
  dc.part2.T3R76C2.value = parseFloat(dc.part2.T3R73C2.value) + 
                           parseFloat(dc.part2.T3R74C2.value); 
  dc.part2.T3R7C2.value  = parseFloat(dc.part2.T3R75C2.value) +
                           parseFloat(dc.part2.T3R76C2.value);
}

function SumT3R7C3P2_2010()
{
  var dc = window.top.document;
  dc.part2.T3R75C3.value = parseFloat(dc.part2.T3R71C3.value) + 
                           parseFloat(dc.part2.T3R72C3.value);
  dc.part2.T3R76C3.value = parseFloat(dc.part2.T3R73C3.value) + 
                           parseFloat(dc.part2.T3R74C3.value); 
  dc.part2.T3R7C3.value  = parseFloat(dc.part2.T3R75C3.value) +
                           parseFloat(dc.part2.T3R76C3.value);
}

function CalcItogRate()
{
  var dc = window.top.document;
  dc.part3.ItogRate.value = fnRound( parseFloat(dc.part3.RATE_MIS.value) * 
                                     (1 + (parseFloat(dc.part3.RATE_INC.value) - parseFloat(dc.part3.RATE_DEC.value)) / 100),
                                 2 );
}

function CalcDebtsP3()
{
  var dc = window.top.document;
  dc.part3.T7R34C1.value = fnRound( CalcInsDebt(document.part3.LAll.value, document.part3.RAll.value), 2 ); 
  dc.part3.T7R18C1.value = fnRound( CalcFssDebt(document.part3.LAll.value, document.part3.RAll.value), 2 );
}

function CalcLAllP3()
{
  var dc = window.top.document;
  dc.part3.LAll.value = fnRound( parseFloat(dc.part3.T7R1C1.value)  +
                                 parseFloat(dc.part3.T7R2C1.value)  +
                                 parseFloat(dc.part3.T7R9C1.value)  +
                                 parseFloat(dc.part3.T7R13C1.value) +
                                 parseFloat(dc.part3.T7R11C1.value) +
                                 parseFloat(dc.part3.T7R16C1.value),
                             2 );
  CalcDebtsP3();
}

function CalcLAllP3_2011()
{
  var dc = window.top.document;
  dc.part3.LAll.value = fnRound( parseFloat(dc.part3.T7R1C1.value)  +
                                 parseFloat(dc.part3.T7R2C1.value)  +
                                 parseFloat(dc.part3.T7R9C1.value)  +
                                 parseFloat(dc.part3.T7R13C1.value) +
                                 parseFloat(dc.part3.T7R11C1.value) +
                                 parseFloat(dc.part3.T7R16C1.value) +
                                 parseFloat(dc.part3.T7R17C61.value),
                             2 );
  CalcDebtsP3();
}

function SumT7R2C1P3()
{
  var dc = window.top.document;
  dc.part3.T7R4C1.value = fnRound( parseFloat(dc.part3.T7R5C1.value) +
                                   parseFloat(dc.part3.T7R6C1.value) +
                                   parseFloat(dc.part3.T7R7C1.value),
                               2 ); 
  dc.part3.T7R2C1.value = fnRound( parseFloat(dc.part3.T7R3C1.value) +
                                   parseFloat(dc.part3.T7R4C1.value),
                               2 );
}

function CalcRAllP3()
{
  var dc = window.top.document;
  dc.part3.RAll.value = fnRound( parseFloat(dc.part3.T7R19C1.value) +
                                 parseFloat(dc.part3.T7R20C1.value) +
                                 parseFloat(dc.part3.T7R26C1.value) +
                                 parseFloat(dc.part3.T7R38C1.value),
                             2 ); 
  CalcDebtsP3();
}

function SumT7R20C1P3()
{
  var dc = window.top.document;
  dc.part3.T7R22C1.value = fnRound( parseFloat(dc.part3.T7R23C1.value) +
                                    parseFloat(dc.part3.T7R24C1.value) +
                                    parseFloat(dc.part3.T7R25C1.value),
                                2 ); 
  dc.part3.T7R20C1.value = fnRound( parseFloat(dc.part3.T7R21C1.value) +
                                    parseFloat(dc.part3.T7R22C1.value),
                                2 );
}

function SumT7R26C1P3()
{
  var dc = window.top.document;
  dc.part3.T7R28C1.value = fnRound( parseFloat(dc.part3.T7R29C1.value) +
                                    parseFloat(dc.part3.T7R30C1.value) +
                                    parseFloat(dc.part3.T7R31C1.value),
                                2 ); 
  dc.part3.T7R26C1.value = fnRound( parseFloat(dc.part3.T7R27C1.value) +
                                    parseFloat(dc.part3.T7R28C1.value),
                                2 );
}

function SumT6R7C2P3()
{
  var dc = window.top.document;
  dc.part3.T6R7C2.value = fnRound( parseFloat(dc.part3.T6R3C2.value)  +
                                   parseFloat(dc.part3.T6R8C2.value)  +
                                   parseFloat(dc.part3.T6R5C2.value)  +
                                   parseFloat(dc.part3.T6R10C2.value) +
                                   parseFloat(dc.part3.T6R12C2.value),
                               2 );
}

function SumT6R7C2P3_2010()
{
  var dc = window.top.document;
  dc.part3.T6R7C2.value = fnRound( parseFloat(dc.part3.T6R3C2.value)  +
                                   parseFloat(dc.part3.T6R8C2.value)  +
                                   parseFloat(dc.part3.T6R5C2.value)  +
                                   parseFloat(dc.part3.T6R10C2.value),
                               2 );
}

function SumC()
{
  var dc = window.top.document;
  dc.part3.C_sum.value = fnRound( parseFloat(dc.part3.C1.value)  +
                                   parseFloat(dc.part3.C2.value)  +
                                   parseFloat(dc.part3.C3.value),
                               2 );
}

function SumI()
{
  var dc = window.top.document;
  dc.part3.I_sum.value = fnRound( parseFloat(dc.part3.I1.value)  +
                                   parseFloat(dc.part3.I2.value)  +
                                   parseFloat(dc.part3.I3.value),
                               2 );
}

function SumNC()
{
  var dc = window.top.document;
  dc.part3.NC_sum.value = fnRound( parseFloat(dc.part3.NC1.value)  +
                                   parseFloat(dc.part3.NC2.value)  +
                                   parseFloat(dc.part3.NC3.value),
                               2 );
}




function HideShowTaxType(year)
{
  var dc = window.top.document;
  var TaxTypeCtrl = dc.getElementById('divTaxTypeP1');

  TaxTypeCtrl.style.display = 'none';

  if (year > 2009) 
    TaxTypeCtrl.style.display = 'block';
}

function T3CalcCol7()
{
  var dc = window.top.document;

  dc.part1.S5.value = fnRound( parseFloat(dc.part1.S1.value) -
                               parseFloat(dc.part1.S2.value) -
                               parseFloat(dc.part1.S3.value) -
                               parseFloat(dc.part1.S4.value),
                           2 );

  dc.part1.S5_1.value = fnRound( parseFloat(dc.part1.S1_1.value) -
                                 parseFloat(dc.part1.S2_1.value) -
                                 parseFloat(dc.part1.S3_1.value) -
                                 parseFloat(dc.part1.S4_1.value),
                             2 );

  dc.part1.S5_2.value = fnRound( parseFloat(dc.part1.S1_2.value) -
                                 parseFloat(dc.part1.S2_2.value) -
                                 parseFloat(dc.part1.S3_2.value) -
                                 parseFloat(dc.part1.S4_2.value),
                             2 );

  dc.part1.S5_3.value = fnRound( parseFloat(dc.part1.S1_3.value) -
                                 parseFloat(dc.part1.S2_3.value) -
                                 parseFloat(dc.part1.S3_3.value) -
                                 parseFloat(dc.part1.S4_3.value),
                             2 );

  dc.part1.S5_Q.value = fnRound( parseFloat(dc.part1.S1_Q.value) -
                                 parseFloat(dc.part1.S2_Q.value) -
                                 parseFloat(dc.part1.S3_Q.value) -
                                 parseFloat(dc.part1.S4_Q.value),
                             2 );
}
 
function T3CalcRow2()
{
  var dc = window.top.document;

  dc.part1.S1_Q.value = fnRound( parseFloat(dc.part1.S1_1.value) +
                                 parseFloat(dc.part1.S1_2.value) +
                                 parseFloat(dc.part1.S1_3.value),
                             2 );

  dc.part1.S2_Q.value = fnRound( parseFloat(dc.part1.S2_1.value) +
                                 parseFloat(dc.part1.S2_2.value) +
                                 parseFloat(dc.part1.S2_3.value),
                             2 );

  dc.part1.S3_Q.value = fnRound( parseFloat(dc.part1.S3_1.value) +
                                 parseFloat(dc.part1.S3_2.value) +
                                 parseFloat(dc.part1.S3_3.value),
                             2 );

  dc.part1.S4_Q.value = fnRound( parseFloat(dc.part1.S4_1.value) +
                                 parseFloat(dc.part1.S4_2.value) +
                                 parseFloat(dc.part1.S4_3.value),
                             2 );
}


function T3CalcRow4_2011()
{
  var dc = window.top.document;

  dc.part1.S5.value = fnRound( parseFloat(dc.part1.S1.value) -
                               parseFloat(dc.part1.S2.value) -
                               parseFloat(dc.part1.S4.value),
                           2 );

  dc.part1.S5_1.value = fnRound( parseFloat(dc.part1.S1_1.value) -
                                 parseFloat(dc.part1.S2_1.value) -
                                 parseFloat(dc.part1.S4_1.value),
                             2 );

  dc.part1.S5_2.value = fnRound( parseFloat(dc.part1.S1_2.value) -
                                 parseFloat(dc.part1.S2_2.value) -
                                 parseFloat(dc.part1.S4_2.value),
                             2 );

  dc.part1.S5_3.value = fnRound( parseFloat(dc.part1.S1_3.value) -
                                 parseFloat(dc.part1.S2_3.value) -
                                 parseFloat(dc.part1.S4_3.value),
                             2 );
}

function T4CalcSums()
{
  var dc = window.top.document;

  dc.part1.FINE_SUM.value = fnRound( parseFloat(dc.part1.FINE_LEFT.value) +
                                     parseFloat(dc.part1.FINE_TAX.value),
                                 2 );

  dc.part1.PNLT_SUM.value = fnRound( parseFloat(dc.part1.PNLT_LEFT.value) +
                                     parseFloat(dc.part1.PNLT_TAX.value),
                                 2 );

  dc.part1.FINE_DEBT.value = fnRound( parseFloat(dc.part1.FINE_SUM.value) -
                                      parseFloat(dc.part1.FINE_PAY.value) +
                                      parseFloat(dc.part1.FINE_RET.value),
                                 2 );

  dc.part1.PNLT_DEBT.value = fnRound( parseFloat(dc.part1.PNLT_SUM.value) -
                                      parseFloat(dc.part1.PNLT_PAY.value) +
                                      parseFloat(dc.part1.PNLT_RET.value),
                                 2 );
}

function CalcT8_2010()
{
  var dc = window.top.document;

  dc.t78.T5R3C14.value = parseInt(dc.t78.T5R31C14.value) + parseInt(dc.t78.T5R32C14.value);
  dc.t78.T5R3C3.value =  fnRound( parseFloat(dc.t78.T5R31C3.value) +
                                  parseFloat(dc.t78.T5R32C3.value),
                              2 );

  dc.t78.T5R3C16.value = parseInt(dc.t78.T5R31C16.value) + parseInt(dc.t78.T5R32C16.value);
  dc.t78.T5R3C5.value =  fnRound( parseFloat(dc.t78.T5R31C5.value) +
                                  parseFloat(dc.t78.T5R32C5.value),
                              2 );

  dc.t78.T5R3C20.value = parseInt(dc.t78.T5R31C20.value) + parseInt(dc.t78.T5R32C20.value);
  dc.t78.T5R3C9.value =  fnRound( parseFloat(dc.t78.T5R31C9.value) +
                                  parseFloat(dc.t78.T5R32C9.value),
                              2 );

  dc.t78.T5R1C2.value = parseInt(dc.t78.T5R1C4.value)  + 
                        parseInt(dc.t78.T5R1C6.value)  +
                        parseInt(dc.t78.T5R1C8.value)  +
                        parseInt(dc.t78.T5R1C10.value) +
                        parseInt(dc.t78.T5R1C12.value);

  dc.t78.T5R1C24.value = parseInt(dc.t78.T5R1C14.value) + 
                         parseInt(dc.t78.T5R1C16.value) +
                         parseInt(dc.t78.T5R1C18.value) +
                         parseInt(dc.t78.T5R1C20.value) +
                         parseInt(dc.t78.T5R1C22.value);

  dc.t78.T5R1C1.value =  fnRound( parseFloat(dc.t78.T5R1C3.value) +
                                  parseFloat(dc.t78.T5R1C5.value) +
                                  parseFloat(dc.t78.T5R1C7.value) +
                                  parseFloat(dc.t78.T5R1C9.value) +
                                  parseFloat(dc.t78.T5R1C11.value),
                              2 );

  dc.t78.T5R2C2.value = parseInt(dc.t78.T5R2C4.value)  + 
                        parseInt(dc.t78.T5R2C6.value)  +
                        parseInt(dc.t78.T5R2C10.value) +
                        parseInt(dc.t78.T5R2C12.value);

  dc.t78.T5R2C24.value = parseInt(dc.t78.T5R2C14.value) + 
                         parseInt(dc.t78.T5R2C16.value) +
                         parseInt(dc.t78.T5R2C20.value) +
                         parseInt(dc.t78.T5R2C22.value);

  dc.t78.T5R2C1.value =  fnRound( parseFloat(dc.t78.T5R2C3.value) +
                                  parseFloat(dc.t78.T5R2C5.value) +
                                  parseFloat(dc.t78.T5R2C9.value) +
                                  parseFloat(dc.t78.T5R2C11.value),
                              2 );

  dc.t78.T5R3C2.value = parseInt(dc.t78.T5R3C4.value)  + 
                        parseInt(dc.t78.T5R3C6.value)  +
                        parseInt(dc.t78.T5R3C10.value);

  dc.t78.T5R3C24.value = parseInt(dc.t78.T5R3C14.value) + 
                         parseInt(dc.t78.T5R3C16.value) +
                         parseInt(dc.t78.T5R3C20.value);

  dc.t78.T5R3C1.value =  fnRound( parseFloat(dc.t78.T5R3C3.value) +
                                  parseFloat(dc.t78.T5R3C5.value) +
                                  parseFloat(dc.t78.T5R3C9.value),
                              2 );

  dc.t78.T5R31C2.value = parseInt(dc.t78.T5R31C4.value)  + 
                         parseInt(dc.t78.T5R31C6.value)  +
                         parseInt(dc.t78.T5R31C10.value);

  dc.t78.T5R31C24.value = parseInt(dc.t78.T5R31C14.value) + 
                          parseInt(dc.t78.T5R31C16.value) +
                          parseInt(dc.t78.T5R31C20.value);

  dc.t78.T5R31C1.value =  fnRound( parseFloat(dc.t78.T5R31C3.value) +
                                   parseFloat(dc.t78.T5R31C5.value) +
                                   parseFloat(dc.t78.T5R31C9.value),
                               2 );
  
  dc.t78.T5R32C2.value = parseInt(dc.t78.T5R32C4.value)  + 
                         parseInt(dc.t78.T5R32C6.value)  +
                         parseInt(dc.t78.T5R32C10.value);

  dc.t78.T5R32C24.value = parseInt(dc.t78.T5R32C14.value) + 
                          parseInt(dc.t78.T5R32C16.value) +
                          parseInt(dc.t78.T5R32C20.value);

  dc.t78.T5R32C1.value =  fnRound( parseFloat(dc.t78.T5R32C3.value) +
                                   parseFloat(dc.t78.T5R32C5.value) +
                                   parseFloat(dc.t78.T5R32C9.value),
                               2 ); 

  dc.t78.T5R4C2.value = parseInt(dc.t78.T5R4C4.value)  + 
                        parseInt(dc.t78.T5R4C6.value)  +
                        parseInt(dc.t78.T5R4C10.value);

  dc.t78.T5R4C24.value = parseInt(dc.t78.T5R4C14.value) + 
                         parseInt(dc.t78.T5R4C16.value) +
                         parseInt(dc.t78.T5R4C20.value);

  dc.t78.T5R4C1.value =  fnRound( parseFloat(dc.t78.T5R4C3.value) +
                                  parseFloat(dc.t78.T5R4C5.value) +
                                  parseFloat(dc.t78.T5R4C9.value),
                              2 );
  
  dc.t78.T5R10C2.value = parseInt(dc.t78.T5R1C2.value) + 
                         parseInt(dc.t78.T5R2C2.value) + 
                         parseInt(dc.t78.T5R3C2.value) + 
                         parseInt(dc.t78.T5R4C2.value);

  dc.t78.T5R10C1.value = fnRound( parseFloat(dc.t78.T5R1C1.value) +
                                  parseFloat(dc.t78.T5R2C1.value) +
                                  parseFloat(dc.t78.T5R3C1.value) + 
                                  parseFloat(dc.t78.T5R4C1.value),
                              2 );

  dc.t78.T5R10C4.value = parseInt(dc.t78.T5R1C4.value) + 
                         parseInt(dc.t78.T5R2C4.value) + 
                         parseInt(dc.t78.T5R3C4.value) + 
                         parseInt(dc.t78.T5R4C4.value);

  dc.t78.T5R10C3.value = fnRound( parseFloat(dc.t78.T5R1C3.value) +
                                  parseFloat(dc.t78.T5R2C3.value) +
                                  parseFloat(dc.t78.T5R3C3.value) + 
                                  parseFloat(dc.t78.T5R4C3.value),
                              2 );

  dc.t78.T5R10C6.value = parseInt(dc.t78.T5R1C6.value) + 
                         parseInt(dc.t78.T5R2C6.value) + 
                         parseInt(dc.t78.T5R3C6.value) + 
                         parseInt(dc.t78.T5R4C6.value);

  dc.t78.T5R10C5.value = fnRound( parseFloat(dc.t78.T5R1C5.value) +
                                  parseFloat(dc.t78.T5R2C5.value) +
                                  parseFloat(dc.t78.T5R3C5.value) + 
                                  parseFloat(dc.t78.T5R4C5.value),
                              2 );
  
  dc.t78.T5R10C8.value = parseInt(dc.t78.T5R1C8.value);

  dc.t78.T5R10C7.value = parseFloat(dc.t78.T5R1C7.value);
  
  dc.t78.T5R10C10.value = parseInt(dc.t78.T5R1C10.value) + 
                          parseInt(dc.t78.T5R2C10.value) + 
                          parseInt(dc.t78.T5R3C10.value) + 
                          parseInt(dc.t78.T5R4C10.value);

  dc.t78.T5R10C9.value = fnRound( parseFloat(dc.t78.T5R1C9.value) +
                                  parseFloat(dc.t78.T5R2C9.value) +
                                  parseFloat(dc.t78.T5R3C9.value) + 
                                  parseFloat(dc.t78.T5R4C9.value),
                              2 );

  dc.t78.T5R10C12.value = parseInt(dc.t78.T5R1C12.value) + 
                          parseInt(dc.t78.T5R2C12.value);

  dc.t78.T5R10C11.value = fnRound( parseFloat(dc.t78.T5R1C11.value) +
                                   parseFloat(dc.t78.T5R2C11.value),
                              2 );
}

function T12CalcSums()
{
  var dc = window.top.document;

  dc.part3.FINE_SUM.value = fnRound( parseFloat(dc.part3.FINE_LEFT.value) +
                                     parseFloat(dc.part3.FINE_TAX.value),
                                 2 );

  dc.part3.PNLT_SUM.value = fnRound( parseFloat(dc.part3.PNLT_LEFT.value) +
                                     parseFloat(dc.part3.PNLT_TAX.value),
                                 2 );

  dc.part3.FINE_DEBT.value = fnRound( parseFloat(dc.part3.FINE_SUM.value) -
                                      parseFloat(dc.part3.FINE_PAY.value) +
                                      parseFloat(dc.part3.FINE_RET.value),
                                 2 );

  dc.part3.PNLT_DEBT.value = fnRound( parseFloat(dc.part3.PNLT_SUM.value) -
                                      parseFloat(dc.part3.PNLT_PAY.value) +
                                      parseFloat(dc.part3.PNLT_RET.value),
                                 2 );
}

function T4CalcRow3_2011()
{
 var dc = window.top.document;
 
 var vIOO_C = parseInt(dc.part1.IOO_C.value);
 var vIOO_C1 = parseInt(dc.part1.IOO_C1.value);
 var vIOO_C2 = parseInt(dc.part1.IOO_C2.value);
 var vIOO_C3 = parseInt(dc.part1.IOO_C3.value);
 var vIOO_CI = parseInt(dc.part1.IOO_CI.value);
 var vIOO_CI1 = parseInt(dc.part1.IOO_CI1.value);
 var vIOO_CI2 = parseInt(dc.part1.IOO_CI2.value);
 var vIOO_CI3 = parseInt(dc.part1.IOO_CI3.value);
 
 if(vIOO_C !=0){
 dc.part1.qIOO_CI.value = fnRound(vIOO_CI/vIOO_C*100,2);
 }
 else{
 dc.part1.qIOO_CI.value = '';
 }
 if(vIOO_C1 !=0){
 dc.part1.qIOO_CI1.value = fnRound(vIOO_CI1/vIOO_C1*100,2);
 }
 else{
 dc.part1.qIOO_CI1.value = '';
 }
 if(vIOO_C2 !=0){
 dc.part1.qIOO_CI2.value = fnRound(vIOO_CI2/vIOO_C2*100,2);
 }
 else{
 dc.part1.qIOO_CI2.value = '';
 }
 if(vIOO_C3 !=0){
 dc.part1.qIOO_CI3.value = fnRound(vIOO_CI3/vIOO_C3*100,2);
 }
 else{
 dc.part1.qIOO_CI3.value = '';
 }
}

function T4CalcRow6_2011()
{
 var dc = window.top.document;
 
 var vIUK_C = parseInt(dc.part1.IUK_C.value);
 var vIUK_C1 = parseInt(dc.part1.IUK_C1.value);
 var vIUK_C2 = parseInt(dc.part1.IUK_C2.value);
 var vIUK_C3 = parseInt(dc.part1.IUK_C3.value);
 var vIUK_CI = parseInt(dc.part1.IUK_CI.value);
 var vIUK_CI1 = parseInt(dc.part1.IUK_CI1.value);
 var vIUK_CI2 = parseInt(dc.part1.IUK_CI2.value);
 var vIUK_CI3 = parseInt(dc.part1.IUK_CI3.value);
 
 if(vIUK_C !=0){
 dc.part1.qIUK_CI.value = fnRound(vIUK_CI/vIUK_C*100,2);
 }
 else{
 dc.part1.qIUK_CI.value = '';
 }
 if(vIUK_C1 !=0){
 dc.part1.qIUK_CI1.value = fnRound(vIUK_CI1/vIUK_C1*100,2);
 }
 else{
 dc.part1.qIUK_CI1.value = '';
 }
 if(vIUK_C2 !=0){
 dc.part1.qIUK_CI2.value = fnRound(vIUK_CI2/vIUK_C2*100,2);
 }
 else{
  dc.part1.qIUK_CI2.value = '';
 }
 if(vIUK_C3 !=0){
 dc.part1.qIUK_CI3.value = fnRound(vIUK_CI3/vIUK_C3*100,2);
 }
 else{
  dc.part1.qIUK_CI3.value = '';
 }
}

function T4CalcRow9_2011()
{
 var dc = window.top.document;
 
 var vIUK_S = parseInt(dc.part1.IUK_S.value);
 var vIUK_S1 = parseInt(dc.part1.IUK_S1.value);
 var vIUK_S2 = parseInt(dc.part1.IUK_S2.value);
 var vIUK_S3 = parseInt(dc.part1.IUK_S3.value);
 var vIUK_SI = parseInt(dc.part1.IUK_SI.value);
 var vIUK_SI1 = parseInt(dc.part1.IUK_SI1.value);
 var vIUK_SI2 = parseInt(dc.part1.IUK_SI2.value);
 var vIUK_SI3 = parseInt(dc.part1.IUK_SI3.value);
 
 if(vIUK_S !=0){
 dc.part1.qIUK_SI.value = fnRound(vIUK_SI/vIUK_S*100,2);
 }
 else{
 dc.part1.qIUK_SI.value = '';
 }
 if(vIUK_S1 !=0){
 dc.part1.qIUK_SI1.value = fnRound(vIUK_SI1/vIUK_S1*100,2);
 }
 else{
 dc.part1.qIUK_SI1.value = '';
 }
 if(vIUK_S2 !=0){
 dc.part1.qIUK_SI2.value = fnRound(vIUK_SI2/vIUK_S2*100,2);
 }
 else{
  dc.part1.qIUK_SI2.value = '';
 }
 if(vIUK_S3 !=0){
 dc.part1.qIUK_SI3.value = fnRound(vIUK_SI3/vIUK_S3*100,2);
 }
 else{
  dc.part1.qIUK_SI3.value = '';
 }
}

function TotalInval_2011()
{
 var dc = window.top.document;
 var ltotalS = 0;
 var ltotalS1 = 0;
 var ltotalS2 = 0;
 var ltotalS3 = 0;
 
 for(i = 0; i < dc.part1.row.value; i++ ){
    
     ltotalS += parseFloat(dc.part1.elements["S_"+i].value);
     ltotalS1 += parseFloat(dc.part1.elements["S1_"+i].value);
     ltotalS2 += parseFloat(dc.part1.elements["S2_"+i].value);
     ltotalS3 += parseFloat(dc.part1.elements["S3_"+i].value);

 }
 
 dc.part1.totalS.value = ltotalS;
 dc.part1.totalS1.value = ltotalS1;
 dc.part1.totalS2.value = ltotalS2;
 dc.part1.totalS3.value = ltotalS3;
}
