<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=GBK">
  <link rel="stylesheet" type="text/css" href="fb_client.css">
</head>

<script>
function matchRate0(rate) {
  var result = new Array();
  if(rate <= 0.05) {
    result[0] = "0.05";
    result[1] = "0.00";
  } else if(rate <= 0.10) {
    result[0] = "0.10";
    result[1] = "25.00";
  } else if(rate <= 0.15) {
    result[0] = "0.15";
    result[1] = "125.00";
  } else if(rate <= 0.20) {
    result[0] = "0.20";
    result[1] = "375.00";
  } else if(rate <= 0.25) {
    result[0] = "0.25";
    result[1] = "1375.00";
  } else if(rate <= 0.30) {
    result[0] = "0.30";
    result[1] = "3375.00";
  } else if(rate <= 0.35) {
    result[0] = "0.35";
    result[1] = "6375.00";
  } else if(rate <= 0.40) {
    result[0] = "0.40";
    result[1] = "10375.00";
  } else {
    result[0] = "0.45";
    result[1] = "15375.00";
  }
  return result;
}

function matchRate1(rate) {
  var result = new Array();
  if(rate <= 0.03) {
    result[0] = "0.03";
    result[1] = "0.00";
  }else if(rate <= 0.10) {
    result[0] = "0.10";
    result[1] = "105.00";
  }else if(rate <= 0.20) {
    result[0] = "0.20";
    result[1] = "555.00";
  }else if(rate <= 0.25) {
    result[0] = "0.25";
    result[1] = "1005.00";
  }else if(rate <= 0.30) {
    result[0] = "0.30";
    result[1] = "2755.00";
  }else if(rate <= 0.35) {
    result[0] = "0.35";
    result[1] = "5505.00";
  }else {
    result[0] = "0.45";
    result[1] = "13505.00";
  }
  return result;
}

