PageSourceSearch

https://www.wilsonsdachboden.com/wp-content/themes/ceris/js/scripts.js?ver=7.1.2

js wilsonsdachboden.com collected 2026-10-02 06:15:54 UTC 223,820 bytes, 4,643 lines download raw bytes

1var ATBS = ATBS || {};
2
3(function($){
4
5    // USE STRICT
6    "use strict";
7
8    var $window = $(window);
9    var $document = $(document);
10    var $goToTopEl = $('.js-go-top-el');
11    var $overlayBg = $('.js-overlay-bg');
12    $(".single-body").fitVids();
13    
14    ATBS.header = {
15
16        init: function(){
17            ATBS.header.pageBlockHeadingInit();
18            ATBS.header.pagiButton();
19            ATBS.header.ajaxSearch();
20            ATBS.header.ajaxMegamenu();
21            ATBS.header.loginForm();
22            ATBS.header.offCanvasMenu();
23            ATBS.header.priorityNavInit();
24            ATBS.header.searchToggle();
25            ATBS.header.smartAffix.init({
26                fixedHeader: '.js-sticky-header',
27                headerPlaceHolder: '.js-sticky-header-holder',
28            });
29            ATBS.header.smartFooterInfo.init({
30                fixedFooter: '.js-sticky-article-info',
31            });
32        },
33        
34        pageBlockHeadingInit: function(){
35            if($('.site-wrapper').hasClass('ceris-block-heading-loading')) {
36                $('.site-wrapper').removeClass('ceris-block-heading-loading');
37            }
38        },
39        /* ============================================================================
40         * Fix sticky navbar padding when open modal
41         * ==========================================================================*/
42        stickyNavbarPadding: function() {
43            var oldSSB = $.fn.modal.Constructor.prototype.setScrollbar;
44            var $stickyHeader = $('.sticky-header .navigation-bar');
45
46            $.fn.modal.Constructor.prototype.setScrollbar = function () 
47            {
48                oldSSB.apply(this);
49                if(this.bodyIsOverflowing && this.scrollbarWidth) 
50                {
51                    $stickyHeader.css('padding-right', this.scrollbarWidth);
52                }       
53            }
54
55            var oldRSB = $.fn.modal.Constructor.prototype.resetScrollbar;
56            $.fn.modal.Constructor.prototype.resetScrollbar = function () 
57            {
58                oldRSB.apply(this);
59                $stickyHeader.css('padding-right', '');
60            }
61        },
62
63        /* ============================================================================
64         * Header dropdown search
65         * ==========================================================================*/
66        searchToggle: function() {
67            var $headerSearchDropdown = $('#header-search-dropdown');
68            var $searchDropdownToggle = $('.js-search-dropdown-toggle');
69            var $mobileHeader = $('#atbs-ceris-mobile-header');
70            var $stickyHeaderNav = $('#atbs-ceris-sticky-header').find('.navigation-bar__inner');
71            var $staticHeaderNav = $('.site-header').find('.navigation-bar__inner');
72            var $headerSearchDropdownInput = $headerSearchDropdown.find('.search-form__input');
73
74            $headerSearchDropdown.on('click', function(e) {
75                e.stopPropagation();
76            });
77
78            $searchDropdownToggle.on('click', function(e) {
79                e.stopPropagation();
80                var $toggleBtn = $(this);
81                var position = '';
82                
83
84                if ($toggleBtn.hasClass('mobile-header-btn')) {
85                    position = 'mobile';
86                } else if ($toggleBtn.parents('.sticky-header').length) {
87                    position = 'sticky';
88                } else {
89                    position = 'navbar';
90                }
91
92                if ($headerSearchDropdown.hasClass('is-in-' + position) || !$headerSearchDropdown.hasClass('is-active')) {
93                    $headerSearchDropdown.toggleClass('is-active');
94                }
95
96                switch(position) {
97                    case 'mobile':
98                        if (!$headerSearchDropdown.hasClass('is-in-mobile')) {
99                            $headerSearchDropdown.addClass('is-in-mobile');
100                            $headerSearchDropdown.removeClass('is-in-sticky');
101                            $headerSearchDropdown.removeClass('is-in-navbar');
102                            $headerSearchDropdown.appendTo($mobileHeader);
103                        }
104                        break;
105
106                    case 'sticky':
107                        if (!$headerSearchDropdown.hasClass('is-in-sticky')) {
108                            $headerSearchDropdown.addClass('is-in-sticky');
109                            $headerSearchDropdown.removeClass('is-in-mobile');
110                            $headerSearchDropdown.removeClass('is-in-navbar');
111                            $headerSearchDropdown.insertAfter($stickyHeaderNav);
112                        }
113                        break;
114
115                    default:
116                        if (!$headerSearchDropdown.hasClass('is-in-navbar')) {
117                            $headerSearchDropdown.addClass('is-in-navbar');
118                            $headerSearchDropdown.removeClass('is-in-sticky');
119                            $headerSearchDropdown.removeClass('is-in-mobile');
120                            $headerSearchDropdown.insertAfter($staticHeaderNav);
121                        }
122                }
123                
124                if ($headerSearchDropdown.hasClass('is-active')) {
125                    setTimeout(function () {
126                        $headerSearchDropdownInput.focus();
127                    }, 200);
128                }
129            });
130
131            $document.on('click', function(event) {
132                switch (event.which) {
133                    case 1:
134                        $headerSearchDropdown.removeClass('is-active');
135                        break;
136                    default:
137                        break;
138                }
139            });
140
141            $window.on('stickyHeaderHidden', function(){
142                if ($headerSearchDropdown.hasClass('is-in-sticky')) {
143                    $headerSearchDropdown.removeClass('is-active');
144                }
145            });
146        },
147        /* ============================================================================
148         * AJAX search
149         * ==========================================================================*/
150        ajaxSearch: function() {
151            var $results = '';
152            var $ajaxSearch = $('.js-ajax-search');
153            var ajaxStatus = '';
154            var noResultText = '<span class="noresult-text">There is no result.</span>';
155            var errorText = '<span class="error-text">There was some error.</span>';
156
157            $ajaxSearch.each(function() {
158                var $this = $(this);
159                var $searchForm = $this.find('.search-form__input');
160                var $resultsContainer = $this.find('.search-results');
161                var $resultsInner = $this.find('.search-results__inner');
162                var searchTerm = '';
163                var lastSearchTerm = '';
164
165                $searchForm.on('input', $.debounce(800, function() {
166                    searchTerm = $searchForm.val();
167
168                    if (searchTerm.length > 0) {
169                        $resultsContainer.addClass('is-active');
170                        $('.atbs-ceris-search-full').addClass("active");
171
172                        if ((searchTerm != lastSearchTerm) || (ajaxStatus === 'failed' )) {
173                            $resultsContainer.removeClass('is-error').addClass('is-loading');
174                            lastSearchTerm = searchTerm;
175                            ajaxLoad(searchTerm, $resultsContainer, $resultsInner);
176                        }
177                    } else {
178                        $resultsContainer.removeClass('is-active');
179                    }
180                }));
181            });
182
183            function ajaxLoad(searchTerm, $resultsContainer, $resultsInner) {
184                var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];   
185                var ajaxCall = $.ajax({
186                        url: ajaxurl,
187                        type: 'post',
188                        dataType: 'html',
189                        data: {
190                            action: 'ceris_ajax_search',
191                            searchTerm: searchTerm,
192                            securityCheck: cerisAjaxSecurity,
193                        },
194                    });
195
196                ajaxCall.done(function(respond) {
197                    $results = $.parseJSON(respond);
198                    ajaxStatus = 'success';
199                    if (!$results.length) {
200                        $results = noResultText;
201                    }
202                    $resultsInner.html($results).css('opacity', 0).animate({opacity: 1}, 500);  
203                });
204
205                ajaxCall.fail(function() {
206                    ajaxStatus = 'failed';
207                    $resultsContainer.addClass('is-error');
208                    $results = errorText;
209                    $resultsInner.html($results).css('opacity', 0).animate({opacity: 1}, 500);  
210                });
211
212                ajaxCall.always(function() {
213                    $resultsContainer.removeClass('is-loading');
214                });
215            }
216        },
217
218        /* ============================================================================
219         * Megamenu Ajax
220         * ==========================================================================*/
221        ajaxMegamenu: function() {
222            var $results = '';
223            var $subCatItem = $('.atbs-ceris-mega-menu ul.sub-categories > li');
224            $subCatItem.on('click',function(e) {
225              e.preventDefault();
226                var $this = $(this);
227                if($(this).hasClass('active')) {
228                    return;
229                }
230                
231                $(this).parents('.sub-categories').find('li').removeClass('active');
232                
233                var $container = $this.parents('.atbs-ceris-mega-menu__inner').find('.posts-list');
234                var $thisCatSplit = $this.attr('class').split('-');
235                var thisCatID = $thisCatSplit[$thisCatSplit.length - 1];
236                var megaMenuStyle = 0;
237                
238                $container.append('<div class="bk-preload-wrapper"></div>');
239                $container.find('article').addClass('bk-preload-blur');
240            
241                if($container.hasClass('megamenu-1st-large')) {
242                    megaMenuStyle = 2;
243                }else if($container.hasClass('megamenu-style-3')) {
244                    megaMenuStyle = 3;
245                }else {
246                    megaMenuStyle = 1;
247                }
248                
249                $this.addClass('active');
250                
251                var $htmlRestore = ajax_buff['megamenu'][thisCatID]['html'];
252                
253                //console.log($htmlRestore);
254                if($htmlRestore == '') {
255                    ajaxLoad(thisCatID, megaMenuStyle, $container);
256                }else {
257                    ajaxRestore($container, thisCatID, $htmlRestore);
258                }
259            });
260            function ajaxLoad(thisCatID, megaMenuStyle, $container) {
261                var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];   
262                var ajaxCall = {
263                    action: 'ceris_ajax_megamenu',
264                    thisCatID: thisCatID,
265                    megaMenuStyle : megaMenuStyle,
266                    securityCheck: cerisAjaxSecurity
267                };
268                
269                $.post(ajaxurl, ajaxCall, function (response) {
270                    $results = $.parseJSON(response);
271                    //Save HTML
272                    ajax_buff['megamenu'][thisCatID]['html'] = $results;
273                    // Append Result
274                    $container.html($results).css('opacity', 0).animate({opacity: 1}, 500); 
275                    $container.find('.bk-preload-wrapper').remove();
276                    $container.find('article').removeClass('bk-preload-blur');
277                });    
278            }
279            function ajaxRestore($container, thisCatID, $htmlRestore) {
280                // Append Result
281                $container.html($htmlRestore).css('opacity', 0).animate({opacity: 1}, 500); 
282                $container.find('.bk-preload-wrapper').remove();
283                $container.find('article').removeClass('bk-preload-blur'); 
284            }
285        },
286        
287        /* ============================================================================
288         * Ajax Button
289         * ==========================================================================*/
290        pagiButton: function() {
291            var $dotNextTemplate = '<span class="atbs-ceris-pagination__item atbs-ceris-pagination__dots atbs-ceris-pagination__dots-next">&hellip;</span>';
292            var $dotPrevTemplate = '<span class="atbs-ceris-pagination__item atbs-ceris-pagination__dots atbs-ceris-pagination__dots-prev">&hellip;</span>';
293            var $buttonTemplate = '<a class="atbs-ceris-pagination__item" href="#">##PAGENUMBER##</a>';
294            var $dotIndex_next;
295            var $dotIndex_prev;
296            var $pagiAction;
297            var $results = '';
298            
299            $('body').on('click', '.atbs-ceris-module-pagination .atbs-ceris-pagination__links > a', function(e) {
300                e.preventDefault();
301                var $this = $(this);
302                if(($this.hasClass('disable-click')) || $this.hasClass('atbs-ceris-pagination__item-current')) 
303                    return;
304                
305                var $pagiChildren = $this.parent().children();
306                var $totalPageVal = parseInt($($pagiChildren[$pagiChildren.length - 2]).text());
307                var $lastIndex = $this.parent().find('.atbs-ceris-pagination__item-current').index();
308                var $lastPageVal = parseInt($($pagiChildren[$lastIndex]).text());
309                
310                var $nextButton = $this.parent().find('.atbs-ceris-pagination__item-next');
311                var $prevButton = $this.parent().find('.atbs-ceris-pagination__item-prev');
312                
313                // Save the last active button 
314                var $lastActiveButton = $this.parent().find('.atbs-ceris-pagination__item-current');
315                // Save the last page
316                var $lastActivePage = $this.parent().find('.atbs-ceris-pagination__item-current');
317                
318                // Add/Remove current class
319                $this.siblings().removeClass('atbs-ceris-pagination__item-current');
320                if($this.hasClass('atbs-ceris-pagination__item-prev')) {
321                    $lastActivePage.prev().addClass('atbs-ceris-pagination__item-current');
322                }else if($this.hasClass('atbs-ceris-pagination__item-next')) {
323                    $lastActivePage.next().addClass('atbs-ceris-pagination__item-current');
324                }else {
325                    $this.addClass('atbs-ceris-pagination__item-current');
326                }
327                
328                var $currentActiveButton = $this.parent().find('.atbs-ceris-pagination__item-current');
329                var $currentIndex = $this.parent().find('.atbs-ceris-pagination__item-current').index();
330                var $currentPageVal = parseInt($($pagiChildren[$currentIndex]).text());
331
332                if($currentPageVal == 1) {
333                    $($prevButton).addClass('disable-click');
334                    $($nextButton).removeClass('disable-click');
335                }else if($currentPageVal == $totalPageVal) {
336                    $($prevButton).removeClass('disable-click');
337                    $($nextButton).addClass('disable-click');
338                }else {
339                    $($prevButton).removeClass('disable-click');
340                    $($nextButton).removeClass('disable-click');
341                }
342                
343                if($totalPageVal > 5) {
344                    
345                    if($this.parent().find('.atbs-ceris-pagination__dots').hasClass('atbs-ceris-pagination__dots-next')) {
346                        $dotIndex_next = $this.parent().find('.atbs-ceris-pagination__dots-next').index();
347                    }else {
348                        $dotIndex_next = -1;
349                    }
350                    if($this.parent().find('.atbs-ceris-pagination__dots').hasClass('atbs-ceris-pagination__dots-prev')) {
351                        $dotIndex_prev = $this.parent().find('.atbs-ceris-pagination__dots-prev').index();
352                    }else {
353                        $dotIndex_prev = -1;
354                    }
355                    
356                    if(isNaN($currentPageVal)) {
357                        if($this.hasClass('atbs-ceris-pagination__item-prev')) {
358                            $currentPageVal = parseInt($($pagiChildren[$currentIndex + 1]).text()) - 1;
359                        }else if($this.hasClass('atbs-ceris-pagination__item-next')) {
360                            $currentPageVal = parseInt($($pagiChildren[$currentIndex - 1]).text()) + 1;
361                        }else {
362                            return;
363                        }
364                        
365                    }
366                    
367                    if($currentPageVal > $lastPageVal) {
368                        $pagiAction = 'up';
369                    }else {
370                        $pagiAction = 'down';
371                    }
372                    
373                    if(($pagiAction == 'up')) {
374                        if(($currentIndex == ($dotIndex_next - 1)) || ($currentIndex == $dotIndex_next) || ($currentPageVal == $totalPageVal)) {
375                            
376                            $this.parent().find('.atbs-ceris-pagination__dots').remove();                 //Remove ALL Dot Signal
377                            
378                            if($currentIndex == $dotIndex_next) {
379                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal))).insertAfter($lastActiveButton);
380                                $lastActiveButton.next().addClass('atbs-ceris-pagination__item-current');
381                                $currentActiveButton = $this.parent().find('.atbs-ceris-pagination__item-current');
382                            }
383                            
384                            while(parseInt(($this.parent().find('a:nth-child(3)')).text()) != $currentPageVal) {
385                                $this.parent().find('a:nth-child(3)').remove();       //Remove 1 button before
386                            }
387                            
388                            $($dotPrevTemplate).insertBefore($currentActiveButton);                 //Insert Dot Next             
389                            
390                            if(($currentPageVal < ($totalPageVal - 3))) {
391                                $($dotNextTemplate).insertAfter($currentActiveButton);              //Insert Dot Prev
392                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal + 2))).insertAfter($currentActiveButton);
393                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal + 1))).insertAfter($currentActiveButton);
394                            }else if(($currentPageVal < ($totalPageVal - 2))) {
395                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal + 2))).insertAfter($currentActiveButton);
396                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal + 1))).insertAfter($currentActiveButton);
397                            }
398                            else if(($currentPageVal < ($totalPageVal - 1))) {
399                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal + 1))).insertAfter($currentActiveButton);
400                            }
401                            if($currentPageVal == $totalPageVal) {
402                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 3))).insertBefore($currentActiveButton);
403                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 2))).insertBefore($currentActiveButton);
404                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 1))).insertBefore($currentActiveButton);
405                            }else if($currentPageVal == ($totalPageVal - 1)) {
406                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 2))).insertBefore($currentActiveButton);
407                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 1))).insertBefore($currentActiveButton);
408                            }else if($currentPageVal == ($totalPageVal - 2 )) {
409                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 1))).insertBefore($currentActiveButton);
410                            }
411                        }
412                    }else if($pagiAction == 'down') {
413                        if(($currentIndex == ($dotIndex_prev + 1)) || ($currentIndex == $dotIndex_prev) || (($currentPageVal == 1) && ($currentIndex < $dotIndex_prev))) {
414                            
415                            $this.parent().find('.atbs-ceris-pagination__dots').remove();                 //Remove ALL Dot Signal
416    
417                            if($currentIndex == $dotIndex_prev) {
418                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal))).insertBefore($lastActiveButton);
419                                $lastActiveButton.prev().addClass('atbs-ceris-pagination__item-current');
420                                $currentActiveButton = $this.parent().find('.atbs-ceris-pagination__item-current');
421                                while(parseInt($this.parent().find('a:nth-child('+($currentIndex + 2)+')').text()) != $totalPageVal) {
422                                    $this.parent().find('a:nth-child('+($currentIndex + 2)+')').remove();       //Remove 1 button before
423                                }
424                            }else if(($currentPageVal == 1) && ($currentIndex < $dotIndex_prev)) {
425                                while(parseInt($this.parent().find('a:nth-child('+($currentIndex + 2)+')').text()) != $totalPageVal) {
426                                    $this.parent().find('a:nth-child('+($currentIndex + 2)+')').remove();       //Remove 1 button before
427                                }
428                            }else {
429                                while(parseInt($this.parent().find('a:nth-child('+($currentIndex + 1)+')').text()) != $totalPageVal) {
430                                    $this.parent().find('a:nth-child('+($currentIndex + 1)+')').remove();       //Remove 1 button before
431                                }
432                            }
433                            $($dotNextTemplate).insertAfter($currentActiveButton);                  //Insert Dot After
434        
435                            if($currentPageVal > 4) {                                               // <- 1 ... 5 6 7 ... 10 -> 
436                                $($dotPrevTemplate).insertBefore($currentActiveButton);              //Insert Dot Prev
437                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 2))).insertBefore($currentActiveButton);
438                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 1))).insertBefore($currentActiveButton);
439                            }else if($currentPageVal > 3) {                                         // <- 1 ... 4 5 6 ... 10 -> 
440                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 2))).insertBefore($currentActiveButton);
441                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 1))).insertBefore($currentActiveButton);
442                            }
443                            else if($currentPageVal > 2) {                                          // <- 1 ... 3 4 5 ... 10 -> 
444                                $($buttonTemplate.replace('##PAGENUMBER##', ($currentPageVal - 1))).insertBefore($currentActiveButton);
445                            }
446                            if($currentPageVal == 1) {
447                                $($buttonTemplate.replace('##PAGENUMBER##', 4)).insertAfter($currentActiveButton);
448                                $($buttonTemplate.replace('##PAGENUMBER##', 3)).insertAfter($currentActiveButton);
449                                $($buttonTemplate.replace('##PAGENUMBER##', 2)).insertAfter($currentActiveButton);
450                            }else if($currentPageVal == 2) {
451                                $($buttonTemplate.replace('##PAGENUMBER##', 4)).insertAfter($currentActiveButton);
452                                $($buttonTemplate.replace('##PAGENUMBER##', 3)).insertAfter($currentActiveButton);
453                            }else if($currentPageVal == 3) {
454                                $($buttonTemplate.replace('##PAGENUMBER##', 4)).insertAfter($currentActiveButton);
455                            }
456                        }
457                    }
458                }
459                if($currentPageVal != 1) {
460                    $this.siblings('.atbs-ceris-pagination__item-prev').css('display', 'inline-block');
461                }else {
462                    if($this.hasClass('atbs-ceris-pagination__item-prev')) {
463                        $this.css('display', 'none');
464                    }else {
465                        $this.siblings('.atbs-ceris-pagination__item-prev').css('display', 'none');
466                    }
467                }
468                if($currentPageVal == $totalPageVal) {
469                    if($this.hasClass('atbs-ceris-pagination__item-next')) {
470                        $this.css('display', 'none');
471                    }else {
472                        $this.siblings('.atbs-ceris-pagination__item-next').css('display', 'none');
473                    }
474                }else {
475                    $this.siblings('.atbs-ceris-pagination__item-next').css('display', 'inline-block');
476                }
477                if($this.closest('.atbs-ceris-module-pagination').hasClass('ceris-user-review-pagination')) {
478                    ATBS.ATBS_CustomerReview.reviewPagination($this, $currentPageVal);
479                }else {
480                    ajaxListing($this, $currentPageVal);   
481                }
482            });
483            function ajaxListing($this, $currentPageVal) {
484                var $moduleID = $this.closest('.atbs-ceris-block').attr('id');
485                var moduleName = $moduleID.split("-")[0];
486                var args = ajax_buff['query'][$moduleID]['args'];
487                
488                if(moduleName == 'ceris_author_results') {
489                    var postOffset = ($currentPageVal-1)*args['number'] + parseInt(args['offset']);
490                    var $container = $this.closest('.atbs-ceris-block').find('.authors-list');
491                    var moduleInfo = '';
492                }else {
493                    var postOffset = ($currentPageVal-1)*args['posts_per_page'] + parseInt(args['offset']);
494                    var $container = $this.closest('.atbs-ceris-block').find('.posts-list');
495                    var moduleInfo = ajax_buff['query'][$moduleID]['moduleInfo'];    
496                }
497                
498                if(moduleInfo.hasOwnProperty('bookmarkTmp')) {
499                    var bookmarkTmp = moduleInfo.bookmarkTmp;
500                    if(bookmarkTmp.length == 0) {
501                        moduleInfo.bookmarkTmp.push("bookmarkTmpEmpty");
502                    }
503                }
504                
505                var parameters = {
506                        moduleName: moduleName,
507                        args: args,
508                        moduleInfo: moduleInfo,
509                        postOffset: postOffset,
510                    };
511                //console.log(parameters);
512                $container.css('height', $container.height()+'px');
513                $container.append('<div class="bk-preload-wrapper"></div>');
514                $container.find('article').addClass('bk-preload-blur');
515                
516                loadAjax(parameters, $container);
517                
518                var $mainCol = $this.parents('.atbs-ceris-main-col');
519                if($mainCol.length > 0) {
520                    var $subCol = $mainCol.siblings('.atbs-ceris-sub-col');
521                    $subCol.css('min-height', '1px');
522                }                
523                
524                var $scrollTarget = $this.parents('.atbs-ceris-block');
525                $('body,html').animate({
526                    scrollTop: $scrollTarget.offset().top,
527                }, 1100);
528                
529                setTimeout(function(){ $container.css('height', 'auto'); }, 1100);
530                
531            }
532            function loadAjax(parameters, $container){
533                //console.log(parameters.moduleName);
534                var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];
535
536                var ajaxCall = {
537                    action: parameters.moduleName,
538                    args: parameters.args,
539                    moduleInfo: parameters.moduleInfo,
540                    postOffset: parameters.postOffset,
541                    securityCheck: cerisAjaxSecurity
542                };
543                
544                //console.log(ajaxCall);
545                $.post(ajaxurl, ajaxCall, function (response) {
546                    $results = $.parseJSON(response);
547                    //Save HTML
548                    // Append Result
549                    $container.html($results).css('opacity', 0).animate({opacity: 1}, 500); 
550                    $container.find('.bk-preload-wrapper').remove();
551                    $container.find('article').removeClass('bk-preload-blur');
552                    ATBS.ATBS_Bookmark.reAddBookmark($container);
553                });   
554            }
555            function checkStickySidebar($this){
556                var $subCol = $this.parents('.atbs-ceris-main-col').siblings('.atbs-ceris-sub-col');
557                if($subCol.hasClass('js-sticky-sidebar')) {
558                    return $subCol;
559                }else {
560                    return 0;
561                }
562            }
563        },
564        
565        /* ============================================================================
566         * Login Form tabs
567         * ==========================================================================*/
568        loginForm: function() {
569            var $loginFormTabsLinks = $('.js-login-form-tabs').find('a');
570
571            $loginFormTabsLinks.on('click', function (e) {
572                e.preventDefault()
573                $(this).tab('show');
574            });
575        },
576
577        
578        /* ============================================================================
579         * Offcanvas Menu
580         * ==========================================================================*/
581        offCanvasMenu: function() {
582            var $backdrop = $('<div class="atbs-ceris-offcanvas-backdrop"></div>');
583            var $offCanvas = $('.js-atbs-ceris-offcanvas');
584            var $offCanvasToggle = $('.js-atbs-ceris-offcanvas-toggle');
585            var $offCanvasClose = $('.js-atbs-ceris-offcanvas-close');
586            var $offCanvasMenuHasChildren = $('.navigation--offcanvas').find('li.menu-item-has-children > a');
587            var menuExpander = ('<div class="submenu-toggle"><i class="mdicon mdicon-expand_more"></i></div>');
588            var check_show_more = false;
589
590            $backdrop.on('click', function(){
591                var button_hide =  $offCanvas.find('.btn-nav-show_full i');
592                $(this).fadeOut(0, function(){
593                    $(this).detach();
594                });
595                var check_show_full = $offCanvas;
596                if($(check_show_full).hasClass('show-full')){
597                    $(check_show_full).removeClass('animation');
598                    setTimeout(function () {
599                        $(check_show_full).removeClass('show-full');
600                        $(check_show_full).removeClass('is-active');
601                    },400);
602                }
603                else{
604                    $(check_show_full).removeClass('show-full');
605                    $(check_show_full).removeClass('is-active');
606                }
607                setTimeout(function () {
608                    $(check_show_full).removeClass('animation');
609                    $(check_show_full).removeClass('show-full');
610                    $(check_show_full).removeClass('is-active');
611                },400);
612                check_show_more = false;
613                button_hide.attr('class','mdicon mdicon-chevron-thin-right');
614            });
615            $offCanvasToggle.on('click', function(e){
616                var check_show_full = $offCanvas;
617                e.preventDefault();
618                var targetID = $(this).attr('href');
619                var $target = $(targetID);
620                $target.toggleClass('is-active');
621                $backdrop.hide().appendTo(document.body).fadeIn(200);
622            });
623            $offCanvasClose.on('click', function(e){
624                e.preventDefault();
625                // var targetID = $(this).attr('href');
626                // var $target = $(targetID);
627                // $target.removeClass('is-active');
628                var button_hide =  $offCanvas.find('.btn-nav-show_full i');
629                $backdrop.fadeOut(200, function(){
630                    $(this).detach();
631                });
632                check_show_more = false;
633                var check_show_full = $offCanvas;
634                if($(check_show_full).hasClass('show-full')){
635                    $(check_show_full).removeClass('animation');
636                    setTimeout(function () {
637                        $(check_show_full).removeClass('show-full');
638                        $(check_show_full).removeClass('is-active');
639                    },400);
640                }
641                else{
642                    $(check_show_full).removeClass('show-full');
643                    $(check_show_full).removeClass('is-active');
644                }
645                button_hide.attr('class','mdicon mdicon-chevron-thin-right');
646            });
647            $offCanvasMenuHasChildren.append(function() {
648                return $(menuExpander).on('click', function(e){
649                    e.preventDefault();
650                    var $subMenu = $(this).parent().siblings('.sub-menu');
651                    $subMenu.slideToggle(200);
652                });
653            });
654            $(window).on('resize',function (e) {
655                var checkExist = setInterval(function() {
656                    var elementPC = $('#atbs-ceris-offcanvas-primary');
657                    var elementMB = $('#atbs-ceris-offcanvas-mobile');
658                    if(elementPC.hasClass('is-active') ){
659                        var checkDisplay = elementPC.css('display');
660                        if(checkDisplay == 'none' ){
661                            $backdrop.css('display','none');
662                            clearInterval(checkExist);
663                        }
664                    }
665                    if(elementMB.hasClass('is-active')) {
666                        var checkDisplay = elementMB.css('display');
667                        if( checkDisplay == 'none'){
668                            $backdrop.css('display','none');
669                            clearInterval(checkExist);
670                        }
671                    }
672                    if(elementPC.hasClass('is-active')  && elementPC.css('display') != 'none' || elementMB.hasClass('is-active')  && elementMB.css('display') != 'none'){
673                        $backdrop.css('display','block');
674                        clearInterval(checkExist);
675                    }
676                    clearInterval(checkExist);
677                }, 100); // check every 100ms
678            });
679            var btn_show_more = $('.btn-nav-show_full');
680            $(btn_show_more).click(function () {
681                var $this = $(this).parents('.atbs-ceris-offcanvas');
682                var button_hide =  $(this).find('i');
683                $(this).fadeOut(500);
684                if( check_show_more == false){
685                    // $($this).animate({'width':'1420px'},500);
686                    $($this).addClass('animation');
687                    setTimeout(function () {
688                        $($this).addClass("show-full");
689                        button_hide.attr('class','mdicon mdicon-chevron-thin-left');
690                        $(btn_show_more).fadeIn(50);
691                    },600);
692                    check_show_more = true;
693                }
694                else {
695                    $($this).removeClass("show-full");
696                    $(this).fadeOut(1000);
697                    setTimeout(function () {
698                        // $($this).animate({'width':'530px'},500);
699                        $($this).removeClass('animation');
700                        $(btn_show_more).fadeIn(50);
701                         button_hide.attr('class','mdicon mdicon-chevron-thin-right');
702                    },200);
703                    check_show_more = false;
704                   
705                }
706            });
707        },
708        /* ============================================================================
709         * Prority+ menu init
710         * ==========================================================================*/
711        priorityNavInit: function() {
712            var $menus = $('.js-priority-nav');
713            $menus.each(function() {
714                ATBS.priorityNav($(this));
715            })
716        },
717
718        /* ============================================================================
719         * Smart sticky header
720         * ==========================================================================*/
721        smartAffix: {
722            //settings
723            $headerPlaceHolder: '', //the affix menu (this element will get the mdAffixed)
724            $fixedHeader: '', //the menu wrapper / placeholder
725            isDestroyed: false,
726            isDisabled: false,
727            isFixed: false, //the current state of the menu, true if the menu is affix
728            isShown: false,
729            windowScrollTop: 0, 
730            lastWindowScrollTop: 0, //last scrollTop position, used to calculate the scroll direction
731            offCheckpoint: 0, // distance from top where fixed header will be hidden
732            onCheckpoint: 0, // distance from top where fixed header can show up
733            breakpoint: 992, // media breakpoint in px that it will be disabled
734
735            init : function init (options) {
736
737                //read the settings
738                this.$fixedHeader = $(options.fixedHeader);
739                this.$headerPlaceHolder = $(options.headerPlaceHolder);
740
741                // Check if selectors exist.
742                if ( !this.$fixedHeader.length || !this.$headerPlaceHolder.length ) {
743                    this.isDestroyed = true;
744                } else if ( !this.$fixedHeader.length || !this.$headerPlaceHolder.length || ( ATBS.documentOnResize.windowWidth <= ATBS.header.smartAffix.breakpoint ) ) { // Check if device width is smaller than breakpoint.
745                    this.isDisabled = true;
746                }
747
748            },// end init
749
750            compute: function compute(){
751                if (ATBS.header.smartAffix.isDestroyed || ATBS.header.smartAffix.isDisabled) {
752                    return;
753                }
754
755                // Set where from top fixed header starts showing up
756                if( !this.$headerPlaceHolder.length ) {
757                    this.offCheckpoint = 400;
758                } else {
759                    this.offCheckpoint = $(this.$headerPlaceHolder).offset().top + 400;
760                }
761                
762                this.onCheckpoint = this.offCheckpoint + 500;
763
764                // Set menu top offset
765                this.windowScrollTop = ATBS.documentOnScroll.windowScrollTop;
766                if (this.offCheckpoint < this.windowScrollTop) {
767                    this.isFixed = true;
768                }
769            },
770            
771            updateState: function updateState() {
772                //update affixed state
773                if (this.isFixed) {
774                    if(this.$fixedHeader.length) {
775                        this.$fixedHeader.addClass('is-fixed');
776                    }
777                } else {
778                    if(this.$fixedHeader.length) {
779                        this.$fixedHeader.removeClass('is-fixed');
780                    }
781                    $window.trigger('stickyHeaderHidden');
782                }
783
784                if (this.isShown) {
785                    if(this.$fixedHeader.length) {
786                        this.$fixedHeader.addClass('is-shown');
787                    }
788                } else {
789                    if(this.$fixedHeader.length) {
790                        this.$fixedHeader.removeClass('is-shown');
791                    }
792                }
793            },
794
795            /**
796             * called by events on scroll
797             */
798            eventScroll: function eventScroll(scrollTop) {
799
800                var scrollDirection = '';
801                var scrollDelta = 0;
802
803                // check the direction
804                if (scrollTop != this.lastWindowScrollTop) { //compute direction only if we have different last scroll top
805
806                    // compute the direction of the scroll
807                    if (scrollTop > this.lastWindowScrollTop) {
808                        scrollDirection = 'down';
809                    } else {
810                        scrollDirection = 'up';
811                    }
812
813                    //calculate the scroll delta
814                    scrollDelta = Math.abs(scrollTop - this.lastWindowScrollTop);
815                    this.lastWindowScrollTop = scrollTop;
816
817                    // update affix state
818                    if (this.offCheckpoint < scrollTop) {
819                        this.isFixed = true;
820                    } else {
821                        this.isFixed = false;
822                    }
823                    
824                    // check affix state
825                    if (this.isFixed) {
826                        // We're in affixed state, let's do some check
827                        if ((scrollDirection === 'down') && (scrollDelta > 14)) {
828                            if (this.isShown) {
829                                this.isShown = false; // hide menu
830                            }
831                        } else {
832                            if ((!this.isShown) && (scrollDelta > 14) && (this.onCheckpoint < scrollTop)) {
833                                this.isShown = true; // show menu
834                            }
835                        }
836                    } else {
837                        this.isShown = false;
838                    }
839
840                    this.updateState(); // update state
841                }
842            }, // end eventScroll function
843
844            /**
845            * called by events on resize
846            */
847            eventResize: function eventResize(windowWidth) {
848                // Check if device width is smaller than breakpoint.
849                if ( ATBS.documentOnResize.windowWidth < ATBS.header.smartAffix.breakpoint ) {
850                    this.isDisabled = true;
851                } else {
852                    this.isDisabled = false;
853                    ATBS.header.smartAffix.compute();
854                }
855            }
856        },
857        
858        smartFooterInfo: {
859            //settings
860            $fixedFooter: '', //the menu wrapper / placeholder
861            isDestroyed: false,
862            isDisabled: false,
863            isFixed: false, //the current state of the menu, true if the menu is affix
864            isShown: false,
865            windowScrollTop: 0, 
866            lastWindowScrollTop: 0, //last scrollTop position, used to calculate the scroll direction
867            offCheckpoint: 0, // distance from top where fixed header will be hidden
868            onCheckpoint: 0, // distance from top where fixed header can show up
869            breakpoint: 992, // media breakpoint in px that it will be disabled
870
871            init : function init (options) {
872                //read the settings
873                this.$fixedFooter = $(options.fixedFooter);
874            },// end init
875
876            compute: function compute(){
877                if (ATBS.header.smartFooterInfo.isDestroyed || ATBS.header.smartFooterInfo.isDisabled) {
878                    return;
879                }
880
881                this.offCheckpoint = 400;
882                
883                this.onCheckpoint = this.offCheckpoint + 500;
884
885                // Set menu top offset
886                this.windowScrollTop = ATBS.documentOnScroll.windowScrollTop;
887                if (this.offCheckpoint < this.windowScrollTop) {
888                    this.isFixed = true;
889                }
890            },
891
892            updateState: function updateState(){
893                //update affixed state
894                if (this.isFixed) {
895                    this.$fixedFooter.addClass('is-fixed');
896                } else {
897                    this.$fixedFooter.removeClass('is-fixed');
898                    //$window.trigger('stickyHeaderHidden');
899                }
900                //var reading_indicator =  $('.scroll-count-percent');
901                //var siteHeaderOffsetTop = $('.site-header').first().offset().top;
902                if (this.isShown) {
903                    this.$fixedFooter.addClass('is-shown');
904                    /*reading_indicator.each( function() {
905                        $(this).css({'top': $('.sticky-header').height() + (siteHeaderOffsetTop + 60)+ 'px' });
906                    });*/
907                } else {
908                    this.$fixedFooter.removeClass('is-shown');
909                    /*reading_indicator.each( function() {
910                        $(this).css({'top': $('.sticky-header').height() + (siteHeaderOffsetTop) + 'px' });
911                    });*/
912                }
913            },
914
915            /**
916             * called by events on scroll
917             */
918            eventScroll: function eventScroll(scrollTop) {
919
920                var scrollDirection = '';
921                var scrollDelta = 0;
922
923                // check the direction
924                if (scrollTop != this.lastWindowScrollTop) { //compute direction only if we have different last scroll top
925
926                    // compute the direction of the scroll
927                    if (scrollTop > this.lastWindowScrollTop) {
928                        scrollDirection = 'down';
929                    } else {
930                        scrollDirection = 'up';
931                    }
932
933                    //calculate the scroll delta
934                    scrollDelta = Math.abs(scrollTop - this.lastWindowScrollTop);
935                    this.lastWindowScrollTop = scrollTop;
936
937                    // update affix state
938                    if (this.offCheckpoint < scrollTop) {
939                        this.isFixed = true;
940                    } else {
941                        this.isFixed = false;
942                    }
943                    //console.log(this);
944                    // check affix state
945                    if (this.isFixed) {
946                        // We're in affixed state, let's do some check
947                        if ((scrollDirection === 'down') && (scrollDelta > 14)) {
948                            if (!this.isShown) {
949                                this.isShown = true; // hide menu
950                            }
951                        } else {
952                            if ((this.isShown) && (scrollDelta > 14) && (this.onCheckpoint < scrollTop)) {
953                                this.isShown = false; // show menu
954                            }
955                        }
956                    } else {
957                        this.isShown = false;
958                    }
959
960                    this.updateState(); // update state
961                }
962            }, // end eventScroll function
963
964            /**
965            * called by events on resize
966            */
967            eventResize: function eventResize(windowWidth) {
968                ATBS.header.smartFooterInfo.compute();
969            }
970        },
971    };
972
973    ATBS.documentOnScroll = {
974        ticking: false,
975        windowScrollTop: 0, //used to store the scrollTop
976
977        init: function() {
978            window.addEventListener('scroll', function(e) {
979                if (!ATBS.documentOnScroll.ticking) {
980                    window.requestAnimationFrame(function() {
981                        ATBS.documentOnScroll.windowScrollTop = $window.scrollTop();
982
983                        // Functions to call here
984                        if (!ATBS.header.smartAffix.isDisabled && !ATBS.header.smartAffix.isDestroyed) {
985                            ATBS.header.smartAffix.eventScroll(ATBS.documentOnScroll.windowScrollTop);
986                        }
987                        
988                        ATBS.header.smartFooterInfo.eventScroll(ATBS.documentOnScroll.windowScrollTop);
989
990                        ATBS.documentOnScroll.goToTopScroll(ATBS.documentOnScroll.windowScrollTop);
991
992                        ATBS.documentOnScroll.ticking = false;
993                    });
994                }
995                ATBS.documentOnScroll.ticking = true;
996            });
997        },
998
999        /* ============================================================================
1000         * Go to top scroll event
1001         * ==========================================================================*/
1002        goToTopScroll: function(windowScrollTop){
1003            if ($goToTopEl.length) {
1004                if(windowScrollTop > 800) {
1005                    if (!$goToTopEl.hasClass('is-active')) $goToTopEl.addClass('is-active');
1006                } else {
1007                    $goToTopEl.removeClass('is-active');
1008                }
1009            }
1010        },
1011        /* ============================================================================
1012         * INFINITY AJAX load more posts
1013         * ==========================================================================*/
1014        infinityAjaxLoadPost: function() {
1015            var loadedPosts = '';
1016            var $ajaxLoadPost = $('.infinity-ajax-load-post');
1017            var $this;
1018    
1019            function ajaxLoad(parameters, postContainer) {
1020                var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];
1021                var ajaxStatus = '',
1022                    ajaxCall = $.ajax({
1023                        url: ajaxurl,
1024                        type: 'post',
1025                        dataType: 'html',
1026                        data: {
1027                            action: parameters.action,
1028                            args: parameters.args,
1029                            postOffset: parameters.postOffset,
1030                            type: parameters.type,
1031                            moduleInfo: parameters.moduleInfo,
1032                            securityCheck: cerisAjaxSecurity
1033                            // other parameters
1034                        },
1035                    });
1036                ajaxCall.done(function(respond) {
1037                    loadedPosts = $.parseJSON(respond);
1038                    ajaxStatus = 'success';
1039                    if(loadedPosts == 'no-result') {
1040                        postContainer.closest('.infinity-ajax-load-post').addClass('disable-infinity-load');
1041                        postContainer.closest('.infinity-ajax-load-post').find('.js-ajax-load-post-trigger').addClass('hidden');
1042                        postContainer.closest('.infinity-ajax-load-post').find('.ceris-no-more-button').removeClass('hidden');
1043                        return;
1044                    }
1045                    if (loadedPosts) {
1046                        var elToLoad = $(loadedPosts).css('opacity',0).animate({'opacity': 1}, 400);
1047                        postContainer.append(elToLoad);
1048                        ATBS.ATBS_Bookmark.reAddBookmark(postContainer);                                                
1049                    }
1050                    $('html, body').animate({ scrollTop: $window.scrollTop() + 1 }, 0).animate({ scrollTop: $window.scrollTop() - 1 }, 0);
1050 // for recalculating of sticky sidebar
1051                    // do stuff like changing parameters
1052                });
1053    
1054                ajaxCall.fail(function() {
1055                    ajaxStatus = 'failed';
1056                });
1057    
1058                ajaxCall.always(function() {
1059                    postContainer.closest('.infinity-ajax-load-post').removeClass('ceris_loading');
1060                    postContainer.closest('.infinity-ajax-load-post').removeClass('infinity-disable');
1061                });
1062            }
1063            function ajaxLoadInfinitiveScroll(){
1064                $ajaxLoadPost.each(function(index) {
1065                    $this = $(this);
1066               
1067                    var triggerElement = $this.find('.js-ajax-load-post-trigger');
1068                    
1069                    var top_of_element = triggerElement.offset().top;
1070                    var bottom_of_element = triggerElement.offset().top + triggerElement.outerHeight();
1071                    var bottom_of_screen = $(window).scrollTop() + $(window).innerHeight();
1072                    var top_of_screen = $(window).scrollTop();
1073                    
1074                    
1075                    if ((bottom_of_screen > top_of_element) && (top_of_screen < bottom_of_element)){
1076                        if($this.hasClass('infinity-disable') || $this.hasClass('disable-infinity-load'))
1077                            return;
1078                                
1079                        $this.addClass('infinity-disable');
1080                        
1081                        var $moduleID = $this.closest('.atbs-ceris-block').attr('id');
1082                        var moduleName = $moduleID.split("-")[0];
1083                        var args = ajax_buff['query'][$moduleID]['args'];
1084    
1085                        var postContainer = $this.find('.posts-list');
1086                        var moduleInfo = ajax_buff['query'][$moduleID]['moduleInfo'];
1087    
1088                        $this.addClass('ceris_loading');
1089    
1090                        var postOffset      = parseInt(args['offset']) + $this.find('article').length;
1091         
1092                        if($this.closest('.atbs-ceris-block').hasClass('ceris_latest_blog_posts')) {
1093                            var stickPostLength = args['post__not_in'].length;
1094                            postOffset = postOffset - stickPostLength;
1095                        }
1096                        var parameters = {
1097                            action: moduleName,
1098                            args: args,
1099                            postOffset: postOffset,
1100                            type: 'loadmore',
1101                            moduleInfo: moduleInfo,
1102                        };
1103                        ajaxLoad(parameters, postContainer);
1104                        
1105                    }
1106                });
1107            }
1108            
1109            $(window).on('scroll', $.debounce(250, ajaxLoadInfinitiveScroll));
1110        },
1111        
1112        //single Scrolling 
1113        /* ============================================================================
1114         * Single INFINITY AJAX Load Posts
1115         * ==========================================================================*/
1116        infinityAjaxLoadSinglePost: function() {
1117            var ajaxLoadPost = $('.single-infinity-scroll');
1118            var nextArticlePopup = $('.single-next-article-info-popup');
1119            var currentArticleInfo = $('.header-current-reading-article');
1120            var $this;
1121            function ajaxLoad(parameters, postContainer) {
1122                var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];
1123                var ajaxStatus = '',
1124                    ajaxCall = $.ajax({
1125                        url: parameters.postURLtoLoad,
1126                        type: "GET",
1127                        dataType: "html"
1128                    });
1129                ajaxCall.done(function(respond) {
1130                    if (respond) {
1131                        var elToLoad = $($(respond).find('.single-infinity-container').html()).css('opacity',0).animate({'opacity': 1}, 400);
1132                        var adsRandomCode = $(respond).find('.single-infinity-container').parents('.ceris-dedicated-single-header').data('infinity-ads');
1133                        postContainer.append(adsRandomCode);
1134                        postContainer.append(elToLoad);
1135                        
1136                        setTimeout(function() {
1137                            var $stickySidebar = $(postContainer).children().last(
1137).find('.js-sticky-sidebar');
1138                            var $stickyHeader = $('.js-sticky-header');
1139            
1140                            var marginTop = ($stickyHeader.length) ? ($stickyHeader.outerHeight() + 20) : 0; // check if there's sticky header
1141            
1142                            if ( $( document.body ).hasClass( 'admin-bar' ) ) // check if admin bar is shown.
1143                                marginTop += 32;
1144            
1145                            if ( $.isFunction($.fn.theiaStickySidebar) ) {
1146                                $stickySidebar.theiaStickySidebar({
1147                                    additionalMarginTop: marginTop,
1148                                    additionalMarginBottom: 20,
1149                                });
1150                            }
1151                            
1152                            //React
1153                            
1154                            var reactions = $(postContainer).children().last().find('.js-atbs-reaction');
1155                            ATBS.ATBS_reaction.atbs_reaction(reactions);
1156                            
1157                            // Remove Ajax Load
1158                            var postURLnextLoad = postContainer.find('.single-infinity-inner').last().data('url-to-load');
1159                            if((typeof postURLnextLoad == 'undefined') || (postURLnextLoad == '')) {
1160                                $('.infinity-single-trigger').remove();
1161                            }
1162                            
1163                        }, 250); // wait a bit for precise height;   
1164                        // Run Photorama
1165                        setTimeout(function() {
1166                            var galleryPhotorama = $(postContainer).children().last().find('.fotorama');
1167                            if(galleryPhotorama.length > 0) {
1168                              $(galleryPhotorama).fotorama();
1169                            }
1170                            
1171                        }, 250); // wait a bit for precise height;   
1172                          
1173                        // js blur single
1174                        var overlayBackgroundSingle = $(postContainer).children().find('.js-overlay-bg');
1175                        
1176                        if (overlayBackgroundSingle.length) {
1177                            overlayBackgroundSingle.each(function() {
1178                                
1179                                var $mainArea = $(this).find('.js-overlay-bg-main-area');
1180                                if (!$mainArea.length) {
1181                                    $mainArea = $(this);
1182                                }
1183                
1184                                var $subArea = $(this).find('.js-overlay-bg-sub-area');
1185                                var $subBg = $(this).find('.js-overlay-bg-sub');
1186                
1187                                var leftOffset = $mainArea.offset().left - $subArea.offset().left;
1188                                var topOffset = $mainArea.offset().top - $subArea.offset().top;
1189                
1190                                $subBg.css('display', 'block');
1191                                $subBg.css('position', 'absolute');
1192                                $subBg.css('width', $mainArea.outerWidth() + 'px');
1193                                $subBg.css('height', $mainArea.outerHeight() + 'px');
1194                                $subBg.css('left', leftOffset + 'px');
1195                                $subBg.css('top', topOffset + 'px');
1196                            });
1197                        };
1198                          
1199                        // do stuff like changing parameters
1200                        var $postSliderSidebar = $(postContainer).children().last().find('.js-atbs-ceris-carousel-1i-loopdot');
1201    
1202                        $postSliderSidebar.each( function() {
1203                            $(this).owlCarousel({
1204                                items: 1,
1205                                margin: 0,
1206                                loop: true,
1207                                nav: true,
1208                                dots: true,
1209                                autoHeight: true,
1210                                navText: ['<i class="mdicon mdicon-chevron-thin-left"></i>', '<i class="mdicon mdicon-chevron-thin-right"></i>'],
1211                                smartSpeed: 500,
1212                                responsive: {
1213                                    0 : {
1214                                        items: 1,
1215                                    },
1216            
1217                                },
1218                            });
1219                        });    
1220                    
1221                        // Review
1222                        var reviews_rating_score = $(postContainer).children().last(
1222).find('.reviews-score-list');
1223                        ATBS.ATBS_CustomerReview.reviewScoreList(reviews_rating_score); 
1224                        
1225                        var reviews_rating_star = $(postContainer).children().last().find('.reviews-rating');
1226                        ATBS.ATBS_CustomerReview.reviewRatingStarIcon(reviews_rating_star);     
1227                        
1228                        var userReviewContents = $(postContainer).children().last().find('.ceris-user-review-content');
1229                        ATBS.ATBS_CustomerReview.reviewReadmoreInit(userReviewContents);
1230                        
1231                        var reader_review_form = $(postContainer).children().last().find('.rating-form');
1232                        ATBS.ATBS_CustomerReview.userReviewFormSubmit(reader_review_form);
1233                        
1234                        var closeReviewPopup_1 = $(postContainer).children().last().find('.btn-close-review-popup');
1235                        var closeReviewPopup_2 = $(postContainer).children().last().find('.btn-close-review-normal');                        
1236                        ATBS.ATBS_CustomerReview.popupThankyouPanel(closeReviewPopup_1, closeReviewPopup_2);
1237
1238                        currentArticleInfoUpdate();
1239                        nextArticlePopupInfo();                                                
1240                    }
1241                });
1242
1243                ajaxCall.fail(function() {
1244                    ajaxStatus = 'failed';
1245                });
1246                ajaxCall.always(function() {
1247                    $this.removeClass('infinity-disable');      
1248                    var triggerElement = $this.find('.infinity-single-trigger');
1249                    if(!triggerElement.length) {
1250                        return
1251                    }
1252                    //ATBS.ajaxLazyload.lazyload_start();
1253                });
1254            }
1255            function nextArticlePopupInfo(){                
1256                var elemnt_scroll  = $('.element-scroll-percent');
1257                elemnt_scroll.each( function() {
1258                    var thisELScroll = $(this);
1259                    var theJourney = $(window).scrollTop() - thisELScroll.offset().top;
1260                    if((theJourney > 0) && (theJourney <= thisELScroll.height())) {
1261                        var nextPostTitletoLoad = thisELScroll.data('post-title-to-load');
1262                        if(theJourney > (thisELScroll.height() - $(window).height())) {
1263                            nextArticlePopup.addClass('atbs-force-hidden');
1264                        }else {
1265                            if((nextArticlePopup.hasClass('atbs-force-hidden')) && (nextPostTitletoLoad != '')) {
1266                                nextArticlePopup.removeClass('atbs-force-hidden');
1267                            }
1268                        }
1269                        if(nextPostTitletoLoad != '') {
1270                            var currentPostTitleText = $.trim(nextArticlePopup.find('.post__title').html());
1271                            if((nextPostTitletoLoad !== currentPostTitleText) || (currentPostTitleText == '')) {
1272                                var wcntPerMin;
1273                                if(typeof ceris_wcount !== 'undefined'){
1274                                    wcntPerMin = ceris_wcount[0];                                    
1275                                }else {
1276                                    wcntPerMin = 130;
1277                                }
1278                                var postWPM = parseInt(thisELScroll.data('next-wcount')/wcntPerMin) + 1;
1279                                nextArticlePopup.find('.post__title').text(nextPostTitletoLoad); 
1280                                nextArticlePopup.find('span.ceris-article-wpm').text(postWPM);
1281                                nextArticlePopup.find('.post__title').unbind();
1282                                nextArticlePopup.find('.post__title').on('click',function(e) {
1283                                    e.preventDefault();
1284                                    $('body,html').animate({
1285                                        scrollTop: thisELScroll.offset().top + thisELScroll.height(),
1286                                    }, 800);
1287                                });   
1288                                nextArticlePopup.removeClass('atbs-force-hidden');
1289                            }
1290                        }else {
1291                            nextArticlePopup.addClass('atbs-force-hidden');
1292                        }
1293                    }
1294                });
1295            }
1296            function currentArticleInfoUpdate() {
1297                var elemnt_scroll  = $('.element-scroll-percent');
1298                elemnt_scroll.each( function() {
1299                    var thisELScroll = $(this);
1300                    var theJourney = $(window).scrollTop() - thisELScroll.offset().top;
1301                    if((theJourney > 0) && (theJourney <= thisELScroll.height())) {
1302                        
1303                        var currentReadingPostTitle = $.trim($(currentArticleInfo.find('h5')).html());
1304                        var currentPostTitleText = $.trim(thisELScroll.find('header.single-header').find('h1.post__title').html());
1305                        currentArticleInfo.find('h5').unbind();
1306                        currentArticleInfo.find('h5').on('click',function(e) {
1307                            e.preventDefault();
1308                            $('body,html').animate({
1309                                scrollTop: thisELScroll.offset().top - 70,
1310                            }, 800);
1311                        });   
1312                        if((currentReadingPostTitle !== currentPostTitleText) || (currentReadingPostTitle == '')) {
1313                            var wcntPerMin;
1314                            if(typeof ceris_wcount !== 'undefined'){
1315                                wcntPerMin = ceris_wcount[0];                                    
1316                            }else {
1317                                wcntPerMin = 130;
1318                            }
1319                            var postWPM = parseInt(thisELScroll.data('wcount')/wcntPerMin) + 1;
1320                            currentArticleInfo.find('h5').text(currentPostTitleText); 
1321                            currentArticleInfo.find('span.ceris-article-wpm').text(postWPM);
1322                            currentArticleInfo.find('h5').unbind();
1323                            currentArticleInfo.find('h5').on('click',function(e) {
1324                                e.preventDefault();
1325                                $('body,html').animate({
1326                                    scrollTop: thisELScroll.offset().top - 70,
1327                                }, 800);
1328                            });   
1329                        }
1330                    }
1331                });
1332            }
1333            function ajaxLoadInfinitiveScroll(){
1334                
1335                $this = ajaxLoadPost;
1336                
1337                nextArticlePopupInfo();
1338                
1339                currentArticleInfoUpdate();
1340                                                
1341                var triggerElement = $this.find('.infinity-single-trigger');
1342                
1343                if(!triggerElement.length) {
1344                    return;
1345                }
1346                
1347                var top_of_element = triggerElement.offset().top;
1348                var bottom_of_element = triggerElement.offset().top + triggerElement.outerHeight();
1349                var bottom_of_screen = $(window).scrollTop() + $(window).innerHeight();
1350                var top_of_screen = $(window).scrollTop();
1351                
1352                if ((bottom_of_screen > top_of_element) && (top_of_screen < bottom_of_element)){
1353                    if($this.hasClass('infinity-disable'))
1354                        return;
1355                            
1356                    $this.addClass('infinity-disable');
1357                    var postURLtoLoad = $this.find('.single-infinity-inner').last().data('url-to-load');
1358                    var postContainer = $this.find('.single-infinity-container');
1359
1360                    var parameters = {
1361                        postURLtoLoad: postURLtoLoad,
1362                    };
1363                    ajaxLoad(parameters, postContainer);
1364                }
1365            }
1366            
1367            $(window).on('scroll', $.debounce(250, ajaxLoadInfinitiveScroll));
1368        },
1369    };
1370
1371    ATBS.documentOnResize = {
1372        ticking: false,
1373        windowWidth: $window.width(),
1374
1375        init: function() {
1376            window.addEventListener('resize', function(e) {
1377                if (!ATBS.documentOnResize.ticking) {
1378                    window.requestAnimationFrame(function() {
1379                        ATBS.documentOnResize.windowWidth = $window.width();
1380
1381                        // Functions to call here
1382                        if (!ATBS.header.smartAffix.isDestroyed) {
1383                            ATBS.header.smartAffix.eventResize(ATBS.documentOnResize.windowWidth);
1384                        }
1385
1386                        ATBS.clippedBackground();
1387
1388                        ATBS.documentOnResize.ticking = false;
1389                    });
1390                }
1391                ATBS.documentOnResize.ticking = true;
1392            });
1393        },
1394    };
1395    ATBS.ATBS_Bookmark = {
1396        init: function() {
1397            var buttonRemoveBookmark = $('.bookmark-for-user .post__button-remove-bookmark');
1398            var buttonBookMarkUser = $('.bookmark-for-user .post__button-bookmark');
1399            var buttonDismissBookmark = $('.ceris-dismiss-item');
1400            var buttonBookMarkShowOption = $('.bookmark-for-guest .button-bookmark-option');
1401            var buttonPercentWBookmark = $('.scroll-count-percent-with-bookmark');
1402            
1403            if(buttonBookMarkUser.length) {
1404                ATBS.ATBS_Bookmark.bookmarkUser(buttonBookMarkUser);
1405            }
1406            
1407            if(buttonRemoveBookmark.length) {
1408                ATBS.ATBS_Bookmark.removebookmarkUser(buttonRemoveBookmark);
1409            }
1410            if(buttonDismissBookmark.length) {
1411                ATBS.ATBS_Bookmark.dismissArticle(buttonDismissBookmark);
1412            }
1413            if(buttonBookMarkShowOption.length) {
1414                ATBS.ATBS_Bookmark.bookmarkforGuest(buttonBookMarkShowOption);
1415            }
1416            if(buttonPercentWBookmark.length) {
1417                ATBS.ATBS_Bookmark.bookmarkSingleScrolling(buttonPercentWBookmark);
1418            }
1419            $(document).on('click',function(event){
1420                if (!$(event.target).closest(".button-bookmark-option, .button-bookmark-option-content").length) {
1421                    $(".show-bookmark-option-content").toggleClass('show-bookmark-option-content');
1422                }
1423            });
1424        },
1425        /* ============================================================================
1426        * Bookmark
1427        * ==========================================================================*/
1428        bookmarkUser: function(buttonBookMarkUser){
1429            buttonBookMarkUser.each(function () {
1430                $(this).off('click');
1431                $(this).on('click',function(){
1432                    $(this).closest('.bookmark__buttons-wrap').find('.post__button-bookmark-option').removeClass('show-bookmark-option-content');
1433                    var bookmarkItem = $(this).parents('.post-has-bookmark');
1434                    $(bookmarkItem).toggleClass('active-status-bookmark');
1435                    
1436                    $(this).toggleClass('show-bookmark-option-content');
1437                    
1438                    var userID = $(this).closest('.bookmark-for-user').data('userid');
1439                    var postID = $(this).closest('.bookmark-for-user').data('postid');
1440                    if($(bookmarkItem).hasClass('active-status-bookmark')) {
1441                        var parameters = {
1442                            action: 'ceris_add_bookmark',
1443                            userID: userID,
1444                            postID: postID
1445                        };
1446                        ATBS.ATBS_Bookmark.ajaxLoad(parameters);
1447                    }else {
1448                        var parameters = {
1449                            action: 'ceris_remove_bookmark',
1450                            userID: userID,
1451                            postID: postID
1452                        };
1453                        ATBS.ATBS_Bookmark.ajaxLoad(parameters);
1454                    }
1455                });
1456            });
1457        },
1458        bookmarkSingleScrolling: function(buttonPercentWBookmark){
1459            buttonPercentWBookmark.each(function () {
1460                $(this).off('click');
1461                $(this).on('click',function(){              
1462                    var bookmarkIcon = $(this).find('.btn-bookmark-icon');
1463                    
1464                    var userID = $(this).closest('.atbs-scroll-single-percent-wrap').data('userid');
1465                    var postID = $(this).closest('.atbs-scroll-single-percent-wrap').data('postid');
1466                    
1467                    $(bookmarkIcon).toggleClass('is-saved');
1468                    if(bookmarkIcon.hasClass('is-saved')) {
1469                        $('.atbs-ceris-block-'+postID).addClass('ceris-already-bookmarked');
1470                    }else {
1471                        $('.atbs-ceris-block-'+postID).removeClass('ceris-already-bookmarked');
1472                    }
1473                    
1474                    $(this).toggleClass('show-bookmark-option-content');
1475                    
1476                    if($(bookmarkIcon).hasClass('is-saved')) {
1477                        var parameters = {
1478                            action: 'ceris_add_bookmark',
1479                            userID: userID,
1480                            postID: postID
1481                        };
1482                        ATBS.ATBS_Bookmark.ajaxLoad(parameters);
1483                    }else {
1484                        var parameters = {
1485                            action: 'ceris_remove_bookmark',
1486                            userID: userID,
1487                            postID: postID
1488                        };
1489                        ATBS.ATBS_Bookmark.ajaxLoad(parameters);
1490                    }
1491                });
1492            });
1493        },
1494        dismissArticle: function(buttonDismissBookmark) {
1495            buttonDismissBookmark.each(function () {
1496                $(this).off('click');
1497                $(this).on('click',function(){
1498                    var thisobj = $(this);
1499                    if($(this).parents('.site-content').hasClass('bookmark-without-dismiss')) {
1500                        return;
1501                    }
1502                    
1503                    var userID = $(this).closest('.bookmark-for-user').data('userid');
1504                    var postID = $(this).closest('.bookmark-for-user').data('postid');
1505                        
1506                    if($(this).hasClass('ceris-remove-dismiss')) {
1507                        var parameters = {
1508                            action: 'ceris_remove_dismiss_article',
1509                            userID: userID,
1510                            postID: postID
1511                        };
1512                        ATBS.ATBS_Bookmark.ajaxLoad(parameters);
1513                    }else {
1514                        var moduleID = $(this).closest('.atbs-ceris-block').attr('id');
1515                        var args = ajax_buff['query'][moduleID]['moduleInfo']['bookmarkTmp'];
1516                        args.push(postID);
1517                        ajax_buff['query'][moduleID]['moduleInfo']['bookmarkTmp'] = args;
1518                        
1519                        var parameters = {
1520                            action: 'ceris_dismiss_article',
1521                            userID: userID,
1522                            postID: postID
1523                        };
1524                        ATBS.ATBS_Bookmark.ajaxLoad(parameters);
1525                    }                  
1526                    $(this).closest('.list-item').addClass('ceris-scale-to-zero');
1527                    var waitingCount = 3;
1528                    var checkItemClassthenRemove = setInterval(function() {
1529                        if(waitingCount == 0) {
1530                            clearInterval(checkItemClassthenRemove);
1531                        }
1532                        if(thisobj.closest('.list-item').hasClass('ceris-scale-to-zero')) {
1533                            thisobj.closest('.list-item').remove();
1534                            clearInterval(checkItemClassthenRemove);
1535                        }
1536                        waitingCount --;
1537                    }, 350); // check every 100ms
1538                });
1539            });
1540        },
1541        removebookmarkUser: function(buttonRemoveBookmark) {
1542            $('.post-has-bookmark').hover(function(){
1543              }, function(){
1544              $(this).find('.post__button-bookmark-option').removeClass('show-bookmark-option-content')
1545            });
1546            buttonRemoveBookmark.each(function () {
1547                $(this).off('click');
1548                $(this).on('click',function(){
1549                    //$(this).closest('.bookmark__buttons-wrap').find('.post__button-bookmark-option').removeClass('show-bookmark-option-content');
1550                    $(this).toggleClass('show-bookmark-option-content');
1551                });
1552            });
1553        },        
1554        bookmarkforGuest: function(buttonBookMarkShowOption) {
1555            $('.post-has-bookmark').hover(function(){
1556              }, function(){
1557              $(this).find('.post__button-bookmark-option').removeClass('show-bookmark-option-content')
1558            });
1559            buttonBookMarkShowOption.each(function () {
1560                $(this).off('click');
1561                $(this).on('click',function(){
1562                    //$(this).closest('.bookmark__buttons-wrap').find('.post__button-bookmark-option').removeClass('show-bookmark-option-content');
1563                    $(this).closest('.post__button-bookmark-option').siblings().removeClass('show-bookmark-option-content');
1564                    $(this).closest('.post__button-bookmark-option').toggleClass('show-bookmark-option-content');
1565                });
1566            });
1567        },
1568        reAddBookmark: function(container){
1569            var buttonBookMarkUser = $(container).find('.bookmark-for-user .post__button-bookmark');
1570            var buttonRemoveBookmark = $(container).find('.bookmark-for-user .post__button-remove-bookmark');
1571            var buttonDismissBookmark = $(container).find('.ceris-dismiss-item');
1572            var buttonBookMarkShowOption = $('.bookmark-for-guest .button-bookmark-option');
1573            
1574            if(buttonBookMarkUser.length) {
1575                ATBS.ATBS_Bookmark.bookmarkUser(buttonBookMarkUser);
1576            }
1577            
1578            if(buttonRemoveBookmark.length) {
1579                ATBS.ATBS_Bookmark.removebookmarkUser(buttonRemoveBookmark);
1580            }
1581            if(buttonDismissBookmark.length) {
1582                ATBS.ATBS_Bookmark.dismissArticle(buttonDismissBookmark);
1583            }
1584            if(buttonBookMarkShowOption.length) {
1585                ATBS.ATBS_Bookmark.bookmarkforGuest(buttonBookMarkShowOption);
1586            }
1587
1588            container.find('.ceris-scale-to-zero').remove();
1589       
1590        },
1591        ajaxLoad: function(parameters) {
1592            var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];
1593           // console.log(parameters);
1594            var ajaxStatus = '',
1595                ajaxCall = $.ajax({
1596                    url: ajaxurl,
1597                    type: 'post',
1598                    dataType: 'html',
1599                    data: {
1600                        action: parameters.action,
1601                        userID: parameters.userID,
1602                        postID: parameters.postID,
1603                        securityCheck: cerisAjaxSecurity
1604                        // other parameters
1605                    },
1606                });
1607            ajaxCall.done(function(respond) {
1608                //console.log(respond);
1609            });
1610
1611            ajaxCall.fail(function() {
1612            });
1613
1614            ajaxCall.always(function() {
1615            });
1616        },
1617    }
1618    ATBS.ATBS_CustomerReview = {
1619        init: function() {
1620            var reviews_rating_score = $('.reviews-score-list');
1621            var reviews_rating_star = $('.reviews-rating');
1622            var userReviewContents = $('.ceris-user-review-content');
1623            var reader_review_form = $('.rating-form');
1624            var closeReviewPopup_1 = $('.btn-close-review-popup');
1625            var closeReviewPopup_2 = $('.btn-close-review-normal');
1626            
1627            ATBS.ATBS_CustomerReview.reviewRatingStarIcon(reviews_rating_star);
1628            ATBS.ATBS_CustomerReview.reviewScoreList(reviews_rating_score);
1629            ATBS.ATBS_CustomerReview.reviewReadmoreInit(userReviewContents);
1630            ATBS.ATBS_CustomerReview.userReviewFormSubmit(reader_review_form);
1631            ATBS.ATBS_CustomerReview.popupThankyouPanel(closeReviewPopup_1, closeReviewPopup_2);
1632            ATBS.ATBS_CustomerReview.reviewAdminDelete();
1633        },
1634        reviewReadmoreInit: function(userReviewContents) {
1635            ATBS.ATBS_CustomerReview.reviewReadmoreCal(userReviewContents);
1636        },
1637        reviewReadmoreCal: function(userReviewContents){
1638            $(userReviewContents).each(function(index, userReviewContent) {
1639                ATBS.ATBS_CustomerReview.reviewReadmoreAction(userReviewContent);
1640            });
1641        },
1642        reviewReadmoreAction: function(userReviewContent) {
1643            var reviewContentHeight = $(userReviewContent).find('.user__description-excerpt').height();
1644            var ceris_html = document.getElementsByTagName('html')[0];
1645            var ceris_rem = parseInt(window.getComputedStyle(ceris_html)['fontSize']);
1646
1647            var checkExist = setInterval(function() {
1648                if(reviewContentHeight > 0) {
1649                    if(reviewContentHeight > (6.8*ceris_rem)) {
1650                        $(userReviewContent).addClass('has-more-active');
1651                    }
1652                    $(userReviewContent).find('.review-readmore').on('click', function(e) {
1653                        $(this).siblings('.user__description-excerpt').css({
1654                          // Set height to prevent instant jumpdown when max height is removed
1655                          "height": $(userReviewContent).find('.user__description-excerpt').height(),
1656                          "max-height": 9999
1657                        }).animate({
1658                          "height": reviewContentHeight
1659                        });
1660                        $(userReviewContent).removeClass('has-more-active');
1661                    });
1662                    $(userReviewContent).removeClass(('review-content-loading'));
1663                    clearInterval(checkExist);
1664                }
1665            }, 50); // check every 100ms
1666        },
1667        popupThankyouPanel: function(closeReviewPopup_1, closeReviewPopup_2){
1668            closeReviewPopup_1.on('click', function(){
1669                $(this).closest('.ceris-user-review-popup-notification ').removeClass('enable-review-popup');
1670            });
1671            closeReviewPopup_2.on('click', function(){
1672                $(this).closest('.ceris-user-review-popup-notification ').removeClass('enable-review-popup');
1673            });
1674        },
1675        userReviewFormSubmit: function(reader_review_form) {
1676            reader_review_form.each(function () {
1677                $(this).submit(function(e){
1678                    e.preventDefault();
1679                    var thisFormSubmitButton;
1680                    thisFormSubmitButton = $(this);
1681                    thisFormSubmitButton.find('.rating-submit').addClass('ceris_loading');
1682                    var formData = $(this).serializeArray();
1683                    var userID = $(this).closest('.reviews-rating').data('userid');
1684                    var postID = $(this).closest('.reviews-rating').data('postid');
1685                    var reviewTime = new Date(); 
1686                    var reviewTimeStr = ATBS.ATBS_CustomerReview.reviewMonthName() + ' ' + reviewTime.getDate() + ', ' + reviewTime.getFullYear();
1687                    var formVal = {userID:userID, postID:postID, reviewTime:reviewTimeStr};
1688      
1689                    $(formData).each(function(index, field){
1690                        switch(field.name) {
1691                            case 'user-star-rating':
1692                                formVal.user_star_rating = field.value;
1693                                break;
1694                            case 'user-review-title':
1695                                formVal.user_review_title = field.value;
1696                                break;
1697                            case 'user-review-content':
1698                                formVal.user_review_content = field.value;
1699                                break;
1700                        }
1701                    });
1702                    var parameters = {
1703                        action: 'ceris_user_review',
1704                        formVal: formVal,
1705                    };
1706                    
1707                    ATBS.ATBS_CustomerReview.ajaxLoad(parameters, thisFormSubmitButton);
1708                });
1709            });
1710        },
1711        reviewMonthName: function(){
1712            var month = new Array();
1713            month[0] = "Jan";
1714            month[1] = "Feb";
1715            month[2] = "Mar";
1716            month[3] = "Apr";
1717            month[4] = "May";
1718            month[5] = "Jun";
1719            month[6] = "Jul";
1720            month[7] = "Aug";
1721            month[8] = "Sep";
1722            month[9] = "Oct";
1723            month[10] = "Nov";
1724            month[11] = "Dec";
1725            
1726            var d = new Date();
1727            return month[d.getMonth()];
1728        },
1729        reviewRatingStarIcon: function(reviews_rating_star){
1730            reviews_rating_star.each(function () {
1731                var theCurrentReviewForm = $(this);
1732                var rating_reviews_list = $(this).find('.rating-form');
1733                $(rating_reviews_list).each(function () {
1734                    var star_score_icon = $(this).find('.star-item');
1735                    star_score_icon.on('click',function () {                        
1736                        $(star_score_icon).removeClass("active");
1737                        var star_score_value = $(this).index();
1738                        $(this).parents('.rating-star').siblings('.user-star-rating').attr('value', 5 - star_score_value);
1739                        star_score_icon.each(function () {
1740                            if ($(this).index() >= star_score_value){
1741                                //console.log($(this).index());
1742                                $(this).addClass("active");
1743                            }
1744                        })
1745                    });
1746                });
1747            });
1748        },
1749        reviewScoreList: function(reviews_rating_score){
1750            reviews_rating_score.each(function () {
1751                var score_list_item = $(this).find(".score-item");
1752                $(score_list_item).each(function () {
1753                    var percent = parseFloat( $(this).data('total') );
1754                    var percent_default = 0;
1755                    var score_item = setInterval(frame, 0  );
1756                    var $this = $(this);
1757                    function frame() {
1758                        if (percent_default >= percent) {
1759                            clearInterval(score_item);
1760                        } else {
1761                            percent_default++;
1762                            $this.find(".score-percent").css({"width": percent_default +'%'});
1763                            $this.find(".score-number").text(percent_default / 10);
1764                            // console.log(percent_default);
1765                        }
1766                    }
1767                });
1768            });
1769        },
1770        ajaxLoad: function(parameters, thisFormSubmitButton) {
1771            var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];
1772            var ajaxStatus = '',
1773                ajaxCall = $.ajax({
1774                    url: ajaxurl,
1775                    type: 'post',
1776                    dataType: 'html',
1777                    data: {
1778                        action: parameters.action,
1779                        formVal: parameters.formVal,
1780                        securityCheck: cerisAjaxSecurity
1781                        // other parameters
1782                    },
1783                });
1784            ajaxCall.done(function(respond) {
1785                var theReview = $.parseJSON(respond);
1786                
1787                var container = $(thisFormSubmitButton).closest('.reviews-rating').siblings('.ceris-user-reviews').find('.user-reviews-list');
1788                container.prepend(theReview);
1789                
1790                var userReviewContents = container.find('.list-item:first-child').find('.ceris-user-review-content');
1791                ATBS.ATBS_CustomerReview.reviewReadmoreCal(userReviewContents);
1792                
1793                var ReviewPerPage = $(thisFormSubmitButton).closest('.reviews-rating').siblings('.ceris-user-reviews').data('user-review-count');
1794                if($(thisFormSubmitButton).closest('.reviews-rating').siblings('.ceris-user-reviews').find('.list-item').length > ReviewPerPage) {
1795                    $(thisFormSubmitButton).closest('.reviews-rating').siblings('.ceris-user-reviews').find('.list-item:last-child').remove();
1796                }
1797                $(thisFormSubmitButton).closest('.reviews-rating').addClass('hidden-form');
1798                $(thisFormSubmitButton).closest('.reviews-content').siblings('.ceris-user-review-popup-notification').addClass('enable-review-popup');
1799                var popuploadcomplete = setInterval(function() {
1800                    $(thisFormSubmitButton).closest('.ceris-reviews-section').find('.circle-loader').addClass('load-complete');       
1801                    $(thisFormSubmitButton).closest('.ceris-reviews-section').find('.checkmark').toggle();
1802                    clearInterval(popuploadcomplete);
1803                },800);
1804            });
1805
1806            ajaxCall.fail(function() {
1807            });
1808
1809            ajaxCall.always(function() {
1810                thisFormSubmitButton.find('.rating-submit').removeClass('ceris_loading');
1811            });
1812        },
1813        reviewPagination: function($this, currentPageVal){
1814            var postID = $this.closest('.ceris-user-reviews').siblings('.reviews-rating').data('postid');
1815            var reviewPerPage = $this.closest('.ceris-user-reviews').data('user-review-count');
1816            var parameters = {
1817                action: 'ceris_user_review_pagination',
1818                currentPageVal : currentPageVal,
1819                postID: postID,
1820                reviewPerPage: reviewPerPage,
1821            };
1822            var container = $this.closest('.ceris-user-review-pagination').siblings('.user-reviews-list');
1823            container.css('height', container.height()+'px');
1824            container.append('<div class="bk-preload-wrapper"></div>');
1825            container.find('.list-item').addClass('bk-preload-blur');
1826            
1827            ATBS.ATBS_CustomerReview.paginationAjaxLoad(parameters, $this);
1828        },
1829        paginationAjaxLoad: function(parameters, $this) {
1830            var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];
1831            var ajaxStatus = '',
1832                ajaxCall = $.ajax({
1833                    url: ajaxurl,
1834                    type: 'post',
1835                    dataType: 'html',
1836                    data: {
1837                        action: parameters.action,
1838                        currentPageVal: parameters.currentPageVal,
1839                        postID: parameters.postID,
1840                        reviewPerPage: parameters.reviewPerPage,
1841                        securityCheck: cerisAjaxSecurity
1842                        // other parameters
1843                    },
1844                });
1845            ajaxCall.done(function(respond) {
1846                var theReviews = $.parseJSON(respond);
1847                var elToLoad = $(theReviews).css('opacity',0).animate({'opacity': 1}, 400);
1848                
1849                var container = $this.closest('.ceris-user-review-pagination').siblings('.user-reviews-list');
1850                container.html(elToLoad); 
1851                
1852                var userReviewContents = $(container).find('.ceris-user-review-content');
1853                ATBS.ATBS_CustomerReview.reviewReadmoreCal(userReviewContents);
1854                          
1855                container.find('.bk-preload-wrapper').remove();
1856                container.find('.list-item').removeClass('bk-preload-blur');
1857                                
1858                setTimeout(function(){ container.css('height', 'auto'); }, 200);
1859                
1860                ATBS.ATBS_CustomerReview.reviewAdminDelete();
1861            });
1862
1863            ajaxCall.fail(function() {
1864            });
1865
1866            ajaxCall.always(function() {
1867            });
1868        },
1869        reviewAdminDelete: function() {
1870            var reviewDelButtons = $('.ceris-admin-delete-review');
1871            $(reviewDelButtons).each(function () {
1872                if(!$(this).hasClass('deleteBtnActive')) {
1873                    $(this).on('click', function() {
1874                        var userID = $(this).data('userid');
1875                        var postID = $(this).data('postid');
1876                        var formVal = {userID:userID, postID:postID};
1877                        var parameters = {
1878                            action: 'ceris_user_delete_review',
1879                            postID: postID,
1880                            formVal: formVal
1881                        };
1882                        ATBS.ATBS_CustomerReview.reviewAdminDeleteAjax(parameters, $(this));
1883                    });
1884                    $(this).addClass('deleteBtnActive');
1885                }
1886            });
1887        },
1888        reviewAdminDeleteAjax: function(parameters, $this) {
1889            var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];
1890            var ajaxStatus = '',
1891            ajaxCall = $.ajax({
1892                url: ajaxurl,
1893                type: 'post',
1894                dataType: 'html',
1895                data: {
1896                    action: parameters.action,
1897                    formVal: parameters.formVal,
1898                    securityCheck: cerisAjaxSecurity
1899                    // other parameters
1900                },
1901            });
1902            ajaxCall.done(function(respond) {
1903                $this.closest('.list-item').slideUp("normal", function() { $(this).remove(); } );
1904            });
1905
1906            ajaxCall.fail(function() {
1907            });
1908
1909            ajaxCall.always(function() {
1910            });
1911        },
1912    }
1913    /* ============================================================================
1914     * Reaction
1915     * ==========================================================================*/    
1916    ATBS.ATBS_reaction = {
1917        init: function() {
1918            var reactions = $('.js-atbs-reaction');
1919            ATBS.ATBS_reaction.atbs_reaction(reactions);
1920        },
1921        /**/
1922        atbs_reaction: function(reactions){
1923            reactions.each( function() {
1924                var reaction_col = $(this).find('.atbs-reactions-col');
1925                reaction_col.on('click', function(){
1926                    var reactionType = $(this).data('reaction-type');
1927                    var reaction_content = $(this).find('.atbs-reactions-content');
1928                    var reactionStatus = '';
1929                    if($(this).find('.atbs-reactions-image').hasClass("active")){
1930                        reactionStatus = 'active';
1931                    }else{
1932                        reactionStatus = 'non-active';
1933                    }
1934                    if($(this).find('.atbs-reactions-image').hasClass("active")){
1935                        $(this).find('.atbs-reactions-image').removeClass("active");
1936                        $(this).find('.atbs-reactions-image').removeClass("scale-icon");
1937                        
1938                    }else{
1939                        $(this).find('.atbs-reactions-image').addClass("active");
1940                        $(this).find('.atbs-reactions-image').addClass("scale-icon"); 
1941                    } 
1942                    if(reaction_content.hasClass("active")){
1943                        reaction_content.removeClass("active");
1944                        reaction_content.removeClass("scale-count");
1945                    }else{
1946                        reaction_content.addClass("active");
1947                        reaction_content.addClass("scale-count");
1948                    }
1949                    ATBS.ATBS_reaction.ajaxLoad($(this), reactionType, reactionStatus);
1950                });
1951            });
1952        },    
1953        ajaxLoad: function(reaction, reactionType, reactionStatus) {
1954            var $this = reaction;
1955            var reaction_content = $this.find('.atbs-reactions-content');
1956            var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];   
1957            var postID = reaction.closest('.js-atbs-reaction').data('article-id');
1958            var ajaxCall = $.ajax({
1959                    url: ajaxurl,
1960                    type: 'post',
1961                    dataType: 'html',
1962                    data: {
1963                        action: 'ceris_ajax_reaction',
1964                        postID: postID,
1965                        reactionType: reactionType,
1966                        reactionStatus: reactionStatus,
1967                        securityCheck: cerisAjaxSecurity,
1968                    },
1969                });
1970            ajaxCall.done(function(respond) {
1971                var results = $.parseJSON(respond);
1972                $this.find('.atbs-reaction-count').html(results);
1973            });
1974            ajaxCall.fail(function() {
1975                //console.log('failed');
1976            });
1977            ajaxCall.always(function() {
1978                 if($this.find('.atbs-reactions-image').hasClass("active")){
1979                    $this.find('.atbs-reactions-image').removeClass("scale-icon");
1980                 }
1981                if(reaction_content.hasClass("active")){
1982                    reaction_content.removeClass("scale-count");
1983                }
1984            });
1985        },
1986    }    
1987    ATBS.ATBS_carousel = {
1988        init: function() {
1989            var CarouselOptions;
1990            var CarouselCarouselOptionsDefault = {
1991        		items: 5,
1992        	};
1993            $.fn.ATBS_Carousel = function(CarouselOptions){
1994                if(typeof CarouselOptions === 'object' && CarouselOptions) {
1995                    console.log(Object.keys(CarouselOptions).length);
1996                    var thisCarouselOptions = $.extend({}, CarouselCarouselOptionsDefault, CarouselOptions);
1997                    if(thisCarouselOptions.items == 1) {
1998                        $(this).wrapInner('<div class="atbs-carousel"></div>');
1999                        var theCarousel = $(this).children();
2000                        $(this).find('.list-item:first-child').addClass('carousel-item-active');
2001                        theCarousel.css('height', $(this).find('.atbs-carousel').height()+'px');
2002                        $(this).append(ATBS.ATBS_carousel.carousel_nav(thisCarouselOptions.navText));
2003                        $(this.find('.atbs-next')).on('click', function(){
2004                            var currentItem = theCarousel.find('.carousel-item-active');
2005                            if(!$(currentItem).is(':last-child')) {
2006                                var nextItem = theCarousel.find('.carousel-item-active').next();
2007                            }else {
2008                                var nextItem = theCarousel.children().first();
2009                            }
2010                            currentItem.removeClass('carousel-item-active');
2011                            nextItem.addClass('carousel-item-active');
2012                            theCarousel.animate({height:nextItem.height()},300);;
2013                        });
2014                        $(this.find('.atbs-prev')).on('click', function(){
2015                            var currentItem = theCarousel.find('.carousel-item-active');
2016                            if(!$(currentItem).is(':first-child')) {
2017                                var nextItem = theCarousel.find('.carousel-item-active').prev();
2018                            }else {
2019                                var nextItem = theCarousel.children().last(
2019);
2020                            }
2021                            currentItem.removeClass('carousel-item-active');
2022                            nextItem.addClass('carousel-item-active');
2023                            $(this).closest('.atbs-nav').siblings('.atbs-carousel').animate({height:nextItem.height()},300);
2024                            console.log('eventaaaaaaa');
2025                        });
2026                                          
2027                        var startX = 0;
2028                        var startY = 0;
2029                        var endX = 0;
2030                        var endY = 0;      
2031                        
2032                        $(theCarousel).on('dragstart', function(e) {   
2033                            startX = e.pageX;
2034                            startY = e.pageY;       
2035                        });
2036                                                
2037                        $(theCarousel).on('dragend', function(e) { 
2038                            e.preventDefault();  
2039                            endX = e.pageX;
2040                            endY = e.pageY;   
2041                            if(endX < startX){
2042                                console.log('left');
2043                            }else {
2044                                console.log('right');
2045                            }
2046                        });
2047                        /*                                                
2048                        var startX = 0;
2049                        var startY = 0;
2050                        var endX = 0;
2051                        var endY = 0;
2052                        
2053                        var thisAlert = function() {
2054                          alert("Link Clicked");
2055                        };
2056                        
2057                        $(theCarousel).on('mousedown', function(e){
2058                            e.preventDefault();
2059                            e.stopPropagation();
2060                            e.stopImmediatePropagation();                            
2061                            startX = e.pageX;
2062                            startY = e.pageY;
2063                            return false;                                                        
2064                          ;  console.log('aaaaaa');                            
2065                        };
2066                        $(theCarousel).closest('.site-content').on('mouseup', function(e){
2067                            e.preventDefault();
2068                            e.stopPropagation();
2069                            e.stopImmediatePropagation();                            
2070                        $(theCarousenmouseup=function(event){
2071                            endX = e.pageX;
2072                            console.log('aaaaaaaaaaa');                            console.log('bbbbbbbbbb');                            
2073                            
2074                            // Swipe Up 
2075                            ifconsole.logrtY - endY > 
2076                              
2077                            return false;                              event.preventDefault();
2078                         )   }
2079                                                                          
2080                        } ;
2081                        };     */
2082                    }
2083                }
2084            };
2085        },
2086        carousel_nav: function($navArray) {
2087            return '<div class="atbs-nav"><div class="atbs-prev">'+$navArray[0]+'</div><div class="atbs-next">'+$navArray[1]+'</div></div>';
2088        },
2089        carousel_1i: function() {
2090            var carousels = $('.js-atbs-ceris-carousel');
2091            carousels.each( function() {
2092                $(this).ATBS_Carousel({
2093                    items: 1,
2094                    margin: 3,
2095                    nav: true,
2096                    dots: true,
2097                    autoHeight: true,
2098                    navText: ['<i class="mdicon mdicon-chevron-thin-left"></i>', '<i class="mdicon mdicon-chevron-thin-right"></i>'],
2099                    smartSpeed: 500,
2100                    responsive: {
2101                        0 : {
2102                            items: 1,
2103                        },
2104                    },
2105                });
2106            });
2107        },    
2108    }      
2109    ATBS.documentOnReady = {
2110
2111        init: function(){
2112            ATBS.header.init();
2113            ATBS.header.smartAffix.compute();
2114            ATBS.header.smartFooterInfo.compute();
2115            ATBS.documentOnScroll.init();
2116            ATBS.documentOnReady.ajaxLoadPost();
2117            ATBS.documentOnScroll.infinityAjaxLoadPost();
2118            ATBS.documentOnScroll.infinityAjaxLoadSinglePost();
2119            ATBS.documentOnReady.scrollSingleCountPercent();
2120            ATBS.documentOnReady.carousel_1i();
2121            ATBS.documentOnReady.carousel_1i30m_thumb_round();
2122            ATBS.documentOnReady.carousel_only_1i_loopdot();
2123            ATBS.documentOnReady.carousel_1i_loopdot();
2124            ATBS.documentOnReady.carousel_1i_get_background();
2125            ATBS.documentOnReady.carousel_1i_fade_dot_number_effect();
2126            ATBS.documentOnReady.carousel_1i_not_nav();
2127            ATBS.documentOnReady.carousel_1i_not_nav_2();
2128            ATBS.documentOnReady.carousel_1i_dot_number_effect();
2129            ATBS.documentOnReady.carousel_1i_dot_number_get_background();
2130            ATBS.documentOnReady.carousel_1i_dot_number_get_background_style_2();
2131            ATBS.documentOnReady.carousel_1i30m_effect();
2132            ATBS.documentOnReady.carousel_1i30m();
2133            ATBS.documentOnReady.carousel_2i0m_number_effect();
2134            ATBS.documentOnReady.carousel_2i30m_number_effect();
2135            ATBS.documentOnReady.carousel_2i50m_number_effect();
2136            ATBS.documentOnReady.carousel_2i0m();
2137            ATBS.documentOnReady.carousel_2i4m();
2138            ATBS.documentOnReady.carousel_2i30m5();
2139            ATBS.documentOnReady.carousel_2i30m();
2140            ATBS.documentOnReady.carousel_2i10m();
2141            ATBS.documentOnReady.carousel_2i20m();
2142            ATBS.documentOnReady.carousel_3i30m5();
2143            ATBS.documentOnReady.carousel_3i30m5_update();
2144            ATBS.documentOnReady.carousel_4i30m5_update();
2145            ATBS.documentOnReady.carousel_3i4m();
2146            ATBS.documentOnReady.carousel_3i30m();
2147            ATBS.documentOnReady.carousel_3i4m_small();
2148            ATBS.documentOnReady.carousel_3i20m();
2149            ATBS.documentOnReady.carousel_headingAside_3i();
2150            ATBS.documentOnReady.carousel_4i();
2151            ATBS.documentOnReady.carousel_4i4m();
2152            ATBS.documentOnReady.carousel_4i0m();
2153            ATBS.documentOnReady.carousel_4i20m();
2154            ATBS.documentOnReady.carousel_4i30m();
2155            ATBS.documentOnReady.carousel_5i0m();
2156            ATBS.documentOnReady.carousel_overlap();
2157            ATBS.documentOnReady.customCarouselNav();
2158            ATBS.documentOnReady.countdown();
2159            ATBS.documentOnReady.goToTop();
2160            ATBS.documentOnReady.newsTicker();
2161            ATBS.documentOnReady.lightBox();
2162            ATBS.documentOnReady.perfectScrollbarInit();
2163            ATBS.documentOnReady.tooltipInit();
2164            ATBS.documentOnReady.ceris_search_button();
2165            ATBS.documentOnReady.carousel_1i_dot_number();
2166            ATBS.ATBS_Bookmark.init();
2167            ATBS.ATBS_CustomerReview.init();
2168            ATBS.ATBS_reaction.init();
2169            ATBS.ATBS_carousel.init();
2170            ATBS.ATBS_carousel.carousel_1i();
2171            ATBS.documentOnReady.the_close_buttons();
2172            ATBS.documentOnReady.ATBS_Article_Header_Nav_Switch();
2173            ATBS.documentOnReady.ATBSNavDetectEdgeBrowser();
2174            ATBS.documentOnReady.atbs_theme_switch();
2175        },
2176
2177        /* ============================================================================
2178        * Dark Mode & Light Mode   js
2179        * ==========================================================================*/
2180        atbs_theme_switch: function () {
2181            const siteWrapper          = $('.site-wrapper');
2182            const darModeOptionEnabled = siteWrapper.hasClass('atbs-enable-dark-mode-option');
2183            if ( !darModeOptionEnabled ) {
2184                return;
2185            }
2186            const theme_switch         = $('.atbs-theme-switch');
2187            const ceris_logo_switch   = $('.atbs-ceris-logo');
2188            function getCookie(cookieName) {
2189                var name = cookieName + '=';
2190                var decodedCookie = decodeURIComponent(document.cookie);
2191                var cookies = decodedCookie.split(';');
2192                for (var i = 0; i < cookies.length; i++) {
2193                    var cookie = cookies[i];
2194                    while (cookie.charAt(0) == ' ') {
2195                        cookie = cookie.substring(1);
2196                    }
2197                    if (cookie.indexOf(name) == 0) {
2198                        return cookie.substring(name.length, cookie.length);
2199                    }
2200                }
2201                return '';
2202            }
2203            function setCookie(cookieName, cookieValue, expireDays) {
2204                var date = new Date();
2205                date.setTime(date.getTime() + expireDays * 24 * 60 * 60 * 1000);
2206                var expires = 'expires=' + date.toGMTString();
2207                document.cookie = cookieName + '=' + cookieValue + ';' + expires + ';path=/';
2208            }
2209            function toggleDarkMode(status) {
2210                if (status == 'on') {
2211                    $(theme_switch).addClass('active');
2212                    $(ceris_logo_switch).addClass('logo-dark-mode-active');
2213                    siteWrapper.addClass('ceris-dark-mode');
2214                    setCookie(ATBS_DARKMODE_COOKIE_NAME[0], 1, 30); // Save data
2215                } else {
2216                    $(theme_switch).removeClass('active');
2217                    $(ceris_logo_switch).removeClass('logo-dark-mode-active');
2218                    siteWrapper.removeClass('ceris-dark-mode');
2219                    setCookie(ATBS_DARKMODE_COOKIE_NAME[0], 0, 30); // Save data
2220                }
2221            }
2222            function updateDarkMode() {
2223                var darkMode = getCookie(ATBS_DARKMODE_COOKIE_NAME[0]);
2224                if (darkMode == 1) {
2225                    toggleDarkMode('off');
2226                } else {
2227                    toggleDarkMode('on');
2228                }
2229            }
2230            function initDarkMode() {
2231                var darkMode        = getCookie(ATBS_DARKMODE_COOKIE_NAME[0]);
2232                var defaultDarkMode = siteWrapper.hasClass('ceris-dark-mode-default');
2233                // Turn on Dark Mode default if is set in Theme Option
2234                if (darkMode == '') {
2235                    if ( defaultDarkMode ) {
2236                        toggleDarkMode('on');
2237                    }
2238                }
2239            }
2240            theme_switch.each(function() {
2241                $(this).on('click', updateDarkMode);
2242            });
2243            initDarkMode(); // init
2244        },
2245
2246        ATBS_Article_Header_Nav_Switch:function() {
2247            var headerNavSW = $('.header-article-nav-icon');
2248            headerNavSW.on('click', function(e){
2249                e.preventDefault();
2250                $(this).closest('.sticky-header').toggleClass('article-header-nav-hide');
2251                if($(this).closest('.sticky-header').hasClass('article-header-nav-hide')) {
2252                    $(this).closest('.sticky-header').find('.navigation-wrapper').fadeOut(300);
2253                    $(this).closest('.sticky-header').find('.header-current-reading-article').fadeIn(3000);
2254                }else {
2255                    $(this).closest('.sticky-header').find('.navigation-wrapper').fadeIn(3000);
2256                    $(this).closest('.sticky-header').find('.header-current-reading-article').fadeOut(300);
2257                }
2258            });
2259        },
2260        ATBSNavDetectEdgeBrowser: function(){
2261            $("#main-menu li").on('mouseenter mouseleave', function (e) {
2262                if ($('ul', this).length) {
2263                    var elm = $('ul:first', this);
2264                    var off = elm.offset();
2265                    var l = off.left;
2266                    var w = elm.width();
2267                    var docW = $(".site-wrapper").width();
2268                    var isEntirelyVisible = (l + w <= docW);
2269
2270                    if (!isEntirelyVisible) {
2271                        $(this).addClass('atbs-submenu-to-left');
2272                    } else {
2273                        //$(this).removeClass('atbs-submenu-to-left');
2274                    }
2275
2276                    if(l<0) {
2277                        $(this).addClass('atbs-submenu-to-right');
2278                    } else {
2279                        //$(this).removeClass('atbs-submenu-to-right');
2280                    }
2281                }
2282            });
2283        },
2284        the_close_buttons: function(){
2285            $('body').imagesLoaded( function() {
2286                //Cookie bar
2287                var CookieCloseButton = $('#cn-close-notice');
2288                $('#cookie-notice').show();
2289                CookieCloseButton.on('click', function(e){
2290                   e.preventDefault();
2291                   $(this).closest('#cookie-notice').remove();
2292                });
2293                
2294                //Currently Reading Article Panel
2295                var nextArticlePopupCloseButton = $('.single-next-article-info-popup--close');
2296                nextArticlePopupCloseButton.on('click', function(e){
2297                   e.preventDefault();
2298                   $(this).closest('.single-next-article-info-popup').addClass('atbs-force-hidden-forever');
2299                });
2300            });
2301        },
2302        /* ============================================================================
2303        * Single scroll percent
2304        * ==========================================================================*/
2305        scrollSingleCountPercent: function(){
2306            var lastWindowScrollTop = 0;
2307            var scrollDirection = '';
2308            var elemnt_scroll = $('.element-scroll-percent');
2309            if(elemnt_scroll.length > 0){
2310                var ofsetTop_element_scroll;
2311                var ofsetBottom_element_scroll;
2312                var progressValue = $('.progress__value');
2313                var progressValueMobile = $('.scroll-count-percent-mobile .percent-number');
2314                var percentNumberText = $('.percent-number').find('.percent-number-text');
2315                var RADIUS = 54;
2316                var CIRCUMFERENCE = 2 * Math.PI * RADIUS;
2317                var docHeight = 0;
2318                $(progressValue).css({'stroke-dasharray' : CIRCUMFERENCE });
2319                var reading_indicator =  $('.scroll-count-percent');
2320                var dataPostID;
2321                progress(0);
2322                $(percentNumberText).html(0);
2323                $(progressValueMobile).css({'width':'0px'});
2324                $(window).scroll(function(e){
2325                    if($(window).scrollTop() > lastWindowScrollTop) {
2326                        scrollDirection = 'down';
2327                    }else {
2328                        scrollDirection = 'up';
2329                    }
2330                    elemnt_scroll  = $('.element-scroll-percent');
2331                    
2332                    if(elemnt_scroll.hasClass('post-content-100-percent')) {
2333                        var theContentPercent = elemnt_scroll.find('.single-content__wrap');
2334                        theContentPercent.each( function() {
2335                            var theJourney = $(window).scrollTop() - $(this).offset().top;
2336                            if((theJourney > 0) && (theJourney <= $(this).height())) {
2337                                ofsetTop_element_scroll = $(this).offset().top;
2338                                ofsetBottom_element_scroll = ofsetTop_element_scroll + $(this).height();
2339                                docHeight = $(this).height();
2340                                dataPostID = $(this).closest('.single-infinity-inner').data('postid');
2341                                
2342                                $('.atbs-scroll-single-percent-wrap').data('postid', dataPostID);
2343                                if($(this).closest('.single-infinity-inner').hasClass('ceris-already-bookmarked')) {
2344                                    $('.scroll-count-percent-with-bookmark').find('.btn-bookmark-icon').addClass('is-saved');
2345                                }else {
2346                                    $('.scroll-count-percent-with-bookmark').find('.btn-bookmark-icon').removeClass('is-saved');
2347                                }
2348                            }
2349                        });
2350                    }else {
2351                        elemnt_scroll.each( function() {
2352                            var theJourney = $(window).scrollTop() - $(this).offset().top;
2353                            if((theJourney > 0) && (theJourney <= $(this).height())) {
2354                                ofsetTop_element_scroll = $(this).offset().top;
2355                                ofsetBottom_element_scroll = ofsetTop_element_scroll + $(this).height();
2356                                docHeight = $(this).height();
2357                                dataPostID = $(this).closest('.single-infinity-inner').data('postid');
2358                                
2359                                $('.atbs-scroll-single-percent-wrap').data('postid', dataPostID);
2360                                if($(this).closest('.single-infinity-inner').hasClass('ceris-already-bookmarked')) {
2361                                    $('.scroll-count-percent-with-bookmark').find('.btn-bookmark-icon').addClass('is-saved');
2362                                }else {
2363                                    $('.scroll-count-percent-with-bookmark').find('.btn-bookmark-icon').removeClass('is-saved');
2364                                }
2365                            }
2366                        });
2367                    }
2368                    
2369                    if(docHeight == 0) {
2370                        return false;
2371                    }
2372                    
2373                    if (($(window).scrollTop() >= ofsetTop_element_scroll) ){
2374                        $('.scroll-count-percent').addClass('active');
2375                    }
2376                    else{
2377                        $('.scroll-count-percent').removeClass('active');
2378                    }
2379                    var windowScrollTop = $(window).scrollTop();
2380                    var scrollPercent = (windowScrollTop - ofsetTop_element_scroll) / (docHeight);
2381                    var scrollPercentRounded = Math.round(scrollPercent*100);
2382                    if(scrollPercentRounded <= 0){
2383                        scrollPercentRounded = 0;
2384                    }else if(scrollPercentRounded >= 100) {
2385                        scrollPercentRounded = 100;
2386                        $('.scroll-count-percent').removeClass('active');
2387                    }
2388                    
2389                    progress(scrollPercentRounded);
2390                    $(percentNumberText).html(scrollPercentRounded);
2391                    $(progressValueMobile).css({'width': scrollPercentRounded + '%'});
2392                    lastWindowScrollTop = $(window).scrollTop();
2393                });
2394                $(window).resize(function () {
2395                    elemnt_scroll  = $('.element-scroll-percent');
2396                    if(elemnt_scroll.hasClass('post-content-100-percent')) {
2397                        var theContentPercent = elemnt_scroll.find('.single-context');
2398                        theContentPercent.each( function() {
2399                            var theJourney = $(window).scrollTop() - $(this).offset().top;
2400                            if((theJourney > 0) && (theJourney <= $(this).height())) {
2401                                ofsetTop_element_scroll = $(this).offset().top;
2402                                ofsetBottom_element_scroll = ofsetTop_element_scroll + $(this).height();
2403                                docHeight = $(this).height();
2404                                return false;
2405                            }
2406                        });
2407                    }else {
2408                        elemnt_scroll.each( function() {
2409                            var theJourney = $(window).scrollTop() - $(this).offset().top;
2410                            if((theJourney > 0) && (theJourney <= $(this).height())) {
2411                                ofsetTop_element_scroll = $(this).offset().top;
2412                                ofsetBottom_element_scroll = ofsetTop_element_scroll + $(this).height();
2413                                docHeight = $(this).height();
2414                                return false;
2415                            }
2416                        });
2417
2418                    }
2419                    
2420                    var windowScrollTop = $(window).scrollTop();
2421                    var winHeight = $(window).height();
2422                    var scrollPercent = (windowScrollTop - ofsetTop_element_scroll) / (docHeight);
2423                    var scrollPercentRounded = Math.round(scrollPercent*100);
2424                    
2425                    if(scrollPercentRounded <= 0){
2426                        scrollPercentRounded = 0;
2427                    }else if(scrollPercentRounded > 100) {
2428                        scrollPercentRounded = 100;
2429                        $('.scroll-count-percent').removeClass('active');
2430                    }
2431                    progress(scrollPercentRounded);
2432                    $(percentNumberText).html(scrollPercentRounded);
2433                    $(progressValueMobile).css({'width': scrollPercentRounded + '%'});
2434                });
2435            }
2436            function progress(value) {
2437                var progress = value / 100;
2438                var dashoffset = CIRCUMFERENCE * (1 - progress);
2439                $(progressValue).css({'stroke-dashoffset': dashoffset });
2440            }
2441        },
2442        /* ============================================================================
2443         * ceris Search Button
2444         * ==========================================================================*/
2445        ceris_search_button: function() {
2446            
2447                $('.js-search-popup').on('click',function(){
2448                    $('.atbs-ceris-search-full').toggleClass('On');
2449                }); 
2450                $('#atbs-ceris-search-remove').on('click',function(){
2451                    $('.atbs-ceris-search-full').removeClass('On');
2452                    $('.atbs-ceris-search-full').removeClass("active");
2453                    $('.search-form__input').val('');
2454                });
2455                if( $(window).resize() || $(window).load() ){
2456                    $(window).height();
2457                    var input_search_frame = $('.atbs-ceris-search-full--form form').height() + parseInt($('.atbs-ceris-search-full--form form').css('margin-bottom'));
2458                    var max_height_search = $(window).height() - parseInt($('.atbs-ceris-search-full').css('padding-bottom')) - parseInt($('.atbs-ceris-search-full').css('padding-top')) - input_search_frame;
2459            
2460                    $('.result-default').css('max-height', max_height_search );
2461                    $('.atbs-ceris-search-full--result').css('max-height', max_height_search +  input_search_frame );
2462                }
2463        
2464        },
2465        /* ============================================================================
2466         * AJAX load more posts
2467         * ==========================================================================*/
2468        ajaxLoadPost: function() {
2469            var loadedPosts = '';
2470            var $ajaxLoadPost = $('.js-ajax-load-post');
2471            var $this;
2472
2473            function ajaxLoad(parameters, $postContainer) {
2474                var cerisAjaxSecurity = ajax_buff['ceris_security']['ceris_security_code']['content'];
2475                //console.log(cerisAjaxSecurity);
2476                var ajaxStatus = '',
2477                    ajaxCall = $.ajax({
2478                        url: ajaxurl,
2479                        type: 'post',
2480                        dataType: 'html',
2481                        data: {
2482                            action: parameters.action,
2483                            args: parameters.args,
2484                            postOffset: parameters.postOffset,
2485                            type: parameters.type,
2486                            moduleInfo: parameters.moduleInfo,
2487                            securityCheck: cerisAjaxSecurity                            
2488                            // other parameters
2489                        },
2490                    });
2491                //console.log(parameters.action);
2492                ajaxCall.done(function(respond) {
2493                    loadedPosts = $.parseJSON(respond);
2494                    ajaxStatus = 'success';
2495                    if(loadedPosts == 'no-result') {
2496                        $postContainer.closest('.js-ajax-load-post').addClass('disable-click');
2497                        $postContainer.closest('.js-ajax-load-post').find('.js-ajax-load-post-trigger').addClass('hidden');
2498                        $postContainer.closest('.js-ajax-load-post').find('.ceris-no-more-button').removeClass('hidden');
2499                        return;
2500                    }
2501                    if (loadedPosts) {
2502                        var elToLoad = $(loadedPosts).css('opacity',0).animate({'opacity': 1}, 400);
2503                        $postContainer.append(elToLoad);
2504                        ATBS.ATBS_Bookmark.reAddBookmark($postContainer);                        
2505                    }
2506                    $('html, body').animate({ scrollTop: $window.scrollTop() + 1 }, 0).animate({ scrollTop: $window.scrollTop() - 1 }, 0);
2506 // for recalculating of sticky sidebar
2507                    // do stuff like changing parameters
2508                });
2509
2510                ajaxCall.fail(function() {
2511                    ajaxStatus = 'failed';
2512                });
2513
2514                ajaxCall.always(function() {
2515                    $postContainer.closest('.js-ajax-load-post').removeClass('ceris_loading');
2516                    $postContainer.closest('.js-ajax-load-post').removeClass('disable-click');
2517                });
2518            }
2519
2520            $ajaxLoadPost.each(function() {
2521                $this = $(this);
2522                var $moduleID = $this.closest('.atbs-ceris-block').attr('id');
2523                var moduleName = $moduleID.split("-")[0];
2524                var $triggerBtn = $this.find('.js-ajax-load-post-trigger');
2525                var args = ajax_buff['query'][$moduleID]['args'];
2526                
2527                var $postContainer = $this.find('.posts-list');
2528                var moduleInfo = ajax_buff['query'][$moduleID]['moduleInfo'];
2529
2530                if(moduleInfo.hasOwnProperty('bookmarkTmp')) {
2531                    var bookmarkTmp = moduleInfo.bookmarkTmp;
2532                    if(bookmarkTmp.length == 0) {
2533                        moduleInfo.bookmarkTmp.push("bookmarkTmpEmpty");
2534                    }
2535                }
2536                                                
2537                $triggerBtn.on('click', function() {
2538                    
2539                    $this = $(this).closest('.js-ajax-load-post');
2540 
2541                    if(($this.hasClass('disable-click')) || $this.hasClass('infinity-ajax-load-post')) 
2542                        return;
2543                    
2544                    $this.addClass('disable-click');
2545                    
2546                    $this.addClass('ceris_loading');
2547                    
2548                    var postOffset  = parseInt(args['offset']) + $this.find('article').length;    
2549                    
2550                    if($this.closest('.atbs-ceris-block').hasClass('ceris_latest_blog_posts')) {
2551                        var stickPostLength = args['post__not_in'].length;
2552                        postOffset = postOffset - stickPostLength;
2553                    }
2554
2555                    var parameters = {
2556                        action: moduleName,
2557                        args: args,
2558                        postOffset: postOffset,
2559                        type: 'loadmore',
2560                        moduleInfo: moduleInfo,
2561                    };
2562                    ajaxLoad(parameters, $postContainer);
2563                });
2564            });
2565        },
2566        
2567        carousel_1i_fade_dot_number_effect: function() {
2568            var $carousels = $('.js-atbs-ceris-carousel-1i-fade-dot-number-effect');
2569            $carousels.each( function() {
2570                $(this).owlCarousel({
2571                    items: 1,
2572                    margin: 0,
2573                    nav: false,
2574                    loop: true,
2575                    dots: true,
2576                    lazyLoad: true,
2577                    // autoHeight: true,
2578                    smartSpeed: 450,
2579                    animateIn: 'fadeIn',
2580                    // animateOut: 'fadeOut',
2581                    onInitialized  : owl_onInitialized,
2582                    onTranslate : owl_onInitialized,
2583                    navText: ['<svg xmlns="http://www.w3.org/2000/svg" width="25" height="17" fill="#fff" viewBox="0 0 32 17"><path id="slider-prev" data-name="Slider Prev" class="slider_arrow_path" d="M8.158,0.007L8.835,0.685,1.5,8.019H32V8.979H1.5l7.338,7.334-0.677.679L0,8.839V8.16Z"></path></svg>', '<svg xmlns="http://www.w3.org/2000/svg" width="25" height="17"  fill="#fff" viewBox="0 0 32 17"><path id="slider-next" data-name="Slider Next" class="slider_arrow_path" d="M23.842,0.007l-0.677.678L30.5,8.019H0V8.979H30.5l-7.338,7.334,0.677,0.679L32,8.839V8.16Z"></path></svg>'],
2584                    responsive: {
2585                        0 : {
2586                            items: 1,
2587                            margin: 30,
2588                        },
2589
2590                        768 : {
2591                            items: 1,
2592                        },
2593                    },
2594                });
2595                $(this).on('translate.owl.carousel', function(event) {
2596                    var element   = event.target;
2597                    var thebackgroundIMG = '';
2598                    var currentImgSrcData = '';
2599                    
2600                    var checkActiveItemLoaded = setInterval(function() {
2601                        if(!$(element).find('.owl-item.active').hasClass('owl-item-active-loaded')) {
2602                            $(element).find('.owl-item').removeClass('owl-item-active-loaded');
2603                            $(element).find('.owl-item.active').addClass('owl-item-active-loaded');
2604                            thebackgroundIMG = $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img');
2605                            currentImgSrcData = $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src');
2606                            thebackgroundIMG.each(function () {
2607                                if($(this).hasClass('active')) {
2608                                    $(this).removeClass('active');
2609                                }else {
2610                                    $(this).removeAttr('src').attr('src', currentImgSrcData);
2611                                    $(this).addClass('active');
2612                                }
2613                            });
2614                            $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').closest('a').attr('href', $(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
2615                            $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('src', $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src'));
2616                            clearInterval(checkActiveItemLoaded);
2617                        }
2618                                                
2619                    }, 10); // check every 10ms
2620                });
2621                function owl_onInitialized(event) {
2622                    var element         = event.target;
2623                    var itemCount       = event.item.count;
2624                    var itenIndex       = event.item.index;
2625                    var owlstageChildrens = $(element).find('.owl-stage').children().length;
2626    
2627                    var theCloned       = owlstageChildrens - itemCount;
2628                    var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
2629                    if(itenIndex < parseInt(theCloned / 2)) {
2630                        currentIndex = owlstageChildrens - theCloned;
2631                    }else if(currentIndex > itemCount) {
2632                        currentIndex = currentIndex - itemCount;
2633                    }
2634    
2635                    $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
2636                    //console.log($(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
2637                    $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').closest('a').attr('href', $(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
2638                    $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('src', $(this).find('.owl-item.active').find('.post__thumb > a > img').attr('src'));
2639                     
2640                    $(element).find('.owl-item.active').addClass('owl-item-active-loaded');
2641                };
2642            });
2643        },
2644
2645        carousel_1i30m_thumb_round: function() {
2646            var $carousels = $('.js-atbs-ceris-carousel-1i30m-thumb-round');
2647            $carousels.each( function() {
2648                var carousel_loop = $(this).data('carousel-loop');
2649                $(this).owlCarousel({
2650                    items: 1,
2651                    loop: true,
2652                    animateOut: 'fadeOut',
2653                    margin: 30,
2654                    nav: true,
2655                    dots: true,
2656                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
2657                    smartSpeed: 300,
2658                });
2659            })
2660        },
2661
2662        /* ============================================================================
2663         * Carousel funtions
2664         * ==========================================================================*/
2665         carousel_1i30m_effect: function() {
2666            var $carousels = $('.js-carousel-1i30m-effect');
2667            $carousels.each( function() {
2668                $(this).owlCarousel({
2669                    items: 1,
2670                    margin: 30,
2671                    loop: true,
2672                    nav: true,
2673                    dots: true,
2674                    autoHeight: true,
2675                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
2676                    smartSpeed: 500,
2677                    responsive: {   
2678                        567 : {
2679                            margin: 0,
2680                        },
2681                    },
2682                });
2683            })
2684        },
2685        carousel_1i_dot_number: function() {
2686            var $carousels = $('.js-atbs-ceris-carousel-1i-dot-number');
2687            $carousels.each( function() {
2688                $(this).owlCarousel({
2689                    items: 1,
2690                    margin: 0,
2691                    nav: false,
2692                    loop: true,
2693                    dots: true,
2694                    lazyLoad: true,
2695                    autoHeight: true,
2696                    onInitialized  : counter,
2697                    onTranslated : counter,
2698                    navText: ['<svg xmlns="http://www.w3.org/2000/svg" width="25" height="17" fill="#fff" viewBox="0 0 32 17"><path id="slider-prev" data-name="Slider Prev" class="slider_arrow_path" d="M8.158,0.007L8.835,0.685,1.5,8.019H32V8.979H1.5l7.338,7.334-0.677.679L0,8.839V8.16Z"></path></svg>', '<svg xmlns="http://www.w3.org/2000/svg" width="25" height="17"  fill="#fff" viewBox="0 0 32 17"><path id="slider-next" data-name="Slider Next" class="slider_arrow_path" d="M23.842,0.007l-0.677.678L30.5,8.019H0V8.979H30.5l-7.338,7.334,0.677,0.679L32,8.839V8.16Z"></path></svg>'],
2699                    smartSpeed: 500,
2700                    responsive: {
2701                        0 : {
2702                            items: 1,
2703                        },
2704
2705                        768 : {
2706                            items: 1,
2707                        },
2708                    },
2709                });
2710            })
2711            function counter(event) {
2712                var element         = event.target;
2713                var itemCount       = event.item.count;
2714                var itenIndex       = event.item.index;
2715                var owlstageChildrens = $(element).find('.owl-stage').children().length;
2716
2717                var theCloned       = owlstageChildrens - itemCount;
2718                var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
2719                if(itenIndex < parseInt(theCloned / 2)) {
2720                    currentIndex = owlstageChildrens - theCloned;
2721                }else if(currentIndex > itemCount) {
2722                    currentIndex = currentIndex - itemCount;
2723                }
2724
2725                $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
2726            }
2727        },
2728        
2729        carousel_1i_loopdot: function() {
2730            var $carousels = $('.js-atbs-ceris-carousel-1i-loopdot');
2731            $carousels.each( function() {
2732                $(this).owlCarousel({
2733                    items: 1,
2734                    margin: 0,
2735                    loop: true,
2736                    nav: true,
2737                    dots: true,
2738                    autoHeight: true,
2739                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
2740                    smartSpeed: 500,
2741                    responsive: {
2742                        0 : {
2743                            items: 1,
2744                        },
2745
2746                        576 : {
2747                            items: 2,
2748                            margin: 30,
2749                        },
2750
2751                        992 : {
2752                            items: 1,
2753                        },
2754                    },
2755                });
2756            })
2757        },
2758        carousel_1i_dot_number_get_background: function() {
2759            var $carousels = $('.js-atbs-ceris-carousel-1i-dot-number-get-background');
2760            $carousels.each( function() {
2761                $(this).owlCarousel({
2762                    items: 1,
2763                    margin: 0,
2764                    nav: false,
2765                    loop: true,
2766                    dots: true,
2767                    lazyLoad: true,
2768                    autoHeight: true,
2769                    smartSpeed:450,
2770                    //animateOut: 'fadeOut',
2771                    onInitialized  : owl_onInitialized,
2772                    onTranslate : counter,
2773                    navText: ['<svg xmlns="http://www.w3.org/2000/svg" width="25" height="17" fill="#fff" viewBox="0 0 32 17"><path id="slider-prev" data-name="Slider Prev" class="slider_arrow_path" d="M8.158,0.007L8.835,0.685,1.5,8.019H32V8.979H1.5l7.338,7.334-0.677.679L0,8.839V8.16Z"></path></svg>', '<svg xmlns="http://www.w3.org/2000/svg" width="25" height="17"  fill="#fff" viewBox="0 0 32 17"><path id="slider-next" data-name="Slider Next" class="slider_arrow_path" d="M23.842,0.007l-0.677.678L30.5,8.019H0V8.979H30.5l-7.338,7.334,0.677,0.679L32,8.839V8.16Z"></path></svg>'],
2774                    responsive: {
2775                        0 : {
2776                            items: 1,
2777                            margin: 30,
2778                        },
2779
2780                        768 : {
2781                            items: 1,
2782                        },
2783                    },
2784                });
2785                $(this).on('translate.owl.carousel', function(event) {
2786                    var element   = event.target;
2787                    var thebackgroundIMG = '';
2788                    var currentImgSrcData = '';
2789                    
2790                    var checkActiveItemLoaded = setInterval(function() {
2791                        if(!$(element).find('.owl-item.active').hasClass('owl-item-active-loaded')) {
2792                            $(element).find('.owl-item').removeClass('owl-item-active-loaded');
2793                            $(element).find('.owl-item.active').addClass('owl-item-active-loaded');
2794                            thebackgroundIMG = $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img');
2795                            currentImgSrcData = $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src');
2796                            thebackgroundIMG.each(function () {
2797                                if($(this).hasClass('active')) {
2798                                    $(this).removeClass('active');
2799                                }else {
2800                                    $(this).removeAttr('src').attr('src', currentImgSrcData);
2801                                    $(this).addClass('active');
2802                                }
2803                            });
2804                            $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').closest('a').attr('href', $(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
2805                            $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('src', $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src'));
2806                            clearInterval(checkActiveItemLoaded);
2807                        }
2808                                                
2809                    }, 10); // check every 10ms
2810                });
2811                function owl_onInitialized(event) {
2812                    var element         = event.target;
2813                    var itemCount       = event.item.count;
2814                    var itenIndex       = event.item.index;
2815                    var owlstageChildrens = $(element).find('.owl-stage').children().length;
2816    
2817                    var theCloned       = owlstageChildrens - itemCount;
2818                    var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
2819                    if(itenIndex < parseInt(theCloned / 2)) {
2820                        currentIndex = owlstageChildrens - theCloned;
2821                    }else if(currentIndex > itemCount) {
2822                        currentIndex = currentIndex - itemCount;
2823                    }
2824    
2825                    $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
2826                    
2827                    $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').closest('a').attr('href', $(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
2828                    $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('src', $(this).find('.owl-item.active').find('.post__thumb > a > img').attr('src'));
2829                     
2830                    $(element).find('.owl-item.active').addClass('owl-item-active-loaded');
2831                };
2832                function counter(event) {
2833                    var element         = event.target;
2834                    var itemCount       = event.item.count;
2835                    var itenIndex       = event.item.index;
2836                    var owlstageChildrens = $(element).find('.owl-stage').children().length;
2837    
2838                    var theCloned       = owlstageChildrens - itemCount;
2839                    var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
2840                    if(itenIndex < parseInt(theCloned / 2)) {
2841                        currentIndex = owlstageChildrens - theCloned;
2842                    }else if(currentIndex > itemCount) {
2843                        currentIndex = currentIndex - itemCount;
2844                    }
2845    
2846                    $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
2847                }
2848            });
2849        },
2850
2851        carousel_1i_dot_number_get_background_style_2: function() {
2852            var $carousels = $('.js-atbs-ceris-carousel-1i-dot-number-get-background-style-2');
2853            $carousels.each( function() {
2854                $(this).owlCarousel({
2855                    items: 1,
2856                    margin: 0,
2857                    nav: true,
2858                    loop: true,
2859                    dots: true,
2860                    lazyLoad: true,
2861                    autoHeight: true,
2862                    smartSpeed:450,
2863                    //animateOut: 'fadeOut',
2864                    onInitialized  : owl_onInitialized,
2865                    onTranslate : counter,
2866                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
2867                    responsive: {
2868                        0 : {
2869                            items: 1,
2870                            margin: 30,
2871                        },
2872
2873                        768 : {
2874                            items: 1,
2875                        },
2876                    },
2877                });
2878                $(this).on('translate.owl.carousel', function(event) {
2879                    var element   = event.target;
2880                    var thebackgroundIMG = '';
2881                    var currentImgSrcData = '';
2882
2883                    var checkActiveItemLoaded = setInterval(function() {
2884                        if(!$(element).find('.owl-item.active').hasClass('owl-item-active-loaded')) {
2885                            $(element).find('.owl-item').removeClass('owl-item-active-loaded');
2886                            $(element).find('.owl-item.active').addClass('owl-item-active-loaded');
2887                            thebackgroundIMG = $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img');
2888                            currentImgSrcData = $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src');
2889                            thebackgroundIMG.each(function () {
2890                                if($(this).hasClass('active')) {
2891                                    $(this).removeClass('active');
2892                                }else {
2893                                    $(this).removeAttr('src').attr('src', currentImgSrcData);
2894                                    $(this).addClass('active');
2895                                }
2896                            });
2897                            $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').closest('a').attr('href', $(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
2898                            $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('src', $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src'));
2899                            clearInterval(checkActiveItemLoaded);
2900                        }
2901
2902                    }, 10); // check every 10ms
2903                });
2904                function owl_onInitialized(event) {
2905                    var element         = event.target;
2906                    var itemCount       = event.item.count;
2907                    var itenIndex       = event.item.index;
2908                    var owlstageChildrens = $(element).find('.owl-stage').children().length;
2909
2910                    var theCloned       = owlstageChildrens - itemCount;
2911                    var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
2912                    if(itenIndex < parseInt(theCloned / 2)) {
2913                        currentIndex = owlstageChildrens - theCloned;
2914                    }else if(currentIndex > itemCount) {
2915                        currentIndex = currentIndex - itemCount;
2916                    }
2917
2918                    $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
2919
2920                    $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').closest('a').attr('href', $(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
2921                    $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('src', $(this).find('.owl-item.active').find('.post__thumb > a > img').attr('src'));
2922
2923                    $(element).find('.owl-item.active').addClass('owl-item-active-loaded');
2924                };
2925                function counter(event) {
2926                    var element         = event.target;
2927                    var itemCount       = event.item.count;
2928                    var itenIndex       = event.item.index;
2929                    var owlstageChildrens = $(element).find('.owl-stage').children().length;
2930
2931                    var theCloned       = owlstageChildrens - itemCount;
2932                    var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
2933                    if(itenIndex < parseInt(theCloned / 2)) {
2934                        currentIndex = owlstageChildrens - theCloned;
2935                    }else if(currentIndex > itemCount) {
2936                        currentIndex = currentIndex - itemCount;
2937                    }
2938
2939                    $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
2940                }
2941            });
2942        },
2943        
2944        carousel_1i_dot_number_effect: function() {
2945            var $carousels = $('.js-atbs-ceris-carousel-1i-dot-number-effect');
2946            $carousels.each( function() {
2947                $(this).owlCarousel({
2948                    items: 1,
2949                    margin: 0,
2950                    nav: false,
2951                    loop: true,
2952                    dots: true,
2953                    lazyLoad: true,
2954                    autoHeight: true,
2955                    smartSpeed:450,
2956                    //animateOut: 'fadeOut',
2957                    onInitialized  : owl_onInitialized,
2958                    onTranslate : owl_onInitialized,
2959                    navText: ['<svg xmlns="http://www.w3.org/2000/svg" width="25" height="17" fill="#fff" viewBox="0 0 32 17"><path id="slider-prev" data-name="Slider Prev" class="slider_arrow_path" d="M8.158,0.007L8.835,0.685,1.5,8.019H32V8.979H1.5l7.338,7.334-0.677.679L0,8.839V8.16Z"></path></svg>', '<svg xmlns="http://www.w3.org/2000/svg" width="25" height="17"  fill="#fff" viewBox="0 0 32 17"><path id="slider-next" data-name="Slider Next" class="slider_arrow_path" d="M23.842,0.007l-0.677.678L30.5,8.019H0V8.979H30.5l-7.338,7.334,0.677,0.679L32,8.839V8.16Z"></path></svg>'],
2960                    responsive: {
2961                        0 : {
2962                            items: 1,
2963                            margin: 30,
2964                        },
2965
2966                        768 : {
2967                            items: 1,
2968                        },
2969                    },
2970                });
2971                $(this).on('translate.owl.carousel', function(event) {
2972                    var element   = event.target;
2973                    var thebackgroundIMG = '';
2974                    var currentImgSrcData = '';
2975                    
2976                    var checkActiveItemLoaded = setInterval(function() {
2977                        if(!$(element).find('.owl-item.active').hasClass('owl-item-active-loaded')) {
2978                            $(element).find('.owl-item').removeClass('owl-item-active-loaded');
2979                            $(element).find('.owl-item.active').addClass('owl-item-active-loaded');
2980                            thebackgroundIMG = $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img');
2981                            currentImgSrcData = $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src');
2982                            thebackgroundIMG.each(function () {
2983                                if($(this).hasClass('active')) {
2984                                    $(this).removeClass('active');
2985                                }else {
2986                                    $(this).removeAttr('src').attr('src', currentImgSrcData);
2987                                    $(this).addClass('active');
2988                                }
2989                            });
2990                            $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').closest('a').attr('href', $(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
2991                            $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('src', $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src'));
2992                            clearInterval(checkActiveItemLoaded);
2993                        }
2994                                                
2995                    }, 10); // check every 10ms
2996                });
2997                function owl_onInitialized(event) {
2998                    var element         = event.target;
2999                    var itemCount       = event.item.count;
3000                    var itenIndex       = event.item.index;
3001                    var owlstageChildrens = $(element).find('.owl-stage').children().length;
3002    
3003                    var theCloned       = owlstageChildrens - itemCount;
3004                    var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
3005                    if(itenIndex < parseInt(theCloned / 2)) {
3006                        curren
3006tIndex = owlstageChildrens - theCloned;
3007                    }else if(currentIndex > itemCount) {
3008                        currentIndex = currentIndex - itemCount;
3009                    }
3010    
3011                    $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
3012                    //console.log($(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
3013                    $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').closest('a').attr('href', $(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));
3014                    $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('src', $(this).find('.owl-item.active').find('.post__thumb > a > img').attr('src'));
3015                     
3016                    $(element).find('.owl-item.active').addClass('owl-item-active-loaded');
3017                };
3018            });
3019        },
3020        carousel_2i0m_number_effect: function() {
3021            var $carousels = $('.js-carousel-2i0m-number-effect');
3022            $carousels.each( function() {
3023                $(this).owlCarousel({
3024                    items: 2,
3025                    margin: 0,
3026                    nav: true,
3027                    dots: true,
3028                    loop: true,
3029                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3030                    smartSpeed: 700,
3031                    onInitialized  : counter,
3032                    onTranslate : counter,
3033                    onTranslated: showAnimation,
3034                    onDrag: removeAnimation,
3035                    responsive: {
3036                        0 : {
3037                            items: 1,
3038                            margin: 0,
3039                        },
3040
3041                        992 : {
3042                            items: 2,
3043                            margin: 0,
3044                        },
3045                    },
3046                });
3047            });
3048            function counter(event) {
3049                var element         = event.target;
3050                var itemCount       = event.item.count;
3051                var itenIndex       = event.item.index;
3052                var owlstageChildrens = $(element).find('.owl-stage').children().length;
3053
3054                var theCloned       = owlstageChildrens - itemCount;
3055                var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
3056                if(itenIndex < parseInt(theCloned / 2)) {
3057                    currentIndex = owlstageChildrens - theCloned;
3058                }else if(currentIndex > itemCount) {
3059                    currentIndex = currentIndex - itemCount;
3060                }
3061
3062                $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
3063            }
3064            function removeAnimation(event) {
3065                // var $this = event.target;
3066                // var item = $($this).find('.owl-item');
3067                // $(item).find('.post__text').removeClass("fadeInText");
3068                // $(item).find('.post__text').addClass("opacity-default");
3069            }
3070            function showAnimation(event) {
3071                // var $this = event.target;
3072                // var item = $($this).find('.active');
3073                // $(item).find('.post__text').addClass("fadeInText");
3074                // $(item).find('.post__text').removeClass("opacity-default");
3075                // $(item).find('.post__thumb').removeClass("FadeOutThumb");
3076            }
3077        },
3078        carousel_2i50m_number_effect: function() {
3079            var $carousels = $('.js-carousel-2i50m-number-effect');
3080            $carousels.each( function() {
3081                $(this).owlCarousel({
3082                    items: 1,
3083                    margin: 0,
3084                    nav: true,
3085                    dots: true,
3086                    autoHeight: true,
3087                    loop: true,
3088                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3089                    smartSpeed: 700,
3090                    onInitialized  : counter,
3091                    onTranslate : counter,
3092                    onTranslated: showAnimation,
3093                    onDrag: removeAnimation,
3094                    responsive: {
3095                        0 : {
3096                            items: 1,
3097                            margin: 20,
3098                        },
3099
3100                        991 : {
3101                            items: 1,
3102                            margin: 30,
3103                        },
3104
3105                        992 : {
3106                            items: 2,
3107                            margin: 30,
3108                        },
3109
3110
3111                        1200 : {
3112                            items: 2,
3113                            margin: 50,
3114                        },
3115                    },
3116                });
3117            });
3118            function counter(event) {
3119                var element         = event.target;
3120                var itemCount       = event.item.count;
3121                var itenIndex       = event.item.index;
3122                var owlstageChildrens = $(element).find('.owl-stage').children().length;
3123
3124                var theCloned       = owlstageChildrens - itemCount;
3125                var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
3126                if(itenIndex < parseInt(theCloned / 2)) {
3127                    currentIndex = owlstageChildrens - theCloned;
3128                }else if(currentIndex > itemCount) {
3129                    currentIndex = currentIndex - itemCount;
3130                }
3131
3132                $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
3133            }
3134            function removeAnimation(event) {
3135                // var $this = event.target;
3136                // var item = $($this).find('.owl-item');
3137                // $(item).find('.post__text').removeClass("fadeInText");
3138                // $(item).find('.post__text').addClass("opacity-default");
3139            }
3140            function showAnimation(event) {
3141                // var $this = event.target;
3142                // var item = $($this).find('.active');
3143                // $(item).find('.post__text').addClass("fadeInText");
3144                // $(item).find('.post__text').removeClass("opacity-default");
3145                // $(item).find('.post__thumb').removeClass("FadeOutThumb");
3146            }
3147        },
3148        
3149        carousel_2i30m_number_effect: function() {
3150            var $carousels = $('.js-carousel-2i30m-number-effect');
3151            $carousels.each( function() {
3152                $(this).owlCarousel({
3153                    items: 1,
3154                    margin: 0,
3155                    nav: true,
3156                    dots: true,
3157                    autoHeight: true,
3158                    loop: true,
3159                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3160                    smartSpeed: 700,
3161                    onInitialized  : counter,
3162                    onTranslate : counter,
3163                    onTranslated: showAnimation,
3164                    onDrag: removeAnimation,
3165                    responsive: {
3166                        0 : {
3167                            items: 1,
3168                            margin: 20,
3169                        },
3170
3171                        480 : {
3172                            items: 1,
3173                            margin: 20,
3174                        },
3175
3176                        481 : {
3177                            items: 2,
3178                            margin: 20,
3179                        },
3180
3181                        577 : {
3182                            items: 3,
3183                            margin: 30,
3184                        },
3185
3186                        991 : {
3187                            items: 3,
3188                            margin: 30,
3189                        },
3190
3191                        992 : {
3192                            items: 2,
3193                            margin: 30,
3194                        },
3195                    },
3196                });
3197            });
3198            function counter(event) {
3199                var element         = event.target;
3200                var itemCount       = event.item.count;
3201                var itenIndex       = event.item.index;
3202                var owlstageChildrens = $(element).find('.owl-stage').children().length;
3203
3204                var theCloned       = owlstageChildrens - itemCount;
3205                var currentIndex = itenIndex - parseInt(theCloned / 2) + 1;
3206                if(itenIndex < parseInt(theCloned / 2)) {
3207                    currentIndex = owlstageChildrens - theCloned;
3208                }else if(currentIndex > itemCount) {
3209                    currentIndex = currentIndex - itemCount;
3210                }
3211
3212                $(element).parent().find('.owl-number').html( currentIndex +' <span class="slide-seperated">/</span> ' + itemCount);
3213            }
3214            function removeAnimation(event) {
3215                // var $this = event.target;
3216                // var item = $($this).find('.owl-item');
3217                // $(item).find('.post__text').removeClass("fadeInText");
3218                // $(item).find('.post__text').addClass("opacity-default");
3219            }
3220            function showAnimation(event) {
3221                // var $this = event.target;
3222                // var item = $($this).find('.active');
3223                // $(item).find('.post__text').addClass("fadeInText");
3224                // $(item).find('.post__text').removeClass("opacity-default");
3225                // $(item).find('.post__thumb').removeClass("FadeOutThumb");
3226            }
3227        },
3228        carousel_1i: function() {
3229            var $carousels = $('.js-atbs-ceris-carousel-1i');
3230            $carousels.each( function() {
3231                var carousel_loop = $(this).data('carousel-loop');
3232                $(this).owlCarousel({
3233                    items: 1,
3234                    loop: true,
3235                    margin: 0,
3236                    nav: true,
3237                    dots: true,
3238                    autoHeight: true,
3239                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3240                    smartSpeed: 500,
3241                });
3242            })
3243        },
3244        /* ============================================================================
3245         * Carousel carousel_only_1i_loopdot
3246         * ==========================================================================*/
3247        carousel_only_1i_loopdot: function() {
3248            var $carousels = $('.js-atbs-ceris-carousel-only-1i-loopdot');
3249            $carousels.each( function() {
3250                $(this).owlCarousel({
3251                    items: 1,
3252                    margin: 0,
3253                    loop: true,
3254                    nav: true,
3255                    dots: true,
3256                    autoHeight: true,
3257                    navText: ['<i class="mdicon mdicon-chevron-thin-left"></i>', '<i class="mdicon mdicon-chevron-thin-right"></i>'],
3258                    smartSpeed: 500,
3259                    responsive: {
3260                        0 : {
3261                            items: 1,
3262                        },
3263
3264                    },
3265                });
3266            })
3267        },
3268        carousel_1i_get_background: function() {
3269            var $carousels = $('.js-atbs-ceris-carousel-1i-get-background');
3270            $carousels.each( function() {
3271                var $this = $(this);
3272                $(this).owlCarousel({
3273                    items: 1,
3274                    margin: 30,
3275                    nav: true,
3276                    loop: true,
3277                    dots: true,
3278                    lazyLoad: true,
3279                    //autoHeight: true,
3280                    smartSpeed:450,
3281                    //animateOut: 'fadeOut',
3282                    navText: ['<i class="mdicon mdicon-chevron-thin-left"></i>', '<i class="mdicon mdicon-chevron-thin-right"></i>'],
3283                    responsive: {
3284                        0 : {
3285                            items: 1,
3286                            margin: 30,
3287                        },
3288
3289                        768 : {
3290                            items: 1,
3291                        },
3292                    },
3293
3294                });
3295                $this.on('translate.owl.carousel', function(event) {
3296                    var element   = event.target;
3297                    var thebackgroundIMG = $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img');
3298                    var currentImgSrcData = $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src');
3299                    thebackgroundIMG.each(function () {
3300                        if($(this).hasClass('active')) {
3301                            $(this).removeClass('active');
3302                        }else {
3303                            $(this).find('img').removeAttr('src').attr('src', currentImgSrcData);
3304                            $(this).addClass('active');
3305                        }
3306                    });
3307
3308                    if ( !($(element).parents('.atbs-ceris-block__inner').children('.owl-background img').hasClass('active'))){
3309
3310                    }
3311                    var checkExist = setInterval(function() {
3312                        $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').find('img').attr('srcset', $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('srcset'));
3313                        //$(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('href', $(element).find('.owl-item.active').find('h3 > a').attr('href'));
3314                        $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').attr('href', $(element).find('.owl-item.active').find('.post__thumb > a').attr('href'));                        
3315                        $(element).parents('.atbs-ceris-block__inner').find('.owl-background .owl-background-img.active').find('img').attr('src', $(element).find('.owl-item.active').find('.post__thumb > a > img').attr('src'));
3316
3317                        clearInterval(checkExist);
3318                    }, 100); // check every 100ms
3319                });
3320
3321                // SetButtonNavDot($(this));
3322                $(window).resize(function () {
3323                    SetButtonNavDot($this);
3324                });
3325                function SetButtonNavDot(event) {
3326                    // set x
3327                    var width_button = parseFloat(event.find('.owl-nav .owl-next').css('width'));
3328                    var width_dots = parseFloat(event.find('.owl-dots').css('width'));
3329                    var spacing_x_owl_dots = width_button + 25;
3330                    var spacing_owl_next =  width_button + 25 + width_dots + 25;
3331                    // set y
3332                    var height_button = parseFloat(event.find('.owl-nav .owl-next').css('height'));
3333                    var height_dots = parseFloat(event.find('.owl-dots').css('height'));
3334                    var spacing_y_owl_dots =parseFloat( height_button / 2 - height_dots / 2 ) ;
3335                    if(   window.matchMedia("(max-width: 768px)").matches ){
3336                        width_button = parseFloat(event.find('.owl-nav .owl-next').css('width'));
3337                        width_dots = parseFloat(event.find('.owl-dots').css('width'));
3338                        spacing_x_owl_dots = width_button + 15;
3339                        spacing_owl_next =  width_button + 15 + width_dots + 15;
3340
3341                        height_button = parseFloat(event.find('.owl-nav .owl-next').css('height'));
3342                        height_dots = parseFloat(event.find('.owl-dots').css('height'));
3343                        spacing_y_owl_dots =parseFloat( height_button / 2 - height_dots / 2 ) ;
3344                    }
3345                    event.find('.owl-dots').css({"left": spacing_x_owl_dots});
3346                    event.find('.owl-dots').css({"bottom": spacing_y_owl_dots});
3347                    event.find('.owl-nav .owl-next').css({"left": spacing_owl_next});
3348                }
3349            });
3350        },
3351        carousel_1i_not_nav: function() {
3352            var $carousels = $('.js-atbs-ceris-carousel-1i_not_nav');
3353            $carousels.each( function() {
3354                $(this).owlCarousel({
3355                    items: 1,
3356                    margin: 0,
3357                    nav: false,
3358                    dots: true,
3359                    loop: true,
3360                    autoHeight: true,
3361                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3362                    smartSpeed: 500,
3363                    responsive: {
3364                        0 : {
3365                            items: 1,
3366                        },
3367                        481 : {
3368                            items: 1,
3369                        },
3370
3371
3372                        992 : {
3373                            items: 1,
3374                        },
3375                    },
3376                });
3377            })
3378        },
3379
3380        carousel_1i_not_nav_2: function() {
3381            var $carousels = $('.js-atbs-ceris-carousel-1i_not_nav_2');
3382            $carousels.each( function() {
3383                $(this).owlCarousel({
3384                    items: 1,
3385                    margin: 0,
3386                    nav: false,
3387                    dots: true,
3388                    loop: true,
3389                    autoHeight: true,
3390                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3391                    smartSpeed: 500,
3392                    responsive: {
3393                        0 : {
3394                            items: 1,
3395                        },
3396                        481 : {
3397                            items: 1,
3398                        },
3399
3400
3401                        992 : {
3402                            items: 1,
3403                        },
3404                    },
3405                });
3406            })
3407        },
3408
3409        carousel_1i30m: function() {
3410            var $carousels = $('.js-carousel-1i30m');
3411            $carousels.each( function() {
3412                $(this).owlCarousel({
3413                    items: 1,
3414                    margin: 30,
3415                    loop: true,
3416                    nav: true,
3417                    dots: true,
3418                    autoHeight: true,
3419                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3420                    smartSpeed: 500,
3421                });
3422            })
3423        },
3424
3425        carousel_overlap: function() {
3426            var $carousels = $('.js-atbs-ceris-carousel-overlap');
3427            $carousels.each( function() {
3428                var $carousel = $(this);
3429                $carousel.flickity({
3430                    wrapAround: true,
3431                });
3432
3433                $carousel.on( 'staticClick.flickity', function( event, pointer, cellElement, cellIndex ) {
3434                    if ( (typeof cellIndex === 'number') && ($carousel.data('flickity').selectedIndex != cellIndex) ) {
3435                        $carousel.flickity( 'selectCell', cellIndex );
3436                    }
3437                });
3438            })
3439        },
3440        carousel_2i10m: function() {
3441            var $carousels = $('.js-carousel-2i10m');
3442            $carousels.each( function() {
3443                $(this).owlCarousel({
3444                    items: 2,
3445                    margin: 10,
3446                    loop: true,
3447                    nav: true,
3448                    dots: true,
3449                    autoplay: true,
3450                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3451                    responsive: {
3452                        0 : {
3453                            items: 1,
3454                            margin: 0,
3455                        },
3456                        769 : {
3457                            items: 2,
3458                        },
3459                    },
3460
3461
3462                });
3463            })
3464        },
3465        carousel_2i0m: function() {
3466            var $carousels = $('.js-carousel-2i0m');
3467            $carousels.each( function() {
3468                $(this).owlCarousel({
3469                    items: 2,
3470                    loop: true,
3471                    nav: true,
3472                    autoHeight:true,
3473                    dots: true,
3474                    smartSpeed: 600,
3475                    // animateOut: 'slideOutDown',
3476                    navText: ['<i class="mdicon mdicon-chevron-thin-left"></i>', '<i class="mdicon mdicon-chevron-thin-right"></i>'],
3477                    responsive: {
3478                        0 : {
3479                            items: 1,
3480                        },
3481                        992 : {
3482                            items: 2,
3483                        },
3484
3485                    },
3486                });
3487            })
3488        },
3489        carousel_2i4m: function() {
3490            var $carousels = $('.js-carousel-2i4m');
3491            $carousels.each( function() {
3492                var carousel_loop = $(this).data('carousel-loop');
3493                $(this).owlCarousel({
3494                    items: 2,
3495                    margin: 4,
3496                    loop: carousel_loop,
3497                    nav: true,
3498                    dots: true,
3499                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3500                    responsive: {
3501                        0 : {
3502                            items: 1,
3503                        },
3504
3505                        768 : {
3506                            items: 2,
3507                        },
3508                    },
3509                });
3510            })
3511        },
3512        carousel_2i30m5: function() {
3513            var $carousels = $('.js-carousel-2i30m5');
3514            $carousels.each( function() {
3515                $(this).owlCarousel({
3516                    items: 3,
3517                    margin: 20,
3518                    loop: true,
3519                    nav: true,
3520                    dots: true,
3521                    autoplay: false,
3522                    stagePadding: 100,
3523                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3524                    responsive: {
3525                        0 : {
3526                            items: 1,
3527                            margin: 15,
3528                            stagePadding: 0,
3529                        },
3530                        321:{
3531                            items: 1,
3532                            margin: 15,
3533                            stagePadding: 0,
3534                        },
3535                        381 : {
3536                            items: 1,
3537                            margin: 20,
3538                            stagePadding: 20,
3539                        },
3540                        421 : {
3541                            items: 1,
3542                            margin: 25,
3543                            stagePadding: 25,
3544                        },
3545                        481: {
3546                            items: 1,
3547                            margin: 30,
3548                            stagePadding: 50,
3549                        },
3550                        577: {
3551                            items: 1,
3552                            margin: 15,
3553                            stagePadding: 50,
3554                        },
3555                        681: {
3556                            items: 1,
3557                            margin: 30,
3558                            stagePadding: 100,
3559                        },
3560                        769 : {
3561                            items: 2,
3562                            stagePadding: 50,
3563                        },
3564                        992 : {
3565                            items: 2,
3566                            stagePadding: 100,
3567                        },
3568                        1600: {
3569                            items: 2,
3570                            margin: 30,
3571                            stagePadding: 200,
3572                        }
3573                    },
3574                });
3575            })
3576        },
3577        carousel_2i30m: function() {
3578            var $carousels = $('.js-carousel-2i30m');
3579            $carousels.each( function() {
3580                $(this).owlCarousel({
3581                    items: 2,
3582                    margin: 30,
3583                    smartSpeed: 910,
3584                    loop: true,
3585                    nav: true,
3586                    dots: true,
3587                    autoplay: false,
3588                    mouseDrag: false,
3589                    touchDrag: true,
3590                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3591                    responsive: {
3592                        0 : {
3593                            items: 1,
3594                            margin: 0,
3595                            touchDrag: true,   
3596                        },
3597                        381 :{
3598                            items: 1,
3599                            margin: 25,
3600                            stagePadding: 0,
3601                        },
3602                        481 : {
3603                            items: 1,
3604                            margin:  10,
3605                        },
3606                        769 : {
3607                            items: 2,
3608                            margin:  15,
3609                        },
3610                        992 : {
3611                            items: 2,
3612                            margin: 30,
3613                        }
3614                    },
3615
3616                });
3617                $(this).parent().find('.owl-background-item-left').css('background-image','url('+ $(this).find('.owl-item.active').first().prev().find('.post__thumb').attr('data-background') + ')');
3618                $(this).parent().find('.owl-background-item-front').css('background-image','url('+ $(this).find('.owl-item.active').first().find('.post__thumb').attr('data-background') + ')');
3619                $(this).parent().find('.owl-background-item-right').css('background-image','url('+ $(this).find('.owl-item.active').first().next().find('.post__thumb').attr('data-background') + ')');
3620                var img_front;
3621                var img_back;
3622                $(this).find('.owl-next').click(function() {
3623                    $(this).parents('.post-main').addClass('disable-owl-click');
3624                    $(this).parents('.post-main').find('.MoveLeftToRight').removeClass('MoveLeftToRight');
3625                    $(this).parents('.post-main').find('.owl-background-item-left').addClass('MoveRightToLeft owl-item-remove');
3626                    $(this).parent().parent().removeClass("StatusLeft");
3627                    $(this).parent().parent().addClass("StatusRight");
3628                    $(this).parents('.owl-carousel').removeClass("dragging");
3629                });
3630                $(this).find('.owl-prev').click(function() {
3631                    $(this).parents('.post-main').addClass('disable-owl-click');
3632                    $(this).parents('.post-main').find('.MoveLeftToRight').removeClass('MoveRightToLeft');
3633                    $(this).parents('.post-main').parent().find('.owl-background-item-left').addClass('MoveLeftToRight');
3634                    $(this).parent().parent().removeClass("StatusRight");
3635                    $(this).parent().parent().addClass("StatusLeft");
3636                    $(this).parents('.owl-carousel').removeClass("dragging");
3637                });
3638                $(this).on('translate.owl.carousel', function(event) {
3639                    var element   = event.target;
3640                    var checkExist = setInterval(function() {
3641                        if( $(element).hasClass('dragging') == false){
3642                            if($(element).hasClass('StatusRight')){
3643                                $(element).parent().find('.owl-background-item').children('div').css('margin-right', '0');
3644                                $(element).removeClass('StatusLeft');
3645                                var item_active_last = $(element).find('.owl-item.active').first().next();
3646                                img_back = $(item_active_last).find('.post__thumb').attr('data-background');
3647
3648                                $(element).parent().find('.owl-background-item-front').first().addClass('owl-background-item-left');
3649                                $(element).parent().find('.owl-background-item-left').last().removeClass('owl-background-item-front');
3650
3651                                $(element).parent().find('.owl-background-item-right').first().addClass('owl-background-item-front');
3652                                $(element).parent().find('.owl-background-item-front').removeClass('owl-background-item-right');
3653                                $(element).parent().find('.owl-background-item').append('<div class="owl-background-item-right" style="background-image: url(' + img_back  + ');"></div>');
3654                                clearInterval(checkExist);
3655                            }
3656                            else if( $(element).hasClass('StatusLeft')){
3657                                $(element).removeClass('StatusRight');
3658                                var item_active_first = $(element).find('.owl-item.active').first().prev();
3659                                img_front = $(item_active_first).find('.post__thumb').attr('data-background');
3660
3661                                $(element).parent().find('.owl-background-item-left').first().addClass('owl-background-item-front');
3662                                $(element).parent().find('.owl-background-item-front').first().removeClass('owl-background-item-left');
3663                                $(element).parent().find('.owl-background-item-front').last().addClass('owl-background-item-right');
3664                                $(element).parent().find('.owl-background-item-right').removeClass('owl-background-item-front');
3665                                $(element).parent().find('.owl-background-item').prepend('<div class="owl-background-item-left margin-right-neg-100" style="background-image: url(' + img_front  + ');"></div>');
3666
3667                                $(element).parent().find('.owl-background-item-right').last().remove();
3668                                clearInterval(checkExist);
3669                            }
3670                        }
3671                        clearInterval(checkExist);
3672                    }, 100); // check every 100ms
3673                });
3674                $(this).on('translated.owl.carousel', function(event) {
3675                    $(this).parent().find('.margin-right-neg-100').removeClass('margin-right-neg-100');
3676                    $(this).parent().find('.MoveLeftToRight').removeClass('MoveLeftToRight');
3677                    $(this).parent().find('.owl-background-item-front').removeClass('fade-in-fwd');
3678                    if($(this).hasClass('StatusRight')){
3679                        $(this).parent().find('.owl-item-remove').remove();
3680                    }
3681                    var $this = $(this);
3682                    var checkExist = setInterval(function() {
3683
3684                        if($this.parents('.post-main').hasClass('disable-owl-click')) {
3685                            $this.parents('.post-main').removeClass('disable-owl-click');
3686                            clearInterval(checkExist);
3687                        }
3688                    }, 100); // check every 100ms
3689                });
3690                $(this).on("drag.owl.carousel", function (event) {
3691                    $(this).addClass("dragging");
3692                });
3693                $(this).on("dragged.owl.carousel", function (event) {
3694                    $(this).parent().find('.owl-background-item-front').addClass('fade-in-fwd');
3695                    $(this).parent().find('.owl-background-item-left').css('background-image','url('+ $(this).find('.owl-item.active').first().prev().find('.post__thumb').attr('data-background') + ')');
3696                    $(this).parent().find('.owl-background-item-front').css('background-image','url('+ $(this).find('.owl-item.active').first().find('.post__thumb').attr('data-background') + ')');
3697                    $(this).parent().find('.owl-background-item-right').css('background-image','url('+ $(this).find('.owl-item.active').last().find('.post__thumb').attr('data-background') + ')');
3698
3699                    //console.log('event : ',event.relatedTarget['_drag']['direction']);
3700                    // touch right to left
3701                    // if( event.relatedTarget['_drag']['direction'] == 'left'){
3702                    //  console.log('a');
3703                    //
3704                    // }
3705                    // // touch left to right
3706                    // else{
3707                    //  console.log('b');
3708                    // }
3709                });
3710            })
3711        },
3712
3713        carousel_3i: function() {
3714            var $carousels = $('.js-carousel-3i');
3715            $carousels.each( function() {
3716                $(this).owlCarousel({
3717                    loop: true,
3718                    nav: true,
3719                    dots: false,
3720                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3721                    responsive: {
3722                        0 : {
3723                            items: 1,
3724                        },
3725
3726                        768 : {
3727                            items: 2,
3728                        },
3729
3730                        992 : {
3731                            items: 3,
3732                        },
3733                    },
3734                });
3735            })
3736        },
3737        carousel_4i30m5_update: function() {
3738            var $carousels = $('.js-carousel-4i30m5-update');
3739            $carousels.each( function() {
3740                $(this).owlCarousel({
3741                    items: 4,
3742                    margin: 20,
3743                    loop: true,
3744                    nav: false,
3745                    dots: true,
3746                    autoplay: false,
3747                    autoHeight: true,
3748                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3749                    responsive: {
3750                        0 : {
3751                            items: 1,
3752                            margin: 15,
3753                        },
3754                        321:{
3755                            items: 1,
3756                            margin: 15,
3757                        },
3758                        380 : {
3759                            items: 1,
3760                            margin: 15,
3761                        },
3762                        481: {
3763                            items: 2,
3764                            margin: 15,
3765                        },
3766                        577: {
3767                            items: 2,
3768                            margin: 15,
3769                            stagePadding: 50,
3770                        },
3771                        680: {
3772                            items: 2,
3773                            margin: 15,
3774                        },
3775                        769 : {
3776                            items: 2,
3777                        },
3778                        992 : {
3779                            items: 3,
3780                        },
3781                        1600: {
3782                            items: 4,
3783                        }
3784                    },
3785
3786
3787                });
3788            })
3789        },
3790        
3791        carousel_3i30m5_update: function() {
3792            var $carousels = $('.js-carousel-3i30m5-update');
3793            $carousels.each( function() {
3794                $(this).owlCarousel({
3795                    items: 3,
3796                    margin: 20,
3797                    loop: true,
3798                    nav: false,
3799                    dots: true,
3800                    autoplay: false,
3801                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3802                    responsive: {
3803                        0 : {
3804                            items: 1,
3805                            margin: 15,
3806                        },
3807                        321:{
3808                            items: 1,
3809                            margin: 15,
3810                        },
3811                        380 : {
3812                            items: 1,
3813                            margin: 15,
3814                        },
3815                        481: {
3816                            items: 2,
3817                            margin: 15,
3818                        },
3819                        577: {
3820                            items: 2,
3821                            margin: 15,
3822                            stagePadding: 50,
3823                        },
3824                        680: {
3825                            items: 2,
3826                            margin: 15,
3827                        },
3828                     
3828   769 : {
3829                            items: 2,
3830                        },
3831                        992 : {
3832                            items: 3,
3833                        },
3834                    },
3835
3836
3837                });
3838            })
3839        },
3840        carousel_3i30m5: function() {
3841            var $carousels = $('.js-carousel-3i30m5');
3842            $carousels.each( function() {
3843                $(this).owlCarousel({
3844                    items: 3,
3845                    margin: 20,
3846                    loop: true,
3847                    nav: false,
3848                    dots: true,
3849                    autoplay: false,
3850                    autoWidth: true,
3851                    // stagePadding: 100,
3852                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3853                    responsive: {
3854                        0 : {
3855                            items: 1,
3856                            margin: 15,
3857                            // stagePadding: 0,
3858                        },
3859                        321:{
3860                            items: 1,
3861                            margin: 15,
3862                            // stagePadding: 30,
3863                        },
3864                        381 : {
3865                            items: 2,
3866                            margin: 15,
3867                            stagePadding: 30,
3868                        },
3869                        481: {
3870                            items: 2,
3871                            margin: 30,
3872                            // stagePadding: 50,
3873                            // stagePadding: 80,
3874                        },
3875                        577: {
3876                            items: 2,
3877                            margin: 15,
3878                            // stagePadding: 50,
3879                        },
3880                        680: {
3881                            items: 2,
3882                            margin: 15,
3883                            // stagePadding: 150,
3884                        },
3885                        769 : {
3886                            items: 3,
3887                            // stagePadding: 50,
3888                        },
3889                        992 : {
3890                            items: 3,
3891                            // stagePadding: 100,
3892                        },
3893                        1600: {
3894                            items: 4,
3895                        }
3896                    },
3897
3898
3899                });
3900            })
3901        },
3902        carousel_3i30m: function() {
3903            var $carousels = $('.js-carousel-3i30m');
3904            $carousels.each( function() {
3905                $(this).owlCarousel({
3906                    margin: 30,
3907                    loop: true,
3908                    nav: true,
3909                    dots: true,
3910                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3911                    responsive: {
3912                        0 : {
3913                            items: 1,
3914                        },
3915
3916                        781 : {
3917                            items: 2,
3918                        },
3919
3920                        992 : {
3921                            items: 3,
3922                        },
3923                    },
3924                });
3925            })
3926        },
3927
3928        carousel_3i4m: function() {
3929            var $carousels = $('.js-carousel-3i4m');
3930            $carousels.each( function() {
3931                var carousel_loop = $(this).data('carousel-loop');
3932                $(this).owlCarousel({
3933                    margin: 4,
3934                    loop: carousel_loop,
3935                    nav: true,
3936                    dots: true,
3937                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3938                    responsive: {
3939                        0 : {
3940                            items: 1,
3941                        },
3942
3943                        768 : {
3944                            items: 2,
3945                        },
3946
3947                        992 : {
3948                            items: 2,
3949                        },
3950                        1200 : {
3951                            items: 3,
3952                        },
3953                    },
3954                });
3955            })
3956        },
3957
3958        carousel_3i4m_small: function() {
3959            var $carousels = $('.js-carousel-3i4m-small');
3960            $carousels.each( function() {
3961                $(this).owlCarousel({
3962                    margin: 4,
3963                    loop: false,
3964                    nav: true,
3965                    dots: true,
3966                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3967                    autoHeight: true,
3968                    responsive: {
3969                        0 : {
3970                            items: 1,
3971                        },
3972
3973                        768 : {
3974                            items: 2,
3975                        },
3976
3977                        1200 : {
3978                            items: 3,
3979                        },
3980                    },
3981                });
3982            })
3983        },
3984        
3985        carousel_2i20m: function() {
3986            var $carousels = $('.js-carousel-2i20m');
3987            $carousels.each( function() {
3988                var carousel_loop = $(this).data('carousel-loop');
3989                $(this).owlCarousel({
3990                    margin: 20,
3991                    loop: carousel_loop,
3992                    nav: true,
3993                    dots: true,
3994                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
3995                    responsive: {
3996                        0 : {
3997                            items: 1,
3998                        },
3999
4000                        768 : {
4001                            items: 2,
4002                        },
4003                    },
4004                });
4005            })
4006        },
4007        
4008        carousel_3i20m: function() {
4009            var $carousels = $('.js-carousel-3i20m');
4010            $carousels.each( function() {
4011                var carousel_loop = $(this).data('carousel-loop');
4012                $(this).owlCarousel({
4013                    margin: 20,
4014                    loop: carousel_loop,
4015                    nav: true,
4016                    dots: true,
4017                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
4018                    responsive: {
4019                        0 : {
4020                            items: 1,
4021                        },
4022
4023                        481 : {
4024                            items: 2,
4025                        },
4026
4027                        992 : {
4028                            items: 3,
4029                        },
4030                    },
4031                });
4032            })
4033        },
4034
4035        carousel_headingAside_3i: function() {
4036            var $carousels = $('.js-atbs-ceris-carousel-heading-aside-3i');
4037            $carousels.each( function() {
4038                var carousel_loop = $(this).data('carousel-loop');
4039                $(this).owlCarousel({
4040                    margin: 20,
4041                    nav: false,
4042                    dots: false,
4043                    loop: carousel_loop,
4044                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
4045                    responsive: {
4046                        0 : {
4047                            items: 1,
4048                            margin: 10,
4049                            stagePadding: 40,
4050                            loop: false,
4051                        },
4052
4053                        768 : {
4054                            items: 2,
4055                        },
4056
4057                        992 : {
4058                            items: 3,
4059                        },
4060                    },
4061                });
4062            })
4063        },
4064
4065        customCarouselNav: function() {
4066            if ( $.isFunction($.fn.owlCarousel) ) {
4067                var $carouselNexts = $('.js-carousel-next');
4068                $carouselNexts.each( function() {
4069                    var carouselNext = $(this);
4070                    var carouselID = carouselNext.parent('.atbs-ceris-carousel-nav-custom-holder').attr('data-carouselID');
4071                    var $carousel = $('#' + carouselID);
4072
4073                    carouselNext.on('click', function() {
4074                        $carousel.trigger('next.owl.carousel');
4075                    });
4076                });
4077
4078                var $carouselPrevs = $('.js-carousel-prev');
4079                $carouselPrevs.each( function() {
4080                    var carouselPrev = $(this);
4081                    var carouselID = carouselPrev.parent('.atbs-ceris-carousel-nav-custom-holder').attr('data-carouselID');
4082                    var $carousel = $('#' + carouselID);
4083
4084                    carouselPrev.on('click', function() {
4085                        $carousel.trigger('prev.owl.carousel');
4086                    });
4087                });
4088            }
4089        },
4090
4091        carousel_4i: function() {
4092            var $carousels = $('.js-carousel-4i');
4093
4094            $carousels.each( function() {
4095                $(this).owlCarousel({
4096                    loop: true,
4097                    nav: true,
4098                    dots: false,
4099                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
4100                    responsive: {
4101                        0 : {
4102                            items: 1,
4103                        },
4104
4105                        768 : {
4106                            items: 2,
4107                        },
4108
4109                        992 : {
4110                            items: 4,
4111                        },
4112                    },
4113                });
4114            })
4115        },
4116        carousel_4i0m: function() {
4117            var $carousels = $('.js-carousel-4i0m');
4118
4119            $carousels.each( function() {
4120                $(this).owlCarousel({
4121                    loop: true,
4122                    nav: false,
4123                    dots: true,
4124                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
4125                    responsive: {
4126                        0 : {
4127                            items: 1,
4128                            touchDrag: true,
4129                            mouseDrag  : true,
4130                            smartSpeed : 800,
4131                            margin: 20,
4132                        },
4133                        481: {
4134                            items: 2,
4135                            margin: 8,
4136                            touchDrag: true,
4137                            mouseDrag  : true,
4138                            smartSpeed : 800,
4139                        },
4140                        577: {
4141                            items: 2,
4142                            margin: 8,
4143                            touchDrag: true,
4144                            mouseDrag  : true,
4145                            smartSpeed : 800,
4146                        },
4147                        769 : {
4148                            items: 3,
4149
4150                        },
4151                        992 : {
4152                            items: 3,
4153                        },
4154                        1200 : {
4155                            items: 4,
4156                        },
4157                    },
4158                });
4159            })
4160        },
4161        
4162        carousel_4i30m: function() {
4163            var $carousels = $('.js-carousel-4i30m');
4164            $carousels.each( function() {
4165                $(this).owlCarousel({
4166                    loop: false,
4167                    nav: false,
4168                    margin: 30,
4169                    dots: true,
4170                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
4171                    responsive: {
4172                        0 : {
4173                            items: 1,
4174                            touchDrag: true,
4175                            mouseDrag  : true,
4176                            smartSpeed : 800,
4177                        },
4178                        481: {
4179                            items: 2,
4180                            margin: 15,
4181                            touchDrag: true,
4182                            mouseDrag  : true,
4183                        },
4184                        577: {
4185                            items: 2,
4186                            margin: 15,
4187                            touchDrag: true,
4188                            mouseDrag  : true,
4189                        },
4190                        769 : {
4191                            items: 3,
4192
4193                        },
4194
4195                        992 : {
4196                            items: 4,
4197                        },
4198                    },
4199                });
4200            })
4201        },
4202        carousel_4i4m: function() {
4203            var $carousels = $('.js-carousel-4i4m');
4204            $carousels.each( function() {
4205                var carousel_loop = $(this).data('carousel-loop');
4206                $(this).owlCarousel({
4207                    margin: 4,
4208                    loop: carousel_loop,
4209                    nav: true,
4210                    dots: true,
4211                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
4212                    responsive: {
4213                        0 : {
4214                            items: 1,
4215                        },
4216
4217                        768 : {
4218                            items: 2,
4219                        },
4220
4221                        992 : {
4222                            items: 4,
4223                        },
4224                    },
4225                });
4226            })
4227        },
4228        carousel_4i20m: function() {
4229            var $carousels = $('.js-carousel-4i20m');
4230
4231            $carousels.each( function() {
4232                var carousel_loop = $(this).data('carousel-loop');
4233                $(this).owlCarousel({
4234                    items: 4,
4235                    margin: 20,
4236                    loop: carousel_loop,
4237                    nav: true,
4238                    dots: true,
4239                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
4240                    responsive: {
4241                        0 : {
4242                            items: 1,
4243                        },
4244
4245                        768 : {
4246                            items: 2,
4247                        },
4248
4249                        992 : {
4250                            items: 3,
4251                        },
4252
4253                        1199 : {
4254                            items: 4,
4255                        },
4256                    },
4257                });
4258            })
4259        },
4260
4261        carousel_5i0m: function() {
4262            var $carousels = $('.js-carousel-5i0m');
4263            $carousels.each( function() {
4264                var carousel_loop = $(this).data('carousel-loop');
4265                $(this).owlCarousel({
4266                    margin: 0,
4267                    // loop: carousel_loop,
4268                    loop:true,
4269                    nav: true,
4270                    dots: true,
4271                    center: true,
4272                    autoWidth: true,
4273                    autoHeight: true,
4274                    // autoplay: false,
4275                    // autoplayTimeout: 4000,
4276                    // autoplayHoverPause: true,
4277                    navText: ['<i class="mdicon mdicon-navigate_before"></i>', '<i class="mdicon mdicon-navigate_next"></i>'],
4278                    responsive: {
4279                        0 : {
4280                            items: 1,
4281                            center: false,
4282                            margin: 30,
4283                        },
4284                        381 : {
4285                            center: true,
4286                            margin: 30,
4287                        },
4288                        481 : {
4289                            items: 2,
4290                            margin: 30,
4291                        },
4292                        767 : {
4293                            items: 1,
4294                            margin: 30,
4295                        },
4296                        992 : {
4297                            margin: 0,
4298                        },
4299                        1199 : {
4300                            items: 5,
4301                        },
4302     
4302               },
4303                });
4304            })
4305        },
4306        /* ============================================================================
4307         * Countdown timer
4308         * ==========================================================================*/
4309        countdown: function() {
4310            if ( $.isFunction($.fn.countdown) ) {
4311                var $countdown = $('.js-countdown');
4312
4313                $countdown.each(function() {
4314                    var $this = $(this);
4315                    var finalDate = $this.data('countdown');
4316
4317                    $this.countdown(finalDate, function(event) {
4318                        $(this).html(event.strftime(''
4319                        + '<div class="countdown__section"><span class="countdown__digit">%-D</span><span class="countdown__text meta-font">day%!D</span></div>'
4320                        + '<div class="countdown__section"><span class="countdown__digit">%H</span><span class="countdown__text meta-font">hr</span></div>'
4321                        + '<div class="countdown__section"><span class="countdown__digit">%M</span><span class="countdown__text meta-font">min</span></div>'
4322                        + '<div class="countdown__section"><span class="countdown__digit">%S</span><span class="countdown__text meta-font">sec</span></div>'));
4323                    });
4324                });
4325            };
4326        },
4327
4328        /* ============================================================================
4329         * Scroll top
4330         * ==========================================================================*/
4331        goToTop: function() {
4332            if ($goToTopEl.length) {
4333                $goToTopEl.on('click', function() {
4334                    $('html,body').stop(true).animate({scrollTop:0},400);
4335                    return false;
4336                });
4337            }
4338        },
4339
4340        /* ============================================================================
4341         * News ticker
4342         * ==========================================================================*/
4343        newsTicker: function() {
4344            var $tickers = $('.js-atbs-ceris-news-ticker');
4345            $tickers.each( function() {
4346                var $ticker = $(this);
4347                var $next = $ticker.siblings('.atbs-ceris-news-ticker__control').find('.atbs-ceris-news-ticker__next');
4348                var $prev = $ticker.siblings('.atbs-ceris-news-ticker__control').find('.atbs-ceris-news-ticker__prev');
4349
4350                $ticker.addClass('initialized').vTicker('init', {
4351                    speed: 300,
4352                    pause: 3000,
4353                    showItems: 1,
4354                });
4355
4356                $next.on('click', function() {
4357                    $ticker.vTicker('next', {animate:true});
4358                });
4359
4360                $prev.on('click', function() {
4361                    $ticker.vTicker('prev', {animate:true});
4362                });
4363            })
4364        },
4365
4366        /* ============================================================================
4367         * Lightbox
4368         * ==========================================================================*/
4369        lightBox: function() {
4370            if ( $.isFunction($.fn.magnificPopup) ) {
4371                var $imageLightbox = $('.js-atbs-ceris-lightbox-image');
4372                var $galleryLightbox = $('.js-atbs-ceris-lightbox-gallery');
4373
4374                $imageLightbox.magnificPopup({
4375                    type: 'image',
4376                    mainClass: 'mfp-zoom-in',
4377                    removalDelay: 80,
4378                });
4379
4380                $galleryLightbox.each(function() {
4381                    $(this).magnificPopup({
4382                        delegate: '.gallery-icon > a',
4383                        type: 'image',
4384                        gallery:{
4385                            enabled: true,
4386                        },
4387                        mainClass: 'mfp-zoom-in',
4388                        removalDelay: 80,
4389                    });
4390                });
4391            }
4392        },
4393
4394        /* ============================================================================
4395         * Custom scrollbar
4396         * ==========================================================================*/
4397        perfectScrollbarInit: function() {
4398            var ps_area = $('.js-perfect-scrollbar');
4399            ps_area.each(function(index,element){
4400                const this_ps_area = element;
4401                new PerfectScrollbar(this_ps_area);
4402            });
4403        },
4404
4405        /* ============================================================================
4406         * Sticky sidebar
4407         * ==========================================================================*/
4408        stickySidebar: function() {
4409            setTimeout(function() {
4410                var $stickySidebar = $('.js-sticky-sidebar');
4411                var $stickyHeader = $('.js-sticky-header');
4412
4413                var marginTop = ($stickyHeader.length) ? ($stickyHeader.outerHeight() + 20) : 0; // check if there's sticky header
4414
4415                if ( $( document.body ).hasClass( 'admin-bar' ) ) // check if admin bar is shown.
4416                    marginTop += 32;
4417
4418                if ( $.isFunction($.fn.theiaStickySidebar) ) {
4419                    $stickySidebar.each(function () {
4420                        if($(this).hasClass('atbs-ceris-block__aside-left')) {
4421                            $(this).theiaStickySidebar({
4422                                additionalMarginTop: 0,
4423                                additionalMarginBottom: 0,
4424                            });
4425                        }else {
4426                            $(this).theiaStickySidebar({
4427                                additionalMarginTop: marginTop,
4428                                additionalMarginBottom: 20,
4429                            });   
4430                        }
4431                    });
4432                }
4433            }, 250); // wait a bit for precise height;
4434            var $stickySidebarMobileFixed = $('.js-sticky-sidebar.atbs-ceris-sub-col--mobile-fixed');
4435            $stickySidebarMobileFixed.each(function () {
4436                var $this = $(this);
4437                var $drop_sub_col = $($this).find('.drop-sub-col');
4438                var $open_sub_col = $($this).find('.open-sub-col');
4439                setTimeout(function () {
4440                    $($this).append('<div class="drop-sub-col"></div>');
4441                    // <i class="mdicon mdicon-arrow_forward"></i>
4442                    $($this).append('<div class="open-sub-col"><i class="mdicon mdicon-arrow_forward"></i></div>');
4443
4444                    var checkExist = setInterval(function() {
4445                        if($drop_sub_col && $open_sub_col){
4446                            $drop_sub_col = $($this).find('.drop-sub-col');
4447                            $open_sub_col = $($this).find('.open-sub-col');
4448                            $drop_sub_col.on('click',function () {
4449                                $($this).removeClass('active');
4450                            });
4451                            $open_sub_col.on('click',function () {
4452                                $($this).addClass('active');
4453                            });
4454                            clearInterval(checkExist);
4455                        }
4456                    }, 100); // check every 100ms
4457
4458                },250);
4459            });
4460        },
4461
4462        /* ============================================================================
4463         * Bootstrap tooltip
4464         * ==========================================================================*/
4465        tooltipInit: function() {
4466            var $element = $('[data-toggle="tooltip"]');
4467
4468            $element.tooltip();
4469        },
4470    };
4471
4472    ATBS.documentOnLoad = {
4473
4474        init: function() {
4475            ATBS.clippedBackground();
4476            ATBS.header.smartAffix.compute(); //recompute when all the page + logos are loaded
4477            ATBS.header.smartAffix.updateState(); // update state
4478            ATBS.header.stickyNavbarPadding(); // fix bootstrap modal backdrop causes sticky navbar to shift
4479            ATBS.documentOnReady.stickySidebar();
4480        }
4481
4482    };
4483
4484    /* ============================================================================
4485     * Blur background mask
4486     * ==========================================================================*/
4487    ATBS.clippedBackground = function() {
4488        if ($overlayBg.length) {
4489            $overlayBg.each(function() {
4490                var $mainArea = $(this).find('.js-overlay-bg-main-area');
4491                if (!$mainArea.length) {
4492                    $mainArea = $(this);
4493                }
4494                var $subArea = $(this).find('.js-overlay-bg-sub-area');
4495                var $subBg = $(this).find('.js-overlay-bg-sub');
4496                if(!$subArea.length){
4497                    return;
4498                }
4499                if(!$subBg.length){
4500                    return;
4501                }
4502                var leftOffset = $mainArea.offset().left - $subArea.offset().left;
4503                var topOffset = $mainArea.offset().top - $subArea.offset().top;
4504                
4505                $subBg.css('display', 'block');
4506                $subBg.css('position', 'absolute');
4507                $subBg.css('width', $mainArea.outerWidth() + 'px');
4508                $subBg.css('height', $mainArea.outerHeight() + 'px');
4509                $subBg.css('left', leftOffset + 'px');
4510                $subBg.css('top', topOffset + 'px');
4511            });
4512        };
4513    }
4514
4515    /* ============================================================================
4516     * Priority+ menu
4517     * ==========================================================================*/
4518    ATBS.priorityNav = function($menu) {
4519        var $btn = $menu.find('button');
4520        var $menuWrap = $menu.find('.navigation');
4521        var $menuItem = $menuWrap.children('li');
4522        var hasMore = false;
4523
4524        if(!$menuWrap.length) {
4525            return;
4526        }
4527
4528        function calcWidth() {
4529            if ($menuWrap[0].getBoundingClientRect().width === 0)
4530                return;
4531
4532            var navWidth = 0;
4533
4534            $menuItem = $menuWrap.children('li');
4535            $menuItem.each(function() {
4536                navWidth += $(this)[0].getBoundingClientRect().width;
4537            });
4538
4539            if (hasMore) {
4540                var $more = $menu.find('.priority-nav__more');
4541                var moreWidth = $more[0].getBoundingClientRect().width;
4542                var availableSpace = $menu[0].getBoundingClientRect().width;
4543
4544                //Remove the padding width (assumming padding are px values)
4545                availableSpace -= (parseInt($menu.css("padding-left"), 10) + parseInt($menu.css("padding-right"), 10));
4546                //Remove the border width
4547                availableSpace -= ($menu.outerWidth(false) - $menu.innerWidth());
4548
4549                if (navWidth > availableSpace) {
4550                    var $menuItems = $menuWrap.children('li:not(.priority-nav__more)');
4551                    var itemsToHideCount = 1;
4552
4553                    $($menuItems.get().reverse()).each(function(index){
4554                        navWidth -= $(this)[0].getBoundingClientRect().width;
4555                        if (navWidth > availableSpace) {
4556                            itemsToHideCount++;
4557                        } else {
4558                            return false;
4559                        }
4560                    });
4561
4562                    var $itemsToHide = $menuWrap.children('li:not(.priority-nav__more)').slice(-itemsToHideCount);
4563
4564                    $itemsToHide.each(function(index){
4565                        $(this).attr('data-width', $(this)[0].getBoundingClientRect().width);
4566                    });
4567
4568                    $itemsToHide.prependTo($more.children('ul'));
4569                } else {
4570                    var $moreItems = $more.children('ul').children('li');
4571                    var itemsToShowCount = 0;
4572
4573                    if ($moreItems.length === 1) { // if there's only 1 item in "More" dropdown
4574                        if (availableSpace >= (navWidth - moreWidth + $moreItems.first().data('width'))) {
4575                            itemsToShowCount = 1;
4576                        }
4577                    } else {
4578                        $moreItems.each(function(index){
4579                            navWidth += $(this).data('width');
4580                            if (navWidth <= availableSpace) {
4581                                itemsToShowCount++;
4582                            } else {
4583                                return false;
4584                            }
4585                        });
4586                    }
4587
4588                    if (itemsToShowCount > 0) {
4589                        var $itemsToShow = $moreItems.slice(0, itemsToShowCount);
4590
4591                        $itemsToShow.insertBefore($menuWrap.children('.priority-nav__more'));
4592                        $moreItems = $more.children('ul').children('li');
4593
4594                        if ($moreItems.length <= 0) {
4595                            $more.remove();
4596                            hasMore = false;
4597                        }
4598                    }
4599                }
4600            } else {
4601                var $more = $('<li class="priority-nav__more"><a href="#"><span><i class="mdicon mdicon-more_horiz"></i></span></a><ul class="sub-menu"></ul></li>');
4602                var availableSpace = $menu[0].getBoundingClientRect().width;
4603
4604                //Remove the padding width (assumming padding are px values)
4605                availableSpace -= (parseInt($menu.css("padding-left"), 10) + parseInt($menu.css("padding-right"), 10));
4606                //Remove the border width
4607                availableSpace -= ($menu.outerWidth(false) - $menu.innerWidth());
4608
4609                if (navWidth > availableSpace) {
4610                    var $menuItems = $menuWrap.children('li');
4611                    var itemsToHideCount = 1;
4612
4613                    $($menuItems.get().reverse()).each(function(index){
4614                        navWidth -= $(this)[0].getBoundingClientRect().width;
4615                        if (navWidth > availableSpace) {
4616                            itemsToHideCount++;
4617                        } else {
4618                            return false;
4619                        }
4620                    });
4621
4622                    var $itemsToHide = $menuWrap.children('li:not(.priority-nav__more)').slice(-itemsToHideCount);
4623
4624                    $itemsToHide.each(function(index){
4625                        $(this).attr('data-width', $(this)[0].getBoundingClientRect().width);
4626                    });
4627
4628                    $itemsToHide.prependTo($more.children('ul'));
4629                    $more.appendTo($menuWrap);
4630                    hasMore = true;
4631                }
4632            }
4633        }
4634
4635        $window.on('load webfontLoaded', calcWidth );
4636        $window.on('resize', $.throttle( 50, calcWidth ));
4637    }
4638
4639    $document.ready( ATBS.documentOnReady.init );
4640    $window.on('load', ATBS.documentOnLoad.init );
4641    $window.on( 'resize', ATBS.documentOnResize.init );
4642
4643})(jQuery);

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.