function svgplan_calculate(){var l,o,t=parseFloat(jQuery("#summa").val()),e=parseFloat(jQuery("#summa").val()),r=(l=jQuery("#vid0").is(":checked")?0:1,o="1var"==jQuery("#schitat-v").val()?parseFloat(jQuery("#srok").val()):12*parseFloat(jQuery("#srok").val()),parseFloat(jQuery("#stavka").val())/1200),u=(r.toFixed(4),parseInt(jQuery("#txtcal110_0").val().split("/")[1])),h=parseInt(jQuery("#txtcal110_0").val().split("/")[2]),e={summa:e,summa_first:t,srok:o,month_stavka:r,date:u,year:h,vid:l};$.ajax({type:"POST",url:window.location.origin+"/php/finansy/kredit/calc28.php",data:e,success:function(t){for(console.log(t),res=JSON.parse(t),window.year_list=[],i=h;i<=h+o/12;i++)window.year_list.push(i);(isNaN(u)||isNaN(h))&&(("0"+(t=new Date).getDate()).slice(-2),u=("0"+(t.getMonth()+1)).slice(-2),h=t.getFullYear(),jQuery("#txtcal111_0").val(t.getDate()+"/"+u+"/"+h)),new Date(h,u,33).getDate();var e=["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],r=[],a=u-1,s=["<table><tr><th>Месяц</th><th>Платеж</th><th>Долговая часть</th><th>Процентная часть</th><th>Остаток долга</th></tr>"];if(0==l){for(i=1;i<=o;i++)h+=Math.floor(a/12),r.push(e[(a=(a+1)%12==0?12:(a+1)%12)-1]+" "+h),s.push("<tr><th>"+e[a-1]+" "+h+"</th>"),s.push("<th>"+res.platezh_list[i-1].toFixed(2)+"</th>"),s.push("<th>"+res.dolg_part_list[i-1].toFixed(2)+"</th>"),s.push("<th>"+res.perc_part_list[i-1].toFixed(2)+"</th>"),s.push("<th>"+res.summa_list[i-1].toFixed(0)+"</th></tr>");jQuery("#rezultat-summa-e-m").val(res.platezh.toFixed(2)+" руб.")}else{for(i=1;i<=o;i++)h+=Math.floor(a/12),r.push(e[(a=(a+1)%12==0?12:(a+1)%12)-1]+" "+h),s.push("<tr><th>"+e[a-1]+" "+h+"</th>"),s.push("<th>"+res.platezh_list[i-1].toFixed(2)+"</th>"),s.push("<th>"+res.dolg_part_list[i-1].toFixed(2)+"</th>"),s.push("<th>"+res.perc_part_list[i-1].toFixed(2)+"</th>"),s.push("<th>"+res.summa_list[i-1].toFixed(0)+"</th></tr>");jQuery("#rezultat-summa-e-m").val(res.f_platezh.toFixed(2)+" .. "+res.l_platezh.toFixed(2)+" руб.")}jQuery("#rezultat-pereplata-po-pr").val(res.perc_part_sum.toFixed(2)+" руб."),jQuery("#rezultat-obshaya-summa-otdachi").val((res.summa_first+res.perc_part_sum).toFixed(2)+" руб."),s.push("</table>"),jQuery("#table").html(s.join("\n"))},error:function(t){console.log("Error. "+t.responseText)}})}jQuery(document).ready(function(){document.querySelectorAll(".rsform-input-box").forEach(function(t){t.addEventListener("input",function(){this.value=this.value.replace(/,/g,"."),this.value=this.value.replace(/[^0-9.]/g,""),this.value=this.value.replace(/(\..*?)\..*/g,"$1")})}),jQuery(".rsform-checkbox, .rsform-select-box, .rsform-radio").change(function(){svgplan_calculate()}),jQuery(".rsform-checkbox, .rsform-select-box, .rsform-input-box, .rsform-calendar-box, .rsform-radio").keyup(function(){svgplan_calculate()})});