function calc(em_id) {
  var row = em_id.split("_")[1];

  var name = document.getElementById("name_" + row);
  if(name.value == "") return;

  var article = document.getElementById("article_" + row);
  var begin = document.getElementById("begin_" + row);
  var end = document.getElementById("end_" + row);

  var income = document.getElementById("income_" + row);
  var levyFreeLimit = document.getElementById("levyFreeLimit_" + row);
  var currentIncome = document.getElementById("currentIncome_" + row);
  var taxFreeIncome = document.getElementById("taxFreeIncome_" + row);

  var pension = document.getElementById("pension_" + row);
  var medical = document.getElementById("medical_" + row);
  var unemployment = document.getElementById("unemployment_" + row);
  var housingFund = document.getElementById("housingFund_" + row);
  var annuity = document.getElementById("annuity_" + row);
  var insurance = document.getElementById("insurance_" + row);
  var otherDeduction = document.getElementById("otherDeduction_" + row);
  var totalDeduction = document.getElementById("totalDeduction_" + row);

  var levyFreeIncome = document.getElementById("levyFreeIncome_" + row);
  var levyPoint = document.getElementById("levyPoint_" + row);
  var donations = document.getElementById("donations_" + row);
  var currentTaxableIncome = document.getElementById("currentTaxableIncome_" + row);
  var periods = document.getElementById("periods_" + row);
  var averageTaxableIncome = document.getElementById("averageTaxableIncome_" + row);
  var taxableIncome = document.getElementById("taxableIncome_" + row);
  var taxRate = document.getElementById("taxRate_" + row);
  var quickDeduction = document.getElementById("quickDeduction_" + row);
  var calcTax = document.getElementById("calcTax_" + row);
  var reliefTax = document.getElementById("reliefTax_" + row);
  var payedTax = document.getElementById("payedTax_" + row);
  var finalTax = document.getElementById("finalTax_" + row);

  if(article.value == "001") {
    makeWrite(income);
    makeRead(levyFreeLimit);
    makeRead(currentIncome);
    makeRead(taxFreeIncome);
    makeRead(pension);
    makeRead(medical);
    makeRead(unemployment);
    makeRead(housingFund);
    makeRead(otherDeduction);
    autoBlank(totalDeduction);
    makeRead(levyFreeIncome);
    makeWrite(levyPoint);
    makeWrite(donations);
    autoBlank(currentTaxableIncome);
    makeRead(periods);periods.value = "12";
    averageTaxableIncome.value = autoZero(bto_scale((income.value - levyPoint.value - donations.value) / periods.value, 2));
    taxableIncome.value = autoZero(bto_scale(income.value - levyPoint.value - donations.value, 2));
    taxRate.value = getRate1(averageTaxableIncome.value)[0];
    quickDeduction.value = getRate1(averageTaxableIncome.value)[1];
    calcTax.value = bto_scale(taxableIncome.value * taxRate.value - quickDeduction.value, 2);
  }else if(article.value == "002") {
    makeWrite(income);
    makeRead(levyFreeLimit);
    makeRead(currentIncome);
    makeWrite(taxFreeIncome);
    makeWrite(pension);
    makeWrite(medical);
    makeWrite(unemployment);
    makeWrite(housingFund);
    makeWrite(otherDeduction);
    totalDeduction.value = bto_scale(atof(pension.value) + atof(medical.value) + atof(unemployment.value) + atof(housingFund.value) + atof(annuity.value) + atof(insurance.value) + atof(otherDeduction.value), 2);
    makeRead(levyFreeIncome);
    makeWrite(levyPoint);
    makeWrite(donations);
    autoBlank(currentTaxableIncome);
    makeRead(periods);periods.value = atoi(end.value.substring(4,6)) - atoi(begin.value.substring(4,6)) + 1;
    averageTaxableIncome.value = autoZero(bto_scale((income.value - taxFreeIncome.value - totalDeduction.value - levyPoint.value - donations.value) / periods.value, 2));
    taxableIncome.value = autoZero(bto_scale(income.value - taxFreeIncome.value - totalDeduction.value - levyPoint.value - donations.value, 2));
    taxRate.value = getRate1(averageTaxableIncome.value)[0];
    quickDeduction.value = getRate1(averageTaxableIncome.value)[1];
    calcTax.value = bto_scale((averageTaxableIncome.value * taxRate.value - quickDeduction.value) * periods.value, 2);
  }else if(article.value == "003") {
    makeWrite(income);
    makeRead(levyFreeLimit);
    makeWrite(currentIncome);
    makeWrite(taxFreeIncome);
    makeWrite(pension);
    makeWrite(medical);
    makeWrite(unemployment);
    makeWrite(housingFund);
    makeWrite(otherDeduction);
    totalDeduction.value = bto_scale(atof(pension.value) + atof(medical.value) + atof(unemployment.value) + atof(housingFund.value) + atof(annuity.value) + atof(insurance.value) + atof(otherDeduction.value), 2);
    makeRead(levyFreeIncome);
    makeRead(levyPoint);levyPoint.value = "3500.00";
    makeWrite(donations);
    autoBlank(currentTaxableIncome);
    makeWrite(periods);if(atoi(periods.value) == 0) periods.value = "1";
    averageTaxableIncome.value = autoZero(bto_scale(income.value / periods.value + atof(currentIncome.value) - taxFreeIncome.value - totalDeduction.value - levyPoint.value - donations.value, 2));
    taxableIncome.value = autoZero(bto_scale(atof(income.value) + atof(currentIncome.value) - taxFreeIncome.value - totalDeduction.value - levyPoint.value - donations.value, 2));if(atoi(averageTaxableIncome.value) == 0) taxableIncome.value = "0.00";
    taxRate.value = getRate1(averageTaxableIncome.value)[0];
    quickDeduction.value = getRate1(averageTaxableIncome.value)[1];
    calcTax.value = bto_scale(taxableIncome.value * taxRate.value - quickDeduction.value, 2);
  }else if(article.value == "004") {
    makeWrite(income);
    makeWrite(levyFreeLimit);
    makeRead(currentIncome);
    makeWrite(taxFreeIncome);
    makeWrite(pension);
    makeWrite(medical);
    makeWrite(unemployment);
    makeWrite(housingFund);
    makeWrite(otherDeduction);
    totalDeduction.value = bto_scale(atof(pension.value) + atof(medical.value) + atof(unemployment.value) + atof(housingFund.value) + atof(annuity.value) + atof(insurance.value) + atof(otherDeduction.value), 2);
    makeRead(levyFreeIncome);
    makeRead(levyPoint);levyPoint.value = "3500.00";
    makeWrite(donations);
    autoBlank(currentTaxableIncome);
    makeWrite(periods);if(atoi(periods.value) == 0) periods.value = "1";
    averageTaxableIncome.value = autoZero(bto_scale((income.value - 3 * levyFreeLimit.value - taxFreeIncome.value - totalDeduction.value - donations.value) / periods.value - levyPoint.value, 2));
    taxableIncome.value = bto_scale(averageTaxableIncome.value * periods.value, 2);
    taxRate.value = getRate1(averageTaxableIncome.value)[0];
    quickDeduction.value = getRate1(averageTaxableIncome.value)[1];
    calcTax.value = bto_scale((averageTaxableIncome.value * taxRate.value - quickDeduction.value) * periods.value, 2);
  }else if(article.value == "005" || article.value == "102" || article.value == "103") {
    makeWrite(income);
    makeRead(levyFreeLimit);
    makeRead(currentIncome);
    makeRead(taxFreeIncome);
    makeRead(pension);
    makeRead(medical);
    makeRead(unemployment);
    makeRead(housingFund);
    makeRead(otherDeduction);
    autoBlank(totalDeduction);
    makeRead(levyFreeIncome);
    makeRead(levyPoint);
    makeRead(donations);
    autoBlank(currentTaxableIncome);
    makeWrite(periods);if(atoi(periods.value) == 0) periods.value = "1";
    averageTaxableIncome.value = autoZero(bto_scale(income.value / periods.value, 2));
    taxableIncome.value = autoZero(income.value);
    taxRate.value = getRate1(averageTaxableIncome.value)[0];
    quickDeduction.value = getRate1(averageTaxableIncome.value)[1];
    calcTax.value = bto_scale((averageTaxableIncome.value * taxRate.value - quickDeduction.value) * periods.value, 2);
  }else if(article.value == "010") {
    makeWrite(income);
    makeRead(levyFreeLimit);
    makeWrite(currentIncome);
    makeWrite(taxFreeIncome);
    makeWrite(pension);
    makeWrite(medical);
    makeWrite(unemployment);
    makeWrite(housingFund);
    makeWrite(otherDeduction);
    totalDeduction.value = bto_scale(atof(pension.value) + atof(medical.value) + atof(unemployment.value) + atof(housingFund.value) + atof(annuity.value) + atof(insurance.value) + atof(otherDeduction.value), 2);
    makeRead(levyFreeIncome);
    makeRead(levyPoint);levyPoint.value = "3500.00";
    makeWrite(donations);
    autoBlank(currentTaxableIncome);
    makeRead(periods);
    autoBlank(averageTaxableIncome);
    taxableIncome.value = autoZero(bto_scale(Math.min(income.value, atof(income.value) + atof(currentIncome.value) - taxFreeIncome.value - totalDeduction.value - levyPoint.value - donations.value), 2));
    taxRate.value = getRate1(taxableIncome.value)[0];
    quickDeduction.value = getRate1(taxableIncome.value)[1];
    calcTax.value = bto_scale(taxableIncome.value * taxRate.value - quickDeduction.value, 2);
  }else if(article.value == "011") {
    makeWrite(income);
    makeRead(levyFreeLimit);
    makeRead(currentIncome);
    makeRead(taxFreeIncome);
    makeRead(pension);
    makeRead(medical);
    makeRead(unemployment);
    makeRead(housingFund);
    makeRead(otherDeduction);
    autoBlank(totalDeduction);
    makeRead(levyFreeIncome);
    makeRead(levyPoint);
    makeRead(donations);
    autoBlank(currentTaxableIncome);
    makeRead(periods);
    autoBlank(averageTaxableIncome);
    taxableIncome.value = autoZero(income.value);
    makeWrite(taxRate);taxRate.value = matchRate1(taxRate.value)[0];
    quickDeduction.value = matchRate1(taxRate.value)[1];
    calcTax.value = bto_scale(taxableIncome.value * taxRate.value - quickDeduction.value, 2);
  }else if(article.value == "013") {
    makeWrite(income);
    makeRead(levyFreeLimit);
    makeRead(currentIncome);
    makeRead(taxFreeIncome);
    makeRead(pension);
    makeRead(medical);
    makeRead(unemployment);
    makeRead(housingFund);
    makeRead(otherDeduction);
    autoBlank(totalDeduction);
    makeRead(levyFreeIncome);
    makeRead(levyPoint);
    makeRead(donations);
    autoBlank(currentTaxableIncome);
    makeRead(periods);
    autoBlank(averageTaxableIncome);
    taxableIncome.value = autoZero(income.value);
    makeWrite(taxRate);taxRate.value = matchRate0(taxRate.value)[0];
    quickDeduction.value = matchRate0(taxRate.value)[1];
    calcTax.value = bto_scale(taxableIncome.value * taxRate.value - quickDeduction.value, 2);
  }else if(article.value == "012") {
    makeWrite(income);
    makeRead(levyFreeLimit);
    makeRead(currentIncome);
    makeWrite(taxFreeIncome);
    makeWrite(pension);
    makeWrite(medical);
    makeWrite(unemployment);
    makeWrite(housingFund);
    makeWrite(otherDeduction);
    totalDeduction.value = bto_scale(atof(pension.value) + atof(medical.value) + atof(unemployment.value) + atof(housingFund.value) + atof(annuity.value) + atof(insurance.value) + atof(otherDeduction.value), 2);
    makeRead(levyFreeIncome);
    makeRead(levyPoint);levyPoint.value = "3500.00";
    makeWrite(donations);
    autoBlank(currentTaxableIncome);
    makeWrite(periods);if(atoi(periods.value) == 0) periods.value = "1";
    averageTaxableIncome.value = autoZero(bto_scale(income.value / periods.value - taxFreeIncome.value - totalDeduction.value - levyPoint.value - donations.value, 2));
    taxableIncome.value = autoZero(bto_scale(income.value - taxFreeIncome.value - totalDeduction.value - levyPoint.value - donations.value, 2));
    taxRate.value = getRate1(averageTaxableIncome.value)[0];
    quickDeduction.value = getRate1(averageTaxableIncome.value)[1];
    calcTax.value = bto_scale((averageTaxableIncome.value * taxRate.value - quickDeduction.value) * periods.value, 2);
  }
  autoFloat(reliefTax);
  autoFloat(payedTax);

  finalTax.value = bto_scale(calcTax.value - reliefTax.value - payedTax.value, 2);

  if(finalTax.value < 0 && article.value != "002") finalTax.value = "0.00";

  if(finalTax.value < 1 && finalTax.value > 0) finalTax.value = "0.00";
}

