((function(){var a=function(a,b){return function(){return a.apply(b,arguments)}};this.OrderForm=function(){function b(b){this.set_cost=a(this.set_cost,this),this.get_cost=a(this.get_cost,this),this.spinner=a(this.spinner,this),this.check_contact_info=a(this.check_contact_info,this),this.bind_contact_info_change=a(this.bind_contact_info_change,this),this.bind_popup_submit=a(this.bind_popup_submit,this),this.bind_submit=a(this.bind_submit,this),this.param=a(this.param,this),this.make_ui=a(this.make_ui,this),this.form=b,this.id=this.form.attr("id"),this.popup_form=$("#order-popup form"),this.contact_info=this.param("contact_info"),this.make_ui(),this.bind_submit(),this.bind_popup_submit(this.popup_form),this.bind_contact_info_change()}return b.prototype.make_ui=function(){return this.form.find("select").selectmenu({change:this.update_form}),this.form.find(":checkbox").checkbox(),this.form.find(":checkbox").change(this.update_form)},b.prototype.param=function(a){return $("#"+this.id+"_"+a)},b.prototype.bind_submit=function(){var a=this;return this.form.submit(function(){return $("#blocker").show(),$("#order-popup").show(),!1})},b.prototype.bind_popup_submit=function(a){var b=this;return a.submit(function(){var c,d,e,f,g,h,i;c=a.parents(".popup"),d=b.form.serializeArray(),g=[];for(h=0,i=d.length;h<i;h++){f=d[h];if(f.name.match(new RegExp("^"+b.id+"\\[.+\\]$"))){if(b.id!=="green_card"&&f.name===""+b.id+"[cost]")continue;g.push(f)}}return g.push({name:"type",value:b.id}),e=""+$.param(g)+"&"+a.serialize(),$.ajax({url:a.attr("action"),type:"post",dataType:"script",data:e+"&_method=",success:function(){return c.find(".initial").hide(),c.find(".success").show()}}),!1})},b.prototype.bind_contact_info_change=function(){return this.contact_info.bind("keyup mouseup change input",this.check_contact_info),this.check_contact_info()},b.prototype.check_contact_info=function(){var a;return a=strip(this.contact_info.val()).length>=7,this.popup_form.find("input[type=submit]").prop("disabled",!a)},b.prototype.spinner=function(){var a;return a=new Spinner({lines:11,length:4,width:2,radius:4,trail:75,speed:1.5,color:"#005C9E"}),a.spin().el},b.prototype.get_cost=function(){var a,b=this;return a=""+this.form.serialize()+"&_method=&type="+this.id,this.costs_cache==null&&(this.costs_cache=[]),this.costs_cache[a]?this.set_cost(this.costs_cache[a]):$.ajax({url:this.form.data("calc-url"),type:"post",dataType:"script",data:a,beforeSend:function(){return b.timer=setTimeout(function(){return b.form.find(".cost").html(b.spinner)},250)},success:function(c){return clearTimeout(b.timer),b.costs_cache[a]=c,b.set_cost(c)}})},b.prototype.set_cost=function(a){return this.form.find(".cost").html(plural_form(a,"рубль","рубля","рублей"))},b}()})).call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b=Object.prototype.hasOwnProperty,c=function(a,c){function e(){this.constructor=a}for(var d in c)b.call(c,d)&&(a[d]=c[d]);return e.prototype=c.prototype,a.prototype=new e,a.__super__=c.prototype,a};this.GreenCardForm=function(b){function d(){this.update_form=a(this.update_form,this),d.__super__.constructor.call(this,$("form#green_card")),this.update_form()}return c(d,b),d.prototype.update_form=function(){var a,b,c,d,e,f;return b=new Array,b[0]=new Array,b[1]=new Array,b[0][0]=new Array(1550,2950,5480,7730,9550,10390,11240,11800,12360,12920,13340,13620,14050),b[0][1]=new Array(460,880,1640,2310,2860,3110,3360,3530,3700,3860,3990,4070,4200),b[0][2]=new Array(2580,4920,9140,12890,15940,17350,18750,19690,20630,21570,22270,22740,23440),b[0][3]=new Array(520,990,1830,2580,3190,3480,3760,3950,4130,4320,4460,4560,4700),b[0][4]=new Array(4420,7930,13170,18400,23630,28860,34090,39330,44560,49790,55020,60250,65480),b[0][5]=new Array(770,1480,2740,3860,4780,5200,5620,5900,6180,6460,6670,6820,7030),b[0][6]=new Array(940,1800,3340,4720,5830,6340,6860,7200,7550,7890,8150,8320,8570),b[1][0]=new Array(530,700,1050,1410,1760,2110,2460,2640,2810,2990,3160,3340,3520),b[1][1]=new Array(160,210,320,420,530,630,740,790,840,890,950,1e3,1050),b[1][2]=new Array(900,1200,1790,2390,2990,3590,4180,4480,4780,5080,5380,5680,5980),b[1][3]=new Array(180,240,360,480,600,720,840,900,960,1010,1070,1130,1190),b[1][4]=new Array(1100,1970,3270,4580,5880,7180,8480,9780,11080,12380,13680,14980,16280),b[1][5]=new Array(260,350,520,690,870,1040,1210,1300,1390,1470,1560,1650,1730),b[1][6]=new Array(320,430,640,860,1070,1290,1500,1610,1720,1830,1930,2040,2150),f=this.form.find("select").map(function(){return $(this).val()}),c=f[0],e=f[1],d=f[2],a=b[c-1][e-1][d-1]*1,d==="1"?this.form.find("div.cost-comment").css("visibility","hidden"):(a*=.95,this.form.find("div.cost-comment").css("visibility","visible")),this.set_cost(a),this.param("cost").attr("value",Math.round(a))},d}(OrderForm)}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b=Object.prototype.hasOwnProperty,c=function(a,c){function e(){this.constructor=a}for(var d in c)b.call(c,d)&&(a[d]=c[d]);return e.prototype=c.prototype,a.prototype=new e,a.__super__=c.prototype,a};this.OsagoForm=function(b){function d(){this.update_form=a(this.update_form,this),d.__super__.constructor.call(this,$("form#osago")),this.update_form()}return c(d,b),d.prototype.update_form=function(a){var b,c,d,e,f,g,h,i;a==null&&(a={}),this.get_cost(),e={},c=this.form.find(".select, .checkbox").map(function(){return $(this).attr("id")});for(g=0,h=c.length;g<h;g++)b=c[g],e[b]=!1;e.osago_type=!0;switch(this.param("osago_type").val()){case"1":e.transport_type=!0,e.person_type=!0,e.class_type=!0,e.time_used_type=!0,e.penalty=!0;break;case"2":e.transport_type=!0,e.person_type=!0,e.contract_term_type=!0,e.penalty=!0;break;case"3":e.person_type=!0,e.person_type=!0}if(e.person_type)switch(this.param("person_type").val()){case"1":e.experience_type=!0}if(e.transport_type)switch(this.param("transport_type").val()){case"1":case"2":e.horsepower_type=!0;break;case"5":e.weight_type=!0;break;case"6":e.seats_type=!0;break;case"4":case"5":case"12":e.person_type=!1,e.experience_type=!1,e.class_type=!1,e.penalty=!1}i=[];for(d in e)f=e[d],f?i.push($("#"+d).show()):i.push($("#"+d).hide());return i},d}(OrderForm)}.call(this),function(){var a=Object.prototype.hasOwnProperty,b=function(b,c){function e(){this.constructor=b}for(var d in c)a.call(c,d)&&(b[d]=c[d]);return e.prototype=c.prototype,b.prototype=new e,b.__super__=c.prototype,b};this.CallForm=function(a){function c(){this.form=$("#call-form form"),this.id=this.form.attr("id"),this.bind_popup_submit(this.form)}return b(c,a),c}(OrderForm)}.call(this),function(){jQuery(function(){$("#green_card").length&&new GreenCardForm,$("#osago").length&&new OsagoForm;if($("#call-form").length)return new CallForm})}.call(this)
