	<tr class="title4" align="right">
  	<td align="center"><b>合计</b></td>
  	<td id="i_0000_1"></td>
  	<td id="i_0000_2"></td>
  	<td id="i_0000_3"></td>
  	<td id="i_0000_4"></td>
  	<td id="i_0000_5"></td>
  	<td id="i_0000_6"></td>
  	<td id="i_0000_7"></td>
  	<td id="i_0000_8"></td>
  	<td id="i_0000_9"></td>
  	<td id="i_0000_10"></td>
  	<td align="center">-</td>
	</tr>
</table>
<br>
<div>
  <button id="btn_detail_delete">删除</button>
  <span style="width:36px;"></span>
  <button id="btn_detail_back">返回</button>
  <span style="width:36px;"></span>
  <button id="btn_detail_save">保存</button>
</div>
</center>
</body>
<script>
function bto_scale(num, scale) {
  var n = parseFloat(num);
  if(n != num) n = 0;
  
  n = n * Math.pow(10,scale);

  if(n > 0) {
    n += 0.005;
  } else {
    n -= 0.005;
  }
  n = Math.round(n);
  
  n = n + "";
  
  var flag = "";
  if(n.substring(0, 1) == "-") {
    flag = "-";
    n = n.substring(1, n.length);
  }
  if(n.length < scale + 1) {
    n = "0000" + n;
    n = n.substring(n.length - scale - 1, n.length);
  }

  str = n.substring(0, n.length - scale) + "." + n.substring(n.length - scale, n.length);
  
  return flag + str;
}
function _calc6() {
  var ipts = document.all.tags("INPUT");
  var d1 = 0;
  var d2 = 0;
  var d4 = 0;
  var d5 = 0;
  var d6 = 0;
  var d7 = 0;
  var d8 = 0;
  for(var i=0;i<ipts.length;i++) {
    var _id = ipts[i].id;
    if(_id.substring(0,4) != "i_06") continue;

    var index = _id.substring(_id.length-2, _id.length);
    var f = parseFloat(ipts[i].value);
    if(f != ipts[i].value) continue;

    if(index == "_1") d1 = d1 + f;
    else if(index == "_2") d2 = d2 + f;
    else if(index == "_4") d4 = d4 + f;
    else if(index == "_5") d5 = d5 + f;
    else if(index == "_6") d6 = d6 + f;
    else if(index == "_7") d7 = d7 + f;
    else if(index == "_8") d8 = d8 + f;
  }
  var e1 = document.getElementById("i_0600_1");
  var e2 = document.getElementById("i_0600_2");
  var e3 = document.getElementById("i_0600_3");
  var e4 = document.getElementById("i_0600_4");
  var e5 = document.getElementById("i_0600_5");
  var e6 = document.getElementById("i_0600_6");
  var e7 = document.getElementById("i_0600_7");
  var e8 = document.getElementById("i_0600_8");
  var e9 = document.getElementById("i_0600_9");
  var e10 = document.getElementById("i_0600_10");
  
  e1.innerText = bto_scale(d1, 2);
  e2.innerText = bto_scale(d2, 2);
  e3.innerText = bto_scale(d1 + d2, 2);
  e4.innerText = bto_scale(d4, 2);
  e5.innerText = bto_scale(d5, 2);
  e6.innerText = bto_scale(d6, 2);
  e7.innerText = bto_scale(d7, 2);
  e8.innerText = bto_scale(d8, 2);
  var t = d5 - d6 - d7 - d8;
  if(t >= 0) {
    e9.innerText = bto_scale(t, 2);
    e10.innerText = "0.00";
  }else {
    e9.innerText = "0.00";
    e10.innerText = bto_scale(t * -1, 2);
  }
}
function _calc9() {
  var ipts = document.all.tags("INPUT");
  var d1 = 0;
  var d2 = 0;
  var d4 = 0;
  var d5 = 0;
  var d6 = 0;
  var d7 = 0;
  var d8 = 0;
  for(var i=0;i<ipts.length;i++) {
    var _id = ipts[i].id;
    if(_id.substring(0,4) != "i_09") continue;

    var index = _id.substring(_id.length-2, _id.length);
    var f = parseFloat(ipts[i].value);
    if(f != ipts[i].value) continue;

    if(index == "_1") d1 = d1 + f;
    else if(index == "_2") d2 = d2 + f;
    else if(index == "_4") d4 = d4 + f;
    else if(index == "_5") d5 = d5 + f;
    else if(index == "_6") d6 = d6 + f;
    else if(index == "_7") d7 = d7 + f;
    else if(index == "_8") d8 = d8 + f;
  }
  var e1 = document.getElementById("i_0900_1");
  var e2 = document.getElementById("i_0900_2");
  var e3 = document.getElementById("i_0900_3");
  var e4 = document.getElementById("i_0900_4");
  var e5 = document.getElementById("i_0900_5");
  var e6 = document.getElementById("i_0900_6");
  var e7 = document.getElementById("i_0900_7");
  var e8 = document.getElementById("i_0900_8");
  var e9 = document.getElementById("i_0900_9");
  var e10 = document.getElementById("i_0900_10");
  
  e1.innerText = bto_scale(d1, 2);
  e2.innerText = bto_scale(d2, 2);
  e3.innerText = bto_scale(d1 + d2, 2);
  e4.innerText = bto_scale(d4, 2);
  e5.innerText = bto_scale(d5, 2);
  e6.innerText = bto_scale(d6, 2);
  e7.innerText = bto_scale(d7, 2);
  e8.innerText = bto_scale(d8, 2);
  var t = d5 - d6 - d7 - d8;
  if(t >= 0) {
    e9.innerText = bto_scale(t, 2);
    e10.innerText = "0.00";
  }else {
    e9.innerText = "0.00";
    e10.innerText = bto_scale(t * -1, 2);
  }
}
function _calcAll() {
  _calc6();
  _calc9();
  var ipts = document.all.tags("INPUT");
  var d1 = 0;
  var d2 = 0;
  var d4 = 0;
  var d5 = 0;
  var d6 = 0;
  var d7 = 0;
  var d8 = 0;
  for(var i=0;i<ipts.length;i++) {
    var _id = ipts[i].id;
    var index = _id.substring(_id.length-2, _id.length);
    var f = parseFloat(ipts[i].value);
    if(f != ipts[i].value) continue;

    if(index == "_1") d1 = d1 + f;
    else if(index == "_2") d2 = d2 + f;
    else if(index == "_4") d4 = d4 + f;
    else if(index == "_5") d5 = d5 + f;
    else if(index == "_6") d6 = d6 + f;
    else if(index == "_7") d7 = d7 + f;
    else if(index == "_8") d8 = d8 + f;
  }
  var e1 = document.getElementById("i_0000_1");
  var e2 = document.getElementById("i_0000_2");
  var e3 = document.getElementById("i_0000_3");
  var e4 = document.getElementById("i_0000_4");
  var e5 = document.getElementById("i_0000_5");
  var e6 = document.getElementById("i_0000_6");
  var e7 = document.getElementById("i_0000_7");
  var e8 = document.getElementById("i_0000_8");
  var e9 = document.getElementById("i_0000_9");
  var e10 = document.getElementById("i_0000_10");
  
  e1.innerText = bto_scale(d1, 2);
  e2.innerText = bto_scale(d2, 2);
  e3.innerText = bto_scale(d1 + d2, 2);
  e4.innerText = bto_scale(d4, 2);
  e5.innerText = bto_scale(d5, 2);
  e6.innerText = bto_scale(d6, 2);
  e7.innerText = bto_scale(d7, 2);
  e8.innerText = bto_scale(d8, 2);
  var t = d5 - d6 - d7 - d8;
  if(t >= 0) {
    e9.innerText = bto_scale(t, 2);
    e10.innerText = "0.00";
  }else {
    e9.innerText = "0.00";
    e10.innerText = bto_scale(t * -1, 2);
  }
}
function _calc() {
  var oId = event.srcElement.id;
  var oValue = event.srcElement.value;
  if(oId == "swglm") {
    if(oValue.length != 15) alert("请输入15位的税务管理码！");
  } else if(oId.substring(0,2) == "i_") {
    var tax = oId.split("_")[1];
    var e1 = document.getElementById("i_" + tax + "_1");
    var e2 = document.getElementById("i_" + tax + "_2");
    var e3 = document.getElementById("i_" + tax + "_3");
    var e4 = document.getElementById("i_" + tax + "_4");
    var e5 = document.getElementById("i_" + tax + "_5");
    var e6 = document.getElementById("i_" + tax + "_6");
    var e7 = document.getElementById("i_" + tax + "_7");
    var e8 = document.getElementById("i_" + tax + "_8");
    var e9 = document.getElementById("i_" + tax + "_9");
    var e10 = document.getElementById("i_" + tax + "_10");
    
    e1.value = bto_scale(e1.value, 2);
    e2.value = bto_scale(e2.value, 2);
    e3.innerText = bto_scale(parseFloat(e1.value) + parseFloat(e2.value), 2);
    if(tax != "0902") {
      e4.value = bto_scale(e4.value, 2);
      e5.value = bto_scale(e5.value, 2);
      e6.value = bto_scale(e6.value, 2);
      e7.value = bto_scale(e7.value, 2);
      e8.value = bto_scale(e8.value, 2);
      var t = e5.value - e6.value - e7.value - e8.value
      if(t >= 0) {
        e9.innerText = bto_scale(t, 2);
        e10.innerText = "0.00";
      }else {
        e9.innerText = "0.00";
        e10.innerText = bto_scale(t * -1, 2);
      }
    }
    _calcAll();
  }
}
function _init() {
  var ipts = document.all.tags("INPUT");
  for(var i=0;i<ipts.length;i++) {
    ipts[i].attachEvent("onchange",_calc);
  }
}

_init();
</script>