function default_text(field, article) {
  if(field == "name") return "";

  if(field == "codeType") return "06";

  if(field == "code") return "";

  if(field == "country") return "156";

  if(field == "preferential") return "0";

  if(field == "employee") return "1";

  if(field == "phone") return "";

  if(field == "email") return "";

  if(field == "address") return "";

  if(field == "company") return "";

  if(field == "article") return "001";

  if(field == "begin") {
    if(article == "001" || article == "002" || article == "003" || article == "004") return getYearB();
    else return getLastMonthB();
  }

  if(field == "end") {
    if(article == "001" || article == "002" || article == "003" || article == "004") return getYearE();
    else return getLastMonthE();
  }

  if(field == "remark") return "";

  return "0.00";
}

function help_text(field, article) {
  if(field == "name") return "纳税人身份证件上面的名称，请如实填写。";

  if(field == "codeType") return "[01 - 护照]、[02 - 通行证]、[03 - 回乡证]、[04 - 台胞证]、[05 - 旅行证]、[06 - 身份证]、[07 - 军官证]、<br>[08 - 税务管理码]、[09 - 特殊类别]、[10 - 纳税人识别号]、[11 - 士兵证]、[90 - 其他]";

  if(field == "code") return "纳税人身份证件上面的号码，请如实填写。";

  if(field == "country") return "[156 - 中国]";

  if(field == "preferential") return "不是残疾烈属孤老请填0，是残疾烈属孤老请填1。";

  if(field == "employee") return "不是雇员请填0，是雇员请填1。";

  if(field == "email") return "雇员请如实填写。";

  if(field == "address") return "非雇员请如实填写。";

  if(field == "company") return "非雇员请如实填写。";

  if(field == "article") return "[001 - 全年一次性奖金]、[002 - 特定行业]、[003 - 内退一次性补偿]、[004 - 一次性解除劳动合同]<br>[005 - 股票期权计算]、[009 - 外籍个人申报以前月份]、[012 - 提前退休一次性补贴]<br>[102 - 股票增值权计算]、[103 - 限制性股票计算]、[105 - 境内无住所个人取得数月奖金]。";

  if(field == "begin" || field == "end") return "请按yyyyMMdd日期格式，如实填写。";

  if(field == "status") return "自动生成。";

  if(field == "totalDeduction") return "自动计算。";

  if(field == "income" || field == "levyFreeLimit" || field == "currentIncome" || field == "taxFreeIncome" || field == "pension" || field == "medical" || field == "unemployment" ||
     field == "housingFund" || field == "otherDeduction" || field == "currentTaxableIncome" || field == "levyFreeIncome" || field == "levyPoint" || field == "donations" ||
     field == "currentTaxableIncome" || field == "periods" || field == "averageTaxableIncome" || field == "taxableIncome" || field == "taxRate" || field == "quickDeduction" || field == "calcTax") {
    if(article == "001") {
      if(field == "income") return "一次性发放的奖金数，请如实填写。";
      if(field == "levyPoint") return "当月工资薪金所得与费用扣除额的差额，应介于0～4800之间，请如实填写。";
      if(field == "donations") return "请如实填写。";
      if(field == "periods") return "默认为12，不允许修改。";
      if(field == "averageTaxableIncome") return "AC=(N-Y-Z)/AB，自动计算。"
      if(field == "taxableIncome") return "AD=N-Y-Z，自动计算。"
      if(field == "taxRate") return "根据AC，自动取值。"
      if(field == "quickDeduction") return "根据AC，自动取值。"
      if(field == "calcTax") return "AG=AD*AE-AF，自动计算。"
    }else if(article == "002") {
      if(field == "income") return "全年工薪所得，请如实填写。";
      if(field == "taxFreeIncome" || field == "pension" || field == "medical" || field == "unemployment" || field == "housingFund" ||
         field == "otherDeduction" || field == "levyPoint" || field == "donations") return "全年合计数，请如实填写。";
      if(field == "periods") return "根据所得起始日期和所得终止日期，自动计算。";
      if(field == "averageTaxableIncome") return "AC=(N-Q-W-Y-Z)/AB，自动计算。"
      if(field == "taxableIncome") return "AD=N-Q-W-Y-Z，自动计算。"
      if(field == "taxRate") return "根据AC，自动取值。"
      if(field == "quickDeduction") return "根据AC，自动取值。"
      if(field == "calcTax") return "AG=(AC*AE-AF)*AB，自动计算。"
    }else if(article == "003") {
      if(field == "income") return "办理内退手续后从原任职单位取得的一次性收入，请如实填写。";
      if(field == "currentIncome") return "领取当月的工资、薪金所得，请如实填写。";
      if(field == "levyPoint") return "默认为3500，不允许修改。";
      if(field == "taxFreeIncome" || field == "pension" || field == "medical" || field == "unemployment" || field == "housingFund" ||
         field == "otherDeduction" || field == "donations") return "领取当月的发生数，请如实填写。";
      if(field == "periods") return "分摊月份数，请如实填写。";
      if(field == "averageTaxableIncome") return "AC=N/AB+P-Q-W-Y-Z，自动计算。"
      if(field == "taxableIncome") return "AD=N+P-Q-W-Y-Z，自动计算。"
      if(field == "taxRate") return "根据AC，自动取值。"
      if(field == "quickDeduction") return "根据AC，自动取值。"
      if(field == "calcTax") return "AG=AD*AE-AF，自动计算。"
    }else if(article == "004") {
      if(field == "income") return "因解除劳动合同而取得的一次性经济补偿收入，请如实填写。";
      if(field == "levyFreeLimit") return "本市上年企业职工平均工资，请如实填写。";
      if(field == "levyPoint") return "默认为3500，不允许修改。";
      if(field == "taxFreeIncome" || field == "pension" || field == "medical" || field == "unemployment" || field == "housingFund" ||
         field == "otherDeduction" || field == "donations") return "实际发生数，请如实填写。";
      if(field == "periods") return "工作年限数，0～12之间，请如实填写。";
      if(field == "averageTaxableIncome") return "AC=(N-3*O-Q-W-Z)/AB-Y，自动计算。"
      if(field == "taxableIncome") return "AD=AC*AB，自动计算。"
      if(field == "taxRate") return "根据AC，自动取值。"
      if(field == "quickDeduction") return "根据AC，自动取值。"
      if(field == "calcTax") return "AG=(AC*AE-AF)*AB，自动计算。"
    }else if(article == "005") {
      if(field == "income") return "股票期权形式的工资、薪金所得，请如实填写。";
      if(field == "periods") return "境内工作期间月份数，0～12之间，请如实填写。";
      if(field == "averageTaxableIncome") return "AC=N/AB，自动计算。"
      if(field == "taxableIncome") return "AD=N，自动计算。"
      if(field == "taxRate") return "根据AC，自动取值。"
      if(field == "quickDeduction") return "根据AC，自动取值。"
      if(field == "calcTax") return "AG=(AC*AE-AF)*AB，自动计算。"
    }else if(article == "102") {
      if(field == "income") return "股票增值权形式的工资、薪金所得，请如实填写。";
      if(field == "periods") return "境内工作期间月份数，0～12之间，请如实填写。";
      if(field == "averageTaxableIncome") return "AC=N/AB，自动计算。"
      if(field == "taxableIncome") return "AD=N，自动计算。"
      if(field == "taxRate") return "根据AC，自动取值。"
      if(field == "quickDeduction") return "根据AC，自动取值。"
      if(field == "calcTax") return "AG=(AC*AE-AF)*AB，自动计算。"
    }else if(article == "103") {
      if(field == "income") return "限制性股票形式的工资、薪金所得，请如实填写。";
      if(field == "periods") return "境内工作期间月份数，0～12之间，请如实填写。";
      if(field == "averageTaxableIncome") return "AC=N/AB，自动计算。"
      if(field == "taxableIncome") return "AD=N，自动计算。"
      if(field == "taxRate") return "根据AC，自动取值。"
      if(field == "quickDeduction") return "根据AC，自动取值。"
      if(field == "calcTax") return "AG=(AC*AE-AF)*AB，自动计算。"
    }else if(article == "010") {
      if(field == "income") return "企业缴纳计入个人账户的企业年金，请如实填写。";
      if(field == "levyPoint") return "默认为3500，不允许修改。";
      if(field == "currentIncome" || field == "taxFreeIncome" || field == "pension" || field == "medical" || field == "unemployment" || field == "housingFund" ||
         field == "otherDeduction" || field == "donations") return "请如实填写。";
      if(field == "taxableIncome") return "如果P-Q-W-Y-Z≥0，AD=N，否则AD=N+P-Q-W-Y-Z，自动计算。"
      if(field == "taxRate") return "根据AD，自动取值。"
      if(field == "quickDeduction") return "根据AD，自动取值。"
      if(field == "calcTax") return "AG=AD*AE-AF，自动计算。"
    }else if(article == "011" || article == "013") {
      if(field == "income") return "企业以前年度缴纳的未扣缴税款的企业年金，请如实填写。";
      if(field == "taxableIncome") return "AD=N，自动计算。"
      if(field == "taxRate") return "手工填写，必须符合工资、薪金税率表。"
      if(field == "quickDeduction") return "根据AE，自动取值。"
      if(field == "calcTax") return "AG=AD*AE-AF，自动计算。"
    }else if(article == "012") {
      if(field == "income") return "提前退休取得的一次性补贴，请如实填写。";
      if(field == "levyPoint") return "默认为3500，不允许修改。";
      if(field == "taxFreeIncome" || field == "pension" || field == "medical" || field == "unemployment" || field == "housingFund" ||
         field == "otherDeduction" || field == "donations") return "请如实填写。";
      if(field == "periods") return "分摊月份数，请如实填写。";
      if(field == "averageTaxableIncome") return "AC=N/AB-Q-W-Y-Z，自动计算。"
      if(field == "taxableIncome") return "AD=N-Q-W-Y-Z，自动计算。"
      if(field == "taxRate") return "根据AC，自动取值。"
      if(field == "quickDeduction") return "根据AC，自动取值。"
      if(field == "calcTax") return "AG=(AC*AE-AF)*AB，自动计算。"
    }
    return "无需填写。";
  }

  if(field == "finalTax") return "自动计算。"

  return "请如实填写。";
}

