function NskCalc(){this.groupType=0;this.regCount=0;this.accountType=0;this.monConsump=0;this.benefitType=0;this.benefitCount=0;this.dayTariff=0;this.nightTariff=0;this.tariffes=new Array();this.tariffes[0]={single_base:210,single_base_ec:378,day_base:210,day_base_ec:378,night_base:105,night_base_ec:189};this.tariffes[1]={single_base:147,single_base_ec:265,day_base:147,day_base_ec:265,night_base:74,night_base_ec:133};this.tariffes[3]={single_base:147,single_base_ec:265,day_base:147,day_base_ec:265,night_base:74,night_base_ec:133}}NskCalc.prototype={calculate:function(){var c=0;var h=50;var g=this.regCount;var k=0;var e=this.monConsump;var i=0;var b=0;var r=0;var d=this.benefitCount;var m=0;var j=0;var a=this.dayTariff;var q=this.nightTariff;var n=0;var l=0;k=this.tariffes[this.groupType].single_base;i=this.tariffes[this.groupType].single_base_ec;m=this.tariffes[this.groupType].day_base;j=this.tariffes[this.groupType].night_base;n=this.tariffes[this.groupType].day_base_ec;l=this.tariffes[this.groupType].night_base_ec;var f={};var p=0;p=e-h*g;if(p<0){f.one=0}else{f.one=p}p=a-(h/2)*g;if(p<0){f.two=0}else{f.two=p}p=q-(h/2)*g;if(p<0){f.three=0}else{f.three=p}switch(this.accountType){case 1:if(e==0){c=0;break}if(g==0){c=e*i;break}switch(this.benefitType){case 0:if((h*d<e)&&(e<h*g)){c=o((h*d*k)/2,0)+(e-h*d)*k}else{if((h*d>=e)&&(e<h*g)){c=o((e*k)/2,0)}else{c=o((h*d*k)/2,0)+h*(g-d)*k+f.one*i}}break;case 1:if(e<h*g){c=o((e*k)/2,0)+o((f.one*i)/2,0)}else{c=o((h*g*k)/2,0)+o((f.one*i)/2,0)}break;case 2:if(e<h*g){c=e*k}else{c=h*g*k+f.one*i}break}break;case 2:if(g==0){b=a*n;r=q*l;c=b+r;break}switch(this.benefitType){case 0:if(a==0){b=0}else{if((h/2*d<=a)&&(a<h/2*g)){b=o(((h/2)*d*m)/2,0)+(a-(h/2)*d)*m}else{if((h/2*d>=a)&&(a<h/2*g)){b=o((a*m)/2,0)}else{b=o(((h/2)*d*m)/2,0)+(h/2)*(g-d)*m+f.two*n}}}if(q==0){r=0}else{if((h/2*d<=q)&&(q<h/2*g)){r=o(((h/2)*d*j)/2,0)+(q-(h/2)*d)*j}else{if((h/2*d>=q)&&(q<h/2*g)){r=o((q*j)/2,0)}else{r=o(((h/2)*d*j)/2,0)+(h/2)*(g-d)*j+f.three*l}}}break;case 1:if(a==0){b=0}else{if((h/2)*g>a){b=o((a*m)/2,0)+o((f.two*n)/2,0)}else{b=o(((h/2)*g*m)/2,0)+o((f.two*n)/2,0)}}if(q==0){r=0}else{if((h/2)*g>q){r=o((q*j)/2,0)+o((f.three*l)/2,0)}else{r=o(((h/2)*g*j)/2,0)+o((f.three*l)/2,0)}}break;case 2:if(a==0){b=0}else{if((h/2)*g>a){b=a*m+f.two*n}else{b=(h/2)*g*m+f.two*n}}if(q==0){r=0}else{if((h/2)*g>q){r=q*j+f.three*l}else{r=(h/2)*g*j+f.three*l}}break}break}if(this.accountType==2){c=(o(b,0)+o(r,0))/100;b=o(b,0)/100;r=o(r,0)/100}else{c=o(c,0)/100}c=c.toString().split(".");b=b.toString().split(".");r=r.toString().split(".");result={total_rub:c[0],total_kop:c[1]?c[1]:"00",day_rub:b[0],day_kop:b[1]?b[1]:"00",night_rub:r[0],night_kop:r[1]?r[1]:"00"};if(result.total_kop.toString().length==1){result.total_kop+="0"}if(result.day_kop.toString().length==1){result.day_kop+="0"}if(result.night_kop.toString().length==1){result.night_kop+="0"}return result;function o(t,s){if(typeof(s)=="undefined"){s=2}var v=0.00002;t+=v;t=t.toString();var u=t.indexOf(".");if(u>=0){t=t.substr(0,u+s+1)}return parseFloat(t)}}};