PageSourceSearch

https://aeroscreen.ru/bitrix/templates/concept_phoenix_s1/js/script.js

js aeroscreen.ru collected 2026-10-08 23:50:08 UTC 318,526 bytes, 10,368 lines download raw bytes

1var stopScrollBasket = false,
2    arStatusBasketPhoenix = {},
3    contentSideHeight = 0,
4    menuSideHeight = 0,
5    basketPoolQuantity = {},
6    cur_pos = 0,
7    cart_page = "N",
8    customEvent = false,
9    layerPopup = 0, 
10    windowWidth = document.documentElement.clientWidth,
11    windowHeight = document.documentElement.clientHeight;
12
13
14
15var paramsLazy = {
16    scrollDirection: 'vertical',
17    threshold: 500,
18    visibleOnly: true,
19    effect: 'fadeIn'
20};
21
22
23function generateMaps(container) {
24    var mapBlock = $(".iframe-map-area", container);
25
26    if (mapBlock.length > 0) {
27        mapBlock.each(
28            function (index, element) {
29                $(element).after($(element).attr("data-src"));
30                $(element).remove();
31            }
32        );
33    }
34
35}
36
37function generateVideos(container) {
38
39    var videoBlock = $(".iframe-video-area", container);
40
41    if (videoBlock.length > 0) {
42        videoBlock.each(
43            function (index, element) {
44                $(element).after($(element).attr("data-src"));
45                $(element).remove();
46            }
47        );
48    }
49}
50
51
52function showWaitSearch(form) {
53    form.find(".circleG-area").addClass('active');
54}
55
56function hideWaitSearch(form) {
57    form.find(".circleG-area").removeClass('active');
58}
59
60function openCart() {
61    $('.no-click-block').addClass('on');
62    $('div.cart-parent').addClass('open');
63    startBlurWrapperContainer();
64    var openCartOut = setTimeout(function () {
65        $('div.cart-parent').addClass('on');
66        clearTimeout(openCartOut);
67    }, 200);
68
69}
70
71function closeCart() {
72    stopBlurWrapperContainer();
73    $('div.cart-parent').removeClass('on');
74    $('.no-click-block').removeClass('on');
75    var closeCartOut = setTimeout(function () {
76        $('div.cart-parent').removeClass('open');
77        clearTimeout(closeCartOut);
78    }, 700);
79
80
81}
82
83function showFormOrder() {
84    if ($(window).width() <= 767)
85        $(".right-p", ".basket-style.page").removeClass('d-none');
86}
87
88function hideFormOrder() {
89    if ($(window).width() <= 767)
90        $(".right-p", ".basket-style.page").addClass('d-none');
91}
92
93function showTabContent(arParams) {
94    var curUrlParam = "-1";
95    var urlParams = getUrlParams();
96    arParams = arParams || {};
97
98
99    if (urlParams['url-tab'] !== undefined) {
100        curUrlParam = urlParams['url-tab'];
101
102        if (curUrlParam == "products" && arParams.products)
103            curUrlParam = "products";
104
105        else if (curUrlParam == "delayed" && arParams.delay)
106            curUrlParam = "delayed";
107
108        else if (arParams.products)
109            curUrlParam = "products";
110
111        else if (arParams.delay)
112            curUrlParam = "delayed";
113    }
114
115
116    if ($(".url-tab[data-url-tab='" + curUrlParam + "']").length > 0) {
117
118        $(".url-tab[data-url-tab='" + curUrlParam + "']").parents(".url-tab-parent")
119            .find(".url-tab").removeClass('active').parents(".url-tab-parent").find(".url-tab-content").removeClass('active');
120
121        $(".url-tab[data-url-tab='" + curUrlParam + "']").addClass('active');
122        $(".url-tab-content[data-url-tab='" + curUrlParam + "']").addClass('active');
123
124        if (curUrlParam == "delayed")
125            hideFormOrder();
126
127    }
128
129}
130
131function getChar(evt) {
132    evt = (evt) ? evt : window.event;
133    var charCode = (evt.which) ? evt.which : evt.keyCode;
134    if (charCode >
134 31 && (charCode < 46 || charCode > 57)) {
135        return null;
136    }
137    return true;
138}
139
140function menuOffset(li) {
141    var mainPosition = $(li).parents('.main-menu-inner').width() + $(li).parents(
142        '.main-menu-inner').offset().left;
143    var liPosition = $(li).children('ul').offset().left + $(li).children('ul').width();
144    if (liPosition >= mainPosition) $(li).addClass('reverse');
145}
146
147function mobileMenuPositionFooter() {
148    if ($('.open-menu-mobile').height() > ($(
149            'div.open-menu-mobile div.menu-mobile-inner').outerHeight() + $(
150            'div.open-menu-mobile div.foot-wrap').outerHeight(true))) $(
151        'div.open-menu-mobile div.foot-wrap').addClass('absolute');
152    else {
153        $('div.open-menu-mobile div.foot-wrap').removeClass('absolute');
154    }
155}
156
157function openMenuFooterPos() {
158    var totalHeight = $('.open-menu .head-menu-wrap').outerHeight(true) + $(
159        '.open-menu .body-menu').outerHeight(true) + $(
160        '.open-menu .footer-menu-wrap').outerHeight(true);
161    var needHeight = $('.open-menu').height() - totalHeight + $(
162        '.open-menu .body-menu').outerHeight();
163    if ($(window).height() > totalHeight) $('.open-menu .body-menu').css(
164        'min-height', needHeight + 'px');
165}
166
167function phoenixResizeVideo() {
168    var win_height = $('div.video-modal').height();
169    var modal = 590;
170    if ($(window).width() > 767) {
171        if (win_height > modal) $("div.video-modal div.phoenix-modal-dialog").addClass(
172            'pos-absolute');
173        else {
174            $("div.video-modal div.phoenix-modal-dialog").removeClass('pos-absolute');
175        }
176    } else {
177        $("div.video-modal div.phoenix-modal-dialog").addClass('pos-absolute');
178    }
179}
180
181function scrollToBlock(dist, elem, offset) {
182    var moreDist = 0;
183
184    offset = offset || 0;
185    elem = elem || 0;
186
187    if ($('header').hasClass("fixed"))
188        moreDist = 69;
189
190    if ($("div.catalog-card-wrap").length > 0 || $("div.catalog-list-wrap").length > 0) {
191        moreDist = 0;
192
193        if ($('header').hasClass("fixed")) moreDist = 80;
194        if (elem) {
195            if (elem.hasClass('review')) moreDist = 100;
196        }
197    }
198    var destinationhref = parseInt($(dist).offset().top - moreDist - offset);
199
200
201    $("html:not(:animated),body:not(:animated)").animate({
202        scrollTop: destinationhref
203    }, 1000, "linear", function () {
204
205        setTimeout(
206            function () {
207
208                if (100 < Math.abs(parseInt($(dist).offset().top - moreDist - offset) - destinationhref)) {
209                    $("html:not(:animated),body:not(:animated)").animate({
210                        scrollTop: parseInt($(dist).offset().top - moreDist - offset)
211                    }, 300, "linear");
212                }
213            }, 300
214        );
215    });
216}
217
218
219function timerCookie(form) {
220    var timeout = true;
221    var timer = form.find('input.timerVal').val();
222    var forCookieTime = parseFloat(form.find('input.forCookieTime').val());
223    var totalTime = 0;
224    var mainTime = new Date().getTime();
225    var idElem = form.find("input[name='element']").val();
226    var idSect = form.find('input.idSect').val();
227    var firstEnter = BX.getCookie($(".domen-url-for-cookie").val() + '_phoenixFirstEnter' + idSect + idElem);
228    var firstEnterVal = BX.getCookie($(".domen-url-for-cookie").val() + '_phoenixFirstEnterVal' + idSect + idElem);
229    setTimeout(function () {
230        form.css('min-height', form.outerHeight());
231    }, 100);
232
233    if (forCookieTime <= 0)
234        forCookieTime = 1;
235
236    form.find('.phoenixtimer').addClass('active');
237    if (typeof (firstEnter) == "undefined" || firstEnterVal != timer) {
238        BX.setCookie($(".domen-url-for-cookie").val() + '_phoenixFirstEnter' + idSect + idElem, mainTime, {
239            expires: forCookieTime * 60 * 60
240        });
241        BX.setCookie($(".domen-url-for-cookie").val() + '_phoenixFirstEnterVal' + idSect + idElem, timer, {
242            expires: forCookieTime * 60 * 60
243        });
244        firstEnter = BX.getCookie($(".domen-url-for-cookie").val() + '_phoenixFirstEnter' + idSect + idElem);
245        firstEnterVal = BX.getCookie($(".domen-url-for-cookie").val() + '_phoenixFirstEnterVal' + idSect + idElem);
246    }
247    totalTime = ((mainTime - firstEnter) / 1000).toFixed();
248    if (totalTime < timer * 60) timer = timer * 60 - totalTime;
249    else {
250        timeout = false;
251    }
252    if (timeout) form.find('.phoenixtimer').countdown({
253        until: timer,
254        format: 'HMS',
255        onExpiry: liftOff,
256        layout: form.find('.phoenixtimer').html()
257    }, $.countdown.regionalOptions['ru']);
258    else {
259        form.find('.questions').removeClass('active');
260        form.find('.timeout_text').addClass('active');
261    }
262
263    function liftOff() {
264        form.find('.questions').removeClass('active');
265        form.find('.timeout_text').addClass('active');
266    }
267}
268
269function parseCount(newVal, ratio, minVal) {
270
271    var ost = newVal % ratio;
272    var ratio_ = ratio - ost;
273
274
275
276    newVal = newVal - minVal;
277    newVal -= (newVal % ratio);
278
279    if (ratio_ >= ost) {
280        newVal += minVal;
281    } else {
282        newVal += minVal + ratio;
283    }
284
285
286    if (newVal <= minVal || isNaN(newVal))
287        newVal = minVal;
288
289    return newVal;
290
291}
292
293function formatNum(val) {
294    val = String(val).replace(/(\d)(?=(\d{3})+([^\d]|$))/g, '$1 ');
295    return val;
296}
297
298function formAttentionScroll(dist, parent) {
299    $(parent).animate({
300        scrollTop: dist
301    }, 700);
302}
303
304
305function setHeaderBgImg(attr) {
306    if (typeof attr !== 'undefined')
307        $('header').css({
308            "background-image": "url('" + attr + "')"
309        });
310}
311
312var lazyController = false,
313    parentContainerSlide = {},
314    parent = {},
315    arImagesLazyload = {};
316
317
318
319
320function updateLazyLoad() {
321
322    $('.lazyload').Lazy({
323        scrollDirection: 'vertical',
324        threshold: 500,
325        visibleOnly: true,
326        effect: 'fadeIn',
327
328        afterLoad: function (element) {
329            if (contentSideHeight > 0)
330                contentSideHeight = $(".parent-fixedSrollBlock").outerHeight(true);
331
332            parent = $(element).parent();
333            parentContainerSlide = parent.find('.parent-slider-item-js');
334
335            if ($(element).hasClass("slider-start")) {
336
337                if (typeof arImagesLazyload["id" + $(element).attr("data-id")] === "undefined")
338                    arImagesLazyload["id" + $(element).attr("data-id")] = {
339                        "s": 0,
340                        "f": 0,
341                        "type": null
342                    };
343
344                arImagesLazyload["id" + $(element).attr("data-id")].s = 1;
345
346
347                arImagesLazyload["id" + $(element).attr("data-id")].type = parentContainerSlide;
348
349            }
350
351
352            if ($(element).hasClass('slider-finish')) {
353
354                if (typeof arImagesLazyload["id" + $(element).attr("data-id")] === "undefined")
355                    arImagesLazyload["id" + $(element).attr("data-id")] = {
356                        "s": 0,
357                        "f": 0,
358                        "type": null
359                    };
360
361                arImagesLazyload["id" + $(element).attr("data-id")].f = 1;
362                arImagesLazyload["id" + $(element).attr("data-id")].type = parentContainerSlide;
363
364            }
365
366            if ($(element).hasClass('slider-finish') || $(element).hasClass("slider-start")) {
367                for (key in arImagesLazyload) {
368
369                    if (arImagesLazyload[key].s == 1 && arImagesLazyload[key].f == 1) {
370
371                        /*if( arImagesLazyload[key].type.hasClass('first-slider') && !arImagesLazyload[key].type.hasClass('slider-init'))
372                            initFSlider(arImagesLazyload[key].type);*/
373
374                        controllerSliders(arImagesLazyload[key].type);
375
376
377                        delete arImagesLazyload[key];
378                    }
379                }
380            }
381
382
383            if ($(element).parents(".parent-video-bg").find(".videoBG").length > 0)
384                correctSizeVideoBg($(element).parents(".parent-video-bg").find(".videoBG"));
385
386
387            if ($(element).hasClass('map-start'))
388                generateMaps($(element).parents("div.block"));
389
390            if ($(element).hasClass('video-start'))
391                generateVideos($(element).parents("div.block"));
392
393            if ($(element).hasClass('video-start-js'))
394                generateVideos($(element).parents("div.video-start-parent"));
395
396            if ($(element).hasClass('videoBG-start'))
397                generateVideoBG($(element).parents("div.block"));
398
399            if ($(element).hasClass('videoBG-start-fb'))
400                generateVideoBG($(element).parents("div.first-block"));
401
402        }
403    });
404
405}
406
407function initMobileSideMenu() {
408
409    if ($(window).width() <= 991 && $(".menu-navigation-inner").length > 0) {
410        var clone = $(".menu-navigation-inner").clone();
411        $(".menu-navigation-inner").remove();
412        clone.addClass('wr-transform-to-dialog-by-mob d-none container-close-from-scroll').children().addClass('transform-to-dialog-by-mob').find(".scroll").addClass('from-modal');
413        clone.appendTo("body");
414    }
415
416}
417
418
419function setSharesValues() {
420
421    if ($(".public_shares").length > 0) {
422
423        var title = "",
424            description = "",
425            image = "",
426            url = "";
427
428        if ($("meta[property=\"og:title\"]").length)
429            title = $("meta[property=\"og:title\"]").attr("content");
430
431        if ($("meta[property=\"og:description\"]").length)
432            description = $("meta[property=\"og:description\"]").attr("content");
433
434        if ($("meta[property=\"og:image\"]").length)
435            image = $("meta[property=\"og:image\"]").attr("content");
436
437        if ($("meta[property=\"og:url\"]").length)
438            url = $("meta[property=\"og:url\"]").attr("content");
439
440
441        $(".public_shares a.vkontakte").attr("onclick", "Share.vkontakte('" + url + "','" + title + "','" + image 
441+ "', '" + description + "')");
442        $(".public_shares a.facebook").attr("onclick", "Share.facebook('" + url + "','" + title + "','" + image + "', '" + description + "')");
443        $(".public_shares a.twitter").attr("onclick", "Share.twitter('" + url + "','" + title + "')");
444
445    }
446}
447
448
449function ShowApplyRegion() {
450
451    if ($(".popup-block.region-apply").length > 0) {
452        setTimeout(function () {
453            $(".popup-block.region-apply").removeClass('d-none');
454            $(".popup-block.region-apply").addClass('fadeInUp');
455
456
457            if ($(window).width() < 768) {
458                startBlurWrapperContainer();
459            }
460        }, 2000);
461
462    }
463}
464
465function controllerSliders(obj)
466{
467    if(obj)
468    {
469        if(!obj.hasClass('slider-init'))
470        {
471
472            if (obj.hasClass('block-slider-list'))
473                initSlider(obj);
474
475            if (obj.hasClass('slider'))
476                initOpSlider(obj);
477
478            if (obj.hasClass('slider-mini'))
479                initOpMiniSlider(obj);
480
481            if (obj.hasClass('slider_catalog_big_items'))
482                initCSlider(obj);
483
484            if (obj.hasClass('partners-slider-list'))
485                initPartnersSlider(obj);
486
487            if (obj.hasClass('slider-gallery'))
488                initGallerySlider(obj);
489
490            if (obj.hasClass('big-advantages-slide'))
491                initAdvantagesBigSlider(obj);
492
493            if (obj.hasClass('small-advantages-slide'))
494                initAdvantagesSmallSlider(obj);
495
496            if (obj.hasClass('slider-news-big'))
497                initNewsBigSlider(obj);
498
499            if (obj.hasClass('slider-news-small'))
500                initNewsSmallSlider(obj);
501
502            if (obj.hasClass('menu-banner-slider'))
503                initBannersSlider(obj);
504
505            if (obj.hasClass('slider-news-detail'))
506                initNewsDetailSlider(obj);
507
508            if (obj.hasClass('catalog-list-slider'))
509                initCatalogDetailSlider(obj);
510
511            if (obj.hasClass('section-items-slider'))
512                initCatalogSubSectionsSlider(obj);
513        }
514    }
515}
516
517function setChangerBlocks() {
518    $("div.changer-blocks").each(
519        function()
520        {
521            var block = $(this);
522            
523            $("div.changer-link-js", block).each(
524                function(index, value)
525                {
526                    var arIds = $(this).attr("data-id").split(",");
527
528                    if(arIds)
529                    {
530                        for (var i = 0; i < arIds.length; i++) {
531
532                            if($(this).hasClass("active"))
533                            {
534                                $("div#block"+arIds[i]).removeClass("d-none");
535                                $('.lazyload').Lazy(paramsLazy);
536
537                                var obj = $("div#block"+arIds[i]).find(".parent-slider-item-js");
538
539                                controllerSliders(obj);
540                            }
541                            
542                        }
543                    }
544                    
545                }
546            );
547        }
548    );
549    
550    
551    $("div.changer-link-js").click(
552        function()
553        {
554            var block = $(this).parents("div.changer-blocks");
555            
556            $("div.changer-link-js", block).removeClass("active");
557            $(this).addClass("active");
558            
559             $("div.changer-link-js", block).each(
560                function(index, value)
561                {
562                    var arIds = $(this).attr("data-id").split(",");
563
564                    if(arIds)
565                    {
566                        for (var i = 0; i < arIds.length; i++) {
567                            $("div#block"+arIds[i]).addClass("d-none");
568                        }
569                    }
570                    
571                }
572            );
573
574            var arIds = $(this).attr("data-id").split(",");
575
576            if(arIds)
577            {
578                for (var i = 0; i < arIds.length; i++) {
579                    $("div#block"+arIds[i]).removeClass("d-none");
580                    $('.lazyload').Lazy(paramsLazy);
581                    var obj = $("div#block"+arIds[i]).find(".parent-slider-item-js");
582                    controllerSliders(obj);
583                }
584            }
585            
586            
587
588            
589        }
590    );
591}
592
593$(document).ready(function () {
594
595    setSharesValues();
596    initMobileSideMenu();
597
598    if ($(window).width() >= 991)
599        $(".slide-hidden-lg").remove();
600
601    else {
602        $(".slide-hidden-xs").remove();
603    }
604
605    if ($(window).width() >= 768)
606        setHeaderBgImg($('header').attr('data-src-lg'));
607
608
609
610    if ($(window).width() < 768) {
611        setHeaderBgImg($('header').attr('data-src-xs'));
612
613        if ($(".error-404").length > 0)
614            $("div.wrapper").addClass('overflow-visible');
615
616    }
617
618
619    updateLazyLoad();
620
621    if (window.frameCacheVars !== undefined) {
622        BX.addCustomEvent("onFrameDataReceived", function (json) {
623            customEvent = true;
624        });
625    }
626
627    initZoomer($('.zoom'));
628
629    $('.date-group').datetimepicker({
630        timepicker: false,
631        format: 'd.m.Y',
632        scrollMonth: false,
633        scrollInput: false,
634        dayOfWeekStart: 1
635
636    });
637
638    getCatalogStories();
639    setChangerBlocks();
640
641    setComments();
642
643});
644
645function ajaxGetComments(params) {
646    var path = "/bitrix/tools/concept.phoenix/ajax/comments/comments_block.php";
647    params = params || 0;
648
649    showProcessLoadBlock($(".block-comments-js"));
650
651    $.post(path, {
652            site_id: $("input.site_id").val(),
653            id: $(".block-comments-js").attr("data-element-id"),
654            mode: params.mode,
655            page: params.pageNum
656
657        },
658        function (html) {
659            closeProcessLoadBlock($(".block-comments-js"));
660
661            if(params.this)
662            {
663                if (params.this.hasClass('get-comments-js')) {
664                    $(".block-comments-js .comments-set-js").append(html);
665                    params.this.remove();
666                } 
667            }
668            else
669            {
670                $('.comments-set-js').append(html);
671            }
672
673
674            if(params.newItem)
675            {
676
677
678                $.ajax({
679                    url: "/bitrix/tools/concept.phoenix/ajax/ajax_hit_page.php",
680                    method: 'POST',
681                    success: function(json) {}
682                });
683
684
685                var otherHeight = 0;
686                if ($('header').hasClass('fixed')) 
687                    otherHeight = 100;
688
689                var newItem = $('.comments-set-js').find('.review-item.first');
690                newItem.addClass('new');
691                formAttentionScroll(newItem.offset().top - otherHeight, "html:not(:animated), body:not(:animated)");
692                setTimeout(function() {
693                    newItem.removeClass('new');
694                }, 2000);
695            }
696        }
697    );
698}
699
700function setComments(newItem){
701    if($('.block-comments-js').length>0)
702    {
703        newItem = newItem || '';
704        var params = {
705            newItem: newItem,
706            mode: "full"
707        };
708
709        ajaxGetComments(params);
710    }
711}
712
713$(document).on("click", ".get-comments-js", function () {
714    var params = {
715        "this": $(this),
716        "pageNum": $(this).attr("data-page"),
717        "mode": "list"
718    };
719    ajaxGetComments(params);
720});
721
722function deleteComment(params) {
723    var path = "/bitrix/tools/concept.phoenix/ajax/comments/delete.php";
724    params = params || 0;
725
726    showProcessLoadBlock($(".block-comments-js"));
727
728    $.post(
729        path, {
730            site_id: $("input.site_id").val(),
731            ELEMENT_ID: params.ELEMENT_ID
732        },
733        function (data) {
734            closeProcessLoadBlock($(".block-comments-js"));
735
736            if (data.OK == "Y") {
737                $(".review-item[data-review-id='"+params.ELEMENT_ID+"']").remove();
738            }
739            else
740            {
741                $('.comments-set-js').html('');
742                setComments();
743            }
744        },
745        "json"
746    );
747}
748
749$(document).on("click", ".comment-delete-js", function () {
750    var params = {
751        "ELEMENT_ID": $(this).attr("data-review-id")
752    };
753    deleteComment(params);
754});
755
756
757function sendComments(that, fields)
758{
759    fields = fields || null;
760
761    var form = that.parents("form"),
762        load = form.find(".loader-simple"),
763        question = form.find(".question-js"),
764        thank = form.find(".thank-js"),
765        text = form.find("textarea[name=TEXT]"),
766        btn = that;
767
768    if(text.val()<=5)
769    {
770        text.addClass('has-error');
771        formAttentionScroll(text.offset().top - form.offset().top, "html:not(:animated), body:not(:animated)");
772        return false;
773    }
774    else
775    {
776        load.removeClass('d-none');
777        btn.addClass('d-none');
778
779   
780        var formSendAll = buildFormValues(form);
781
782        formSendAll.append("send", "Y");
783        formSendAll.append("site_id", $("input.site_id").val());
784
785        if(fields)
786        {
787            if(fields.captchaToken)
788                formSendAll.append("captchaToken", fields.captchaToken);
789        }
790
791
792        var path = "/bitrix/tools/concept.phoenix/ajax/comments/add.php";
793
794
795        $.ajax({
796            url: path,
797            method: 'POST',
798            contentType: false,
799            processData: false,
800            data: formSendAll,
801            dataType: 'json',
802            success: function (json) {
803                if (json.OK == "Y") {
804
805                    thank.html(json.MESSAGE);
806                    question.addClass('d-none');
807                    thank.removeClass('d-none');
808
809                    setTimeout(function() {
810
811                        if(json.NEW === 'Y')
812                        {
813                            $('.comments-set-js').html('');
814                            setComments(json.NEW);
815                        }
816                        question.removeClass('d-none');
817                        thank.addClass('d-none');
818                        load.addClass('d-none');
819                        btn.removeClass('d-none');
820
821                        text.val('');
822                        text.parent().removeClass('in-focus');
823
824                    }, 2000);
825
826                    $.ajax({
827                        url: "/bitrix/tools/concept.phoenix/ajax/ajax_hit_page.php",
828                        method: 'POST',
829                        success: function (json) {}
830                    });
831
832                    /*setTimeout(function() {
833
834                        location.href = location.href;
835                    }, 3000);*/
836
837
838
839
840                } else if (json.OK == "N") {
841                    question.removeClass('d-none');
842                    thank.addClass('d-none');
843                    load.addClass('d-none');
844                    btn.removeClass('d-none');
845                }
846
847                console.log(json.CAPTCHA_SCORE);
848
849            }
850        });
851
852
853    }
854}
855
856$(document).on("click", ".btn-submit-comments-js", function () {
857
858    var that = $(this);
859    if($("body").hasClass('captcha'))
860    {
861        grecaptcha.execute($(".captcha-site-key").val(), {action: 'homepage'}).then(function(token) {
862
863            sendComments(that, {captchaToken:token});
864        });
865    }
866    else
867    {
868        sendComments(that);
869    }
870    
871
872});
873
874
875
876function initZoomer(obj) {
877    if ($(window).width() > 1024)
878        obj.zoom();
879}
880
881
882function correctBgStyle(obj) {
883    $('div.lazyload', obj).each(
884        function (index, element) {
885            if (typeof $(element).attr("src") != "undefined") {
886                $(element).attr("style", "background-image: url(" + $(element).attr("src") + ");");
887                $(element).removeAttr("src");
888
889            }
890        }
891
892    );
893}
894
895function correctLazyloadInSlider(obj) {
896    if ($('.lazyload', obj).length) {
897        $('.lazyload', obj).each(
898            function (index, element) {
899                $(element).attr("src", $(element).attr("data-src"));
900                $(element).removeAttr("data-src");
901            }
902
903        );
904
905        if ($('div.lazyload', obj).length)
906            correctBgStyle(obj);
907
908    }
909}
910
911function initNewsDetailSlider(obj) {
912    obj.on('init', function (event, slick) {
913        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
914        obj.addClass("slider-init");
915        correctLazyloadInSlider(obj);
916        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
917            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
918        }
919    });
920
921    obj.slick({
922        slidesToShow: 3,
923        slidesToScroll: 1,
924        dots: false,
925        infinite: true,
926        centerPadding: 0,
927        arrows: true,
928        responsive: [{
929                breakpoint: 991,
930                settings: {
931                    slidesToShow: 2
932                }
933            }, {
934                breakpoint: 575.98,
935                settings: {
936                    slidesToShow: 1
937                }
938            },
939            {
940                breakpoint: 0,
941                settings: "unslick"
942            }
943        ]
944    });
945}
946
947function initCatalogSubSectionsSlider(obj) {
948
949    if ($(window).width() < 768) {
950        obj.on('init', function (event, slick) {
951            obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
952            obj.addClass("slider-init");
953            correctLazyloadInSlider(obj);
954        });
955
956        obj.slick({
957            arrows: false,
958            slidesToShow: 3,
959            slidesToScroll: 3,
960            centerMode: false,
961            variableWidth: true,
962            infinite: false,
963        });
964
965    }
966}
967
968function initCatalogDetailSlider(obj) {
969    obj.on('init', function (event, slick) {
970        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
971        obj.addClass("slider-init");
972        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
973            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
974        }
975
976        correctLazyloadInSlider(obj);
977    });
978
979    var count = 3;
980
981
982    if(obj.attr('data-count'))
983        count = obj.attr('data-count');
984
985
986    obj.slick({
987        slidesToShow: count,
988        slidesToScroll: 1,
989        dots: false,
990        infinite: true,
991        centerPadding: 0,
992        arrows: true,
993        responsive: [{
994                breakpoint: 991,
995                settings: {
996                    slidesToShow: (count - 1)
997                }
998            }, {
999                breakpoint: 575.98,
1000                settings: {
1001                    slidesToShow: 2,
1002                    adaptiveHeight: true
1003                }
1004            },
1005            {
1006                breakpoint: 0,
1007                settings: "unslick"
1008            }
1009        ]
1010    });
1011}
1012
1013function initNewsBigSlider(obj) {
1014    obj.on('init', function (event, slick) {
1015        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1016        obj.addClass("slider-init");
1017        correctLazyloadInSlider(obj);
1018        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1019            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1020        }
1021    });
1022
1023    obj.slick({
1024        slidesToShow: 4,
1025        slidesToScroll: 1,
1026        dots: false,
1027        infinite: true,
1028        centerPadding: 0,
1029        centerMode: false,
1030        adaptiveHeight: false,
1031        focusOnSelect: false,
1032        arrows: true,
1033        responsive: [{
1034                breakpoint: 1200,
1035                settings: {
1036                    slidesToShow: 3,
1037                }
1038            }, {
1039                breakpoint: 991,
1040                settings: {
1041                    slidesToShow: 2
1042                }
1043            }, {
1044                breakpoint: 767,
1045                settings: {
1046                    slidesToShow: 2
1047                }
1048            }, {
1049                breakpoint: 575.98,
1050                settings: {
1051                    slidesToShow: 1,
1052                    adaptiveHeight: true,
1053                }
1054            },
1055            {
1056                breakpoint: 0,
1057                settings: "unslick"
1058            }
1059        ]
1060    });
1061}
1062
1063function initNewsSmallSlider(obj) {
1064    obj.on('init', function (event, slick) {
1065        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1066        obj.addClass("slider-init");
1067        correctLazyloadInSlider(obj);
1068        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1069            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1070        }
1071    });
1072
1073    obj.slick({
1074        slidesToShow: 3,
1075        slidesToScroll: 1,
1076        dots: false,
1077        infinite: true,
1078        centerPadding: 0,
1079        centerMode: false,
1080        adaptiveHeight: false,
1081        focusOnSelect: false,
1082        arrows: true,
1083        responsive: [{
1084                breakpoint: 1200,
1085                settings: {
1086                    slidesToShow: 2,
1087                }
1088            }, {
1089                breakpoint: 767,
1090                settings: {
1091                    slidesToShow: 2
1092                }
1093            }, {
1094                breakpoint: 575.98,
1095                settings: {
1096                    slidesToShow: 1
1097                }
1098            },
1099            {
1100                breakpoint: 0,
1101                settings: "unslick"
1102            }
1103        ]
1104    });
1105}
1106
1107function initAdvantagesBigSlider(obj) {
1108    obj.on('init', function (event, slick) {
1109        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1110        obj.addClass("slider-init");
1111        correctLazyloadInSlider(obj);
1112        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1113            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1114        }
1115    });
1116
1117    obj.slick({
1118        slidesToShow: 3,
1119        slidesToScroll: 1,
1120        dots: false,
1121        infinite: true,
1122        centerPadding: 0,
1123        centerMode: false,
1124        adaptiveHeight: false,
1125        focusOnSelect: false,
1126        responsive: [{
1127            breakpoint: 1200,
1128            settings: {
1129                slidesToShow: 3,
1130            }
1131        }, {
1132            breakpoint: 991,
1133            settings: {
1134                slidesToShow: 2
1135            }
1136        }, {
1137            breakpoint: 575.98,
1138            settings: {
1139                slidesToShow: 1
1140            }
1141        }, {
1142            breakpoint: 0,
1143            settings: "unslick"
1144        }]
1145    });
1146}
1147
1148function initBannersSlider(obj) {
1149    obj.on('init', function (event, slick) {
1150        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1151        obj.addClass("slider-init");
1152        correctLazyloadInSlider(obj);
1153
1154        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1155            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1156        }
1157    });
1158
1159    obj.slick({
1160        slidesToShow: 1,
1161        slidesToScroll: 1,
1162        autoplay: true,
1163        autoplaySpeed: 5000,
1164        dots: false,
1165        infinite: true,
1166        adaptiveHeight: false,
1167        speed: 500,
1168        arrows: false
1169    });
1170}
1171
1172
1173function initAdvantagesBigSlider(obj) {
1174    obj.on('init', function (event, slick) {
1175        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1176        obj.addClass("slider-init");
1177        correctLazyloadInSlider(obj);
1178        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1179            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1180        }
1181    });
1182
1183    obj.slick({
1184        dots: true,
1185        adaptiveHeight: false
1186    });
1187}
1188
1189function initAdvantagesSmallSlider(obj) {
1190    obj.on('init', function (event, slick) {
1191        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1192        obj.addClass("slider-init");
1193        correctLazyloadInSlider(obj);
1194
1195        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1196            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1197        }
1198    });
1199
1200    obj.slick({
1201        dots: true,
1202        slidesToShow: 2,
1203        adaptiveHeight: false,
1204        slidesToScroll: 2,
1205        responsive: [{
1206            breakpoint: 767,
1207            settings: {
1208                slidesToShow: 2,
1209                slidesToScroll: 2
1210            }
1211        }, {
1212            breakpoint: 575.98,
1213            settings: {
1214                slidesToShow: 1,
1215                slidesToScroll: 1
1216            }
1217        }, {
1218            breakpoint: 0,
1219            settings: "unslick"
1220        }]
1221    });
1222}
1223
1224function initOpMiniSlider(obj) {
1225    obj.on('init', function (event, slick) {
1226        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1227        obj.addClass("slider-init");
1228        correctLazyloadInSlider(obj);
1229        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1230            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1231        }
1232    });
1233
1234    obj.slick({
1235        dots: true,
1236        infinite: true,
1237        adaptiveHeight: true,
1238        arrows: true
1239    });
1240}
1241
1242function initOpSlider(obj) {
1243    obj.on('init', function (event, slick) {
1244        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1245        obj.addClass("slider-init");
1246        correctLazyloadInSlider(obj);
1247        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1248            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1249        }
1250    });
1251
1252    var count = obj.attr('data-count');
1253
1254    if (count == 1) {
1255        $('.slider-for', obj).slick({
1256            slidesToShow: 1,
1257            arrows: false,
1258            asNavFor: obj.find('.slider-nav'),
1259            appendArrows: obj.find('.slider-nav-wrap')
1260        });
1261        $('.slider-nav', obj).slick({
1262            slidesToShow: 1,
1263            asNavFor: obj.find('.slider-for'),
1264            centerPadding: 0,
1265            dots: false,
1266            centerMode: true,
1267            focusOnSelect: true,
1268        });
1269        obj.addClass("one-slide");
1270    } else if (count == 2) {
1271        $('.slider-for', obj).slick({
1272            slidesToShow: 1,
1273            slidesToScroll: 1,
1274            speed: 300,
1275            fade: true,
1276            adaptiveHeight: true,
1277            arrows: false,
1278            asNavFor: obj.find('.slider-nav'),
1279            appendArrows: obj.find('.slider-nav-wrap')
1280        });
1281        $('.slider-nav', obj).slick({
1282            slidesToShow: 2,
1283            slidesToScroll: 1,
1284            speed: 300,
1285            asNavFor: obj.find('.slider-for'),
1286            centerPadding: 0,
1287            dots: false,
1288            centerMode: true,
1289            focusOnSelect: true,
1290            responsive: [{
1291                breakpoint: 1200,
1292                settings: {
1293                    slidesToShow: 2
1294                }
1295            }, {
1296                breakpoint: 991,
1297                settings: {
1298                    slidesToShow: 1
1299                }
1300            }, {
1301                breakpoint: 0,
1302                settings: "unslick"
1303            }]
1304        });
1305    } else {
1306        $('.slider-for', obj).slick({
1307            slidesToShow: 1,
1308            slidesToScroll: 1,
1309            speed: 300,
1310            fade: true,
1311            adaptiveHeight: true,
1312            arrows: false,
1313            asNavFor: obj.find('.slider-nav'),
1314            appendArrows: obj.find('.slider-nav-wrap')
1315        });
1316        $('.slider-nav', obj).slick({
1317            slidesToShow: 3,
1318            slidesToScroll: 1,
1319            speed: 300,
1320            asNavFor: obj.find('.slider-for'),
1321            centerPadding: 0,
1322            dots: false,
1323            centerMode: true,
1324            focusOnSelect: true,
1325            responsive: [{
1326                breakpoint: 1200,
1327                settings: {
1328                    slidesToShow: 3
1329                }
1330            }, {
1331                breakpoint: 991,
1332                settings: {
1333                    slidesToShow: 1
1334                }
1335            }, {
1336                breakpoint: 0,
1337                settings: "unslick"
1338            }]
1339        });
1340    }
1341}
1342
1343function initCSlider(obj) {
1344
1345    var sliderCount = 0;
1346
1347    if (obj.attr("data-count"))
1348        sliderCount = parseInt(obj.attr("data-count"));
1349
1350
1351
1352    if (sliderCount > 1) {
1353        obj.on('init', function (event, slick) {
1354            obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1355            obj.addClass("slider-init");
1356
1357            correctLazyloadInSlider(obj);
1358            if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1359                correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1360            }
1361        });
1362
1363        obj.on('beforeChange', function (event, slick, currentSlide, nextSlide) {
1364            correctLazyloadInSlider(obj);
1365        });
1366
1367        obj.addClass("slider-init");
1368
1369        obj.slick({
1370            slidesToShow: 1,
1371            slidesToScroll: 1,
1372            autoplay: false,
1373            dots: true,
1374            infinite: false,
1375            adaptiveHeight: true,
1376            speed: 500,
1377            arrows: true,
1378            responsive: [{
1379                breakpoint: 767.98,
1380                settings: {
1381                    dots: false
1382                }
1383            }]
1384        });
1385    } else {
1386        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1387        obj.addClass("slider-init");
1388    }
1389
1390
1391}
1392
1393function initGallerySlider(obj) {
1394
1395    var count = parseInt(obj.attr("data-slide-visible"));
1396
1397    obj.on('init', function (event, slick) {
1398        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1399        obj.addClass("slider-init");
1400        correctLazyloadInSlider(obj);
1401        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1402            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1403        }
1404    });
1405
1406    obj.slick({
1407        dots: true,
1408        adaptiveHeight: true,
1409        slidesToScroll: count,
1410        slidesToShow: count,
1411        responsive: [{
1412            breakpoint: 767,
1413            settings: {
1414                slidesToShow: 1,
1415                slidesToScroll: 1,
1416            }
1417        }, {
1418            breakpoint: 0,
1419            settings: "unslick"
1420        }]
1421    });
1422}
1423
1424function initPartnersSlider(obj) {
1425
1426    obj.on('init', function (event, slick) {
1427        obj.find(".slick-slide").removeClass('noactive-slide-lazyload');
1428        obj.addClass("slider-init");
1429        correctLazyloadInSlider(obj);
1430        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1431            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1432        }
1433    });
1434
1435
1436    obj.slick({
1437        slidesToShow: 6,
1438        slidesToScroll: 1,
1439        dots: false,
1440        infinite: true,
1441        adaptiveHeight: false,
1442        speed: 500,
1443        arrows: true,
1444        responsive: [{
1445            breakpoint: 1200,
1446            settings: {
1447                slidesToShow: 4,
1448            }
1449        }, {
1450            breakpoint: 767,
1451            settings: {
1452                slidesToShow: 1,
1453            }
1454        }, {
1455            breakpoint: 0,
1456            settings: "unslick"
1457        }]
1458    });
1459}
1460
1461
1462function setHeightForFirstSlider() {
1463
1464    if ($(window).width() >= 768 || ($(window).width() < 768 && $(".wrap-first-slider").attr("data-full-height") == "Y")) {
1465
1466        var height1 = 0,
1467            height2 = 0,
1468            sizeSlides = $('div.first-slider div.first-block').length;
1469
1470
1471        $('div.first-slider div.first-block').each(
1472            function (index) {
1473
1474
1475                if ($(this).outerHeight() > height2) {
1476                    height1 = $(this).height();
1477                    height2 = $(this).outerHeight();
1478                }
1479
1480
1481                if (sizeSlides == index + 1) {
1482
1483                    if (sizeSlides > 1)
1484                        $('div.first-slider div.first-block-container').css("height", height1);
1485
1486                    if ($(".wrap-first-slider").attr("data-full-height") == "Y") {
1487                        if ($(window).height() > $(".wrap-first-slider").height())
1488                            $(".wrap-first-slider").find(".slick-track").css("height", $(window).height() +
1489                                "px");
1490                    }
1491
1492                    if (($(window).width() < 768 && $(".wrap-first-slider").attr("data-full-height") == "Y")) {
1493                        if ($(window).height() > $(".wrap-first-slider").height())
1494                            $(".wrap-first-slider").find(".slick-track").css("height", $(window).height() +
1495                                "px");
1496                    }
1497
1498                    if ($('div.first-slider div.first-block').find(".videoBG").length > 0) {
1499                        $($('div.first-slider div.first-block').find(".videoBG")).each(
1500                            function (index) {
1501                                correctSizeVideoBg($(this));
1502                            }
1503                        );
1504                    }
1505
1506                }
1507
1508            }
1509        );
1510
1511    }
1512
1513}
1514
1515function initFSlider(obj, size) {
1516    var adaptiveMob = ($(window).width() < 768 && $(".wrap-first-slider").attr("data-full-height") == "Y") ? false : true,
1517        sizeSlides = $('div.first-slider div.first-block').length,
1518        params = {};
1519
1520    if (size == "lg") {
1521        params = {
1522            dots: false,
1523            infinite: true,
1524            adaptiveHeight: false,
1525            speed: 500,
1526            pauseOnFocus: false,
1527            pauseOnHover: false
1528        };
1529    } else if (size == "xs") {
1530        params = {
1531            dots: false,
1532            infinite: true,
1533            adaptiveHeight: false,
1534            speed: 500,
1535            pauseOnFocus: false,
1536            pauseOnHover: false,
1537            responsive: [{
1538
1539                    breakpoint: 767,
1540                    settings: {
1541                        adaptiveHeight: adaptiveMob,
1542
1543                    }
1544
1545                },
1546                {
1547
1548                    breakpoint: 0,
1549                    settings: "unslick"
1550
1551                }
1552            ]
1553        };
1554    }
1555
1556    obj.on('init', function (event, slick) {
1557        obj.find(".first-block").removeClass('noactive-slide-lazyload');
1558        setHeightForFirstSlider();
1559
1560    });
1561
1562
1563    if ($(".wrap-first-slider").attr("data-autoslide") == "Y") {
1564        params["autoplaySpeed"] = $(".wrap-first-slider").attr("data-autoslide-time");
1565        params["autoplay"] = true;
1566    }
1567
1568    obj.slick(params);
1569
1570}
1571
1572function initSlider(obj) {
1573    var speed = 0,
1574        params = {
1575            autoplay: false,
1576            autoplaySpeed: 0,
1577            slidesToShow: 1,
1578            slidesToScroll: 1,
1579            infinite: true,
1580            dots: true,
1581            infinite: true,
1582            adaptiveHeight: false,
1583            speed: 500,
1584            arrows: true,
1585            responsive: [{
1586                breakpoint: 991,
1587                settings: {
1588                    adaptiveHeight: true
1589                }
1590            }, {
1591                breakpoint: 767,
1592                settings: {
1593                    dots: false
1594                }
1595            }, {
1596                breakpoint: 0,
1597                settings: "unslick"
1598            }]
1599        };
1600
1601    if (typeof (obj.attr("data-scroll-speed")) != 'undefined')
1602        speed = +(obj.attr("data-scroll-speed"));
1603
1604
1605    if (obj.attr("data-count") == "1")
1606        params["dots"] = false;
1607
1608    params["autoplay"] = false;
1609    params["autoplaySpeed"] = 0;
1610
1611    if (speed > 0) {
1612        params["autoplay"] = true;
1613        params["autoplaySpeed"] = speed * 1000;
1614    }
1615
1616    obj.on('init', function (event, slick) {
1617        obj.find(".block-slider-item").removeClass('noactive-slide-lazyload');
1618        obj.addClass("slider-init");
1619        correctLazyloadInSlider(obj);
1620        if (obj.parents(".parent-video-bg").find(".videoBG").length > 0) {
1621            correctSizeVideoBg(obj.parents(".parent-video-bg").find(".videoBG"));
1622        }
1623    });
1624
1625    obj.slick(params);
1626}
1627
1628
1629
1630var contentSidePosTop = 0,
1631    contentSidePosBot = 0,
1632    contentSidePosBot = 0,
1633    currentPosTop = 0,
1634    currentPosBot = 0,
1635    headerHeight = 0;
1636
1637
1638function setParamsScrollSide() {
1639    contentSideHeight = $(".parent-fixedSrollBlock").outerHeight(true);
1640    menuSideHeight = $(".selector-fixedSrollBlock-real-height").outerHeight(true);
1641    contentSidePosTop = $(".parent-fixedSrollBlock").offset().top;
1642    contentSidePosBot = contentSidePosTop + contentSideHeight;
1643    currentPosTop = $(document).scrollTop() + headerHeight;
1644    currentPosBot = currentPosTop + menuSideHeight;
1645}
1646
1647
1648function setPositionScrollSide() {
1649
1650    setParamsScrollSide();
1651
1652
1653    if (contentSideHeight > menuSideHeight && !$(".selector-fixedSrollBlock").hasClass('fixed-finish')) {
1654
1655        if (currentPosTop >= contentSidePosTop && currentPosBot <= contentSidePosBot) {
1656            $(".selector-fixedSrollBlock").removeClass('fixed-stop fixed-start');
1657            $(".selector-fixedSrollBlock").addClass('fixed-move');
1658        } else if (currentPosBot >= contentSidePosBot) {
1659            $(".selector-fixedSrollBlock").removeClass('fixed-move fixed-start');
1660            $(".selector-fixedSrollBlock").addClass('fixed-stop');
1661        } else {
1662            $(".selector-fixedSrollBlock").removeClass('fixed-move fixed-stop');
1663            $(".selector-fixedSrollBlock").addClass('fixed-start');
1664        }
1665    } else {
1666        $(".selector-fixedSrollBlock").removeClass('fixed-move fixed-stop');
1667        $(".selector-fixedSrollBlock").addClass('fixed-start fixed-finish');
1668    }
1669}
1670
1671
1672function setHeaderHeight() {
1673    if ($(".fix-board").length > 0)
1674        headerHeight = 69;
1675}
1676
1677function setStartParamsScrollSide() {
1678    $(".selector-fixedSrollBlock").css({
1679        "width": $(".wrapperWidthFixedSrollBlock").width() + "px",
1680        "top": headerHeight + "px"
1681    });
1682}
1683
1684function scrollSideInit() {
1685
1686    if ($(".parent-fixedSrollBlock").length && $(window).width() > 1023) {
1687        setStartParamsScrollSide();
1688        setPositionScrollSide();
1689
1690        $(window).scroll(
1691            function () {
1692                if ($(".parent-fixedSrollBlock").length)
1693                    setPositionScrollSide();
1694            }
1695        );
1696    }
1697
1698}
1699
1700
1701function initblueimp() {
1702    setTimeout(function () {
1703        $("body").append('<div class="blueimp-gallery blueimp-gallery-controls" id="blueimp-gallery">' +
1704            '<div class="slides"></div>' +
1705            '<h3 class="title bold"></h3>' +
1706            '<a class="prev"></a>' +
1707            '<a class="next"></a>' +
1708            '<a class="close"></a>' +
1709            '</div>');
1710    }, 2000);
1711}
1712
1713
1714$(document).ready(function () {
1715    initblueimp();
1716    setHeaderHeight();
1717    scrollSideInit();
1718    correctColsHead();
1719
1720});
1721
1722function correctColsHead() {
1723    if ($(".correct-cols-head").length > 0) {
1724        var cols = "",
1725            selector = "";
1726
1727        $(".correct-cols-head").each(function (index) {
1728            cols = $(this).attr("data-head-cols");
1729            selector = $(this).attr("data-head-target");
1730
1731            $("." + selector).addClass(cols);
1732        });
1733    }
1734}
1735
1736
1737function markProductAddBasket(id) {
1738    arStatusBasketPhoenix = {};
1739    setInfoBasket("add2Basket");
1740}
1741
1742function markProductDelayBasket(id, action) {
1743    if (action == 'active')
1744        $('.add2delay[data-item=' + id + ']').addClass('active');
1745
1746    if (action == 'delete')
1747        $('.add2delay[data-item=' + id + ']').removeClass('active');
1748
1749
1750    arStatusBasketPhoenix = {};
1751    setInfoBasket();
1752}
1753
1754
1755function markProductCompareBasket(id, action) {
1756    if (action == 'active')
1757        $('.add2compare[data-item=' + id + ']').addClass('active');
1758
1759    if (action == 'delete')
1760        $('.add2compare[data-item=' + id + ']').removeClass('active');
1761
1762    arStatusBasketPhoenix = {};
1763    setInfoBasket();
1764}
1765
1766
1767function delParamURL(url, param) {
1768    var a = url.split('?');
1769    var re = new RegExp('(\\?|&)' + param + '=[^&]+', 'g');
1770
1771    if (url == "undefined")
1772        url = "";
1773
1774    url = ('?' + a[1]).replace(re, '');
1775    url = url.replace(/^&|\?/, '');
1776
1777    if (url == "undefined")
1778        url = "";
1779
1780    var dlm = (url == '') ? '' : '?';
1781
1782    return a[0] + dlm + url;
1783}
1784
1785function addParam2URL(param, value) {
1786    var url = window.location.href;
1787
1788    if (history.replaceState) {
1789        var baseUrl = delParamURL(url, param);
1790        baseUrl += (baseUrl.split('?')[1] ? '&' : '?') + param + "=" + value;
1791        history.replaceState(null, null, baseUrl);
1792    } else {
1793        console.warn('History API don`t support');
1794    }
1795}
1796
1797
1798function deleteProduct(id, params) {
1799
1800    params = params || null;
1801
1802    showProcessLoad();
1803
1804    if (params !== null) {
1805        var productsCount = $("input#products_count"),
1806            delayedCount = $("input#delayed_count");
1807
1808        if (params.action == "product" && productsCount)
1809            addParam2URL("url-tab", "products");
1810
1811        else if (params.action == "delayed" && delayedCount)
1812            addParam2URL("url-tab", "delayed");
1813
1814        else {
1815            addParam2URL("url-tab", "-1");
1816        }
1817
1818    }
1819
1820    $.ajax({
1821        url: '/bitrix/tools/concept.phoenix/ajax/basket/delete_product_basket.php',
1822        method: 'POST',
1823        data: {
1824            site_id: $("input.site_id").val(),
1825            id: id
1826        },
1827        success: function (data) {
1828
1829            closeProcessLoad();
1830
1831            if (data.OK == "Y") {
1832                arStatusBasketPhoenix = {};
1833                setInfoBasket();
1834            }
1835        }
1836    });
1837}
1838
1839function clearBasket() {
1840    showProcessLoad();
1841    $.ajax({
1842        url: '/bitrix/tools/concept.phoenix/ajax/basket/clear_basket.php',
1843        method: 'POST',
1844        data: {
1845            site_id: $("input.site_id").val()
1846        },
1847        success: function (data) {
1848            closeProcessLoad();
1849            closeCart();
1850            arStatusBasketPhoenix = {};
1851            setInfoBasket();
1852        }
1853    });
1854}
1855
1856$(document).on("click", ".basket-item-actions-remove", function () {
1857    arStatusBasketPhoenix = {};
1858    setInfoBasket();
1859});
1860
1861$(document).on("click", ".clear-cart", function () {
1862
1863    clearBasket();
1864    arStatusBasketPhoenix = {};
1865    setInfoBasket();
1866});
1867
1868
1869function setCountBasket(count, classValue, classParent) {
1870    count = count || 0;
1871
1872    if (count)
1873        $(classParent).addClass('active');
1874
1875
1876    else {
1877        $(classParent).removeClass('active');
1878    }
1879
1880
1881    $(classValue).text(count);
1882
1883}
1884
1885function setCountMiniBasket(count) {
1886    count = count || 0;
1887
1888    if (count)
1889        $(".open-cart").removeClass('cart-empty').addClass('no-empty');
1890
1891
1892
1893    else {
1894        $(".open-cart").removeClass('no-empty').addClass('cart-empty');
1895    }
1896
1897
1898    $(".open-cart span.count").text(count);
1899
1900}
1901
1902
1903function updateBasket(params) {
1904
1905    /*if($("input#shop-mode").val()!="Y")
1906        return false;*/
1907
1908    basketPoolQuantity = new BasketPoolQuantity();
1909
1910    if (params.type_mode == "fly") {
1911        $.post(
1912            '/bitrix/tools/concept.phoenix/ajax/basket/' + params.path, {
1913                site_id: $("input.site_id").val()
1914            },
1915            function (html) {
1916                $(params.selector).html(html);
1917                basketPoolQuantity = new BasketPoolQuantity();
1918            }
1919        );
1920    } else if (params.type_mode == "page") {
1921        var productsCount = 0,
1922            delayed_count = 0;
1923
1924
1925        function updateBasketProductsInfo() {
1926
1927            if ($("#products_count").length > 0)
1928                productsCount = parseInt($("#products_count").val());
1929
1930            if ($("#delayed_count").length > 0)
1931                delayed_count = parseInt($("#delayed_count").val());
1932
1933
1934            if (productsCount > 0)
1935                $(".clear-basket-node-control").removeClass("d-none");
1936
1937
1938            else {
1939                $(".clear-basket-node-control").addClass("d-none");
1940            }
1941
1942            if (productsCount > 0 || delayed_count > 0) {
1943                $(".basket-style.page .cart-advantage").removeClass('hidden');
1944                $(".basket-page-header-btn").removeClass('d-none');
1945            } else {
1946                $(".basket-style.page .cart-advantage").addClass('hidden')
1947            }
1948
1949
1950            if ($("input.basketOrder").length > 0) {
1951                if (productsCount > 0)
1952                    $(".basketOrder-body").removeClass('d-none');
1953                else {
1954                    $(".basketOrder-body").addClass('d-none');
1955                }
1956            }
1957
1958            if (productsCount <= 0 && delayed_count <= 0) {
1959                $(".basket-page-header-btn").addClass('d-none');
1960                $(".clear-basket-node-control").addClass('d-none');
1961
1962                if ($("input.basketOrder").length > 0)
1963                    $(".basketOrder-side").addClass('d-none');
1964
1965            }
1966
1967            closeProcessLoad();
1968
1969            if (params.firstLoad != "Y") {
1970                if ($("input.basketOrder").length > 0 && (productsCount > 0 || delayed_count > 0))
1971                    BX.Sale.OrderAjaxComponent.sendRequest("refreshOrderAjax", "noRedirect");
1972            }
1973
1974        }
1975
1976        if (params.firstLoad != "Y") {
1977
1978            showProcessLoad();
1979            $.post(
1980                "/bitrix/tools/concept.phoenix/ajax/basket/" + params.path, {
1981                    "site_id": $("input.site_id").val(),
1982                    "ajax_content": "products"
1983                },
1984                function (html) {
1985
1986                    $(".body-basket-ajax-left").html(html);
1987
1988
1989                    basketPoolQuantity = new BasketPoolQuantity();
1990
1991
1992                    updateBasketProductsInfo();
1993
1994
1995
1996
1997                    $.post(
1998                        "/bitrix/tools/concept.phoenix/ajax/basket/" + params.path, {
1999                            "site_id": $("input.site_id").val(),
2000                            "ajax_content": "side"
2001                        },
2002                        function (html) {
2003
2004                            $(".body-basket-ajax-right").html(html);
2005
2006                            scrollSideInit();
2007                            closeProcessLoad();
2008
2009                        }
2010                    );
2011
2012                }
2013            );
2014
2015        } else {
2016
2017            updateBasketProductsInfo();
2018        }
2019
2020    }
2021
2022
2023}
2024
2025function setInfoBasket(param) {
2026
2027
2028    /*if($("input#shop-mode").val()!="Y")
2029        return false;*/
2030
2031    param = param || "";
2032
2033    if ($("input#basketPage").length > 0)
2034        showProcessLoad();
2035
2036    $.ajax({
2037        url: '/bitrix/tools/concept.phoenix/ajax/basket/get_ajax_basket.php',
2038        method: 'POST',
2039        data: {
2040            iblockID: $("input#catalogIblockID").val(),
2041            site_id: $("input.site_id").val()
2042        },
2043        success: function (data) {
2044
2045            arStatusBasketPhoenix = data;
2046            setItemButtonStatus(arStatusBasketPhoenix);
2047            setCountMiniBasket(arStatusBasketPhoenix.BASKET_COUNT);
2048            setCountBasket(arStatusBasketPhoenix.BASKET_COUNT, '.count-basket', '.count-basket-items-parent');
2049            setCountBasket(arStatusBasketPhoenix.DELAY_COUNT, '.count-delay', '.count-delay-parent');
2050            setCountBasket(arStatusBasketPhoenix.COMPARE_COUNT, '.count-compare', '.count-compare-parent');
2051
2052
2053            var optBasket = {};
2054
2055            if ($("input#basketPage").length > 0) {
2056                optBasket = {
2057                    "type_mode": "page",
2058                    "path": "get_basket_items.php",
2059                    "selector": ".body-basket-ajax",
2060                };
2061            } else {
2062                optBasket = {
2063                    "type_mode": "fly",
2064                    "path": "get_fly_basket.php",
2065                    "selector": ".body-fly-basket-ajax",
2066                };
2067            }
2068
2069            if (param == "firstLoad")
2070                optBasket["firstLoad"] = "Y";
2071
2072            updateBasket(optBasket);
2073
2074            if (
2075                param == "add2Basket" &&
2076                $("input#showBasketAfterFirstAdd").val() == "Y" &&
2077                arStatusBasketPhoenix.BASKET_COUNT == 1 &&
2078                $("input#basketPage").val() != "basket_page" &&
2079                $(window).width() > 767
2080            ) {
2081                openCart();
2082            }
2083
2084            if (arStatusBasketPhoenix.BASKET_COUNT == 0 && param != "firstLoad")
2085                closeCart();
2086        }
2087    });
2088}
2089
2090function setItemButtonStatus(data, parent, inBasket, inDelay, inCompare) {
2091
2092    if (inBasket || inDelay || inCompare) {
2093        parent = parent || '';
2094
2095        if (parent.length > 0)
2096            parent = "#" + parent;
2097
2098        $(parent + ' .add2basket').parents('.catalog-item').removeClass('in-cart');
2099        $(parent + ' .add2delay').removeClass('active');
2100        $(parent + ' .add2compare').removeClass('active');
2101
2102        if (inBasket)
2103            $(parent + ' .add2basket[data-item=' + data + ']').parents('.catalog-item').addClass('in-cart');
2104
2105
2106        if (inDelay)
2107            $(parent + ' .add2delay[data-item=' + data + ']').addClass('active');
2108
2109
2110        if (inCompare)
2111            $(parent + ' .add2compare[data-item=' + data + ']').addClass('active');
2112
2113
2114    } else {
2115        $('.add2basket').parents('.catalog-item').removeClass('in-cart');
2116        $('.add2delay').removeClass('active');
2117        $('.add2compare').removeClass('active');
2118        $('.common-btn-basket-style').removeClass('added');
2119
2120
2121        if (data.BASKET) {
2122            for (var i in data.BASKET) {
2123                var id = data.BASKET[i];
2124                if (typeof id === 'number' || typeof id === 'string') {
2125                    $('.add2basket[data-item=' + id + ']').parents('.catalog-item').addClass('in-cart');
2126                    $('.common-btn-basket-style[data-item=' + id + ']').addClass('added');
2127                }
2128            }
2129        }
2130
2131        if (data.DELAY) {
2132            for (var i in data.DELAY) {
2133                var id = data.DELAY[i];
2134                if (typeof id === 'number' || typeof id === 'string') {
2135                    $('.add2delay[data-item=' + id + ']').addClass('active');
2136                }
2137            }
2138        }
2139
2140        if (data.COMPARE) {
2141            for (var i in data.COMPARE) {
2142                var id = data.COMPARE[i];
2143                if (typeof id === 'number' || typeof id === 'string') {
2144                    $('.add2compare[data-item=' + id + ']').addClass('active');
2145                }
2146            }
2147        }
2148    }
2149}
2150
2151
2152$(document).ready(function () {
2153
2154    if (device.ios())
2155        $('div.block.parallax-attachment').removeClass('parallax-attachment');
2156
2157
2158    if ($('div.first-slider.slider-lg').length > 0)
2159        initFSlider($('div.first-slider.slider-lg'), "lg");
2160
2161    if ($('div.first-slider.slider-xs').length > 0)
2162        initFSlider($('div.first-slider.slider-xs'), "xs");
2163
2164    if ($("form.timer_form").length > 0) {
2165        $("form.timer_form").each(function (index) {
2166            timerCookie($(this));
2167        });
2168    }
2169
2170    if ($(window).width() > 1024) {
2171        $('.services').find('.service-item').hover(function () {
2172            var element_height = $(this).find('.service-element').height();
2173            var element_bot_height = $(this).find('.bot-wrap').height();
2174            var need_height = element_height - element_bot_height;
2175            $(this).css({
2176                'height': need_height + 'px'
2177            });
2178        }, function () {
2179            $(this).css({
2180                'height': 'auto'
2181            });
2182        });
2183    } else {
2184        $('.services').find('.service-item').hover(function () {
2185            $(this).css({
2186                'height': 'auto'
2187            });
2188        });
2189    }
2190
2191    if ($("div.expired-page").length)
2192        $("div.expired-page").height($(document).height());
2193
2194    if ($("div.error-404").length) {
2195        $("html").addClass('height-100');
2196        $("div.error-404").height($(document).height());
2197    }
2198
2199
2200    if ($(window).width() > 1199) {
2201        $(document).on({
2202                mouseenter: fun
2202ction () {
2203                    var th = $(this);
2204                    $.data(this, 'timer', setTimeout($.proxy(function () {
2205                        $(th).parents(".parent-show-board-contact-js").find('.list-contacts').stop(true,
2206                            true).addClass('open');
2207                    }, this), 300));
2208                },
2209
2210                mouseleave: function () {
2211                    clearTimeout($.data(this, 'timer'));
2212                },
2213            },
2214            ".show-board-contact-js"
2215        );
2216
2217        $(document).on({
2218                mouseleave: function () {
2219                    $(this).removeClass('open');
2220                },
2221            },
2222            "header .list-contacts"
2223        );
2224
2225
2226        $('nav.main-menu > li.parent.view_1').hover(function () {
2227
2228            var th = $(this);
2229
2230            jQuery.data(this, 'timer', setTimeout(jQuery.proxy(function () {
2231
2232                if (th.find("ul.child").length > 0) {
2233                    $('ul.child', this).stop(true, true).addClass("show-open");
2234                    menuOffset(this);
2235                    if ($('ul.child', this).width() < th.width())
2236                        $('ul.child', this).css('width', th.width());
2237                }
2238
2239                if (th.hasClass('catalog-view-flat')) {
2240
2241                    th.find(".wrapper-catalog-menu-board").addClass('on');
2242                    setTimeout(function () {
2243                        th.find(".wrapper-catalog-menu-board").addClass('active');
2244                        $('.lazyload').Lazy(paramsLazy);
2245                    }, 100);
2246
2247                }
2248
2249
2250            }, this), 350));
2251
2252
2253        }, function () {
2254            var th = $(this);
2255
2256            clearTimeout(jQuery.data(this, 'timer'));
2257
2258            if (th.find("ul.child").length > 0)
2259                $('ul.child', this).stop(true, true).removeClass("show-open");
2260
2261            if (th.hasClass('catalog-view-flat')) {
2262                th.find(".wrapper-catalog-menu-board").removeClass('active');
2263                setTimeout(function () {
2264                    th.find(".wrapper-catalog-menu-board").removeClass('on');
2265                }, 100);
2266            }
2267
2268            $('.lazyload').Lazy(paramsLazy);
2269
2270        });
2271
2272        $('nav.main-menu > li.parent.view_2').hover(function () {
2273
2274            var th = $(this);
2275
2276            menuLvls4Selected(th);
2277
2278            jQuery.data(this, 'timer', setTimeout(jQuery.proxy(function () {
2279
2280                th.find(".dropdown-menu-view-2").addClass('on');
2281                setTimeout(function () {
2282                    th.find(".dropdown-menu-view-2").addClass('active');
2283                    $('.lazyload').Lazy(paramsLazy);
2284                }, 100);
2285
2286
2287            }, this), 200));
2288
2289
2290        }, function () {
2291            var th = $(this);
2292
2293            clearTimeout(jQuery.data(this, 'timer'));
2294
2295            th.find(".dropdown-menu-view-2").removeClass('active');
2296            setTimeout(function () {
2297                th.find(".dropdown-menu-view-2").removeClass('on');
2298            }, 100);
2299
2300
2301        });
2302
2303
2304
2305        $('nav.main-menu ul.child > li.parent2').hover(function () {
2306            jQuery.data(this, 'timer', setTimeout(jQuery.proxy(function () {
2307                $('ul.child2', this).stop(true, true).addClass("show-open");
2308                menuOffset(this);
2309            }, this), 100));
2310        }, function () {
2311            clearTimeout(jQuery.data(this, 'timer'));
2312            $('ul.child2', this).stop(true, true).removeClass("show-open");
2313        });
2314    }
2315
2316
2317    $('body').append(
2318        '<div class="modalArea modalAreaEmployee"></div><div class="modalArea modalAreaDetail"></div><div class="modalArea modalAreaVideo"></div><div class="modalArea modalAreaForm"></div><div class="modalArea modalAreaWindow"></div><div class="modalArea modalAreaAgreement"></div>'
2319    );
2320
2321    $.datetimepicker.setLocale('ru');
2322    $('form.form .date').datetimepicker({
2323        timepicker: false,
2324        format: 'd/m/Y',
2325        scrollMonth: false,
2326        scrollInput: false,
2327        dayOfWeekStart: 1
2328    });
2329    if ($(window).width() < 767) {
2330        var anim_callmob_in = setTimeout(function () {
2331            $("#callphone-mob .callphone-desc").show().addClass('active');
2332            clearTimeout(anim_callmob_in);
2333        }, 5000);
2334        var anim_callmob_out = setTimeout(function () {
2335            $("#callphone-mob .callphone-desc").removeClass('active');
2336            clearTimeout(anim_callmob_out);
2337        }, 12000);
2338        var anim_callmob_out2 = setTimeout(function () {
2339            $("#callphone-mob .callphone-desc").hide();
2340            clearTimeout(anim_callmob_out2);
2341        }, 12500);
2342
2343    }
2344
2345    if ($(window).width() > 767) {
2346        $(window).enllax();
2347
2348        new WOW().init();
2349        var wow = new WOW({
2350            boxClass: 'parent-animate',
2351            animateClass: 'animated',
2352            offset: 0,
2353            mobile: true,
2354            live: true,
2355            callback: function (box) {
2356                var sec = 0;
2357                if ($(box).attr("data-delay"))
2358                    sec = parseFloat($(box).attr("data-delay")) * 1000;
2359
2360                $("div.child-animate", box).each(function () {
2361                    var elem = $(this);
2362                    setTimeout(function () {
2363                        elem.removeClass("opacity-zero").addClass("animated fadeIn");
2364                    }, sec);
2365                    sec += 500;
2366                });
2367            },
2368            scrollContainer: null
2369        });
2370        wow.init();
2371    }
2372
2373    $('[data-toggle="tooltip"]').tooltip({
2374        html: true
2375    });
2376
2377    $('[data-toggle="filter-tooltip"]').tooltip({
2378        html: true,
2379        container: ".bx-filter-section"
2380    });
2381
2382    $('[data-toggle="sku-tooltip"]').tooltip({
2383        html: true
2384    });
2385
2386    $('[data-toggle="prop-tooltip"]').tooltip({
2387        html: true
2388    });
2389
2390    if ($(window).width() > 767) {
2391        setTimeout(function () {
2392            $('div.wrap-scroll-down').addClass('active');
2393        }, 3000);
2394    }
2395
2396
2397
2398    var url = location.href;
2399    url = url.split("#");
2400
2401    if (typeof (url[1]) != "undefined" && url[1].length > 0 && url[1].length < 20) {
2402        var urlRes = url[1];
2403
2404        if (url[1].indexOf('?') !== -1) {
2405            url = url[1].split("?");
2406            urlRes = url[0];
2407        }
2408
2409        if ($("#" + urlRes).length > 0)
2410            scrollToBlock("#" + urlRes, false);
2411    }
2412});
2413
2414$(document).on("click", "div.switcher-wrap div.switcher-title", function () {
2415    var block = $(this).parents("div.switcher-wrap");
2416    if (!block.hasClass("active")) {
2417        $("div.switcher-content", block).slideDown(200, function () {
2418            block.addClass("active");
2419        });
2420    } else {
2421        $("div.switcher-content", block).slideUp(200, function () {
2422            block.removeClass("active");
2423        });
2424    }
2425});
2426
2427function correctSizeVideoBg(obj) {
2428
2429    var height = obj.parents('.parent-video-bg').outerHeight();
2430    var videoThis = obj.find(".video-bg-display");
2431    var width = $(window).width();
2432    var video_w = 0;
2433    var video_h = 0;
2434    var add = 4;
2435
2436    if (width / height < 16 / 9) {
2437        video_w = height * 16 / 9 + add;
2438        video_h = height + add;
2439    } else {
2440        video_w = width + add;
2441        video_h = width * 9 / 16 + add;
2442    }
2443
2444    videoThis.width(video_w).height(video_h);
2445    videoThis.addClass('active');
2446}
2447
2448
2449
2450function generateVideoBG(container) {
2451    if ($(window).width() >= 1200 || ($(window).width() >= 768 && $(window).width() < 1200 && !device.android() && !device.ios())) {
2452        var videoBG = $(".videoBG", container),
2453            iframeType = videoBG.attr("data-type"),
2454            srcMP4 = videoBG.attr("data-srcMP4"),
2455            srcWEBM = videoBG.attr("data-srcWEBM"),
2456            srcOGG = videoBG.attr("data-srcOGG"),
2457            srcYB = videoBG.attr("data-srcYB"),
2458            html = "";
2459
2460
2461
2462        if (iframeType == "file") {
2463            if (videoBG.children('video').length <= 0) {
2464                if (srcMP4)
2465                    html += '<source src="' + srcMP4 + '" type="video/mp4">';
2466
2467                if (srcWEBM)
2468                    html += '<source src="' + srcWEBM + '" type="video/webm">';
2469
2470                if (srcOGG)
2471                    html += '<source src="' + srcOGG + '" type="video/ogg">';
2472
2473
2474                html = '<video class="video-bg-display" autoplay="autoplay" loop="loop" preload="auto" muted="muted">' + html + '</video>';
2475            }
2476        } else if (iframeType == "iframe") {
2477
2478            if (videoBG.children('iframe').length <= 0) {
2479                if (srcYB)
2480                    html += '<iframe src="' + srcYB + '" class="video-bg-display" allowfullscreen="" frameborder="0" height="100%" width="100%"></iframe>';
2481            }
2482        }
2483
2484        if (html)
2485            videoBG.prepend(html);
2486
2487        correctSizeVideoBg(videoBG);
2488
2489    }
2490}
2491
2492function updateMainMenu(menu) {
2493
2494    if (menu.length > 0) {
2495        menu.removeClass('full');
2496        menu.find('li.lvl1').removeClass('visible');
2497        menu.parents(".wrap-main-menu").removeClass('ready');
2498        var totalWidth = menu.parents("td.wrapper-menu").width();
2499
2500        if ($(document).width() > 767) {
2501            var visible = 0;
2502            var size = menu.find('li.lvl1').length;
2503
2504            menu.find('li.lvl1').each(function (index) {
2505
2506                if (visible > 4) {
2507                    menu.addClass('full');
2508                }
2509
2510                if (totalWidth > ($(this).width())) {
2511                    totalWidth = totalWidth - $(this).width();
2512
2513                    $(this).addClass('visible');
2514                    visible++;
2515
2516                    if (size == (index + 1))
2517                        menu.parents(".wrap-main-menu").addClass('ready');
2518                } else {
2519                    menu.parents(".wrap-main-menu").addClass('ready');
2520                    return false;
2521                }
2522            });
2523        }
2524    }
2525}
2526
2527$(document).ready(function () {
2528    updateMainMenu($('nav.main-menu'));
2529});
2530
2531
2532
2533$(window).on("load", function () {
2534    setInfoBasket("firstLoad");
2535
2536    if ($(".hide-adv").length > 0) {
2537        setTimeout(function () {
2538            $.post(
2539                "/bitrix/tools/concept.phoenix/ajax/hide_adv.php", {
2540                    "check": "Y",
2541                    "USER_ID": $(".hide-adv").attr("data-user")
2542                },
2543                function (data) {
2544                    if (data.OK == "Y") {
2545                        $("body").append('<script type="text/javascript">
vendor: 287 bytes, line 2545
2545 (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(
254554591493
vendor: 76 bytes, line 2545
2545, "init", { clickmap:false, trackLinks:false, accurateTrackBounce:false }); 
2545</script> <noscript><div><img src="https://mc.yandex.ru/watch/54591493" style="position:absolute; left:-9999px;" alt="" /></div></noscript><script>ym(54591493, "reachGoal", "hide_phoenix");</script>');
2546                    }
2547                },
2548                "json"
2549            );
2550
2551        }, 20000);
2552    }
2553
2554});
2555
2556
2557
2558$(window).scroll(function () {
2559
2560    if ($('header').hasClass('fixed')) {
2561        var headerBotPos = $('header').outerHeight(true) + 150;
2562
2563        if ($(window).scrollTop() >= headerBotPos) {
2564            $('header').addClass('top');
2565            setTimeout(function () {
2566                $('header').addClass('on');
2567            }, 100);
2568        } else {
2569            $('header').removeClass('top');
2570            setTimeout(function () {
2571                $('header').removeClass('on');
2572            }, 50);
2573        }
2574    }
2575
2576    var top = $(document).scrollTop();
2577    var height = $('header').height();
2578
2579    if (top >= height)
2580        $('a.up').addClass('on');
2581    else {
2582        $('a.up').removeClass('on');
2583    }
2584
2585
2586
2587});
2588
2589
2590
2591
2592var windowWidth = $(window).width();
2593
2594$(window).resize(function () {
2595    phoenixResizeVideo();
2596
2597    if (windowWidth != $(window).width()) {
2598        mobileMenuPositionFooter();
2599        updateMainMenu($('nav.main-menu'));
2600    }
2601});
2602
2603if ($(window).width() < 1199) {
2604    $(document).on("click", "header .open-list-contact", function () {
2605        $("header div.list-contacts").addClass('open');
2606    });
2607    $(document).mouseup(function (e) {
2608        var div = $("header div.list-contacts");
2609        if (!div.is(e.target) && div.has(e.target).length === 0) div.removeClass(
2610            'open');
2611    });
2612
2613    $(document).on("click", "nav.main-menu li.parent.view_1", function () {
2614        var menu = $(this).parents('nav.main-menu');
2615        if (!$(this).children('a').hasClass("open")) {
2616            $('li.parent', menu).find("ul.child").removeClass("show-open").find(
2617                "ul.child2").removeClass("show-open");
2618            $('li.parent > a', menu).removeClass("open");
2619            $(this).find("ul.child").addClass("show-open");
2620            $(this).children('a').addClass("open");
2621            menuOffset(this);
2622            return false;
2623        }
2624    });
2625
2626
2627    $(document).on("click", "nav.main-menu li.parent.view_2", function () {
2628
2629        if (!$(this).children('a').hasClass("open")) {
2630            $(this).children('a').addClass("open");
2631
2632            var th = $(this);
2633
2634            menuLvls4Selected(th);
2635
2636            $('.lazyload').Lazy(paramsLazy);
2637            $(this).find(".dropdown-menu-view-2").addClass('on');
2638            setTimeout(function () {
2639                th.find(".dropdown-menu-view-2").addClass('active');
2640            }, 100);
2641
2642            return false;
2643        }
2644    });
2645    $(document).on("click", "nav.main-menu li.parent2", function () {
2646
2647        var menu = $(this).parents('nav.main-menu');
2648        var menu_list = $("ul.child > li.parent2", menu);
2649
2650
2651
2652        if (!$(this).children('a').hasClass("open")) {
2653
2654            if ($(this).find("ul.child").length > 0) {
2655                menu.find("ul.child2").removeClass("show-open");
2656                $(this).find("ul.child2").addClass("show-open");
2657                menuOffset(this);
2658            }
2659
2660
2661            $("a", menu_list).removeClass("open");
2662            $(this).children('a').addClass("open");
2663
2664
2665            return false;
2666        }
2667    });
2668    $(document).mouseup(function (e) {
2669        var div = $("nav.main-menu");
2670        if (!div.is(e.target) && div.has(e.target).length === 0) {
2671            $('li.parent > a', div).removeClass("open");
2672            $("ul.child", div).removeClass("show-open");
2673            $('li.parent2 > a', div).removeClass("open");
2674            $("ul.child2", div).removeClass("show-open");
2675
2676            if ($("li.parent", div).hasClass('catalog-view-flat')) {
2677                $("li.parent", div).find(".wrapper-catalog-menu-board").removeClass('active');
2678                setTimeout(function () {
2679                    $("li.parent", div).find(".wrapper-catalog-menu-board").removeClass('on');
2680                }, 100);
2681
2682            }
2683        }
2684    });
2685}
2686
2687
2688
2689$(document).on("click", ".universal-arrows-mini .arrow-prev", function () {
2690    $(this).parents(".universal-parent-slider").find('.universal-slider').slick("slickPrev");
2691});
2692$(document).on("click", ".universal-arrows-mini .arrow-next", function () {
2693    $(this).parents('.universal-parent-slider').find('.universal-slider').slick("slickNext");
2694});
2695
2696$(document).on("click", ".cart-show", function () {
2697
2698    if ($(this).hasClass('cart-empty'))
2699        return false;
2700
2701    openCart();
2702});
2703
2704$(document).on("click", ".cart-close", function () {
2705    closeCart();
2706});
2707
2708$(document).on("keypress", "input.count-val", function (e) {
2709    e = e || event;
2710
2711    if (e.ctrlKey || e.altKey || e.metaKey) return;
2712
2713    var chr = getChar(e);
2714
2715    if (chr == null) return false;
2716});
2717
2718
2719$(document).on('click', 'ul.switcher-tab li:not(.active)', function () {
2720    $(this).addClass('active').siblings().removeClass('active').closest(
2721        'div.switcher').find('div.switcher-wrap').removeClass('active').eq($(this)
2722        .index()).addClass('active');
2723});
2724
2725$(document).on('click', 'a.map-show', function () {
2726    $(this).parent().hide();
2727    $(this).parents('div.map-block').find(".map-height").show();
2728});
2729
2730
2731
2732$(document).on("click", ".bl-txt .wr-tabs li:not(.active)", function () {
2733
2734    var img = $(this).closest('.wr-tabs').find('img').eq($(this).index());
2735
2736    $(this).addClass('active').siblings().removeClass('active').closest(
2737        '.wr-tabs').find('img').removeClass(
2738        'active').eq($(this).index()).addClass('active');
2739
2740    if (img.attr("data-src"))
2741        $(img).Lazy();
2742
2743
2744});
2745
2746$(document).on("click", ".bl-txt .wr-tabs .title-mobile", function () {
2747
2748    var block = $(this).parent(".item");
2749
2750    if (!$(this).hasClass("active")) {
2751
2752        if ($("img", block).attr("data-src")) {
2753            var _this = $(this);
2754
2755            $("img", block).Lazy({
2756                afterLoad: function (element) {
2757                    $("img", block).removeAttr('style');
2758
2759                    _this.addClass("active");
2760
2761                    $("img", block).slideDown(200, function () {
2762                        $(this).addClass("active");
2763                    });
2764
2765
2766                }
2767            });
2768        } else {
2769            $(this).addClass("active");
2770            $("img", block).slideDown(200, function () {
2771                $(this).addClass("active");
2772            });
2773        }
2774
2775    } else {
2776        $(this).removeClass("active");
2777        $("img", block).slideUp(200, function () {
2778            $(this).removeClass("active");
2779        });
2780    }
2781
2782});
2783
2784$(document).on("click", "div.wrap-scroll-down .scroll-down", function () {
2785    var s_b = $(this).parents('div.parent-scroll-down').next(),
2786        heightOut = 70,
2787        destination = null;
2788
2789    while (s_b.hasClass('hidden-lg')) {
2790        s_b = s_b.next();
2791    }
2792
2793    destination = $(s_b).offset().top - heightOut;
2794
2795    $("html:not(:animated),body:not(:animated)").animate({
2796        scrollTop: destination
2797    }, 700);
2798});
2799
2800$(document).on('click', '.open-main-menu', function () {
2801    if ($(window).width() <= 767) {
2802        $('div.open-menu-mobile').addClass('show-open');
2803        setTimeout(function () {
2804            $('div.open-menu-mobile.show-open').addClass('on');
2805        }, 50);
2806        setTimeout(function () {
2807            $('a.close-menu.mobile').addClass('on');
2808        }, 1000);
2809        setTimeout(function () {
2810            mobileMenuPositionFooter();
2811        }, 100);
2812        $('body').addClass('modal-open');
2813    } else {
2814        $('div.open-menu').addClass('show-open');
2815        setTimeout(function () {
2816            openMenuFooterPos();
2817        }, 100);
2818        setTimeout(function () {
2819            $('div.open-menu').addClass('on');
2820        }, 150);
2821        $('div.wrapper').addClass('blur');
2822        $('div.menu-shadow').addClass('show-open');
2823        $('body').addClass('modal-open');
2824        $(".open-cart").addClass('off');
2825    }
2826
2827    $('.lazyload').Lazy(paramsLazy);
2828});
2829
2830$(document).on('click', '.close-menu', function () {
2831    if ($(window).width() <= 767) {
2832        $('div.open-menu-mobile').removeClass('on');
2833        $('body').removeClass('modal-open');
2834        $('a.close-menu.mobile').removeClass('on');
2835        setTimeout(function () {
2836            $('div.open-menu-mobile.show-open').removeClass('show-open');
2837        }, 500);
2838    } else {
2839        $('div.wrapper').removeClass('blur');
2840        $('div.open-menu').removeClass('show-open');
2841        $('div.menu-shadow').removeClass('show-open');
2842        $('body').removeClass('modal-open');
2843        $(".open-cart").removeClass('off');
2844    }
2845});
2846
2847$(document).on('click', '.close-menu-js.open', function () {
2848
2849    $('div.wrapper').removeClass('blur');
2850    $('div.open-menu').removeClass('show-open');
2851    $('div.menu-shadow').removeClass('show-open');
2852    $('body').removeClass('modal-open');
2853    $(".open-cart").removeClass('off');
2854   
2855});
2856
2857$(document).on('click', '.close-menu-mobile-js', function () {
2858
2859    $('div.open-menu-mobile').removeClass('on');
2860    $('body').removeClass('modal-open');
2861    $('a.close-menu.mobile').removeClass('on');
2862    setTimeout(function () {
2863        $('div.open-menu-mobile.show-open').removeClass('show-open');
2864    }, 500);
2865   
2866});
2867
2868
2869$(document).on("click", "div.list-menu li.parent", function () {
2870    var menu = $(this).parents('div.list-menu');
2871    var Li = $(this);
2872    menu.find('ul.child2').slideUp(200);
2873    if (!$(this).children('a').hasClass("open")) {
2874        $('li.parent > a', menu).removeClass("open");
2875        $("ul.child2", Li).slideDown(200);
2876        $(this).children('a').addClass("open");
2877        return false;
2878    } else if ($(this).children('a').hasClass("empty-link")) {
2879        menu.find('ul.child2').slideUp(200);
2880        $('li.parent > a', menu).removeClass("open");
2881    }
2882});
2883
2884$(document).on('click', 'a.open-mobile-list', function () {
2885    $('ul.mobile-menu-list').removeClass('show-open');
2886    $("ul.mobile-menu-list[data-menu-list='" + $(this).attr('data-menu-list') +
2887        "']").addClass('show-open');
2888    mobileMenuPositionFooter();
2889});
2890
2891$(document).on('click', 'div.open-menu-mobile div.open-list-contact', function () {
2892    var btn = $(this);
2893
2894    btn.parents('div.contacts').find('div.list-contacts').addClass('open');
2895    btn.hide();
2896
2897    if (btn.parents('div.contacts').find(".iframe-map-area").length > 0)
2898        generateMaps(btn.parents('div.contacts').find(".contact-wrap.map"));
2899
2900    mobileMenuPositionFooter();
2901});
2902
2903$(document).on("click", ".scroll-after", function () {
2904    var elementClick = $(this).attr("href");
2905
2906    setTimeout(function () {
2907        scrollToBlock(elementClick, $(this));
2908    }, 200);
2909    return false;
2910});
2911
2912$(document).on("click", "a.scroll", function () {
2913    var elementClick = $(this).attr("href");
2914    scrollToBlock(elementClick, $(this));
2915
2916    if ($(this).hasClass('from-modal')) {
2917        $('div.no-click-block').removeClass('on');
2918        $('body').removeClass('modal-open');
2919        $('div.wrapper').removeClass('blur');
2920        if (device.ios()) {
2921            window.scrollTo(0, cur_pos);
2922            $("body").removeClass("modal-ios");
2923        }
2924
2925        if ($(this).parents(".container-close-from-scroll").length > 0)
2926            $(this).parents(".container-close-from-scroll").addClass('d-none');
2927
2928    }
2929
2930    return false;
2931});
2932
2933$(document).on('click', 'div.tab-child:not(.active)', function () {
2934    $(this).addClass('active').siblings().removeClass('active').closest(
2935        'div.tab-parent').find('div.tab-content').removeClass('active').eq($(this)
2936        .index()).addClass('active');
2937});
2938
2939$(document).on('click', '.select-list-choose', function () {
2940    $(this).parents('.form-select').addClass('open');
2941});
2942
2943$(document).on('click', '.ar-down', function () {
2944    if ($(this).parents('.form-select').hasClass('open')) $(this).parents(
2945        '.form-select').removeClass('open');
2946    else {
2947        $(this).parents('.form-select').addClass('open');
2948    }
2949});
2950
2951$(document).on('click', '.form-select .name', function () {
2952    $(this).parents('.form-select').find('.select-list-choose').removeClass(
2953        'first').find(".list-area").text($(this).text());
2954    $(this).parents('.form-select').removeClass('open');
2955});
2956
2957
2958function callModal(arParams) {
2959    showProcessLoad();
2960    
2961    $.post("/bitrix/tools/concept.phoenix/ajax/popup/" + arParams.path, {
2962            arParams: arParams,
2963            platform: arParams["platform"],
2964            site_id: $("input.site_id").val()
2965        },
2966        function (html) {
2967            closeProcessLoad();
2968
2969            startBlurWrapperContainer();
2970
2971            var $area = $('div.' + arParams.container);
2972            $area.html(html);
2973
2974            (function(){
2975                var $captcha = $area.find('#captcha-container, .smart-captcha').first();
2976                var $loader  = $area.find('.load-captcha').first();
2977                if(!$captcha.length || !$loader.length) return;
2978
2979                $loader.show(); 
2980
2981                var elapsed = 0;
2982                var iv = setInterval(function(){
2983                    var hasToken = $captcha.find('input[name="smart-token"]').length && $.trim($captcha.find('input[name="smart-token"]').val()).length;
2984                    var hasIframe = $captcha.find('iframe').length;
2985                    if(hasToken || hasIframe) {
2986                        clearInterval(iv);
2987                        $loader.fadeOut(50);
2988                        return;
2989                    }
2990                    elapsed += 100;
2991                    if(elapsed >= 5000) { 
2992                        clearInterval(iv);
2993                        $loader.fadeOut(50);
2994                    }
2995                }, 100);
2996            })();
2997
2998            setTimeout(function () {
2999                $area.find('.phoenix-modal').addClass('active');
3000            }, 100);
3001
3002
3003            if (arParams.from_modal == "Y") {
3004                $area.find('.close-modal').addClass('remove-blur-container').attr('data-blur-container', arParams.element_id);
3005            }
3006
3007            if (arParams.container == 'modalAreaForm') {
3008                $area.find("form.form .date").datetimepicker({
3009                    timepicker: false,
3010                    format: 'd/m/Y',
3011                    scrollMonth: false,
3012                    scrollInput: false,
3013                    dayOfWeekStart: 1
3014                });
3015            }
3016
3017            if (typeof (arParams.header) != "undefined") {
3018                if (arParams.header.length > 0) {
3019                    $area.find('input[name="header"]').val(arParams.header);
3020                }
3021            }
3022
3023        });
3024}
3025
3026$(document).on('click', '.call-modal', function () {
3027    var arParams = {},
3028        element_id = $(this).attr("data-call-modal"),
3029		platform = $(this).attr("data-video-platform"),
3030        all_id = $(this).attr("data-all-id");
3031
3032
3033    if ($(this).hasClass('callform')) {
3034        arParams["path"] = "formmodal.php";
3035        arParams["element_id"] = element_id.replace("form", "");
3036        arParams["container"] = "modalAreaForm";
3037    }
3038
3039    else if ($(this).hasClass('callvideo')) {
3040        arParams["path"] = "videomodal.php";
3041        arParams["element_id"] = element_id;
3042        arParams["container"] = "modalAreaVideo";
3043		arParams["platform"] = platform;
3044    }
3045
3046    else if ($(this).hasClass('callmodal')) {
3047        arParams["path"] = "windowmodal.php";
3048        arParams["element_id"] = element_id.replace("modal", "");
3049        arParams["container"] = "modalAreaWindow";
3050    }
3051    else if ($(this).hasClass('callagreement')) {
3052        arParams["path"] = "agreemodal.php";
3053        arParams["element_id"] = element_id.replace("agreement", "");
3054        arParams["container"] = "modalAreaAgreement";
3055    }
3056    else if ($(this).hasClass('callemployee')) {
3057        arParams["path"] = "employee.php";
3058        arParams["element_id"] = element_id;
3059        arParams["container"] = "modalAreaEmployee";
3060        if(all_id)
3061            arParams["all_id"] = all_id;
3062    }
3063
3064
3065    if ($(this).hasClass("element-item")) {
3066        arParams["element_item_id"] = $(this).attr("data-element-item-id");
3067        arParams["element_item_type"] = $(this).attr("data-element-item-type");
3068        arParams["element_item_name"] = $(this).attr("data-element-item-name");
3069        arParams["element_item_price"] = $(this).attr("data-element-item-price");
3070    }
3071
3072
3073
3074    if (typeof ($(this).attr("data-header")) != "undefined") {
3075        if ($(this).attr("data-header").length > 0) {
3076            arParams["header"] = $(this).attr("data-header");
3077        }
3078
3079    }
3080
3081
3082    arParams["from_modal"] = "N";
3083
3084    if ($(this).hasClass("from-modal")) {
3085        arParams["from_modal"] = "Y";
3086        $(this).parents(".blur-container").addClass('blur-active').attr("data-blur-container", arParams["element_id"]);
3087    }
3088
3089
3090    callModal(arParams);
3091
3092});
3093
3094function resetCustomDynamicInputs(){
3095    for (var i = 1; i <= 3; i++) {
3096        $('#custom-dynamic-input-'+i).val('');
3097    }
3098}
3099
3100
3101$(document).on('click', '.close-modal', function () {
3102    $('div.modalAreaForm form.form .date').datetimepicker('destroy');
3103
3104    if ($(this).hasClass('remove-blur-container')) {
3105        $(".blur-container[data-blur-container='" + $(this).attr("data-blur-container") + "']").removeClass('blur-active');
3106    } else {
3107        stopBlurWrapperContainer();
3108    }
3109
3110
3111    if ($(this).hasClass('wind-close'))
3112        $(this).parents("div.shadow-modal-wind-contact").removeClass('on');
3113    else {
3114        $(this).parents("div.modalArea").children().remove();
3115    }
3116
3117    resetCustomDynamicInputs();
3118    
3119});
3120
3121$(document).on('click', '.open_modal_contacts', function () {
3122    $('div.shadow-modal-wind-contact').addClass('on');
3123
3124    startBlurWrapperContainer();
3125});
3126
3127$(document).on('click', '.tab-menu', function () {
3128    $(this).parents('.tab-control').find('.tab-menu').removeClass('active');
3129    $(this).parents('.tab-control').find('.tabb-content').removeClass('active');
3130    $(this).addClass('active');
3131    $('.tabb-content[data-tab="' + $(this).attr("data-tab") + '"]').addClass(
3132        'active');
3133});
3134
3135
3136$(document).on('click', '.show-hidden', function () {
3137
3138    if ($(this).parent().hasClass('off')) {
3139        $(this).parents('.show-hidden-parent').find('.show-hidden-child').addClass(
3140            'hidden');
3141        $(this).parent().removeClass('off');
3142    } else {
3143        $(this).parents('.show-hidden-parent').find('.show-hidden-child').removeClass(
3144            'hidden');
3145        $(this).parent().addClass('off');
3146    }
3147});
3148
3149$(document).on("click", ".click-slide-show", function () {
3150    var block = $(this).parent(".parent-slide-show");
3151    if (!$(this).hasClass("active")) {
3152        $(this).addClass("active");
3153        $(".content-slide-show", block).slideDown(200, function () {
3154            $(this).addClass("active");
3155        });
3156    } else {
3157        $(this).removeClass("active");
3158        $(".content-slide-show", block).slideUp(200, function () {
3159            $(this).removeClass("active");
3160        });
3161    }
3162});
3163
3164Share = {
3165    vkontakte: function (purl, ptitle, pimg, text) {
3166        url = 'http://vkontakte.ru/share.php?';
3167        url += 'url=' + encodeURIComponent(purl);
3168        url += '&title=' + encodeURIComponent(ptitle);
3169        url += '&description=' + encodeURIComponent(text);
3170        url += '&image=' + encodeURIComponent(pimg);
3171        url += '&noparse=true';
3172        Share.popup(url);
3173    },
3174    facebook: function (purl, ptitle, pimg, text) {
3175        url = 'https://www.facebook.com/sharer/sharer.php?';
3176        url += '&title=' + encodeURIComponent(ptitle);
3177        url += '&description=' + encodeURIComponent(text);
3178        url += '&u=' + encodeURIComponent(purl);
3179        url += '&picture=' + encodeURIComponent(pimg);
3180        Share.popup(url);
3181    },
3182    twitter: function (purl, ptitle) {
3183        url = 'http://twitter.com/share?';
3184        url += 'text=' + encodeURIComponent(ptitle);
3185        url += '&url=' + encodeURIComponent(purl);
3186        url += '&counturl=' + encodeURIComponent(purl);
3187        Share.popup(url);
3188    },
3189
3190    ok: function (purl, ptitle) {
3191        url = 'https://connect.ok.ru/dk?st.cmd=WidgetSharePreview';
3192        url += '&st.title=' + encodeURIComponent(ptitle);
3193        url += '&st.shareUrl=' + encodeURIComponent(purl);
3194        Share.popup(url);
3195    },
3196
3197    mailRu: function (purl, ptitle) {
3198        url = 'https://connect.mail.ru/share?';
3199        url += '&url=' + encodeURIComponent(purl);
3200        url += '&title=' + encodeURIComponent(ptitle);
3201        Share.popup(url);
3202    },
3203
3204    wtsApp: function (purl, ptitle) {
3205        url = 'https://api.whatsapp.com/send?';
3206        url += '&text=' + encodeURIComponent(ptitle) + ' ' + encodeURIComponent(purl);
3207        Share.popup(url);
3208    },
3209
3210    telegram: function (purl, ptitle) {
3211        url = 'https://telegram.me/share/url?';
3212        url += 'url=' + encodeURIComponent(purl);
3213        url += '&text=' + encodeURIComponent(ptitle);
3214        Share.popup(url);
3215    },
3216    skype: function (purl) {
3217        url = 'https://web.skype.com/share?';
3218        url += 'url=' + encodeURIComponent(purl);
3219        Share.popup(url);
3220    },
3221    gPlus: function (purl) {
3222        url = 'https://plus.google.com/share?';
3223        url += 'url=' + encodeURIComponent(purl);
3224        Share.popup(url);
3225    },
3226
3227    reddit: function (purl) {
3228        url = 'https://www.reddit.com/submit?';
3229        url += 'url=' + encodeURIComponent(purl);
3230        Share.popup(url);
3231    },
3232
3233    popup: function (url) {
3234        window.open(url, '', 'toolbar=0,status=0,width=626,height=436');
3235    }
3236};
3237
3238$(document).on('click', '.click-show-pic', function () {
3239    $(this).parents('.parent-show-pic').find('.item-show-pic').removeClass(
3240        'active');
3241    $(this).parents('.parent-show-pic').find('.click-show-pic').removeClass(
3242        'active');
3243    $(this).parents('.parent-show-pic').find('.item-show-pic[data-show-pic="' +
3244        $(this).attr("data-show-pic") + '"]').addClass('active');
3245    $(this).addClass('active');
3246});
3247
3248$(document).on('click', '.scroll-next', function () {
3249    var dist = $(this).parents('.scroll-next-parent').next().offset().top - 40;
3250    if ($("header").hasClass("fixed")) dist -= 70;
3251    $("html:not(:animated),body:not(:animated)").animate({
3252        scrollTop: dist
3253    }, 700);
3254});
3255
3256$(document).on("click", ".phoenix-alert-btn", function () {
3257    $("div.alert-block div.phoenix-alert-btn").addClass("on");
3258    $("div.alert-block div.alert-block-content").addClass("on");
3259});
3260
3261$(document).on("click", "a.alert-close", function () {
3262    $("div.alert-block div.phoenix-alert-btn").removeClass("on");
3263    $("div.alert-block div.alert-block-content").removeClass("on");
3264});
3265
3266
3267
3268var mouseUp = (device.ios()) ? "touchend" : "mouseup";
3269
3270$(document).on(mouseUp, function (e) {
3271
3272    var div = $(".form-select");
3273    if (!div.is(e.target) && div.has(e.target).length === 0)
3274        div.removeClass('open');
3275
3276
3277    var div2 = $(".search-list");
3278    if (!div2.is(e.target) && div2.hasClass("active"))
3279        div2.removeClass('active');
3280
3281
3282    var search_top_js = $(".search-top-js");
3283
3284    if (!search_top_js.is(e.target) && search_top_js.has(e.target).length === 0) {
3285        if (search_top_js.hasClass("active")) {
3286            search_top_js.removeClass('active');
3287            $(".no-click-block").removeClass('on');
3288
3289            if (!$('.open-menu').hasClass('show-open'))
3290                stopBlurWrapperContainer();
3291
3292            if ($('.open-menu').hasClass('show-open'))
3293                $('.open-menu').removeClass('blur-active');
3294
3295            var st = setTimeout(function () {
3296                search_top_js.removeClass('fixed');
3297                clearTimeout(st);
3298            }, 100);
3299
3300            $(".ajax-search-results").hide();
3301        }
3302    }
3303
3304    var bxFilterSearch = $(".bx-filter-popup-result");
3305    if (!bxFilterSearch.is(e.target))
3306        bxFilterSearch.hide();
3307
3308
3309    var selectInputSku = $(".wrapper-select-input");
3310    if (!selectInputSku.is(e.target) && selectInputSku.has(e.target).length === 0)
3311        selectInputSku.removeClass('open');
3312
3313    var checboxReq = $(".check-require.has-error");
3314    if (!checboxReq.is(e.target))
3315        checboxReq.removeClass('has-error');
3316
3317
3318    var selectReq = $(".form-select.has-error");
3319    if (!selectReq.is(e.target))
3320        selectReq.removeClass('has-error');
3321
3322});
3323
3324
3325
3326
3327$(document).on('change', ".cart-choose-select", function () {
3328    $(this).parents(".parent-choose-select").find(".inp-show-js").removeClass(
3329        'active');
3330    $(this).parents(".parent-choose-select").find(
3331        ".inp-show-js[data-choose-select='" + $(this).attr("data-choose-select") +
3332        "']").addClass('active');
3333});
3334
3335
3336$(document).on("click", ".search-icon-js", function () {
3337    $(this).parents(".search-input-box").find(".search-js").focus();
3338    scrollToBlock($(this).parents(".search-input-box").find(".search-scroll-focus"), '', 40);
3339});
3340
3341$(document).on("click", ".show-search-list", function () {
3342    $(this).parents(".show-search-list-parent").find(".search-list").addClass('active');
3343});
3344
3345
3346
3347
3348
3349
3350function checkInput(input) {
3351    if (input.val().length > 0) {
3352        input.parents('.search-panel-js').find('.hint-area').hide();
3353        input.parents('.search-panel-js').find('.search-btns-box').addClass('before-active');
3354
3355        var timeOut = setTimeout(
3356            function () {
3357                input.parents('.search-panel-js').find('.search-btns-box').addClass('active');
3358                clearTimeout(timeOut);
3359            }, 100);
3360    } else {
3361        input.parents('.search-panel-js').find('.search-btns-box').removeClass('before-active active');
3362        input.parents('.search-panel-js').find('.hint-area').show();
3363    }
3364
3365}
3366$(document).on("keyup", "form.search-form input.search-js",
3367    function () {
3368        checkInput($(this));
3369    }
3370);
3371
3372$('form.search-form input.search-js').focusout(function () {
3373    checkInput($(this));
3374});
3375
3376$(document).on("click", "input.search-scroll-focus", function () {
3377    scrollToBlock($(this), '', 40);
3378});
3379
3380$(document).on("focus", "form.search-form.fix-header input.search-js", function () {
3381    $(this).parents("form.search-form.fix-header").addClass('focus');
3382});
3383
3384$(document).on("focusout", 'form.search-form.fix-header input.search-js', function () {
3385    if ($(this).val().length <= 0)
3386        $(this).parents("form.search-form.fix-header").removeClass('focus');
3387});
3388
3389
3390
3391
3392$(document).on("click", ".open-search-top", function () {
3393    $(".search-top-js").addClass('fixed');
3394
3395    if ($('.open-menu').hasClass('show-open'))
3396        $('.open-menu').addClass('blur-active');
3397
3398    else {
3399        startBlurWrapperContainer();
3400    }
3401
3402    var st = setTimeout(function () {
3403        $(".no-click-block").addClass('on');
3404        $(".search-top-js").addClass('active');
3405        $(".search-top-js").find('input.search-js').focus();
3406        clearTimeout(st);
3407    }, 100);
3408});
3409$(document).on("click", ".close-search-top", function () {
3410    $(this).parents(".search-top-js").removeClass('active');
3411    var th = $(this);
3412    $(".no-click-block").removeClass('on');
3413
3414    if ($('.open-menu').hasClass('show-open'))
3415        $('.open-menu').removeClass('blur-active');
3416    else {
3417        stopBlurWrapperContainer();
3418    }
3419
3420    var st = setTimeout(function () {
3421        th.parents(".search-top-js").removeClass('fixed');
3422        clearTimeout(st);
3423    }, 100);
3424    $(".ajax-search-results").hide();
3425});
3426
3427
3428
3429
3430
3431function showContentCtTab(th, param, blockID) {
3432    if (typeof param != 'undefined') {
3433
3434        if (param.length > 0) {
3435            th = th || "";
3436
3437            if (th.length > 0) {
3438                th.parents(".parent-tab").find(".tab-section").removeClass('active');
3439                th.addClass('active');
3440
3441                th.parents(".parent-tab").find(".tab-element").removeClass('active');
3442                th.parents(".parent-tab").find(".tab-element." + th.attr("data-tab")).addClass('active');
3443            } else {
3444                var head = "";
3445
3446
3447                if (param.length > 0) {
3448                    blockID = blockID || "";
3449
3450                    head = $("#" + blockID).find(".parent-tab");
3451                } else {
3452                    head = $(".parent-tab");
3453                }
3454
3455                head.find(".tab-section").removeClass('active');
3456                head.find(".tab-section[data-tab=" + param + "]").addClass('active');
3457
3458                head.find(".tab-element").removeClass('active');
3459                head.find(".tab-element." + param).addClass('active');
3460            }
3461
3462            $('.lazyload').Lazy(paramsLazy);
3463
3464        }
3465    }
3466}
3467$(document).on("click", ".tab-section",
3468    function () {
3469        showContentCtTab($(this), $(this).attr("data-tab"));
3470    }
3471);
3472
3473function getUrlParams() {
3474    var params = window
3475        .location
3476        .search
3477        .replace('?', '')
3478        .split('&')
3479        .reduce(
3480            function (p, e) {
3481                var a = e.split('=');
3482                p[a[0]] = a[1];
3483                return p;
3484            }, {}
3485        );
3486
3487    return params;
3488}
3489
3490$(document).ready(function () {
3491
3492    var params = getUrlParams();
3493
3494    showContentCtTab("", params["ct_tab"], params["ct_tab_blockID"]);
3495
3496});
3497
3498(function (window) {
3499
3500
3501    window.JCCatalogElement = function (arParams) {
3502        this.element = arParams;
3503        this.nodes = {};
3504        this.currentElement = {};
3505        this.oldElement = {};
3506        this.errorCode = 0;
3507        this.firstLoad = true;
3508        this.selectedValues = {};
3509
3510        if (typeof arParams === 'object') {
3511            this.initConfig();
3512
3513            switch (this.element.PRODUCT_TYPE) {
3514                case 0:
3515                case 1:
3516                case 2:
3517                    this.initProductData();
3518                    break;
3519                case 3:
3520                    this.initOffersData();
3521                    break;
3522                default:
3523                    this.errorCode = -1;
3524            }
3525        }
3526
3527        if (this.errorCode === 0)
3528            BX.ready(BX.delegate(this.init, this));
3529
3530    };
3531
3532    window.JCCatalogElement.prototype = {
3533        initConfig: function () {
3534            this.nodes.obProduct = BX(this.element.VISUAL.ID);
3535
3536
3537            if (!this.nodes.obProduct)
3538                this.errorCode = -1;
3539
3540
3541            this.element.PRODUCT_TYPE = parseInt(this.element.PRODUCT_TYPE, 10);
3542
3543            this.nodes.obBigSlider = BX(this.element.VISUAL.BIG_SLIDER);
3544            this.nodes.obBasketActions = BX(this.element.VISUAL.BASKET_ACTIONS);
3545            this.nodes.obPreorderBtn = BX(this.element.VISUAL.PREORDER);
3546            this.nodes.obWrPreorderBtn = this.nodes.obPreorderBtn.parentNode;
3547            this.nodes.obPreorderBtn && BX.bind(this.nodes.obPreorderBtn, 'click', BX.proxy(this.preOrder, this));
3548
3549            this.nodes.obMeasure = BX(this.element.VISUAL.QUANTITY_MEASURE);
3550
3551            this.nodes.obPreviewText = BX(this.element.VISUAL.PREVIEW_TEXT);
3552
3553            this.nodes.obWrSubscribe = BX(this.element.VISUAL.SUBSCRIBE);
3554
3555
3556            this.nodes.obBlockChars = this.nodes.obProduct.querySelector("#chars");
3557            this.nodes.obSkuChars = BX(this.element.VISUAL.SKU_CHARS);
3558
3559            if (this.nodes.obBasketActions) {
3560                this.nodes.obWrBuyBtn = this.nodes.obBasketActions.querySelector('.wr-btn-fast-order');
3561                this.nodes.obWrBasketBtn = this.nodes.obBasketActions.querySelector('.wr-btn-basket');
3562
3563                /*if (this.element.SHOW_BUY_BTN === "Y") {*/
3564                    this.nodes.obFastOrder = BX(this.element.VISUAL.FAST_ORDER);
3565                    this.nodes.obFastOrder && BX.bind(this.nodes.obFastOrder, 'click', BX.proxy(this.fastOrder, this));
3566                /*}*/
3567
3568                /*if (this.element.SHOW_BTN_BASKET === "Y") {*/
3569                    this.nodes.obAdd2BasketBtn = BX(this.element.VISUAL.ADD2BASKET);
3570                    this.nodes.obMove2Basket = BX(this.element.VISUAL.MOVE2BASKET);
3571                    this.nodes.obAdd2BasketBtn && BX.bind(this.nodes.obAdd2BasketBtn, 'click', BX.proxy(this.add2Basket, this));
3572                /*}*/
3573            }
3574
3575            this.nodes.obPriceMatrix = BX(this.element.VISUAL.PRICE_MATRIX);
3576
3577            this.nodes.obArticleAvailable = BX(this.element.VISUAL.ARTICLE_AVAILABLE);
3578
3579            if (this.element.VISUAL.CALL_FORM_BETTER_PRICE) {
3580                this.nodes.obCallFormBetterPrice = BX(this.element.VISUAL.CALL_FORM_BETTER_PRICE);
3581                BX.bind(this.nodes.obCallFormBetterPrice, 'click', BX.delegate(this.callFormBetterPrice, this));
3582            }
3583
3584            if (this.element.CONFIG.USE_DELAY === "Y") {
3585                this.nodes.obDelay = BX(this.element.VISUAL.DELAY);
3586                this.nodes.obDelay && BX.bind(this.nodes.obDelay, 'click', BX.proxy(this.add2Delay, this));
3587            }
3588
3589            if (this.element.CONFIG.USE_COMPARE === "Y") {
3590                this.nodes.obCompare = BX(this.element.VISUAL.COMPARE);
3591                this.nodes.obCompare && BX.bind(this.nodes.obCompare, 'click', BX.proxy(this.add2Compare, this));
3592            }
3593
3594
3595            if (this.element.CONFIG.SHOW_PRICE === "Y") {
3596                this.nodes.obPrice = {
3597                    wrapper: null,
3598                    price: null,
3599                    old: null,
3600                    discount: null,
3601                    percent: null,
3602                    total: null
3603                };
3604
3605                this.nodes.obPrice.price = BX(this.element.VISUAL.PRICE);
3606
3607
3608                if (!this.nodes.obPrice.price) {
3609                    this.errorCode = -16;
3610                } else {
3611                    this.nodes.obPrice.total = BX(this.element.VISUAL.PRICE_TOTAL);
3612                    this.nodes.obPrice.old = BX(this.element.VISUAL.OLD_PRICE);
3613                    this.nodes.obPrice.discount = BX(this.element.VISUAL.DISCOUNT_PRICE);
3614                    this.nodes.obPrice.percent = BX(this.element.VISUAL.DISCOUNT_PERCENT);
3615                }
3616
3617            }
3618
3619            if (this.element.CONFIG.SHOW_QUANTITY === "Y") {
3620                this.nodes.obQuantity = BX(this.element.VISUAL.QUANTITY);
3621                this.nodes.quantity = this.nodes.obProduct.querySelector('.quantity-block');
3622
3623                if (this.element.VISUAL.QUANTITY_UP) {
3624                    this.nodes.obQuantityUp = BX(this.element.VISUAL.QUANTITY_UP);
3625                    BX.bind(this.nodes.obQuantityUp, 'click', BX.delegate(this.quantityUp, this));
3626
3627                }
3628
3629                if (this.element.VISUAL.QUANTITY_DOWN) {
3630                    this.nodes.obQuantityDown = BX(this.element.VISUAL.QUANTITY_DOWN);
3631                    BX.bind(this.nodes.obQuantityDown, 'click', BX.delegate(this.quantityDown, this));
3632                }
3633
3634                if (this.nodes.obQuantity)
3635                    BX.bind(this.nodes.obQuantity, 'change', BX.delegate(this.quantityChange, this));
3636
3637
3638                this.element.precisionFactor = Math.pow(10, this.element.CONFIG.PRECISION);
3639            }
3640
3641
3642        },
3643
3644        initProductData: function () {
3645            this.currentElement = this.element;
3646
3647            this.oldElement = this.currentElement;
3648
3649            this.currentElement.MAX_QUANTITY = this.currentElement.QUANTITY_FLOAT ?
3650                parseFloat(this.element.MAX_QUANTITY) :
3651                parseInt(this.element.MAX_QUANTITY, 10);
3652            this.currentElement.STEP_QUANTITY = this.currentElement.QUANTITY_FLOAT ?
3653                parseFloat(this.currentElement.STEP_QUANTITY) :
3654                parseInt(this.currentElement.STEP_QUANTITY, 10);
3655
3656            this.currentElement.MIN_QUANTITY = this.currentElement.ITEM_PRICE_MODE === 'Q' ? parseFloat(this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].MIN_QUANTITY) : this.currentElement.STEP_QUANTITY;
3657
3658            if (this.currentElement.QUANTITY_FLOAT)
3659                this.currentElement.STEP_QUANTITY = Math.round(this.currentElement.STEP_QUANTITY * this.element.precisionFactor) / this.element.precisionFactor;
3660
3661            this.setPrice();
3662            this.setQuantityHtml();
3663            this.btnsControl();
3664
3665            if (this.nodes.obPriceMatrix && this.currentElement.PRICE_MATRIX_RESULT.HTML)
3666                this.setPriceMatrix(this.currentElement.PRICE_MATRIX_RESULT.HTML);
3667        },
3668
3669        setQuantityHtml: function () {
3670            if (this.currentElement.QUANTITY.HTML) {
3671                var productAvailableValue = this.nodes.obProduct.querySelector(".product-available-js");
3672
3673                productAvailableValue.innerHTML = this.currentElement.QUANTITY.HTML;
3674                productAvailableValue.classList.add("active");
3675            }
3676        },
3677
3678        changeDetailUrl: function (ID) {
3679            var arNames = this.nodes.obProduct.querySelectorAll("a.product-name");
3680
3681            if (arNames) {
3682                for (i = 0; i < arNames.length; i++) {
3683                    arNames[i].href = this.currentElement.DETAIL_PAGE_URL;
3684                }
3685            }
3686
3687        },
3688
3689
3690        init: function () {
3691            var i = 0,
3692                j = 0,
3693                treeItems = null;
3694
3695
3696            if (this.errorCode === 0) {
3697
3698                switch (this.element.PRODUCT_TYPE) {
3699                    case 0:
3700                    case 1:
3701                    case 2:
3702
3703                        this.checkQuantityControls();
3704                        getHtmlStoreList(this.currentElement.ID, this.element.STORE, this.currentElement.MEASURE);
3705                        break;
3706
3707                    case 3:
3708
3709                        treeItems = this.nodes.obTree.querySelectorAll('li');
3710
3711                        for (i = 0; i < treeItems.length; i++) {
3712                            BX.bind(treeItems[i], 'click', BX.delegate(this.selectOfferProp, this));
3713                        }
3714
3715
3716                        this.setCurrent();
3717                        break;
3718                }
3719
3720            }
3721        },
3722
3723        getEntities: function (parent, entity, additionalFilter) {
3724            if (!parent || !entity)
3725                return {
3726                    length: 0
3727                };
3728
3729            additionalFilter = additionalFilter || '';
3730
3731            return parent.querySelectorAll(additionalFilter + '[data-entity="' + entity + '"]');
3732        },
3733
3734        initOffersData: function () {
3735
3736            if (this.element.CONFIG.SHOW_OFFERS) {
3737
3738                this.currentElement = this.element.OFFERS[this.element.OFFER_ID_SELECTED];
3739
3740                if (this.element.CONFIG.USE_OID === 'Y')
3741                    this.addParameterToURL("oID", this.currentElement.ID);
3742
3743                this.nodes.obTree = BX(this.element.VISUAL.TREE);
3744
3745
3746
3747                if (!this.nodes.obTree)
3748                    this.errorCode = -256;
3749            } else {
3750                this.errorCode = -1;
3751            }
3752
3753        },
3754
3755        preOrder: function () {
3756            var arParams = {
3757                    path: "formmodal.php",
3758                    element_id: this.element.FORM_PREORDER_ID,
3759                    container: "modalAreaForm",
3760                    element_item_type: "PREORDER",
3761                    element_item_name: this.element.NAME
3762                },
3763                element_id = $(this).attr("data-call-modal"),
3764                header = $(this).attr("data-header");
3765
3766
3767            arParams["element_item_id"] = this.currentElement.ID.toString();
3768            arParams["ARTICLE"] = this.currentElement.ARTICLE;
3769            arParams["PHOTO"] = this.currentElement.PHOTO;
3770
3771
3772            switch (this.element.PRODUCT_TYPE) {
3773                case 1:
3774                case 2:
3775                    arParams["element_item_input"] = this.element.NAME;
3776                    break;
3777                case 3:
3778                    arParams["element_item_offers"] = this.currentElement.TREE_INFO;
3779                    arParams["element_item_input"] = getStringNameItem(this.element.NAME, this.currentElement.TREE_INFO);
3780                    break;
3781
3782                default:
3783                    break;
3784            }
3785
3786
3787            callModal(arParams);
3788        },
3789
3790        callFormBetterPrice: function () {
3791
3792            var arParams = {
3793                    path: "formmodal.php",
3794                    element_id: this.element.FORM_BETTER_PRICE_ID,
3795                    container: "modalAreaForm",
3796                    element_item_type: "BETTER_PRICE",
3797                    element_item_name: this.element.NAME
3798                },
3799                element_id = $(this).attr("data-call-modal"),
3800                header = $(this).attr("data-header");
3801
3802
3803            arParams["element_item_id"] = this.currentElement.ID.toString();
3804            arParams["ARTICLE"] = this.currentElement.ARTICLE;
3805            arParams["PHOTO"] = this.currentElement.PHOTO;
3806
3807            switch (this.element.PRODUCT_TYPE) {
3808                case 1:
3809                case 2:
3810                    arParams["element_item_input"] = this.element.NAME;
3811                    break;
3812                case 3:
3813
3814                    arParams["element_item_offers"] = this.currentElement.TREE_INFO;
3815                    arParams["element_item_input"] = getStringNameItem(this.element.NAME, this.currentElement.TREE_INFO);
3816                    break;
3817
3818                default:
3819                    break;
3820            }
3821
3822
3823            callModal(arParams);
3824
3825        },
3826
3827        fastOrder: function () {
3828            if (!this.currentElement.CAN_BUY)
3829                return;
3830
3831
3832            var productID = '',
3833                value = 1,
3834                productItem = {};
3835
3836
3837            if (this.nodes.obQuantity)
3838                value = this.nodes.obQuantity.value;
3839
3840            productItem = {
3841                "QUANTITY": value,
3842                "PRICE": this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED],
3843                "NAME": this.currentElement.NAME_HTML
3844            };
3845
3846            productItem["PRODUCT_ID"] = this.currentElement.ID.toString();
3847            productItem["ARTICLE"] = this.currentElement.ARTICLE;
3848            productItem["PHOTO"] = this.currentElement.PHOTO;
3849
3850
3851            switch (this.element.PRODUCT_TYPE) {
3852                case 1:
3853                case 2:
3854                    break;
3855                case 3:
3856                    productItem["element_item_offers"] = this.currentElement.TREE_INFO;
3857                    break;
3858
3859                default:
3860                    break;
3861            }
3862
3863            showProcessLoad();
3864
3865            BX.ajax({
3866                method: 'POST',
3867                dataType: 'html',
3868                url: '/bitrix/tools/concept.phoenix/ajax/basket/call_form_fast_order.php',
3869                data: {
3870                    productItem: productItem,
3871                    site_id: $("input.site_id").val()
3872                },
3873                onsuccess: BX.proxy(this.callFormResult, this)
3874            });
3875        },
3876
3877
3878
3879        callFormResult: function (html) {
3880            closeProcessLoad();
3881            startModalMode("div.modalAreaForm");
3882            $('div.modalAreaForm').html(html);
3883            $('div.modalAreaForm form.form .date').datetimepicker({
3884                    timepicker: false,
3885                    format: 'd/m/Y',
3886                    scrollMonth: false,
3887                    scrollInput: false,
3888                    dayOfWeekStart: 1
3889                });
3890        },
3891
3892
3893        add2Delay: function () {
3894            var productID = '',
3895                value = 1;
3896
3897            if (this.nodes.obQuantity)
3898                value = this.nodes.obQuantity.value;
3899
3900
3901            BX.ajax({
3902                method: 'POST',
3903                dataType: 'json',
3904                url: '/bitrix/tools/concept.phoenix/ajax/basket/wishlist.php',
3905                data: {
3906                    product_id: this.currentElement.ID,
3907                    price_id: this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].ID,
3908                    price: this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].PRICE,
3909                    name: this.currentElement.NAME,
3910                    detail_page: this.currentElement.DETAIL_PAGE_URL,
3911                    can_buy: this.currentElement.CAN_BUY,
3912                    quantity: value,
3913                    currency: this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].CURRENCY,
3914                    site_id: $("input.site_id").val()
3915                },
3916                onsuccess: BX.proxy(this.delayResult, this)
3917            });
3918        },
3919
3920        delayResult: function (arResult) {
3921            if (arResult["OK"] == "Y") {
3922                if (this.element.PRODUCT_TYPE == 3) {
3923                    if (arResult["ACTION"] == 'active')
3924                        this.currentElement.IN_DELAY = true;
3925
3926                    if (arResult["ACTION"] == 'delete')
3927                        this.currentElement.IN_DELAY = false;
3928                }
3929
3930                markProductDelayBasket(this.currentElement.ID, arResult["ACTION"]);
3931            } else {
3932                console.log(arResult["OK"]);
3933            }
3934        },
3935
3936        add2Compare: function () {
3937
3938            var checked = false;
3939
3940            if (!BX.hasClass(this.nodes.obCompare, "active"))
3941                checked = true;
3942
3943            var url = checked ? this.element.CONFIG.COMPARE_URL + '?action=ADD_TO_COMPARE_LIST&id=#ID#' : this.element.CONFIG.COMPARE_URL + '?action=DELETE_FROM_COMPARE_LIST&id=#ID#',
3944                compareLink;
3945
3946            if (url) {
3947
3948                compareLink = url.replace('#ID#', this.currentElement.ID);
3949
3950
3951
3952                BX.ajax({
3953                    method: 'POST',
3954                    dataType: checked ? 'json' : 'html',
3955                    url: compareLink + (compareLink.indexOf('?') !== -1 ? '&' : '?') + 'ajax_action=Y',
3956                    onsuccess: checked ?
3957                        BX.proxy(this.compareResult, this) : BX.proxy(this.compareDeleteResult, this)
3958                });
3959            }
3960        },
3961
3962        compareResult: function (arResult) {
3963            /*if (!BX.type.isPlainObject(arResult))
3964                return;
3965
3966            
3967
3968            if (arResult.STATUS === 'OK')
3969            {*/
3970            if (this.element.OFFERS.length > 0)
3971                this.currentElement.IN_COMPARE = true;
3972
3973
3974            markProductCompareBasket(this.currentItemId, 'active');
3975            /*}*/
3976        },
3977
3978        compareDeleteResult: function (arResult) {
3979
3980            if (this.element.OFFERS.length > 0)
3981                this.currentElement.IN_COMPARE = false;
3982
3983
3984            markProductCompareBasket(this.currentItemId, 'delete');
3985
3986        },
3987
3988        add2Basket: function () {
3989
3990            if (!this.currentElement.CAN_BUY)
3991                return;
3992
3993            var productID = '',
3994                value = 1;
3995
3996            if (this.nodes.obQuantity)
3997                value = this.nodes.obQuantity.value;
3998
3999
4000            productItem = {
4001                PRODUCT_ID: this.currentElement.ID,
4002                QUANTITY: value,
4003                PRICE_ID: this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].ID
4004            };
4005
4006            $(this.nodes.obAdd2BasketBtn).addClass("btn-processing");
4007
4008            BX.ajax({
4009                method: 'POST',
4010                dataType: 'json',
4011                url: '/bitrix/tools/concept.phoenix/ajax/basket/add2basket.php',
4012                data: {
4013                    productItem: productItem,
4014                    site_id: $("input.site_id").val()
4015                },
4016                onsuccess: BX.proxy(this.basketResult, this)
4017            });
4018        },
4019
4020        basketResult: function (arResult) {
4021            if (arResult["OK"] == "Y") {
4022                if (this.element.PRODUCT_TYPE === 3)
4023                    this.element.OFFERS[this.element.OFFER_ID_SELECTED].IN_BASKET = true;
4024
4025                markProductAddBasket(this.currentElement.ID);
4026
4027
4028
4029                if (arResult["SCRIPTS"])
4030                    $('body').append(arResult["SCRIPTS"]);
4031            }
4032
4033            $(this.nodes.obAdd2BasketBtn).removeClass("btn-processing");
4034        },
4035
4036        deleteParameterURL: function (url, param) {
4037            var a = url.split('?');
4038            var re = new RegExp('(\\?|&)' + param + '=[^&]+', 'g');
4039
4040            if (url == "undefined")
4041                url = "";
4042
4043            url = ('?' + a[1]).replace(re, '');
4044            url = url.replace(/^&|\?/, '');
4045
4046            if (url == "undefined")
4047                url = "";
4048
4049            var dlm = (url == '') ? '' : '?';
4050            return a[0] + dlm + url;
4051        },
4052
4053        addParameterToURL: function (param, value) {
4054
4055            var url = window.location.href;
4056
4057
4058            if (history.replaceState) {
4059                var baseUrl = this.deleteParameterURL(url, param);
4060                baseUrl += (baseUrl.split('?')[1] ? '&' : '?') + param + "=" + value;
4061                history.replaceState(null, null, baseUrl);
4062            } else {
4063                console.warn('History API don`t support');
4064            }
4065        },
4066
4067        selectOfferProp: function () {
4068            var i = 0,
4069                strTreeValue = '',
4070                arTreeItem = [],
4071                rowItems = null,
4072                target = BX.proxy_context,
4073                smallCardItem;
4074
4075
4076            if (target && target.hasAttribute('data-treevalue')) {
4077                if (BX.hasClass(target, 'active'))
4078                    return;
4079
4080
4081
4082                if (typeof document.activeElement === 'object') {
4083                    document.activeElement.blur();
4084                }
4085
4086
4087
4088                strTreeValue = target.getAttribute('data-treevalue');
4089                arTreeItem = strTreeValue.split('_');
4090
4091                this.searchOfferPropIndex(arTreeItem[0], arTreeItem[1]);
4092
4093
4094                rowItems = BX.findChildren(target.parentNode, {
4095                    tagName: 'li'
4096                }, false);
4097
4098
4099                if (rowItems && rowItems.length) {
4100                    for (i = 0; i < rowItems.length; i++) {
4101                        BX.removeClass(rowItems[i], 'active');
4102                    }
4103                }
4104
4105
4106                BX.addClass(target, 'active');
4107
4108            }
4109        },
4110
4111
4112        searchOfferPropIndex: function (strPropID, strPropValue) {
4113            var strName = '',
4114                arShowValues = false,
4115                arCanBuyValues = [],
4116                allValues = [],
4117                index = -1,
4118                i, j,
4119                arFilter = {},
4120                tmpFilter = [];
4121
4122
4123
4124            for (i = 0; i < this.element.TREE_PROPS.length; i++) {
4125                if (this.element.TREE_PROPS[i].ID === strPropID) {
4126                    index = i;
4127                    break;
4128                }
4129            }
4130
4131            if (index > -1) {
4132                for (i = 0; i < index; i++) {
4133                    strName = 'PROP_' + this.element.TREE_PROPS[i].ID;
4134                    arFilter[strName] = this.selectedValues[strName];
4135                }
4136
4137
4138                strName = 'PROP_' + this.element.TREE_PROPS[index].ID;
4139                arFilter[strName] = strPropValue;
4140
4141
4142
4143                for (i = index + 1; i < this.element.TREE_PROPS.length; i++) {
4144
4145                    strName = 'PROP_' + this.element.TREE_PROPS[i].ID;
4146                    arShowValues = this.getRowValues(arFilter, strName);
4147
4148
4149
4150                    if (!arShowValues)
4151                        break;
4152
4153                    allValues = [];
4154
4155                    if (this.element.CONFIG.SHOW_ABSENT === 'Y') {
4156
4157                        arCanBuyValues = [];
4158                        tmpFilter = [];
4159                        tmpFilter = BX.clone(arFilter, true);
4160
4161                        for (j = 0; j < arShowValues.length; j++) {
4162                            tmpFilter[strName] = arShowValues[j];
4163                            allValues[allValues.length] = arShowValues[j];
4164                            if (this.getCanBuy(tmpFilter))
4165                                arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
4166                        }
4167                    } else {
4168                        arCanBuyValues = arShowValues;
4169                    }
4170
4171
4172
4173
4174                    if (this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arC
4174anBuyValues)) {
4175                        arFilter[strName] = this.selectedValues[strName];
4176
4177                    } else {
4178
4179                        if (this.element.CONFIG.SHOW_ABSENT === 'Y') {
4180                            arFilter[strName] = (arCanBuyValues.length ? arCanBuyValues[0] : allValues[0]);
4181                        } else {
4182                            arFilter[strName] = arCanBuyValues[0];
4183                        }
4184                    }
4185
4186
4187                    this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
4188
4189                }
4190
4191
4192                this.selectedValues = arFilter;
4193
4194
4195                this.changeInfo();
4196
4197            }
4198
4199            if (this.element.CONFIG.USE_OID === 'Y')
4200                this.addParameterToURL("oID", this.currentElement.ID);
4201
4202
4203
4204        },
4205
4206        setCurrent: function () {
4207            var i,
4208                j = 0,
4209                strName = '',
4210                arShowValues = false,
4211                arCanBuyValues = [],
4212                arFilter = {},
4213                tmpFilter = [],
4214                current = this.currentElement.TREE;
4215
4216
4217
4218            for (i = 0; i < this.element.TREE_PROPS.length; i++) {
4219                strName = 'PROP_' + this.element.TREE_PROPS[i].ID;
4220                arShowValues = this.getRowValues(arFilter, strName);
4221
4222
4223                if (!arShowValues)
4224                    break;
4225
4226                if (BX.util.in_array(current[strName], arShowValues)) {
4227                    arFilter[strName] = current[strName];
4228                } else {
4229                    arFilter[strName] = arShowValues[0];
4230                    this.element.OFFER_ID_SELECTED = 0;
4231                }
4232
4233                if (this.element.CONFIG.SHOW_ABSENT === 'Y') {
4234                    arCanBuyValues = [];
4235                    tmpFilter = [];
4236                    tmpFilter = BX.clone(arFilter, true);
4237
4238                    for (j = 0; j < arShowValues.length; j++) {
4239                        tmpFilter[strName] = arShowValues[j];
4240
4241                        if (this.getCanBuy(tmpFilter)) {
4242                            arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
4243                        }
4244                    }
4245                } else {
4246                    arCanBuyValues = arShowValues;
4247                }
4248
4249
4250                this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
4251            }
4252
4253            this.selectedValues = arFilter;
4254
4255            this.changeInfo();
4256        },
4257
4258        getRowValues: function (arFilter, index) {
4259            var arValues = [],
4260                i = 0,
4261                j = 0,
4262                boolSearch = false,
4263                boolOneSearch = true;
4264
4265
4266
4267            if (arFilter.length === 0) {
4268                for (i = 0; i < this.element.OFFERS.length; i++) {
4269                    if (!BX.util.in_array(this.element.OFFERS[i].TREE[index], arValues)) {
4270                        arValues[arValues.length] = this.element.OFFERS[i].TREE[index];
4271
4272                    }
4273                }
4274                boolSearch = true;
4275            } else {
4276                for (i = 0; i < this.element.OFFERS.length; i++) {
4277                    boolOneSearch = true;
4278
4279                    for (j in arFilter) {
4280                        if (arFilter[j] !== this.element.OFFERS[i].TREE[j]) {
4281                            boolOneSearch = false;
4282                            break;
4283                        }
4284                    }
4285
4286                    if (boolOneSearch) {
4287                        if (!BX.util.in_array(this.element.OFFERS[i].TREE[index], arValues)) {
4288                            arValues[arValues.length] = this.element.OFFERS[i].TREE[index];
4289
4290                        }
4291
4292                        boolSearch = true;
4293                    }
4294                }
4295            }
4296
4297
4298
4299            return (boolSearch ? arValues : false);
4300        },
4301
4302        updateRow: function (intNumber, activeId, showId, canBuyId) {
4303
4304            var i = 0,
4305                value = '',
4306                isCurrent = false,
4307                rowItems = null;
4308
4309
4310            var lineContainer = this.nodes.obTree.querySelectorAll('.wrapper-sku-props');
4311
4312
4313            if (intNumber > -1 && intNumber < lineContainer.length) {
4314                rowItems = lineContainer[intNumber].querySelectorAll('li');
4315
4316                for (i = 0; i < rowItems.length; i++) {
4317                    value = rowItems[i].getAttribute('data-onevalue');
4318                    isCurrent = value === activeId;
4319
4320
4321                    if (isCurrent) {
4322                        BX.addClass(rowItems[i], 'active');
4323                    } else {
4324                        BX.removeClass(rowItems[i], 'active');
4325                    }
4326
4327                    if (BX.util.in_array(value, canBuyId)) {
4328                        BX.removeClass(rowItems[i], 'notallowed');
4329                    } else {
4330                        BX.addClass(rowItems[i], 'notallowed');
4331                    }
4332
4333                    rowItems[i].style.display = BX.util.in_array(value, showId) ? '' : 'none';
4334
4335                    if (isCurrent) {
4336                        lineContainer[intNumber].style.display = (value == 0) ? 'none' : '';
4337                    }
4338                }
4339            }
4340        },
4341
4342        changeInfo: function () {
4343            var index = -1,
4344                j = 0,
4345                boolOneSearch = true,
4346                descTitle = null,
4347                rowItems = null;
4348
4349            var i;
4350
4351            for (i = 0; i < this.element.OFFERS.length; i++) {
4352                boolOneSearch = true;
4353
4354                for (j in this.selectedValues) {
4355
4356                    if (this.selectedValues[j] !== this.element.OFFERS[i].TREE[j]) {
4357                        boolOneSearch = false;
4358                        break;
4359                    }
4360
4361                }
4362
4363                if (boolOneSearch) {
4364                    index = i;
4365                    break;
4366                }
4367            }
4368
4369            this.oldElement = this.currentElement;
4370
4371            this.element.OFFER_ID_SELECTED = index;
4372            this.currentElement = this.element.OFFERS[this.element.OFFER_ID_SELECTED];
4373
4374            this.changeCharsBlock();
4375
4376            if (index > -1) {
4377
4378                if (this.nodes.obPriceMatrix && this.currentElement.PRICE_MATRIX_RESULT.HTML)
4379                    this.setPriceMatrix(this.currentElement.PRICE_MATRIX_RESULT.HTML);
4380
4381                this.updateInfoBasketOffer(this.currentElement.ID, this.element.VISUAL.ID);
4382
4383
4384                for (i = 0; i < this.element.OFFERS.length; i++) {
4385                    if (this.element.CONFIG.OFFER_GROUP) {
4386                        if (offerGroupNode = BX(this.element.VISUAL.OFFER_GROUP + this.element.OFFERS[i].ID))
4387                            offerGroupNode.style.display = (i == index ? '' : 'none');
4388
4389                    }
4390                }
4391
4392
4393                $("input.product-" + this.currentElement.ID + "-picture-src-small").val(this.currentElement.MORE_PHOTOS[0].SMALL.SRC);
4394
4395                if (this.element.CONFIG.ZOOM) {
4396                    $(this.nodes.obProduct).find('.zoom-offer').trigger('zoom
4396-offer.destroy');
4397                    initZoomer($(this.nodes.obProduct).find(".zoom-offer"));
4398                }
4399
4400
4401                if (this.currentElement.IN_BASKET == true ||
4402                    this.currentElement.IN_DELAY == true ||
4403                    this.currentElement.IN_COMPARE == true
4404                ) {
4405
4406                    setItemButtonStatus(
4407                        this.currentElement.ID,
4408                        '',
4409                        this.currentElement.IN_BASKET,
4410                        this.currentElement.IN_DELAY,
4411                        this.currentElement.IN_COMPARE
4412                    );
4413
4414
4415                    setItemButtonStatus(this.currentElement.ID, '', 'offer_delay_added');
4416                    setItemButtonStatus(this.currentElement.ID, '', 'compare_added');
4417
4418                } else {
4419                    setItemButtonStatus(arStatusBasketPhoenix);
4420                }
4421            }
4422
4423            this.quantitySet();
4424            this.setPrice();
4425            this.setQuantityHtml();
4426            this.btnsControl();
4427
4428            if (!this.firstLoad) {
4429                this.drawImages(this.currentElement.MORE_PHOTOS);
4430
4431                if (this.element.CONFIG.USE_OID !== 'Y')
4432                    this.changeDetailUrl(this.currentElement.ID);
4433
4434                var previewText = this.nodes.obPreviewText.querySelector('.detail-description');
4435
4436                if (previewText)
4437                    this.changeText(previewText, this.currentElement.PREVIEW_TEXT_HTML);
4438
4439
4440                this.showArticleStoreQuantity();
4441            }
4442
4443            getHtmlStoreList(this.currentElement.ID, this.element.STORE, this.currentElement.MEASURE);
4444
4445            this.firstLoad = false;
4446        },
4447
4448        changeText: function (ob, text) {
4449            if (text.length > 0) {
4450
4451                ob.innerHTML = text;
4452                ob.classList.remove('d-none');
4453                
4454            } else {
4455                ob.classList.add('d-none');
4456                ob.innerHTML = '';
4457            }
4458            },
4459
4460
4461        hideBtns: function () {
4462
4463            if (this.currentElement.SHOW_BUY_BTN === 'Y') {
4464                this.nodes.obWrBuyBtn.classList.add('d-none');
4465                this.nodes.obWrBuyBtn.classList.remove('active');
4466            }
4467
4468
4469            if (this.currentElement.SHOW_BTN_BASKET === 'Y') {
4470                this.nodes.obWrBasketBtn.classList.add('d-none');
4471                this.nodes.obWrBasketBtn.classList.remove('active');
4472            }
4473
4474
4475
4476            this.nodes.obBasketActions.classList.add('d-none');
4477            this.nodes.quantity.classList.add('d-none');
4478            this.nodes.obBasketActions.classList.remove('active');
4479            this.nodes.quantity.classList.remove('active');
4480        },
4481
4482        showBtns: function () {
4483
4484            this.nodes.obBasketActions.classList.remove('d-none');
4485            this.nodes.obBasketActions.classList.add('active');
4486
4487            if (this.currentElement.SHOW_BUY_BTN === 'Y') {
4488                this.nodes.obWrBuyBtn.classList.remove('d-none');
4489                this.nodes.obWrBuyBtn.classList.add('active');
4490            } else {
4491                this.nodes.obWrBuyBtn.classList.add('d-none');
4492                this.nodes.obWrBuyBtn.classList.remove('active');
4493            }
4494
4495            if (this.currentElement.SHOW_BTN_BASKET === 'Y') {
4496                this.nodes.obWrBasketBtn.classList.remove('d-none');
4497                this.nodes.quantity.classList.remove('d-none');
4498                this.nodes.obWrBasketBtn.classList.add('active');
4499                this.nodes.quantity.classList.add('active');
4500            }
4501            else
4502            {
4503                this.nodes.quantity.classList.add('d-none');
4504                this.nodes.quantity.classList.remove('active');
4505            }
4506        },
4507
4508        btnsControl: function () {
4509            var show = false;
4510
4511            if (this.currentElement.SHOWPREORDERBTN || this.currentElement.MODE_ARCHIVE) {
4512                if (this.currentElement.SHOWPREORDERBTN) {
4513                    this.nodes.obWrPreorderBtn.classList.remove('d-none');
4514                    this.nodes.obWrPreorderBtn.classList.add('active');
4515                } else {
4516                    this.nodes.obWrPreorderBtn.classList.add('d-none');
4517                    this.nodes.obWrPreorderBtn.classList.remove('active');
4518                }
4519
4520                
4521            } else {
4522                this.nodes.obWrPreorderBtn.classList.add('d-none');
4523                this.nodes.obWrPreorderBtn.classList.remove('active');
4524
4525                if (this.currentElement.CAN_BUY && this.currentElement.MODE_DISALLOW_ORDER != "Y")
4526                    show = true;
4527            }
4528
4529            if (this.currentElement.SUBSCRIBE === "Y" && this.currentElement.MAX_QUANTITY <= 0) {
4530                this.nodes.obWrSubscribe.classList.add("active");
4531
4532                if(this.nodes.obWrSubscribe.firstElementChild)
4533                    this.nodes.obWrSubscribe.firstElementChild.style.display = "";
4534
4535            } else {
4536                this.nodes.obWrSubscribe.classList.add("d-none");
4537            }
4538
4539            if (this.currentElement.SHOW_BTNS === 'Y' && this.currentElement.CAN_BUY)
4540                show = true;
4541            else
4542            {
4543                show = false;
4544            }
4545
4546            if (show)
4547                this.showBtns();
4548            else{
4549                this.hideBtns();
4550            }
4551
4552
4553
4554        },
4555
4556        updateInfoBasketOffer: function (id, parent) {
4557            parent = parent || '';
4558
4559            if (parent.length > 0)
4560                parent = "#" + parent;
4561
4562
4563            $(parent + ' .add2basket').attr('data-item', id);
4564            $(parent + ' .move2basket').attr('data-item', id);
4565            $(parent + ' .quantity-block').attr('data-item', id);
4566            $(parent + ' .delay').attr('data-item', id);
4567            $(parent + ' .compare').attr('data-item', id);
4568        },
4569
4570        setPriceMatrix: function (sPriceMatrix) {
4571            if (sPriceMatrix.length > 0) {
4572                this.nodes.obPriceMatrix.classList.remove('d-none');
4573                this.nodes.obPriceMatrix.innerHTML = sPriceMatrix;
4574            } else {
4575                this.nodes.obPriceMatrix.classList.add('d-none');
4576                this.nodes.obPriceMatrix.innerHTML = '';
4577            }
4578        },
4579
4580        changeCharsBlock: function () {
4581
4582            var html = "";
4583
4584
4585
4586            if (this.nodes.obSkuChars) {
4587                
4588                if (this.currentElement.SKU_LIST_CHARS.length) {
4589                    for (i = 0; i < this.currentElement.SKU_LIST_CHARS.length; i++) {
4590                        html += "<table class='cart-char-table mobile-break show-hidden-child'>";
4591                        html += "<tbody>";
4592                        html += "<tr>";
4593                        html += "<td class='left'>" + this.currentElement.SKU_LIST_CHARS[i].NAME + "</td>";
4594                        html += "<td class='dotted'>";
4595                        html += "<div class='dotted'></div>";
4596                        html += "</td>";
4597                        html += "<td class='sku-value right bold'>" + this.currentElement.SKU_LIST_CHARS[i].VALUE + "</td>";
4598                        html += "</tr>";
4599                        html += "</tbody>";
4600                        html += "</table>";
4601                    }
4602
4603                    $("#chars").removeClass('d-none');
4604                    
4605                } else {
4606                    $(".chars-link").addClass("d-none");
4607                }
4608
4609                BX.adjust(this.nodes.obSkuChars, {
4610                    html: html
4611                });
4612
4613                if ($(".cart-char-table").length <= 0 && $(".cart-char-col-right").length <= 0)
4614                {
4615                    $("#chars").addClass('d-none');
4616                    $(".chars-link").addClass("d-none");
4617                }
4618                else
4619                {
4620                    $("#chars").removeClass('d-none');
4621                    $(".chars-link").removeClass("d-none");
4622                }
4623
4624
4625                if (html.length <= 0 && $(this.nodes.obSkuChars).parents(".cart-char-col-left").find(".cart-char-table").length <= 0)
4626                    $(this.nodes.obSkuChars).parents(".cart-char-col-left").hide();
4627
4628                else {
4629                    $(this.nodes.obSkuChars).parents(".cart-char-col-left").show();
4630                }
4631            }
4632
4633
4634        },
4635
4636        showArticleStoreQuantity: function () {
4637            var showArticle = false,
4638                showQuantity = false,
4639                html = "";
4640
4641            var showArticle = false,
4642                showQuantity = false,
4643                html = "";
4644
4645            var obAvailable = this.nodes.obArticleAvailable.querySelector(".product-available-js"),
4646                obArticle = this.nodes.obArticleAvailable.querySelector(".detail-article");
4647
4648            if (this.currentElement.QUANTITY.HTML.length > 0) {
4649                obAvailable.innerHTML = this.currentElement.QUANTITY.HTML;
4650                obAvailable.classList.remove('d-none');
4651                showQuantity = true;
4652            } else {
4653                obAvailable.classList.add('d-none');
4654            }
4655
4656            if (this.currentElement.ARTICLE) {
4657                obArticle.innerHTML = BX.message("ARTICLE") + this.currentElement.ARTICLE;
4658                obArticle.title = obArticle.innerHTML;
4659                obArticle.classList.remove('d-none');
4660                showArticle = true;
4661            } else {
4662                obArticle.classList.add('d-none');
4663            }
4664
4665
4666            if (showArticle || showQuantity) {
4667                this.nodes.obArticleAvailable.classList.remove('d-none');
4668            } else {
4669                this.nodes.obArticleAvailable.classList.add('d-none');
4670            }
4671
4672        },
4673
4674        setPrice: function () {
4675            var price;
4676
4677            if (this.nodes.obQuantity)
4678                this.checkPriceRange(this.nodes.obQuantity.value);
4679
4680            this.checkQuantityControls();
4681
4682            price = this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED];
4683
4684            var blockPrice = this.nodes.obProduct.querySelector('.block-price');
4685
4686            /*if(typeof price == "undefined")
4687                price = this.currentElement.PRICE;*/
4688
4689            if (this.nodes.obPrice.price) {
4690                var showPrice = true;
4691
4692                if (this.currentElement.MODE_ARCHIVE === 'Y' || price.PRICE == "-1")
4693                    showPrice = false;
4694
4695                if (showPrice) {
4696                    this.nodes.obPrice.price.innerHTML = price.PRINT_PRICE;
4697                    blockPrice.classList.remove('d-none');
4698
4699                    var nameTypePrice = this.nodes.obProduct.querySelector(".name-type-price");
4700
4701                    if (price.NAME && !this.currentElement.PRICE_MATRIX_RESULT.EXTRA_PRICE) {
4702                        nameTypePrice.innerHTML = price.NAME;
4703                        nameTypePrice.classList.remove('d-none');
4704                    } else {
4705                        nameTypePrice.innerHTML = '';
4706                        nameTypePrice.classList.add('d-none');
4707                    }
4708
4709                    if (price && price.RATIO_PRICE !== price.RATIO_BASE_PRICE) {
4710                        if (this.element.CONFIG.SHOW_OLD_PRICE === "Y") {
4711                            this.nodes.obPrice.old.classList.remove("d-none");
4712                            this.nodes.obPrice.old.innerHTML = price.PRINT_BASE_PRICE;
4713
4714
4715                            if (this.nodes.obPrice.discount) {
4716                                this.nodes.obPrice.discount.querySelector('.product-price-discount-js').innerHTML = price.PRINT_DISCOUNT;
4717
4718                                if (this.element.CONFIG.SHOW_DISCOUNT_PERCENT === "Y" && price.PERCENT > 0) {
4719                                    this.nodes.obPrice.percent.innerHTML = (-price.PERCENT) + "%";
4720                                    this.nodes.obPrice.percent.classList.remove('d-none');
4721                                } else {
4722                                    this.nodes.obPrice.percent.classList.add('d-none');
4723                                }
4724
4725
4726                                this.nodes.obPrice.discount.classList.remove('d-none');
4727                            } else {
4728                                this.nodes.obPrice.discount.classList.add('d-none');
4729                            }
4730                        }
4731                    } else {
4732                        this.nodes.obPrice.old.classList.add("d-none");
4733                        this.nodes.obPrice.discount.classList.add('d-none');
4734                        this.nodes.obPrice.percent.classList.add('d-none');
4735                    }
4736
4737                    if (this.nodes.obPrice.total) {
4738
4739                        if (price && this.nodes.obQuantity && this.nodes.obQuantity.value != this.currentElement.STEP_QUANTITY) {
4740                            var sum = BX.Currency.currencyFormat(price.PRICE * this.nodes.obQuantity.value, price.CURRENCY, true);
4741                            this.nodes.obPrice.total.classList.remove('d-none');
4742                            this.nodes.obPrice.total.querySelector('.total-value').innerHTML = sum;
4743                            this.nodes.obPrice.total.querySelector('.total-value').title = sum;
4744                        } else {
4745                            this.nodes.obPrice.total.classList.add('d-none');
4746                        }
4747
4748                    }
4749                } else {
4750                    this.nodes.obPrice.price.innerHTML = "";
4751                    blockPrice.classList.add("d-none");
4752                }
4753            }
4754
4755
4756        },
4757
4758        checkQuantityControls: function () {
4759            if (!this.nodes.obQuantity)
4760                return;
4761
4762
4763            var reachedTopLimit = this.element.CONFIG.SHOW_QUANTITY === "Y" && parseFloat(this.nodes.obQuantity.value) + this.currentElement.STEP_QUANTITY > this.currentElement.MAX_QUANTITY,
4764                reachedBottomLimit = parseFloat(this.nodes.obQuantity.value) - this.currentElement.STEP_QUANTITY < this.currentElement.MIN_QUANTITY;
4765
4766
4767            if (reachedTopLimit)
4768                BX.addClass(this.nodes.obQuantityUp, 'product-item-amount-field-btn-disabled');
4769
4770            else if (BX.hasClass(this.nodes.obQuantityUp, 'product-item-amount-field-btn-disabled')) {
4771                BX.removeClass(this.nodes.obQuantityUp, 'product-item-amount-field-btn-disabled');
4772            }
4773
4774            if (reachedBottomLimit)
4775                BX.addClass(this.nodes.obQuantityDown, 'product-item-amount-field-btn-disabled');
4776
4777            else if (BX.hasClass(this.nodes.obQuantityDown, 'product-item-amount-field-btn-disabled')) {
4778                BX.removeClass(this.nodes.obQuantityDown, 'product-item-amount-field-btn-disabled');
4779            }
4780
4781            if (reachedTopLimit && reachedBottomLimit)
4782                this.nodes.obQuantity.setAttribute('disabled', 'disabled');
4783
4784            else {
4785                this.nodes.obQuantity.removeAttribute('disabled');
4786            }
4787        },
4788
4789        checkPriceRange: function (quantity) {
4790            if (typeof quantity === 'undefined' || this.currentElement.ITEM_PRICE_MODE !== 'Q')
4791                return;
4792
4793
4794            var range, found = false;
4795
4796            for (var i in this.currentElement.ITEM_QUANTITY_RANGES) {
4797                if (this.currentElement.ITEM_QUANTITY_RANGES.hasOwnProperty(i)) {
4798                    range = this.currentElement.ITEM_QUANTITY_RANGES[i];
4799
4800
4801                    if (
4802                        parseFloat(quantity) >= parseFloat(range.SORT_FROM) &&
4803                        (
4804                            range.SORT_TO === 'INF' ||
4805                            parseFloat(quantity) <= parseFloat(range.SORT_TO)
4806                        )
4807                    ) {
4808                        found = true;
4809                        this.currentElement.ITEM_QUANTITY_RANGE_SELECTED = range.HASH;
4810                        break;
4811                    }
4812                }
4813            }
4814
4815            if (!found && (range = this.getMinPriceRange())) {
4816                this.currentElement.ITEM_QUANTITY_RANGE_SELECTED = range.HASH;
4817            }
4818
4819            for (var k in this.currentElement.ITEM_PRICES) {
4820                if (this.currentElement.ITEM_PRICES.hasOwnProperty(k)) {
4821                    if (this.currentElement.ITEM_PRICES[k].QUANTITY_HASH == this.currentElement.ITEM_QUANTITY_RANGE_SELECTED) {
4822                        this.currentElement.ITEM_PRICE_SELECTED = k;
4823                        break;
4824                    }
4825                }
4826            }
4827        },
4828
4829        checkQuantityRange: function (quantity, direction) {
4830            if (typeof quantity === 'undefined' || this.currentElement.ITEM_PRICE_MODE !== 'Q') {
4831                return quantity;
4832            }
4833
4834            quantity = parseFloat(quantity);
4835
4836            var nearestQuantity = quantity;
4837            var range, diffFrom, absDiffFrom, diffTo, absDiffTo, shortestDiff;
4838
4839            for (var i in this.currentElement.ITEM_QUANTITY_RANGES) {
4840                if (this.currentElement.ITEM_QUANTITY_RANGES.hasOwnProperty(i)) {
4841                    range = this.currentElement.ITEM_QUANTITY_RANGES[i];
4842
4843                    if (
4844                        parseFloat(quantity) >= parseFloat(range.SORT_FROM) &&
4845                        (
4846                            range.SORT_TO === 'INF' ||
4847                            parseFloat(quantity) <= parseFloat(range.SORT_TO)
4848                        )
4849                    ) {
4850                        nearestQuantity = quantity;
4851                        break;
4852                    } else {
4853                        diffFrom = parseFloat(range.SORT_FROM) - quantity;
4854                        absDiffFrom = Math.abs(diffFrom);
4855                        diffTo = parseFloat(range.SORT_TO) - quantity;
4856                        absDiffTo = Math.abs(diffTo);
4857
4858                        if (shortestDiff === undefined || shortestDiff > absDiffFrom) {
4859                            if (
4860                                direction === undefined ||
4861                                (direction === 'up' && diffFrom > 0) ||
4862                                (direction === 'down' && diffFrom < 0)
4863                            ) {
4864                                shortestDiff = absDiffFrom;
4865                                nearestQuantity = parseFloat(range.SORT_FROM);
4866                            }
4867                        }
4868
4869                        if (shortestDiff === undefined || shortestDiff > absDiffTo) {
4870                            if (
4871                                direction === undefined ||
4872                                (direction === 'up' && diffFrom > 0) ||
4873                                (direction === 'down' && diffFrom < 0)
4874                            ) {
4875                                shortestDiff = absDiffTo;
4876                                nearestQuantity = parseFloat(range.SORT_TO);
4877                            }
4878                        }
4879                    }
4880                }
4881            }
4882
4883            return nearestQuantity;
4884        },
4885
4886        getMinPriceRange: function () {
4887            var range;
4888
4889            for (var i in this.currentElement.ITEM_QUANTITY_RANGES) {
4890                if (this.currentElement.ITEM_QUANTITY_RANGES.hasOwnProperty(i)) {
4891                    if (
4892                        !range ||
4893                        parseInt(this.currentElement.ITEM_QUANTITY_RANGES[i].SORT_FROM) < parseInt(range.SORT_FROM)
4894                    ) {
4895                        range = this.currentElement.ITEM_QUANTITY_RANGES[i];
4896                    }
4897                }
4898            }
4899
4900            return range;
4901        },
4902
4903
4904        startQuantityInterval: function () {
4905            var target = BX.proxy_context;
4906            var func = target.id === this.element.VISUAL.QUANTITY_DOWN ?
4907                BX.proxy(this.quantityDown, this) :
4908                BX.proxy(this.quantityUp, this);
4909
4910
4911
4912            this.quantityDelay = setTimeout(
4913                BX.delegate(function () {
4914                    this.quantityTimer = setInterval(func, 150);
4915                }, this),
4916                300
4917            );
4918        },
4919
4920        clearQuantityInterval: function () {
4921            clearTimeout(this.quantityDelay);
4922            clearInterval(this.quantityTimer);
4923        },
4924
4925        quantityUp: function () {
4926
4927            var curValue = 0,
4928                boolSet = true;
4929
4930            if (this.errorCode === 0 && this.element.CONFIG.SHOW_QUANTITY === "Y" && this.currentElement.CAN_BUY) {
4931
4932                curValue = this.currentElement.QUANTITY_FLOAT ? parseFloat(this.nodes.obQuantity.value) : parseInt(this.nodes.obQuantity.value, 10);
4933
4934
4935                if (!isNaN(curValue)) {
4936
4937                    curValue += this.currentElement.STEP_QUANTITY;
4938
4939                    curValue = this.checkQuantityRange(curValue, 'up');
4940
4941                    if (this.currentElement.CHECK_QUANTITY && curValue > this.currentElement.MAX_QUANTITY) {
4942                        boolSet = false;
4943                    }
4944
4945                    if (boolSet) {
4946                        if (this.currentElement.QUANTITY_FLOAT) {
4947                            curValue = Math.round(curValue * this.element.precisionFactor) / this.element.precisionFactor;
4948                        }
4949
4950
4951
4952                        this.nodes.obQuantity.value = curValue;
4953
4954                        this.setPrice();
4955                    }
4956                }
4957            }
4958        },
4959
4960        quantityDown: function () {
4961            var curValue = 0,
4962                boolSet = true;
4963
4964            if (this.errorCode === 0 && this.element.CONFIG.SHOW_QUANTITY === "Y" && this.currentElement.CAN_BUY) {
4965                curValue = this.currentElement.QUANTITY_FLOAT ? parseFloat(this.nodes.obQuantity.value) : parseInt(this.nodes.obQuantity.value, 10);
4966
4967                if (!isNaN(curValue)) {
4968                    curValue -= this.currentElement.STEP_QUANTITY;
4969
4970                    curValue = this.checkQuantityRange(curValue, 'down');
4971
4972                    if (curValue < this.currentElement.MIN_QUANTITY) {
4973                        boolSet = false;
4974                    }
4975
4976                    if (boolSet) {
4977                        if (this.currentElement.QUANTITY_FLOAT) {
4978                            curValue = Math.round(curValue * this.element.precisionFactor) / this.element.precisionFactor;
4979                        }
4980
4981                        this.nodes.obQuantity.value = curValue;
4982
4983                        this.setPrice();
4984                    }
4985                }
4986            }
4987        },
4988
4989        quantityChange: function () {
4990            var curValue = 0,
4991                intCount;
4992
4993
4994            if (this.errorCode === 0 && this.element.CONFIG.SHOW_QUANTITY === "Y") {
4995
4996                if (this.currentElement.CAN_BUY) {
4997
4998                    curValue = this.currentElement.QUANTITY_FLOAT ? parseFloat(this.nodes.obQuantity.value) : Math.round(this.nodes.obQuantity.value);
4999
5000
5001                    if (!isNaN(curValue)) {
5002                        curValue = this.checkQuantityRange(curValue);
5003
5004                        if (this.currentElement.CHECK_QUANTITY) {
5005                            if (curValue > this.currentElement.MAX_QUANTITY) {
5006                                curValue = this.currentElement.MAX_QUANTITY;
5007                            }
5008                        }
5009
5010                        this.checkPriceRange(curValue);
5011
5012                        if (curValue < this.currentElement.MIN_QUANTITY) {
5013                            curValue = this.currentElement.MIN_QUANTITY;
5014                        } else {
5015                            intCount = Math.round(
5016                                Math.round(curValue * this.element.precisionFactor / this.currentElement.STEP_QUANTITY) / this.element.precisionFactor
5017                            ) || 1;
5018
5019
5020                            curValue = (intCount <= 1 ? this.currentElement.STEP_QUANTITY : intCount * this.currentElement.STEP_QUANTITY);
5021
5022                            curValue = Math.round(curValue * this.element.precisionFactor) / this.element.precisionFactor;
5023
5024                        }
5025
5026
5027                        this.nodes.obQuantity.value = curValue;
5028                    } else {
5029                        this.nodes.obQuantity.value = this.currentElement.MIN_QUANTITY;
5030                    }
5031                } else {
5032                    this.nodes.obQuantity.value = this.currentElement.MIN_QUANTITY;
5033                }
5034
5035                this.setPrice();
5036            }
5037
5038        },
5039
5040        quantitySet: function () {
5041
5042            var strLimit, resetQuantity;
5043
5044            var newOffer = this.currentElement,
5045                oldOffer = this.oldElement;
5046
5047            if (this.errorCode === 0) {
5048
5049                this.currentElement.CAN_BUY = newOffer.CAN_BUY;
5050
5051                if (this.currentElement.CAN_BUY) {
5052                    this.nodes.quantity.classList.remove('d-none');
5053                    this.nodes.obBasketActions.classList.remove('d-none');
5054                    this.nodes.obWrSubscribe.classList.add('d-none');
5055                } else {
5056                    this.nodes.quantity.classList.add('d-none');
5057
5058                    if (this.nodes.obWrSubscribe) {
5059
5060                        if (newOffer.CATALOG_SUBSCRIBE === 'Y') {
5061                            this.nodes.obWrSubscribe.classList.remove('d-none');
5062                            this.nodes.obWrSubscribe.setAttribute('data-item', newOffer.ID);
5063                            BX(this.element.VISUAL.SUBSCRIBE_LINK + '_hidden').click();
5064                        } else {
5065                            this.nodes.obWrSubscribe.classList.add('d-none');
5066                        }
5067                    }
5068                }
5069
5070                this.currentElement.QUANTITY_FLOAT = newOffer.QUANTITY_FLOAT;
5071                this.element.CHECK_QUANTITY = newOffer.CHECK_QUANTITY;
5072
5073
5074
5075                if (this.currentElement.QUANTITY_FLOAT) {
5076                    this.currentElement.STEP_QUANTITY = Math.round(parseFloat(newOffer.STEP_QUANTITY) * this.element.precisionFactor) / this.element.precisionFactor;
5077                    this.currentElement.MAX_QUANTITY = parseFloat(newOffer.MAX_QUANTITY);
5078                    this.currentElement.MIN_QUANTITY = this.currentElement.ITEM_PRICE_MODE === 'Q' ? parseFloat(this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].MIN_QUANTITY) : this.currentElement.STEP_QUANTITY;
5079                } else {
5080                    this.currentElement.STEP_QUANTITY = parseInt(newOffer.STEP_QUANTITY, 10);
5081                    this.currentElement.MAX_QUANTITY = parseInt(newOffer.MAX_QUANTITY, 10);
5082                    this.currentElement.MIN_QUANTITY = this.currentElement.ITEM_PRICE_MODE === 'Q' ? parseInt(this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].MIN_QUANTITY) : this.currentElement.STEP_QUANTITY;
5083                }
5084
5085
5086
5087                if (this.element.CONFIG.SHOW_QUANTITY) {
5088                    var isDifferentMinQuantity = oldOffer.ITEM_PRICES.length &&
5089                        oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED] &&
5090                        oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED].MIN_QUANTITY != this.currentElement.MIN_QUANTITY;
5091
5092                    if (this.currentElement.QUANTITY_FLOAT) {
5093                        resetQuantity = Math.round(parseFloat(oldOffer.STEP_QUANTITY) * this.element.precisionFactor) / this.element.precisionFactor !== this.currentElement.STEP_QUANTITY ||
5094                            isDifferentMinQuantity ||
5095                            oldOffer.MEASURE !== newOffer.MEASURE ||
5096                            (
5097                                this.currentElement.CHECK_QUANTITY &&
5098                                parseFloat(oldOffer.MAX_QUANTITY) > this.currentElement.MAX_QUANTITY &&
5099                                parseFloat(this.nodes.obQuantity.value) > this.currentElement.MAX_QUANTITY
5100                            );
5101                    } else {
5102                        resetQuantity = parseInt(oldOffer.STEP_QUANTITY, 10) !== this.currentElement.STEP_QUANTITY ||
5103                            isDifferentMinQuantity ||
5104                            oldOffer.MEASURE !== newOffer.MEASURE ||
5105                            (
5106                                this.currentElement.CHECK_QUANTITY &&
5107                                parseInt(oldOffer.MAX_QUANTITY, 10) > this.currentElement.MAX_QUANTITY &&
5108                                parseInt(this.nodes.obQuantity.value, 10) > this.currentElement.MAX_QUANTITY
5109                            );
5110                    }
5111
5112                    this.nodes.obQuantity.disabled = !this.currentElement.CAN_BUY;
5113
5114                    if (resetQuantity) {
5115                        this.nodes.obQuantity.value = this.currentElement.MIN_QUANTITY;
5116                    }
5117                }
5118
5119                if (this.nodes.obMeasure) {
5120
5121                    if (newOffer.MEASURE_HTML) {
5122                        BX.adjust(this.nodes.obMeasure, {
5123                            html: newOffer.MEASURE_HTML,
5124                            style: {
5125                                display: ''
5126                            }
5127                        });
5128                    } else {
5129                        BX.adjust(this.nodes.obMeasure, {
5130                            html: '',
5131                            style: {
5132                                display: 'none'
5133                            }
5134                        });
5135                    }
5136                }
5137
5138            }
5139        },
5140
5141        getCanBuy: function (arFilter) {
5142            var i,
5143                j = 0,
5144                boolOneSearch = true,
5145                boolSearch = false;
5146
5147            for (i = 0; i < this.element.OFFERS.length; i++) {
5148                boolOneSearch = true;
5149
5150                for (j in arFilter) {
5151                    if (arFilter[j] !== this.element.OFFERS[i].TREE[j]) {
5152                        boolOneSearch = false;
5153                        break;
5154                    }
5155                }
5156
5157                if (boolOneSearch) {
5158                    if (this.element.OFFERS[i].CAN_BUY) {
5159                        boolSearch = true;
5160                        break;
5161                    }
5162                }
5163            }
5164
5165            return boolSearch;
5166        },
5167
5168
5169
5170        drawImages: function (images) {
5171
5172            var nodeControlPics = $(this.nodes.obBigSlider).find(".controls-pictures"),
5173                nodeBigPics = $(this.nodes.obBigSlider).find(".wrapper-big-picture"),
5174                nodeControlPicsParent = nodeControlPics.parent(),
5175                nodeBigPicsParent = nodeBigPics.parent(),
5176                listControl = "",
5177                listBigPic = "",
5178                imagesIsset = images && BX.type.isArray(images),
5179                countMoreImages = 0,
5180                countImages = 0;
5181
5182
5183            nodeControlPics.removeClass('one-photo').html("");
5184            nodeBigPics.html("");
5185
5186
5187            if (imagesIsset) {
5188                countImages = images.length;
5189
5190                if (countImages > 0) {
5191
5192                    for (i = 0; i < images.length; i++) {
5193
5194                        if (i < 3) {
5195                            listControl += "<div data-value='" + images[i].ID + "'";
5196                            listControl += "class='small-picture";
5197
5198                            if (i == 0) {
5199                                listControl += " active";
5200                            }
5201                            listControl += "'>";
5202
5203
5204                            listControl += "<img src='" + images[i].SMALL.SRC + "' alt = '";
5205
5206                            if (images[i].DESC)
5207                                listControl += images[i].DESC;
5208
5209                            listControl += "'/>";
5210
5211                            listControl += "</div>";
5212                        }
5213
5214
5215
5216                        listBigPic += "<div data-id='" + images[i].ID + "'";
5217                        listBigPic += "class='big-picture";
5218
5219                        if (i == 0) {
5220                            listBigPic += " active";
5221                        }
5222                        listBigPic += "'>";
5223
5224                        listBigPic += "<a class='cursor-loop d-block open-popup-gallery " + this.element.CONFIG.ZOOM + "-offer' data-popup-gallery='" + this.currentElement.ID + "_" + this.element.OBJ_ID + "'>";
5225
5226                        listBigPic += "<img class='d-block mx-auto img-fluid open-popup-gallery-item' data-src='" + images[i].BIG.SRC + "' src='" + images[i].BIG.SRC + "' title='" + this.element.TITLE + "'";
5227                        listBigPic += " data-popup-gallery='" + this.currentElement.ID + "_" + this.element.OBJ_ID + "'";
5228                        listBigPic += " data-small-src = '" + images[i].SMALL.SRC + "'";
5229                        listBigPic += " data-big-src = '" + images[i].BIG.SRC + "'";
5230                        listBigPic += " data-desc ='" + images[i].DESC + "'";
5231                        listBigPic += " alt ='" + images[i].DESC + "'";
5232                        listBigPic += ">";
5233
5234
5235                        listBigPic += "</a>";
5236
5237                        listBigPic += "</div>";
5238
5239                    }
5240
5241                    if (images.length > 3) {
5242                        countMoreImages = images.length - 3;
5243                        listControl += "<div class='more open-popup-gallery' data-popup-gallery='" + this.currentElement.ID + "_" + this.element.OBJ_ID + "'><a>" + BX.message('MORE_PHOTOS') + ' ' + (images.length - 3) + "</a></div>";
5244                    }
5245                }
5246
5247            } else {
5248                listBigPic += "<div";
5249                listBigPic += "class='big-picture active'>";
5250
5251
5252                listBigPic += "<img src='" + this.no_photo_src + "' title='" + this.config.title + "'>";
5253
5254
5255
5256                listBigPic += "</div>";
5257            }
5258
5259            nodeBigPics.html(listBigPic);
5260            nodeControlPics.html(listControl);
5261
5262
5263            if (countImages  > 1 || nodeControlPicsParent.hasClass('video')) {
5264                
5265                nodeControlPicsParent.removeClass('d-none');
5266
5267                nodeControlPicsParent.addClass('col-2');
5268                nodeBigPicsParent.removeClass('col-12');
5269                nodeBigPicsParent.addClass('col-10');
5270
5271            } else {
5272                nodeControlPicsParent.addClass('d-none');
5273                nodeBigPicsParent.removeClass('col-10');
5274                nodeBigPicsParent.addClass('col-12');
5275            }
5276
5277        }
5278
5279    };
5280
5281    window.JCCatalogItem = function (arParams) {
5282        this.element = arParams;
5283        this.nodes = {};
5284        this.currentElement = {};
5285        this.oldElement = {};
5286        this.firstLoad = true;
5287        this.errorCode = 0;
5288        this.selectedValues = {};
5289
5290
5291
5292        if (typeof arParams === 'object') {
5293            this.initConfig();
5294
5295            switch (this.element.PRODUCT_TYPE) {
5296                case 0:
5297                case 1:
5298                case 2:
5299                    this.initProductData();
5300                    break;
5301                case 3:
5302                    this.initOffersData();
5303                    break;
5304                default:
5305                    this.errorCode = -1;
5306            }
5307
5308        }
5309
5310        if (this.errorCode === 0)
5311            BX.ready(BX.delegate(this.init, this));
5312    };
5313
5314    window.JCCatalogItem.prototype = {
5315
5316        initConfig: function () {
5317            this.nodes.obProduct = BX(this.element.VISUAL.ID);
5318
5319            if (!this.nodes.obProduct)
5320                this.errorCode = -1;
5321
5322
5323            this.element.PRODUCT_TYPE = parseInt(this.element.PRODUCT_TYPE, 10);
5324
5325            this.nodes.obPriceMatrix = BX(this.element.VISUAL.PRICE_MATRIX);
5326            this.nodes.obMeasure = BX(this.element.VISUAL.QUANTITY_MEASURE);
5327            this.nodes.obPreviewText = BX(this.element.VISUAL.PREVIEW_TEXT);
5328            this.nodes.obShortDescription = BX(this.element.VISUAL.SHORT_DESCRIPTION);
5329            this.nodes.obArticleAvailable = BX(this.element.VISUAL.ARTICLE_AVAILABLE);
5330            this.nodes.obSkuChars = BX(this.element.VISUAL.SKU_CHARS);
5331            this.nodes.obPict = BX(this.element.VISUAL.PICT);
5332
5333            this.nodes.obBasketActions = BX(this.element.VISUAL.BASKET_ACTIONS);
5334
5335            this.nodes.obWrAdd2BasketBtn = BX(this.element.VISUAL.WR_ADD2BASKET);
5336
5337
5338            this.nodes.obAdd2BasketBtn = BX(this.element.VISUAL.ADD2BASKET);
5339            this.nodes.obMove2Basket = BX(this.element.VISUAL.MOVE2BASKET);
5340            this.nodes.obAdd2BasketBtn && BX.bind(this.nodes.obAdd2BasketBtn, 'click', BX.proxy(this.add2Basket, this));
5341
5342
5343            this.nodes.obDetailUrlImg = BX(this.element.VISUAL.DETAIL_URL_IMG);
5344            this.nodes.obName = BX(this.element.VISUAL.NAME);
5345
5346            this.nodes.obBtn2pageProduct = BX(this.element.VISUAL.BTN2DETAIL_PAGE_PRODUCT);
5347
5348
5349
5350            if (this.element.CONFIG.USE_DELAY === "Y") {
5351                this.nodes.obDelay = BX(this.element.VISUAL.DELAY);
5352                this.nodes.obDelay && BX.bind(this.nodes.obDelay, 'click', BX.proxy(this.add2Delay, this));
5353            }
5354
5355            if (this.element.CONFIG.USE_COMPARE === "Y") {
5356                this.nodes.obCompare = BX(this.element.VISUAL.COMPARE);
5357                this.nodes.obCompare && BX.bind(this.nodes.obCompare, 'click', BX.proxy(this.add2Compare, this));
5358            }
5359
5360            if (this.element.CONFIG.SHOW_PRICE === "Y") {
5361                this.nodes.obPrice = {
5362                    price: null,
5363                    old: null,
5364                    percent: null
5365                };
5366
5367                this.nodes.obPrice.price = BX(this.element.VISUAL.PRICE);
5368
5369                if (!this.nodes.obPrice.price) {
5370                    this.errorCode = -16;
5371                } else {
5372                    this.nodes.obPrice.old = BX(this.element.VISUAL.OLD_PRICE);
5373                    this.nodes.obPrice.percent = BX(this.element.VISUAL.DISCOUNT_PERCENT);
5374                }
5375
5376            }
5377
5378            if (this.element.CONFIG.SHOW_QUANTITY === "Y") {
5379                this.nodes.obQuantity = BX(this.element.VISUAL.QUANTITY);
5380                this.nodes.quantity = this.nodes.obProduct.querySelector('.quantity-block');
5381
5382
5383
5384                if (this.element.VISUAL.QUANTITY_UP) {
5385                    this.nodes.obQuantityUp = BX(this.element.VISUAL.QUANTITY_UP);
5386                    BX.bind(this.nodes.obQuantityUp, 'click', BX.delegate(this.quantityUp, this));
5387
5388                }
5389
5390                if (this.element.VISUAL.QUANTITY_DOWN) {
5391                    this.nodes.obQuantityDown = BX(this.element.VISUAL.QUANTITY_DOWN);
5392                    BX.bind(this.nodes.obQuantityDown, 'click', BX.delegate(this.quantityDown, this));
5393                }
5394
5395                if (this.nodes.obQuantity)
5396                    BX.bind(this.nodes.obQuantity, 'change', BX.delegate(this.quantityChange, this));
5397
5398
5399                this.element.precisionFactor = Math.pow(10, this.element.CONFIG.PRECISION);
5400            }
5401
5402        },
5403
5404        initProductData: function () {
5405            this.currentElement = this.element;
5406
5407            this.oldElement = this.currentElement;
5408
5409            this.currentElement.MAX_QUANTITY = this.currentElement.QUANTITY_FLOAT ?
5410                parseFloat(this.element.MAX_QUANTITY) :
5411                parseInt(this.element.MAX_QUANTITY, 10);
5412            this.currentElement.STEP_QUANTITY = this.currentElement.QUANTITY_FLOAT ?
5413                parseFloat(this.currentElement.STEP_QUANTITY) :
5414                parseInt(this.currentElement.STEP_QUANTITY, 10);
5415
5416            this.currentElement.MIN_QUANTITY = this.currentElement.ITEM_PRICE_MODE === 'Q' ? parseFloat(this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].MIN_QUANTITY) : this.currentElement.STEP_QUANTITY;
5417
5418            if (this.currentElement.QUANTITY_FLOAT)
5419                this.currentElement.STEP_QUANTITY = Math.round(this.currentElement.STEP_QUANTITY * this.element.precisionFactor) / this.element.precisionFactor;
5420
5421            this.setPrice();
5422            this.setQuantityHtml();
5423            this.btnsControl();
5424
5425            if (this.nodes.obPriceMatrix && this.currentElement.PRICE_MATRIX_RESULT.HTML)
5426                this.setPriceMatrix(this.currentElement.PRICE_MATRIX_RESULT.HTML);
5427        },
5428
5429        initOffersData: function () {
5430
5431            if (this.element.CONFIG.SHOW_OFFERS) {
5432                this.currentElement = this.element.OFFERS[this.element.OFFER_ID_SELECTED];
5433                this.nodes.obTree = BX(this.element.VISUAL.TREE);
5434
5435                if (!this.nodes.obTree)
5436                    this.errorCode = -256;
5437            } else {
5438                this.hideBtns();
5439                this.errorCode = -1;
5440            }
5441
5442
5443        },
5444
5445        init: function () {
5446            var i = 0,
5447                j = 0,
5448                treeItems = null;
5449
5450
5451            if (this.errorCode === 0) {
5452
5453                switch (this.element.PRODUCT_TYPE) {
5454                    case 0:
5455                    case 1:
5456                    case 2:
5457
5458                        this.checkQuantityControls();
5459                        break;
5460
5461                    case 3:
5462
5463                        treeItems = this.nodes.obTree.querySelectorAll('li');
5464
5465                        for (i = 0; i < treeItems.length; i++) {
5466                            BX.bind(treeItems[i], 'click', BX.delegate(this.selectOfferProp, this));
5467                        }
5468
5469
5470                        this.setCurrent();
5471                        break;
5472                }
5473
5474            }
5475
5476
5477        },
5478
5479        add2Basket: function () {
5480
5481            if (!this.currentElement.CAN_BUY)
5482                return;
5483
5484            var productID = '',
5485                value = 1;
5486
5487            if (this.nodes.obQuantity)
5488                value = this.nodes.obQuantity.value;
5489
5490
5491            productItem = {
5492                PRODUCT_ID: this.currentElement.ID,
5493                QUANTITY: value,
5494                PRICE_ID: this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].ID
5495            };
5496
5497            $(this.nodes.obAdd2BasketBtn).addClass("btn-processing");
5498
5499            BX.ajax({
5500                method: 'POST',
5501                dataType: 'json',
5502                url: '/bitrix/tools/concept.phoenix/ajax/basket/add2basket.php',
5503                data: {
5504                    productItem: productItem,
5505                    site_id: $("input.site_id").val()
5506                },
5507                onsuccess: BX.proxy(this.basketResult, this)
5508            });
5509        },
5510
5511        basketResult: function (arResult) {
5512            if (arResult["OK"] == "Y") {
5513                if (this.element.PRODUCT_TYPE === 3)
5514                    this.element.OFFERS[this.element.OFFER_ID_SELECTED].IN_BASKET = true;
5515
5516                markProductAddBasket(this.currentElement.ID);
5517
5518                if (arResult["SCRIPTS"])
5519                    $('body').append(arResult["SCRIPTS"]);
5520            }
5521
5522            $(this.nodes.obAdd2BasketBtn).removeClass("btn-processing");
5523        },
5524
5525        add2Delay: function () {
5526            var productID = '',
5527                value = 1;
5528
5529            if (this.nodes.obQuantity)
5530                value = this.nodes.obQuantity.value;
5531
5532
5533            BX.ajax({
5534                method: 'POST',
5535                dataType: 'json',
5536                url: '/bitrix/tools/concept.phoenix/ajax/basket/wishlist.php',
5537                data: {
5538                    product_id: this.currentElement.ID,
5539                    price_id: this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].ID,
5540                    price: this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].PRICE,
5541                    name: this.currentElement.NAME,
5542                    detail_page: this.currentElement.DETAIL_PAGE_URL,
5543                    can_buy: this.currentElement.CAN_BUY,
5544                    quantity: value,
5545                    currency: this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].CURRENCY,
5546                    site_id: $("input.site_id").val()
5547                },
5548                onsuccess: BX.proxy(this.delayResult, this)
5549            });
5550        },
5551
5552        delayResult: function (arResult) {
5553            if (arResult["OK"] == "Y") {
5554                if (this.element.PRODUCT_TYPE == 3) {
5555                    if (arResult["ACTION"] == 'active')
5556                        this.currentElement.IN_DELAY = true;
5557
5558                    if (arResult["ACTION"] == 'delete')
5559                        this.currentElement.IN_DELAY = false;
5560                }
5561
5562                markProductDelayBasket(this.currentElement.ID, arResult["ACTION"]);
5563            } else {
5564                console.log(arResult["OK"]);
5565            }
5566        },
5567
5568        add2Compare: function () {
5569
5570            var checked = false;
5571
5572            if (!BX.hasClass(this.nodes.obCompare, "active"))
5573                checked = true;
5574
5575            var url = checked ? this.element.CONFIG.COMPARE_URL + '?action=ADD_TO_COMPARE_LIST&id=#ID#' : this.element.CONFIG.COMPARE_URL + '?action=DELETE_FROM_COMPARE_LIST&id=#ID#',
5576                compareLink;
5577
5578            if (url) {
5579
5580                compareLink = url.replace('#ID#', this.currentElement.ID);
5581
5582
5583
5584                BX.ajax({
5585                    method: 'POST',
5586                    dataType: checked ? 'json' : 'html',
5587                    url: compareLink + (compareLink.indexOf('?') !== -1 ? '&' : '?') + 'ajax_action=Y',
5588                    onsuccess: checked ?
5589                        BX.proxy(this.compareResult, this) : BX.proxy(this.compareDeleteResult, this)
5590                });
5591            }
5592        },
5593
5594        compareResult: function (arResult) {
5595
5596            if (this.element.OFFERS.length > 0)
5597                this.currentElement.IN_COMPARE = true;
5598
5599
5600            markProductCompareBasket(this.currentItemId, 'active');
5601
5602        },
5603
5604        compareDeleteResult: function (arResult) {
5605
5606            if (this.element.OFFERS.length > 0)
5607                this.currentElement.IN_COMPARE = false;
5608
5609
5610            markProductCompareBasket(this.currentItemId, 'delete');
5611
5612        },
5613
5614        showArticleStoreQuantity: function () {
5615            var showArticle = false,
5616                showQuantity = false,
5617                html = "";
5618
5619            var obAvailable = this.nodes.obArticleAvailable.querySelector(".product-available-js"),
5620                obArticle = this.nodes.obArticleAvailable.querySelector(".detail-article");
5621
5622            if (this.currentElement.QUANTITY.HTML.length > 0) {
5623                obAvailable.innerHTML = this.currentElement.QUANTITY.HTML;
5624                obAvailable.classList.remove('d-none');
5625                showQuantity = true;
5626            } else {
5627                obAvailable.classList.add('d-none');
5628            }
5629
5630            if (this.currentElement.ARTICLE) {
5631                obArticle.innerHTML = BX.message("ARTICLE") + this.currentElement.ARTICLE;
5632                obArticle.title = obArticle.innerHTML;
5633                obArticle.classList.remove('d-none');
5634                showArticle = true;
5635            } else {
5636                obArticle.classList.add('d-none');
5637            }
5638
5639
5640            if (showArticle || showQuantity) {
5641                this.nodes.obArticleAvailable.classList.remove('d-none');
5642            } else {
5643                this.nodes.obArticleAvailable.classList.add('d-none');
5644            }
5645
5646        },
5647
5648        selectOfferProp: function () {
5649            var i = 0,
5650                strTreeValue = '',
5651                arTreeItem = [],
5652                rowItems = null,
5653                target = BX.proxy_context,
5654                smallCardItem;
5655
5656
5657            if (target && target.hasAttribute('data-treevalue')) {
5658                if (BX.hasClass(target, 'active'))
5659                    return;
5660
5661
5662
5663                if (typeof document.activeElement === 'object') {
5664                    document.activeElement.blur();
5665                }
5666
5667
5668
5669                strTreeValue = target.getAttribute('data-treevalue');
5670                arTreeItem = strTreeValue.split('_');
5671
5672                this.searchOfferPropIndex(arTreeItem[0], arTreeItem[1]);
5673
5674
5675                rowItems = BX.findChildren(target.parentNode, {
5676                    tagName: 'li'
5677                }, false);
5678
5679
5680                if (rowItems && rowItems.length) {
5681                    for (i = 0; i < rowItems.length; i++) {
5682                        BX.removeClass(rowItems[i], 'active');
5683                    }
5684                }
5685
5686
5687                BX.addClass(target, 'active');
5688
5689            }
5690        },
5691
5692        searchOfferPropIndex: function (strPropID, strPropValue) {
5693            var strName = '',
5694                arShowValues = false,
5695                arCanBuyValues = [],
5696                allValues = [],
5697                index = -1,
5698                i, j,
5699                arFilter = {},
5700                tmpFilter = [];
5701
5702
5703
5704            for (i = 0; i < this.element.TREE_PROPS.length; i++) {
5705                if (this.element.TREE_PROPS[i].ID === strPropID) {
5706                    index = i;
5707                    break;
5708                }
5709            }
5710
5711            if (index > -1) {
5712                for (i = 0; i < index; i++) {
5713                    strName = 'PROP_' + this.element.TREE_PROPS[i].ID;
5714                    arFilter[strName] = this.selectedValues[strName];
5715                }
5716
5717
5718                strName = 'PROP_' + this.element.TREE_PROPS[index].ID;
5719                arFilter[strName] = strPropValue;
5720
5721
5722
5723                for (i = index + 1; i < this.element.TREE_PROPS.length; i++) {
5724
5725                    strName = 'PROP_' + this.element.TREE_PROPS[i].ID;
5726                    arShowValues = this.getRowValues(arFilter, strName);
5727
5728
5729
5730                    if (!arShowValues)
5731                        break;
5732
5733                    allValues = [];
5734
5735                    if (this.element.CONFIG.SHOW_ABSENT === 'Y') {
5736
5737                        arCanBuyValues = [];
5738                        tmpFilter = [];
5739                        tmpFilter = BX.clone(arFilter, true);
5740
5741                        for (j = 0; j < arShowValues.length; j++) {
5742                            tmpFilter[strName] = arShowValues[j];
5743                            allValues[allValues.length] = arShowValues[j];
5744                            if (this.getCanBuy(tmpFilter))
5745                                arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
5746                        }
5747                    } else {
5748                        arCanBuyValues = arShowValues;
5749                    }
5750
5751
5752
5753
5754                    if (this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arC
5754anBuyValues)) {
5755                        arFilter[strName] = this.selectedValues[strName];
5756
5757                    } else {
5758
5759                        if (this.element.CONFIG.SHOW_ABSENT === 'Y') {
5760                            arFilter[strName] = (arCanBuyValues.length ? arCanBuyValues[0] : allValues[0]);
5761                        } else {
5762                            arFilter[strName] = arCanBuyValues[0];
5763                        }
5764                    }
5765
5766
5767                    this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
5768
5769                }
5770
5771
5772                this.selectedValues = arFilter;
5773
5774                this.changeInfo();
5775
5776            }
5777
5778        },
5779
5780        setCurrent: function () {
5781            var i,
5782                j = 0,
5783                strName = '',
5784                arShowValues = false,
5785                arCanBuyValues = [],
5786                arFilter = {},
5787                tmpFilter = [],
5788                current = this.currentElement.TREE;
5789
5790
5791            for (i = 0; i < this.element.TREE_PROPS.length; i++) {
5792                strName = 'PROP_' + this.element.TREE_PROPS[i].ID;
5793                arShowValues = this.getRowValues(arFilter, strName);
5794
5795
5796                if (!arShowValues)
5797                    break;
5798
5799                if (BX.util.in_array(current[strName], arShowValues)) {
5800                    arFilter[strName] = current[strName];
5801                } else {
5802                    arFilter[strName] = arShowValues[0];
5803                    this.element.OFFER_ID_SELECTED = 0;
5804                }
5805
5806                if (this.element.CONFIG.SHOW_ABSENT === 'Y') {
5807                    arCanBuyValues = [];
5808                    tmpFilter = [];
5809                    tmpFilter = BX.clone(arFilter, true);
5810
5811                    for (j = 0; j < arShowValues.length; j++) {
5812                        tmpFilter[strName] = arShowValues[j];
5813
5814                        if (this.getCanBuy(tmpFilter)) {
5815                            arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
5816                        }
5817                    }
5818                } else {
5819                    arCanBuyValues = arShowValues;
5820                }
5821
5822
5823                this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
5824            }
5825
5826            this.selectedValues = arFilter;
5827
5828            this.changeInfo();
5829        },
5830
5831        getRowValues: function (arFilter, index) {
5832            var arValues = [],
5833                i = 0,
5834                j = 0,
5835                boolSearch = false,
5836                boolOneSearch = true;
5837
5838
5839
5840            if (arFilter.length === 0) {
5841                for (i = 0; i < this.element.OFFERS.length; i++) {
5842                    if (!BX.util.in_array(this.element.OFFERS[i].TREE[index], arValues)) {
5843                        arValues[arValues.length] = this.element.OFFERS[i].TREE[index];
5844
5845                    }
5846                }
5847                boolSearch = true;
5848            } else {
5849                for (i = 0; i < this.element.OFFERS.length; i++) {
5850                    boolOneSearch = true;
5851
5852                    for (j in arFilter) {
5853                        if (arFilter[j] !== this.element.OFFERS[i].TREE[j]) {
5854                            boolOneSearch = false;
5855                            break;
5856                        }
5857                    }
5858
5859                    if (boolOneSearch) {
5860                        if (!BX.util.in_array(this.element.OFFERS[i].TREE[index], arValues)) {
5861                            arValues[arValues.length] = this.element.OFFERS[i].TREE[index];
5862
5863                        }
5864
5865                        boolSearch = true;
5866                    }
5867                }
5868            }
5869
5870
5871
5872            return (boolSearch ? arValues : false);
5873        },
5874
5875        updateRow: function (intNumber, activeId, showId, canBuyId) {
5876
5877            var i = 0,
5878                value = '',
5879                isCurrent = false,
5880                rowItems = null;
5881
5882
5883            var lineContainer = this.nodes.obTree.querySelectorAll('.wrapper-sku-props');
5884
5885
5886            if (intNumber > -1 && intNumber < lineContainer.length) {
5887                rowItems = lineContainer[intNumber].querySelectorAll('li');
5888
5889
5890
5891                for (i = 0; i < rowItems.length; i++) {
5892                    value = rowItems[i].getAttribute('data-onevalue');
5893                    isCurrent = value === activeId;
5894
5895                    if (isCurrent) {
5896                        BX.addClass(rowItems[i], 'active');
5897                    } else {
5898                        BX.removeClass(rowItems[i], 'active');
5899                    }
5900
5901                    if (BX.util.in_array(value, canBuyId)) {
5902                        BX.removeClass(rowItems[i], 'notallowed');
5903                    } else {
5904                        BX.addClass(rowItems[i], 'notallowed');
5905                    }
5906
5907                    rowItems[i].style.display = BX.util.in_array(value, showId) ? '' : 'none';
5908
5909                    if (isCurrent) {
5910                        lineContainer[intNumber].style.display = (value == 0) ? 'none' : '';
5911                    }
5912                }
5913            }
5914        },
5915
5916        changeInfo: function () {
5917            var index = -1,
5918                j = 0,
5919                boolOneSearch = true,
5920                descTitle = null,
5921                rowItems = null;
5922
5923            var i;
5924
5925            for (i = 0; i < this.element.OFFERS.length; i++) {
5926                boolOneSearch = true;
5927
5928                for (j in this.selectedValues) {
5929
5930                    if (this.selectedValues[j] !== this.element.OFFERS[i].TREE[j]) {
5931                        boolOneSearch = false;
5932                        break;
5933                    }
5934
5935                }
5936
5937                if (boolOneSearch) {
5938                    index = i;
5939                    break;
5940                }
5941            }
5942
5943            this.oldElement = this.currentElement;
5944
5945            this.element.OFFER_ID_SELECTED = index;
5946            this.currentElement = this.element.OFFERS[this.element.OFFER_ID_SELECTED];
5947
5948            this.changeCharsBlock();
5949
5950            if (index > -1) {
5951
5952                if (this.nodes.obPriceMatrix && this.currentElement.PRICE_MATRIX_RESULT.HTML)
5953                    this.setPriceMatrix(this.currentElement.PRICE_MATRIX_RESULT.HTML);
5954
5955                this.updateInfoBasketOffer(this.currentElement.ID, this.element.VISUAL.ID);
5956
5957
5958                for (i = 0; i < this.element.OFFERS.length; i++) {
5959                    if (this.element.CONFIG.OFFER_GROUP && this.element.OFFERS[i].OFFER_GROUP) {
5960                        if (offerGroupNode = BX(this.element.VISUAL.OFFER_GROUP + this.element.OFFERS[i].ID))
5961                            offerGroupNode.style.display = (i == index ? '' : 'none');
5962
5963                    }
5964                }
5965
5966                $("input.product-" + this.currentElement.ID + "-picture-src-small").val(this.currentElement.PHOTO);
5967
5968                if (this.element.CONFIG.ZOOM) {
5969                    $(this.nodes.obProduct).find('.zoom-offer').trigger('zoom
5969-offer.destroy');
5970                    initZoomer($(this.nodes.obProduct).find(".zoom-offer"));
5971                }
5972
5973
5974                if (this.currentElement.IN_BASKET == true ||
5975                    this.currentElement.IN_DELAY == true ||
5976                    this.currentElement.IN_COMPARE == true
5977                ) {
5978
5979                    setItemButtonStatus(
5980                        this.currentElement.ID,
5981                        '',
5982                        this.currentElement.IN_BASKET,
5983                        this.currentElement.IN_DELAY,
5984                        this.currentElement.IN_COMPARE
5985                    );
5986
5987
5988                    setItemButtonStatus(this.currentElement.ID, '', 'offer_delay_added');
5989                    setItemButtonStatus(this.currentElement.ID, '', 'compare_added');
5990
5991                } else {
5992                    setItemButtonStatus(arStatusBasketPhoenix);
5993                }
5994            }
5995
5996            this.quantitySet();
5997            this.setPrice();
5998            this.btnsControl();
5999            this.setQuantityHtml();
6000
6001            if (!this.firstLoad) {
6002                this.drawPicture();
6003
6004                this.changeDetailUrl(this.currentElement.ID);
6005
6006                if (this.nodes.obShortDescription)
6007                    this.changeText(this.nodes.obShortDescription, this.currentElement.SHORT_DESCRIPTION_HTML);
6008
6009                if (this.nodes.obPreviewText)
6010                    this.changeText(this.nodes.obPreviewText, this.currentElement.PREVIEW_TEXT_HTML);
6011
6012                this.showArticleStoreQuantity();
6013            }
6014
6015
6016            this.firstLoad = false;
6017            this.updateInfoBasketOffer(this.currentElement.ID, this.element.VISUAL.ID);
6018        },
6019
6020        setQuantityHtml: function () {
6021
6022            var productAvailableValue = this.nodes.obProduct.querySelector(".product-available-js");
6023
6024            if (this.currentElement.QUANTITY.HTML && productAvailableValue) {
6025                productAvailableValue.innerHTML = this.currentElement.QUANTITY.HTML;
6026                productAvailableValue.classList.add("active");
6027            }
6028        },
6029
6030        setPrice: function () {
6031            var price;
6032
6033            
6034            if (this.nodes.obQuantity)
6035                this.checkPriceRange(this.nodes.obQuantity.value);
6036
6037            this.checkQuantityControls();
6038
6039            price = this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED];
6040
6041            
6042            var blockPrice = this.nodes.obProduct.querySelector('.block-price');
6043
6044            if (this.nodes.obPrice.price) {
6045                var showPrice = true;
6046
6047                if (this.currentElement.MODE_ARCHIVE === 'Y' || price.PRICE == "-1")
6048                    showPrice = false;
6049
6050                if (showPrice) {
6051                    this.nodes.obPrice.price.innerHTML = price.PRINT_PRICE;
6052                    blockPrice.classList.remove("d-none");
6053
6054                    var nameTypePrice = this.nodes.obProduct.querySelector(".name-type-price");
6055
6056                    if (price.NAME && !this.currentElement.PRICE_MATRIX_RESULT.EXTRA_PRICE) {
6057                        nameTypePrice.innerHTML = price.NAME;
6058                        nameTypePrice.classList.remove('d-none');
6059                    } else {
6060                        nameTypePrice.innerHTML = '';
6061                        nameTypePrice.classList.add('d-none');
6062                    }
6063
6064                    if (price && price.RATIO_PRICE !== price.RATIO_BASE_PRICE) {
6065                        if (this.element.CONFIG.SHOW_OLD_PRICE === "Y") {
6066                            this.nodes.obPrice.old.classList.remove("d-none");
6067                            this.nodes.obPrice.old.innerHTML = price.PRINT_BASE_PRICE;
6068
6069                            if (this.element.CONFIG.SHOW_DISCOUNT_PERCENT === "Y" && price.PERCENT > 0) {
6070                                this.nodes.obPrice.percent.innerHTML = (-price.PERCENT) + "%";
6071                                this.nodes.obPrice.percent.classList.remove('d-none');
6072                            } else {
6073                                this.nodes.obPrice.percent.classList.add('d-none');
6074                            }
6075                        }
6076                    } else {
6077                        this.nodes.obPrice.old.classList.add("d-none");
6078                        this.nodes.obPrice.percent.classList.add('d-none');
6079                    }
6080                } else {
6081                    this.nodes.obPrice.price.innerHTML = "";
6082                    blockPrice.classList.add("d-none");
6083                }
6084            }
6085        },
6086
6087        checkPriceRange: function (quantity) {
6088            if (typeof quantity === 'undefined' || this.currentElement.ITEM_PRICE_MODE !== 'Q')
6089                return;
6090
6091
6092            var range, found = false;
6093
6094            for (var i in this.currentElement.ITEM_QUANTITY_RANGES) {
6095                if (this.currentElement.ITEM_QUANTITY_RANGES.hasOwnProperty(i)) {
6096                    range = this.currentElement.ITEM_QUANTITY_RANGES[i];
6097
6098
6099                    if (
6100                        parseFloat(quantity) >= parseFloat(range.SORT_FROM) &&
6101                        (
6102                            range.SORT_TO === 'INF' ||
6103                            parseFloat(quantity) <= parseFloat(range.SORT_TO)
6104                        )
6105                    ) {
6106                        found = true;
6107                        this.currentElement.ITEM_QUANTITY_RANGE_SELECTED = range.HASH;
6108                        break;
6109                    }
6110                }
6111            }
6112
6113            if (!found && (range = this.getMinPriceRange())) {
6114                this.currentElement.ITEM_QUANTITY_RANGE_SELECTED = range.HASH;
6115            }
6116
6117            for (var k in this.currentElement.ITEM_PRICES) {
6118                if (this.currentElement.ITEM_PRICES.hasOwnProperty(k)) {
6119                    if (this.currentElement.ITEM_PRICES[k].QUANTITY_HASH == this.currentElement.ITEM_QUANTITY_RANGE_SELECTED) {
6120                        this.currentElement.ITEM_PRICE_SELECTED = k;
6121                        break;
6122                    }
6123                }
6124            }
6125        },
6126
6127        getMinPriceRange: function () {
6128            var range;
6129
6130            for (var i in this.currentElement.ITEM_QUANTITY_RANGES) {
6131                if (this.currentElement.ITEM_QUANTITY_RANGES.hasOwnProperty(i)) {
6132                    if (
6133                        !range ||
6134                        parseInt(this.currentElement.ITEM_QUANTITY_RANGES[i].SORT_FROM) < parseInt(range.SORT_FROM)
6135                    ) {
6136                        range = this.currentElement.ITEM_QUANTITY_RANGES[i];
6137                    }
6138                }
6139            }
6140
6141            return range;
6142        },
6143
6144        checkQuantityControls: function () {
6145            if (!this.nodes.obQuantity)
6146                return;
6147
6148
6149            var reachedTopLimit = this.element.CONFIG.SHOW_QUANTITY === "Y" && parseFloat(this.nodes.obQuantity.value) + this.currentElement.STEP_QUANTITY > this.currentElement.MAX_QUANTITY,
6150                reachedBottomLimit = parseFloat(this.nodes.obQuantity.value) - this.currentElement.STEP_QUANTITY < this.currentElement.MIN_QUANTITY;
6151
6152
6153            if (reachedTopLimit)
6154                BX.addClass(this.nodes.obQuantityUp, 'product-item-amount-field-btn-disabled');
6155
6156            else if (BX.hasClass(this.nodes.obQuantityUp, 'product-item-amount-field-btn-disabled')) {
6157                BX.removeClass(this.nodes.obQuantityUp, 'product-item-amount-field-btn-disabled');
6158            }
6159
6160            if (reachedBottomLimit)
6161                BX.addClass(this.nodes.obQuantityDown, 'product-item-amount-field-btn-disabled');
6162
6163            else if (BX.hasClass(this.nodes.obQuantityDown, 'product-item-amount-field-btn-disabled')) {
6164                BX.removeClass(this.nodes.obQuantityDown, 'product-item-amount-field-btn-disabled');
6165            }
6166
6167            if (reachedTopLimit && reachedBottomLimit)
6168                this.nodes.obQuantity.setAttribute('disabled', 'disabled');
6169
6170            else {
6171                this.nodes.obQuantity.removeAttribute('disabled');
6172            }
6173        },
6174
6175        quantityUp: function () {
6176
6177            var curValue = 0,
6178                boolSet = true;
6179
6180            if (this.errorCode === 0 && this.element.CONFIG.SHOW_QUANTITY === "Y" && this.currentElement.CAN_BUY) {
6181
6182                curValue = this.currentElement.QUANTITY_FLOAT ? parseFloat(this.nodes.obQuantity.value) : parseInt(this.nodes.obQuantity.value, 10);
6183
6184
6185                if (!isNaN(curValue)) {
6186
6187                    curValue += this.currentElement.STEP_QUANTITY;
6188
6189                    curValue = this.checkQuantityRange(curValue, 'up');
6190
6191                    if (this.currentElement.CHECK_QUANTITY && curValue > this.currentElement.MAX_QUANTITY) {
6192                        boolSet = false;
6193                    }
6194
6195                    if (boolSet) {
6196                        if (this.currentElement.QUANTITY_FLOAT) {
6197                            curValue = Math.round(curValue * this.element.precisionFactor) / this.element.precisionFactor;
6198                        }
6199
6200
6201
6202                        this.nodes.obQuantity.value = curValue;
6203
6204                        this.setPrice();
6205                    }
6206                }
6207            }
6208        },
6209
6210        quantityDown: function () {
6211            var curValue = 0,
6212                boolSet = true;
6213
6214            if (this.errorCode === 0 && this.element.CONFIG.SHOW_QUANTITY === "Y" && this.currentElement.CAN_BUY) {
6215                curValue = this.currentElement.QUANTITY_FLOAT ? parseFloat(this.nodes.obQuantity.value) : parseInt(this.nodes.obQuantity.value, 10);
6216
6217                if (!isNaN(curValue)) {
6218                    curValue -= this.currentElement.STEP_QUANTITY;
6219
6220                    curValue = this.checkQuantityRange(curValue, 'down');
6221
6222                    if (curValue < this.currentElement.MIN_QUANTITY) {
6223                        boolSet = false;
6224                    }
6225
6226                    if (boolSet) {
6227                        if (this.currentElement.QUANTITY_FLOAT) {
6228                            curValue = Math.round(curValue * this.element.precisionFactor) / this.element.precisionFactor;
6229                        }
6230
6231                        this.nodes.obQuantity.value = curValue;
6232
6233                        this.setPrice();
6234                    }
6235                }
6236            }
6237        },
6238
6239        quantityChange: function () {
6240            var curValue = 0,
6241                intCount;
6242
6243
6244            if (this.errorCode === 0 && this.element.CONFIG.SHOW_QUANTITY === "Y") {
6245
6246                if (this.currentElement.CAN_BUY) {
6247
6248                    curValue = this.currentElement.QUANTITY_FLOAT ? parseFloat(this.nodes.obQuantity.value) : Math.round(this.nodes.obQuantity.value);
6249
6250
6251                    if (!isNaN(curValue)) {
6252                        curValue = this.checkQuantityRange(curValue);
6253
6254                        if (this.currentElement.CHECK_QUANTITY) {
6255                            if (curValue > this.currentElement.MAX_QUANTITY) {
6256                                curValue = this.currentElement.MAX_QUANTITY;
6257                            }
6258                        }
6259
6260                        this.checkPriceRange(curValue);
6261
6262                        if (curValue < this.currentElement.MIN_QUANTITY) {
6263                            curValue = this.currentElement.MIN_QUANTITY;
6264                        } else {
6265                            intCount = Math.round(
6266                                Math.round(curValue * this.element.precisionFactor / this.currentElement.STEP_QUANTITY) / this.element.precisionFactor
6267                            ) || 1;
6268
6269
6270                            curValue = (intCount <= 1 ? this.currentElement.STEP_QUANTITY : intCount * this.currentElement.STEP_QUANTITY);
6271
6272                            curValue = Math.round(curValue * this.element.precisionFactor) / this.element.precisionFactor;
6273
6274                        }
6275
6276
6277                        this.nodes.obQuantity.value = curValue;
6278                    } else {
6279                        this.nodes.obQuantity.value = this.currentElement.MIN_QUANTITY;
6280                    }
6281                } else {
6282                    this.nodes.obQuantity.value = this.currentElement.MIN_QUANTITY;
6283                }
6284
6285                this.setPrice();
6286            }
6287
6288        },
6289
6290        checkQuantityRange: function (quantity, direction) {
6291            if (typeof quantity === 'undefined' || this.currentElement.ITEM_PRICE_MODE !== 'Q') {
6292                return quantity;
6293            }
6294
6295            quantity = parseFloat(quantity);
6296
6297            var nearestQuantity = quantity;
6298            var range, diffFrom, absDiffFrom, diffTo, absDiffTo, shortestDiff;
6299
6300            for (var i in this.currentQuantityRanges) {
6301                if (this.currentQuantityRanges.hasOwnProperty(i)) {
6302                    range = this.currentQuantityRanges[i];
6303
6304                    if (
6305                        parseFloat(quantity) >= parseFloat(range.SORT_FROM) &&
6306                        (
6307                            range.SORT_TO === 'INF' ||
6308                            parseFloat(quantity) <= parseFloat(range.SORT_TO)
6309                        )
6310                    ) {
6311                        nearestQuantity = quantity;
6312                        break;
6313                    } else {
6314                        diffFrom = parseFloat(range.SORT_FROM) - quantity;
6315                        absDiffFrom = Math.abs(diffFrom);
6316                        diffTo = parseFloat(range.SORT_TO) - quantity;
6317                        absDiffTo = Math.abs(diffTo);
6318
6319                        if (shortestDiff === undefined || shortestDiff > absDiffFrom) {
6320                            if (
6321                                direction === undefined ||
6322                                (direction === 'up' && diffFrom > 0) ||
6323                                (direction === 'down' && diffFrom < 0)
6324                            ) {
6325                                shortestDiff = absDiffFrom;
6326                                nearestQuantity = parseFloat(range.SORT_FROM);
6327                            }
6328                        }
6329
6330                        if (shortestDiff === undefined || shortestDiff > absDiffTo) {
6331                            if (
6332                                direction === undefined ||
6333                                (direction === 'up' && diffFrom > 0) ||
6334                                (direction === 'down' && diffFrom < 0)
6335                            ) {
6336                                shortestDiff = absDiffTo;
6337                                nearestQuantity = parseFloat(range.SORT_TO);
6338                            }
6339                        }
6340                    }
6341                }
6342            }
6343
6344            return nearestQuantity;
6345        },
6346
6347        getCanBuy: function (arFilter) {
6348            var i,
6349                j = 0,
6350                boolOneSearch = true,
6351                boolSearch = false;
6352
6353            for (i = 0; i < this.element.OFFERS.length; i++) {
6354                boolOneSearch = true;
6355
6356                for (j in arFilter) {
6357                    if (arFilter[j] !== this.element.OFFERS[i].TREE[j]) {
6358                        boolOneSearch = false;
6359                        break;
6360                    }
6361                }
6362
6363                if (boolOneSearch) {
6364                    if (this.element.OFFERS[i].CAN_BUY) {
6365                        boolSearch = true;
6366                        break;
6367                    }
6368                }
6369            }
6370
6371            return boolSearch;
6372        },
6373
6374        updateInfoBasketOffer: function (id, parent) {
6375            parent = parent || '';
6376
6377            if (parent.length > 0)
6378                parent = "#" + parent;
6379
6380
6381            $(parent + ' .add2basket').attr('data-item', id);
6382            $(parent + ' .move2basket').attr('data-item', id);
6383            $(parent + ' .quantity-block').attr('data-item', id);
6384            $(parent + ' .delay').attr('data-item', id);
6385            $(parent + ' .compare').attr('data-item', id);
6386        },
6387
6388        setPriceMatrix: function (sPriceMatrix) {
6389            if (sPriceMatrix.length > 0) {
6390                this.nodes.obPriceMatrix.classList.remove('d-none');
6391                this.nodes.obPriceMatrix.innerHTML = sPriceMatrix;
6392            } else {
6393                this.nodes.obPriceMatrix.classList.add('d-none');
6394                this.nodes.obPriceMatrix.innerHTML = '';
6395            }
6396        },
6397
6398        quantitySet: function () {
6399            var strLimit, resetQuantity;
6400
6401            var newOffer = this.currentElement,
6402                oldOffer = this.oldElement;
6403
6404            if (this.errorCode === 0) {
6405
6406                this.currentElement.CAN_BUY = newOffer.CAN_BUY;
6407
6408                this.currentElement.QUANTITY_FLOAT = newOffer.QUANTITY_FLOAT;
6409                this.element.CHECK_QUANTITY = newOffer.CHECK_QUANTITY;
6410
6411
6412
6413                if (this.currentElement.QUANTITY_FLOAT) {
6414                    this.currentElement.STEP_QUANTITY = Math.round(parseFloat(newOffer.STEP_QUANTITY) * this.element.precisionFactor) / this.element.precisionFactor;
6415                    this.currentElement.MAX_QUANTITY = parseFloat(newOffer.MAX_QUANTITY);
6416                    this.currentElement.MIN_QUANTITY = this.currentElement.ITEM_PRICE_MODE === 'Q' ? parseFloat(this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].MIN_QUANTITY) : this.currentElement.STEP_QUANTITY;
6417                } else {
6418                    this.currentElement.STEP_QUANTITY = parseInt(newOffer.STEP_QUANTITY, 10);
6419                    this.currentElement.MAX_QUANTITY = parseInt(newOffer.MAX_QUANTITY, 10);
6420                    this.currentElement.MIN_QUANTITY = this.currentElement.ITEM_PRICE_MODE === 'Q' ? parseInt(this.currentElement.ITEM_PRICES[this.currentElement.ITEM_PRICE_SELECTED].MIN_QUANTITY) : this.currentElement.STEP_QUANTITY;
6421                }
6422
6423
6424
6425                if (this.element.CONFIG.SHOW_QUANTITY) {
6426                    var isDifferentMinQuantity = oldOffer.ITEM_PRICES.length &&
6427                        oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED] &&
6428                        oldOffer.ITEM_PRICES[oldOffer.ITEM_PRICE_SELECTED].MIN_QUANTITY != this.currentElement.MIN_QUANTITY;
6429
6430                    if (this.currentElement.QUANTITY_FLOAT) {
6431                        resetQuantity = Math.round(parseFloat(oldOffer.STEP_QUANTITY) * this.element.precisionFactor) / this.element.precisionFactor !== this.currentElement.STEP_QUANTITY ||
6432                            isDifferentMinQuantity ||
6433                            oldOffer.MEASURE !== newOffer.MEASURE ||
6434                            (
6435                                this.currentElement.CHECK_QUANTITY &&
6436                                parseFloat(oldOffer.MAX_QUANTITY) > this.currentElement.MAX_QUANTITY &&
6437                                parseFloat(this.nodes.obQuantity.value) > this.currentElement.MAX_QUANTITY
6438                            );
6439                    } else {
6440                        resetQuantity = parseInt(oldOffer.STEP_QUANTITY, 10) !== this.currentElement.STEP_QUANTITY ||
6441                            isDifferentMinQuantity ||
6442                            oldOffer.MEASURE !== newOffer.MEASURE ||
6443                            (
6444                                this.currentElement.CHECK_QUANTITY &&
6445                                parseInt(oldOffer.MAX_QUANTITY, 10) > this.currentElement.MAX_QUANTITY &&
6446                                parseInt(this.nodes.obQuantity.value, 10) > this.currentElement.MAX_QUANTITY
6447                            );
6448                    }
6449
6450                    this.nodes.obQuantity.disabled = !this.currentElement.CAN_BUY;
6451
6452                    if (resetQuantity) {
6453                        this.nodes.obQuantity.value = this.currentElement.MIN_QUANTITY;
6454                    }
6455                }
6456
6457                if (this.nodes.obMeasure) {
6458
6459                    if (newOffer.MEASURE_HTML) {
6460                        BX.adjust(this.nodes.obMeasure, {
6461                            html: newOffer.MEASURE_HTML,
6462                            style: {
6463                                display: ''
6464                            }
6465                        });
6466                    } else {
6467                        BX.adjust(this.nodes.obMeasure, {
6468                            html: '',
6469                            style: {
6470                                display: 'none'
6471                            }
6472                        });
6473                    }
6474                }
6475
6476            }
6477        },
6478
6479        changeText: function (ob, text) {
6480            if (text.length > 0) {
6481
6482                ob.innerHTML = text;
6483                ob.classList.remove('d-none');
6484                
6485            } else {
6486                ob.classList.add('d-none');
6487                ob.innerHTML = '';
6488            }
6489        },
6490
6491        setCompared: function (state) {
6492            if (!this.nodes.obCompare)
6493                return;
6494
6495            var checkbox = this.nodes.obCompare.querySelector('[data-entity="compare-checkbox"]');
6496            if (checkbox) {
6497                checkbox.checked = state;
6498            }
6499        },
6500
6501        drawPicture: function () {
6502            if (this.nodes.obPict) {
6503                BX.adjust(this.nodes.obPict, {
6504
6505                    props: {
6506                        src: this.currentElement.PHOTO,
6507                        alt: this.element.ALT
6508                    },
6509
6510                });
6511            }
6512        },
6513
6514        changeCharsBlock: function () {
6515            var html = "",
6516                showChars = false;
6517
6518
6519            if (this.nodes.obSkuChars) {
6520                if (this.currentElement.SKU_LIST_CHARS.length) {
6521                    if (this.element.VIEW == "LIST") {
6522                        for (i = 0; i < this.currentElement.SKU_LIST_CHARS.length; i++) {
6523                            html += "<div class='characteristics-item'>";
6524                            html += "<span class='characteristics-item-name'>" + this.currentElement.SKU_LIST_CHARS[i].NAME + " - </span>";
6525                            html += "<span class='characteristics-item-value'>" + this.currentElement.SKU_LIST_CHARS[i].VALUE + "</span>";
6526                            html += "</div>";
6527                        }
6528                    } else {
6529                        for (i = 0; i < this.currentElement.SKU_LIST_CHARS.length; i++) {
6530                            html += "<div class='characteristics-item'>";
6531                            html += "<span class='characteristics-item-name bold'>" + this.currentElement.SKU_LIST_CHARS[i].NAME + ": </span>";
6532                            html += "<span class='characteristics-item-value'>" + this.currentElement.SKU_LIST_CHARS[i].VALUE + "</span>";
6533                            html += "</div>";
6534                        }
6535                    }
6536
6537
6538                    html = "<div class='characteristics'>" + html + "</div>";
6539                }
6540
6541                BX.adjust(this.nodes.obSkuChars, {
6542                    html: html
6543                });
6544            }
6545
6546            if (this.element.PROPS_CHARS.length > 0 || this.element.PROP_CHARS.length > 0 || this.currentElement.SKU_LIST_CHARS.length > 0) {
6547                showChars = true;
6548            }
6549
6550            var wrChars = this.nodes.obProduct.querySelector('.wrapper-characteristics');
6551
6552
6553            if (wrChars) {
6554
6555                if (showChars)
6556                    wrChars.classList.remove('hidden');
6557
6558                else {
6559                    wrChars.classList.add('hidden');
6560                }
6561            }
6562
6563        },
6564
6565        changeDetailUrl: function (ID) {
6566
6567            if (this.nodes.obDetailUrlImg)
6568                this.nodes.obDetailUrlImg.href = this.currentElement.DETAIL_PAGE_URL;
6569
6570            if (this.nodes.obName)
6571                this.nodes.obName.href = this.currentElement.DETAIL_PAGE_URL;
6572
6573        },
6574
6575        hideBtns: function () {
6576            this.nodes.obWrAdd2BasketBtn.classList.remove('active');
6577            this.nodes.obWrAdd2BasketBtn.classList.add('d-none');
6578            this.nodes.obBtn2pageProduct.classList.remove('d-none');
6579
6580        },
6581
6582        showBtns: function () {
6583            this.nodes.obWrAdd2BasketBtn.classList.add('active');
6584            this.nodes.obWrAdd2BasketBtn.classList.remove('d-none');
6585            this.nodes.obBtn2pageProduct.classList.add('d-none');
6586        },
6587
6588        btnsControl: function () {
6589            var show = false;
6590
6591
6592
6593            if ((this.currentElement.CAN_BUY && this.currentElement.MODE_DISALLOW_ORDER != "Y") && (this.currentElement.SHOWPREORDERBTN || this.currentElement.MODE_ARCHIVE))
6594                show = true;
6595
6596            if (this.currentElement.SHOW_BTN_BASKET === 'Y' && this.currentElement.CAN_BUY)
6597                show = true;
6598            else
6599            {
6600                show = false;
6601            }
6602
6603            if(this.currentElement.ISOFFERS && this.currentElement.VIEW === 'FLAT SLIDER')
6604                show = false;
6605            
6606
6607            if (show)
6608                this.showBtns();
6609            else
6610            {
6611                this.hideBtns();
6612            }
6613        },
6614
6615    };
6616
6617})(window);
6618
6619
6620$(document).on('click', '.small-picture', function () {
6621    $(this).parents(".wrapper-picture").find(".big-picture").removeClass('active');
6622    $(this).parents(".wrapper-picture").find(".small-picture").removeClass('active');
6623
6624    $(this).addClass('active');
6625    $(this).parents(".wrapper-picture").find(".big-picture[data-id='" + $(this).attr("data-value") + "']").addClass('active');
6626
6627    if ($(this).hasClass('popup-control')) {
6628        $('#sliderPopup').attr('data-current-image', $(this).attr("data-value"));
6629    }
6630});
6631
6632var popupGalleryCollection = [];
6633
6634function popupGallery(id) {
6635
6636    if (typeof ($(".open-popup-gallery-item[data-popup-gallery='" + id + "']")) != "undefined") {
6637
6638        if ($(".open-popup-gallery-item[data-popup-gallery='" + id + "']").length > 0) {
6639
6640            $(".open-popup-gallery-item[data-popup-gallery='" + id + "']").each(
6641                function (index) {
6642                    popupGalleryCollection[index] = {
6643                        "smallSrc": $(this).attr("data-small-src"),
6644                        "bigSrc": $(this).attr("data-big-src"),
6645                        "desc": $(this).attr("data-desc"),
6646                    };
6647
6648                    if ($(this).parents(".big-picture").hasClass('active'))
6649                        popupGalleryCollection[index]["active"] = "Y";
6650
6651
6652                }
6653            );
6654
6655            sliderPopup(popupGalleryCollection);
6656
6657        }
6658    }
6659
6660}
6661
6662function sliderPopup(images) {
6663    if (images && BX.type.isArray(images)) {
6664
6665        var nodeControlPics = $("#sliderPopup").find(".controls-pictures"),
6666            nodeBigPics = $("#sliderPopup").find(".wrapper-big-picture"),
6667            nodeControlPicsParent = nodeControlPics.parent(),
6668            nodeBigPicsParent = nodeBigPics.parent(),
6669            listControl = "",
6670            listBigPic = "";
6671
6672        nodeControlPics.html("");
6673        nodeBigPics.html("");
6674
6675        if (images.length > 0) {
6676
6677            for (i = 0; i < images.length; i++) {
6678
6679                listControl += "<div data-value='" + i + "'";
6680                listControl += "class='small-picture popup-control";
6681
6682                if (images[i].active == "Y") {
6683                    listControl += " active";
6684                    $("#sliderPopup").attr("data-current-image", i);
6685                }
6686                listControl += "'>";
6687
6688
6689                listControl += "<img src='" + images[i].smallSrc + "' alt = '";
6690
6691                if (images[i].desc)
6692                    listControl += images[i].desc;
6693
6694                listControl += "'/>";
6695
6696                listControl += "</div>";
6697
6698
6699                listBigPic += "<div data-id='" + i + "'";
6700                listBigPic += "class='big-picture";
6701
6702                if (images[i].active == "Y")
6703                    listBigPic += " active";
6704
6705                if (images[i].desc)
6706                    listBigPic += " with-desc";
6707
6708                listBigPic += "'>";
6709
6710
6711                listBigPic += "<img src='" + images[i].bigSrc + "' class='d-block mx-auto img-fluid' alt = '";
6712
6713                if (images[i].desc)
6714                    listBigPic += images[i].desc;
6715
6716                listBigPic += "'/>";
6717
6718                if (images[i].desc)
6719                    listBigPic += "<div class='desc-img'>" + images[i].desc + "</div>";
6720
6721
6722                listBigPic += "</div>";
6723
6724            }
6725
6726        }
6727
6728        nodeBigPics.html(listBigPic);
6729        nodeControlPics.html(listControl);
6730
6731
6732    }
6733}
6734
6735function destroyPopupGallery() {
6736    popupGalleryCollection = [];
6737    $('#sliderPopup').removeClass('active');
6738    $('body').removeClass('modal-open');
6739
6740    $('#sliderPopup').find(".wrapper-big-picture").children().remove();
6741    $('#sliderPopup').find(".controls-pictures").children().remove();
6742
6743
6744}
6745
6746$(document).on('click', '.open-popup-gallery', function () {
6747    $('.popup-slider').addClass('active');
6748    $('body').addClass('modal-open');
6749    popupGallery($(this).attr("data-popup-gallery"));
6750
6751});
6752
6753
6754$(document).on('click', '.wrapper-select-input', function () {
6755    if (!$(this).hasClass('open'))
6756        $(this).addClass('open');
6757
6758    else {
6759        $(this).removeClass('open');
6760    }
6761
6762});
6763
6764
6765
6766
6767
6768
6769
6770function setCurrentPopupSlide(slideID) {
6771    $('#sliderPopup').find(".small-picture").removeClass('active');
6772    $('#sliderPopup').find(".big-picture").removeClass('active');
6773
6774    $('#sliderPopup').find(".small-picture[data-value='" + slideID + "']").addClass('active');
6775    $('#sliderPopup').find(".big-picture[data-id='" + slideID + "']").addClass('active');
6776
6777    $('#sliderPopup').attr("data-current-image", slideID);
6778}
6779
6780function slidePopupControl(btn, action) {
6781    var arSlider = $('#sliderPopup').find(".controls-pictures").children(),
6782        curSlide = $('#sliderPopup').attr("data-current-image");
6783
6784
6785    for (var i = 0; arSlider.length > i; i++) {
6786        if (i == curSlide) {
6787            if (action == "prev") {
6788                curSlide = i - 1;
6789            }
6790
6791            if (action == "next") {
6792                curSlide = i + 1;
6793            }
6794
6795            if (curSlide > arSlider.length - 1) {
6796                curSlide = 0;
6797            }
6798            if (curSlide < 0) {
6799                curSlide = arSlider.length - 1;
6800            }
6801
6802            if (typeof curSlide !== "undefined") {
6803                setCurrentPopupSlide(curSlide);
6804            }
6805
6806            return;
6807        }
6808    }
6809}
6810
6811$(document).on('click', '.nav-item.action_prev', function () {
6812    slidePopupControl($(this), 'prev');
6813});
6814$(document).on('click', '.nav-item.action_next', function () {
6815    slidePopupControl($(this), 'next');
6816});
6817
6818
6819$(document).on('click', '.btn-open-hidden-board', function () {
6820    $(".content-hidden-board[data-content=" + $(this).attr("data-open") + "]").addClass('active');
6821    $(".catalog-list-wrap.z-index-99").removeClass('z-index-99');
6822});
6823
6824$(document).on('click', '.btn-close-hidden-board', function () {
6825    $(".content-hidden-board[data-content=" + $(this).attr("data-close") + "]").removeClass('active');
6826});
6827
6828$(document).mouseup(function (e) {
6829    var div = $(".content-hidden-board.active");
6830
6831    if (!div.is(e.target) && div.has(e.target).length === 0) {
6832        div.removeClass('active');
6833    }
6834});
6835
6836if ($(window).width() > 1200) {
6837    $(document).on({
6838            mouseenter: function () {
6839
6840                var total = parseInt($(this).find('.elem-hover-height-more').css(
6841                    'margin-bottom')) + $(this).find('.elem-hover-height').outerHeight(
6842                    true);
6843
6844                $(this).css({
6845                    'height': total + 'px'
6846                });
6847                $(this).find('div.elem-hover-show').slideDown(250);
6848            },
6849
6850            mouseleave: function () {
6851                $(this).find('div.elem-hover-show').slideUp(0);
6852            },
6853        },
6854        ".elem-hover"
6855    );
6856
6857}
6858
6859$(document).on('click', '.section-with-hidden-items .head-filter',
6860    function () {
6861        var btn = $(this);
6862        var content = $(".content-animate-slide-down[data-show ='" + btn.attr("data-show") + "']");
6863        var btns = $(".click-animate-slide-down[data-show ='" + btn.attr("data-show") + "']");
6864
6865        content.slideUp(400, function () {
6866            btns.addClass('noactive-mob').removeClass('active-mob');
6867            content.addClass('noactive-mob').removeClass('active-mob');
6868        });
6869    }
6870);
6871
6872$(document).on('click', '.click-animate-slide-down',
6873    function () {
6874        var btn = $(this);
6875        var content = $(".content-animate-slide-down[data-show ='" + btn.attr("data-show") + "']");
6876
6877        if ($(window).width() > 768) {
6878
6879            if (!btn.hasClass('active')) {
6880                content.slideDown(400, function () {
6881                    btn.addClass('active').removeClass('noactive');
6882                    content.addClass('active').removeClass('noactive');
6883                });
6884                BX.setCookie($(".domen-url-for-cookie").val() + '_phoenix_catalog_tab_' + btn.attr("data-show") + $("input.site_id").val(), 'active', {
6885                    expires: 60 * 60 * 60 * 60,
6886                    path: "/"
6887                });
6888            } else {
6889                content.slideUp(400, function () {
6890                    btn.addClass('noactive').removeClass('active');
6891                    content.addClass('noactive').removeClass('active');
6892                });
6893                BX.setCookie($(".domen-url-for-cookie").val() + '_phoenix_catalog_tab_' + btn.attr("data-show") + $("input.site_id").val(), 'noactive', {
6894                    expires: 60 * 60 * 60 * 60,
6895                    path: "/"
6896                });
6897            }
6898
6899        } else {
6900            if (!btn.hasClass('active-mob')) {
6901                content.addClass('active-mob').removeClass('noactive-mob');
6902                content.slideDown(400, function () {
6903                    btn.addClass('active-mob').removeClass('noactive-mob');
6904                });
6905
6906            } else {
6907                content.slideUp(400, function () {
6908                    btn.addClass('noactive-mob').removeClass('active-mob');
6909                    content.addClass('noactive-mob').removeClass('active-mob');
6910                });
6911            }
6912        }
6913
6914    }
6915);
6916
6917$(document).on('click', '.btn-hide-column',
6918    function () {
6919
6920        if (!$(this).hasClass('active')) {
6921
6922            if ($('div.menu-banner-slider').hasClass('slick-initialized'))
6923                $('div.menu-banner-slider').slick('unslick');
6924
6925            $('div.menu-banner-slider').slick({
6926                slidesToShow: 1,
6927                slidesToScroll: 1,
6928                autoplay: true,
6929                autoplaySpeed: 5000,
6930                dots: false,
6931                infinite: true,
6932                adaptiveHeight: false,
6933                speed: 500,
6934                arrows: false
6935            });
6936
6937            $(this).addClass('active');
6938            $('.parent-hide-column').removeClass('hide');
6939            /*$('.catalog-list-wrap .catalog-list').addClass('three-col').removeClass('four-col');*/
6940            BX.setCookie($(".domen-url-for-cookie").val() + '_phoenix_catalog_side_column_' + $("input.site_id").val(), 'Y', {
6941                expires: 60 * 60 * 60 * 60,
6942                path: "/"
6943            });
6944        } else {
6945
6946            if ($('div.menu-banner-slider').hasClass('slick-initialized'))
6947                $('div.menu-banner-slider').slick('unslick');
6948            
6949            $(this).removeClass('active');
6950            $('.parent-hide-column').addClass('hide');
6951            /*$('.catalog-list-wrap .catalog-list').removeClass('three-col').addClass('four-col');*/
6952            BX.setCookie($(".domen-url-for-cookie").val() + '_phoenix_catalog_side_column_' + $("input.site_id").val(), 'N', {
6953                expires: 60 * 60 * 60 * 60,
6954                path: "/"
6955            });
6956        }
6957
6958        showProcessLoad();
6959
6960        updateCatalogList();
6961    }
6962);
6963
6964function updateCatalogList($params) {
6965    $params = $params || {
6966        "ajax_action": "Y"
6967    };
6968    showProcessLoad();
6969
6970    $('.element-list-wrap').removeClass("active");
6971
6972    $.post(
6973        location.href,
6974        $params,
6975        function (html) {
6976            closeProcessLoad();
6977
6978            $('.element-list-wrap').html(html);
6979            $('.element-list-wrap').addClass("active");
6980            $('.lazyload').Lazy(paramsLazy);
6981            setInfoBasket("firstLoad");
6982        }
6983    );
6984
6985}
6986
6987$(document).on('click', '.sort_btn_js',
6988    function () {
6989        var sort = $(this).attr("data-sort"),
6990            order = $(this).attr("data-order"),
6991            _th = $(this),
6992            available = null;
6993
6994        _th.parents(".element-sort").find(".sort_btn_js").removeClass('active');
6995        _th.addClass('active');
6996
6997        if (_th.hasClass('asc')) {
6998            _th.removeClass('asc').addClass('desc');
6999            _th.attr("data-order", "asc");
7000        } else if (_th.hasClass('desc')) {
7001            _th.removeClass('desc').addClass('asc');
7002            _th.attr("data-order", "desc");
7003        }
7004
7005        if($('.sort-available-js').length>0)
7006        {
7007            if ($('.sort-available-js').attr("data-available") == "Y") {
7008                available = 'N';
7009            } else {
7010                available = 'Y';
7011            }
7012        }
7013        
7014
7015        var $params = {
7016            "ajax_action": "Y",
7017            "sort": sort,
7018            "order": order,
7019        };
7020
7021        if(available)
7022            $params['available'] = available;
7023
7024        updateCatalogList($params);
7025
7026    }
7027);
7028
7029$(document).on('click', '.sort-available-js',
7030    function () {
7031        var $params = {
7032            "ajax_action": "Y",
7033            "available": $(this).attr("data-available")
7034        };
7035
7036
7037        if ($(this).attr("data-available") == "Y") {
7038            $(this).attr("data-available", "N");
7039            $(this).addClass("active");
7040        } else {
7041            $(this).attr("data-available", "Y");
7042            $(this).removeClass("active");
7043        }
7044
7045
7046        updateCatalogList($params);
7047    }
7048);
7049
7050$(document).on('click', '.display-view-js',
7051    function () {
7052
7053        if (!$(this).hasClass('active')) {
7054            var $params = {
7055                "ajax_action": "Y",
7056                "view": $(this).attr("data-view")
7057            };
7058
7059            $(this).parents('.view-list').find('.display-view-js').removeClass('active');
7060            $(this).addClass('active');
7061
7062            updateCatalogList($params);
7063
7064        }
7065
7066    }
7067);
7068
7069$(document).on('click', '.toogle-animate-click',
7070    function () {
7071        var block = $(this).parents(".toogle-animate-parent");
7072        if (!block.hasClass("active")) {
7073            $(".toogle-animate-content", block).slideDown(200, function () {
7074                block.addClass("active");
7075            });
7076        } else {
7077            $(".toogle-animate-content", block).slideUp(200, function () {
7078                block.removeClass("active");
7079            });
7080        }
7081    }
7082);
7083
7084$(document).on('click', 'div.bx_sort_container ul.tabs-head li',
7085    function () {
7086        if (!$(this).hasClass("current"))
7087            location.href = $(this).find("span").attr("data-href");
7088    }
7089);
7090
7091
7092
7093BasketPoolQuantity = function () {
7094    this.processing = false;
7095    this.poolQuantity = {};
7096    this.updateTimer = null;
7097    this.currentQuantity = {};
7098    this.lastStableQuantities = {};
7099
7100    this.updateQuantity();
7101};
7102
7103
7104BasketPoolQuantity.prototype.updateQuantity = function () {
7105
7106    if (BX('basket_items')) {
7107        var items = BX('basket_items').querySelectorAll('div.product');
7108
7109        if (!!items && items.length > 0) {
7110            for (var i = 0; items.length > i; i++) {
7111                var itemId = items[i].id;
7112                this.currentQuantity[itemId] = BX('QUANTITY_' + itemId).value;
7113            }
7114        }
7115
7116
7117        this.lastStableQuantities = BX.clone(this.currentQuantity, true);
7118    }
7119
7120
7121};
7122
7123BasketPoolQuantity.prototype.changeQuantity = function (itemId) {
7124    var quantity = BX('QUANTITY_' + itemId).value;
7125    var isPoolEmpty = this.isPoolEmpty();
7126
7127    if (this.currentQuantity[itemId] && this.currentQuantity[itemId] != quantity) {
7128        this.poolQuantity[itemId] = this.currentQuantity[itemId] = quantity;
7129    }
7130
7131    if (!isPoolEmpty) {
7132        this.enableTimer(true);
7133    } else {
7134        this.trySendPool();
7135    }
7136};
7137
7138
7139BasketPoolQuantity.prototype.trySendPool = function () {
7140
7141    if (!this.isPoolEmpty() && !this.isProcessing()) {
7142        this.enableTimer(false);
7143
7144        recalcBasketAjax({});
7145
7146    }
7147};
7148
7149BasketPoolQuantity.prototype.isPoolEmpty = function () {
7150    return (Object.keys(this.poolQuantity).length == 0);
7151};
7152
7153BasketPoolQuantity.prototype.clearPool = function () {
7154    this.poolQuantity = {};
7155};
7156
7157BasketPoolQuantity.prototype.isProcessing = function () {
7158    return (this.processing === true);
7159};
7160
7161BasketPoolQuantity.prototype.setProcessing = function (value) {
7162    this.processing = (value === true);
7163};
7164
7165BasketPoolQuantity.prototype.enableTimer = function (value) {
7166    clearTimeout(this.updateTimer);
7167    if (value === false)
7168        return;
7169
7170    this.updateTimer = setTimeout(function () {
7171        basketPoolQuantity.trySendPool();
7172    }, 1500);
7173};
7174
7175function updateQuantity(controlId, basketId, ratio, bUseFloatQuantity) {
7176    clearTimeout($.data(this, 'timer-quantity'));
7177
7178    $.data(this, 'timer-quantity', setTimeout($.proxy(function () {
7179
7180        var oldVal = BX(controlId).defaultValue,
7181            newVal = parseFloat(BX(controlId).value) || 0,
7182            bIsCorrectQuantityForRatio = false,
7183            autoCalculate = ((BX("auto_calculation") && BX("auto_calculation").value == "Y") || !BX("auto_calculation"));
7184
7185
7186
7187
7188        if (ratio === 0 || ratio == 1) {
7189            bIsCorrectQuantityForRatio = true;
7190        } else {
7191
7192            var newValInt = newVal * 10000,
7193                ratioInt = ratio * 10000,
7194                reminder = newValInt % ratioInt,
7195                newValRound = parseInt(newVal);
7196
7197            if (reminder === 0) {
7198                bIsCorrectQuantityForRatio = true;
7199            }
7200        }
7201
7202        var bIsQuantityFloat = false;
7203
7204        if (parseInt(newVal) != parseFloat(newVal)) {
7205            bIsQuantityFloat = true;
7206        }
7207
7208        newVal = (bUseFloatQuantity === false && bIsQuantityFloat === false) ? parseInt(newVal) : parseFloat(newVal).toFixed(4);
7209        newVal = correctQuantity(newVal);
7210
7211
7212
7213        if (bIsCorrectQuantityForRatio) {
7214            BX(controlId).defaultValue = newVal;
7215
7216            BX("QUANTITY_INPUT_" + basketId).value = newVal;
7217
7218            BX("QUANTITY_" + basketId).value = newVal;
7219
7220            if (autoCalculate) {
7221                basketPoolQuantity.changeQuantity(basketId);
7222            }
7223        } else {
7224            newVal = getCorrectRatioQuantity(newVal, ratio, bUseFloatQuantity);
7225            newVal = correctQuantity(newVal);
7226
7227            if (newVal != oldVal) {
7228                BX("QUANTITY_INPUT_" + basketId).value = newVal;
7229                BX("QUANTITY_" + basketId).value = newVal;
7230
7231                if (autoCalculate) {
7232                    basketPoolQuantity.changeQuantity(basketId);
7233                }
7234            } else {
7235                BX(controlId).value = oldVal;
7236            }
7237        }
7238
7239
7240
7241    }, this), 700));
7242
7243
7244}
7245
7246function correctQuantity(quantity) {
7247    return parseFloat((quantity * 1).toString());
7248}
7249
7250
7251function recalcBasketAjax(params) {
7252
7253
7254    if (basketPoolQuantity.isProcessing()) {
7255        return false;
7256    }
7257
7258    /*BX.showWait();*/
7259
7260
7261    var property_values = {},
7262        action_var = 'recalculate',
7263        delayedItems = '',
7264        items = BX('basket_items').querySelectorAll('div.product'),
7265        postData,
7266        i;
7267
7268    if (BX('delayed_items'))
7269        delayedItems = BX('delayed_items').querySelectorAll('div.product');
7270
7271
7272    postData = {
7273        'sessid': BX.bitrix_sessid(),
7274        'site_id': $("input.site_id").val(),
7275        'action_var': action_var,
7276        'quantity_float': BX('quantity_float').value
7277    };
7278
7279    postData[action_var] = 'recalculate';
7280
7281    if (!!params && typeof params === 'object') {
7282        for (i in params) {
7283            if (params.hasOwnProperty(i))
7284                postData[i] = params[i];
7285        }
7286    }
7287
7288
7289
7290    if (!!items && items.length > 0) {
7291        for (i = 0; items.length > i; i++) {
7292            postData['QUANTITY_' + items[i].id] = BX('QUANTITY_' + items[i].id).value;
7293        }
7294    }
7295
7296    if (!!delayedItems && delayedItems.length > 0) {
7297        $('.show_items[data-items="delayed"]').css({
7298            "display": ""
7299        });
7300
7301        for (i = 1; delayedItems.length > i; i++)
7302            postData['DELAY_' + delayedItems[i].id] = 'Y';
7303    } else {
7304        $('.show_items[data-items="delayed"]').css({
7305            "display": "none"
7306        });
7307        showFormOrder();
7308    }
7309
7310
7311
7312    basketPoolQuantity.setProcessing(true);
7313    basketPoolQuantity.clearPool();
7314
7315
7316    if ($("input.basketOrder").length <= 0)
7317        showProcessLoadTopRight();
7318
7319    BX.ajax({
7320        url: '/bitrix/components/bitrix/sale.basket.basket/ajax.php',
7321        method: 'POST',
7322        data: postData,
7323        dataType: 'json',
7324        onsuccess: function (result) {
7325
7326
7327            /*BX.closeWait();*/
7328            if ($("input.basketOrder").length <= 0)
7329                closeProcessLoadTopRight();
7330
7331            if ($("input.basketOrder").length > 0 && params.action != "stopRefreshOrder")
7332                BX.Sale.OrderAjaxComponent.sendRequest("refreshOrderAjax", "noRedirect");
7333
7334
7335
7336            basketPoolQuantity.setProcessing(false);
7337
7338            if (basketPoolQuantity.isPoolEmpty()) {
7339                updateBasketTable(null, result);
7340                basketPoolQuantity.updateQuantity();
7341            } else {
7342                basketPoolQuantity.enableTimer(true);
7343            }
7344
7345        }
7346    });
7347}
7348
7349function setQuantity(basketId, ratio, sign, bUseFloatQuantity) {
7350    var curVal = parseFloat(BX("QUANTITY_INPUT_" + basketId).value),
7351        newVal;
7352
7353    newVal = (sign == 'up') ? curVal + ratio : curVal - ratio;
7354
7355    if (newVal < 0)
7356        newVal = 0;
7357
7358    if (bUseFloatQuantity) {
7359        newVal = parseFloat(newVal).toFixed(4);
7360    }
7361    newVal = correctQuantity(newVal);
7362
7363    if (ratio > 0 && newVal < ratio) {
7364        newVal = ratio;
7365    }
7366
7367    if (!bUseFloatQuantity && newVal != newVal.toFixed(4)) {
7368        newVal = parseFloat(newVal).toFixed(4);
7369    }
7370
7371    newVal = getCorrectRatioQuantity(newVal, ratio, bUseFloatQuantity);
7372    newVal = correctQuantity(newVal);
7373
7374    BX("QUANTITY_INPUT_" + basketId).value = newVal;
7375    BX("QUANTITY_INPUT_" + basketId).defaultValue = newVal;
7376
7377    updateQuantity('QUANTITY_INPUT_' + basketId, basketId, ratio, bUseFloatQuantity);
7378}
7379
7380function getCorrectRatioQuantity(quantity, ratio, bUseFloatQuantity) {
7381    var newValInt = quantity * 10000,
7382        ratioInt = ratio * 10000,
7383        reminder = (quantity / ratio - ((quantity / ratio).toFixed(0))).toFixed(6),
7384        result = quantity,
7385        bIsQuantityFloat = false,
7386        i;
7387    ratio = parseFloat(ratio);
7388
7389    if (reminder == 0) {
7390        return result;
7391    }
7392
7393    if (ratio !== 0 && ratio != 1) {
7394        for (i = ratio, max = parseFloat(quantity) + parseFloat(ratio); i <= max; i = parseFloat(parseFloat(i) + parseFloat(ratio)).toFixed(4)) {
7395            result = i;
7396        }
7397
7398    } else if (ratio === 1) {
7399        result = quantity | 0;
7400    }
7401
7402    if (parseInt(result, 10) != parseFloat(result)) {
7403        bIsQuantityFloat = true;
7404    }
7405
7406    result = (bUseFloatQuantity === false && bIsQuantityFloat === false) ? parseInt(result, 10) : parseFloat(result).toFixed(4);
7407    result = correctQuantity(result);
7408    return result;
7409}
7410
7411function correctQuantity(quantity) {
7412    return parseFloat((quantity * 1).toString());
7413}
7414
7415
7416
7417function updateBasketTable(basketItemId, res) {
7418
7419    var table = BX("basket_items"),
7420        rows,
7421        newBasketItemId,
7422        arItem,
7423        lastRow,
7424        newRow,
7425        arColumns,
7426        bShowDeleteColumn = false,
7427        bShowDelayColumn = false,
7428        bShowPropsColumn = false,
7429        bShowPriceType = false,
7430        bUseFloatQuantity,
7431        origBasketItem,
7432        oCellMargin,
7433        i,
7434        oCellName,
7435        imageURL,
7436        cellNameHTML,
7437        oCellItem,
7438        cellItemHTML,
7439        bSkip,
7440        j,
7441        val,
7442        propId,
7443        arProp,
7444        bIsImageProperty,
7445        countValues,
7446        full,
7447        fullWidth,
7448        itemWidth,
7449        arVal,
7450        valId,
7451        arSkuValue,
7452        selected,
7453        valueId,
7454        k,
7455        arItemProp,
7456        oCellQuantity,
7457        oCellQuantityHTML,
7458        ratio,
7459        isUpdateQuantity,
7460        oldQuantity,
7461        oCellPrice,
7462        fullPrice,
7463        id,
7464        oCellDiscount,
7465        oCellWeight,
7466        oCellCustom,
7467        customColumnVal,
7468        propsMap,
7469        selectedIndex,
7470        counter,
7471        marginLeft,
7472        createNewItem;
7473
7474
7475
7476
7477
7478    if (!table || typeof res !== 'object') {
7479        return;
7480    }
7481
7482    rows = table.querySelectorAll('div.product');
7483    lastRow = rows[rows.length - 1];
7484    bUseFloatQuantity = (res.PARAMS.QUANTITY_FLOAT === 'Y');
7485
7486
7487    if (!!res.BASKET_DATA) {
7488        for (id in res.BASKET_DATA.GRID.ROWS) {
7489            if (res.BASKET_DATA.GRID.ROWS.hasOwnProperty(id)) {
7490                var item = res.BASKET_DATA.GRID.ROWS[id];
7491
7492                if (BX('discount_value_' + id))
7493                    BX('discount_value_' + id).innerHTML = item.DISCOUNT_PRICE_PERCENT_FORMATED;
7494
7495                if (BX('current_price_' + id))
7496                    BX('current_price_' + id).innerHTML = item.PRICE_FORMATED;
7497
7498                if (BX('old_price_' + id)) {
7499
7500
7501                    if (item.DISCOUNT_PRICE_PERCENT > 0) {
7502                        BX('old_price_' + id).innerHTML = item.SUM_FULL_PRICE_FORMATED;
7503                        $('#old_price_' + id).css({
7504                            "display": ""
7505                        });
7506                    } else {
7507                        $('#old_price_' + id).css({
7508                            "display": "none"
7509                        });
7510                    }
7511                }
7512
7513                if (BX('sum_' + id))
7514                    BX('sum_' + id).innerHTML = item.SUM;
7515
7516
7517                /* if the quantity was set by user to 0 or was too much, we need to show corrected quantity value from ajax response*/
7518                if (BX('QUANTITY_' + id)) {
7519                    BX('QUANTITY_INPUT_' + id).value = item.QUANTITY;
7520                    BX('QUANTITY_INPUT_' + id).defaultValue = item.QUANTITY;
7521
7522                    BX('QUANTITY_' + id).value = item.QUANTITY;
7523                }
7524            }
7525        }
7526    }
7527
7528
7529    if (!!res.BASKET_DATA)
7530        couponListUpdate(res.BASKET_DATA);
7531
7532
7533    /*
7534    if (res.hasOwnProperty('WARNING_MESSAGE'))
7535    {
7536        var warningText = '';
7537
7538        for (i = res['WARNING_MESSAGE'].length - 1; i >= 0; i--)
7539            warningText += res['WARNING_MESSAGE'][i] + '<br/>';
7540
7541        BX('warning_message').innerHTML = warningText;
7542    }
7543    */
7544
7545    if (!!res.BASKET_DATA) {
7546        if (BX('allSum_FORMATED'))
7547            BX('allSum_FORMATED').innerHTML = res['BASKET_DATA']['allSum_FORMATED'];
7548
7549        if (BX('DISCOUNT_PRICE_ALL')) {
7550            if (res['BASKET_DATA']['DISCOUNT_PRICE_ALL'] > 0) {
7551                $('.basket-style').find(".dynamic-show-hide-discount").css({
7552                    "display": ""
7553                });
7554                $('.basket-style').find(".dynamic-show-hide-total-title").css({
7555                    "display": "none"
7556                });
7557                BX('DISCOUNT_PRICE_ALL').innerHTML = res['BASKET_DATA']['DISCOUNT_PRICE_FORMATED'];
7558            } else {
7559                $('.basket-style').find(".dynamic-show-hide-total-title").css({
7560                    "display": ""
7561                });
7562                $('.basket-style').find(".dynamic-show-hide-discount").css({
7563                    "display": "none"
7564                });
7565            }
7566
7567        }
7568
7569        if ($("input#min_sum").length > 0) {
7570            if ($("input#min_sum").val().length) {
7571                var minSum = $("input#min_sum").val();
7572                minSum = +minSum;
7573
7574
7575                if (res['BASKET_DATA']['allSum'] <= minSum) {
7576                    $(".alert-message-min-sum").css({
7577                        "display": ""
7578                    });
7579                    $(".basket-buttons").css({
7580                        "display": "none"
7581                    });
7582                    $(".clear-basket-node-control").addClass('hidden');
7583                } else {
7584                    $(".alert-message-min-sum").css({
7585                        "display": "none"
7586                    });
7587                    $(".basket-buttons").css({
7588                        "display": ""
7589                    });
7590                    $(".clear-basket-node-control").removeClass('hidden');
7591                }
7592
7593            }
7594        }
7595    }
7596}
7597
7598function couponListUpdate(res) {
7599    if (!!res && typeof res !== 'object')
7600        return;
7601
7602
7603    var couponBlock = $('.coupons_block');
7604
7605
7606
7607    if (couponBlock.length > 0) {
7608
7609        if (!!res.COUPON_LIST && BX.type.isArray(res.COUPON_LIST)) {
7610
7611            if ($('.input-coupon').length > 0) {
7612                $('.input-coupon').val("");
7613                $('.input-coupon').parents(".in-focus").removeClass('in-focus');
7614            }
7615
7616
7617            couponsCollection = $(".coupons_block").find(".coupon-one");
7618
7619            if (couponsCollection.length > 0) {
7620                for (i = 0; i < res.COUPON_LIST.length; i++) {
7621                    couponFound = false;
7622                    key = -1;
7623
7624                    for (j = 0; j < couponsCollection.length; j++) {
7625
7626                        if ($(couponsCollection[j]).find(".coupon-close").attr("data-coupon") === res.COUPON_LIST[i].COUPON) {
7627                            couponFound = true;
7628                            key = j;
7629                            couponsCollection[j].couponUpdate = true;
7630                            break;
7631                        }
7632                    }
7633
7634
7635                    if (couponFound) {
7636
7637                        couponClass = 'disabled';
7638                        if (res.COUPON_LIST[i].JS_STATUS === 'BAD')
7639                            couponClass = 'bad';
7640                        else if (res.COUPON_LIST[i].JS_STATUS === 'APPLYED')
7641                            couponClass = 'good';
7642
7643
7644                        $(couponsCollection[key]).removeClass("disabled bad good").addClass(couponClass)
7645
7646                        /*BX.adjust(couponsCollection[key], {props: {className: couponClass}});
7647                        BX.adjust(couponsCollection[key].nextSibling, {props: {className: couponClass}});
7648                        BX.adjust(couponsCollection[key].nextSibling.nextSibling, {html: res.COUPON_LIST[i].JS_CHECK_CODE});*/
7649
7650                    } else {
7651                        couponCreate(res.COUPON_LIST[i]);
7652                    }
7653
7654                }
7655
7656                for (j = 0; j < couponsCollection.length; j++) {
7657                    if (typeof (couponsCollection[j].couponUpdate) === 'undefined' || !couponsCollection[j].couponUpdate) {
7658                        $(couponsCollection[j]).remove();
7659                        couponsCollection[j] = null;
7660                    } else {
7661                        couponsCollection[j].couponUpdate = null;
7662                    }
7663                }
7664
7665            } else {
7666                for (i = 0; i < res.COUPON_LIST.length; i++) {
7667                    couponCreate(res.COUPON_LIST[i]);
7668                }
7669            }
7670        }
7671
7672    }
7673}
7674
7675
7676function couponCreate(oneCoupon, order) {
7677    var couponClass = 'disabled',
7678        removeClass = 'remove-coupon';
7679    order = order || false;
7680
7681    if ($(".coupons_block").length <= 0)
7682        return;
7683
7684    if (oneCoupon.JS_STATUS === 'BAD')
7685        couponClass = 'bad';
7686    else if (oneCoupon.JS_STATUS === 'APPLYED')
7687        couponClass = 'good';
7688
7689    if (order)
7690        removeClass = 'remove-order-coupon';
7691
7692
7693    html = "<div class=\"coupon-one " + couponClass + "\">" +
7694        "<span class=\"coupon-name\">" + oneCoupon.COUPON + "</span><span class=\"coupon-close " + removeClass + "\" data-coupon=\"" + oneCoupon.COUPON + "\"></span>" +
7695        "</div>";
7696
7697
7698    $(html).appendTo(".coupons_block");
7699}
7700
7701
7702
7703$(document).on("click", ".remove-coupon", function () {
7704    var target = this,
7705        value;
7706
7707    if (BX.type.isElementNode(target) && target.hasAttribute('data-coupon')) {
7708        value = target.getAttribute('data-coupon');
7709        if (BX.type.isNotEmptyString(value)) {
7710            recalcBasketAjax({
7711                'delete_coupon': value
7712            });
7713        }
7714    }
7715});
7716
7717
7718$(document).on("click", ".remove-order-coupon", function () {
7719    var target = this,
7720        value;
7721
7722    if (BX.type.isElementNode(target) && target.hasAttribute('data-coupon')) {
7723        value = target.getAttribute('data-coupon');
7724        if (BX.type.isNotEmptyString(value)) {
7725            BX.Sale.OrderAjaxComponent.sendRequest("removeCoupon", value);
7726        }
7727    }
7728});
7729
7730$(document).on("click", ".show_items", function () {
7731    $(".show_items").removeClass('active');
7732    $(this).addClass('active');
7733    $(".basket_items_list").removeClass('active');
7734    $(".basket_items_list[data-items='" + $(this).attr("data-items") + "']").addClass('active');
7735
7736    if ($(this).attr("data-items") == "delayed")
7737        hideFormOrder();
7738
7739    if ($(this).attr("data-items") == "items")
7740        showFormOrder();
7741
7742    BasketFilter($("input.basket-filter").val());
7743
7744}
7744);
7745
7746function enterCoupon() {
7747
7748    if ($('.input-coupon').length > 0)
7749        recalcBasketAjax({
7750            'coupon': $('.input-coupon').val()
7751        });
7752}
7753
7754function enterOrderCoupon() {
7755
7756    if ($('.input-coupon').length > 0)
7757        BX.Sale.OrderAjaxComponent.sendRequest("enterCoupon", $('.input-coupon').val());
7758}
7759
7760function add2Basket(productItem, target) {
7761    productItem = productItem || "";
7762    target = target || "";
7763
7764
7765    if (productItem) {
7766        if (target.length > 0)
7767            target.addClass('btn-processing');
7768
7769
7770        BX.ajax({
7771            method: 'POST',
7772            dataType: 'json',
7773            url: '/bitrix/tools/concept.phoenix/ajax/basket/add2basket.php',
7774            data: {
7775                productItem: productItem,
7776                site_id: $("input.site_id").val()
7777            },
7778            onsuccess: function (arResult) {
7779                /*if (!BX.type.isPlainObject(arResult))
7780                    return;*/
7781
7782                if (arResult["OK"] == "Y") {
7783                    markProductAddBasket(productItem["PRODUCT_ID"]);
7784
7785                    if (arResult["SCRIPTS"])
7786                        $('body').append(arResult["SCRIPTS"]);
7787                } else {
7788                    if (target.length > 0)
7789                        target.removeClass('btn-processing');
7790                }
7791            }
7792        });
7793    }
7794
7795}
7796
7797function showProcessLoadBlock(obj) {
7798    obj.find('.loading-block').addClass('active');
7799}
7800
7801function closeProcessLoadBlock(obj) {
7802    obj.find('.loading-block').removeClass('active');
7803}
7804
7805function showProcessLoad() {
7806    $('.loading').addClass('active');
7807}
7808
7809function closeProcessLoad() {
7810    $('.loading').removeClass('active');
7811}
7812
7813function showProcessLoadItem(id) {
7814    $('.preloader-item[data-preload="' + id + '"]').addClass('active');
7815}
7816
7817function closeProcessLoadItem(id) {
7818    $('.preloader-item[data-preload="' + id + '"]').removeClass('active');
7819}
7820
7821function showProcessLoadTopRight() {
7822    $('.loading-top-right').addClass('active');
7823}
7824
7825function closeProcessLoadTopRight() {
7826    $('.loading-top-right').removeClass('active');
7827}
7828
7829
7830function startBlurWrapperContainer(params) {
7831    params = params || {
7832        "blur": true
7833    };
7834
7835
7836    if (!$("body").hasClass('modal-open')) {
7837
7838        if (params.blur)
7839            $('.wrapper').addClass('blur');
7840
7841
7842        $("body").addClass("modal-open");
7843
7844        if (device.ios()) {
7845            cur_pos = $(document).scrollTop();
7846            $("body").addClass("modal-ios");
7847        }
7848
7849
7850    }
7851
7852}
7853
7854function stopBlurWrapperContainer() {
7855    if ($("body").hasClass('modal-open')) {
7856        $("body").removeClass("modal-open");
7857        $('.wrapper').removeClass('blur');
7858
7859        if (device.ios()) {
7860            $("body").removeClass("modal-ios");
7861            window.scrollTo(0, cur_pos);
7862        }
7863    }
7864}
7865
7866function startModalMode(selectorArea) {
7867
7868    startBlurWrapperContainer();
7869    closeProcessLoad();
7870
7871    setTimeout(function () {
7872        $(selectorArea).find('.phoenix-modal').addClass('active');
7873    }, 100);
7874}
7875
7876function callFastOrderForm(fromBasket, productItem) {
7877    fromBasket = fromBasket || "";
7878    productItem = productItem || "";
7879
7880
7881    $.ajax({
7882        method: 'POST',
7883        dataType: 'html',
7884        url: '/bitrix/tools/concept.phoenix/ajax/basket/call_form_fast_order.php',
7885        data: {
7886            site_id: $("input.site_id").val(),
7887            fromBasket: fromBasket,
7888            productItem: productItem
7889        },
7890        success: function (html) {
7891
7892            closeProcessLoad();
7893            startModalMode("div.modalAreaForm");
7894            $('div.modalAreaForm').html(html);
7895            $('div.modalAreaForm form.form .date').datetimepicker({
7896                timepicker: false,
7897                format: 'd/m/Y',
7898                scrollMonth: false,
7899                scrollInput: false,
7900                dayOfWeekStart: 1
7901            });
7902        }
7903    });
7904}
7905
7906function getStringNameItem(name, offers) {
7907    var input = name;
7908
7909    for (var i in offers) {
7910        input += offers[i].SKU_NAME + ": " + offers[i].NAME + "; ";
7911    }
7912
7913    return input;
7914}
7915
7916$(document).on("click", ".callFastOrder",
7917    function () {
7918        var callDialog = "N";
7919
7920        if ($(".callFastOrder").hasClass("callDialog"))
7921            callDialog = "Y";
7922
7923        if ($(this).attr("data-param-product"))
7924            var productItem = eval("(" + $(this).attr("data-param-product") + ")");
7925
7926        callFastOrderForm(callDialog, productItem);
7927    }
7928);
7929
7930$(document).on("click", ".btn-add2basket",
7931    function () {
7932        var productItem = eval("(" + $(this).attr("data-param-product") + ")");
7933        add2Basket(productItem, $(this));
7934    }
7935);
7936
7937
7938
7939function AjaxQuickSearch(arParams) {
7940    var _this = this;
7941    this.arParams = {
7942        'CONTAINER_ID': arParams.CONTAINER_ID,
7943        'INPUT_ID': arParams.INPUT_ID,
7944        'SHOW_RESULTS': arParams.SHOW_RESULTS,
7945        'LINE_VIEW_SIZE': ""
7946    };
7947
7948    if (arParams.LINE_VIEW_SIZE)
7949        this.arParams.LINE_VIEW_SIZE = arParams.LINE_VIEW_SIZE;
7950
7951
7952    this.arParams.AJAX_PAGE = "/bitrix/tools/concept.phoenix/ajax/search.php";
7953    this.arParams.MIN_QUERY_LEN = 3;
7954
7955    this.cache = [];
7956    this.cache_key = null;
7957
7958    this.startText = '';
7959    this.running = false;
7960    this.searchWait = 0;
7961    this.currentRow = -1;
7962    this.RESULT = null;
7963    this.RESULT_WRAPPER = null;
7964    this.CONTAINER = null;
7965    this.INPUT = null;
7966    this.WAIT = null;
7967    this.HINT_BTN = null;
7968    this.SEARCH_IN_BTN = null;
7969    this.FOCUS = false;
7970    this.searchIn = null;
7971    this.searchInOld = null;
7972
7973
7974    this.ShowResult = function (result) {
7975        if (BX.type.isString(result))
7976            _this.RESULT.innerHTML = result;
7977
7978        if ($.trim(_this.RESULT.innerHTML).length > 0) {
7979            setTimeout(function () {
7980                _this.RESULT_WRAPPER.style.display = 'block';
7981                var pos = _this.adjustResultNode();
7982            }, 450);
7983        } else {
7984            _this.RESULT_WRAPPER.style.display = 'none';
7985        }
7986
7987    };
7988
7989    this.onKeyPress = function (keyCode) {
7990
7991        switch (keyCode) {
7992            case 27:
7993                _this.RESULT_WRAPPER.style.display = 'none';
7994                _this.currentRow = -1;
7995                _this.UnSelectAll();
7996                return true;
7997        }
7998
7999        return false;
8000    };
8001
8002    this.onTimeout = function () {
8003        _this.onChange(function () {
8004            setTimeout(_this.onTimeout, 500);
8005        });
8006    };
8007
8008    this.onChange = function (callback) {
8009
8010        if ($(window).width() >= 1199) {
8011            if (this.arParams.SHOW_RESULTS != "Y")
8012                return;
8013
8014            if (_this.running) {
8015                _this.runningCall = true;
8016                return;
8017            }
8018
8019            _this.running = true;
8020
8021            if (_this.INPUT.value != _this.oldValue || _this.searchIn != _this.searchInOld) {
8022                _this.oldValue = _this.INPUT.value;
8023                _this.searchInOld = _this.searchIn;
8024
8025                if (_this.INPUT.value.length >= _this.arParams.MIN_QUERY_LEN) {
8026                    showWaitSearch($("#" + _this.arParams.CONTAINER_ID));
8027                    clearTimeout(_this.searchWait);
8028
8029                    _this.searchWait = setTimeout(
8030                        function () {
8031                            _this.cache_key = _this.arParams.INPUT_ID + '|' + _this.INPUT.value + '|' + _this.searchIn;
8032
8033                            if (_this.cache[_this.cache_key] == null) {
8034                                if (_this.INPUT.value.length >= _this.arParams.MIN_QUERY_LEN) {
8035                                    BX.ajax.post(
8036                                        _this.arParams.AJAX_PAGE, {
8037                                            'q': _this.INPUT.value,
8038                                            'searchIn': _this.searchIn,
8039                                            'LINE_VIEW_SIZE': _this.arParams.LINE_VIEW_SIZE,
8040                                            'ajax_mode': "Y",
8041                                            'site_id': $("input.site_id").val()
8042                                        },
8043                                        function (result) {
8044
8045                                            _this.cache[_this.cache_key] = result;
8046                                            _this.ShowResult(result);
8047                                            if (_this.WAIT)
8048                                                _this.WAIT.style.display = 'none';
8049
8050                                            hideWaitSearch($("#" + _this.arParams.CONTAINER_ID));
8051
8052                                            if (!!callback)
8053                                                callback();
8054
8055                                            _this.running = false;
8056
8057                                            if (_this.runningCall) {
8058                                                _this.runningCall = false;
8059                                                _this.onChange();
8060                                            }
8061                                        }
8062                                    );
8063
8064                                    return;
8065                                } else {
8066                                    hideWaitSearch($("#" + _this.arParams.CONTAINER_ID));
8067                                }
8068
8069                            } else {
8070                                _this.ShowResult(_this.cache[_this.cache_key]);
8071                                _this.currentRow = -1;
8072                                _this.EnableMouseEvents();
8073                                hideWaitSearch($("#" + _this.arParams.CONTAINER_ID));
8074                            }
8075                        }, 900);
8076                } else {
8077                    _this.RESULT_WRAPPER.style.display = 'none';
8078                    _this.RESULT.innerHTML = "";
8079                    _this.currentRow = -1;
8080                    _this.UnSelectAll();
8081                }
8082
8083
8084            }
8085
8086            if (!!callback)
8087                callback();
8088
8089
8090            _this.running = false;
8091        }
8092
8093    };
8094
8095    this.onScroll = function () {
8096        if (BX.type.isElementNode(_this.RESULT_WRAPPER) && _this.RESULT_WRAPPER.style.display !== "none" && _this.RESULT.innerHTML !== '')
8097            _this.adjustResultNode();
8098
8099    };
8100
8101    this.UnSelectAll = function () {
8102        var tbl = BX.findChild(_this.RESULT, {
8103            'tag': 'table',
8104            'class': 'title-search-result'
8105        }, true);
8106        if (tbl) {
8107            var cnt = tbl.rows.length;
8108            for (var i = 0; i < cnt; i++)
8109                tbl.rows[i].className = '';
8110        }
8111    };
8112
8113    this.EnableMouseEvents = function () {
8114
8115    };
8116
8117    this.onFocusLost = function (hide) {
8118        setTimeout(function () {
8119            if (!_this.FOCUS)
8120                _this.RESULT_WRAPPER.style.display = 'none';
8121        }, 250);
8122
8123        _this.FOCUS = false;
8124    };
8125
8126    this.onFocusGain = function () {
8127        if ($.trim(_this.RESULT.innerHTML).length)
8128            _this.ShowResult();
8129    };
8130
8131    this.onKeyDown = function (e) {
8132        if (!e)
8133            e = window.event;
8134
8135        if (_this.RESULT_WRAPPER.style.display == 'block') {
8136            if (_this.onKeyPress(e.keyCode))
8137                return BX.PreventDefault(e);
8138        }
8139    };
8140
8141    this.adjustResultNode = function () {
8142        if (!(BX.type.isElementNode(_this.RESULT_WRAPPER) &&
8143                BX.type.isElementNode(_this.CONTAINER)))
8144            return {
8145                top: 0,
8146                right: 0,
8147                bottom: 0,
8148                left: 0,
8149                width: 0,
8150                height: 0
8151            };
8152
8153
8154        var pos = BX.pos(_this.CONTAINER);
8155        var bxpanel = document.getElementById("bx-panel");
8156        var bxheight = 0;
8157
8158        if (bxpanel != null && !$("#" + this.arParams.CONTAINER_ID).hasClass('outside-div'))
8159            bxheight = parseInt(bxpanel.clientHeight);
8160
8161
8162        _this.RESULT_WRAPPER.style.position = 'absolute';
8163        _this.RESULT_WRAPPER.style.top = (pos.bottom - bxheight) + 'px';
8164        _this.RESULT_WRAPPER.style.left = (pos.left - 15) + 'px';
8165        _this.RESULT_WRAPPER.style.width = (pos.width + 30) + 'px';
8166
8167
8168        if ($("#" + this.arParams.CONTAINER_ID).hasClass('outside-div'))
8169            _this.RESULT_WRAPPER.style.height = ($(window).height() - pos.height - 40) + 'px';
8170
8171        return pos;
8172    };
8173
8174    this._onContainerLayoutChange = function () {
8175        if (BX.type.isElementNode(_this.RESULT_WRAPPER) && _this.RESULT_WRAPPER.style.display !== "none" && _this.RESULT.innerHTML !== '')
8176            _this.adjustResultNode();
8177
8178    };
8179
8180    this.SetSearchIn = function () {
8181        searchGet = $(BX.proxy_context);
8182
8183        searchGet.parents(".show-search-list-parent").find(".search-cur").text(searchGet.text());
8184        searchGet.parents(".search-list").find('span.search-get').removeClass("active");
8185        searchGet.parents(".search-list").removeClass('active');
8186        searchGet.addClass('active');
8187        searchGet.parents("form.search-form").attr("action", searchGet.attr("data-url"));
8188
8189        _this.searchIn = searchGet.attr("data-id");
8190
8191        _this.onChange();
8192    };
8193
8194    this.Init = function () {
8195
8196        var parent = document.getElementById("phoenix-container");
8197
8198        if ($("#" + this.arParams.CONTAINER_ID).hasClass('outside-div'))
8199            parent = document.getElementById("body");
8200
8201
8202        this.searchIn = $("#" + this.arParams.CONTAINER_ID).find(".search-get.active").attr("data-id");
8203
8204        this.RESULT_WRAPPER = parent.appendChild(document.createElement("DIV"));
8205
8206        this.RESULT_WRAPPER.className = 'ajax-search-results';
8207
8208        if ($("#" + this.arParams.CONTAINER_ID).hasClass('outside-div'))
8209            this.RESULT_WRAPPER.className = 'ajax-search-results outside';
8210
8211
8212        this.RESULT = this.RESULT_WRAPPER.appendChild(document.createElement("DIV"));
8213        this.RESULT.className = 'ajax-search-results-inner';
8214
8215
8216        this.INPUT = BX(this.arParams.INPUT_ID);
8217        this.startText = this.oldValue = this.INPUT.value;
8218
8219        BX.bind(this.INPUT, 'focus', function () {
8220            _this.onFocusGain()
8221        });
8222        BX.bind(this.INPUT, 'blur', function () {
8223            _this.onFocusLost()
8224        });
8225
8226        this.INPUT.onkeydown = this.onKeyDown;
8227        BX.bind(this.INPUT, 'bxchange', function () {
8228            _this.onChange()
8229        });
8230
8231        this.CONTAINER = BX(this.arParams.CONTAINER_ID);
8232        BX.addCustomEvent(this.CONTAINER, "OnNodeLayoutChange", this._onContainerLayoutChange);
8233
8234        this.HINT_BTN = BX(this.arParams.CONTAINER_ID + "_hint");
8235
8236
8237        BX.bind(this.HINT_BTN, 'click', function () {
8238
8239            _this.FOCUS = true;
8240            BX.focus(_this.INPUT);
8241
8242            _this.INPUT.value = _this.HINT_BTN.innerHTML;
8243
8244            if (!$("#" + _this.arParams.CONTAINER_ID).find(".search-panel-js").hasClass('top-panel'))
8245                scrollToBlock($("#" + _this.arParams.INPUT_ID).parents(".search-panel-js").find(".search-scroll-focus"), '', 40);
8246
8247            checkInput($("#" + _this.arParams.INPUT_ID));
8248
8249            _this.onChange();
8250
8251            setTimeout(function () {
8252                _this.FOCUS = false;
8253            }, 1000);
8254        });
8255
8256
8257        var searchGet = this.CONTAINER.querySelectorAll('.search-get');
8258
8259        if (searchGet.length) {
8260            for (var i = 0; i < searchGet.length; i++)
8261                BX.bind(searchGet[i], 'click', BX.delegate(this.SetSearchIn, this));
8262        }
8263
8264
8265
8266        var fixedParent = BX.findParent(this.CONTAINER, BX.is_fixed);
8267
8268        if (BX.type.isElementNode(fixedParent)) {
8269            BX.bind(window, 'scroll', BX.throttle(this.onScroll, 100, this));
8270        }
8271    };
8272
8273
8274    BX.ready(
8275        function () {
8276            _this.Init(arParams)
8277        }
8278    );
8279
8280}
8281
8282$(document).on("click", ".show-dialog-map", function () {
8283    showProcessLoad();
8284    $.post(
8285        '/bitrix/tools/concept.phoenix/ajax/popup/dialog_map.php', {
8286            site_id: $("input.site_id").val()
8287        },
8288        function (html) {
8289            closeProcessLoad();
8290            startBlurWrapperContainer();
8291
8292            $("div.modalAreaWindow").html(html);
8293
8294            setTimeout(function () {
8295                $("div.modalAreaWindow").find('.phoenix-modal').addClass('active');
8296            }, 100);
8297
8298        }
8299    );
8300});
8301
8302$(window).on("load", function () {
8303
8304
8305    if (customEvent) {
8306        updateLazyLoad();
8307    } else {
8308        var counter = 0;
8309
8310        var timerId = setInterval(
8311            function () {
8312                if (counter > 5)
8313                    clearInterval(timerId);
8314
8315                updateLazyLoad();
8316                counter++;
8317            },
8318            1000
8319        );
8320
8321
8322    }
8323});
8324
8325$(document).on("click", ".show-fast-order-form", function () {
8326    $(".form-order[data-target='" + $(this).attr("data-target") + "']").addClass('active');
8327    $(".info-table[data-target='" + $(this).attr("data-target") + "']").removeClass('active');
8328    $(".hide-fast-order-form[data-target='" + $(this).attr("data-target") + "']").addClass('active');
8329    $('.date-group').datetimepicker({
8330        timepicker: false,
8331        format: 'd.m.Y',
8332        scrollMonth: false,
8333        scrollInput: false,
8334        dayOfWeekStart: 1
8335
8336    });
8337});
8338
8339$(document).on("click", ".hide-fast-order-form", function () {
8340    $(this).removeClass('active');
8341    $(".form-order[data-target='" + $(this).attr("data-target") + "']").removeClass('active');
8342    $(".info-table[data-target='" + $(this).attr("data-target") + "']").addClass('active');
8343});
8344
8345$(document).on("click", ".btn-show-sort-board", function () {
8346    $(this).children('.sort-dialog-content').addClass('active');
8347});
8348$(document).mouseup(function (e) {
8349    var div = $(".sort-dialog-content");
8350    if (!div.is(e.target) && div.has(e.target).length === 0) div.removeClass(
8351        'active');
8352});
8353
8354$(document).on("click", ".show-side-menu", function () {
8355    $(".wr-transform-to-dialog-by-mob").removeClass('d-none');
8356    startBlurWrapperContainer();
8357});
8358$(document).on("click", ".close-side-menu", function () {
8359    $(".wr-transform-to-dialog-by-mob").addClass('d-none');
8360    stopBlurWrapperContainer();
8361});
8362
8363if ($(window).width() <= 1024) {
8364    $(document).on({
8365            click: function () {
8366                $(".soc-groups-in-menu").removeClass('d-none');
8367            }
8368
8369        },
8370        ".show-soc-groups"
8371    );
8372}
8373$(document).on({
8374        click: function () {
8375            $(".soc-groups-in-menu").addClass('d-none');
8376        }
8377
8378    },
8379    ".close-soc-groups"
8380);
8381
8382$(document).mouseup(function (e) {
8383    var div = $(".soc-groups-in-menu");
8384    if (!div.is(e.target) && div.has(e.target).length === 0) div.addClass(
8385        'd-none');
8386});
8387
8388
8389
8390
8391
8392var ratingProducts = {},
8393    ratingProductsParse = {};
8394
8395$(document).ready(function () {
8396    getRatingCookie();
8397    setVoteItems();
8398});
8399
8400function setVoteItems() {
8401    for (key in ratingProductsParse) {
8402
8403        var collectVote = $(".simple-rating[data-item-id='" + key + "']").children(),
8404            currentPoint = parseInt(ratingProductsParse[key]);
8405
8406        $(".simple-rating[data-item-id='" + key + "']").addClass("disabled");
8407
8408        $(collectVote).each(
8409            function (index, element) {
8410                if (parseInt($(element).attr("data-point")) <= currentPoint)
8411                    $(element).addClass('voted');
8412            }
8413        );
8414
8415    }
8416}
8417
8418function setVoteItem(id, vote) {
8419
8420    var collectVote = $(".simple-rating[data-item-id='vote-block-" + id + "']").children(),
8421        currentPoint = parseInt(vote);
8422
8423    $(".simple-rating[data-item-id='vote-block-" + id + "']").addClass("disabled");
8424    collectVote.removeClass('voted');
8425
8426    $(collectVote).each(
8427        function (index, element) {
8428            if (parseInt($(element).attr("data-point")) <= currentPoint)
8429                $(element).addClass('voted');
8430        }
8431    );
8432}
8433
8434function issetRatingCookie(id) {
8435    return !(ratingProductsParse[id] === undefined);
8436}
8437
8438function getRatingCookie() {
8439    ratingProducts = BX.getCookie($(".domen-url-for-cookie").val() + '_phoenix_rating_products');
8440
8441    if (ratingProducts)
8442        ratingProductsParse = JSON.parse(ratingProducts);
8443}
8444
8445function setRatingCookie(id, vote) {
8446    ratingProductsParse["vote-block-" + id] = vote;
8447    BX.setCookie($(".domen-url-for-cookie").val() + '_phoenix_rating_products', JSON.stringify(ratingProductsParse), {
8448        expires: 60 * 60 * 60 * 60,
8449        path: "/"
8450    });
8451}
8452
8453function setReviewsCountProduct(id, review) {
8454    $(".reviews-count[data-item-id=\"" + id + "\"]").html(review);
8455}
8456
8457function setRatingProduct(id, rating, selector) {
8458
8459    selector = selector || "";
8460    var collectVote = $(selector + ".stars_container[data-item-id='vote-block-" + id + "']").children(),
8461        currentPoint = parseInt(rating);
8462
8463    $(selector + ".stars_container[data-item-id='vote-block-" + id + "']").attr("data-rating", rating);
8464
8465
8466
8467    if (currentPoint > 5)
8468        currentPoint = 5;
8469
8470    else if (currentPoint < 0)
8471        return false;
8472
8473    collectVote.removeClass('active');
8474
8475    $(collectVote).each(
8476        function (index, element) {
8477            if (parseInt($(element).attr("data-point")) <= currentPoint)
8478                $(element).addClass('active');
8479        }
8480    );
8481
8482    return true;
8483}
8484
8485function showMessageSuccessVote() {
8486
8487    $('#alert-vote').show();
8488
8489    var voteAlertTimer = setTimeout(function () {
8490        $('#alert-vote').hide();
8491        clearTimeout(voteAlertTimer);
8492    }, 2000);
8493}
8494
8495function updateRatingProduct(id, vote) {
8496
8497    $.ajax({
8498        url: '/bitrix/tools/concept.phoenix/ajax/update/rating.php',
8499        method: 'POST',
8500        data: {
8501            site_id: $("input.site_id").val(),
8502            id: id.replace('vote-block-', ''),
8503            vote: vote
8504        },
8505        success: function (data) {
8506            if (data.OK == "Y") {
8507                setRatingProduct(data.PRODUCT.ID, data.PRODUCT.RATING);
8508                setRatingCookie(data.PRODUCT.ID, data.PRODUCT.VOTE);
8509                setVoteItem(data.PRODUCT.ID, data.PRODUCT.VOTE);
8510                showMessageSuccessVote();
8511            }
8512
8513        }
8514    });
8515}
8516
8517$(document).on({
8518        mouseenter: function () {
8519
8520            if ($(this).parent().hasClass('simple-rating') && issetRatingCookie($(this).parent().attr("data-item-id")))
8521                return false;
8522
8523            var collectVote = $(this).parent().children(),
8524                currentPoint = parseInt($(this).attr("data-point"));
8525
8526            collectVote.removeClass('hover');
8527
8528            $(collectVote).each(
8529                function (index, element) {
8530                    if (parseInt($(element).attr("data-point")) <= currentPoint)
8531                        $(element).addClass('hover');
8532                }
8533
8534            );
8535        },
8536
8537        mouseleave: function () {
8538            $(this).parent().children().removeClass('hover');
8539        }
8540    },
8541    ".stars_container.hover .star"
8542);
8543
8544
8545$(document).on("click", ".stars_container.simple-rating .star", function () {
8546    getRatingCookie();
8547
8548    if (!issetRatingCookie($(this).parent().attr("data-item-id")))
8549        updateRatingProduct($(this).parent().attr("data-item-id"), $(this).attr("data-point"));
8550});
8551
8552$(document).on("click", ".stars_container.full-rating .star", function () {
8553    setRatingProduct($(this).parent().attr("data-item-id").replace('vote-block-', ''), $(this).attr("data-point"), ".full-rating");
8554
8555
8556    if ($(this).parents(".wr-rating").length > 0)
8557        $(this).parents(".wr-rating").removeClass('has-error');
8558
8559    if ($("input[name='review-vote'][data-item-id='" + $(this).parent().attr("data-item-id") + "']").length > 0)
8560        $("input[name='review-vote'][data-item-id='" + $(this).parent().attr("data-item-id") + "']").val($(this).attr("data-point"));
8561
8562});
8563
8564
8565function setRatingProgress(id, rating) {
8566
8567    var circleParent = $("svg.circle-progress-bar[data-item-id='" + id + "']"),
8568        circle = circleParent.find("circle.rating-progress-bar"),
8569        radius = parseInt(circle.css("r")),
8570        circumference = 2 * Math.PI * radius,
8571        offset = 0,
8572        rating = parseFloat(rating).toFixed(1) || 0;
8573
8574    var color = "";
8575
8576    if (rating == 0)
8577        color = "rating-0";
8578
8579    else if (rating < 1)
8580        return false;
8581
8582    else if (rating > 5)
8583        rating = 5.0;
8584
8585
8586
8587    if (1 <= rating && rating <= 1.8)
8588        color = "rating-1";
8589
8590    if (1.8 < rating && rating <= 2.8)
8591        color = "rating-2";
8592
8593    if (2.8 < rating && rating <= 3.8)
8594        color = "rating-3";
8595
8596    if (3.8 < rating && rating <= 4.8)
8597        color = "rating-4";
8598
8599    if (4.8 < rating && rating <= 5)
8600        color = "rating-5";
8601
8602
8603    offset = circumference - rating / 5 * circumference;
8604
8605    circle[0].style.strokeDasharray = circumference + " " + circumference;
8606    circle[0].style.strokeDashoffset = offset;
8607
8608    circleParent.removeClass('rating-0 rating-1 rating-2 rating-3 rating-4 rating-5');
8609    circleParent.addClass(color);
8610
8611
8612    $(".rating-value[data-item-id='" + id + "']").text(rating);
8613
8614    return true;
8615}
8616
8617
8618
8619
8620
8621
8622
8623
8624var noClickLayer = 0;
8625
8626function openFlyBlock(id) {
8627    if (noClickLayer == 0)
8628        startBlurWrapperContainer();
8629
8630    noClickLayer++;
8631
8632    $('body').append('<div class="click-ghost-area" data-fly-block-id="' + id + '"></div>');
8633
8634    $('.fly-block[data-fly-block-id="' + id + '"]').addClass('active');
8635
8636    var tOutShow = setTimeout(function () {
8637        $('.fly-block[data-fly-block-id="' + id + '"]').addClass('on');
8638
8639        clearTimeout(tOutShow);
8640    }, 200);
8641}
8642
8643function closeFlyBlock(id) {
8644    if (noClickLayer == 1)
8645        stopBlurWrapperContainer();
8646
8647    noClickLayer--;
8648
8649    $('.click-ghost-area[data-fly-block-id="' + id + '"]').remove();
8650    $('.fly-block[data-fly-block-id="' + id + '"]').removeClass('on');
8651
8652
8653    var tOutHide = setTimeout(function () {
8654        $('.fly-block[data-fly-block-id="' + id + '"]').removeClass('active');
8655
8656        clearTimeout(tOutHide);
8657    }, 700);
8658}
8659
8660$(document).on("click", ".click-ghost-area", function () {
8661
8662    if (typeof ($(this).attr("data-fly-block-id")) != "undefined")
8663        closeFlyBlock($(this).attr("data-fly-block-id"));
8664});
8665
8666function setFlyBlockParams(_this) {
8667    params = null;
8668
8669    if (_this.hasClass('fly-block-review')) {
8670        params = {
8671            "PRODUCT_ID": _this.attr("data-product-id"),
8672            "NAME": $("input.product-" + _this.attr("data-product-id") + "-name").val(),
8673            "PICTURE_SRC": $("input.product-" + _this.attr("data-product-id") + "-picture-src-small").val(),
8674            "PATH": "/bitrix/tools/concept.phoenix/ajax/reviews/fly_block_review_html.php"
8675        };
8676    }
8677
8678
8679    return params;
8680}
8681
8682
8683
8684var loadingFlyReviewFlag = false;
8685
8686function loadingFlyReview() {
8687    loadingFlyReviewFlag = true;
8688}
8689
8690function completedFlyReview() {
8691    loadingFlyReviewFlag = false;
8692}
8693
8694function createFlyBlock(id, params) {
8695
8696    if (loadingFlyReviewFlag)
8697        return false;
8698
8699    showProcessLoad();
8700
8701    params = params || null;
8702
8703    loadingFlyReview();
8704
8705    $.post(
8706        params.PATH, {
8707            site_id: $("input.site_id").val(),
8708            params: params
8709        },
8710        function (html) {
8711            closeProcessLoad();
8712            $('body').append(html);
8713
8714            setRatingProduct(params.PRODUCT_ID, $(".stars_container.full-rating[data-item-id='vote-block-" + params.PRODUCT_ID + "']").attr("data-rating"), ".full-rating");
8715            openFlyBlock(id);
8716            completedFlyReview();
8717
8718            $('[data-toggle="tooltip-ajax"]').tooltip({
8719                html: true
8720            });
8721        }
8722    );
8723
8724}
8725
8726$(document).on("click", ".open-fly-block", function () {
8727    var id = $(this).attr("data-fly-block-id");
8728
8729    if ($('.fly-block[data-fly-block-id="' + id + '"]').length <= 0) {
8730        var params = setFlyBlockParams($(this));
8731
8732        createFlyBlock(id, params);
8733    } else {
8734        openFlyBlock(id);
8735    }
8736
8737});
8738
8739$(document).on("click", ".close-fly-block", function () {
8740    closeFlyBlock($(this).attr("data-fly-block-id"));
8741});
8742
8743
8744$(document).on({
8745        click: function () {
8746            var label = $(this).parent();
8747
8748            if (label.hasClass("selected")) {
8749                label.removeClass("selected");
8750                $(this).prop('checked', false);
8751            } else {
8752                $("input[type='radio'][name='" + $(this).attr("name") + "']").parent().removeClass("selected");
8753                label.addClass("selected");
8754            }
8755        },
8756    },
8757    ".btn-radio-simple:not(.disabled) input[type='radio']"
8758);
8759
8760
8761$(document).on('change', "input.load-file-simple[type='file']",
8762    function () {
8763
8764        var inp = $(this);
8765        var file_list_name = "";
8766
8767        $(inp[0].files).each(
8768            function (key) {
8769
8770                if (key == 10)
8771                    return false;
8772
8773                if (key != 0)
8774                    file_list_name += ",&ensp;";
8775
8776                file_list_name += "<span>" + inp[0].files[key].name + "</span>";
8777            }
8778        );
8779
8780
8781        if (!file_list_name.length)
8782            return;
8783
8784        inp.parents('form').addClass('file-download');
8785        inp.parents('label').find('.area-files-name').html(file_list_name);
8786        inp.closest('.load-file').removeClass("has-error");
8787
8788    }
8789);
8790
8791
8792
8793$(document).on("focus", ".text-require, .input-simple input[type='email']", function () {
8794    $(this).removeClass("has-error");
8795});
8796
8797function validForm(form, params) {
8798
8799    var valid = true;
8800    params = params || null;
8801
8802    if (typeof ($("input.agreecheck", form).val()) != "undefined") {
8803        if (!$("input.agreecheck", form).prop("checked")) {
8804            $("input.agreecheck", form).parents("div.wrap-agree").addClass("has-error");
8805            valid = false;
8806        }
8807    }
8808
8809    $("input[type='email'], input[type='text'], input[type='password'], textarea", form).each(
8810        function (key, value) {
8811            if ($(this).hasClass("text-require")) {
8812                if ($(this).val().trim().length <= 0) {
8813                    $(this).val("");
8814                    $(this).addClass("has-error");
8815                    valid = false;
8816                }
8817            } else if ($(this).attr("type") == "email" && $(this).val().length > 0) {
8818
8819                if (!(
8820                        /^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,15}$/i
8821                    ).test($(this).val())) {
8822                    $(this).addClass("has-error");
8823                    valid = false;
8824                }
8825            }
8826        }
8827    );
8828
8829    $(".file-require", form).each(function (key, value) {
8830        if ($(this).parents('.label-require-file').find('span.area-file').hasClass(
8831                'area-file')) {
8832            $(this).parents('.label-require-file').addClass("has-error");
8833            valid = false;
8834        }
8835    });
8836
8837    if (params !== null) {
8838
8839        for (key in params) {
8840
8841            if (params[key].selector.length > 0) {
8842                params[key].selector.removeClass('has-error');
8843
8844                if (params[key].value.length <= 0) {
8845                    params[key].selector.addClass('has-error');
8846                    valid = false;
8847                }
8848            }
8849        }
8850    }
8851
8852
8853    return valid;
8854}
8855
8856
8857function buildFormValues(form, params) {
8858
8859    params = params || null;
8860
8861    var formSendAll = new FormData();
8862
8863
8864    if (params) {
8865        for (key in params) {
8866            formSendAll.append(key, params[key]);
8867        }
8868    }
8869
8870    form_arr = form.find(':input,select,textarea').serializeArray();
8871
8872
8873    for (var i = 0; i < form_arr.length; i++) {
8874        if (form_arr[i].value.length > 0)
8875            formSendAll.append(form_arr[i].name, form_arr[i].value);
8876
8877
8878    };
8879
8880    if (form.hasClass('file-download')) {
8881        form.find('input[type=file]').each(function (key) {
8882
8883            var inp = $(this);
8884            var file_list_name = "";
8885
8886            $(inp[0].files).each(
8887                function (k) {
8888                    formSendAll.append(inp.attr('name'), inp[0].files[k], inp[0].files[k].name);
8889                }
8890            );
8891
8892        });
8893    }
8894
8895    return formSendAll;
8896}
8897
8898$(document).on("click", ".btn-submit-review", function () {
8899    var form = $(this).parents("form.form-review"),
8900        load = form.find(".preloader-simple"),
8901        btn = $(this),
8902        moderateMode = $("input.review-moderate-mode").val(),
8903        panelProcess = $(".wr-panel-process", form),
8904        panelSuccess = $(".wr-panel-success", form),
8905        footer = $("div.footer", form);
8906
8907    paramsValid = {
8908        "rating": {
8909            "selector": $(".wr-rating", form),
8910            "value": $(".stars_container", form).attr('data-rating')
8911        }
8912    };
8913
8914
8915    if (!validForm(form, paramsValid)) {
8916        formAttentionScroll(form.find('.has-error:first').offset().top - form.offset().top, ".fly-block");
8917        return false;
8918    } else {
8919        load.addClass('active');
8920        btn.removeClass('active');
8921
8922        var params = {
8923            "send": "Y",
8924            "site_id": $("input.site_id").val(),
8925            "VOTE": $(".stars_container", form).attr('data-rating')
8926        };
8927        var formSendAll = buildFormValues(form, params);
8928
8929        var path = "/bitrix/tools/concept.phoenix/ajax/reviews/add.php";
8930
8931
8932        $.ajax({
8933            url: path,
8934            method: 'POST',
8935            contentType: false,
8936            processData: false,
8937            data: formSendAll,
8938            dataType: 'json',
8939            success: function (json) {
8940                if (json.OK == "Y") {
8941                    panelProcess.addClass('d-none');
8942                    footer.addClass('d-none');
8943                    panelSuccess.removeClass('d-none');
8944
8945                    $.ajax({
8946                        url: "/bitrix/tools/concept.phoenix/ajax/ajax_hit_page.php",
8947                        method: 'POST',
8948                        success: function (json) {}
8949                    });
8950
8951                    /*setTimeout(function() {
8952
8953                        location.href = location.href;
8954                    }, 3000);*/
8955
8956
8957                } else if (json.OK == "N") {
8958                    load.removeClass('active');
8959                    btn.addClass('active');
8960                }
8961
8962            }
8963        });
8964    }
8965
8966    return true;
8967
8968});
8969
8970var reviewsLike = {},
8971    reviewsLikeParse = {};
8972
8973function setReviewsLike() {
8974
8975    for (key in reviewsLikeParse) {
8976        $(".review-item[data-review-id='" + key.replace("like-", "") + "']").find(".review-like").addClass('selected');
8977    }
8978
8979}
8980
8981function getReviewsLikeCookie() {
8982    reviewsLike = BX.getCookie($(".domen-url-for-cookie").val() + '_phoenix_reviewsLike');
8983
8984    if (reviewsLike)
8985        reviewsLikeParse = JSON.parse(reviewsLike);
8986}
8987
8988function setReviewsLikeCookie(id, value) {
8989    reviewsLikeParse["like-" + id] = value;
8990    BX.setCookie($(".domen-url-for-cookie").val() + '_phoenix_reviewsLike', JSON.stringify(reviewsLikeParse), {
8991        expires: 60 * 60 * 60 * 60,
8992        path: "/"
8993    });
8994}
8995
8996function deleteReviewsLikeCookie(id) {
8997    delete reviewsLikeParse["like-" + id];
8998    BX.setCookie($(".domen-url-for-cookie").val() + '_phoenix_reviewsLike', JSON.stringify(reviewsLikeParse), {
8999        expires: 60 * 60 * 60 * 60,
9000        path: "/"
9001    });
9002}
9003
9004
9005var likeProcess = false;
9006
9007$(document).on("click", ".review-like", function () {
9008    if (likeProcess)
9009        return false;
9010
9011    var btn = $(this),
9012        reviewNode = $(this).parents(".review-item"),
9013        reviewID = reviewNode.attr("data-review-id"),
9014        countLikeNode = reviewNode.find(".review-like-count"),
9015        action = btn.hasClass('selected') ? "unlike" : "like";
9016
9017    likeProcess = true;
9018
9019
9020    var path = "/bitrix/tools/concept.phoenix/ajax/reviews/update_like.php";
9021
9022    var formSendAll = new FormData();
9023    formSendAll.append("REVIEW_ID", reviewID);
9024    formSendAll.append("ACTION", action);
9025    formSendAll.append("site_id", $("input.site_id").val());
9026    formSendAll.append("sessid", (typeof BX !== "undefined" && typeof BX.bitrix_sessid === "function") ? BX.bitrix_sessid() : "");
9027
9028    $.ajax({
9029        url: path,
9030        method: 'POST',
9031        contentType: false,
9032        processData: false,
9033        data: formSendAll,
9034        dataType: 'json',
9035        success: function (json) {
9036            likeProcess = false;
9037
9038            if (json.OK == "Y") {
9039                if (action === "like") {
9040                    btn.addClass('selected');
9041                    setReviewsLikeCookie(reviewID, 1);
9042                } else {
9043                    btn.removeClass('selected');
9044                    deleteReviewsLikeCookie(reviewID);
9045                }
9046
9047                if (parseInt(json.LIKE_COUNT) > 0) {
9048                    countLikeNode.html("+" + json.LIKE_COUNT);
9049                    countLikeNode.addClass('plus');
9050                } else {
9051                    countLikeNode.html(0);
9052                    countLikeNode.removeClass('plus');
9053                }
9054
9055                countLikeNode.attr("data-count", json.LIKE_COUNT);
9056
9057            }
9058
9059        }
9060    });
9061});
9062
9063
9064
9065function ajaxGetReviews(params) {
9066    var path = "/bitrix/tools/concept.phoenix/ajax/reviews/reviews_block.php";
9067    params = params || 0;
9068
9069    showProcessLoad();
9070
9071    if (params.this.hasClass('btn-filter'))
9072        params.this.parents(".group-list-simple").find(".btn-filter").removeClass('selected');
9073
9074
9075    $.post(path, {
9076            site_id: $("input.site_id").val(),
9077            id: $(".review-block-ajax").attr("data-product-id"),
9078            page: params.pageNum,
9079            filter: params.filter,
9080            mode: "list"
9081
9082        },
9083        function (html) {
9084            closeProcessLoad();
9085
9086            getReviewsLikeCookie();
9087
9088            setTimeout(function () {
9089                setReviewsLike();
9090            }, 700);
9091
9092
9093            if (params.this.hasClass('getReviews')) {
9094                $(".review-block-ajax .wr-review-list").append(html);
9095                params.this.remove();
9096            } else if (params.this.hasClass('btn-filter')) {
9097                $(".review-block-ajax .wr-review-list").html(html);
9098                params.this.addClass('selected');
9099            }
9100        }
9101    );
9102}
9103
9104$(document).on("click", ".getReviews", function () {
9105    var params = {
9106        "this": $(this),
9107        "pageNum": $(this).attr("data-page"),
9108        "filter": $(this).attr("data-filter"),
9109    };
9110    ajaxGetReviews(params);
9111});
9112
9113$(document).on("click", ".btn-filter.active:not(.selected)", function () {
9114    var params = {
9115        "this": $(this),
9116        "pageNum": 0,
9117        "filter": $(this).attr("data-filter"),
9118
9119    };
9120    ajaxGetReviews(params);
9121});
9122
9123
9124
9125function ajaxReviewsBlock() {
9126
9127    if ($(".review-block-ajax").length > 0) {
9128        var path = "/bitrix/tools/concept.phoenix/ajax/reviews/reviews_block.php";
9129
9130        $.post(path, {
9131                site_id: $("input.site_id").val(),
9132                id: $(".review-block-ajax").attr("data-product-id"),
9133                mode: "full"
9134            },
9135            function (html) {
9136                $(".review-block-ajax").html(html);
9137                getReviewsLikeCookie();
9138                setReviewsLike();
9139                $('[data-toggle="tooltip-ajax"]').tooltip({
9140                    html: true
9141                });
9142            }
9143        );
9144    }
9145}
9146
9147$(document).ready(function () {
9148    ajaxReviewsBlock();
9149});
9150
9151$(document).on("click", ".btn-show-container", function () {
9152    $(this).parents(".wr-hidden-container").find(".hidden-container").removeClass('d-none');
9153    $(this).remove();
9154});
9155
9156
9157
9158var arrBasketFilter = {},
9159    arrDelayFilter = {};
9160
9161
9162function BasketFilter(query) {
9163    query = query || "";
9164
9165    if (query.length <= 0)
9166        $(".basket-items-search-clear-btn").addClass('d-none');
9167    else {
9168        $(".basket-items-search-clear-btn").removeClass('d-none');
9169    }
9170
9171    query = query.toLowerCase();
9172
9173    var realKey = "",
9174        productName = "",
9175        arrSearchBasket = {},
9176        selector = "";
9177
9178
9179    if ($(".tab_item[data-items='items']").hasClass('active')) {
9180        arrSearchBasket = arrBasketFilter;
9181        selector = $("#basket_items");
9182    }
9183
9184
9185    if ($(".tab_item[data-items='delayed']").hasClass('active')) {
9186        arrSearchBasket = arrDelayFilter;
9187        selector = $("#delayed_items");
9188    }
9189
9190    for (key in arrSearchBasket) {
9191
9192        realKey = key.replace('id_', '');
9193
9194        if (!(arrSearchBasket[key].QUERY.indexOf(query) !== -1))
9195            selector.find(".product#" + realKey).addClass('d-none').find(".product-name").html(arrSearchBasket[key].NAME);
9196
9197
9198        else {
9199
9200            productName = arrSearchBasket[key].NAME.slice(arrSearchBasket[key].QUERY.indexOf(query), arrSearchBasket[key].QUERY.indexOf(query) + query.length);
9201            productName = arrSearchBasket[key].NAME.replace(productName, "<span class='highlight'>" + productName + "</span>");
9202
9203            selector.find(".product#" + realKey).removeClass('d-none').find(".product-name").html(productName);
9204        }
9205    }
9206
9207    delete arrSearchBasket;
9208
9209
9210}
9211
9212
9213$(document).on({
9214        keyup: function () {
9215            BasketFilter($(this).val());
9216        },
9217
9218        paste: function () {
9219            BasketFilter($(this).val());
9220        },
9221
9222        cut: function () {
9223            BasketFilter($(this).val());
9224        },
9225
9226        blur: function () {
9227            BasketFilter($(this).val());
9228        },
9229    },
9230    "input.basket-filter"
9231);
9232
9233
9234function clearInput(input) {
9235    input.val("").attr("placeholder", input.attr("data-placeholder"));
9236}
9237
9238$(document).on({
9239        click: function () {
9240            BasketFilter("");
9241            clearInput($("input.basket-filter"));
9242        },
9243    },
9244    ".basket-items-search-clear-btn"
9245);
9246
9247function initPhoneMask() {
9248    $(document).on("focus", "form input.phone",
9249        function () {
9250            /*if (!device.android())*/
9251                $(this).mask($("input.mask-phone").val());
9252        }
9253    );
9254}
9255
9256
9257function getTermination(num, array) {
9258    num = num.toString();
9259    var number = num.substring(num.length, -2);
9260    var term = "";
9261
9262    if (number > 10 && number < 15) {
9263        term = array[3];
9264    } else {
9265
9266        number = num.substring(num.length, -1);
9267
9268        if (number == 0) {
9269            term = array[0];
9270        }
9271        if (number == 1) {
9272            term = array[1];
9273        }
9274        if (number > 1) {
9275            term = array[2];
9276        }
9277        if (number > 4) {
9278            term = array[3];
9279        }
9280    }
9281
9282    return term;
9283}
9284
9285
9286$(document).on('click', '.open-dialog-window',
9287    function () {
9288
9289        if ($(this).attr("data-typename")) {
9290            var params = {
9291                "typeName": $(this).attr("data-typename"),
9292                "elementID": $(this).attr("data-elementid"),
9293                "blockTitle": $(this).attr("data-blocktitle"),
9294                "iblockID": $("input#LAND_iblockID").val(),
9295                "iblockTypeID": $("input#LAND_iblockTypeID").val(),
9296                "site_id": $("input.site_id").val()
9297            };
9298
9299            callDialogWindow(params);
9300        }
9301
9302    }
9303);
9304
9305function callDialogWindow(params) {
9306
9307    params = params || null;
9308
9309    if (params) {
9310        showProcessLoad();
9311        startBlurWrapperContainer();
9312
9313        $.post("/bitrix/tools/concept.phoenix/ajax/popup/modal.php", params,
9314            function (html) {
9315                closeProcessLoad();
9316                $(".modalAreaDetail").html(html);
9317
9318                setTimeout(function () {
9319                    $('div.modalAreaDetail').find('.phoenix-modal').addClass('active');
9320                }, 100);
9321            });
9322    }
9323}
9324
9325
9326function getHtmlStoreList(PRODUCT_ID, STORE, MEASURE) {
9327    if ($("input.tab-store").length > 0) {
9328
9329        if (STORE.length <= 0) {
9330            $(".ajax_store_area").html("");
9331            return true;
9332        }
9333
9334        clearTimeout($.data(this, 'store_block'));
9335
9336        $.data(this, 'store_block', setTimeout($.proxy(function () {
9337
9338            showProcessLoadItem("store_block");
9339            $.ajax({
9340                url: '/bitrix/tools/concept.phoenix/ajax/store_list.php',
9341                method: 'POST',
9342                data: {
9343                    site_id: $("input.site_id").val(),
9344                    TAB: $("input.tab-store").val(),
9345                    PRODUCT_ID: PRODUCT_ID,
9346                    STORE: STORE,
9347                    MEASURE: MEASURE
9348                },
9349                success: function (data) {
9350
9351                    setTimeout(function () {
9352                        closeProcessLoadItem("store_block");
9353                        $(".ajax_store_area").html(data);
9354                    }, 300);
9355
9356
9357                }
9358            });
9359        }, this), 700));
9360    }
9361}
9362
9363$(document).on("click", ".bx_storege .btn-tab", function () {
9364    $(".bx_storege").find(".btn-tab").removeClass('active');
9365    $(".bx_storege").find(".tab-content").addClass('d-none');
9366    $(this).addClass('active');
9367    $(".tab-content[data-content='" + $(this).attr("data-content") + "']").removeClass('d-none');
9368});
9369
9370$(document).on("click", ".bx_storege .list-item.flat", function () {
9371
9372    $(".bx_storege").find(".back2list").removeClass('d-none');
9373    $(".bx_storege").find(".list-item.flat").addClass('d-none');
9374    $(".bx_storege").find(".detail-item.flat").addClass('d-none');
9375
9376    $(".detail-item.flat[data-content='" + $(this).attr("data-content") + "']").removeClass('d-none');
9377});
9378
9379
9380$(document).on("click", ".bx_storege .back2list", function () {
9381    $(this).addClass('d-none');
9382    $(".bx_storege").find(".list-item.flat").removeClass('d-none');
9383    $(".bx_storege").find(".detail-item.flat").addClass('d-none');
9384});
9385
9386function preparePopupBlockStore() {
9387    if ($(".popup-block[data-popup='store-block']").length > 0) {
9388        var clone = $(".popup-block[data-popup='store-block']").clone();
9389        $(".popup-block[data-popup='store-block']").remove();
9390        clone.appendTo('body');
9391    }
9392}
9393
9394$(document).ready(function () {
9395    preparePopupBlockStore();
9396});
9397
9398
9399PopupWindow = {
9400
9401    init: function (container, params) {
9402
9403        if (container.length <= 0)
9404            return false;
9405
9406        params = params || {};
9407
9408        if (params.ajax) {
9409            console.log('ajax');
9410        } else {
9411            PopupWindow.show(container, params);
9412        }
9413    },
9414    show: function (container, params) {
9415
9416        if (container.hasClass('animated')) {
9417
9418        } else {
9419            container.removeClass("d-none");
9420
9421            var cartOut = setTimeout(function () {
9422                container.addClass('active');
9423                clearTimeout(cartOut);
9424            }, 300);
9425
9426        }
9427
9428
9429        startBlurWrapperContainer({
9430            "blur": params.blur
9431        });
9432
9433
9434        if (params.hideContainer)
9435            $(params.hideContainer).addClass('d-none');
9436
9437
9438    },
9439    hide: function (container, params) {
9440        var timeHide = 300;
9441
9442        if (container.hasClass('animated')) {
9443            if (container.hasClass('fadeInUp')) {
9444                container.removeClass('fadeInUp');
9445                if (typeof container.attr("data-animate-out") != "undefined") {
9446                    var animateOut = container.attr("data-animate-out");
9447                    container.addClass(animateOut);
9448
9449                    timeHide = 1500;
9450                }
9451
9452            }
9453        } else {
9454            container.removeClass('active');
9455        }
9456
9457        var cartOut = setTimeout(function () {
9458            container.addClass('d-none');
9459            clearTimeout(cartOut);
9460        }, timeHide);
9461
9462        if (params.blur)
9463            stopBlurWrapperContainer();
9464    }
9465
9466};
9467
9468
9469$(document).on('click', '.show-popup-block', function () {
9470    var container = $('.popup-block[data-popup="' + $(this).attr("data-popup") + '"]'),
9471        params = {
9472            "blur": false,
9473            "hideContainer": false
9474        };
9475
9476    if (typeof $(this).attr("data-hide-container") != 'undefined')
9477        params.hideContainer = $(this).attr("data-hide-container");
9478
9479
9480    PopupWindow.init(container, params);
9481});
9482
9483$(document).on('click', '.info-right-side .show-popup-block-store', function () {
9484    var container = $('.popup-block[data-popup="store-block"]'),
9485        params = {
9486            "blur": false
9487        };
9488
9489    PopupWindow.init(container, params);
9490});
9491
9492
9493
9494$(document).on('click', '.hide-popup-block-js', function () {
9495
9496    var container = $(this).parents(".popup-block"),
9497        params = {
9498            "blur": true
9499        };
9500    PopupWindow.hide(container, params);
9501
9502    if ($(this).hasClass('set-first-region-values'))
9503        setFirstRegionValues();
9504
9505});
9506
9507function setFirstRegionValues() {
9508    setTimeout(function () {
9509        $(".value-region").text($("input.region-name").val());
9510    }, 1000);
9511
9512
9513    if ($("input.region-image").val().length > 0) {
9514        $("input.region-image-default").val($("input.region-image").val());
9515        $(".region-popup").find(".left-side").css({
9516            "background-image": "url(" + $("input.region-image-default").val() + ")"
9517        });
9518        $(".region-popup").find(".right-side").css({
9519            "background-image": "url(" + $("input.region-image-default").val() + ")"
9520        });
9521    }
9522
9523    $("input.region-id").val($("input.region-id-current").val());
9524
9525
9526    $("input.region-id-default").val($("input.region-id-current").val());
9527    $("input.region-name-default").val($("input.region-name").val());
9528
9529    if ($("input[name='region-value'][value='" + $("input.region-id-current").val() + "']").length > 0)
9530        $("input[name='region-value'][value='" + $("input.region-id-current").val() + "']").prop("checked", true);
9531    else {
9532        var favorites = $(".region-popup input[type='radio']");
9533
9534        if (favorites.length > 0) {
9535            $(favorites).each(
9536                function (index, element) {
9537                    element.checked = false;
9538                }
9539
9540            );
9541        }
9542    }
9543}
9544
9545function autocompleteRegionAreaSelected(th, ui) {
9546    th.parents(".mode-select").addClass('ok');
9547
9548
9549    var favorites = th.parents("form").find("input[type='radio']");
9550
9551    if (favorites.length > 0) {
9552        $(favorites).each(
9553            function (index, element) {
9554                element.checked = false;
9555            }
9556
9557        );
9558    }
9559
9560
9561    var arRegionsValues = ui.item.value.split(';');
9562    var regionID = arRegionsValues[0];
9563    var regionHref = arRegionsValues[1];
9564    var regionName = arRegionsValues[2];
9565
9566    th.val(ui.item.label);
9567
9568    if (regionName.length > 0)
9569        $(".value-region").text(regionName);
9570    else {
9571        $(".value-region").text(ui.item.label);
9572    }
9573
9574    $("input.region-id").val(regionID);
9575    $(".region-popup .error-input").addClass('d-none');
9576
9577    $(".region-popup").find(".left-side").removeAttr('style');
9578    $(".region-popup").find(".right-side").removeAttr('style');
9579
9580
9581    if (ui.item.icon.length > 0) {
9582        $(".region-popup").find(".left-side").css({
9583            "background-image": "url(" + ui.item.icon + ")"
9584        });
9585        $(".region-popup").find(".right-side").css({
9586            "background-image": "url(" + ui.item.icon + ")"
9587        });
9588
9589    }
9590
9591}
9592
9593
9594function autocompleteRegionAreaChange(th, flag) {
9595
9596    if (flag) {
9597        $("input.autocompleteRegion").parents(".mode-select").addClass('ok');
9598        $(".region-popup .error-input").addClass('d-none');
9599
9600        var favorites = th.parents("form").find("input[type='radio']");
9601
9602        if (favorites.length > 0) {
9603            $(favorites).each(
9604                function (index, element) {
9605                    element.checked = false;
9606                }
9607
9608            );
9609        }
9610    } else {
9611
9612        $("input.autocompleteRegion").val("");
9613
9614        $(".region-popup .error-input").removeClass('d-none');
9615
9616        $("input.autocompleteRegion").parents(".mode-select").removeClass('ok');
9617        $("input.region-id").val($("input.region-id-default").val());
9618
9619        if ($("input[name='region-value'][value='" + $("input.region-id").val() + "']").length > 0)
9620            $("input[name='region-value'][value='" + $("input.region-id").val() + "']").prop("checked", true);
9621
9622
9623
9624        $(".value-region").html($("input.region-name-default").val());
9625
9626        $(".region-popup").find(".right-side").removeAttr('style');
9627        $(".region-popup").find(".left-side").removeAttr('style');
9628
9629        if ($("input.region-image-default").val().length > 0) {
9630            $(".region-popup").find(".left-side").css({
9631                "background-image": "url(" + $("input.region-image-default").val() + ")"
9632            });
9633            $(".region-popup").find(".right-side").css({
9634                "background-image": "url(" + $("input.region-image-default").val() + ")"
9635            });
9636        }
9637    }
9638
9639}
9640
9641
9642$(document).on('click', '.region-popup input[type="radio"]', function () {
9643
9644    var form = $(this).parents("form");
9645    $("input.region-id").val($(this).val());
9646    $(".value-region").text($(this).attr("data-label"));
9647    $(".region-popup .error-input").addClass('d-none');
9648
9649
9650    if ($(window).width() <= 767) {
9651        $("input.autocompleteRegion").val($(this).parent().find("span.text").html());
9652        form.find(".mode-select").addClass('ok');
9653    } else {
9654        $("input.autocompleteRegion").val("");
9655        form.find(".mode-select").removeClass('ok');
9656    }
9657
9658    $(".region-popup").find(".right-side").removeAttr('style');
9659    if ($(this).attr("data-icon").length > 0)
9660        $(".region-popup").find(".right-side").css({
9661            "background-image": "url(" + $(this).attr("data-icon") + ")"
9662        });
9663
9664    $(".region-popup").find(".left-side").removeAttr('style');
9665    if ($(this).attr("data-icon").length > 0)
9666        $(".region-popup").find(".left-side").css({
9667            "background-image": "url(" + $(this).attr("data-icon") + ")"
9668        });
9669
9670
9671});
9672
9673
9674$(document).on("focus", "input.autocompleteRegion", function () {
9675    if ($(this).val().length <= 0) {
9676        $(this).parents(".mode-select").removeClass('ok');
9677    }
9678});
9679$(document).on("blur", "input.autocompleteRegion", function () {
9680    if ($(this).val().length <= 0) {
9681        $(this).parents(".mode-select").removeClass('ok');
9682    }
9683});
9684
9685
9686
9687function setCookieRegion(regionID, submit) {
9688    submit = submit || "";
9689
9690    $.ajax({
9691        url: '/bitrix/tools/concept.phoenix/ajax/update/region_set_cookie.php',
9692        method: 'POST',
9693        data: {
9694            site_id: $("input.site_id").val(),
9695            serverName: $("input.serverName").val(),
9696            curPageUrl: $("input.curPageUrl").val(),
9697            submit: submit,
9698            id: regionID
9699        },
9700        success: function (data) {
9701            if (data.HREF.length > 0) {
9702                setTimeout(function () {
9703                    location.href = data.HREF;
9704                }, 1000);
9705            }
9706            else
9707            {
9708                $('.value-region').html(data.NAME_LOCATION);
9709                $('.value-region-main').html(data.NAME_LOCATION);
9710
9711                var favorites = $(".region-popup input[type='radio']");
9712
9713                if (favorites.length > 0) {
9714                    $(favorites).each(
9715                        function (index, element) {
9716                            element.checked = false;
9717                        }
9718
9719                    );
9720                }
9721
9722                $('input[name="region-value"][value='+data.ID_LOCATION+']').prop("checked", true);
9723               
9724            }
9725        },
9726        error: function () {
9727            $(".submit-region").removeClass("hide-text");
9728            $(".submit-region-load").removeClass('d-block');
9729        }
9730    });
9731}
9732
9733$(document).on("click", ".submit-region", function () {
9734
9735    var regionID = $("input.region-id").val(),
9736        regionDefaultID = $("input.region-id-default").val(),
9737        container = $(this).parents(".popup-block"),
9738        params = {
9739            "blur": true
9740        };
9741
9742
9743    regionID = regionID || regionDefaultID;
9744
9745    $(this).addClass("hide-text");
9746    $(".submit-region-load").addClass('d-block');
9747
9748    setCookieRegion(regionID, "Y");
9749});
9750
9751
9752var subMenuLvl2 = null;
9753
9754document.addEventListener("DOMContentLoaded", function() { 
9755    subMenuLvl2 = document.querySelectorAll(".sub-menu-lvl-2-item-js");
9756
9757    if(subMenuLvl2)
9758    {
9759
9760        if (windowWidth <= 1024)
9761        {
9762            for (var i = 0; i < subMenuLvl2.length; i++)
9763            {
9764                subMenuLvl2[i].addEventListener('click', function()
9765                {
9766                    var target = event.target.closest(".sub-menu-lvl-2-item-js");
9767
9768                    if(!target.classList.contains('active'))
9769                    {
9770                        event.preventDefault();
9771                    }
9772
9773                    showSubMenuLvl2Items(target);
9774                
9775                    
9776                });
9777            }
9778        }
9779        else
9780        {
9781            
9782
9783            for (var i = 0; i < subMenuLvl2.length; i++)
9784            {
9785                subMenuLvl2[i].addEventListener('mouseenter', function()
9786                {
9787                    var target = event.target.closest(".sub-menu-lvl-2-item-js");
9788
9789                    $.data(this, 'timer-'+i, setTimeout($.proxy(function () {
9790                        showSubMenuLvl2Items(target);
9791                    }, this), 100));
9792
9793                });
9794
9795                subMenuLvl2[i].addEventListener('mouseleave', function()
9796                {
9797                    clearTimeout($.data(this, 'timer-'+i));
9798                });
9799            }
9800        }
9801    }
9802});
9803
9804
9805
9806function clearSubMenuLvl2Items()
9807{
9808    var subMenuLvl2Items = document.querySelectorAll(".sub-menu-wr-lvl-3-item-js");
9809
9810    if(subMenuLvl2Items)
9811    {
9812        for (var i = 0; i < subMenuLvl2Items.length; i++)
9813        {
9814            subMenuLvl2Items[i].classList.remove('active');
9815        }
9816    }
9817    if(subMenuLvl2)
9818    {
9819        for (var i = 0; i < subMenuLvl2.length; i++)
9820        {
9821            subMenuLvl2[i].classList.remove('active');
9822        }
9823    }
9824}
9825
9826function showSubMenuLvl2Items(target){
9827    var attr = target.getAttribute('data-sub-menu-lvl-2'),
9828        groupItems = document.querySelector(".sub-menu-wr-lvl-3-item-js[data-sub-menu-lvl-2='"+attr+"']");
9829
9830    clearSubMenuLvl2Items();
9831
9832    if(groupItems)
9833        groupItems.classList.add('active');
9834
9835    target.classList.add('active');
9836    $('.lazyload').Lazy(paramsLazy);
9837}
9838
9839
9840function menuLvls4Selected(th){
9841    var itemSelected = th.find('.sub-menu-lvl-2-item-js.selected'),
9842        items = th.find('.sub-menu-lvl-2-item-js');
9843
9844    clearSubMenuLvl2Items();
9845
9846
9847    if(itemSelected.length<=0 && items.length>0){
9848        items[0].classList.add('active');
9849        $(".sub-menu-wr-lvl-3-item-js[data-sub-menu-lvl-2="+items[0].getAttribute('data-sub-menu-lvl-2')+"]").addClass('active');
9850    }
9851    else if(itemSelected.length>0)
9852    {
9853        itemSelected[0].classList.add('active');
9854        $(".sub-menu-wr-lvl-3-item-js[data-sub-menu-lvl-2="+itemSelected[0].getAttribute('data-sub-menu-lvl-2')+"]").addClass('active');
9855    }
9856}
9857
9858
9859
9860function getCatalogStories(){
9861
9862    if($(".catalog-stories-ajax").length>0)
9863    {
9864
9865        $.ajax({
9866            url: '/bitrix/tools/concept.phoenix/ajax/catalog_stories.php',
9867            method: 'POST',
9868            data: {
9869                site_id: $("input.site_id").val(),
9870                COUNT: $(".catalog-stories-ajax").attr('data-count'),
9871            },
9872            success: function (data) {
9873                $(".catalog-stories-ajax").append(data);   
9874            }
9875        });
9876    }
9877}
9878
9879(function (window) {
9880
9881if (!!window.JCSaleGiftBasket)
9882{
9883    return;
9884}
9885
9886window.JCSaleGiftBasket = function (arParams)
9887{
9888    this.element = arParams;
9889    this.nodes = {};
9890    this.currentElement = {};
9891    this.oldElement = {};
9892    this.errorCode = 0;
9893    this.firstLoad = true;
9894    this.selectedValues = {};
9895    this.firstLoad = false;
9896
9897
9898    if (typeof arParams === 'object') {
9899        this.initConfig();
9900
9901        switch (this.element.PRODUCT_TYPE) {
9902            case 0:
9903            case 1:
9904            case 2:
9905
9906                this.initProductData();
9907                break;
9908            case 3:
9909                this.initOffersData();
9910                break;
9911            default:
9912                this.errorCode = -1;
9913        }
9914    }
9915
9916
9917    if (this.errorCode === 0)
9918        BX.ready(BX.delegate(this.init, this));
9919};
9920
9921window.JCSaleGiftBasket.prototype = {
9922    initConfig: function () {
9923        this.element.PRODUCT_TYPE = parseInt(this.element.PRODUCT_TYPE, 10);
9924        this.nodes.obProduct = document.querySelector("#"+this.element.VISUAL.ID);
9925        this.nodes.obProductItem = this.nodes.obProduct.querySelector('.gift-item-js');
9926        this.nodes.obImg = this.nodes.obProduct.querySelector('.gift-item-img-js');
9927        this.nodes.obImgLink = this.nodes.obProduct.querySelector('.gift-item-img-link-js');
9928        this.nodes.obPrice = this.nodes.obProduct.querySelector('.gift-item-price-js');
9929        this.nodes.obName = this.nodes.obProduct.querySelector('.gift-item-name-js');
9930        this.nodes.obSku = this.nodes.obProduct.querySelector('.sku-container-js');
9931        this.nodes.obBtn = this.nodes.obProduct.querySelector('.gift-item-btn-js');
9932
9933        this.nodes.obBtn && BX.bind(this.nodes.obBtn, 'click', BX.proxy(this.SendToBasket, this));
9934
9935    },
9936
9937    initProductData: function () {
9938        
9939        this.currentElement = this.element;
9940        this.oldElement = this.currentElement;
9941
9942        this.setPrice();
9943
9944        if(this.currentElement.CAN_BUY)
9945        {
9946            this.nodes.obProduct.classList.remove('d-none');
9947        }
9948        else
9949        {
9950            this.nodes.obProduct.remove();
9951        }
9952
9953
9954        
9955    },
9956
9957    initOffersData: function () {
9958
9959        if (this.element.CONFIG.SHOW_OFFERS)
9960        {
9961            this.currentElement = this.element.OFFERS[this.element.OFFER_ID_SELECTED];
9962
9963            var treeItems = this.nodes.obSku.querySelectorAll('li');
9964
9965            for (i = 0; i < treeItems.length; i++) {
9966                BX.bind(treeItems[i], 'click', BX.delegate(this.selectOfferProp, this));
9967            }
9968
9969            this.setCurrent();
9970
9971        }
9972    },
9973
9974    selectOfferProp: function () {
9975            var i = 0,
9976                strTreeValue = '',
9977                arTreeItem = [],
9978                rowItems = null,
9979                target = BX.proxy_context,
9980                smallCardItem;
9981
9982
9983            if (target && target.hasAttribute('data-treevalue')) {
9984                if (BX.hasClass(target, 'active'))
9985                    return;
9986
9987
9988
9989                if (typeof document.activeElement === 'object') {
9990                    document.activeElement.blur();
9991                }
9992
9993
9994
9995                strTreeValue = target.getAttribute('data-treevalue');
9996                arTreeItem = strTreeValue.split('_');
9997
9998                this.searchOfferPropIndex(arTreeItem[0], arTreeItem[1]);
9999
10000
10001                rowItems = BX.findChildren(target.parentNode, {
10002                    tagName: 'li'
10003                }, false);
10004
10005
10006                if (rowItems && rowItems.length) {
10007                    for (i = 0; i < rowItems.length; i++) {
10008                        BX.removeClass(rowItems[i], 'active');
10009                    }
10010                }
10011
10012
10013                BX.addClass(target, 'active');
10014
10015            }
10016        },
10017
10018        searchOfferPropIndex: function (strPropID, strPropValue) {
10019            var strName = '',
10020                arShowValues = false,
10021                arCanBuyValues = [],
10022                allValues = [],
10023                index = -1,
10024                i, j,
10025                arFilter = {},
10026                tmpFilter = [];
10027
10028
10029
10030            for (i = 0; i < this.element.TREE_PROPS.length; i++) {
10031                if (this.element.TREE_PROPS[i].ID === strPropID) {
10032                    index = i;
10033                    break;
10034                }
10035            }
10036
10037            if (index > -1) {
10038                for (i = 0; i < index; i++) {
10039                    strName = 'PROP_' + this.element.TREE_PROPS[i].ID;
10040                    arFilter[strName] = this.selectedValues[strName];
10041                }
10042
10043
10044                strName = 'PROP_' + this.element.TREE_PROPS[index].ID;
10045                arFilter[strName] = strPropValue;
10046
10047
10048
10049                for (i = index + 1; i < this.element.TREE_PROPS.length; i++) {
10050
10051                    strName = 'PROP_' + this.element.TREE_PROPS[i].ID;
10052                    arShowValues = this.getRowValues(arFilter, strName);
10053
10054
10055
10056                    if (!arShowValues)
10057                        break;
10058
10059                    allValues = [];
10060
10061                    if (this.element.SHOW_ABSENT === 'Y') {
10062
10063                        arCanBuyValues = [];
10064                        tmpFilter = [];
10065                        tmpFilter = BX.clone(arFilter, true);
10066
10067                        for (j = 0; j < arShowValues.length; j++) {
10068                            tmpFilter[strName] = arShowValues[j];
10069                            allValues[allValues.length] = arShowValues[j];
10070                            if (this.getCanBuy(tmpFilter))
10071                                arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
10072                        }
10073                    } else {
10074                        arCanBuyValues = arShowValues;
10075                    }
10076
10077
10078
10079
10080                    if (this.selectedValues[strName] && BX.util.in_array(this.selectedValues[strName], arC
10080anBuyValues)) {
10081                        arFilter[strName] = this.selectedValues[strName];
10082
10083                    } else {
10084
10085                        if (this.element.SHOW_ABSENT === 'Y') {
10086                            arFilter[strName] = (arCanBuyValues.length ? arCanBuyValues[0] : allValues[0]);
10087                        } else {
10088                            arFilter[strName] = arCanBuyValues[0];
10089                        }
10090                    }
10091
10092
10093
10094                    this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
10095
10096                }
10097
10098
10099                this.selectedValues = arFilter;
10100
10101                this.changeInfo();
10102
10103            }
10104
10105        },
10106
10107        setCurrent: function () {
10108            var i,
10109                j = 0,
10110                strName = '',
10111                arShowValues = false,
10112                arCanBuyValues = [],
10113                arFilter = {},
10114                tmpFilter = [],
10115                current = this.currentElement.TREE;
10116
10117
10118            for (i = 0; i < this.element.TREE_PROPS.length; i++) {
10119                strName = 'PROP_' + this.element.TREE_PROPS[i].ID;
10120                arShowValues = this.getRowValues(arFilter, strName);
10121
10122
10123                if (!arShowValues)
10124                    break;
10125
10126                if (BX.util.in_array(current[strName], arShowValues)) {
10127                    arFilter[strName] = current[strName];
10128                } else {
10129                    arFilter[strName] = arShowValues[0];
10130                    this.element.OFFER_ID_SELECTED = 0;
10131                }
10132
10133
10134                if (this.element.CONFIG.SHOW_ABSENT === 'Y') {
10135                    arCanBuyValues = [];
10136                    tmpFilter = [];
10137                    tmpFilter = BX.clone(arFilter, true);
10138
10139                    for (j = 0; j < arShowValues.length; j++) {
10140                        tmpFilter[strName] = arShowValues[j];
10141
10142                        if (this.getCanBuy(tmpFilter)) {
10143                            arCanBuyValues[arCanBuyValues.length] = arShowValues[j];
10144                        }
10145                    }
10146                } else {
10147                    arCanBuyValues = arShowValues;
10148                }
10149
10150                this.updateRow(i, arFilter[strName], arShowValues, arCanBuyValues);
10151            }
10152
10153            this.selectedValues = arFilter;
10154
10155            this.changeInfo();
10156        },
10157        getCanBuy: function (arFilter) {
10158            var i,
10159                j = 0,
10160                boolOneSearch = true,
10161                boolSearch = false;
10162
10163            for (i = 0; i < this.element.OFFERS.length; i++) {
10164                boolOneSearch = true;
10165
10166                for (j in arFilter) {
10167                    if (arFilter[j] !== this.element.OFFERS[i].TREE[j]) {
10168                        boolOneSearch = false;
10169                        break;
10170                    }
10171                }
10172
10173                if (boolOneSearch) {
10174
10175                    if (this.element.OFFERS[i].CAN_BUY) {
10176                        boolSearch = true;
10177                        break;
10178                    }
10179                }
10180            }
10181
10182            return boolSearch;
10183        },
10184
10185        getRowValues: function (arFilter, index) {
10186            var arValues = [],
10187                i = 0,
10188                j = 0,
10189                boolSearch = false,
10190                boolOneSearch = true;
10191
10192
10193
10194            if (arFilter.length === 0) {
10195                for (i = 0; i < this.element.OFFERS.length; i++) {
10196                    if (!BX.util.in_array(this.element.OFFERS[i].TREE[index], arValues)) {
10197                        arValues[arValues.length] = this.element.OFFERS[i].TREE[index];
10198
10199                    }
10200                }
10201                boolSearch = true;
10202            } else {
10203                for (i = 0; i < this.element.OFFERS.length; i++) {
10204                    boolOneSearch = true;
10205
10206                    for (j in arFilter) {
10207                        if (arFilter[j] !== this.element.OFFERS[i].TREE[j]) {
10208                            boolOneSearch = false;
10209                            break;
10210                        }
10211                    }
10212
10213                    if (boolOneSearch) {
10214                        if (!BX.util.in_array(this.element.OFFERS[i].TREE[index], arValues)) {
10215                            arValues[arValues.length] = this.element.OFFERS[i].TREE[index];
10216
10217                        }
10218
10219                        boolSearch = true;
10220                    }
10221                }
10222            }
10223
10224
10225
10226            return (boolSearch ? arValues : false);
10227        },
10228
10229        updateRow: function (intNumber, activeId, showId, canBuyId) {
10230
10231            var i = 0,
10232                value = '',
10233                isCurrent = false,
10234                rowItems = null;
10235
10236
10237            var lineContainer = this.nodes.obSku.querySelectorAll('.wr-sku-props');
10238
10239
10240            if (intNumber > -1 && intNumber < lineContainer.length) {
10241                rowItems = lineContainer[intNumber].querySelectorAll('li');
10242
10243                for (i = 0; i < rowItems.length; i++) {
10244                    value = rowItems[i].getAttribute('data-onevalue');
10245                    isCurrent = value === activeId;
10246
10247                    if (isCurrent) {
10248                        BX.addClass(rowItems[i], 'active');
10249                    } else {
10250                        BX.removeClass(rowItems[i], 'active');
10251                    }
10252
10253                    if (BX.util.in_array(value, canBuyId)) {
10254                        BX.removeClass(rowItems[i], 'notallowed');
10255                    } else {
10256                        BX.addClass(rowItems[i], 'notallowed');
10257                    }
10258
10259                    rowItems[i].style.display = BX.util.in_array(value, showId) ? '' : 'none';
10260
10261                    if (isCurrent) {
10262                        lineContainer[intNumber].style.display = (value == 0) ? 'none' : '';
10263                    }
10264                }
10265            }
10266        },
10267
10268        changeInfo: function () {
10269
10270            var index = -1,
10271                j = 0,
10272                boolOneSearch = true,
10273                descTitle = null,
10274                rowItems = null;
10275
10276            var i;
10277
10278            for (i = 0; i < this.element.OFFERS.length; i++) {
10279                boolOneSearch = true;
10280
10281                for (j in this.selectedValues) {
10282
10283                    if (this.selectedValues[j] !== this.element.OFFERS[i].TREE[j]) {
10284                        boolOneSearch = false;
10285                        break;
10286                    }
10287
10288                }
10289
10290                if (boolOneSearch) {
10291                    index = i;
10292                    break;
10293                }
10294            }
10295
10296            this.oldElement = this.currentElement;
10297
10298            this.element.OFFER_ID_SELECTED = index;
10299            this.currentElement = this.element.OFFERS[this.element.OFFER_ID_SELECTED];
10300
10301            this.setPrice();
10302
10303            if (!this.firstLoad) {
10304                this.drawPicture();
10305                this.changeDetailUrl(this.currentElement.ID);
10306            }
10307        },
10308        drawPicture: function (){
10309            this.nodes.obImg.src = this.currentElement.PHOTO;
10310            this.nodes.obImg.alt = this.element.ALT;
10311            
10312        },
10313        changeDetailUrl: function (){
10314            this.nodes.obName.href = this.nodes.obImgLink.href = this.currentElement.DETAIL_PAGE_URL;
10315        },
10316
10317        setPrice: function (){
10318            this.nodes.obPrice.innerHTML = this.currentElement.PRICE.PRINT_VALUE;
10319            this.nodes.obPrice.title=this.currentElement.PRICE.VALUE;
10320
10321            if (!this.currentElement.CAN_BUY){
10322                this.nodes.obBtn.parentNode.classList.add('hidden');
10323            }
10324            else
10325            {
10326                this.nodes.obBtn.parentNode.classList.remove('hidden');
10327            }
10328        },
10329        SendToBasket: function (){
10330
10331            if (!this.currentElement.CAN_BUY)
10332                return;
10333
10334            var productID = '',
10335                value = 1;
10336
10337            if (this.nodes.obQuantity)
10338                value = this.nodes.obQuantity.value;
10339
10340            productItem = {
10341                PRODUCT_ID: this.currentElement.ID,
10342                QUANTITY: value,
10343                PRICE_ID: this.currentElement.PRICE.PRICE_ID
10344            };
10345
10346            showProcessLoad();
10347            BX.ajax({
10348                method: 'POST',
10349                dataType: 'json',
10350                url: '/bitrix/tools/concept.phoenix/ajax/basket/add2basket.php',
10351                data: {
10352                    productItem: productItem,
10353                    site_id: $("input.site_id").val()
10354                },
10355                onsuccess: BX.proxy(this.basketResult, this)
10356            });
10357        },
10358        basketResult: function (arResult) {
10359            closeProcessLoad();
10360            if (arResult["OK"] == "Y") {
10361                setInfoBasket();
10362        }
10363
10364        
10365    },
10366};
10367
10368})(window);

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.