function del_new(em) {
  var row = em.id.split("_")[1];
  var s = document.getElementById("statusC_" + row);
  if(s.value == "") return;
  
  var flag;
  if(s.value.substring(0,1) == "-") {
    s.value = s.value.substring(1,s.value.length);
    flag = false;
    document.getElementById("del_" + row).innerText = "删除";
  } else {
    s.value = "-" + s.value;
    flag = true;
    document.getElementById("del_" + row).innerText = "恢复";
  }
  var ips = em.parentElement.parentElement.all.tags("input");
  for(var i=1;i<ips.length;i++) {
    ips[i].disabled = flag;
  }
}

function del(em) {
  var ips = em.parentElement.parentElement.all.tags("input");
  for(var i=1;i<ips.length;i++) {
    ips[i].value = "";
  }
}

function _del() {
  if(document.getElementById("flag3").value != "0") {
    var d = document.getElementById("del_" + document.getElementById("flag3").value);
    var r = document.getElementById("row_" + document.getElementById("flag3").value);
    r.value = "";
    del(d);
  }
}

function __valid() {  
  if(document.getElementById("flag2").value != "0") {
    var ips = document.all.tags("input");
    for(var i=1;i<ips.length;i++) {
      if(ips[i].disabled) {
        ips[i].disabled = false;
      }
    }
    ips = document.all.tags("button");
    for(var i=1;i<ips.length;i++) {
      if(ips[i].innerText == "恢复") {
        ips[i].innerText = "删除"
      }
    }
    for(var i=1;i<=20;i++){
      var s = document.getElementById("statusC_"+i);
      if(s.value != "" && s.value != "0"){
        document.getElementById("status_"+i).style.color = "red";
        document.getElementById("name_" + i).style.color = "red";
      }else{
        document.getElementById("name_" + i).style.color = "black";
      }
    } 
  }
}
</script>
<body>
<input type="hidden" id="flag2" value="0" onpropertychange="__valid()">
<input type="hidden" id="flag3" value="0" onpropertychange="_del()">
<input type="hidden" id="reportType" value="0">
<div style="border:1px solid gray;padding:2px">
<div align="center" class="title">个 人 所 得 税 申 报 （ 特 殊 算 法 明 细 数 据 ）（ 税 优 型 商 业 险 试 点 单 位 适 用 ）</div>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td style="padding:6px 0px 6px 0px;">
      <button onclick="WebBrowser.ExecWB(6,1)">打 印</button>&nbsp;
      <button onclick="WebBrowser.ExecWB(7,1)">打印预览</button>&nbsp;
      <button onclick="WebBrowser.ExecWB(8,1)">打印设置</button>&nbsp;
      <span>
        缩放比例：
        <select id="bodySize" onchange="changeBodySize(this)">
          <option value="1.00">100%</option>
          <option value="0.80">80%</option>
          <option value="0.70">70%</option>
          <option value="0.50">50%</option>
          <option value="0.40">40%</option>
          <option value="0.35">35%</option>
          <option value="0.30">30%</option>
        </select>
      </span>
    </td>
    <td align="left">编制单位：<input id="cname" style="width:320px;text-align:left" readonly></td>
    <td align="right">金额单位：元（列至角分）</td>
  </tr>
