PageSourceSearch

https://www.osgrm.ru/bitrix/templates/aspro-allcorp2_2024/js/general.js?1727932058175676

js osgrm.ru collected 2026-10-04 08:50:35 UTC 175,676 bytes, 5,594 lines download raw bytes

1var funcDefined = function (func) {
2  try {
3    if (typeof func == "function") return true;
4    else return typeof window[func] === "function";
5  } catch (e) {
6    return false;
7  }
8};
9
10getRandomInt = function (min, max) {
11  return Math.floor(Math.random() * (max - min)) + min;
12};
13
14ShowOverlay = function () {
15  $('<div class="jqmOverlay waiting"></div>').appendTo("body");
16};
17
18window.addEventListener("popstate", function (event) {
19  if (typeof startActions == "function") {
20    setTimeout(startActions, 500);
21  }
22});
23
24HideOverlay = function () {
25  $(".jqmOverlay").detach();
26  CloseMobilePhone();
27};
28
29if (!funcDefined("pauseYmObserver")) {
30  // pause ya metrika webvisor MutationObserver callback (DOM indexer)
31  // use before insert html with some animation
32  pauseYmObserver = function () {
33    if (
34      typeof MutationObserver === "function" &&
35      typeof MutationObserver.observers === "object" &&
36      typeof MutationObserver.observers.ym === "object"
37    ) {
38      MutationObserver.observers.ym.pause();
39    }
40  };
41}
42
43if (!funcDefined("resumeYmObserver")) {
44  // resume ya metrika webvisor MutationObserver callback
45  // use when animation finished
46  resumeYmObserver = function () {
47    if (
48      typeof MutationObserver === "function" &&
49      typeof MutationObserver.observers === "object" &&
50      typeof MutationObserver.observers.ym === "object"
51    ) {
52      MutationObserver.observers.ym.resume();
53    }
54  };
55}
56
57CheckTopMenuDotted = function () {
58  var menu = $("nav.mega-menu.sliced");
59  /*if(isMobile)
60		return;*/
61
62  if (window.matchMedia("(max-width:991px)").matches) return;
63
64  if (menu.length) {
65    menu.each(function () {
66      var menuMoreItem = $(this).find("td.js-dropdown");
67      if ($(this).parents(".collapse").css("display") == "none") {
68        return false;
69      }
70
71      var block_w = $(this).closest("div").actual("width");
72      var menu_w = $(this).find("table").actual("outerWidth");
73      var afterHide = false;
74
75      while (menu_w > block_w) {
76        menuItemOldSave = $(this).find("td").not(".nosave").last();
77        if (menuItemOldSave.length) {
78          menuMoreItem.show();
79          menuItemNewSave =
80            '<li class="' +
81            (menuItemOldSave.hasClass("dropdown") ? "dropdown-submenu " : "") +
82            (menuItemOldSave.hasClass("active") ? "active " : "") +
83            '" data-hidewidth="' +
84            menu_w +
85            '">' +
86            menuItemOldSave.find(".wrap").html() +
87            "</li>";
88          menuItemOldSave.remove();
89          menuMoreItem
90            .find("> .wrap > .dropdown-menu")
91            .prepend(menuItemNewSave);
92          menu_w = $(this).find("table").actual("outerWidth");
93          afterHide = true;
94        }
95        //menu.find('.nosave').css('display', 'table-cell');
96        else {
97          break;
98        }
99      }
100
101      if (!afterHide) {
102        do {
103          var menuItemOldSaveCnt = menuMoreItem
104            .find(".dropdown-menu")
105            .find("li").length;
106          menuItemOldSave = menuMoreItem
107            .find(".dropdown-menu")
108            .find("li")
109            .first();
110          if (!menuItemOldSave.length) {
111            menuMoreItem.hide();
112            break;
113          } else {
114            var hideWidth = menuItemOldSave.attr("data-hidewidth");
115            if (hideWidth > block_w) {
116              break;
117            } else {
118              menuItemNewSave =
119                '<td class="' +
120                (menuItemOldSave.hasClass("dropdown-submenu")
121                  ? "dropdown "
122                  : "") +
123                (menuItemOldSave.hasClass("active") ? "active " : "") +
124                '" data-hidewidth="' +
125                block_w +
126                '"><div class="wrap">' +
127                menuItemOldSave.html() +
128                "</div></td>";
129              menuItemOldSave.remove();
130              $(menuItemNewSave).insertBefore($(this).find("td.js-dropdown"));
131              if (!menuItemOldSaveCnt) {
132                menuMoreItem.hide();
133                break;
134              }
135            }
136          }
137          menu_w = $(this).find("table").actual("outerWidth");
138        } while (menu_w <= block_w);
139      }
140      $(this).find("td").css("visibility", "visible");
141      $(this).find("td").removeClass("unvisible");
142      $(this).parents(".menu-only").css("opacity", "1");
143    });
144  }
145  return false;
146};
147
148CheckTopVisibleMenu = function (that) {
149  var dropdownMenu = $(".dropdown-menu:visible").last();
150
151  if (dropdownMenu.length) {
152    dropdownMenu.find("a").css("white-space", "");
153    dropdownMenu.css("left", "");
154    dropdownMenu.css("right", "");
155    dropdownMenu.removeClass("toright");
156
157    var dropdownMenu_left = dropdownMenu.offset().left;
158    if (typeof dropdownMenu_left != "undefined") {
159      var menu = dropdownMenu.parents(".mega-menu");
160      if (!menu.length) menu = dropdownMenu.closest(".logo-row");
161      var menu_width = menu.outerWidth();
162      var menu_left = menu.offset().left;
163      var menu_right = menu_left + menu_width;
164      var isToRight = dropdownMenu.parents(".toright").length > 0;
165      var parentsDropdownMenus = dropdownMenu.parents(".dropdown-menu");
166      var isHasParentDropdownMenu = parentsDropdownMenus.length > 0;
167      if (isHasParentDropdownMenu) {
168        var parentDropdownMenu_width = parentsDropdownMenus
169          .first()
170          .outerWidth();
171        var parentDropdownMenu_left = parentsDropdownMenus
172          .first()
173          .offset().left;
174        var parentDropdownMenu_right =
175          parentDropdownMenu_width + parentDropdownMenu_left;
176      }
177
178      if (parentDropdownMenu_right + dropdownMenu.outerWidth() > menu_right) {
179        dropdownMenu.find("a").css("white-space", "normal");
180      }
181
182      var dropdownMenu_width = dropdownMenu.outerWidth();
183      var dropdownMenu_right = dropdownMenu_left + dropdownMenu_width;
184
185      if (dropdownMenu_right > menu_right || isToRight) {
186        var addleft = 0;
187        addleft = menu_right - dropdownMenu_right;
188        if (isHasParentDropdownMenu || isToRight) {
189          dropdownMenu.css("left", "auto");
190          dropdownMenu.css("right", "100%");
191          dropdownMenu.addClass("toright");
192        } else {
193          var dropdownMenu_curLeft = parseInt(dropdownMenu.css("left"));
194          dropdownMenu.css("left", dropdownMenu_curLeft + addleft + "px");
195        }
196      }
197    }
198  }
199};
200
201MegaMenuFixed = function () {
202  var animationTime = 150;
203
204  $(".logo_and_menu-row .burger").on("click", function () {
205    $(".mega_fixed_menu").fadeIn(animationTime);
206  });
207
208  $(".mega_fixed_menu .svg.svg-close").on("click", function () {
209    $(this).closest(".mega_fixed_menu").fadeOut(animationTime);
210  });
211
212  $(".mega_fixed_menu .dropdown-menu .arrow").on("click", function (e) {
213    e.preventDefault();
214    e.stopPropagation();
215    $(this)
216      .closest(".dropdown-submenu")
217      .find(".dropdown-menu")
218      .slideToggle(animationTime);
219    $(this).closest(".dropdown-submenu").addClass("opened");
220  });
221};
222
223CheckPopupTop = function () {
224  // var popup = $(".jqmWindow.show");
225  // if (popup.length) {
226  //   var documentScollTop = $(document).scrollTop();
227  //   var windowHeight = $(window).height();
228  //   var popupTop = parseInt(popup.css("top"));
229  //   var popupHeight = popup.height();
230
231  //   if (windowHeight >= popupHeight) {
232  //     // center
233  //     popupTop = (windowHeight - popupHeight) / 2;
234  //   } else {
235  //     if (documentScollTop > documentScrollTopLast) {
236  //       // up
237  //       popupTop -= documentScollTop - documentScrollTopLast;
238  //     } else if (documentScollTop < documentScrollTopLast) {
239  //       // down
240  //       popupTop += documentScrollTopLast - documentScollTop;
241  //     }
242
243  //     if (popupTop + popupHeight < windowHeight) {
244  //       // bottom
245  //       popupTop = windowHeight - popupHeight;
246  //     } else if (popupTop > 0) {
247  //       // top
248  //       popupTop = 0;
249  //     }
250  //   }
251  //   popup.css("top", popupTop + "px");
252  // }
253};
254
255CheckMainBannerSliderVText = function (slider) {
256  /*if(slider.parents('.banners-big').length){
257		var sh = slider.height();
258		slider.find('.item').each(function() {
259			var curSlideTextInner = $(this).find('.text .inner');
260			if(curSlideTextInner.length){
261				var ith = curSlideTextInner.actual('height');
262				var p = (ith >= sh ? 0 : Math.floor((sh - ith) / 2));
263				curSlideTextInner.css('padding-top', p + 'px');
264			}
265		});
266	}*/
267};
268
269CheckStickyFooter = function () {
270  BX.addCustomEvent("onWindowResize", function (eventdata) {
271    if (!isMobile) {
272      try {
273        var footerHeight = $("footer").outerHeight();
274        ignoreResize.push(true);
275        $("footer").css("margin-top", "-" + footerHeight + "px");
276        $(".body").css("margin-bottom", "-" + footerHeight + "px");
277        $(".main").css("padding-bottom", footerHeight + 0 + "px");
278        ignoreResize.pop();
279      } catch (e) {}
280    }
281  });
282};
283
284verticalAlign = function (class_name) {
285  if (typeof class_name == "undefined") class_name = "auto_align";
286  if ($("." + class_name).length) {
287    maxHeight = 0;
288    $("." + class_name).each(function () {
289      if ($(this).height() > maxHeight) {
290        maxHeight = $(this).height();
291      }
292    });
293    $("." + class_name).each(function () {
294      delta = Math.round((maxHeight - $(this).height()) / 2);
295      $(this).css({
296        "padding-top": delta + "px",
297        "padding-bottom": delta + "px",
298      });
299    });
300  }
301};
302
303getGridSize = function (counts, custom_counts) {
304  var z = parseInt($(".body_media").css("top"));
305  if (typeof custom_counts != "undefined") {
306    if (window.matchMedia("(max-width: 700px)").matches)
307      return counts[3] ? counts[3] : counts[2];
308    else if (window.matchMedia("(max-width: 850px)").matches) return counts[2];
309    else if (window.matchMedia("(max-width: 1100px)").matches) return counts[1];
310    else return counts[0];
311  } else {
312    if (window.matchMedia("(max-width: 600px)").matches) {
313      return counts[3] ? counts[3] : counts[2];
314    } else return z == 2 ? counts[0] : z == 1 ? counts[1] : counts[2];
315  }
316};
317
318CheckFlexSlider = function () {
319  $(".flexslider:not(.thmb):visible").each(function () {
320    var slider = $(this);
321    slider.resize();
322    var counts = slider.data("flexslider").vars.counts,
323      slide_counts = slider.data("flexslider").vars.slide_counts;
324    if (typeof counts != "undefined") {
325      var cnt = getGridSize(counts, slider.data("flexslider").vars.customGrid);
326      var to0 =
327        cnt != slider.data("flexslider").vars.minItems ||
328        cnt != slider.data("flexslider").vars.maxItems ||
329        cnt != slider.data("flexslider").vars.move;
330      if (to0) {
331        slider.data("flexslider").vars.minItems = cnt;
332        slider.data("flexslider").vars.maxItems = cnt;
333        if (typeof slide_counts != "undefined")
334          slider.data("flexslider").vars.move = slide_counts;
335        else slider.data("flexslider").vars.move = cnt;
336
337        slider.flexslider(0);
338        slider.resize();
339        slider.resize(); // twise!
340      }
341    }
342  });
343};
344
345CheckHeaderFixed = function () {
346  var header_fixed = $("#headerfixed");
347  header = $("header").first();
348  if (header_fixed.length) {
349    if (header.length) {
350      var isHeaderFixed = false,
351        headerCanFix = true,
352        headerFixedHeight = header_fixed.actual("outerHeight"),
353        headerNormalHeight = header.actual("outerHeight"),
354        headerDiffHeight = headerNormalHeight - headerFixedHeight,
355        mobileBtnMenu = $(".btn.btn-responsive-nav"),
356        headerTop = $("#panel:visible").actual("outerHeight");
357      (topBlock = $(".TOP_HEADER").first()),
358        ($headerFixedNlo = header_fixed.find("[data-nlo]")),
359        (isNloLoaded = !$headerFixedNlo.length),
360        (OnHeaderFixedScrollHandler = "");
361
362      if (headerDiffHeight <= 0) headerDiffHeight = 0;
363      if (topBlock.length) headerTop += topBlock.actual("outerHeight");
364
365      $(window).scroll(
366        (OnHeaderFixedScrollHandler = function () {
367          /*if(!isMobile && window.matchMedia('(min-width: 992px)').matches)
368				{*/
369          var scrollTop = $(window).scrollTop();
370          headerCanFix =
371            !mobileBtnMenu.is(
372              ":visible"
373            ) /* && !$('.dropdown-menu:visible').length*/;
374
375          var current_is = $(".search-wrapper .search-input:visible"),
376            title_search_result = $(
377              ".title-search-result." + current_is.attr("id")
378            ),
379            pos,
380            pos_input;
381
382          if (!isHeaderFixed) {
383            if (scrollTop > headerNormalHeight + headerTop && headerCanFix) {
384              if (!isNloLoaded) {
385                if (!$headerFixedNlo.hasClass("nlo-loadings")) {
386                  $headerFixedNlo.addClass("nlo-loadings");
387                  setTimeout(function () {
388                    $.ajax({
389                      data: { nlo: $headerFixedNlo.attr("data-nlo") },
390                      complete: function (jqXHR, textStatus) {
391                        if (textStatus === "success" || jqXHR.status == 404) {
392                          // stop ya metrika webvisor DOM indexer
393                          pauseYmObserver();
394
395                          isNloLoaded = true;
396                          var ob = BX.processHTML($.trim(jqXHR.responseText));
397                          BX.ajax.processScripts(ob.SCRIPT);
398                          $headerFixedNlo.replaceWith(ob.HTML);
399
400                          OnHeaderFixedScrollHandler();
401
402                          // resume ya metrika webvisor
403                          // (300ms transition) + (100ms scroll handler)
404                          setTimeout(resumeYmObserver, 400);
405
406                          CheckTopMenuDotted();
407                        }
408                      },
409                      error: function () {
410                        $headerFixedNlo.removeClass("nlo-loadings");
411                      },
412                    });
413                  }, 300);
414                }
415              } else {
416                isHeaderFixed = true;
417                header_fixed.css("top", "-" + headerNormalHeight + "px");
418                header_fixed.addClass("fixed");
419
420                header_fixed.animate(
421                  { top: "0" },
422                  { duration: 300, complete: function () {} }
423                );
424                CheckTopMenuDotted();
425              }
426
427              ///////
428              // isHeaderFixed = true;
429              // header_fixed.css('top', '-' + headerNormalHeight + 'px');
430              // header_fixed.addClass('fixed');
431              // // header_fixed.stop(0).animate({top: '0'}, 300);
432
433              // header_fixed.animate({top: '0'}, {duration:300, complete:
434              // 	function(){}
435              // });
436              // CheckTopMenuDotted();
437            }
438          } else if (isHeaderFixed || !headerCanFix) {
439            if (scrollTop <= headerDiffHeight + headerTop || !headerCanFix) {
440              isHeaderFixed = false;
441              header_fixed.removeClass("fixed");
442            }
443          }
444          // }
445        })
446      );
447    }
448  }
449
450  //mobile fixed
451  var mfixed = $(
452    "body.mfixed_Y #mobileheader, body.mfixed_Y #mobileheadersimple"
453  );
454  if (mfixed.length && isMobile) {
455    var isMHeaderFixed = false,
456      mheaderCanFix = true,
457      //mheaderFixedHeight = mfixed.actual('outerHeight'),
458      mheaderFixedHeight = 0,
459      mheaderTop = $("#panel:visible").actual("outerHeight");
460    $(window).scroll(function () {
461      var scrollTop = $(window).scrollTop();
462      if (window.matchMedia("(max-width:991px)").matches) {
463        if (
464          $("body.mfixed_Y.mfixed_view_scroll_top #mobileheader").length ||
465          $("body.mfixed_Y.mfixed_view_scroll_top #mobileheadersimple").length
466        ) {
467          if (scrollTop > startScroll) {
468            $("body.mfixed_Y.mfixed_view_scroll_top #mobileheader").removeClass(
469              "fixed"
470            );
471            $(
472              "body.mfixed_Y.mfixed_view_scroll_top #mobileheadersimple"
473            ).removeClass("fixed");
474          } else if (scrollTop > mheaderFixedHeight + mheaderTop) {
475            $("body.mfixed_Y.mfixed_view_scroll_top #mobileheader").addClass(
476              "fixed"
477            );
478            $(
479              "body.mfixed_Y.mfixed_view_scroll_top #mobileheadersimple"
480            ).addClass("fixed");
481          } else if (scrollTop <= mheaderFixedHeight + mheaderTop) {
482            $("body.mfixed_Y.mfixed_view_scroll_top #mobileheader").removeClass(
483              "fixed"
484            );
485            $(
486              "body.mfixed_Y.mfixed_view_scroll_top #mobileheadersimple"
487            ).removeClass("fixed");
488          }
489          startScroll = scrollTop;
490        } else {
491          if (!isMHeaderFixed) {
492            if (scrollTop > mheaderFixedHeight + mheaderTop) {
493              isMHeaderFixed = true;
494              mfixed.addClass("fixed");
495            }
496          } else if (isMHeaderFixed) {
497            if (scrollTop <= mheaderFixedHeight + mheaderTop) {
498              isMHeaderFixed = false;
499              mfixed.removeClass("fixed");
500            }
501          }
502        }
503      } else mfixed.removeClass("fixed");
504    });
505  }
506};
507
508CheckObjectsSizes = function () {
509  $(".container iframe,.container object,.container video").each(function () {
510    var height_attr = $(this).attr("height");
511    var width_attr = $(this).attr("width");
512    if (height_attr && width_attr) {
513      $(this).css("height", ($(this).outerWidth() * height_attr) / width_attr);
514    }
515  });
516};
517
518scrollToTop = function () {
519  if (arAllcorp2Options["THEME"]["SCROLLTOTOP_TYPE"] !== "NONE") {
520    scrollToTopAnimateClassIn =
521      arAllcorp2Options.THEME.SCROLLTOTOP_TYPE.indexOf("ROUND") !== -1
522        ? "rotateIn"
523        : "rubberBand";
524    scrollToTopAnimateClassOut =
525      arAllcorp2Options.THEME.SCROLLTOTOP_TYPE.indexOf("ROUND") !== -1
526        ? "rotateOut"
527        : "flipOutX";
528    if (BX.browser.IsMac()) {
529      scrollToTopAnimateClassIn = scrollToTopAnimateClassOut = "";
530    }
531    var _isScrolling = false;
532    // Append Button
533    $("body").append(
534      $("<a />")
535        .addClass(
536          "scroll-to-top " +
537            arAllcorp2Options["THEME"]["SCROLLTOTOP_TYPE"] +
538            " " +
539            arAllcorp2Options["THEME"]["SCROLLTOTOP_POSITION"]
540        )
541        .attr({ href: "#", id: "scrollToTop" })
542    );
543    $scrolltotop = $("#scrollToTop");
544
545    if (arAllcorp2Options.THEME.SCROLLTOTOP_POSITION_RIGHT)
546      $scrolltotop.css({
547        right: arAllcorp2Options.THEME.SCROLLTOTOP_POSITION_RIGHT + "px",
548        left: "auto",
549      });
550
551    $scrolltotop.click(function (e) {
552      e.preventDefault();
553      $("body, html").animate({ scrollTop: 0 }, 500);
554      return false;
555    });
556    // Show/Hide Button on Window Scroll event.
557    $(window).scroll(function () {
558      if (!_isScrolling) {
559        _isScrolling = true;
560
561        var bottom = 70,
562          scrollVal = $(window).scrollTop(),
563          windowHeight = $(window).height();
564
565        if (arAllcorp2Options.THEME.SCROLLTOTOP_POSITION_BOTTOM) {
566          bottom = arAllcorp2Options.THEME.SCROLLTOTOP_POSITION_BOTTOM;
567          $scrolltotop.css("bottom", bottom + "px");
568        }
569
570        var footerOffset = 0;
571        if ($("footer").get(0)) {
572          footerOffset = $("footer").offset().top;
573        }
574        if (scrollVal > 150) {
575          $("#scrollToTop").stop(true, true).addClass("visible");
576          _isScrolling = false;
577        } else {
578          $("#scrollToTop").stop(true, true).removeClass("visible");
579          _isScrolling = false;
580        }
581        CheckScrollToTop();
582      }
583    });
584  }
585};
586
587CheckScrollToTop = function () {
588  if (
589    arAllcorp2Options["THEME"]["SCROLLTOTOP_TYPE"] !== "NONE" &&
590    $scrolltotop.length != undefined
591  ) {
592    if (documentScrollTop > 150) {
593      $scrolltotop.stop(true, true).addClass("visible").addClass("animated");
594      if (scrollToTopAnimateClassOut) {
595        $scrolltotop.removeClass(scrollToTopAnimateClassOut);
596      }
597      if (scrollToTopAnimateClassIn) {
598        $scrolltotop.addClass(scrollToTopAnimateClassIn);
599      }
600    } else {
601      $scrolltotop.stop(true, true).removeClass("visible");
602      if (scrollToTopAnimateClassIn) {
603        $scrolltotop.removeClass(scrollToTopAnimateClassIn);
604      }
605      if (scrollToTopAnimateClassOut) {
606        $scrolltotop.addClass(scrollToTopAnimateClassOut);
607      }
608    }
609  }
610  var bottom = 23,
611    scrollVal = $(window).scrollTop(),
612    windowHeight = $(window).height();
613
614  if (arAllcorp2Options.THEME.SCROLLTOTOP_POSITION_BOTTOM) {
615    bottom = arAllcorp2Options.THEME.SCROLLTOTOP_POSITION_BOTTOM;
616    $scrolltotop.css("bottom", bottom + "px");
617  }
618
619  if ($("footer").length) var footerOffset = $("footer").offset().top;
620
621  if (scrollVal + windowHeight > footerOffset) {
622    $("#scrollToTop").css(
623      "bottom",
624      bottom + scrollVal + windowHeight - footerOffset
625    );
626  } else if (parseInt($("#scrollToTop").css("bottom")) > bottom) {
627    $("#scrollToTop").css("bottom", bottom);
628  }
629};
630
631$.fn.mCustomScrollbarDeferred = function (config) {
632  $(this).addClass("scroll-init");
633
634  $(this).hover(
635    function (e) {
636      var $this = $(this);
637      if (!$this.hasClass("mCustomScrollbar")) {
638        $this.data(
639          "scrollTimer",
640          setTimeout(function () {
641            $this.mCustomScrollbar(config);
642            $this.off(
643              "touchstart touchmove touchend mousewheel mouseenter mouseleave"
644            );
645          }, 200)
646        );
647      }
648    },
649    function (e) {
650      clearTimeout($(this).data("scrollTimer"));
651    }
652  );
653
654  $(this).on("touchstart touchmove", function (e) {
655    var $this = $(this);
656    if (!$this.hasClass("mCustomScrollbar")) {
657      $this.mCustomScrollbar(config);
658    }
659
660    var $scrollContainer = $this.find(">.mCustomScrollBox>.mCSB_container");
661    if ($scrollContainer.length) {
662      var touch =
663        e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
664
665      var newTouch = new Touch({
666        identifier: 42,
667        target: $scrollContainer[0],
668        clientX: touch.clientX,
669        clientY: touch.clientY,
670        screenX: touch.screenX,
671        screenY: touch.screenY,
672        pageX: touch.pageX,
673        pageY: touch.pageY,
674        radiusX: 1,
675        radiusY: 1,
676      });
677
678      var newEvent = new TouchEvent(e.type, {
679        cancelable: true,
680        bubbles: true,
681        composed: true,
682        touches: [newTouch],
683        targetTouches: [newTouch],
684        changedTouches: [newTouch],
685      });
686
687      $scrollContainer[0].dispatchEvent(newEvent);
688    }
689  });
690
691  $(this).on("touchend", function (e) {
692    $(this).off(
693      "touchstart touchmove touchend mousewheel mouseenter mouseleave"
694    );
695  });
696
697  if ($.event.special.mousewheel) {
698    $(this).on("mousewheel", function (e) {
699      var $this = $(this);
700      if (!$this.hasClass("mCustomScrollbar")) {
701        $this.mCustomScrollbar(config);
702        $this.off(
703          "touchstart touchmove touchend mousewheel mouseenter mouseleave"
704        );
705      }
706    });
707  }
708};
709
710InitScrollBar = function (el, initOptions) {
711  var block;
712  if (typeof el === "undefined") {
713    block = $(".srollbar-custom:not(.mobile-scroll):not(.scroll-init)");
714  } else {
715    block = el.filter(":not(.scroll-init)");
716  }
717
718  if (block.length) {
719    block.addClass("scroll-init");
720
721    var options,
722      defaults = {
723        mouseWheel: {
724          scrollAmount: 150,
725          preventDefault: true,
726        },
727      };
728    var config = $.extend(
729      {},
730      defaults,
731      options,
732      block.data("plugin-options"),
733      initOptions
734    );
735
736    config.callbacks = {
737      onScroll: function () {
738        if ($(this).find(".mCSB_buttonLeft").hasClass("disabled"))
739          $(this).find(".mCSB_buttonLeft").removeClass("disabled");
740        if ($(this).find(".mCSB_buttonRight").hasClass("disabled"))
741          $(this).find(".mCSB_buttonRight").removeClass("disabled");
742      },
743      onTotalScrollBack: function () {
744        $(this).find(".mCSB_buttonLeft").addClass("disabled");
745      },
746      onTotalScroll: function () {
747        $(this).find(".mCSB_buttonRight").addClass("disabled");
748      },
749      onInit: function () {
750        $(this).find(".mCSB_buttonLeft").addClass("disabled");
751      },
752    };
753
754    block.filter(":not(.scroll-deferred)").mCustomScrollbar(config);
755    block.filter(".scroll-deferred").mCustomScrollbarDeferred(config);
756  }
757};
758
759InitCustomScrollBar = function (el) {
760  var block;
761  if (typeof el === "undefined") {
762    block = $(".scrollbar:not(.mobile-scroll):not(.scroll-init)");
763  } else {
764    block = el.filter(":not(.scroll-init)");
765  }
766
767  if (block.length) {
768    block.addClass("scroll-init");
769
770    var options,
771      defaults = {
772        effect: "fadeIn",
773        effectTime: 300,
774        threshold: 0,
775        // threshold: 30
776      };
777
778    var config = $.extend({}, defaults, options, block.data("plugin-options"));
779
780    block.filter(":not(.scroll-deferred)").mCustomScrollbar(config);
781    block.filter(".scroll-deferred").mCustomScrollbarDeferred(config);
782  }
783};
784
785var isMobile = jQuery.browser.mobile;
786var players = {};
787
788if (isMobile) {
789  document.documentElement.className += " mobile";
790}
791
792var timerScroll = false,
793  ignoreScroll = [],
794  documentScrollTopLast = $(document).scrollTop(),
795  startScroll = 0;
796
797function pauseMainBanner() {
798  $(".banners-big .flexslider").flexslider("pause");
799}
800
801function playMainBanner() {
802  $(".banners-big .flexslider").flexslider("play");
803}
804
805function startMainBannerSlideVideo($slide) {
806  var slideActiveIndex = $slide.attr("data-slide_index");
807  var $slides = $slide
808    .closest(".items")
809    .find('.item[data-slide_index="' + slideActiveIndex + '"]'); // current slide & cloned
810  var videoSource = $slide.attr("data-video_source");
811  if (videoSource) {
812    if (!$slides.hasClass("started")) {
813      $slides.addClass("loading");
814    }
815    pauseMainBanner();
816
817    var videoPlayerSrc = $slide.attr("data-video_src");
818    var videoSoundDisabled = $slide.attr("data-video_disable_sound");
819    var bVideoSoundDisabled = videoSoundDisabled == 1;
820    var videoLoop = $slide.attr("data-video_loop");
821    var bVideoLoop = videoLoop == 1;
822    var videoCover = $slide.attr("data-video_cover");
823    var bVideoCover = videoCover == 1; //&& !isMobile
824    var videoUnderText = $slide.attr("data-video_under_text");
825    var bVideoUnderText = videoUnderText == 1;
826    var videoPlayer = $slide.attr("data-video_player");
827    var bVideoPlayerYoutube = videoPlayer === "YOUTUBE";
828    var bVideoPlayerVimeo = videoPlayer === "VIMEO";
829    var bVideoPlayerRutube = videoPlayer === "RUTUBE";
830    var bVideoPlayerHtml5 = videoPlayer === "HTML5";
831
832    if (videoPlayerSrc && !$slide.find(".video").length) {
833      var InitPlayer = function () {
834        $slides.each(function (i, node) {
835          var $_slide = $(node);
836          var videoID = getRandomInt(100, 1000);
837          var bClone = $_slide.hasClass("clone"); //,
838          // 	tmp_class = $_slide.attr('id');
839          // if(!$_slide.find('.video.'+tmp_class).length)
840          // {
841
842          if (bVideoPlayerYoutube) {
843            $_slide.prepend(
844              '<div class="wrapper_video"><iframe id="player_' +
845                videoID +
846                '" class="video' +
847                (bVideoCover ? " cover" : "") +
848                '" src="' +
849                videoPlayerSrc +
850                '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen allow="accelerometer; autoplay; encrypted-media; gyroscope; fullscreen;"></iframe></div>'
851            );
852          } else if (bVideoPlayerVimeo) {
853            $_slide.prepend(
854              '<div class="wrapper_video"><iframe id="player_' +
855                videoID +
856                '" class="video' +
857                (bVideoCover ? " cover" : "") +
858                '" src="' +
859                videoPlayerSrc +
860                '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen allow="accelerometer; autoplay; encrypted-media; gyroscope; fullscreen;"></iframe></div>'
861            );
862          } else if (bVideoPlayerRutube) {
863            videoPlayerSrc = videoPlayerSrc + "&playerid=" + videoID;
864            $_slide.prepend(
865              '<div class="wrapper_video"><iframe id="player_' +
866                videoID +
867                '" class="video' +
868                (bVideoCover ? " cover" : "") +
869                '" src="' +
870                videoPlayerSrc +
871                '" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen allow="accelerometer; autoplay; encrypted-media; gyroscope; fullscreen;"></iframe></div>'
872            );
873          } else if (bVideoPlayerHtml5) {
874            $_slide.prepend(
875              '<div class="wrapper_video"><video autobuffer playsinline webkit-playsinline autoplay id="player_' +
876                videoID +
877                '" class="video' +
878                (bVideoCover ? " cover" : "") +
879                '"' +
880                (bVideoLoop ? " loop " : "") +
881                (bVideoSoundDisabled || bClone ? " muted " : "") +
882                '><source src="' +
883                videoPlayerSrc +
884                '" type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\' /><p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that supports HTML5 video</p></video></div>'
885            );
886          }
887          // }
888
889          if (typeof players !== "undefined" && players) {
890            players[videoID] = {
891              id: "player_" + videoID,
892              mute: bVideoSoundDisabled || bClone,
893              loop: bVideoLoop,
894              cover: bVideoCover,
895              videoPlayer: videoPlayer,
896              slideIndex: slideActiveIndex,
897              clone: bClone,
898              playing: false,
899            };
900
901            if (bVideoPlayerYoutube) {
902              window[players[videoID].id] = new YT.Player(players[videoID].id, {
903                events: {
904                  onReady: function (e) {
905                    //var videoID = e.target.f.id.replace('player_', '')
906                    if (videoID) {
907                      var mute = players[videoID].mute;
908                      var cover = players[videoID].cover;
909                      var clone = players[videoID].clone;
910
911                      // mute sound
912                      if (mute || clone) {
913                        window[players[videoID].id].mute();
914                      }
915
916                      // cover video
917                      if (cover) {
918                        CoverPlayer();
919                      }
920
921                      // not start clone video playing
922                      if (clone) {
923                        setTimeout(function () {
924                          e.target.pauseVideo();
925                        }, 100);
926                      } else {
927                        // stop slider
928                        pauseMainBanner();
929                        e.target.playVideo();
930
931                        // e.target.playVideo();
932                        // e.target.playVideo();
933                      }
934
935                      // update slide class
936                      var $slide = $("#player_" + videoID).closest(".item");
937                      $slide.addClass("started");
938                      //$slide.removeClass('loading')
939                    }
940                  },
941                  onStateChange: function (e) {
942                    // var videoID = e.target.a.id.replace('player_', '')
943                    // var videoID = e.target.f.id.replace('player_', '')
944                    if (videoID) {
945                      var clone = players[videoID].clone;
946                      var loop = players[videoID].loop;
947                      var slideIndex = players[videoID].slideIndex;
948                      var $btn = $("#" + players[videoID].id)
949                        .closest(".item")
950                        .find(".btn-video");
951
952                      if (!clone) {
953                        if (e.data === YT.PlayerState.PLAYING) {
954                          players[videoID].playing = true;
955
956                          //$('#player_'+videoID).closest('.item').find('.maxwidth-theme').addClass('loading');
957                          //$('#player_'+videoID).closest('.item').find('.maxwidth-theme .btn-video').addClass('loading');
958                          $btn.addClass("loading");
959
960                          // stop slider
961                          pauseMainBanner();
962
963                          e.target.playVideo();
964                        } else if (e.data === YT.PlayerState.PAUSED) {
965                          players[videoID].playing = false;
966                          $btn.removeClass("loading");
967
968                          // sync time in cloned players & pause
969                          var time =
970                            Math.floor(
971                              window[players[videoID].id].getCurrentTime() * 10
972                            ) / 10;
973
974                          window[players[videoID].id].seekTo(time, true);
975                          for (var j in players) {
976                            if (
977                              players[j].slideIndex == slideIndex &&
978                              players[j].clone
979                            ) {
980                              if ("getCurrentTime" in window[players[j].id]) {
981                                window[players[j].id].pauseVideo();
982                                window[players[j].id].seekTo(time, true);
983                              }
984                            }
985                          }
986                        } else if (e.data === YT.PlayerState.ENDED) {
987                          players[videoID].playing = false;
988                          $btn.removeClass("loading");
989                          if (loop) {
990                            e.target.playVideo();
991                          } else {
992                            // play slider
993                            playMainBanner();
994                          }
995                        }
996                      }
997                    }
998                  },
999                },
1000              });
1001            } else if (bVideoPlayerVimeo) {
1002              window[players[videoID].id] = new Vimeo.Player(
1003                document.getElementById(players[videoID].id),
1004                { autopause: false, byline: false, loop: false, title: false }
1005              );
1006              window[players[videoID].id].on("loaded", onVimeoPlayerReady);
1007              window[players[videoID].id].on("play", onVimeoPlayerStateChange);
1008              window[players[videoID].id].on("pause", onVimeoPlayerStateChange);
1009              window[players[videoID].id].on("ended", onVimeoPlayerStateChange);
1010            } else if (bVideoPlayerRutube) {
1011              document.getElementById(players[videoID].id).onload = function (
1012                e
1013              ) {
1014                var videoID = this.id.replace("player_", "");
1015                players[videoID].contentWindow = this.contentWindow;
1016                onRutubePlayerReady(videoID);
1017              };
1018            } else if (bVideoPlayerHtml5) {
1019              document
1020                .getElementById(players[videoID].id)
1021                .addEventListener("loadeddata", onHtml5PlayerReady);
1022              document
1023                .getElementById(players[videoID].id)
1024                .addEventListener("play", onHtml5PlayerStateChange);
1025              document
1026                .getElementById(players[videoID].id)
1027                .addEventListener("pause", onHtml5PlayerStateChange);
1028              document
1029                .getElementById(players[videoID].id)
1030                .addEventListener("ended", onHtml5PlayerStateChange);
1031            }
1032          }
1033        });
1034      };
1035
1036      if (!bVideoPlayerHtml5) {
1037        var obPlayerVariable = "";
1038        var fnPlayerVariable = "";
1039        if (typeof window["YoutubePlayerScriptLoaded"] === "undefined") {
1040          window["YoutubePlayerScriptLoaded"] = false;
1041        }
1042        if (typeof window["VimeoPlayerScriptLoaded"] === "undefined") {
1043          window["VimeoPlayerScriptLoaded"] = false;
1044        }
1045        if (typeof window["RutubePlayerListnersAdded"] === "undefined") {
1046          window["RutubePlayerListnersAdded"] = false;
1047        }
1048
1049        // load script
1050        if (bVideoPlayerYoutube) {
1051          obPlayerVariable = "YT";
1052          fnPlayerVariable = "Player";
1053          if (!window["YoutubePlayerScriptLoaded"]) {
1054            var script = document.createElement("script");
1055            script.src = "https://www.youtube.com/iframe_api";
1056            var firstScriptTag = document.getElementsByTagName("script")[0];
1057            firstScriptTag.parentNode.insertBefore(script, firstScriptTag);
1058            window["YoutubePlayerScriptLoaded"] = true;
1059          }
1060        } else if (bVideoPlayerVimeo) {
1061          obPlayerVariable = "Vimeo";
1062          if (!window["VimeoPlayerScriptLoaded"]) {
1063            var script = document.createElement("script");
1064            script.src = "https://player.vimeo.com/api/player.js";
1065            (document.head || document.documentElement).appendChild(script);
1066            window["VimeoPlayerScriptLoaded"] = true;
1067          }
1068        } else if (bVideoPlayerRutube) {
1069          if (!window["RutubePlayerListnersAdded"]) {
1070            window.addEventListener("message", function (e) {
1071              if (e.origin.indexOf("rutube.ru") !== -1) {
1072                var message = JSON.parse(e.data);
1073                if (typeof message === "object" && message) {
1074                  if (typeof message.type !== "undefined" && message.type) {
1075                    var videoID = false;
1076
1077                    for (var j in players) {
1078                      if (typeof players[j].contentWindow !== "undefined") {
1079                        if (players[j].contentWindow == e.source) {
1080                          videoID = j;
1081                          break;
1082                        }
1083                      }
1084                    }
1085
1086                    if (videoID) {
1087                      switch (message.type) {
1088                        case "player:changeState":
1089                          onRutubePlayerStateChange(
1090                            videoID,
1091                            message.data.state
1092                          );
1093                          break;
1094                        case "player:currentTime":
1095                          onRutubePlayerCurrentTime(videoID, message.data.time);
1096                          break;
1097                      }
1098                    }
1099                  }
1100                }
1101              }
1102            });
1103          }
1104        }
1105
1106        if (!obPlayerVariable.length) {
1107          InitPlayer();
1108        } else {
1109          // wait player class
1110          if (typeof window[obPlayerVariable] === "object") {
1111            if (
1112              !fnPlayerVariable.length ||
1113              (fnPlayerVariable.length &&
1114                typeof window[obPlayerVariable][fnPlayerVariable] ===
1115                  "function")
1116            ) {
1117              InitPlayer();
1118            }
1119          } else {
1120            var waitPlayerInterval = setInterval(function () {
1121              if (typeof window[obPlayerVariable] === "object") {
1122                if (
1123                  !fnPlayerVariable.length ||
1124                  (fnPlayerVariable.length &&
1125                    typeof window[obPlayerVariable][fnPlayerVariable] ===
1126                      "function")
1127                ) {
1128                  clearInterval(waitPlayerInterval);
1129
1130                  InitPlayer();
1131                }
1132              }
1133            }, 50);
1134          }
1135        }
1136      } else {
1137        InitPlayer();
1138      }
1139    } else {
1140      // pause play video
1141      if (typeof players !== "undefined" && players) {
1142        for (var j in players) {
1143          if (
1144            /*players[j].playing &&*/ !players[j]
1145              .clone /* && (players[j].slideIndex != curSlideIndex)*/
1146          ) {
1147            if (typeof window[players[j].id] == "object") {
1148              if (players[j].playing) {
1149                if (players[j].videoPlayer === "YOUTUBE") {
1150                  window[players[j].id].pauseVideo();
1151                } else if (players[j].videoPlayer === "VIMEO") {
1152                  window[players[j].id].pause();
1153                } else if (players[j].videoPlayer === "RUTUBE") {
1154                  document
1155                    .getElementById(players[j].id)
1156                    .contentWindow.postMessage(
1157                      JSON.stringify({
1158                        type: "player:pause",
1159                        data: {},
1160                      }),
1161                      "*"
1162                    );
1163                } else if (players[j].videoPlayer === "HTML5") {
1164                  document.getElementById(players[j].id).pause();
1165                }
1166              } else if (players[j].slideIndex == slideActiveIndex) {
1167                if (players[j].videoPlayer === "YOUTUBE") {
1168                  window[players[j].id].playVideo();
1169                } else if (players[j].videoPlayer === "VIMEO") {
1170                  window[players[j].id].play();
1171                } else if (players[j].videoPlayer === "RUTUBE") {
1172                  document
1173                    .getElementById(players[j].id)
1174                    .contentWindow.postMessage(
1175                      JSON.stringify({
1176                        type: "player:play",
1177                        data: {},
1178                      }),
1179                      "*"
1180                    );
1181                } else if (players[j].videoPlayer === "HTML5") {
1182                  document.getElementById(players[j].id).play();
1183                }
1184              }
1185            }
1186          }
1187        }
1188      }
1189    }
1190  }
1191}
1192
1193var CoverPlayer = function () {
1194  var $videoCover = $(".video.cover");
1195  if ($videoCover.length) {
1196    var bannersHeight = $(".banners-big").height();
1197    var bannersWidth = $(".banners-big").width();
1198    var windowWidth = $(window).width();
1199    var height = (windowWidth * 2.4) / 3.55;
1200    height = height < 240 ? 240 : height;
1201    height = height > 240 && height < 660 ? 660 : height;
1202    $videoCover.css({
1203      height: height + "px",
1204      "margin-top": (bannersHeight - height) / 2 + "px",
1205    });
1206  }
1207};
1208
1209function onVimeoPlayerReady(e) {
1210  var videoID = this.element.id.replace("player_", "");
1211  if (videoID) {
1212    var mute = players[videoID].mute;
1213    var cover = players[videoID].cover;
1214    var clone = players[videoID].clone;
1215
1216    // mute sound
1217    if (mute || clone) {
1218      window[players[videoID].id].setVolume(0);
1219    }
1220
1221    // cover video
1222    if (cover) {
1223      CoverPlayer();
1224    }
1225
1226    // not start clone video playing
1227    if (clone) {
1228      setTimeout(function () {
1229        window[players[videoID].id].pause();
1230      }, 100);
1231    } else {
1232      // stop slider
1233      pauseMainBanner();
1234
1235      window[players[videoID].id].play();
1236    }
1237
1238    // update slide class
1239    var $slide = $("#player_" + videoID).closest(".item");
1240    $slide.addClass("started");
1241    // $slide.removeClass('loading')
1242  }
1243}
1244
1245function onVimeoPlayerStateChange(e) {
1246  var videoID = this.element.id.replace("player_", "");
1247  if (videoID) {
1248    var cover = players[videoID].cover;
1249    var clone = players[videoID].clone;
1250    var loop = players[videoID].loop;
1251    var slideIndex = players[videoID].slideIndex;
1252    var $btn = $("#" + players[videoID].id)
1253      .closest(".item")
1254      .find(".btn-video");
1255
1256    if (!clone) {
1257      window[players[videoID].id].getPaused().then(function (paused) {
1258        if (paused) {
1259          players[videoID].playing = false;
1260          $btn.removeClass("loading");
1261          // sync time in cloned players & pause
1262          window[players[videoID].id].getCurrentTime().then(function (seconds) {
1263            var time = Math.floor(seconds * 10) / 10;
1264            window[players[videoID].id]
1265              .setCurrentTime(time)
1266              .then(function (seconds) {
1267                for (var j in players) {
1268                  if (players[j].slideIndex == slideIndex && players[j].clone) {
1269                    window[players[j].id].pause();
1270                    window[players[j].id]
1271                      .setCurrentTime(time)
1272                      .then(function (seconds) {});
1273                  }
1274                }
1275              });
1276          });
1277        } else {
1278          //$('#player_'+videoID).closest('.item').find('.maxwidth-theme').addClass('loading');
1279          // $('#player_'+videoID).closest('.item').find('.maxwidth-theme .btn-video').addClass('loading');
1280          window[players[videoID].id].getEnded().then(function (ended) {
1281            if (ended) {
1282              players[videoID].playing = false;
1283              $btn.removeClass("loading");
1284              if (loop) {
1285                window[players[videoID].id].play();
1286              } else {
1287                // play slider
1288                playMainBanner();
1289              }
1290            } else {
1291              players[videoID].playing = true;
1292              $btn.addClass("loading");
1293
1294              // stop slider
1295              pauseMainBanner();
1296            }
1297          });
1298        }
1299      });
1300    }
1301  }
1302}
1303
1304function onRutubePlayerReady(videoID) {
1305  if (videoID) {
1306    var mute = players[videoID].mute;
1307    var cover = players[videoID].cover;
1308    var clone = players[videoID].clone;
1309    var player = document.getElementById(players[videoID].id);
1310
1311    // mute sound
1312    if (mute || clone) {
1313      player.contentWindow.postMessage(
1314        JSON.stringify({
1315          type: "player:mute",
1316          data: {},
1317        }),
1318        "*"
1319      );
1320    }
1321
1322    // cover video
1323    if (cover) {
1324      CoverPlayer();
1325    }
1326
1327    // not start clone video playing
1328    if (clone) {
1329      setTimeout(function () {
1330        player.contentWindow.postMessage(
1331          JSON.stringify({
1332            type: "player:pause",
1333            data: {},
1334          }),
1335          "*"
1336        );
1337      }, 100);
1338    } else {
1339      // stop slider
1340      pauseMainBanner();
1341
1342      player.contentWindow.postMessage(
1343        JSON.stringify({
1344          type: "player:play",
1345          data: {},
1346        }),
1347        "*"
1348      );
1349    }
1350
1351    // update slide class
1352    var $slide = $("#player_" + videoID).closest(".item");
1353    $slide.addClass("started");
1354    // $slide.removeClass('loading')
1355  }
1356}
1357
1358function onRutubePlayerCurrentTime(videoID, time) {
1359  if (videoID) {
1360    players[videoID].time = time;
1361  }
1362}
1363
1364function onRutubePlayerStateChange(videoID, state) {
1365  if (videoID) {
1366    var clone = players[videoID].clone;
1367    var loop = players[videoID].loop;
1368    var slideIndex = players[videoID].slideIndex;
1369    var player = document.getElementById(players[videoID].id);
1370
1371    if (!clone) {
1372      if (state === "playing") {
1373        $("#" + videoID)
1374          .closest(".item")
1375          .find(".maxwidth-theme")
1376          .addClass("loading");
1377        $("#" + videoID)
1378          .closest(".item")
1379          .find(".maxwidth-theme .btn-video")
1380          .addClass("loading");
1381
1382        players[videoID].playing = true;
1383
1384        // stop slider
1385        pauseMainBanner();
1386      } else if (state === "paused") {
1387        players[videoID].playing = false;
1388
1389        // sync time in cloned players & pause
1390        var time = Math.floor(players[videoID].time * 10) / 10;
1391        player.contentWindow.postMessage(
1392          JSON.stringify({
1393            type: "player:setCurrentTime",
1394            data: { time: time },
1395          }),
1396          "*"
1397        );
1398        for (var j in players) {
1399          if (players[j].slideIndex == slideIndex && players[j].clone) {
1400            document.getElementById(players[j].id).contentWindow.postMessage(
1401              JSON.stringify({
1402                type: "player:pause",
1403                data: {},
1404              }),
1405              "*"
1406            );
1407            document.getElementById(players[j].id).contentWindow.postMessage(
1408              JSON.stringify({
1409                type: "player:setCurrentTime",
1410                data: { time: time },
1411              }),
1412              "*"
1413            );
1414          }
1415        }
1416      } else if (state === "stopped") {
1417        $("#" + videoID)
1418          .closest(".item")
1419          .find(".maxwidth-theme")
1420          .removeClass("loading");
1421        $("#" + videoID)
1422          .closest(".item")
1423          .find(".maxwidth-theme .btn-video")
1424          .removeClass("loading");
1425
1426        players[videoID].playing = false;
1427        if (loop) {
1428          player.contentWindow.postMessage(
1429            JSON.stringify({
1430              type: "player:play",
1431              data: {},
1432            }),
1433            "*"
1434          );
1435        } else {
1436          // play slider
1437          playMainBanner();
1438        }
1439      }
1440    }
1441  }
1442}
1443
1444function onHtml5PlayerReady(e) {
1445  var videoID = e.target.id.replace("player_", "");
1446  if (videoID) {
1447    var mute = players[videoID].mute;
1448    var cover = players[videoID].cover;
1449    var clone = players[videoID].clone;
1450
1451    // mute sound
1452    if (mute || clone) {
1453      $("#" + players[videoID].id).prop("muted", true);
1454    }
1455
1456    // cover video
1457    if (cover) {
1458      CoverPlayer();
1459    }
1460
1461    // not start clone video playing
1462    if (clone) {
1463      e.target.pause();
1464    } else {
1465      // stop slider
1466      pauseMainBanner();
1467
1468      e.target.play();
1469    }
1470
1471    // update slide class
1472    var $slide = $("#player_" + videoID).closest(".item");
1473    $slide.addClass("started");
1474    // $slide.removeClass('loading')
1475  }
1476}
1477
1478function onHtml5PlayerStateChange(e) {
1479  var videoID = e.target.id.replace("player_", "");
1480  if (videoID) {
1481    var cover = players[videoID].cover;
1482    var clone = players[videoID].clone;
1483    var loop = players[videoID].loop;
1484    var slideIndex = players[videoID].slideIndex;
1485
1486    if (!clone) {
1487      if (e.target.paused) {
1488        players[videoID].playing = false;
1489
1490        // sync time in cloned players & pause
1491        var time = Math.floor(e.target.currentTime * 10) / 10;
1492        e.target.currentTime = time;
1493        for (var j in players) {
1494          if (players[j].slideIndex == slideIndex && players[j].clone) {
1495            document.getElementById(players[j].id).pause();
1496            document.getElementById(players[j].id).currentTime = time;
1497          }
1498        }
1499      } else if (e.target.ended) {
1500        players[videoID].playing = false;
1501        if (loop) {
1502          $("#player_" + videoID)
1503            .closest(".item")
1504            .find(".maxwidth-theme")
1505            .addClass("loading");
1506          $("#player_" + videoID)
1507            .closest(".item")
1508            .find(".maxwidth-theme .btn-video")
1509            .addClass("loading");
1510
1511          e.target.play();
1512        } else {
1513          // play slider
1514          playMainBanner();
1515        }
1516      } else {
1517        players[videoID].playing = true;
1518        if (!$(this).closest(".banners-big").hasClass("view_2")) {
1519          $("#player_" + videoID)
1520            .closest(".item")
1521            .find(".maxwidth-theme")
1522            .addClass("loading");
1523          $("#player_" + videoID)
1524            .closest(".item")
1525            .find(".maxwidth-theme .btn-video")
1526            .addClass("loading");
1527        }
1528        // stop slider
1529        pauseMainBanner();
1530      }
1531    }
1532  }
1533}
1534
1535$.fn.equalizeHeights = function (outer, classNull, minHeight, autoHeightBlock) {
1536  var maxHeight = this.map(function (i, e) {
1537    var minus_height = 0,
1538      calc_height = 0;
1539    if (classNull !== false && $(e).find(classNull).is(":visible"))
1540      minus_height = parseInt($(e).find(classNull).actual("outerHeight"));
1541    if (minus_height) minus_height += 15;
1542    $(e).css("height", "");
1543    if (autoHeightBlock !== false) {
1544      var height_tmp = $(e).find(autoHeightBlock).css("height");
1545      $(e).find(autoHeightBlock).css("height", "");
1546    }
1547    if (outer == true) {
1548      calc_height = $(e).actual("outerHeight") - minus_height;
1549    } else {
1550      calc_height = $(e).actual("height") - minus_height;
1551    }
1552
1553    if (autoHeightBlock !== false) {
1554      $(e).find(autoHeightBlock).css("height", height_tmp);
1555    }
1556    if (minHeight !== false) {
1557      if (calc_height < minHeight) {
1558        calc_height += minHeight - calc_height;
1559      }
1560      if (window.matchMedia("(max-width: 520px)").matches) {
1561        calc_height = 300;
1562      }
1563      if (window.matchMedia("(max-width: 400px)").matches) {
1564        calc_height = 200;
1565      }
1566    }
1567    return calc_height;
1568  }).get();
1569
1570  for (var i = 0, c = maxHeight.length; i < c; ++i) {
1571    if (maxHeight[i] % 2) {
1572      --maxHeight[i];
1573    }
1574  }
1575
1576  return this.height(Math.max.apply(this, maxHeight));
1577};
1578
1579$.fn.getFloatWidth = function () {
1580  var width = 0;
1581
1582  if ($(this).length) {
1583    var rect = $(this)[0].getBoundingClientRect();
1584    if (!(width = rect.width)) {
1585      width = rect.right - rect.left;
1586    }
1587  }
1588
1589  return width;
1590};
1591
1592$.fn.sliceHeight = function (options) {
1593  function _slice(el) {
1594    el.each(function () {
1595      $(this).css("line-height", "");
1596      $(this).css("height", "");
1597    });
1598    if (
1599      typeof options.autoslicecount == "undefined" ||
1600      options.autoslicecount !== false
1601    ) {
1602      var elsw =
1603          typeof options.row !== "undefined" && options.row.length
1604            ? el.first().parents(options.row).getFloatWidth()
1605            : el.first().parents(".items").getFloatWidth(),
1606        elw =
1607          typeof options.item !== "undefined" && options.item.length
1608            ? $(options.item).first().getFloatWidth()
1609            : el.first().hasClass("item")
1610            ? el.first().getFloatWidth()
1611            : el.first().parents(".item").getFloatWidth();
1612
1613      if (!elsw) {
1614        elsw = el.first().parents(".row").getFloatWidth();
1615      }
1616      if (elw && options.fixWidth) elw -= options.fixWidth;
1617
1618      if (elsw && elw) {
1619        options.slice = Math.floor(elsw / elw);
1620      }
1621    }
1622    if (
1623      typeof options.typeResize == "undefined" ||
1624      options.typeResize == false
1625    ) {
1626      if (options.sliceEqualLength && el.closest(".flexslider").length)
1627        options.slice = el.length;
1628      if (options.slice) {
1629        for (var i = 0; i < el.length; i += options.slice) {
1630          $(el.slice(i, i + options.slice)).equalizeHeights(
1631            options.outer,
1632            options.classNull,
1633            options.minHeight,
1634            options.autoHeightBlock
1635          );
1636        }
1637      }
1638      if (options.lineheight) {
1639        var lineheightAdd = parseInt(options.lineheight);
1640        if (isNaN(lineheightAdd)) {
1641          lineheightAdd = 0;
1642        }
1643        el.each(function () {
1644          $(this).css(
1645            "line-height",
1646            $(this).actual("height") + lineheightAdd + "px"
1647          );
1648        });
1649      }
1650    }
1651
1652    if (typeof options.callback == "function") options.callback(el);
1653  }
1654  var options = $.extend(
1655    {
1656      slice: null,
1657      outer: false,
1658      lineheight: false,
1659      autoslicecount: true,
1660      classNull: false,
1661      minHeight: false,
1662      row: false,
1663      item: false,
1664      typeResize: false,
1665      resize: true,
1666      typeValue: false,
1667      sliceEqualLength: false,
1668      fixWidth: 0,
1669      callback: false,
1670      autoHeightBlock: false,
1671    },
1672    options
1673  );
1674
1675  var el = $(this);
1676  ignoreResize.push(true);
1677  _slice(el);
1678  ignoreResize.pop();
1679
1680  if (options.resize != false) {
1681    BX.addCustomEvent("onWindowResize", function (eventdata) {
1682      ignoreResize.push(true);
1683      _slice(el);
1684      ignoreResize.pop();
1685    });
1686  }
1687};
1688
1689waitingExists = function (selector, delay, callback) {
1690  if (typeof callback !== "undefined" && selector.length && delay > 0) {
1691    delay = parseInt(delay);
1692    delay = delay < 0 ? 0 : delay;
1693
1694    if (!$(selector).length) {
1695      setTimeout(function () {
1696        waitingExists(selector, delay, callback);
1697      }, delay);
1698    } else {
1699      callback();
1700    }
1701  }
1702};
1703
1704waitingNotExists = function (
1705  selectorExists,
1706  selectorNotExists,
1707  delay,
1708  callback
1709) {
1710  if (
1711    typeof callback !== "undefined" &&
1712    selectorExists.length &&
1713    selectorNotExists.length &&
1714    delay > 0
1715  ) {
1716    delay = parseInt(delay);
1717    delay = delay < 0 ? 0 : delay;
1718
1719    setTimeout(function () {
1720      if (selectorExists.length && !$(selectorNotExists).length) {
1721        callback();
1722      }
1723    }, delay);
1724  }
1725};
1726
1727function onLoadjqm(hash) {
1728  var name = $(hash.t).data("name"),
1729    top =
1730      ($(window).height() > hash.w.height()
1731        ? Math.floor(($(window).height() - hash.w.height()) / 2)
1732        : 0) + "px";
1733  $.each($(hash.t).get(0).attributes, function (index, attr) {
1734    if (/^data\-autoload\-(.+)$/.test(attr.nodeName)) {
1735      var key = attr.nodeName.match(/^data\-autoload\-(.+)$/)[1];
1736      var el = $('input[name="' + key.toUpperCase() + '"]');
1737      if (!el.length)
1738        //is form block
1739        el = $('input[data-sid="' + key.toUpperCase() + '"]');
1740
1741      var value = $(hash.t).data("autoload-" + key);
1742      value = value.replace(/%99/g, "\\"); // replace symbol \
1743
1744      el.val(BX.util.htmlspecialcharsback(value)).attr("readonly", "readonly");
1745      el.closest(".form-group").addClass("input-filed");
1746      el.attr("title", el.val());
1747    }
1748  });
1749  if (hash.c.noOverlay === undefined || (hash.c.noOverlay !== undefined && !hash.c.noOverlay)) {
1750    $("body").css({ overflow: "hidden", height: "100vh"});
1751    hash.w.closest("#popup_iframe_wrapper").css({ "z-index": 3000, display: "flex" });
1752  }
1753  var eventdata = { action: "loadForm" };
1754  BX.onCustomEvent("onCompleteAction", [eventdata, $(hash.t)[0]]);
1755
1756  if ($(hash.t).data("autohide")) {
1757    $(hash.w).data("autohide", $(hash.t).data("autohide"));
1758  }
1759  if (name == "order_product") {
1760    if ($(hash.t).data("product")) {
1761      $('input[name="PRODUCT"]').closest(".form-group").addClass("input-filed");
1762      $('input[name="PRODUCT"]')
1763        .val($(hash.t).data("product"))
1764        .attr("readonly", "readonly")
1765        .attr("title", $('input[name="PRODUCT"]').val());
1766    }
1767  }
1768  if (name == "question") {
1769    if ($(hash.t).data("product")) {
1770      $('input[name="NEED_PRODUCT"]')
1771        .closest(".form-group")
1772        .addClass("input-filed");
1773      $('input[name="NEED_PRODUCT"]')
1774        .val($(hash.t).data("product"))
1775        .attr("readonly", "readonly")
1776        .attr("title", $('input[name="NEED_PRODUCT"]').val());
1777    }
1778  }
1779
1780  if (
1781    arAllcorp2Options["THEME"]["REGIONALITY_SEARCH_ROW"] == "Y" &&
1782    (hash.w.hasClass("city_chooser_frame ") ||
1783      hash.w.hasClass("city_chooser_small_frame"))
1784  )
1785    hash.w.addClass("small_popup_regions");
1786
1787  hash.w.addClass("show").css({
1788    //"margin-left": "-" + Math.floor(hash.w.width() / 2) + "px",
1789    //top: top,
1790    opacity: 1,
1791  });
1792  hash.w.addClass("scrollblock");
1793
1794  //show password eye
1795  if (hash.w.hasClass("auth_frame")) {
1796    hash.w.find(".form-group:not(.eye-password-ignore) [type=password]").each(function (item) {
1797      $(this).closest(".form-group").addClass("eye-password");
1798    });
1799  }
1800}
1801
1802function onHide(hash) {
1803  if ($(hash.w).data("autohide")) {
1804    eval($(hash.w).data("autohide"));
1805  }
1806  if (!hash.w.closest("#popup_iframe_wrapper").find(".jqmOverlay").length) {
1807    hash.w.closest("#popup_iframe_wrapper").css({ "z-index": "", display: "" });
1808  }
1809  // hash.w.css('opacity', 0).hide();
1810  hash.w.animate({ opacity: 0 }, 200, function () {
1811    hash.w.hide();
1812    hash.w.empty();
1813    hash.o.remove();
1814    hash.w.removeClass("show");
1815    $("body").css({ overflow: "", height: "" });
1816    if (!hash.w.closest("#popup_iframe_wrapper").find(".jqmOverlay").length) {
1817      hash.w.closest("#popup_iframe_wrapper").css({ "z-index": "", display: "" });
1818    }
1819  });
1820}
1821
1822function parseUrlQuery() {
1823  var data = {};
1824  if (location.search) {
1825    var pair = location.search.substr(1).split("&");
1826    for (var i = 0; i < pair.length; i++) {
1827      var param = pair[i].split("=");
1828      data[param[0]] = param[1];
1829    }
1830  }
1831  return data;
1832}
1833
1834function scroll_block(block) {
1835  if (block.length) {
1836    var topPos = block.offset().top,
1837      headerH = $("header").outerHeight(true, true);
1838    if ($(".stores_tab").length) {
1839      $(".stores_tab").addClass("active").siblings().removeClass("active");
1840    } else {
1841      $(".prices_tab").addClass("active").siblings().removeClass("active");
1842      if (
1843        $(".prices_tab .opener").length &&
1844        !$(".prices_tab .opener .opened").length
1845      ) {
1846        var item = $(".prices_tab .opener").first();
1847        item.find(".opener_icon").addClass("opened");
1848        item.parents("tr").addClass("nb");
1849        item
1850          .parents("tr")
1851          .next(".offer_stores")
1852          .find(".stores_block_wrap")
1853          .slideDown(200);
1854      }
1855    }
1856    $("html,body").animate({ scrollTop: topPos - 80 }, 150);
1857  }
1858}
1859
1860$.fn.jqmEx = function () {
1861  $(this).each(function () {
1862    var _this = $(this);
1863    var name = _this.data("name");
1864
1865    if (name.length) {
1866      var script = arAllcorp2Options["SITE_DIR"] + "ajax/form.php";
1867      var paramsStr = "";
1868      var trigger = "";
1869      var arTriggerAttrs = {};
1870      $.each(_this.get(0).attributes, function (index, attr) {
1871        var attrName = attr.nodeName;
1872        var attrValue = _this.attr(attrName);
1873        trigger += "[" + attrName + '="' + attrValue + '"]';
1874        arTriggerAttrs[attrName] = attrValue;
1875        if (/^data\-param\-(.+)$/.test(attrName)) {
1876          var key = attrName.match(/^data\-param\-(.+)$/)[1];
1877          paramsStr += key + "=" + attrValue + "&";
1878        }
1879      });
1880      var triggerAttrs = JSON.stringify(arTriggerAttrs);
1881      var encTriggerAttrs = encodeURIComponent(triggerAttrs);
1882
1883      if (name == "auth") script += "?" + paramsStr + "auth=Y";
1884      else script += "?" + paramsStr + "data-trigger=" + encTriggerAttrs;
1885
1886      if (
1887        !$("." + name + '_frame[data-trigger="' + encTriggerAttrs + '"]').length
1888      ) {
1889        if (_this.attr("disabled") != "disabled") {
1890          $("body #popup_iframe_wrapper")
1891            .find("." + name + '_frame[data-trigger="' + encTriggerAttrs + '"]')
1892            .remove();
1893          $("body #popup_iframe_wrapper").append(
1894            '<div class="' +
1895              name +
1896              '_frame jqmWindow" style="width:500px" data-trigger="' +
1897              encTriggerAttrs +
1898              '"></div>'
1899          );
1900          $("." + name + '_frame[data-trigger="' + encTriggerAttrs + '"]').jqm({
1901            trigger: trigger,
1902            onLoad: function (hash) {
1903              onLoadjqm(hash);
1904            },
1905            onHide: function (hash) {
1906              onHide(hash);
1907            },
1908            ajax: script,
1909          });
1910        }
1911      }
1912    }
1913    return;
1914  });
1915};
1916
1917InitFlexSlider = function () {
1918  $(".flexslider:not(.thmb):not(.flexslider-init):visible").each(function () {
1919    var slider = $(this);
1920    var options;
1921    var defaults = {
1922      animationLoop: false,
1923      controlNav: false,
1924      directionNav: true,
1925      animation: "slide",
1926    };
1927    var config = $.extend({}, defaults, options, slider.data("plugin-options"));
1928    if (
1929      typeof config.counts != "undefined" &&
1930      config.direction !== "vertical"
1931    ) {
1932      var slide_counts = "";
1933      if (typeof slider.data("plugin-options") != "undefined") {
1934        if ("slide_counts" in slider.data("plugin-options"))
1935          slide_counts = slider.data("plugin-options").slide_counts;
1936      }
1937      config.maxItems = getGridSize(config.counts);
1938      config.minItems = getGridSize(config.counts);
1939
1940      if (slide_counts) config.move = slide_counts;
1941      else config.move = getGridSize(config.counts);
1942
1943      config.itemWidth = 200;
1944    }
1945
1946    // custom direction nav
1947    if (typeof config.customDirection != "undefined")
1948      config.customDirectionNav = $(config.customDirection);
1949
1950    (config.prevText = BX.message("FANCY_PREV")), //String: Set the text for the "previous" directionNav item
1951      (config.nextText = BX.message("FANCY_NEXT")),
1952      (config.after = config.start =
1953        function (slider) {
1954          var eventdata = { slider: slider };
1955          BX.onCustomEvent("onSlide", [eventdata]);
1956        });
1957
1958    config.before = function (slider) {
1959      var eventdata = { slider: slider };
1960      BX.onCustomEvent("onSlideBefore", [eventdata]);
1961    };
1962
1963    config.end = function (slider) {
1964      var eventdata = { slider: slider };
1965      BX.onCustomEvent("onSlideEnd", [eventdata]);
1966    };
1967
1968    /*if(typeof(config.nav) == 'undefined')
1969			slider.addClass('dark-nav');*/
1970    slider.flexslider(config).addClass("flexslider-init");
1971    if (config.controlNav) slider.addClass("flexslider-control-nav");
1972    if (config.directionNav) slider.addClass("flexslider-direction-nav");
1973  });
1974};
1975
1976InitFlexSliderClass = function (class_name) {
1977  //$('.flexslider:not(.thmb):not(.flexslider-init)').each(function(){
1978
1979  var slider = $(class_name);
1980  var options;
1981  var defaults = {
1982    animationLoop: false,
1983    controlNav: false,
1984    directionNav: true,
1985    animation: "slide",
1986  };
1987  var config = $.extend({}, defaults, options, slider.data("plugin-options"));
1988
1989  var slide_counts = "";
1990  if (typeof slider.data("plugin-options") != "undefined") {
1991    if ("slide_counts" in slider.data("plugin-options"))
1992      slide_counts = slider.data("plugin-options").slide_counts;
1993  }
1994
1995  if (typeof config.counts != "undefined" && config.direction !== "vertical") {
1996    config.maxItems = getGridSize(config.counts);
1997    config.minItems = getGridSize(config.counts);
1998    config.move = getGridSize(config.counts);
1999
2000    config.itemWidth = 200;
2001  }
2002  if (slide_counts) config.move = slide_counts;
2003
2004  // custom direction nav
2005  if (typeof config.customDirection != "undefined")
2006    config.customDirectionNav = $(config.customDirection);
2007
2008  (config.prevText = BX.message("FANCY_PREV")), //String: Set the text for the "previous" directionNav item
2009    (config.nextText = BX.message("FANCY_NEXT")),
2010    (config.after = config.start =
2011      function (slider) {
2012        var eventdata = { slider: slider };
2013        BX.onCustomEvent("onSlide", [eventdata]);
2014      });
2015
2016  config.before = function (slider) {
2017    var eventdata = { slider: slider };
2018    BX.onCustomEvent("onSlideBefore", [eventdata]);
2019  };
2020
2021  config.end = function (slider) {
2022    var eventdata = { slider: slider };
2023    BX.onCustomEvent("onSlideEnd", [eventdata]);
2024  };
2025
2026  slider.flexslider(config).addClass("flexslider-init");
2027  if (config.controlNav) slider.addClass("flexslider-control-nav");
2028  if (config.directionNav) slider.addClass("flexslider-direction-nav");
2029  //});
2030};
2031
2032InitFlexSliderMin = function () {
2033  $(".bxSlider.top-small").on("mousedown", ".slides li", function () {
2034    var index = $(this).data("slide_key");
2035    $(this).siblings().removeClass("flex-active-slide");
2036    $(this).addClass("flex-active-slide");
2037    $(this)
2038      .siblings('[data-slide_key="' + index + '"]')
2039      .addClass("flex-active-slide");
2040    $(".top-bigs").data("flexslider").flexAnimate(index);
2041  });
2042};
2043
2044SliceHeightBlocks = function () {
2045  $('*[data-slice="Y"]').each(function () {
2046    var slice_els = $(this).find('*[data-slice-block="Y"]');
2047    if (slice_els.length) {
2048      var slice_params = {};
2049      if (slice_els.data("slice-params"))
2050        slice_params = slice_els.data("slice-params");
2051      slice_els.sliceHeight(slice_params);
2052    }
2053  });
2054};
2055
2056createTableCompare = function (originalTable, appendDiv, cloneTable) {
2057  try {
2058    if ($(".tarifs .head-block:visible").length) {
2059      var clone = originalTable.clone().addClass("clone");
2060      if (cloneTable.length) {
2061        cloneTable.remove();
2062        appendDiv.html("");
2063        appendDiv.html(clone);
2064      } else {
2065        appendDiv.append(clone);
2066      }
2067    }
2068  } catch (e) {
2069  } finally {
2070  }
2071};
2072
2073InitTopestMenuGummi = function () {
2074  if (!isOnceInited) {
2075    function _init() {
2076      var arItems = $menuTopest.find(">li:not(.more)");
2077      var cntItems = arItems.length;
2078      if (cntItems) {
2079        var itemsWidth = 0;
2080        for (var i = 0; i < cntItems; ++i) {
2081          var item = arItems.eq(i);
2082          var itemWidth = item.actual("outerWidth", { includeMargin: true });
2083          arItemsHideWidth[i] =
2084            (itemsWidth += itemWidth) + (i !== cntItems - 1 ? moreWidth : 0);
2085        }
2086      }
2087    }
2088
2089    function _gummi() {
2090      var rowWidth = $menuTopest.actual("innerWidth");
2091      var arItems = $menuTopest.find(">li:not(.more),li.more>.dropdown>li");
2092      var cntItems = arItems.length;
2093      if (cntItems) {
2094        var bMore = false;
2095        for (var i = cntItems - 1; i >= 0; --i) {
2096          var item = arItems.eq(i);
2097          var bInMore = item.parents(".more").length > 0;
2098          if (!bInMore) {
2099            if (arItemsHideWidth[i] > rowWidth) {
2100              if (!bMore) {
2101                bMore = true;
2102                more.removeClass("hidden");
2103              }
2104              var clone = item.clone();
2105              clone.find(">a").addClass("dark_font");
2106              clone.prependTo(moreDropdown);
2107              item.addClass("cloned");
2108            }
2109          }
2110        }
2111        for (var i = 0; i < cntItems; ++i) {
2112          var item = arItems.eq(i);
2113          var bInMore = item.parents(".more").length > 0;
2114          if (bInMore) {
2115            if (arItemsHideWidth[i] <= rowWidth) {
2116              if (i === cntItems - 1) {
2117                bMore = false;
2118                more.addClass("hidden");
2119              }
2120              var clone = item.clone();
2121              clone.find(">a").removeClass("dark_font");
2122              clone.insertBefore(more);
2123              item.addClass("cloned");
2124            }
2125          }
2126        }
2127        $menuTopest.find("li.cloned").remove();
2128      }
2129    }
2130
2131    var $menuTopest = $(".menu.topest");
2132    if ($menuTopest.length) {
2133      var more = $menuTopest.find(">.more");
2134      var moreDropdown = more.find(">.dropdown");
2135      var moreWidth = more.actual("outerWidth", { includeMargin: true });
2136      var arItemsHideWidth = [];
2137
2138      ignoreResize.push(true);
2139      _init();
2140      _gummi();
2141      ignoreResize.pop();
2142
2143      BX.addCustomEvent("onWindowResize", function (eventdata) {
2144        try {
2145          ignoreResize.push(true);
2146          _gummi();
2147        } catch (e) {
2148        } finally {
2149          ignoreResize.pop();
2150        }
2151      });
2152    }
2153  }
2154};
2155
2156CheckHeaderFixedMenu = function () {
2157  if (
2158    arAllcorp2Options["THEME"]["HEADER_FIXED"] == 2 &&
2159    $("#headerfixed .js-nav").length &&
2160    window.matchMedia("(min-width: 992px)").matches
2161  ) {
2162    $("#headerfixed .js-nav").css("width", "0");
2163    var all_width = 0,
2164      cont_width = $("#headerfixed .maxwidth-theme").actual("width"),
2165      padding_menu =
2166        $("#headerfixed .logo-row.v2 .menu-block").actual("outerWidth") -
2167        $("#headerfixed .logo-row.v2 .menu-block").actual("width");
2168    $("#headerfixed .logo-row.v2 > .inner-table-block").each(function () {
2169      if (!$(this).hasClass("menu-block"))
2170        all_width += $(this).actual("outerWidth");
2171    });
2172    $("#headerfixed .js-nav").width(cont_width - all_width - padding_menu);
2173  }
2174};
2175
2176CheckTopMenuPadding = function () {
2177  if (
2178    $(".logo_and_menu-row .right-icons .wrap_icon").length &&
2179    $(".logo_and_menu-row .menu-row").length
2180  ) {
2181    var menuPosition = $(".menu-row .menu-only").position().left,
2182      maxWidth = $(".logo_and_menu-row .maxwidth-theme").width() - 32,
2183      leftPadding = 0,
2184      rightPadding = 0;
2185
2186    $(".logo_and_menu-row .menu-row>div")
2187      .each(function (indx) {
2188        if (!$(this).hasClass("menu-only")) {
2189          var elementPosition = $(this).position().left,
2190            elementWidth = $(this).outerWidth();
2191
2192          if (elementPosition > menuPosition) {
2193            rightPadding += elementWidth;
2194          } else {
2195            leftPadding += elementWidth;
2196          }
2197        }
2198      })
2199      .promise()
2200      .done(function () {
2201        $(".logo_and_menu-row .menu-only").css({
2202          "padding-left": leftPadding,
2203          "padding-right": rightPadding + 1,
2204          opacity: 1,
2205        });
2206      });
2207  }
2208};
2209
2210CheckTopMenuOncePadding = function () {
2211  if ($(".menu-row.sliced .right-icons .wrap_icon").length) {
2212    var menuPosition = $(".menu-row .menu-only").position().left,
2213      maxWidth = $(".logo_and_menu-row .maxwidth-theme").width() - 32,
2214      leftPadding = 0,
2215      rightPadding = 0;
2216
2217    $(".menu-row.sliced .maxwidth-theme>div>div")
2218      .each(function (indx) {
2219        if (!$(this).hasClass("menu-only")) {
2220          var elementPosition = $(this).position().left,
2221            elementWidth = $(this).outerWidth();
2222
2223          if (elementPosition > menuPosition) {
2224            rightPadding += elementWidth;
2225          } else {
2226            leftPadding += elementWidth;
2227          }
2228        }
2229      })
2230      .promise()
2231      .done(function () {
2232        $(".menu-row.sliced .menu-only").css({
2233          "padding-left": leftPadding,
2234          "padding-right": rightPadding + 1,
2235          opacity: 1,
2236        });
2237      });
2238  }
2239};
2240
2241CheckSearchWidth = function () {
2242  if ($(".logo_and_menu-row .search_wrap").length) {
2243    var searchPosition = $(".logo_and_menu-row .search_wrap").position().left,
2244      maxWidth = $(".logo_and_menu-row .maxwidth-theme").width() - 32;
2245    width = 0;
2246
2247    $(".logo_and_menu-row .maxwidth-theme>div")
2248      .each(function () {
2249        if (!$(this).hasClass("search_wrap")) {
2250          var elementWidth = $(this).outerWidth();
2251
2252          width = width ? width - elementWidth : maxWidth - elementWidth;
2253        }
2254      })
2255      .promise()
2256      .done(function () {
2257        $(".logo_and_menu-row .search_wrap")
2258          .outerWidth(width)
2259          .css({ opacity: 1, visibility: "visible" });
2260      });
2261  }
2262};
2263
2264waitCounter = function (idCounter, delay, callback) {
2265  var obCounter = window["yaCounter" + idCounter];
2266  if (typeof obCounter == "object") {
2267    if (typeof callback == "function") callback();
2268  } else {
2269    setTimeout(function () {
2270      waitCounter(idCounter, delay, callback);
2271    }, delay);
2272  }
2273};
2274
2275var waitReCaptcha = function (delay, callback) {
2276  if (typeof grecaptcha == "object") {
2277    if (typeof callback == "function") {
2278      callback();
2279    }
2280  } else {
2281    setTimeout(function () {
2282      waitReCaptcha(delay, callback);
2283    }, delay);
2284  }
2285};
2286
2287var reCaptchaRender = function (response) {
2288  if ($(".g-recaptcha:not(.rendered)").length) {
2289    waitReCaptcha(50, function () {
2290      $(".g-recaptcha:not(.rendered)").each(function () {
2291        $this = $(this);
2292        $this.addClass("rendered");
2293        var id = grecaptcha.render($this[0], {
2294          sitekey: $this.attr("data-sitekey"),
2295          theme: $this.attr("data-theme"),
2296          size: $this.attr("data-size"),
2297          callback: $this.attr("data-callback"),
2298        });
2299        $this.attr("data-widgetid", id);
2300      });
2301    });
2302  }
2303};
2304
2305var reCaptchaVerify = function (response) {
2306  $(".g-recaptcha.rendered").each(function () {
2307    var id = $(this).attr("data-widgetid");
2308    if (typeof id !== "undefined") {
2309      if (grecaptcha.getResponse(id) != "") {
2310        $(this).closest("form").find(".recaptcha").valid();
2311      }
2312    }
2313  });
2314};
2315
2316var reCaptchaVerifyHidden = function (response) {
2317  $(".g-recaptcha.rendered:last").each(function () {
2318    var id = $(this).attr("data-widgetid");
2319    if (typeof id !== "undefined" && response) {
2320      if (!$(this).closest("form").find(".g-recaptcha-response").val())
2321        $(this).closest("form").find(".g-recaptcha-response").val(response);
2322      $(this).closest("form").submit();
2323    }
2324  });
2325};
2326
2327waitYTPlayer = function (delay, callback) {
2328  if (typeof YT !== "undefined" && YT && YT.Player) {
2329    if (typeof callback == "function") callback();
2330  } else {
2331    setTimeout(function () {
2332      waitYTPlayer(delay, callback);
2333    }, delay);
2334  }
2335};
2336
2337var scrollToTopAnimateClassIn = false;
2338var scrollToTopAnimateClassOut = false;
2339
2340var $body = {};
2341var $scrolltotop = {};
2342var isOnceInited = false;
2343
2344if (navigator.userAgent.indexOf("Edge") != -1)
2345  document.documentElement.className += " edge";
2346
2347initFull = function () {
2348  checkMobileRegion();
2349};
2350
2351var isFrameDataReceived = false;
2352if (typeof window.frameCacheVars !== "undefined") {
2353  BX.addCustomEvent("onFrameDataReceived", function (json) {
2354    initFull();
2355
2356    isFrameDataReceived = true;
2357  });
2358} else {
2359  $(document).ready(initFull);
2360}
2361
2362checkMobileRegion = function () {
2363  if ($(".confirm_region").length) {
2364    if (!$(".top_mobile_region").length)
2365      $(
2366        '<div class="top_mobile_region"><div class="confirm_region"></div><div class="close_popup"></div></div>'
2367      ).insertBefore($("#mobileheader"));
2368    $(".top_mobile_region .confirm_region").html($(".confirm_region").html());
2369
2370    $(".top_mobile_region .close_popup").click(function () {
2371      $(".js-confirm-region-close").trigger("click");
2372      $(this).remove();
2373    });
2374  }
2375};
2376
2377$(document).ready(function () {
2378  scrollToTop();
2379  // CheckStickyFooter();
2380  InitScrollBar();
2381
2382  if (!jQuery.browser.safari) {
2383    CheckTopMenuPadding();
2384    CheckTopMenuOncePadding();
2385    CheckHeaderFixed();
2386    CheckTopMenuDotted();
2387    MegaMenuFixed();
2388    CheckSearchWidth();
2389    InitTopestMenuGummi();
2390    isOnceInited = true;
2391
2392    setTimeout(function () {
2393      $(window).resize(); // need to check resize flexslider & menu
2394    }, 350);
2395
2396    setTimeout(function () {
2397      $(window).scroll();
2398    }, 250); // need to check position fixed ask block
2399  } else {
2400    setTimeout(function () {
2401      $(window).resize(); // need to check resize flexslider & menu
2402      setTimeout(function () {
2403        CheckTopMenuPadding();
2404        CheckTopMenuOncePadding();
2405        CheckHeaderFixed();
2406        CheckTopMenuDotted();
2407        MegaMenuFixed();
2408        CheckSearchWidth();
2409        InitTopestMenuGummi();
2410        isOnceInited = true;
2411        setTimeout(function () {
2412          $(window).scroll();
2413        }, 50);
2414      }, 50);
2415    }, 350);
2416  }
2417
2418  if (arAllcorp2Options["THEME"]["USE_DEBUG_GOALS"] === "Y") {
2419    $.cookie("_ym_debug", "1");
2420  } else {
2421    $.cookie("_ym_debug", null);
2422  }
2423
2424  /*  --- Bind mobile menu  --- */
2425  var $mobileMenu = $("#mobilemenu");
2426  if ($mobileMenu.length) {
2427    $mobileMenu.isLeftSide = $mobileMenu.hasClass("leftside");
2428    $mobileMenu.isOpen = $mobileMenu.hasClass("show");
2429    $mobileMenu.isDowndrop = $mobileMenu
2430      .find(">.scroller")
2431      .hasClass("downdrop");
2432    $mobileMenuNlo = $mobileMenu.find("[data-nlo]");
2433
2434    $("#mobileheader .burger").click(function () {
2435      SwipeMobileMenu();
2436      CloseMobilePhone();
2437    });
2438
2439    if ($mobileMenu.isLeftSide) {
2440      $mobileMenu.parent().append('<div id="mobilemenu-overlay"></div>');
2441      var $mobileMenuOverlay = $("#mobilemenu-overlay");
2442
2443      $mobileMenuOverlay.click(function () {
2444        if ($mobileMenu.isOpen) {
2445          CloseMobileMenu();
2446          $mobileMenu.find('.expanded').removeClass("expanded");
2447        }
2448      });
2449
2450      $(document).swiperight(function (e) {
2451        if (
2452          !$(e.target).closest(".flexslider").length &&
2453          !$(e.target).closest(".swipeignore").length
2454        ) {
2455          OpenMobileMenu();
2456        }
2457      });
2458
2459      $(document).swipeleft(function (e) {
2460        if (
2461          !$(e.target).closest(".flexslider").length &&
2462          !$(e.target).closest(".swipeignore").length
2463        ) {
2464          CloseMobileMenu();
2465        }
2466      });
2467    } else {
2468      $("#mobileheader").click(function (e) {
2469        if (
2470          !$(e.target).closest("#mobilemenu").length &&
2471          !$(e.target).closest(".burger").length &&
2472          $mobileMenu.isOpen
2473        ) {
2474          CloseMobileMenu();
2475        }
2476      });
2477    }
2478
2479    $(document).on(
2480      "click",
2481      "#mobilemenu .menu a,#mobilemenu .social-icons a",
2482      function (e) {
2483        var $this = $(this);
2484        if ($this.hasClass("parent")) {
2485          e.preventDefault();
2486
2487          if (!$mobileMenu.isDowndrop) {
2488            $this.closest("li").addClass("expanded");
2489            MoveMobileMenuWrapNext();
2490          } else {
2491            if (!$this.closest("li").hasClass("expanded")) {
2492              $this.closest("li").addClass("expanded");
2493            } else {
2494              $this.closest("li").removeClass("expanded");
2495            }
2496          }
2497        } else {
2498          if ($this.closest("li").hasClass("counters")) {
2499            var href = $this.attr("href");
2500            if (typeof href !== "undefined") {
2501              window.location.href = href;
2502              window.location.reload();
2503            }
2504          }
2505
2506          if (!$this.closest(".menu_back").length) {
2507            CloseMobileMenu();
2508          }
2509        }
2510      }
2511    );
2512
2513    $(document).on("click", "#mobilemenu .dropdown .menu_back", function (e) {
2514      e.preventDefault();
2515      var $this = $(this);
2516      MoveMobileMenuWrapPrev();
2517      setTimeout(function () {
2518        $this.closest(".expanded").removeClass("expanded");
2519      }, 400);
2520    });
2521
2522    OpenMobileMenu = function () {
2523      if (!$mobileMenu.isOpen) {
2524        // hide styleswitcher
2525        if ($(".style-switcher").hasClass("active")) {
2526          $(".style-switcher .switch").trigger("click");
2527        }
2528        $(".style-switcher .switch").hide();
2529        $(".style-switcher .switch_presets").hide();
2530
2531        if ($mobileMenu.isLeftSide) {
2532          // show overlay
2533          setTimeout(function () {
2534            $mobileMenuOverlay.fadeIn("fast");
2535          }, 100);
2536        } else {
2537          // scroll body to top & set fixed
2538          $("body").scrollTop(0).css({ position: "fixed" });
2539
2540          // set menu top = bottom of header
2541          $mobileMenu.css({
2542            top:
2543              +($("#mobileheader").height() + $("#mobileheader").offset().top) +
2544              "px",
2545          });
2546
2547          // change burger icon
2548          $("#mobileheader .burger").addClass("c");
2549        }
2550
2551        // show menu
2552        $mobileMenu.addClass("show");
2553        $mobileMenu.isOpen = true;
2554
2555        if (!$mobileMenu.isDowndrop) {
2556          var $wrap = $mobileMenu.find(".wrap").first();
2557          var params = $wrap.data("params");
2558          if (typeof params === "undefined") {
2559            params = {
2560              depth: 0,
2561              scroll: {},
2562              height: {},
2563            };
2564          }
2565          $wrap.data("params", params);
2566        }
2567
2568        if ($mobileMenuNlo.length) {
2569          if (!$mobileMenuNlo.hasClass("nlo-loadings")) {
2570            $mobileMenuNlo.addClass("nlo-loadings");
2571            setTimeout(function () {
2572              $.ajax({
2573                data: { nlo: $mobileMenuNlo.attr("data-nlo") },
2574                complete: function (jqXHR, textStatus) {
2575                  if (textStatus === "success" || jqXHR.status == 404) {
2576                    var ob = BX.processHTML($.trim(jqXHR.responseText));
2577                    BX.ajax.processScripts(ob.SCRIPT);
2578                    $mobileMenuNlo.replaceWith(ob.HTML);
2579                  }
2580                },
2581                error: function () {
2582                  $mobileMenuNlo.removeClass("nlo-loadings");
2583                },
2584              });
2585            }, 300);
2586          }
2587        }
2588      }
2589    };
2590
2591    CloseMobileMenu = function () {
2592      if ($mobileMenu.isOpen) {
2593        // hide menu
2594        $mobileMenu.removeClass("show");
2595        $mobileMenu.isOpen = false;
2596
2597        // show styleswitcher
2598        $(".style-switcher .switch").show();
2599        $(".style-switcher .switch_presets").show();
2600
2601        if ($mobileMenu.isLeftSide) {
2602          // hide overlay
2603          setTimeout(function () {
2604            $mobileMenuOverlay.fadeOut("fast");
2605          }, 100);
2606        } else {
2607          // change burger icon
2608          $("#mobileheader .burger").removeClass("c");
2609
2610          // body unset fixed
2611          $("body").css({ position: "" });
2612        }
2613
2614        if (!$mobileMenu.isDowndrop) {
2615          setTimeout(function () {
2616            var $scroller = $mobileMenu.find(".scroller").first();
2617            var $wrap = $mobileMenu.find(".wrap").first();
2618            var params = $wrap.data("params");
2619            params.depth = 0;
2620            $wrap.data("params", params).attr("style", "");
2621            $mobileMenu.scrollTop(0);
2622            $scroller.css("height", "");
2623          }, 400);
2624        }
2625      }
2626    };
2627
2628    SwipeMobileMenu = function () {
2629      if ($mobileMenu.isOpen) {
2630        CloseMobileMenu();
2631      } else {
2632        OpenMobileMenu();
2633      }
2634    };
2635
2636    function MoveMobileMenuWrapNext() {
2637      if (!$mobileMenu.isDowndrop) {
2638        var $scroller = $mobileMenu.find(".scroller").first();
2639        var $wrap = $mobileMenu.find(".wrap").first();
2640        if ($wrap.length) {
2641          var params = $wrap.data("params");
2642          var $dropdownNext = $mobileMenu
2643            .find(".expanded>.dropdown")
2644            .eq(params.depth);
2645          if ($dropdownNext.length) {
2646            // save scroll position
2647            params.scroll[params.depth] = parseInt($mobileMenu.scrollTop());
2648
2649            // height while move animating
2650            params.height[params.depth + 1] = Math.max(
2651              $dropdownNext.height(),
2652              !params.depth
2653                ? $wrap.height()
2654                : $mobileMenu
2655                    .find(".expanded>.dropdown")
2656                    .eq(params.depth - 1)
2657                    .height()
2658            );
2659            $scroller.css("height", params.height[params.depth + 1] + "px");
2660
2661            // inc depth
2662            ++params.depth;
2663
2664            // translateX for move
2665            $wrap.css("transform", "translateX(" + -100 * params.depth + "%)");
2666
2667            // scroll to top
2668            setTimeout(function () {
2669              $mobileMenu.animate({ scrollTop: 0 }, 200);
2670            }, 100);
2671
2672            // height on enimating end
2673            var h = $dropdownNext.height();
2674            setTimeout(function () {
2675              if (h) {
2676                $scroller.css("height", h + "px");
2677              } else {
2678                $scroller.css("height", "");
2679              }
2680            }, 200);
2681          }
2682
2683          $wrap.data("params", params);
2684        }
2685      }
2686    }
2687
2688    function MoveMobileMenuWrapPrev() {
2689      if (!$mobileMenu.isDowndrop) {
2690        var $scroller = $mobileMenu.find(".scroller").first();
2691        var $wrap = $mobileMenu.find(".wrap").first();
2692        if ($wrap.length) {
2693          var params = $wrap.data("params");
2694          if (params.depth > 0) {
2695            var $dropdown = $mobileMenu
2696              .find(".expanded>.dropdown")
2697              .eq(params.depth - 1);
2698            if ($dropdown.length) {
2699              // height while move animating
2700              $scroller.css("height", params.height[params.depth] + "px");
2701
2702              // dec depth
2703              --params.depth;
2704
2705              // translateX for move
2706              $wrap.css(
2707                "transform",
2708                "translateX(" + -100 * params.depth + "%)"
2709              );
2710
2711              // restore scroll position
2712              setTimeout(function () {
2713                $mobileMenu.animate(
2714                  { scrollTop: params.scroll[params.depth] },
2715                  200
2716                );
2717              }, 100);
2718
2719              // height on enimating end
2720              var h = !params.depth
2721                ? false
2722                : $mobileMenu
2723                    .find(".expanded>.dropdown")
2724                    .eq(params.depth - 1)
2725                    .height();
2726              setTimeout(function () {
2727                if (h) {
2728                  $scroller.css("height", h + "px");
2729                } else {
2730                  $scroller.css("height", "");
2731                }
2732              }, 200);
2733            }
2734          }
2735
2736          $wrap.data("params", params);
2737        }
2738      }
2739    }
2740  }
2741  /*  --- END Bind mobile menu  --- */
2742
2743  /*  --- Bind mobile phone  --- */
2744  var $mobileHeader = $("#mobileheader, #mobileheadersimple");
2745  var $mobilePhone = $("#mobilePhone");
2746  $mobilePhone.isOpen = false;
2747
2748  if ($mobilePhone.length) {
2749    $mobilePhone.isOpen = $mobilePhone.hasClass("show");
2750
2751    $(document).on("click", ".wrap_phones > .svg", function (e) {
2752      SwipeMobilePhone();
2753      e.stopPropagation();
2754    });
2755
2756    $(document).on("click", ".wrap_phones .more_phone.title svg", function (e) {
2757      CloseMobilePhone();
2758      e.stopPropagation();
2759    });
2760    $(document).on("click", ".wrap_phones .more_phone.title svg", function (e) {
2761      CloseMobilePhone();
2762      e.stopPropagation();
2763    });
2764  }
2765
2766  SwipeMobilePhone = function () {
2767    if ($mobilePhone.isOpen) {
2768      CloseMobilePhone();
2769    } else {
2770      OpenMobilePhone();
2771    }
2772  };
2773
2774  OpenMobilePhone = function () {
2775    if (!$mobilePhone.isOpen) {
2776      CloseMobileMenu();
2777
2778      // show overlay
2779      $(
2780        '<div class="jqmOverlay mobp" style="top:' +
2781          ($mobileHeader.position().top + $mobileHeader.height()) +
2782          'px;"></div>'
2783      ).appendTo("body");
2784      // toggle phones
2785      setTimeout(function () {
2786        $mobilePhone.slideDown("fast", function () {
2787          $mobilePhone.addClass("show");
2788          $mobilePhone.isOpen = true;
2789        });
2790      }, 100);
2791    }
2792  };
2793
2794  CloseMobilePhone = function () {
2795    if ($mobilePhone.isOpen) {
2796      // toggle phones
2797      setTimeout(function () {
2798        $mobilePhone.slideUp("fast", function () {
2799          $mobilePhone.removeClass("show");
2800          $mobilePhone.isOpen = false;
2801
2802          // hide overlay
2803          $(".jqmOverlay.mobp").remove();
2804        });
2805      }, 100);
2806    }
2807  };
2808
2809  checkMobilePhone = function () {
2810    if (!window.matchMedia("(max-width: 991px)").matches) {
2811      CloseMobilePhone();
2812    }
2813  };
2814  /*  --- END Bind mobile phone  --- */
2815
2816  /* change type2 menu for fixed */
2817  if ($("#headerfixed .js-nav").length) {
2818    if (arAllcorp2Options["THEME"]["HEADER_FIXED"] == 2) CheckHeaderFixedMenu();
2819
2820    setTimeout(function () {
2821      $("#headerfixed .js-nav").addClass("opacity1");
2822    }, 350);
2823  }
2824
2825  /* close search block */
2826  $("html, body").on("mousedown", function (e) {
2827    if (
2828      typeof e.target.className == "string" &&
2829      e.target.className.indexOf("adm") < 0
2830    ) {
2831      e.stopPropagation();
2832      var search_target = $(e.target).closest(".bx_searche");
2833      if (
2834        !$(e.target).hasClass("inline-search-block") &&
2835        !$(e.target).hasClass("svg") &&
2836        !search_target.length
2837      ) {
2838        $(".inline-search-block").removeClass("show");
2839        $(".title-search-result").hide();
2840        if (arAllcorp2Options["THEME"]["TYPE_SEARCH"] == "fixed")
2841          $(".jqmOverlay.search").detach();
2842      }
2843
2844      if (isMobile) {
2845        if (search_target.length) location.href = search_target.attr("href");
2846      }
2847      var class_name = $(e.target).attr("class");
2848      if (typeof class_name == "undefined" || class_name.indexOf("tooltip") < 0)
2849        //tooltip link
2850        $(".tooltip-link").tooltip("hide");
2851    }
2852  });
2853  $(".inline-search-block")
2854    .find("*")
2855    .on("mousedown", function (e) {
2856      e.stopPropagation();
2857    });
2858
2859  $(".filter-action").on("click", function () {
2860    $(this).toggleClass("active");
2861    $(this).find(".svg").toggleClass("white");
2862    if ($(".introtext").length) {
2863      var top_pos = $(".filters-wrap").position();
2864      $(".bx_filter").css({ top: top_pos.top + 40 });
2865    }
2866    $(".bx_filter").slideToggle();
2867  });
2868
2869  waitingNotExists(
2870    "#bx-composite-banner .bx-composite-btn",
2871    "#footer .col-sm-3.hidden-md.hidden-lg #bx-composite-banner .bx-composite-btn",
2872    500,
2873    function () {
2874      $("#footer .col-sm-3.hidden-md.hidden-lg #bx-composite-banner").html(
2875        $("#bx-composite-banner .bx-composite-btn").parent().html()
2876      );
2877    }
2878  );
2879
2880  $.extend($.validator.messages, {
2881    required: BX.message("JS_REQUIRED"),
2882    email: BX.message("JS_FORMAT"),
2883    equalTo: BX.message("JS_PASSWORD_COPY"),
2884    minlength: BX.message("JS_PASSWORD_LENGTH"),
2885    remote: BX.message("JS_ERROR"),
2886  });
2887
2888  $.validator.addMethod(
2889    "regexp",
2890    function (value, element, regexp) {
2891      var re = new RegExp(regexp);
2892      return this.optional(element) || re.test(value);
2893    },
2894    BX.message("JS_FORMAT")
2895  );
2896
2897  $.validator.addMethod(
2898    "filesize",
2899    function (value, element, param) {
2900      return this.optional(element) || element.files[0].size <= param;
2901    },
2902    BX.message("JS_FILE_SIZE")
2903  );
2904
2905  $.validator.addMethod(
2906    "date",
2907    function (value, element, param) {
2908      var status = false;
2909      if (!value || value.length <= 0) {
2910        status = true;
2911      } else {
2912        var re = new RegExp("^([0-9]{2})(.)([0-9]{2})(.)([0-9]{4})$");
2913        var matches = re.exec(value);
2914        if (matches) {
2915          var composedDate = new Date(matches[5], matches[3] - 1, matches[1]);
2916          status =
2917            composedDate.getMonth() == matches[3] - 1 &&
2918            composedDate.getDate() == matches[1] &&
2919            composedDate.getFullYear() == matches[5];
2920        }
2921      }
2922      return status;
2923    },
2924    BX.message("JS_DATE")
2925  );
2926
2927  $.validator.addMethod(
2928    "datetime",
2929    function (value, element, param) {
2930      var status = false;
2931      if (!value || value.length <= 0) {
2932        status = true;
2933      } else {
2934        var re = new RegExp(
2935          "^([0-9]{2})(.)([0-9]{2})(.)([0-9]{4}) ([0-9]{1,2}):([0-9]{1,2})$"
2936        );
2937        var matches = re.exec(value);
2938        if (matches) {
2939          var composedDate = new Date(
2940            matches[5],
2941            matches[3] - 1,
2942            matches[1],
2943            matches[6],
2944            matches[7]
2945          );
2946          status =
2947            composedDate.getMonth() == matches[3] - 1 &&
2948            composedDate.getDate() == matches[1] &&
2949            composedDate.getFullYear() == matches[5] &&
2950            composedDate.getHours() == matches[6] &&
2951            composedDate.getMinutes() == matches[7];
2952        }
2953      }
2954      return status;
2955    },
2956    BX.message("JS_DATETIME")
2957  );
2958
2959  $.validator.addMethod(
2960    "extension",
2961    function (value, element, param) {
2962      param =
2963        typeof param === "string" ? param.replace(/,/g, "|") : "png|jpe?g|gif";
2964      return (
2965        this.optional(element) ||
2966        value.match(new RegExp(".(" + param + ")$", "i"))
2967      );
2968    },
2969    BX.message("JS_FILE_EXT")
2970  );
2971
2972  $.validator.addMethod(
2973    "captcha",
2974    function (value, element, params) {
2975      return $.validator.methods.remote.call(this, value, element, {
2976        url: arAllcorp2Options["SITE_DIR"] + "ajax/check-captcha.php",
2977        type: "post",
2978        data: {
2979          captcha_word: value,
2980          captcha_sid: function () {
2981            return $(element)
2982              .closest("form")
2983              .find('input[name="captcha_sid"]')
2984              .val();
2985          },
2986        },
2987      });
2988    },
2989    BX.message("JS_ERROR")
2990  );
2991
2992  $.validator.addMethod(
2993    "recaptcha",
2994    function (value, element, param) {
2995      var id = $(element)
2996        .closest("form")
2997        .find(".g-recaptcha")
2998        .attr("data-widgetid");
2999      if (typeof id !== "undefined") {
3000        return grecaptcha.getResponse(id) != "";
3001      } else {
3002        return true;
3003      }
3004    },
3005    BX.message("JS_RECAPTCHA_ERROR")
3006  );
3007
3008  /*reload captcha*/
3009  $("body").on("click", ".refresh", function (e) {
3010    e.preventDefault();
3011    $.ajax({
3012      url: arAllcorp2Options["SITE_DIR"] + "ajax/captcha.php",
3013    }).done(function (text) {
3014      if ($(".captcha_sid").length) {
3015        $(".captcha_sid").val(text);
3016        $(".captcha_img").attr(
3017          "src",
3018          "/bitrix/tools/captcha.php?captcha_sid=" + text
3019        );
3020      }
3021    });
3022  });
3023
3024  $.validator.addClassRules({
3025    phone: {
3026      regexp: arAllcorp2Options["THEME"]["VALIDATE_PHONE_MASK"],
3027    },
3028    confirm_password: {
3029      equalTo: "input.password",
3030      minlength: 6,
3031    },
3032    password: {
3033      minlength: 6,
3034    },
3035    inputfile: {
3036      extension: arAllcorp2Options["THEME"]["VALIDATE_FILE_EXT"],
3037      filesize: 5000000,
3038    },
3039    datetime: {
3040      datetime: "",
3041    },
3042    captcha: {
3043      captcha: "",
3044    },
3045    recaptcha: {
3046      recaptcha: "",
3047    },
3048  });
3049
3050  $.validator.setDefaults({
3051    highlight: function (element) {
3052      $(element).parent().addClass("error");
3053    },
3054    unhighlight: function (element) {
3055      $(element).parent().removeClass("error");
3056    },
3057  });
3058
3059  $(".video_link").fancybox({
3060    type: "iframe",
3061    maxWidth: 800,
3062    maxHeight: 600,
3063    fitToView: false,
3064    width: "70%",
3065    height: "70%",
3066    autoSize: false,
3067    closeClick: false,
3068  });
3069
3070  /*city*/
3071  $("select.region").on("change", function () {
3072    var val = parseInt($(this).val());
3073    if ($("select.city").length) {
3074      if (val) {
3075        $("select.city option").hide();
3076        $("select.city option").prop("disabled", "disabled");
3077        $("select.city option[data-parent_section=" + val + "]").prop(
3078          "disabled",
3079          ""
3080        );
3081        $("select.city option:eq(0)").prop("disabled", "");
3082        // $('select.city').ikSelect('reset');
3083        $("select.city option[data-parent_section=" + val + "]").show();
3084      } else $("select.city option").prop("disabled", "disabled");
3085      $("select.city option:eq(0)").prop("disabled", "");
3086      // $('select.city').ikSelect('reset');
3087    }
3088  });
3089
3090  $("select.city, select.region").on("change", function () {
3091    var _this = $(this),
3092      val = parseInt(_this.val());
3093    if (_this.hasClass("region")) {
3094      $("select.city option:eq(0)").show();
3095      $("select.city").val(0);
3096    }
3097
3098    if ((_this.hasClass("region") && !val) || _this.hasClass("city")) {
3099      $.ajax({
3100        type: "POST",
3101        data: { ID: val },
3102      }).success(function (html) {
3103        var ob = BX.processHTML(html);
3104        $(".ajax_items")[0].innerHTML = ob.HTML;
3105        BX.ajax.processScripts(ob.SCRIPT);
3106      });
3107    }
3108  });
3109
3110  $(".mobile_regions .city_item").on("click", function (e) {
3111    e.preventDefault();
3112    var _this = $(this);
3113    $.removeCookie("current_region");
3114
3115    if (arAllcorp2Options["SITE_ADDRESS"].indexOf(",") != "-1") {
3116      var arDomains = arAllcorp2Options["SITE_ADDRESS"].split(",");
3117      if (arDomains) {
3118        for (var i in arDomains) {
3119          var domain_name = arDomains[i].replace("\n", "");
3120          domain_name = arDomains[i].replace("'", "");
3121          $.cookie("current_region", _this.data("id"), {
3122            path: "/",
3123            domain: domain_name,
3124          });
3125        }
3126      }
3127    }
3127 else $.cookie("current_region", _this.data("id"), { path: "/", domain: arAllcorp2Options["SITE_ADDRESS"] });
3128
3129    location.href = _this.attr("href");
3130  });
3131
3132  InitFlexSlider();
3133  InitFlexSliderMin();
3134
3135  // for check flexslider bug in composite mode
3136  waitingNotExists(
3137    ".detail .galery #slider",
3138    ".detail .galery #slider .flex-viewport",
3139    1000,
3140    function () {
3141      InitFlexSlider();
3142      setTimeout(function () {
3143        $(window).resize();
3144      }, 350);
3145    }
3146  );
3147
3148  /* change view type catalog */
3149  $(".view-button").on("click", function () {
3150    $(this).siblings().removeClass("cur");
3151    $(this).addClass("cur");
3152  });
3153
3154  // -- escape close popup form
3155  $(document).on("keydown", function (e) {
3156    if (e.keyCode == 27) {
3157      if ($(".jqmWindow.show").length) $(".jqmWindow.show .jqmClose").click();
3158      $(".title-search-result").hide();
3159      if ($(".inline-search-block.fixed.show").length)
3160        $(".inline-search-block.fixed .inline-search-hide").click();
3161    }
3162  });
3163
3164  /*check mobile device*/
3165  if (isMobile) {
3166    $(".hint span").remove();
3167
3168    $(document).on("click", '*[data-event="jqm"]', function (e) {
3169      e.preventDefault();
3170      var _this = $(this);
3171      var name = _this.data("name");
3172
3173      if (window.matchMedia("(min-width:992px)").matches) {
3174        e.stopPropagation();
3175        $(this).jqmEx();
3176        $(this).trigger("click");
3177      } else if (name.length) {
3178        var script = arAllcorp2Options["SITE_DIR"] + "form/";
3179        var paramsStr = "";
3180        var arTriggerAttrs = {};
3181        $.each(_this.get(0).attributes, function (index, attr) {
3182          var attrName = attr.nodeName;
3183          var attrValue = _this.attr(attrName);
3184          attrValue = attrValue.replace(/%99/g, "\\"); // replace symbol \
3185          arTriggerAttrs[attrName] = attrValue;
3186          if (/^data\-param\-(.+)$/.test(attrName)) {
3187            var key = attrName.match(/^data\-param\-(.+)$/)[1];
3188            paramsStr += key + "=" + attrValue + "&";
3189          }
3190        });
3191        var triggerAttrs = JSON.stringify(arTriggerAttrs);
3192        var encTriggerAttrs = encodeURIComponent(triggerAttrs);
3193        script +=
3194          "?name=" + name + "&" + paramsStr + "data-trigger=" + encTriggerAttrs;
3195        location.href = script;
3196      }
3197    });
3198
3199    // $('.fancybox').removeClass('fancybox');
3200  } else {
3201    $(document).on("click", '*[data-event="jqm"]', function (e) {
3202      e.preventDefault();
3203      e.stopPropagation();
3204      $(this).jqmEx();
3205      $(this).trigger("click");
3206    });
3207  }
3208
3209  $(".animate-load").on("click", function () {
3210    $(this).parent().addClass("loadings");
3211  });
3212
3213  BX.addCustomEvent("onCompleteAction", function (eventdata, _this) {
3214    try {
3215      if (eventdata.action === "loadForm") {
3216        $(_this).parent().removeClass("loadings");
3217      } else if (eventdata.action === "loadBasket") {
3218        var basket_link = $(".basket-link");
3219        if (basket_link.length) {
3220          basket_link.attr("title", $(_this).find("a").attr("title"));
3221          if ($(_this).find("a .count").length) {
3222            var count = basket_link.find(".count").length
3223              ? parseInt($(_this).find(".count").text())
3224              : parseInt($(_this).find(".count").text());
3225            basket_link
3226              .find(".prices")
3227              .text($(_this).find(".icon").data("summ"));
3228            if (basket_link.find(".count").length) {
3229              basket_link.find(".count").text(count);
3230              if (count) basket_link.addClass("basket-count");
3231              else basket_link.removeClass("basket-count");
3232            } else {
3233              basket_link
3234                .find(".js-basket-block")
3235                .append($(_this).find(".count"));
3236              basket_link.addClass("basket-count");
3237              CheckHeaderFixedMenu();
3238            }
3239
3240            $("#mobilemenu .menu .ready .count").text(count);
3241            if (count) {
3242              $("#mobilemenu .menu .ready .count").removeClass("empted");
3243            } else {
3244              $("#mobilemenu .menu .ready .count").addClass("empted");
3245            }
3246          } else if ($(_this).find(".opener").length) {
3247            var count = parseInt($(_this).find(".opener .count").text());
3248
3249            if (basket_link.find(".count").length) {
3250              basket_link.find(".count").text(count);
3251              if (count) basket_link.addClass("basket-count");
3252              else basket_link.removeClass("basket-count");
3253              basket_link.attr("title", $(_this).find(".opener").attr("title"));
3254            }
3255            $("#mobilemenu .menu .ready .count").text(count);
3256            if (count) {
3257              $("#mobilemenu .menu .ready .count").removeClass("empted");
3258            } else {
3259              $("#mobilemenu .menu .ready .count").addClass("empted");
3260            }
3261          } else {
3262            basket_link.find(".count").remove();
3263            basket_link.removeClass("basket-count");
3264            CheckHeaderFixedMenu();
3265          }
3266        }
3267      } else if (eventdata.action === "loadRSS") {
3268      } else if (eventdata.action === "ajaxContentLoaded") {
3269        if ("type" in eventdata) {
3270          if (eventdata.type == "table_block") {
3271            console.log("123");
3272            $(".catalog.item-views.table .item .title").sliceHeight();
3273            $(".catalog.item-views.table .item .cont").sliceHeight();
3274            $(".catalog.item-views.table .item .slice_price").sliceHeight();
3275            $(".catalog.item-views.table .item").sliceHeight();
3276          } else if (eventdata.type == "table_block2") {
3277            console.log("123456");
3278            $(".catalog.item-views.table .item .title").sliceHeight();
3279            $(".catalog.item-views.table .item .cont").sliceHeight({
3280              autoHeightBlock: ".cont_inner",
3281              classNull: ".props_wrapper",
3282            });
3283            $(".catalog.item-views.table .item .slice_price").sliceHeight();
3284            $(".catalog.item-views.table .item").sliceHeight({
3285              autoHeightBlock: ".cont_inner",
3286              callback: setHoverHeight,
3287            });
3288          }
3289        }
3290      }
3291    } catch (e) {
3292      console.error(e);
3293    }
3294  });
3295
3296  BX.addCustomEvent("onCounterGoals", function (eventdata) {
3297    if (
3298      arAllcorp2Options["THEME"]["YA_GOLAS"] == "Y" &&
3299      arAllcorp2Options["THEME"]["YA_COUNTER_ID"]
3300    ) {
3301      var idCounter = arAllcorp2Options["THEME"]["YA_COUNTER_ID"];
3302      idCounter = parseInt(idCounter);
3303
3304      if (typeof eventdata != "object") eventdata = { goal: "undefined" };
3305
3306      if (typeof eventdata.goal != "string") eventdata.goal = "undefined";
3307
3308      if (idCounter) {
3309        try {
3310          waitCounter(idCounter, 50, function () {
3311            var obCounter = window["yaCounter" + idCounter];
3312            if (typeof obCounter == "object") {
3313              obCounter.reachGoal(eventdata.goal);
3314            }
3315          });
3316        } catch (e) {
3317          console.error(e);
3318        }
3319      } else {
3320        console.info("Bad counter id!", idCounter);
3321      }
3322    }
3323  });
3324
3325  BX.addCustomEvent(window, "onAjaxSuccess", function (e) {
3326    if (e != "OK") {
3327      InitFlexSlider();
3328      InitFlexSliderMin();
3329    }
3330  });
3331
3332  /* show print */
3333  if (arAllcorp2Options["THEME"]["PRINT_BUTTON"] == "Y") {
3334    setTimeout(function () {
3335      if ($(".page-top .rss-block.top").length) {
3336        $(
3337          '<div class="print-link"><i class="svg svg-print"></i></div>'
3338        ).insertBefore($(".page-top .rss-block.top .shares-block"));
3339      } else if ($(".page-top .rss").length) {
3340        $(
3341          '<div class="print-link"><i class="svg svg-print"></i></div>'
3342        ).insertAfter($(".page-top .rss"));
3343      } else if ($(".page-top h1").length)
3344        $(
3345          '<div class="print-link"><i class="svg svg-print"></i></div>'
3346        ).insertBefore($(".page-top h1"));
3347      // else
3348      // $('footer .print-block').html('<div class="print-link"><i class="svg svg-print"><svg id="Print.svg" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path class="cls-1" d="M1553,287h-2v3h-8v-3h-2a2,2,0,0,1-2-2v-5a2,2,0,0,1,2-2h2v-4h8v4h2a2,2,0,0,1,2,2v5A2,2,0,0,1,1553,287Zm-8,1h4v-4h-4v4Zm4-12h-4v2h4v-2Zm4,4h-12v5h2v-3h8v3h2v-5Z" transform="translate(-1539 -274)"/></svg></i></div>');
3349    }, 150);
3350  }
3351
3352  $(document).on("click", ".print-link", function () {
3353    window.print();
3354  });
3355
3356  $(".head-block .item-link").on("click", function () {
3357    var _this = $(this);
3358    _this.siblings().removeClass("active");
3359    _this.addClass("active");
3360  });
3361
3362  $("table.table").each(function () {
3363    var _this = $(this),
3364      first_td = _this.find("thead tr th");
3365    if (!first_td.length) first_td = _this.find("thead tr td");
3366    if (first_td.length) {
3367      _this.find("tbody tr:not(.nomobile)").each(function (i) {
3368        $(this)
3369          .find("td")
3370          .each(function (i) {
3371            if (typeof first_td[i] !== "undefined") {
3372              $(
3373                '<div class="th-mobile">' + first_td[i].textContent + "</div>"
3374              ).appendTo($(this));
3375            }
3376          });
3377      });
3378    }
3379  });
3380
3381  $("a.fancybox").fancybox();
3382
3383  /* flex pagination */
3384  $(document).on("mouseenter", ".flex-viewport .item", function () {
3385    $(this).closest(".flexslider").find(".flex-control-nav").toggleClass("noz");
3386    $(this)
3387      .closest(".flexslider")
3388      .find(".flex-control-nav")
3389      .css("z-index", "0");
3390  });
3391  $(document).on("mouseleave", ".flex-viewport .item", function () {
3392    $(this).closest(".flexslider").find(".flex-control-nav").toggleClass("noz");
3393    $(this)
3394      .closest(".flexslider")
3395      .find(".flex-control-nav")
3396      .css("z-index", "2");
3397  });
3398
3399  /* ajax more items */
3400  $(document).on("click", ".ajax_load_btn", function () {
3401    var url = $(this)
3402        .closest(".bottom_nav")
3403        .find(".module-pagination .next a")
3404        .attr("href"),
3405      th = $(this).find(".more_text_ajax"),
3406      _this = $(this),
3407      container = $(this).closest(".bottom_nav");
3408    if (!th.hasClass("loading")) {
3409      th.addClass("loading");
3410      var objUrl = parseUrlQuery(),
3411        add_url = "",
3412        obData = { AJAX_REQUEST: "Y" };
3413      if ("clear_cache" in objUrl) {
3414        if (objUrl.clear_cache == "Y") add_url = "&clear_cache=Y";
3415      }
3416      if ($(".banners-small.front").length) {
3417        obData.MD = $(".banners-small.front").find(".items").data("c
3417olmd");
3418        obData.SM = $(".banners-small.front").find(".items").data("colsm");
3419      }
3420      $.ajax({
3421        url: url + "" + add_url,
3422        data: BX.ajax.prepareData(obData),
3423        success: function (html) {
3424          var eventdata = { action: "ajaxContentLoaded", content: html };
3425          if ($(".ajax_load").length) {
3426            th.removeClass("loading");
3427            if (_this.closest(".item-views.list").length) {
3428              _this.closest(".item-views").find(".items").append(html);
3429            } else if (_this.closest(".item-views.table").length) {
3430              _this.closest(".item-views").find(".items").append(html);
3431              // touchItemBlock('.catalog_item a');
3432              eventdata.type = "table_block";
3433              if (
3434                arAllcorp2Options["THEME"]["CATALOG_BLOCK_TYPE"] ==
3435                "catalog_table_2"
3436              )
3437                eventdata.type = "table_block2";
3438            } else if ($(".module_products_list").length) {
3439              $(".module_products_list > tbody").append(html);
3440            }
3441            $(".bottom_nav").html($(html).find(".bottom_nav").html());
3442          } else {
3443            if ($(".banners-small.front").length) {
3444              $(".banners-small .items.row").append(html);
3445              $(".bottom_nav").html(
3446                $(".banners-small .items.row .bottom_nav").html()
3447              );
3448              $(".banners-small .items.row .bottom_nav").remove();
3449            } else if (
3450              container.hasClass("index_block") &&
3451              container.data("class")
3452            ) {
3453              //index page
3454              var class_block = th
3455                  .closest(".drag-block")
3456                  .attr("class")
3457                  .replace("drag-block container", ""),
3458                html_content = "";
3459              class_block = class_block.replace(/\s/g, "");
3460
3461              html_content = $(html)
3462                .find("." + class_block)
3463                .find(container.data("class"));
3464              th.closest(".drag-block")
3465                .find(container.data("class"))
3466                .find(container.data("item"))
3467                .append(html_content.find(container.data("item")).html());
3468              th.closest(".nav_wrapper").html(
3469                html_content.find(".nav_wrapper").html()
3470              );
3471            } else {
3472              $(html).insertBefore($(".blog .bottom_nav"));
3473              $(".bottom_nav").html($(".blog .bottom_nav:hidden").html());
3474              $(".blog .bottom_nav:hidden").remove();
3475            }
3476          }
3477
3478          setTimeout(function () {
3479            BX.onCustomEvent("onCompleteAction", [eventdata, th[0]]);
3480            $(".banners-small .item.normal-block").sliceHeight();
3481            th.removeClass("loading");
3482          }, 100);
3483        },
3484      });
3485    }
3486  });
3487
3488  /* bug fix in ff*/
3489  $("img").removeAttr("draggable");
3490
3491  clicked_tab = 0;
3492
3493  $(".title-tab-heading").on("click", function () {
3494    var container = $(this).closest(".tab-pane"),
3495      nav = $(this).closest(".tabs").find(".nav"),
3496      slide_block = $(this).next();
3497
3498    clicked_tab = container.index() + 1;
3499
3500    container.siblings().removeClass("active");
3501    container.siblings().find(".title-tab-heading + div").hide();
3502
3503    $(".catalog.detail .nav.nav-tabs li").removeClass("active");
3504    nav.find("li").removeClass("active");
3505
3506    if (container.hasClass("active")) {
3507      slide_block.slideUp(200, function () {
3508        container.removeClass("active");
3509        nav.find("li:eq(" + container.index() + ")").removeClass("active");
3510      });
3511    } else {
3512      container.addClass("active");
3513      scrollToBlock(container);
3514      nav.find("li:eq(" + container.index() + ")").addClass("active");
3515      slide_block.slideDown();
3516    }
3517  });
3518
3519  // Responsive Menu Events
3520  var addActiveClass = false;
3521  $("#mainMenu li.dropdown > a > i, #mainMenu li.dropdown-submenu > a > i").on(
3522    "click",
3523    function (e) {
3524      e.preventDefault();
3525      if ($(window).width() > 979) return;
3526      addActiveClass = $(this).closest("li").hasClass("resp-active");
3527      // $('#mainMenu').find('.resp-active').removeClass('resp-active');
3528      if (!addActiveClass) {
3529        $(this).closest("li").addClass("resp-active");
3530      } else {
3531        $(this).closest("li").removeClass("resp-active");
3532      }
3533    }
3534  );
3535
3536  /*animate increment*/
3537  if ($(".spincrement").length) {
3538    $(".spincrement").counterUp({
3539      delay: 80,
3540      time: 1000,
3541    });
3542  }
3543
3544  $(".bx_filter_input_container input[type=text]").numeric({ allow: "." });
3545
3546  $(".toggle .more_items").on("click", function () {
3547    $(this).closest(".toggle").find(".collapsed").fadeToggle();
3548    $(this).remove();
3549    if (typeof $(this).data("resize") !== "undefined" && $(this).data("resize"))
3550      $(window).resize();
3551  });
3552  $(document).on("click", ".toggle_menu .more_items", function () {
3553    $(this).closest(".toggle_menu").find(".collapsed").addClass("clicked_exp");
3554    $(this).remove();
3555  });
3556
3557  /* search sync */
3558  $(document).on("keyup", ".search-input-div input", function (e) {
3559    var inputValue = $(this).val();
3560    $(".search-input-div input").val(inputValue);
3561
3562    if ($(this).closest("#headerfixed").length) {
3563      if (e.keyCode == 13) $(".search form").submit();
3564    }
3565  });
3566  $(document).on("click", ".search-button-div button", function (e) {
3567    if ($(this).closest("#headerfixed").length) $(".search form").submit();
3568  });
3569
3570  $(".inline-search-show, .inline-search-hide").on("click", function (e) {
3571      if (
3572        typeof $(this).data("type_search") != "undefined" &&
3573        $(this).data("type_search") == "fixed"
3574      )
3575        $(".inline-search-block").addClass("fixed");
3576
3577      if (arAllcorp2Options["THEME"]["TYPE_SEARCH"] != "fixed") {
3578        var height_block = 0;
3579
3580        height_block = $(this).closest(".maxwidth-theme").actual("outerHeight");
3581        if ($(this).closest("header.long").length)
3582          height_block = $(this).closest("header.long").actual("outerHeight");
3583        if ($("header > .top-block").length) {
3584          height_block += $("header > .top-block").actual("outerHeight");
3585          height_block -= 6;
3586        }
3587        if ($("#bx-panel").length)
3588          height_block += $("#bx-panel").actual("outerHeight");
3589        $(".inline-search-block").css({
3590          height: height_block,
3591          "line-height": height_block - 4 + "px",
3592          top: -height_block,
3593        });
3594      }
3595
3596      $(".inline-search-block").toggleClass("show");
3597      if ($(".top-block").length) {
3598        if ($(".inline-search-block").hasClass("show"))
3599          $(".inline-search-block").css(
3600            "background",
3601            $(".top-block").css("background-color")
3602
3603          );
3604        else {
3605        $(".inline-search-block").css("background", "#fff");
3606        $("#title-search-input").blur();
3607        $(".jqmOverlay").detach();
3608        }
3609      }
3610      if (arAllcorp2Options["THEME"]["TYPE_SEARCH"] == "fixed") {
3611        if ($(".inline-search-block").hasClass("show"))
3612          $('<div class="jqmOverlay search"></div>').appendTo("body");
3613        else {
3614          $(".jqmOverlay").remove();
3615        }
3616      }
3617  });
3618
3619  if ($(".styled-block .row > div.col-md-3").length) {
3620    BX.addCustomEvent("onWindowResize", function (eventdata) {
3621      try {
3622        ignoreResize.push(true);
3623        $(".styled-block .row > div.col-md-3").each(function () {
3624          $(this).css({ height: "", "line-height": "" });
3625          var z = parseInt($(".body_media").css("top"));
3626          if (z > 0) {
3627            var rowHeight = $(this)
3628              .parents(".row")
3629              .first()
3630              .actual("outerHeight");
3631            $(this).css({
3632              height: rowHeight + "px",
3633              "line-height": rowHeight + "px",
3634            });
3635          }
3636        });
3637      } catch (e) {
3638      } finally {
3639        ignoreResize.pop();
3640      }
3641    });
3642  }
3643
3644  if ($(".order-block").length) {
3645    BX.addCustomEvent("onWindowResize", function (eventdata) {
3646      try {
3647        ignoreResize.push(true);
3648        $(".order-block").each(function () {
3649          var cols = $(this).find(".row > div");
3650          if (cols.length) {
3651            var colFirst = cols.first();
3652            var colLast = cols.last();
3653            var colText = colFirst.find(".text");
3654            var bText = colText.length;
3655            var bOnlyText = cols.length === 1 && bText;
3656            var bPrice = colFirst.find(".price").length;
3657            var z = parseInt($(".body_media").css("top"));
3658
3659            cols.css({ height: "", "padding-top": "", "padding-bottom": "" });
3660            colText.css({
3661              height: "",
3662              "padding-top": "",
3663              "padding-bottom": "",
3664            });
3665            if ((!bPrice && z > 0) || (bPrice && z > 1)) {
3666              var minHeight = 83;
3667
3668              if (!bOnlyText) {
3669                var colLast_height = colLast.outerHeight();
3670                colLast_height =
3671                  colLast_height >= minHeight ? colLast_height : minHeight;
3672              }
3673
3674              if (bText) {
3675                var colFirst_height = colFirst.outerHeight();
3676                colFirst_height =
3677                  colFirst_height >= minHeight ? colFirst_height : minHeight;
3678              }
3679
3680              var colMax_height = bText
3681                ? !bOnlyText
3682                  ? colLast_height >= colFirst_height
3683                    ? colLast_height
3684                    : colFirst_height
3685                  : colLast_height
3686                : colFirst_height;
3687
3688              if (!bOnlyText) {
3689                var textPadding =
3690                  41 + (colMax_height - colFirst.outerHeight()) / 2;
3691                colLast.find(".btns").css({
3692                  "padding-top": textPadding + "px",
3693                  "padding-bottom": textPadding + "px",
3694                  height: colMax_height + "px",
3695                });
3696              }
3697              if (bText) {
3698                colLast.css({ height: colMax_height + "px" });
3699                var textPadding =
3700                  41 + (colMax_height - colText.outerHeight()) / 2;
3701                colText.css({
3702                  "padding-top": textPadding + "px",
3703                  "padding-bottom": textPadding + "px",
3704                  height: colMax_height + "px",
3705                });
3706              }
3707            }
3708          }
3709        });
3710      } catch (e) {
3711      } finally {
3712        ignoreResize.pop();
3713      }
3714    });
3715  }
3716
3717  if ($(".equal-padding").length) {
3718    BX.addCustomEvent("onWindowResize", function (eventdata) {
3719      try {
3720        ignoreResize.push(true);
3721        $(".equal-padding").each(function () {
3722          $(this)
3723            .find(".text")
3724            .css({ "padding-top": "0px", "padding-bottom": "0px" });
3725          var equal_block = $(this).siblings(".equals"),
3726            height = $(this).actual("outerHeight");
3727
3728          delta = Math.round((equal_block.actual("outerHeight") - height) / 2);
3729          if (delta)
3730            $(this)
3731              .find(".text")
3732              .css({
3733                "padding-top": delta + "px",
3734                "padding-bottom": delta + "px",
3735              });
3736        });
3737      } catch (e) {
3738      } finally {
3739        ignoreResize.pop();
3740      }
3741    });
3742  }
3743
3744  $(document).on("click", ".mega-menu .dropdown-menu", function (e) {
3745    e.stopPropagation();
3746  });
3747
3748  $(document).on(
3749    "click",
3750    ".mega-menu .dropdown-toggle.more-items",
3751    function (e) {
3752      e.preventDefault();
3753    }
3754  );
3755
3756  $(
3757    ".table-menu .dropdown,.table-menu .dropdown-submenu,.table-menu .dropdown-toggle"
3758  ).on("mouseenter", function () {
3759    CheckTopVisibleMenu();
3760  });
3761
3762  $(
3763    ".mega-menu .search-item .search-icon, .menu-row #title-search .fa-close"
3764  ).on("click", function (e) {
3765    e.preventDefault();
3766    $(".menu-row #title-search").toggleClass("hide");
3767  });
3768
3769  $(".mega-menu ul.nav .search input").on("keyup", function (e) {
3770    var inputValue = $(this).val();
3771    $(".menu-row > .search input").val(inputValue);
3772    if (e.keyCode == 13) {
3773      $(".menu-row > .search form").submit();
3774    }
3775  });
3776
3777  $(".menu-row > .search input").on("keyup", function (e) {
3778    var inputValue = $(this).val();
3779    $(".mega-menu ul.nav .search input").val(inputValue);
3780    if (e.keyCode == 13) {
3781      $(".menu-row > .search form").submit();
3782    }
3783  });
3784
3785  $(".mega-menu ul.nav .search button").on("click", function (e) {
3786    e.preventDefault();
3787    var inputValue = $(this).parents(".search").find("input").val();
3788    $(".menu-and-search .search input").val(inputValue);
3789    $(".menu-row > .search form").submit();
3790  });
3791
3792  $(".filter .calendar").on("click", function () {
3793    var button = $(this).next();
3794    if (button.hasClass("calendar-icon")) {
3795      button.trigger("click");
3796    }
3797  });
3798
3799  /*sliceheights*/
3800  if ($(".banners-small .item.normal-block").length)
3801    $(".banners-small .item.normal-block").sliceHeight();
3802  if ($(".teasers .item").length) $(".teasers .item").sliceHeight();
3803  if ($(".wrap-portfolio-front .row.items > div").length)
3804    $(".wrap-portfolio-front .row.items > div").sliceHeight({
3805      row: ".row.items",
3806      item: ".item1",
3807    });
3808
3809  SliceHeightBlocks();
3810
3811  /* toggle */
3812  var $this = this,
3813    previewParClosedHeight = 25;
3814
3815  $("section.toggle > label").prepend($("<i />").addClass("fa fa-plus"));
3816  $("section.toggle > label").prepend($("<i />").addClass("fa fa-minus"));
3817  $("section.toggle.active > p").addClass("preview-active");
3818  $("section.toggle.active > div.toggle-content").slideDown(
3819    350,
3820    function () {}
3821  );
3822
3823  $("section.toggle > label").click(function (e) {
3824    var parentSection = $(this).parent(),
3825      parentWrapper = $(this).parents("div.toogle"),
3826      previewPar = false,
3827      isAccordion = parentWrapper.hasClass("toogle-accordion");
3828
3829    if (isAccordion && typeof e.originalEvent != "undefined") {
3830      parentWrapper.find("section.toggle.active > label").trigger("click");
3831    }
3832
3833    parentSection.toggleClass("active");
3834
3835    // Preview Paragraph
3836    if (parentSection.find("> p").get(0)) {
3837      previewPar = parentSection.find("> p");
3838      var previewParCurrentHeight = previewPar.css("height");
3839      previewPar.css("height", "auto");
3840      var previewParAnimateHeight = previewPar.css("height");
3841      previewPar.css("height", previewParCurrentHeight);
3842    }
3843
3844    // Content
3845    var toggleContent = parentSection.find("> div.toggle-content");
3846
3847    if (parentSection.hasClass("active")) {
3848      $(previewPar).animate(
3849        {
3850          height: previewParAnimateHeight,
3851        },
3852        350,
3853        function () {
3854          $(this).addClass("preview-active");
3855        }
3856      );
3857      toggleContent.slideDown(350, function () {});
3858    } else {
3859      $(previewPar).animate(
3860        {
3861          height: previewParClosedHeight,
3862        },
3863        350,
3864        function () {
3865          $(this).removeClass("preview-active");
3866        }
3867      );
3868      toggleContent.slideUp(350, function () {});
3869    }
3870  });
3871
3872  /* accordion */
3873  $(".accordion-head").on("click", function (e) {
3874    e.preventDefault();
3875    if (!$(this).next().hasClass("collapsing")) {
3876      $(this).toggleClass("accordion-open");
3877      $(this).toggleClass("accordion-close");
3878    }
3879  });
3880
3881  /* progress bar */
3882  $("[data-appear-progress-animation]").each(function () {
3883    var $this = $(this);
3884    $this.appear(
3885      function () {
3886        var delay = $this.attr("data-appear-animation-delay")
3887          ? $this.attr("data-appear-animation-delay")
3888          : 1;
3889        if (delay > 1) $this.css("animation-delay", delay + "ms");
3890        $this.addClass($this.attr("data-appear-animation"));
3891
3892        setTimeout(function () {
3893          $this.animate(
3894            {
3895              width: $this.attr("data-appear-progress-animation"),
3896            },
3897            1500,
3898            "easeOutQuad",
3899            function () {
3900              $this.find(".progress-bar-tooltip").animate(
3901                {
3902                  opacity: 1,
3903                },
3904                500,
3905                "easeOutQuad"
3906              );
3907            }
3908          );
3909        }, delay);
3910      },
3911      { accX: 0, accY: -50 }
3912    );
3913  });
3914
3915  /* portfolio item */
3916  $(".item.animated-block").appear(
3917    function () {
3918      var $this = $(this);
3919
3920      $this.addClass($this.data("animation")).addClass("visible");
3921    },
3922    { accX: 0, accY: 150 }
3923  );
3924
3925  $("a[rel=tooltip]").tooltip();
3926  $("span[data-toggle=tooltip]").tooltip();
3927
3928  $(document).on("change", "select.sort", function () {
3929    location.href = $(this).val();
3930  });
3931
3932  setTimeout(function (th) {
3933    $(".catalog.group.list .item").each(function () {
3934      var th = $(this);
3935      if (
3936        (tmp =
3937          th.find(".image").outerHeight() -
3938          th.find(".text_info").outerHeight()) > 0
3939      ) {
3940        th.find(".text_info .titles").height(
3941          th.find(".text_info .titles").outerHeight() + tmp
3942        );
3943      }
3944    });
3945  }, 50);
3946
3947  /* ajax tabs*/
3948
3949  /*tabs on front in mobile*/
3950  $(".items-link-mobile").each(function () {
3951    var _this = $(this),
3952      selectOption = _this.find("option"),
3953      selectOptionLength = selectOption.length,
3954      selectedOption = selectOption.filter(":selected"),
3955      duration = 200; // ������������ ��������
3956
3957    _this.hide();
3958    _this.wrap('<div class="select"></div>');
3959    $("<div>", {
3960      class: "new-select",
3961      text: _this.children("option:disabled").text(),
3962    }).insertAfter(_this);
3963
3964    var selectHead = _this.next(".new-select");
3965    $("<div>", {
3966      class: "new-select__list",
3967    }).insertAfter(selectHead);
3968
3969    var selectList = selectHead.next(".new-select__list");
3970    for (var i = 1; i < selectOptionLength; i++) {
3971      $("<div>", {
3972        class: "new-select__item",
3973        html: $("<span>", {
3974          text: selectOption.eq(i).text(),
3975        }),
3976      })
3977        .attr("data-value", selectOption.eq(i).val())
3978        .appendTo(selectList);
3979    }
3980
3981    var selectItem = selectList.find(".new-select__item");
3982    var selectItemFirst = selectList.find(".new-select__item:first-child");
3983    selectList.slideUp();
3984    selectHead.on("click", function () {
3985      if (!$(this).hasClass("on")) {
3986        $(this).addClass("on");
3987        selectList.slideDown(duration);
3988
3989        selectItemCur = selectList.find(".new-select__item.active");
3990
3991        if (!selectItem.hasClass("active")) {
3992          selectItemFirst.addClass("active");
3993          selectItemCur = selectItemFirst;
3994        }
3995
3996        selectItem.on("click", function () {
3997          selectItemCur.removeClass("active");
3998          var chooseItem = $(this).data("value");
3999
4000          $("select").val(chooseItem).attr("selected", "selected");
4001          selectHead.text($(this).find("span").text());
4002          selectHead.attr("data-value", $(this).attr("data-value"));
4003          $(this).addClass("active");
4004          var _this = $(this);
4005          selectList.slideUp(150, function () {
4006            selectHead.removeClass("on");
4007
4008            var index = _this.index();
4009            var curHeadBlock = _this.closest(".head-block");
4010            var indexTab = curHeadBlock.find(".items-link .item-link.active");
4011            var indexActiveTab = indexTab.index();
4012
4013            if (indexActiveTab != index) {
4014              curHeadBlock
4015                .find(".items-link .item-link")
4016                .eq(index)
4017                .trigger("click");
4018            }
4019          });
4020        });
4021      } else {
4022        $(this).removeClass("on");
4023        selectList.slideUp(duration);
4024      }
4025    });
4026  });
4027
4028  // $('.items-link-mobile').on('change', function(){
4029  // 	var value = $(this).val();
4030
4031  // 	var option = $(this).find('option[value='+value+']');
4032
4033  // 	var index = option.index();
4034
4035  // 	var curHeadBlock = $(this).closest('.head-block');
4036  // 	var indexTab = curHeadBlock.find('.item-link.active');
4037  // 	var indexActiveTab = indexTab.index();
4038
4039  // 	if(indexActiveTab != index){
4040  // 		curHeadBlock.find('.items-link .item-link').eq(index).trigger('click');
4041  // 	}
4042  // });
4043
4044  /*tabs on PC*/
4045  $(".head-block .item-link").on("click", function () {
4046    var index = $(this).index(),
4047      body_block = $(this).closest(".catalog").find(".body-block"),
4048      obQuery = parseUrlQuery(),
4049      url_post =
4050        arAllcorp2Options["SITE_DIR"] +
4051        "include/mainpage/comp_catalog_ajax.php";
4052    // $hideItemsLink = $('.clicked').siblings('.hide_mobile');
4053
4054    $(this).siblings().removeClass("active").addClass("hide_mobile");
4055    $(this).addClass("active").removeClass("hide_mobile");
4056
4057    if ("clear_cache" in obQuery)
4058      url_post += "?clear_cache=" + obQuery.clear_cache;
4059
4060    if (!$(this).hasClass("clicked")) {
4061      $.ajax({
4062        url: url_post,
4063        type: "POST",
4064        data: {
4065          AJAX_POST: "Y",
4066          AJAX_PARAMS: $(this)
4067            .closest(".item-views.catalog")
4068            .find(".request-data")
4069            .data("value"),
4070          GLOBAL_FILTER: body_block
4071            .find(".item-block:eq(" + index + ")")
4072            .data("filter"),
4073        },
4074      }).success(function (html) {
4075        body_block.find(".item-block:eq(" + index + ")").html(html);
4076
4077        InitFlexSliderClass(
4078          body_block.find(".item-block:eq(" + index + ")").find(".flexslider")
4079        ); //reinit flexslider
4080
4081        body_block.css(
4082          "height",
4083          body_block.find(".item-block.active").actual("outerHeight")
4084        );
4085
4086        body_block
4087          .find(".item-block")
4088          .removeClass("active")
4089          .removeClass("opacity1")
4090          .addClass("opacity0");
4091        body_block.find(".item-block:eq(" + index + ")").addClass("active");
4092
4093        setTimeout(function () {
4094          body_block.css("height", "auto");
4095
4096          //recalculate height
4097          body_block
4098            .find(
4099              ".item-block:eq(" +
4100                index +
4101                ") .catalog.item-views.table .item .title"
4102            )
4103            //.sliceHeight({ sliceEqualLength: true });
4104          body_block
4105            .find(
4106              ".item-block:eq(" +
4107                index +
4108                ") .catalog.item-views.table .item .cont"
4109            )
4110            //.sliceHeight({ sliceEqualLength: true });
4111          body_block
4112            .find(
4113              ".item-block:eq(" +
4114                index +
4115                ") .catalog.item-views.table .item .slice_price"
4116            )
4117            //.sliceHeight({ sliceEqualLength: true });
4118          body_block
4119            .find(
4120              ".item-block:eq(" + index + ") .catalog.item-views.table .item"
4121            )
4122            //.sliceHeight({ sliceEqualLength: true });
4123
4124          body_block
4125            .find(".item-block:eq(" + index + ")")
4126            .removeClass("opacity0")
4127            .addClass("opacity1");
4128          if (typeof setHoverHeight == "function") setHoverHeight();
4129        }, 100);
4130
4131        setBasketItemsClasses();
4132      });
4133    } else {
4134      body_block
4135        .find(".item-block")
4136        .removeClass("active")
4137        .removeClass("opacity1")
4138        .addClass("opacity0");
4139      body_block
4140        .find(".item-block:eq(" + index + ")")
4141        .addClass("active")
4142        .removeClass("opacity0")
4143        .addClass("opacity1");
4144
4145      if (!body_block.find(".item-block.active .flex-control-nav li").length) {
4146        $(".item-views.catalog .flex-direction-nav li a").addClass(
4147          "flex-disabled"
4148        );
4149      } else {
4150        $(".item-views.catalog .flex-direction-nav li a").removeClass(
4151          "flex-disabled"
4152        );
4153      }
4154      setBasketItemsClasses();
4155      if (typeof setHoverHeight == "function") setHoverHeight();
4156
4157      // if ($hideItemsLink.hasClass('hide_mobile')) {
4158      //     $hideItemsLink.each(function(){
4159      //         $(this).removeClass("hide_mobile");
4160      //     });
4161      // }
4162    }
4163    $(this).addClass("clicked");
4164  });
4165
4166  /*item galery*/
4167  $(".thumbs .item a").on("click", function (e) {
4168    e.preventDefault();
4169    $(".thumbs .item").removeClass("current");
4170    $(this).closest(".item").toggleClass("current");
4171    $(".slides li" + $(this).attr("href"))
4172      .addClass("current")
4173      .siblings()
4174      .removeClass("current");
4175  });
4176
4177  $("header.fixed .btn-responsive-nav").on("click", function () {
4178    $("html, body").animate({ scrollTop: 0 }, 400);
4179  });
4180
4181  $("body").on("click", ".form .refresh-page", function () {
4182    location.href = location.href;
4183  });
4184
4185  // click on HTML5 video
4186  $(document).on("click", "video.video", function (e) {
4187    var videoID = e.target.id.replace("player_", "");
4188    if (videoID) {
4189      if (players[videoID].playing) {
4190        e.target.pause();
4191      } else {
4192        e.target.play();
4193      }
4194    }
4195  });
4196
4197  // START VIDEO BUTTON
4198  /*$(document).on('click', '.banners-big .item .btn-video', function(){
4199		$(this).addClass('loading');
4200		startMainBannerSlideVideo($(this).closest('.item'));
4201	});*/
4202
4203  $(document).on("click", ".basket.fly .opener", function () {
4204    if (window.matchMedia("(max-width: 767px)").matches)
4205      location.href = arAllcorp2Options["THEME"]["URL_BASKET_SECTION"];
4206    else $(this).closest(".ajax_basket").toggleClass("opened");
4207  });
4208
4209  $(document).on("click", ".basket.fly .close_block", function () {
4210    $(".basket.fly .opener").trigger("click");
4211  });
4212
4213  /* show props */
4214  $(document).on("click", ".show_props", function () {
4215    $(this).prev(".props_list").stop().slideToggle(333);
4216    $(this).find(".char_title").toggleClass("opened");
4217  });
4218
4219  /* animated labels */
4220  $(document)
4221    .on(
4222      "focus",
4223      ".animated-labels input,.animated-labels textarea",
4224      function () {
4225        $(this).closest(".animated-labels").addClass("input-filed");
4226      }
4227    )
4228    .on(
4229      "focusout",
4230      ".animated-labels input,.animated-labels textarea",
4231      function () {
4232        if ("" != $(this).val())
4233          $(this).closest(".animated-labels").addClass("input-filed");
4234        else $(this).closest(".animated-labels").removeClass("input-filed");
4235      }
4236    );
4237
4238  /* accordion action*/
4239  $(".panel-collapse").on("hidden.bs.collapse", function () {
4240    $(this).parent().toggleClass("opened");
4241  });
4242  $(".panel-collapse").on("show.bs.collapse", function () {
4243    $(this).parent().toggleClass("opened");
4244  });
4245
4246  // DIGITAL BASKET
4247  // - basket fly close
4248  $(document).on("click", function () {
4249    if ($(".basket.fly").length && $(".ajax_basket").hasClass("opened")) {
4250      $(".ajax_basket").removeClass("opened");
4251    }
4252  });
4253
4254  $(document).on("click", ".basket.fly", function (e) {
4255    e.stopPropagation();
4256  });
4257
4258  // - COUNTER
4259  var timerBasketCounter = false;
4260
4261  // -- keyup input
4262  $(document).on("keydown", ".count", function (e) {
4263    // Allow: backspace, delete, tab, escape, enter and .
4264    if (
4265      $.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||
4266      // Allow: Ctrl+A, Command+A
4267      (e.keyCode === 65 && (e.ctrlKey === true || e.metaKey === true)) ||
4268      // Allow: home, end, left, right, down, up
4269      (e.keyCode >= 35 && e.keyCode <= 40)
4270    ) {
4271      // let it happen, don't do anything
4272      return;
4273    }
4274    // Ensure that it is a number and stop the keypress
4275    if (
4276      (e.shiftKey || e.keyCode < 48 || e.keyCode > 57) &&
4277      (e.keyCode < 96 || e.keyCode > 105)
4278    ) {
4279      e.preventDefault();
4280    }
4281  });
4282  $(document).on("keyup", ".count", function (e) {
4283    var $this = $(this),
4284      counterInputValueNew = $this.val(),
4285      price = $this.closest(".item").find("input[name=PRICE]").val();
4286
4287    Summ($this, counterInputValueNew, price);
4288  });
4289
4290  // -- scroll after apply option
4291  if ($(".instagram_ajax").length) {
4292    BX.addCustomEvent("onCompleteAction", function (eventdata) {
4293      if (eventdata.action === "instagrammLoaded") scrollPreviewBlock();
4294    });
4295  } else scrollPreviewBlock();
4296
4297  $("select.region").on("change", function () {
4298    var val = parseInt($(this).val());
4299    if ($("select.city").length) {
4300      if (val) {
4301        $("select.city").removeAttr("disabled");
4302        $("select.city option").hide();
4303        $("select.city option[data-parent_section=" + val + "]").show();
4304      } else $("select.city").attr("disabled", "disabled");
4305    }
4306  });
4307
4308  $("select.city, select.region").on("change", function () {
4309    var _this = $(this),
4310      val = parseInt(_this.val());
4311    if (_this.hasClass("region")) {
4312      $("select.city option:eq(0)").show();
4313      $("select.city").val(0);
4314    }
4315
4316    if ((_this.hasClass("region") && !val) || _this.hasClass("city")) {
4317      $.ajax({
4318        type: "POST",
4319        data: { ID: val },
4320      }).success(function (html) {
4321        var ob = BX.processHTML(html);
4322        $(".ajax_items")[0].innerHTML = ob.HTML;
4323        BX.ajax.processScripts(ob.SCRIPT);
4324      });
4325    }
4326  });
4327
4328  // -- blur input
4329  $(document).on("blur", ".count", function () {
4330    BasketCounter($(this));
4331  });
4332
4333  // -- click minus, plus button
4334  $(document).on("click", ".minus, .plus", function (e) {
4335    e.stopPropagation();
4336    BasketCounter($(this));
4337  });
4338
4339  // - Add2Basket
4340  $(document).on("click", ".to_cart", function (e) {
4341    e.stopPropagation();
4342    var item = $(this).closest("[data-item]"),
4343      _this = $(this),
4344      itemData = item.data("item"),
4345      buyBlock = item.find(".buy_block"),
4346      counter = buyBlock.find(".counter"),
4347      buttonToCart = buyBlock.find(".to_cart"),
4348      itemQuantity = parseFloat(buttonToCart.data("quantity")),
4349      countItem = $(".basket").length
4350        ? parseInt($(".basket .count").text())
4351        : parseInt($(".basket_top:visible .count").text());
4352
4353    if (
4354      typeof arBasketItems === "object" &&
4355      typeof arBasketItems[itemData.ID] !== "object"
4356    )
4357      arBasketItems[itemData.ID] = { ID: itemData.ID };
4358
4359    $(".basket_top .count")
4360      .text(countItem + 1)
4361      .removeClass("empted");
4362    $(".basket .count")
4363      .text(countItem + 1)
4364      .removeClass("empted");
4365
4366    if (
4367      typeof arAllcorp2Options["THEME"]["ORDER_BASKET_VIEW"] !== "undefined"
4368    ) {
4369      if (
4370        $.trim(arAllcorp2Options["THEME"]["ORDER_BASKET_VIEW"]) === "HEADER" &&
4371        $(".basket_top").length
4372      )
4373        var bBasketTop = true;
4374      else if ($(".basket.fly").length) var bBasketFly = true;
4375    }
4376
4377    if (isNaN(itemQuantity) || itemQuantity <= 0) {
4378      itemQuantity = 1;
4379    }
4380
4381    if (!isNaN(itemData.ID) && parseInt(itemData.ID) > 0) {
4382      buyBlock.addClass("in");
4383
4384      $.ajax({
4385        url: arAllcorp2Options["SITE_DIR"] + "include/footer/site-basket.php",
4386        type: "POST",
4387        data: { itemData: itemData, quantity: itemQuantity },
4388      }).success(function (html) {
4389        var eventdata = { action: "loadForm" };
4390        BX.onCustomEvent("onCompleteAction", [eventdata, _this[0]]);
4391
4392        const bShowCartNotice = arAllcorp2Options.THEME.SHOW_BASKET_NOTICE
4393          && arAllcorp2Options.THEME.SHOW_BASKET_NOTICE === 'Y'
4394          && typeof JNoticeSurface !== "undefined"
4395          && !_this.hasClass("added");
4396        
4397        if (bBasketTop) {
4398          $(".ajax_basket").html(html);
4399        }
4400
4401        if (bBasketFly) {
4402          if ($(".basket.fly").length) {
4403            $(".ajax_basket").html(html);
4404            
4405            const $nodeAjaxBasket = $(".ajax_basket");
4406            const bOpenCart = !bShowCartNotice
4407              && arAllcorp2Options.THEME.SHOW_BASKET_ONADDTOCART
4408              && arAllcorp2Options.THEME.SHOW_BASKET_ONADDTOCART === 'Y'
4409              && !$nodeAjaxBasket.hasClass('opened-once');
4410            
4411            if (bOpenCart) {
4412              setTimeout(function () {
4413                if (!$nodeAjaxBasket.hasClass("opened")) {
4414                  $nodeAjaxBasket.addClass("opened opened-once");
4415                }
4416              }, 50);
4417            }
4418          }
4419        }
4420
4421        if (bShowCartNotice) {
4422          JNoticeSurface.get().onAdd2cart([_this[0]]);
4423        }
4424
4425        var eventdata = { action: "loadBasket" };
4426        BX.onCustomEvent("onCompleteAction", [eventdata, $(".ajax_basket")[0]]);
4427
4428        if (arAllcorp2Options["THEME"]["USE_SALE_GOALS"] != "N") {
4429          var eventdata = {
4430            goal: "goal_basket_add",
4431            params: { itemData: itemData, quantity: itemQuantity },
4432          };
4433          BX.onCustomEvent("onCounterGoals", [eventdata]);
4434        }
4435      });
4436    } else {
4437      return;
4438    }
4439  });
4440
4441  // - Remove9Basket
4442  $(document).on("click", ".remove", function () {
4443    var item = $(this).closest("[data-item]"),
4444      itemData = item.data("item"),
4445      bRemove = "Y",
4446      bRemoveAll =
4447        $.trim($(this).closest("[data-remove_all]").data("remove_all")) === "Y"
4448          ? "Y"
4449          : false;
4450    (getCurUri = $.trim($("input[name=getPageUri]").val())),
4451      (countItem = $(".basket").length
4452        ? parseInt($(".basket .item").length)
4453        : parseInt($(".basket_top:visible .item").length)),
4454      (bOneItem = countItem - 1 <= 0),
4455      (scrollTop = $(".basket.fly").length
4456        ? $(".basket.fly .items_wrap").scrollTop()
4457        : $(".basket_top:visible").length
4458        ? $(".basket_top .items:visible").scrollTop()
4459        : "");
4460
4461    if (
4462      typeof arBasketItems === "object" &&
4463      itemData &&
4464      typeof arBasketItems[itemData.ID] === "object"
4465    )
4466      delete arBasketItems[itemData.ID];
4467
4468    var _ajax = function () {
4469      $.ajax({
4470        url: arAllcorp2Options["SITE_DIR"] + "include/footer/site-basket.php",
4471        data: { itemData: itemData, remove: bRemove, removeAll: bRemoveAll },
4472      }).success(function (html) {
4473        if (bBasketTop) {
4474          $(".ajax_basket").html(html);
4475          $(".basket_top .items").scrollTop(scrollTop);
4476        }
4477
4478        if (getCurUri) {
4479          $.ajax({
4480            url: getCurUri,
4481            type: "POST",
4482          }).success(function (html) {
4483            if ($(".basket.default").length) {
4484              $(".basket.default").html(html);
4485            }
4486          });
4487        }
4488
4489        if (bBasketFly) {
4490          $(".ajax_basket").html(html);
4491          $(".ajax_basket").addClass("opened");
4492          $(".basket.fly .items_wrap").scrollTop(scrollTop);
4493        }
4494
4495        var eventdata = { action: "loadBasket" };
4496        BX.onCustomEvent("onCompleteAction", [eventdata, $(html)]);
4497
4498        if (arAllcorp2Options["THEME"]["USE_SALE_GOALS"] != "N") {
4499          var eventdata = {
4500            goal: "goal_basket_remove",
4501            params: {
4502              itemData: itemData,
4503              remove: bRemove,
4504              removeAll: bRemoveAll,
4505            },
4506          };
4507          BX.onCustomEvent("onCounterGoals", [eventdata]);
4508        }
4509      });
4510    };
4511
4512    if (
4513      typeof arAllcorp2Options["THEME"]["ORDER_BASKET_VIEW"] !== "undefined"
4514    ) {
4515      if (
4516        $.trim(arAllcorp2Options["THEME"]["ORDER_BASKET_VIEW"]) === "HEADER" &&
4517        $(".basket_top").length
4518      )
4519        var bBasketTop = true;
4520      else if ($(".basket.fly").length) var bBasketFly = true;
4521    }
4522
4523    if (
4524      (typeof itemData !== "undefined" &&
4525        !isNaN(itemData.ID) &&
4526        itemData.ID > 0) ||
4527      bRemoveAll
4528    ) {
4529      if (bRemoveAll) {
4530        $(".buy_block").removeClass("in");
4531        $(".basket .count").text(0).addClass("empted");
4532        $(".basket_top .count").text(0).addClass("empted");
4533        $("#mobilemenu .menu .ready .count").text(0).addClass("empted");
4534      } else {
4535        $("[data-item]").each(function () {
4536          if ($(this).data("item").ID == itemData.ID) {
4537            $(this).find(".buy_block").removeClass("in");
4538          }
4539        });
4540        if ($(".basket").length) {
4541          if ($(".basket_top .count").length)
4542            $(".basket_top .count").text(
4543              parseFloat($(".basket_top:visible .count").text()) - 1
4544            );
4545          else {
4546            $(".basket .count").text(
4547              parseFloat($(".basket .count").text()) - 1
4548            );
4549            $(".basket_top .count").text(
4550              parseFloat($(".basket .count").text()) - 1
4551            );
4552          }
4553        } else {
4554          $(".basket_top .count").text(
4555            parseFloat($(".basket_top:visible .count").text()) - 1
4556          );
4557        }
4558
4559        $("#mobilemenu .menu .ready .count").text(
4560          parseFloat($("#mobilemenu .menu .ready .count").text()) - 1
4561        );
4562      }
4563
4564      if (bOneItem && !bRemoveAll) {
4565        if (item.closest(".basket_top").length) {
4566          item.closest(".dropdown").animate({ opacity: 0 }, 200, function () {
4567            _ajax();
4568          });
4569        } else {
4570          item.closest(".basket").find(".count").addClass("empted");
4571          item.closest(".basket_wrap").fadeOut(200, function () {
4572            item
4573              .closest(".basket")
4574              .find(".basket_empty")
4575              .fadeIn(200, function () {
4576                _ajax();
4577              });
4578          });
4579        }
4580      } else if (bRemoveAll) {
4581        $(".basket_wrap").fadeOut(200, function () {
4582          $(".remove.all").remove();
4583          $(".basket")
4584            .find(".basket_empty")
4585            .fadeIn(200, function () {
4586              _ajax();
4587            });
4588        });
4589      } else if (!bOneItem) {
4590        item.animate({ opacity: 0 }, 200).slideUp(200, function () {
4591          _ajax();
4592        });
4593      }
4594    } else {
4595      return;
4596    }
4597  });
4598  $(document).on("click", ".print", function () {
4599    window.print();
4600  });
4601
4602  $(".choise").on("click", function () {
4603    var _this = $(this);
4604    if (typeof _this.data("block") != "undefined") {
4605      scrollToBlock(_this.data("block"));
4606    }
4607  });
4608
4609  /*touch event*/
4610  document.addEventListener(
4611    "touchend",
4612    function (event) {
4613      if (
4614        !$(event.target).closest(".menu-item").length &&
4615        !$(event.target).hasClass("menu-item")
4616      ) {
4617        $(".mega-menu .dropdown-menu").css({ display: "none", opacity: 0 });
4618        $(".menu-item").removeClass("hover");
4619        $(".bx-breadcrumb-item.drop").removeClass("hover");
4620      }
4621      if (!$(event.target).closest(".menu.topest").length) {
4622        $(".menu.topest").css({ overflow: "hidden" });
4623        $(".menu.topest > li").removeClass("hover");
4624      }
4625      if (!$(event.target).closest(".full.has-child").length) {
4626        $(".menu_top_block.catalog_block li").removeClass("hover");
4627      }
4628      /*if(!$(event.target).closest('.basket_block').length){
4629			$('.basket_block .link').removeClass('hover');
4630			$('.basket_block .basket_popup_wrapp').slideUp();
4631		}
4632		if(!$(event.target).closest('.catalog_item').length){
4633			var tabsContentUnhoverHover = $('.tab:visible').attr('data-unhover') * 1;
4634			$('.tab:visible').stop().animate({'height': tabsContentUnhoverHover}, 100);
4635			$('.tab:visible').find('.catalog_item').removeClass('hover');
4636			$('.tab:visible').find('.catalog_item .buttons_block').stop().fadeOut(233);
4637			if($('.catalog_block').length){
4638				$('.catalog_block').find('.catalog_item_wrapp').removeClass('hover');
4639				$('.catalog_block').find('.catalog_item').removeClass('hover');
4640			}
4641		}*/
4642    },
4643    false
4644  );
4645
4646  touchMenu(".mega-menu .menu-item");
4647  touchTopMenu(".menu.topest li");
4648  /*show password*/
4649  $(".form-group:not(.eye-password-ignore) [type=password]").each(function (item) {
4650    let passBlock = $(this).closest(".form-group");
4651    let labelBlock = passBlock.find(".label_block");
4652    if (labelBlock.length) {
4653      labelBlock.addClass("eye-password");
4654    } else {
4655      passBlock.addClass("eye-password");
4656    }
4657  });
4658
4659  $(document).on("click", ".eye-password:not(.eye-password-ignore)", function (event) {
4660    let input = this.querySelector("input");
4661    let eyeWidth = 56;
4662    if (this.clientWidth - eyeWidth < event.offsetX) {
4663      if (input.type == "password") {
4664        input.type = "text";
4665        this.classList.add("password-show");
4666      } else if (input.type == "text") {
4667        input.type = "password";
4668        this.classList.remove("password-show");
4669      }
4670    }
4671  });
4672  /**/
4673});
4674
4675function touchMenu(selector) {
4676  if (isMobile) {
4677    if ($(selector).length) {
4678      $(selector).each(function () {
4679        var th = $(this);
4680        th.on("touchend", function (e) {
4681          var _th = $(e.target).closest(".menu-item");
4682
4683          $(".menu.topest > li").removeClass("hover");
4684          $(".menu_top_block.catalog_block li").removeClass("hover");
4685          $(".bx-breadcrumb-item.drop").removeClass("hover");
4686
4687          if (_th.find(".dropdown-menu").length && !_th.hasClass("hover")) {
4688            e.preventDefault();
4689            e.stopPropagation();
4690            _th.siblings().removeClass("hover");
4691            _th.addClass("hover");
4692            $(".menu-row .dropdown-menu").css({ display: "none", opacity: 0 });
4693            if (_th.hasClass("menu-item")) {
4694              _th
4695                .closest(".dropdown-menu")
4696                .css({ display: "block", opacity: 1 });
4697            }
4698            if (_th.find("> .wrap > .dropdown-menu")) {
4699              _th
4700                .find("> .wrap > .dropdown-menu")
4701                .css({ display: "block", opacity: 1 });
4702            } else if (_th.find("> .dropdown-menu")) {
4703              _th
4704                .find("> .dropdown-menu")
4705                .css({ display: "block", opacity: 1 });
4706            }
4707            CheckTopVisibleMenu();
4708          } else {
4709            var href = $(e.target).attr("href")
4710              ? $(e.target).attr("href")
4711              : $(e.target).closest("a").attr("href");
4712            if (href && href !== "undefined") location.href = href;
4713          }
4714        });
4715      });
4716    }
4717  } else {
4718    $(selector).off();
4719  }
4720}
4721
4722function touchTopMenu(selector) {
4723  if (isMobile) {
4724    if ($(selector).length) {
4725      $(selector).each(function () {
4726        var th = $(this);
4727        th.on("touchend", function (e) {
4728          var _th = $(e.target).closest("li");
4729
4730          $(".menu-item").removeClass("hover");
4731          $(".menu-item .dropdown-menu").css({ display: "none", opacity: 0 });
4732          $(".menu_top_block.catalog_block li").removeClass("hover");
4733          $(".bx-breadcrumb-item.drop").removeClass("hover");
4734
4735          if (_th.hasClass("more") && !_th.hasClass("hover")) {
4736            e.preventDefault();
4737            e.stopPropagation();
4738            _th.siblings().removeClass("hover");
4739            _th.addClass("hover");
4740            $(".menu.topest").css({ overflow: "visible" });
4741          } else {
4742            var href = $(e.target).attr("href")
4743              ? $(e.target).attr("href")
4744              : $(e.target).closest("a").attr("href");
4745            if (href && href !== "undefined") location.href = href;
4746          }
4747        });
4748      });
4749    }
4750  } else {
4751    $(selector).off();
4752  }
4753}
4754
4755scrollPreviewBlock = function () {
4756  if (
4757    typeof $.cookie("scoll_block") != "undefined" &&
4758    $.cookie("scoll_block")
4759  ) {
4760    var scoll_block = $($.cookie("scoll_block"));
4761    if (scoll_block.length) {
4762      $("body, html").animate({ scrollTop: scoll_block.offset().top }, 500);
4763      $.cookie("scoll_block", null);
4764    }
4765  }
4766};
4767
4768scrollToBlock = function (block) {
4769  if ($(block).length) {
4770    var offset = $(block).offset().top;
4771    if (typeof $(block).data("toggle") != "undefined") $(block).click();
4772
4773    if (typeof $(block).data("offset") != "undefined")
4774      offset += $(block).data("offset");
4775
4776    $("body, html").animate({ scrollTop: offset }, 500);
4777  }
4778};
4779
4780// START VIDEO BUTTON
4781$(".banners-big .maxwidth-banner .item.vvideo .maxwidth-theme").on(
4782  "click",
4783  function (e) {
4784    if (!$(e.target).hasClass("btn-video")) {
4785      if ($(this).hasClass("loading")) {
4786        e.stopPropagation();
4787        $(this).find(".btn-video").trigger("click");
4788      }
4789    }
4790  }
4791);
4792
4793$(document).on("click", ".banners-big .item.current  .btn-video", function (e) {
4794  e.stopPropagation();
4795  if (
4796    !$(this).hasClass("loading") &&
4797    !$(this).closest(".banners-big").hasClass("view_2")
4798  ) {
4799    $(this).addClass("loading");
4800    $(this).closest(".maxwidth-theme").addClass("loading");
4801  } else {
4802    $(this).removeClass("loading");
4803    $(this).closest(".maxwidth-theme").removeClass("loading");
4804  }
4805
4806  startMainBannerSlideVideo($(this).closest(".item"));
4807});
4808
4809//  BANNER GO TO LINK
4810$(document).on("click", ".banners-big.front .box .tablet_img", function (e) {
4811  var wurl = $(this).closest(".box").hasClass("wurl");
4812  if (wurl) {
4813    var href = $(this).closest(".box").find(".target").attr("href");
4814    console.log(href);
4815    if (href.length) {
4816      var target = $(this).closest(".box").find(".target").attr("target");
4817      if (typeof target === "undefined" || target === "_self") {
4818        location.href = href;
4819      } else {
4820        window.open(href);
4821      }
4822    }
4823  }
4824});
4825
4826//DIGITAL BASKET
4827function number_format(number, decimals, dec_point, thousands_sep) {
4828  number = (number + "").replace(/[^0-9+\-Ee.]/g, "");
4829  var n = !isFinite(+number) ? 0 : +number,
4830    prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
4831    sep = typeof thousands_sep === "undefined" ? "," : thousands_sep,
4832    dec = typeof dec_point === "undefined" ? "." : dec_point,
4833    s = "",
4834    toFixedFix = function (n, prec) {
4835      var k = Math.pow(10, prec);
4836      return "" + (Math.round(n * k) / k).toFixed(prec);
4837    };
4838
4839  // Fix for IE parseFloat(0.55).toFixed(0) = 0;
4840  s = (prec ? toFixedFix(n, prec) : "" + Math.round(n)).split(".");
4841
4842  if (s[0].length > 3) {
4843    s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);
4844  }
4845
4846  if ((s[1] || "").length < prec) {
4847    s[1] = s[1] || "";
4848    s[1] += new Array(prec - s[1].length + 1).join("0");
4849  }
4850
4851  return s.join(dec);
4852}
4853
4854setBasketItemsClasses = function () {
4855  if (
4856    typeof arBasketItems !== "undefined" &&
4857    typeof arBasketItems !== "string"
4858  ) {
4859    if (Object.keys(arBasketItems).length) {
4860      for (var key in arBasketItems) {
4861        $("[data-item]").each(function () {
4862          if ($(this).data("item").ID == key) {
4863            $(this).find(".buy_block").addClass("in");
4864          }
4865        });
4866      }
4867    }
4868  }
4869};
4870
4871function Summ(el, counterInputValueNew, price) {
4872  if (counterInputValueNew <= 0) {
4873    counterInputValueNew = 1;
4874  }
4875
4876  var summ = number_format(counterInputValueNew * price, 0, ".", " "),
4877    allSumm = 0;
4878
4879  el.closest(".items")
4880    .find(".item")
4881    .each(function () {
4882      var $this = $(this),
4883        price = parseFloat($this.find("input[name=PRICE]").val()),
4884        count = parseFloat($this.find("input.count").val());
4885
4886      if (count <= 0) {
4887        count = 1;
4888      }
4889
4890      if (!isNaN(price) && !isNaN(count)) {
4891        allSumm += count * price;
4892      }
4893    });
4894
4895  allSumm = number_format(parseFloat(allSumm), 0, ".", " ");
4896
4897  el.closest(".item").find(".summ .price_val").text(summ);
4898  el.closest(".basket").find(".foot .total>span").text(allSumm);
4899}
4900
4901var timerBasketUpdate = false;
4902// - COUNTER
4903BasketCounter = function (el) {
4904  var elClass = $.trim(el.attr("class")),
4905    bClassMinus = elClass.indexOf("minus") > -1,
4906    bClassPlus = elClass.indexOf("plus") > -1,
4907    bClassCount = elClass.indexOf("count") > -1,
4908    getCurUri = $.trim($("input[name=getPageUri]").val()),
4909    buyBlock = el.closest(".buy_block"),
4910    buttonToCart = buyBlock.find(".to_cart"),
4911    counterInput = el.closest(".counter").find("input.count"),
4912    counterInputValue = parseFloat($.trim(counterInput.val())),
4913    price = parseFloat(buyBlock.find("input[name=PRICE]").val()),
4914    counterInputMaxCount =
4915      Math.pow(10, parseInt(counterInput.attr("maxlength"))) - 1,
4916    bAjax = el.closest(".basket").length ? true : false;
4917
4918  // class minus button
4919  if (bClassMinus) {
4920    var counterInputValueNew = counterInputValue - 1;
4921
4922    if (counterInputValueNew <= 0) {
4923      counterInputValueNew = 1;
4924    }
4925
4926    counterInput.val(counterInputValueNew);
4927
4928    if (bAjax) {
4929      Summ(el, counterInputValueNew, price);
4930
4931      if (timerBasketUpdate) {
4932        clearTimeout(timerBasketUpdate);
4933        timerBasketUpdate = false;
4934      }
4935
4936      timerBasketUpdate = setTimeout(function () {
4937        BasketUpdate(el, counterInputValueNew);
4938        timerBasketUpdate = false;
4939      }, 700);
4940    }
4941  }
4942  // class plus button
4943  else if (bClassPlus) {
4944    var counterInputValueNew = counterInputValue + 1;
4945
4946    if (counterInputValueNew > counterInputMaxCount) {
4947      counterInputValueNew = counterInputMaxCount;
4948    }
4949
4950    counterInput.val(counterInputValueNew);
4951
4952    if (bAjax) {
4953      Summ(el, counterInputValueNew, price);
4954
4955      if (timerBasketUpdate) {
4956        clearTimeout(timerBasketUpdate);
4957        timerBasketUpdate = false;
4958      }
4959
4960      timerBasketUpdate = setTimeout(function () {
4961        BasketUpdate(el, counterInputValueNew);
4962        timerBasketUpdate = false;
4963      }, 700);
4964    }
4965  }
4966  // class input
4967  else if (bClassCount) {
4968    var counterInputValueNew = counterInputValue;
4969
4970    if (counterInputValueNew <= 0 || isNaN(counterInputValueNew)) {
4971      counterInputValueNew = 1;
4972    }
4973    el.val(counterInputValueNew);
4974
4975    if (bAjax) {
4976      BasketUpdate(el, counterInputValueNew);
4977    }
4978  }
4979
4980  if (!getCurUri && !el.closest(".basket.fly").length) {
4981    buttonToCart.data("quantity", counterInputValueNew);
4982  }
4983};
4984
4985BasketUpdate = function (el, counterInputValueNew) {
4986  var itemData = el.closest("[data-item]").data("item"),
4987    itemData =
4988      typeof arBasketItems === "object" &&
4989      typeof arBasketItems[itemData.ID] === "object"
4990        ? arBasketItems[itemData.ID]
4991        : itemData,
4992    buyBlock = el.closest(".buy_block"),
4993    buttonToCart = buyBlock.find(".to_cart"),
4994    getCurUri = $.trim($("input[name=getPageUri]").val());
4995  scrollTop = $(".basket.fly").length
4996    ? $(".basket.fly .items_wrap").scrollTop()
4997    : $(".basket_top:visible").length
4998    ? $(".basket_top .items:visible").scrollTop()
4999    : "";
5000
5001  if (
5002    typeof arAllcorp2Options["THEME"]["ORDER_BASKET_VIEW"] !== "undefined" &&
5003    $.trim(arAllcorp2Options["THEME"]["ORDER_BASKET_VIEW"]) === "FLY" &&
5004    $(".basket.fly").length
5005  ) {
5006    var bBasketFly = true;
5007  }
5008
5009  if (
5010    typeof arAllcorp2Options["THEME"]["ORDER_BASKET_VIEW"] !== "undefined" &&
5011    $.trim(arAllcorp2Options["THEME"]["ORDER_BASKET_VIEW"]) === "HEADER" &&
5012    $(".basket_top").length
5013  ) {
5014    var bBasketTop = true;
5015  } else {
5016    if (
5017      typeof itemData != "undefined" &&
5018      !isNaN(itemData.ID) &&
5019      itemData.ID > 0
5020    ) {
5021      $.ajax({
5022        // url: arAllcorp2Options['SITE_DIR'] + 'ajax/basket_items.php',
5023        url: arAllcorp2Options["SITE_DIR"] + "include/footer/site-basket.php",
5024        data: { itemData: itemData, quantity: counterInputValueNew },
5025      }).success(function (data) {
5026        if (typeof data === "object") {
5027          arBasketItems = data;
5028        }
5029        if (bBasketTop) {
5030          $.ajax({
5031            url:
5032              arAllcorp2Options["SITE_DIR"] + "include/footer/site-basket.php",
5033            type: "POST",
5034            data: { ajaxPost: "Y" },
5035          }).success(function (html) {
5036            buyBlock.removeClass("in");
5037            $(".ajax_basket").html(html);
5038
5039            /*if(!getCurUri){
5040							setTimeout(function(){
5041								$('.basket_top .dropdown').addClass('expanded');
5042							}, 100);
5043
5044							setTimeout(function(){
5045								$('.basket_top .dropdown').removeClass('expanded');
5046							}, 1000);
5047						}*/
5048          });
5049        }
5050
5051        if (bBasketFly) {
5052          $.ajax({
5053            url:
5054              arAllcorp2Options["SITE_DIR"] + "include/footer/site-basket.php",
5055            type: "POST",
5056            data: { ajaxPost: "Y" },
5057          }).success(function (html) {
5058            if ($(".basket.fly").length) {
5059              $(".ajax_basket").html(html);
5060              $(".basket.fly .items_wrap").scrollTop(scrollTop);
5061            }
5062          });
5063        }
5064
5065        var eventdata = { action: "loadBasket" };
5066        BX.onCustomEvent("onCompleteAction", [eventdata, $(data)]);
5067
5068        if (getCurUri) {
5069          $.ajax({
5070            url: getCurUri,
5071            type: "POST",
5072          }).success(function (html) {
5073            if ($(".basket.default").length) {
5074              $(".basket.default").html(html);
5075            }
5076          });
5077        }
5078      });
5079    } else {
5080      return;
5081    }
5082  }
5083};
5084
5085showTopIcons = function () {
5086  $("h1").addClass("shares");
5087  $(document).ready(function () {
5088    if ($("a.rss").length) $("a.rss").after($(".share.top"));
5089    else $("h1").before($(".share.top"));
5090  });
5091};
5092
5093CheckTabActive = function () {
5094  if (typeof clicked_tab && clicked_tab) {
5095    /*if(window.matchMedia('(min-width: 768px)').matches)
5096		{
5097			clicked_tab--;
5098			$('.catalog.detail .nav.nav-tabs li:eq('+clicked_tab+')').addClass('active');
5099			$('.catalog.detail .tab-content .tab-pane:eq('+clicked_tab+')').addClass('active');
5100			$('.catalog.detail .tab-content .tab-pane .title-tab-heading').next().removeAttr('style');
5101			clicked_tab = 0;
5102		}*/
5103  }
5104};
5105
5106/* parallax bg */
5107ParallaxBg = function () {
5108  if ($("*[data-type=parallax-bg]").length) {
5109    var x = $(window).scrollTop() / $(document).height();
5110    x = parseInt(-x * 280);
5111    $("*[data-type=parallax-bg]")
5112      .stop()
5113      .animate({ "background-position-y": x + "px" }, 400, "swing");
5114  }
5115};
5116SetFixedAskBlock = function () {
5117  if ($(".ask_a_question_wrapper").length) {
5118    var offset = $(".ask_a_question_wrapper").offset(),
5119      block = $(".ask_a_question_wrapper").find(".ask_a_question"),
5120      block_offset = BX.pos(block[0]),
5121      block_height = block_offset.bottom - block_offset.top,
5122      ask_block_offset = 130,
5123      diff_top_scroll = $("#headerfixed").height() + 90,
5124      footer_block = $("footer").offset().top;
5125	if($('.news-filter').length) {
5126		$('.news-filter').removeClass('abs-pos')
5127	}
5128    //need for short page content
5129    var wrapHeight = block.height();
5130    block.parent().css({ "min-height": wrapHeight + 42 + "px" });
5131
5132    if (
5133      block_height + ask_block_offset <
5134      block.closest(".fixed_wrapper").height()
5135    ) {
5136      if (
5137        block_height + ask_block_offset >
5138        block.closest(".fixed_wrapper").height()
5139      )
5140        block.addClass("nonfixed");
5141      else block.removeClass("nonfixed");
5142
5143      if (block.closest(".fixed_wrapper").length)
5144        footer_block = BX.pos(block.closest(".fixed_wrapper")[0]).bottom;
5145
5146      if (
5147        block_height + diff_top_scroll + documentScrollTopLast + 80 >
5148        footer_block
5149      ) {
5150        block
5151          .removeClass("fixed")
5152          .css({ top: "auto", width: "auto", bottom: "-70px" })
5153          .addClass("normal");
5154        block.parent().css("position", "static");
5155		if($('.news-filter').length) {
5156			$('.news-filter').addClass('abs-pos')
5157		}
5158        block.parent().parent().css("position", "static");
5159      } else {
5160        block.removeClass("normal");
5161        //block.parent().removeAttr('style');
5162        block.parent().css({ "min-height": wrapHeight + 42 + "px" });
5163        block.parent().parent().removeAttr("style");
5164
5165        if (documentScrollTopLast + diff_top_scroll - 30 > offset.top)
5166          block.addClass("fixed").css({
5167            top: diff_top_scroll,
5168            bottom: "auto",
5169            width: $(".fixed_block_fix").width(),
5170          });
5171        else block.removeClass("fixed").css({ top: 0, width: "auto" });
5172      }
5173    }
5174  }
5175};
5176
5177// Events
5178var timerScroll = false,
5179  ignoreScroll = [],
5180  documentScrollTopLast = $(document).scrollTop(),
5181  documentScrollTop = $(document).scrollTop();
5182$(window).scroll(function () {
5183  documentScrollTop = $(document).scrollTop();
5184  CheckPopupTop();
5185  SetFixedAskBlock();
5186  if (!ignoreScroll.length) {
5187    if (timerScroll) {
5188      clearTimeout(timerScroll);
5189      timerScroll = false;
5190    }
5191    timerScroll = setTimeout(function () {
5192      BX.onCustomEvent("onWindowScroll", false);
5193    }, 100);
5194  }
5195  documentScrollTopLast = $(document).scrollTop();
5196});
5197
5198var timerResize = false,
5199  ignoreResize = [];
5200
5201$(window).resize(function () {
5202  documentScrollTop = $(document).scrollTop();
5203
5204  var scrollTimer = setInterval(function () {
5205    if (typeof arAllcorp2Options !== "undefined") {
5206      CheckPopupTop();
5207      CheckScrollToTop();
5208      clearInterval(scrollTimer);
5209    }
5210  });
5211
5212  if (!ignoreResize.length) {
5213    if (timerResize) {
5214      clearTimeout(timerResize);
5215      timerResize = false;
5216    }
5217    timerResize = setTimeout(function () {
5218      BX.onCustomEvent("onWindowResize", false);
5219    }, 100);
5220  }
5221  documentScrollTopLast = $(document).scrollTop();
5222
5223  if (arAllcorp2Options["THEME"]["COMPACT_FOOTER_MOBILE"] && arAllcorp2Options["THEME"]["COMPACT_FOOTER_MOBILE"] == "Y") {
5224    if (window.matchMedia("(max-width:767px)").matches) {
5225      $("footer").addClass("mobile");
5226      $(".bottom-menu .items>.wrap_compact_mobile").addClass(
5227        "accordion-body collapse"
5228      );
5229      $(".bottom-menu .items>.item-link").attr("data-toggle", "collapse");
5230    } else {
5231      $("footer").removeClass("mobile");
5232      $(".bottom-menu .items>.wrap_compact_mobile").removeClass(
5233        "accordion-body collapse"
5234      );
5235      $(".bottom-menu .items>.item-link").removeAttr("data-toggle");
5236    }
5237  }
5238});
5239
5240BX.addCustomEvent("onWindowScroll", function (eventdata) {
5241  try {
5242    ignoreScroll.push(true);
5243    ParallaxBg();
5244
5245    if (arAllcorp2Options["THEME"]["TYPE_SEARCH"] != "fixed") {
5246      if (!$("header > .top-block").length) {
5247        var height_block = 0,
5248          scrollVal = $(window).scrollTop();
5249        height_block = $(".logo_and_menu-row").actual("outerHeight");
5250        if (!scrollVal) {
5251          $(".inline-search-block").css({
5252            height: height_block,
5253            "line-height": height_block - 4 + "px",
5254            top: -height_block,
5255          });
5256        }
5257      }
5258    }
5259  } catch (e) {
5260  } finally {
5261    ignoreScroll.pop();
5262  }
5263});
5264
5265BX.addCustomEvent("onWindowResize", function (eventdata) {
5266  try {
5267    ignoreResize.push(true);
5268
5269    CheckHeaderFixedMenu();
5270    CheckTopMenuDotted();
5271    CheckTopVisibleMenu();
5272    CheckFlexSlider();
5273    CheckMainBannerSliderVText($(".banners-big .flexslider"));
5274    CheckObjectsSizes();
5275    CoverPlayer();
5276    verticalAlign();
5277    CheckTabActive();
5278    setTimeout(function () {
5279      createTableCompare(
5280        $(".main-block .items .title-block:not(.clone) .item"),
5281        $(".prop_title_table"),
5282        $(".main-block .prop_title_table .item.clone")
5283      );
5284    }, 100);
5285    SliceHeightBlocks();
5286  } catch (e) {
5287  } finally {
5288    ignoreResize.pop();
5289  }
5290});
5291
5292BX.addCustomEvent("onSlide", function (eventdata) {
5293  try {
5294    ignoreResize.push(true);
5295    if (eventdata) {
5296      var slider = eventdata.slider;
5297      if (slider) {
5298        // add classes .curent & .shown to slide
5299        slider.find(".item").removeClass("current");
5300        var curSlide = slider.find(".item.flex-active-slide");
5301        var curSlideIndex = curSlide.attr("data-slide_index");
5302
5303        curSlide.addClass("current");
5304        slider
5305          .find(".item[data-slide_index=" + curSlideIndex + "]")
5306          .addClass("shown");
5307        slider.resize();
5308
5309        if (typeof curSlideIndex !== "undefined" && curSlideIndex.length) {
5310          // set main banners text vertical center
5311          CheckMainBannerSliderVText(slider);
5312          if ($(".item.vvideo")) {
5313            $(".item.vvideo .maxwidth-theme").removeClass("loading");
5314            $(".item.vvideo .maxwidth-theme .btn-video").removeClass("loading");
5315
5316            if (!slider.closest(".banners-big").hasClass("view_2")) {
5317              $(".item.vvideo[data-video_autoplay=1] .maxwidth-theme").addClass(
5318                "loading"
5319              );
5320              $(
5321                ".item.vvideo[data-video_autoplay=1] .maxwidth-theme .btn-video"
5322              ).addClass("loading");
5323            }
5324          }
5325
5326          // pause play video
5327          if (typeof players !== "undefined" && players) {
5328            for (var j in players) {
5329              if (
5330                players[j].playing &&
5331                !players[j].clone &&
5332                players[j].slideIndex != curSlideIndex
5333              ) {
5334                if (typeof window[players[j].id] == "object") {
5335                  if (players[j].videoPlayer === "YOUTUBE") {
5336                    window[players[j].id].pauseVideo();
5337                  } else if (players[j].videoPlayer === "VIMEO") {
5338                    window[players[j].id].pause();
5339                  } else if (players[j].videoPlayer === "RUTUBE") {
5340                    document
5341                      .getElementById(players[j].id)
5342                      .contentWindow.postMessage(
5343                        JSON.stringify({
5344                          type: "player:pause",
5345                          data: {},
5346                        }),
5347                        "*"
5348                      );
5349                  } else if (players[j].videoPlayer === "HTML5") {
5350                    document.getElementById(players[j].id).pause();
5351                  }
5352                }
5353              }
5354            }
5355          }
5356          // autoplay video
5357          var bVideoAutoPlay = curSlide.attr("data-video_autoplay") == 1;
5358          if (bVideoAutoPlay) {
5359            startMainBannerSlideVideo(curSlide);
5360          }
5361        } else {
5362          slider.find(".item").css("opacity", "1");
5363        }
5364        if (slider.closest(".blocks").length)
5365          slider
5366            .closest(".blocks")
5367            .find(".flex-direction-nav li")
5368            .addClass("initied");
5369
5370        if (slider.closest(".wraps").length)
5371          slider
5372            .closest(".wraps")
5373            .find(".flex-direction-nav li")
5374            .addClass("initied");
5375
5376        if (
5377          !slider.find(".flex-control-nav li").length &&
5378          slider.hasClass("normal")
5379        ) {
5380          slider.find(".flex-direction-nav li a").addClass("flex-disabled");
5381        }
5382
5383        if (slider.closest(".banners-big").length) {
5384          // var curSlide = slider.find('.item.flex-active-slide');
5385          //logo src
5386          var bLogoImg = $("header .logo-block .logo img").length;
5387          if (bLogoImg)
5388            $("header .logo-block .logo img").attr(
5389              "src",
5390              arAllcorp2Options.THEME.LOGO_IMAGE
5391            );
5392
5393          //nav flex color
5394          slider.find(".flex-control-nav li").removeClass();
5395
5396          //header color
5397          $("header").removeClass("light dark");
5398          if (typeof curSlide.data("color") != "undefined") {
5399            slider
5400              .find(".flex-control-nav li")
5401              .addClass(curSlide.data("color"));
5402            $("header").addClass(curSlide.data("color"));
5403            if (bLogoImg) {
5404              if (
5405                arAllcorp2Options.THEME.LOGO_IMAGE_LIGHT &&
5406                curSlide.data("color") == "light"
5407              )
5408                $("header .logo-block .logo img").attr(
5409                  "src",
5410                  arAllcorp2Options.THEME.LOGO_IMAGE_LIGHT
5411                );
5412            }
5413          }
5414        }
5415
5416        if (
5417          !slider.hasClass("flexslider-init-slice") &&
5418          slider.hasClass("nav-title") &&
5419          $(".gallery-block").closest(".tab-pane").hasClass("active")
5420        ) {
5421          slider.find(".item").sliceHeight({ lineheight: -3 });
5422          slider.addClass("flexslider-init-slice");
5423        }
5424
5425        if (slider.find(".flex-direction-nav").length) {
5426          if (slider.find(".flex-direction-nav").find("a.flex-disabled").length)
5427            slider
5428              .find(".flex-direction-nav")
5429              .removeClass("opacity1")
5430              .addClass("opacity0");
5431          else
5432            slider
5433              .find(".flex-direction-nav")
5434              .removeClass("opacity0")
5435              .addClass("opacity1");
5436        }
5437      }
5438    }
5439  } catch (e) {
5440  } finally {
5441    ignoreResize.pop();
5442  }
5443});
5444
5445BX.addCustomEvent("onSlideBefore", function (eventdata) {
5446  try {
5447    ignoreResize.push(true);
5448    if (eventdata) {
5449      var slider = eventdata.slider;
5450      if (slider) {
5451        if (slider.closest(".banners-big").length) {
5452          setTimeout(function () {
5453            var curSlide = slider.find(".item.flex-active-slide");
5454            //logo src
5455            var bLogoImg = $("header .logo-block .logo img").length;
5456            if (bLogoImg)
5457              $("header .logo-block .logo img").attr(
5458                "src",
5459                arAllcorp2Options.THEME.LOGO_IMAGE
5460              );
5461
5462            //nav flex color
5463            slider.find(".flex-control-nav li").removeClass();
5464
5465            //header color
5466            $("header").removeClass("light dark");
5467            if (typeof curSlide.data("color") != "undefined") {
5468              slider
5469                .find(".flex-control-nav li")
5470                .addClass(curSlide.data("color"));
5471              $("header").addClass(curSlide.data("color"));
5472              if (bLogoImg) {
5473                if (
5474                  arAllcorp2Options.THEME.LOGO_IMAGE_LIGHT &&
5475                  curSlide.data("color") == "light"
5476                )
5477                  $("header .logo-block .logo img").attr(
5478                    "src",
5479                    arAllcorp2Options.THEME.LOGO_IMAGE_LIGHT
5480                  );
5481              }
5482            }
5483          }, 100);
5484        } else if (slider.hasClass("top-bigs")) {
5485          setTimeout(function () {
5486            var index = slider
5487              .find(".item.flex-active-slide")
5488              .data("slide_key");
5489            $(".bxSlider.top-small .slides").data("bxSlider").goToSlide(index);
5490            $(".bxSlider.top-small .slides li").removeClass(
5491              "flex-active-slide"
5492            );
5493            $(
5494              '.bxSlider.top-small .slides li[data-slide_key="' + index + '"]'
5495            ).addClass("flex-active-slide");
5496          }, 100);
5497        }
5498      }
5499    }
5500  } catch (e) {
5501  } finally {
5502    ignoreResize.pop();
5503  }
5504});
5505
5506BX.addCustomEvent("onSlideEnd", function (eventdata) {
5507  try {
5508    ignoreResize.push(true);
5509    if (eventdata) {
5510      var slider = eventdata.slider;
5511      if (slider) {
5512      }
5513    }
5514  } catch (e) {
5515  } finally {
5516    ignoreResize.pop();
5517  }
5518});
5519
5520$(window).resize(function () {
5521  CheckTopMenuPadding();
5522  CheckTopMenuOncePadding();
5523  CheckSearchWidth();
5524});
5525
5526var onCaptchaVerifyinvisible = function (response) {
5527  $(".g-recaptcha:last").each(function () {
5528    var id = $(this).attr("data-widgetid");
5529    if (typeof id !== "undefined" && response) {
5530      if (!$(this).closest("form").find(".g-recaptcha-response").val())
5531        $(this).closest("form").find(".g-recaptcha-response").val(response);
5532      if ($("iframe[src*=recaptcha]").length) {
5533        $("iframe[src*=recaptcha]").each(function () {
5534          var block = $(this).parent().parent();
5535          if (!block.hasClass("grecaptcha-badge")) block.css("width", "100%");
5536        });
5537      }
5538      if ($(this).closest("form").attr("name") == "form_comment")
5539        BX.submit(BX("form_comment"));
5540      else $(this).closest("form").submit();
5541    }
5542  });
5543};
5544
5545var onCaptchaVerifynormal = function (response) {
5546  $(".g-recaptcha").each(function () {
5547    var id = $(this).attr("data-widgetid");
5548    if (typeof id !== "undefined") {
5549      if (grecaptcha.getResponse(id) != "") {
5550        $(this).closest("form").find(".recaptcha").valid();
5551      }
5552    }
5553  });
5554};
5555
5556BX.addCustomEvent("onSubmitForm", function (eventdata) {
5557  try {
5558    if (
5559      !window.renderRecaptchaById ||
5560      !window.asproRecaptcha ||
5561      !window.asproRecaptcha.key
5562    ) {
5563      eventdata.form.submit();
5564      $(eventdata.form).closest(".form").addClass("sending");
5565      return true;
5566    }
5567
5568    if (
5569      window.asproRecaptcha.params.recaptchaSize == "invisible" &&
5570      $(eventdata.form).find(".g-recaptcha").length
5571    ) {
5572      if ($(eventdata.form).find(".g-recaptcha-response").val()) {
5573        eventdata.form.submit();
5574        $(eventdata.form).closest(".form").addClass("sending");
5575        return true;
5576      } else {
5577        if (typeof grecaptcha != "undefined") {
5578          grecaptcha.execute(
5579            $(eventdata.form).find(".g-recaptcha").data("widgetid")
5580          );
5581        } else {
5582          return false;
5583        }
5584      }
5585    } else {
5586      eventdata.form.submit();
5587      $(eventdata.form).closest(".form").addClass("sending");
5588      return true;
5589    }
5590  } catch (e) {
5591    console.error(e);
5592    return true;
5593  }
5594});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.