$((function(){KMA.init(),$(window).resize((function(){KMA.modalRefresh()})),KMA.modalRefresh(),$(document).on("click","[modal]",(function(){var t=$("div#"+$(this).attr("modal"));if(t.length)return KMA.modalShow(t),!1})).on("click",".icon-close, .modal, .button-close",(function(t){if(t.preventDefault(),t.target!=this)return!1;KMA.modalHide($(this).closest(".modal"))})).on("keydown",(function(t){27==t.keyCode&&KMA.modalHide($(".modal:visible:last"))})).on("click",".modal > *",(function(t){return t.stopPropagation(),!0})),$("#kmacb-form form").on("submit",(function(t){t.preventDefault();var e=$("form:first"),n=e.find("input[name=frompopup]"),a=$(this).serializeArray();switch($(a).each((function(t,n){try{e.find("[name="+n.name+"]").val(n.value)}catch(t){}})),n.val("1"),window.last_action_popup){case"click":e.find("input[name=order_source]").val(source_popup_operator);break;case"leave":e.find("input[name=order_source]").val(source_popup_out)}e.trigger("submit",!0).trigger("reset")})),$("#kmacb-form-append").length&&$("#kmacb-form form").length&&($("#kmacb-form form").prepend($("#kmacb-form-append").html()),$("#kmacb-form-append").remove()),$("form").append(''),$("form").append('')}));var KMA=function(t,e){return t.extend(e,{init:function(){this.initFireMetric(),this.setTimezone(),this.initDataCountry(),this.initMethodForm(),this.checkPhoneLen(),this.initAgreement(),this.initTranslate()},modalHide:function(e){e.fadeOut("fast",(function(){t(".modal:visible").length||(t("body").removeClass("modal-show"),t(document).trigger("kma.modal-hide"))}))},modalRefresh:function(){if(t(".modal:visible:last").length){var e=t(".modal:visible:last .modal-block"),n=parseInt(e.outerWidth()),a=parseInt(e.outerHeight());t(window).height()>a+20?e.addClass("modal-top").removeClass("margin-t-b").css("margin-top",a/2*-1):e.addClass("margin-t-b").removeClass("modal-top"),t(window).width()>n?e.addClass("modal-left").removeClass("margin-l").css("margin-left",n/2*-1):e.addClass("margin-l").removeClass("modal-left")}},modalShow:function(e){e.fadeIn("fast"),t("body").addClass("modal-show"),t(document).trigger("kma.modal-show"),this.modalRefresh()},initCallback:function(e){try{t("#kmacb > a").on("click",(function(e,n){null!=n&&n||t(this).trigger("kma.callbackOperator")})),null!=window.kmacb_manager_class&&t("#kmacb").addClass(window.kmacb_manager_class),null!=window.kmacb_form_selector&&(t("#kmacb > a").attr("kmacb-custom-form",window.kmacb_form_selector),t("#kmacb > a").on("click",(function(e,n){e.preventDefault(),e.stopPropagation(),t(window.kmacb_form_selector).trigger("click",[!0,!0])})),t(window.kmacb_form_selector).on("click",(function(e,n){null!=n&&n||t(document).trigger("kma.callbackButton")}))),setTimeout((function(){t("#kmacb").show()}),e)}catch(t){}},setTimezone:function(){var e=(new Date).getTimezoneOffset();t("form").append('')},setCountryField:function(t){},checkAndSetCountryField:function(e){t("select[name=country]").length||t("input[name=country]").length||this.setCountryField(e)},disableCountrySelect:function(e){t("select[name=country]").length&&(t("select[name=country]").attr("disabled","disabled"),this.setCountryField(e))},showComebacker:!1,initComebacker:function(e){this.showComebacker=!0;try{setTimeout((function(){var e=!0;t(window).on("mouseout",(function(n){if(n.pageY-t(window).scrollTop()<1&&e){if(null!=window.customPopupShowed&&!0===window.customPopupShowed)return;if(t(".modal:visible").length)return;t(document).trigger("kma.mouseLeave"),t("#kmacb > a").trigger("click",[!0]),e=!1}}))}),e)}catch(t){}},phoneMaxLen:25,checkPhoneLen:function(){var e=this;try{null!=window.phone_max_length&&""!=window.phone_max_length&&(e.phoneMaxLen=parseInt(window.phone_max_length))}catch(t){}t(document).on("keypress","input[name=phone]",(function(n){var a=new RegExp("[^0-9]*","g");t(this).val().replace(a,"").length>=e.phoneMaxLen&&n.preventDefault()}))},validateAndSendForm:function(e,n){var a=this;t(document).on("submit","form",(function(o,i){if(!t(this).closest("#kmacb-form").length){if(e&&a.prepareJsonData(t(this)),t("input[name=name]",this).val(t.trim(t("input[name=name]",this).val())),!t("input[name=name]",this).val())return alert(n.validation_name),!1;var r=t("input[name=phone]",this).val(),c=new RegExp("[^0-9]*","g"),l=new RegExp("[^0-9-+ ()]","g"),s=r.replace(c,"");if(-1!=r.search(l))return alert(n.validation_phone1),!1;if(!s||s.length<9)return alert(n.validation_phone2),!1;if(s.length&&s.length>a.phoneMaxLen)return alert(n.validation_phone3),!1;if(a.showComebackerAlert=!1,i)t("#kmacb-form form").trigger("kma.cbform-validate");else{try{var u=null==t(this).attr("data-kma-yacounter-id-important")?t(this).attr("data-kma-yacounter-id"):t(this).attr("data-kma-yacounter-id-important"),m=null==t(this).attr("data-kma-yacounter-goal-important")?t(this).attr("data-kma-yacounter-goal"):t(this).attr("data-kma-yacounter-goal-important");null!=u&&null!=m&&(u=u.trim(),m=m.trim(),""!=u&&""!=m&&window["yaCounter"+u].reachGoal(m),!0===window.metricDebug&&console.log(u,m))}catch(t){console.log("Exception: Yandex Metrica - yaCounter")}try{var d=t(this).attr("data-kma-ga-goal"),f=t(this).attr("data-kma-ga-goal-category");null!=d&&(d=d.trim(),"function"==typeof gtag?gtag("event",d,f?{event_category:f}:{}):ga("send",d,f?{eventCategory:f}:{})),null!=window.kma_order_ga_params&&("function"==typeof gtag?gtag("event",d,f?{event_category:f}:{}):ga("send",d,f?{eventCategory:f}:{})),!0===window.metricDebug&&console.log(d,f)}catch(t){console.log("Exception: Google Analitics - send event")}}return t(this).trigger("kma.form-validate"),!0}})),t("a.order-btn").click((function(){return t(this).closest("form").submit(),!1}))},prepareJsonData:function(e){var n=e.serializeArray(),a=!1;t(n).each((function(t,e){"address"==e.name&&(a=!0),"name"!=e.name&&"phone"!=e.name&&"address"!=e.name&&"client_data"!=e.name||delete n[t]})),0==a&&e.append(""),e.find("input[name='address']").val(t.JSON.encode(n))},initVibrate:function(t){setInterval((function(){try{window.navigator&&window.navigator.vibrate?navigator.vibrate([50,30,100,30,100,30,100,30,100,30,100,30,100,30,100,30,100,30,100,30]):navigator.vibrate(0)}catch(t){}}),t)},showComebackerAlert:!0,initComebackerAlert:function(e){var n=this;window.onbeforeunload=function(a){if(n.showComebackerAlert)return n.showComebackerAlert=!1,t("form").append(''),e.comebacker_text}},showNewsBlogIframe:!0,funcNewsBlogIframe:function(e,n){if(this.showNewsBlogIframe)return this.showNewsBlogIframe=!1,t("body").css({overflow:"hidden",background:"#FFF"}).html(''),e.comebacker_text},initNewsBlogIframe:function(e,n,a){var o=this,i=null,r=1e3*parseInt(a);t(document).on("mousemove keydown scroll",(function(){clearTimeout(i),i=setTimeout((function(){o.funcNewsBlogIframe(e,n)}),r)})),t("body").trigger("mousemove")},initRedirectAfterSomeSeconds:function(e,n){var a=null,o=1e3*parseInt(n);t(document).on("mousemove keydown scroll",(function(){clearTimeout(a),a=setTimeout((function(){window.location.href=e}),o)}))},initDataCountry:function(){var e=this;e.changeDataCountry(window.country),e.changeDataNotCountry(window.country),t(".country_select").change((function(){e.changeDataCountry(t(this).val()),e.changeDataNotCountry(t(this).val())}))},eur:["AT","BG","GB","HU","DE","GR","ES","IT","CY","MK","NL","PL","PT","RO","RS","SK","SI","TR","FR","HR","CZ","CH","BE","IL","LV","LT","LU","NO","SE","EE"],sng:["RU","UA","BY","KZ","MD","KG","UZ","AZ","AM","TJ","TM","GE","UZ"],afr:["NG"],changeDataCountry:function(e){var n=this;t.each(t("[data-kma-country]"),(function(){var a=t(this).attr("data-kma-country").split(" ").join("").toUpperCase().split(","),o=t(this).is("[data-kma-class]")?t(this).attr("data-kma-class"):void 0,i=void 0;i=n.sng.indexOf(e)>-1?"SNG":n.eur.indexOf(e)>-1?"EUR":n.afr.indexOf(e)>-1?"AFR":"ASIA",a.indexOf(e)>-1||null!=i&&a.indexOf(i)>-1?null!=o?t(this).addClass(o):t(this).show():null!=o?t(this).removeClass(o):t(this).hide()}))},changeDataNotCountry:function(e){var n=this;t.each(t("[data-kma-not-country]"),(function(){var a=t(this).attr("data-kma-not-country").split(" ").join("").toUpperCase().split(","),o=void 0;o=n.sng.indexOf(e)>-1?"SNG":n.eur.indexOf(e)>-1?"EUR":n.afr.indexOf(e)>-1?"AFR":"ASIA",a.indexOf(e)>-1||null!=o&&a.indexOf(o)>-1?t(this).hide():t(this).show()}))},initAgreement:function(){if(!t("[modal=agreement]").length){var e=t("[modal=polit]:visible:last"),n=e.clone();e.after(n.attr("modal","agreement").text("Пользовательское соглашение")),e.after("
")}},ruLangList:["ru","az","be","kk","uk","ka","uz","ky","am","tg"],initTranslate:function(){var e=t("[modal=agreement]:visible:last"),n=t("[modal=polit]:visible:last");e.length&&(this.ruLangList.indexOf(window.lang.toLowerCase())>-1?e.text("Пользовательское соглашение"):e.text("User Agreement")),n.length&&(this.ruLangList.indexOf(window.lang.toLowerCase())>-1?n.text("Политика конфиденциальности"):n.text("Privacy Policy"))},initMethodForm:function(){t("form").attr("method","POST")},fireMetric:function(e){var n,a,o=void 0,i=void 0;void 0!==t(e).attr("data-goal")?o=i=t(e).attr("data-goal"):(o=t(e).attr("data-ym-goal"),i=t(e).attr("data-ga-goal")),a=t(e).attr("data-ga-goal-cat"),n=t(e).attr("data-ym-id"),!0===window.metricDebug&&console.log(n,o,i,a);try{void 0!==typeof n&&void 0!==typeof o&&t.globalEval("yaCounter"+n+".reachGoal('"+o+"');"),void 0!==typeof i&&("function"==typeof gtag?gtag("event",i,a?{event_category:a}:{}):ga("send",i,a?{eventCategory:a}:{}))}catch(t){!0===window.metricDebug&&console.log("metric doesnt install",t)}},initFireMetric:function(){var e=this;t(document).on("click","[data-trigger=click]",(function(t,n,a){a||e.fireMetric(this)})),t(document).on("submit","[data-trigger=submit]:not([data-kma-yacounter-id]):not([data-kma-ga-goal])",(function(){return!!t(this).parents("#kmacb-form").length||(e.fireMetric(this),!1)})),t(document).on("kma.cbform-validate",(function(n){return"submit"===t(n.target).attr("data-trigger")&&e.fireMetric(n.target),!1})),t(document).on("kma.callbackOperator",(function(n){"click"===t(n.target).attr("data-trigger")&&e.fireMetric(n.target)}))},change_country:function(t){}})}(jQuery,KMA||{});function change_country(t){if("undefined"==typeof country_list||null==country_list[t])return console.log("there is no such country in country_list"),!1;for(var e in 0==country_list[t].s1?($(".price_land_s1").text(text_item_is_free),$(".price_land_s1 + .price_land_curr").hide()):($(".price_land_s1").text(country_list[t].s1),$(".price_land_s1 + .price_land_curr").show()),$(".price_land_curr").text(country_list[t].curr),$(".price_land_s2").text(country_list[t].s2),$(".price_land_s3").text(country_list[t].s3),$(".price_land_s4").text(country_list[t].s4),$(".price_land_discount").text(country_list[t].discount),$(".price_field_s1").val(country_list[t].s1),$(".price_field_s2").val(country_list[t].s2),$(".price_field_s3").val(country_list[t].s3),$("rekv").html(country_list[t].rekv),$(".js-agreement-rekv").html(country_list[t].rekv),country_list[t].specialfields)$(".additional_fields_"+e).html(country_list[t].specialfields[e]);$("form input[name=campaign]").val(country_list[t].campaign)}$((function(){"undefined"!=typeof list_of_parameters&&jQuery.each($('form[action="'+action_url+'"]'),(function(t,e){for(key_param in list_of_parameters)0==$(e).find("input[name="+key_param+"]").length&&$(e).append('')})),window.last_action_popup=!1,$(document).on("kma.callbackOperator",(function(t){window.last_action_popup="click"})),$(document).on("kma.mouseLeave",(function(t){window.last_action_popup="leave"})),$("form").on("submit",(function(t){var e=$(this);if(e.closest("#kmacb-form").length||e.closest(".mfp-content").length||e.closest(".puForm").length||e.closest(".modal").length)switch(e.find("input[name=frompopup]").val("1"),window.last_action_popup){case"click":e.find("input[name=order_source]").val(source_popup_operator);break;case"leave":e.find("input[name=order_source]").val(source_popup_out)}}))})),$((function(){try{$(document).on("change",".country_select",(function(){change_country($(this).val()),$(".country_select").val($(this).val())}))}catch(t){$(".country_select").live("change",(function(){change_country($(this).val()),$(".country_select").val($(this).val())}))}change_country(country),setTimeout((function(){$(".country_select:visible").length&&$(".country_select:visible").val()!=country&&($(".country_select:visible").val(country),$(".country_select:visible").trigger("change"))}),500)}));