</table>
<table cellspacing="0" cellpadding="0" style="border-collapse:collapse" border="1" bordercolor="gray" id="main">
  <tr class="bg1" valign="bottom">
    <th rowspan="2" nowrap>&nbsp;序号&nbsp;<br><br><br><br></th>
    <th rowspan="2" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;姓名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br>A</th>
    <th rowspan="2" nowrap>证<br>件<br>类<br>型<br>B</th>
    <th rowspan="2" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;证件号码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br>C</th>
    <th rowspan="2" nowrap>国家<br>或<br>地区<br>代码<br>D</th>
    <th rowspan="2" nowrap>是否<br>残疾<br>烈属<br>孤老<br>E</th>
    <th rowspan="2" nowrap>是<br>否<br>雇<br>员<br>F</th>
    <th rowspan="2" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;电话&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br>G</th>
    <th rowspan="2" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;电子邮箱&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br>H</th>
    <th rowspan="2" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;联系地址&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br>I</th>
    <th rowspan="2" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;工作单位&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><br>J</th>
    <th rowspan="2" nowrap>所得<br>项目<br>代码<br>K</th>
    <th rowspan="2" nowrap>所得起始<br>日期<br><br>L</th>
    <th rowspan="2" nowrap>所得终止<br>日期<br><br>M</th>
    <th rowspan="2" nowrap>全年工薪所得<br>（一次性奖金、补偿、年金等）<br><br>N</th>
    <th rowspan="2" nowrap>&nbsp;免征额&nbsp;<br><br><br>O</th>
    <th rowspan="2" nowrap>当月工薪所得<br><br><br>P</th>
    <th rowspan="2" nowrap>&nbsp;&nbsp;免税&nbsp;&nbsp;<br>所得<br><br>Q</th>
    <th colspan="8" nowrap>税前扣除项目</th>
    <th rowspan="2" nowrap>&nbsp;不征税&nbsp;<br>所得<br><br>Z</th>
    <th rowspan="2" nowrap>减除费用<br>（补差）<br><br>AA</th>
    <th rowspan="2" nowrap>准予扣除<br>的捐赠额<br><br>AB</th> 
    <th rowspan="2" nowrap>当月<br>应纳税所得额<br><br>AC</th> 
    <th rowspan="2" nowrap>分摊<br>月份<br>（年限）<br>AD</th>
    <th rowspan="2" nowrap>月平均<br>应纳税所得额<br><br>AE</th>
    <th rowspan="2" nowrap>应纳税所得额<br><br><br>AF</th>
    <th rowspan="2" nowrap>&nbsp;适用&nbsp;<br>税率<br><br>AG</th>
    <th rowspan="2" nowrap>速算<br>&nbsp;扣除数&nbsp;<br><br>AH</th>
    <th rowspan="2" nowrap>年（月）应扣缴<br>税额<br><br>AI</th>
    <th rowspan="2" nowrap>&nbsp;&nbsp;&nbsp;&nbsp;减免&nbsp;&nbsp;&nbsp;&nbsp;<br>税额<br><br>AJ</th>
    <th rowspan="2" nowrap>&nbsp;&nbsp;&nbsp;已预缴&nbsp;&nbsp;&nbsp;<br>税额<br><br>AK</th>
    <th rowspan="2" nowrap>&nbsp;应补（退）&nbsp;<br>税额<br><br>AL=AI-AJ-AK</th>
    <th rowspan="2" nowrap style="width:160px;">备注<br><br><br>AM</th>
    <th rowspan="2" nowrap style="width:320px;">审核<a name="_valid_"></a><br><br><br><br></th>
    <th rowspan="2" nowrap valign="center">操作</th>
  </tr>
  <tr class="bg1" valign="bottom">
    <th nowrap>基本养老<br>保险费<br>R</th>
    <th nowrap>基本医疗<br>保险费<br>S</th>
    <th nowrap>&nbsp;&nbsp;失业&nbsp;&nbsp;<br>保险费<br>T</th>
    <th nowrap>&nbsp;&nbsp;住房&nbsp;&nbsp;<br>公积金<br>U</th>
    <th nowrap>&nbsp;&nbsp;年金&nbsp;&nbsp;<br><br>V</th>
    <th nowrap>&nbsp;税优型商业险&nbsp;<br><br>W</th>
    <th nowrap>&nbsp;&nbsp;其他&nbsp;&nbsp;<br><br>X</th>
    <th nowrap>&nbsp;&nbsp;合计&nbsp;&nbsp;<br><br>Y</th>
  </tr>
  <script>
    for(var i=1;i<=20;i++) {
      document.write("<tr>");
      document.write("<td><input             id='row_" + i +"'  value='" + i +"' style='text-align:center' readonly></td>");
      document.write("<td><input             id='name_" + i +"'                 maxlength='32'></td>");
      document.write("<td><input             id='codeType_" + i +"'             maxlength='2'  class='acenter'></td>");
      document.write("<td><input             id='code_" + i +"'                 maxlength='18'></td>");
      document.write("<td><input             id='country_" + i +"'              maxlength='3'  class='acenter'></td>");
      document.write("<td><input             id='preferential_" + i +"'         maxlength='1'  class='acenter'></td>");
      document.write("<td><input             id='employee_" + i +"'             maxlength='1'  class='acenter'></td>");
      document.write("<td><input             id='phone_" + i +"'                maxlength='20'></td>");
      document.write("<td><input             id='email_" + i +"'                maxlength='40'></td>");
      document.write("<td><input             id='address_" + i +"'              maxlength='100'></td>");
      document.write("<td><input             id='company_" + i +"'              maxlength='24'></td>");
      document.write("<td><input             id='article_" + i +"'              maxlength='3'  class='acenter'></td>");
      document.write("<td><input             id='begin_" + i +"'                maxlength='8'  class='acenter'></td>");
      document.write("<td><input             id='end_" + i +"'                  maxlength='8'  class='acenter'></td>");
      document.write("<td><input             id='income_" + i +"'               maxlength='12' class='aright'></td>");
      document.write("<td><input             id='levyFreeLimit_" + i +"'        maxlength='12' class='aright'></td>");
      document.write("<td><input             id='currentIncome_" + i +"'        maxlength='12' class='aright'></td>");
      document.write("<td><input             id='taxFreeIncome_" + i +"'        maxlength='12' class='aright'></td>");
      document.write("<td><input             id='pension_" + i +"'              maxlength='8'  class='aright'></td>");
      document.write("<td><input             id='medical_" + i +"'              maxlength='8'  class='aright'></td>");
      document.write("<td><input             id='unemployment_" + i +"'         maxlength='8'  class='aright'></td>");
      document.write("<td><input             id='housingFund_" + i +"'          maxlength='8'  class='aright'></td>");
      document.write("<td><input             id='annuity_" + i +"'        maxlength='8'  class='aright'></td>");
      document.write("<td><input class='ins' id='insurance_" + i +"'      maxlength='8'  class='aright' readonly>&nbsp;<button id='show_insurance_" + i +"' class='btn' onclick='show_insurance();'>明细</button><button id='save_insurance_" + i +"' class='btn2 none' onclick='save_insurance();'>保存</button></td>");
      document.write("<td><input             id='otherDeduction_" + i +"'       maxlength='8'  class='aright'></td>");
      document.write("<td class='bg1'><input id='totalDeduction_" + i +"'                      class='aright bg1' readonly></td>");
      document.write("<td><input             id='levyFreeIncome_" + i +"'       maxlength='8'  class='aright'></td>");
      document.write("<td><input             id='levyPoint_" + i +"'            maxlength='8'  class='aright'></td>");
      document.write("<td><input             id='donations_" + i +"'            maxlength='8'  class='aright'></td>");
      document.write("<td class='bg1'><input id='currentTaxableIncome_" + i +"'                class='aright bg1' readonly></td>");
      document.write("<td><input             id='periods_" + i +"'              maxlength='3'  class='aright'></td>");
      document.write("<td class='bg1'><input id='averageTaxableIncome_" + i +"'                class='aright bg1' readonly></td>");
      document.write("<td class='bg1'><input id='taxableIncome_" + i +"'                       class='aright bg1' readonly></td>");
      document.write("<td><input             id='taxRate_" + i +"'              maxlength='4'  class='aright'></td>");
      document.write("<td><input             id='quickDeduction_" + i +"'       maxlength='8'  class='aright'></td>");
      document.write("<td class='bg1'><input id='calcTax_" + i +"'                             class='aright bg1' readonly></td>");
      document.write("<td><input             id='reliefTax_" + i +"'            maxlength='12' class='aright'></td>");
      document.write("<td><input             id='payedTax_" + i +"'             maxlength='12' class='aright'></td>");
      document.write("<td class='bg1'><input id='finalTax_" + i +"'                            class='aright bg1' readonly></td>");
      document.write("<td><input             id='remark_" + i +"'               maxlength='18'></td>");
      document.write("<td class='bg1'><input id='status_" + i +"'  class='bg1'  readonly style='color:red;'>");
      document.write("                <input id='statusC_" + i +"' type='hidden' value='0'></td>");
      document.write("<td><button            id='del_" + i +"'         onclick='del_new(this)' class='btn'>删除</button></td>");
      document.write("</tr>");
    }
  </script>
</table>
<table border="0" width="100%">
  <tr>
    <td style="padding-top:4px">
      <span style="width:99px"><span id="ss1">共0条记录</span></span>
      <span style="width:50px">第<span id="ss2">1</span>页</span>
      <span style="width:50px">共<span id="ss3">1</span>页</span>
      &nbsp;<button id="b1">首页</button>
      &nbsp;<button id="b2">上页</button>
      &nbsp;<button id="b3">下页</button>
      &nbsp;<button id="b4">尾页</button>
      &nbsp;<button id="b6">转至</button>
      &nbsp;<input  id="ppp" style="width:40px;border:1px solid gray">&nbsp;页
      &nbsp;&nbsp;<button id="b11">分项汇总</button>
      &nbsp;&nbsp;<button id="b5">显示全部</button>
      &nbsp;&nbsp;<button onclick="_valid();document.body.scrollLeft=10000;">校验本页</button>
      &nbsp;&nbsp;<button id="b12">插入记录</button>
      &nbsp;&nbsp;<button onclick="help_html()">帮助手册</button>
      &nbsp;&nbsp;<button id="b9">设置单位</button>
      &nbsp;&nbsp;<button id="b10">模糊查询</button>
    </td>
  </tr>
</table>
</div>
<script src="fb_client.js"></script>
</body>
</html>
