PageSourceSearch

https://www.littlebirdiehome.com/st-app/modules/st-bootstrap/dist/st-bootstrap.js?v=1.17172

js littlebirdiehome.com collected 2026-09-26 11:45:05 UTC 90,456 bytes, 2,401 lines download raw bytes

1'use strict';
2
3if (isMobile.any) {
4    $(body).addClass('trueMobile');
5}
6
7function getScrollbarWidth() {
8    // Creating invisible container
9    var outer = document.createElement('div');
10    outer.style.visibility = 'hidden';
11    outer.style.overflow = 'scroll';
12    outer.style.msOverflowStyle = 'scrollbar';
13    if (document.body == null) return 0;
14    document.body.appendChild(outer);
15
16    var inner = document.createElement('div');
17    outer.appendChild(inner);
18
19    var scrollbarWidth = (outer.offsetWidth - inner.offsetWidth);
20
21    outer.parentNode.removeChild(outer);
22    return scrollbarWidth;
23}
24
25$('head').prepend('<style>:root{--scrollbar-width:' + getScrollbarWidth() +'px;}</style>');
26
27var bodyDirectDiv = $('body > div:not(.gj-picker):not(.hero):not(.modal):not(.bottom-navigation-bar):not(.tmask):not(.tbox):not(#at20mc):not(.SearchFormMobile):not(.modal-backdrop):not(.ui-helper-hidden-accessible):not(.announcement-bar):not([class^="ju_"])');
28
29// Remove Default Stylesheets
30$('link[rel="stylesheet"][href*="normalize.css"]').attr('disabled', 'disabled').remove();
31
32// Chrome WebApp
33if('serviceWorker' in navigator && stappConfig.cfgSvcWorker === "true") {
34    navigator.serviceWorker
35        .register('/st-svcworker.js', {scope: '/'})
36        .then(function(reg) {
37            console.log("Service Worker Registered. Scope is " + reg.scope);
38        })
39        .catch(function(error) {
40            console.log('Registration failed with ' + error);
41        });
42}
43
44// Set Animation On Scroll
45$(function(win) {
46    $.fn.inViewport = function(cb) {
47        return this.each(function(i,el){
48            function visPx(){
49                var H = $(this).height(),
50                    r = el.getBoundingClientRect(), t=r.top, b=r.bottom;
51                return cb.call(el, Math.max(0, t>0? H-t : (b<H?b:H)));
52            } visPx();
53            $(win).on("ready load resize scroll", visPx);
54            $(win).on("touchstart touchmove touchend", visPx);
55        });
56    };
57}(window));
58
59$(".animate").inViewport(function(px){
60    if(px) {
61        var animation = $(this).attr('data-animation');
62        $(this).addClass(animation + " animated") ;
63        $(this).css('visibility','visible')
64    }
65});
66
67// Download PDF Function
68function downloadPdf(FilePath,SaveFileName) {
69    // Check if iOS
70    if ((navigator.standalone === true) ||
71        (window.matchMedia('(display-mode: standalone)').matches)) {
72    }
73    var fileName = "&filename=\"download.pdf\"";
74    if (SaveFileName !== undefined && SaveFileName.length > 0) {
75        fileName = "&filename=\"" + SaveFileName + ".pdf\"";
76    }
77    console.log(SaveFileName)
78    console.log(fileName)
79    window.location.href = "../../content/asp/boot-downloadPDF.asp?filepath="+ FilePath + "" + fileName;
80}
81
82// WIP - Find Email Function
83function findEmail() {
84    var stringToSearchIn=document.body.innerHTML;
85    // var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; //String with ONLY Email address
86    var re = /(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
87    var extractedEmail=re.exec(stringToSearchIn);
88    // console.log(extractedEmail[0])
89}
90
91// WIP - Email Validation Function
92function validateEmail(email) {
93    var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
94    return re.test(String(email).toLowerCase());
95}
96
97// WIP - Encode Email Function
98function encodeEmail(formfield) {
99    /*toEncode = formfield.email_address.value;
100    encodedAddress = "";
101
102    for( ii = 0; ii < toEncode.length; ii++){
103        encodedAddress = encodedAddress +"&#" + toEncode.charCodeAt(ii) + ";";
104    }
105
106    completeEmailAddressCode = '<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;' + encodedAddress +'">' + encodedAddress + '</a>';
107    formfield.encoded_email_address.value = completeEmailAddressCode;*/
108}
109
110// Counter Function
111function counterUpDown(e,v,d,l,s) {
112    var i;
113    if (d === "down") {
114        for (i = v; i >= 0; i--) {
115            l-1 === 0 ? l = 1: null;
116            var setIncrement = i + (l-1);
117            (function(i) {
118                window.setTimeout(function() {
119                    e.innerHTML = (v - i).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
120                }, i * 1); // <- Set Count Speed in ms
121            })(i);
122        }
123    } else if (d === "up") {
124        // l-1 === 0 ? l = 1: null; <- Set Increment
125        // if (s === undefined) {s = 0;}
126        // s = parseInt(s, 10);
127        for (i = 0; i <= v; i++) {
128            (function(i) {
129                window.setTimeout(function() {
130                    e.innerHTML = i.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
131                }, i * 0.3); // <- Set Count Speed in ms
132            })(i);
133            // i += (l-1); <- Set Increment
134        }
135    }
136}
137
138function counterSet(e) {
139    var cVal = e.dataset.value,
140        cDir = e.dataset.direction,
141        cInc = e.dataset.increment,
142        cStrt = e.dataset.start;
143    counterUpDown(e,cVal,cDir,cInc,cStrt);
144}
145
146function triggerCounter(selector) {
147    counterSet(selector);
148}
149
150$(".display-counter").inViewport(function(px){
151    if(px && !this.classList.contains('animated')) {
152        triggerCounter(this);
153        this.classList.add('animated');
154    }
155});
156
157// Clear Unnecessary Elements
158$('.clearContainer').each(function () {
159    $(this).remove();
160});
161
162$('.site-container').each(function() {
163    $(this).contents().unwrap();
164});
165
166//wrap megamenu options without children
167$(".megaMenu-list.megaMenu-hasChild .megaMenu-item:not(.megaMenuChild-hasChild)").wrapAll('<li class="megaMenu-item dropdown-item megaMenuChild-hasChild megaMenuNoChildCategories"><ul>');
168
169// Construct Bootstrap Page Layout
170var sidebarMainMenu = $(document).find('#mainMenuSidebar');
171
172$('.container-row').each(function () {
173    $(this).removeClass('container-row').addClass('row');
174    if ($(this).find('.content').length > 0) {
175        $(this).addClass('row-content');
176    }
177});
178
179$('.container-cell').each(function () {
180    if (!$(this).parent().hasClass('row')) {
181        if (!$(this).next().hasClass('row')) {
182            if ($(this).hasClass('sidebar') || $(this).next().hasClass('content')) {
183                if ($(this).hasClass('sidebar')) {
184                    $(this).next().addBack().wrapAll('<div id="row-sidebar" class="row-sidebar row-content row" />');
185                } else {
186                    if ($(this).next().hasClass('content')) {
187                        $(this).next().addBack().wrapAll('<div id="row-content" class="row-content row" />');
188                    }
189                }
190            } else {
191                $(this).next().addBack().wrapAll('<div id="row-' + Math.random().toString(36).substring(2, 15) + '" class="row" />');
192            }
193        } else {
194            $(this).wrap('<div class="row" />');
195        }
196    }
197
198    if ($(this).hasClass('sidebar')) {
199        $(this).removeClass('container-cell').addClass('col-auto pl-0 pr-0');
200        var sidebarContentExists = $.trim($(this).html());
201        if (sidebarContentExists.length <= 0) {
202            $(this).addClass('d-none');
203        }
204    } else {
205        $(this).removeClass('container-cell').addClass('col');
206    }
207});
208
209if ((stappConfig.cfgMenuPos === "left" || stappConfig.cfgMenuPos === "right") && sidebarMainMenu.length > 0) {
210    $('body').addClass('sidebarMenu');
211    $(document).find('body > div:not(.modal):not(.bottom-navigation-bar)').removeClass().addClass('container-fluid d-flex flex-column flex-nowrap');
212
213    if (stappConfig.cfgMenuPos === "left") {
214        $(document).find('body > .container-fluid > .row').wrapAll('<main role="main" class="col-auto d-flex flex-column container-fluid mx-0 ml-lg-auto mr-lg-0 px-3" />');
215        $(document).find('body > .container-fluid').prepend(sidebarMainMenu);
216    } else if (stappConfig.cfgMenuPos === "right"){
217        $(document).find('body > .container-fluid > .row').wrapAll('<main role="main" class="col-auto d-flex flex-column flex-nowrap container-fluid mx-0 mr-lg-auto ml-lg-0 px-3" />');
218        $(document).find('body > .container-fluid').append(sidebarMainMenu);
219    }
220    $(document).find('body > .container-fluid').contents().wrapAll('<div class="row" />');
221
222} else {
223    if (stappConfig.cfgFullPageWidth) {
224        $(document).find(bodyDirectDiv).removeClass().addClass('container-fluid d-flex flex-column flex-nowrap');
225    } else {
226        $(document).find(bodyDirectDiv).removeClass().addClass('container d-flex flex-column flex-nowrap');
227    }
228}
229
230var cfmLabelFixed;
231function fixedForm(ff) {
232    if (ff !== null && ff === "1") {
233        cfmLabelFixed = " cfm-label-fixed"
234    } else {
235        cfmLabelFixed = ""
236    }
237}
238fixedForm(stappConfig.cfgCFMAnimatedLabels);
239
240// Auto iFrame Height
241function resizeIframe(obj) {
242    setTimeout(function () {
243        if (obj[0].contentWindow.document.body.scrollHeight>0) {
244            obj[0].style.height = obj[0].contentWindow.document.body.scrollHeight + 'px';
245        }
246    }, 250);
247}
248
249function autoHeight(autoFrame) {
250    autoFrame.on('load', function () {
251        resizeIframe(autoFrame)
252    });
253}
254
255// Format US Thousands
256function CommaFormatted(amount) {
257    var delimiter = ","; // replace comma if desired
258    var a = amount.split('.', 2);
259    var d = a[1];
260    var i = parseInt(a[0]);
261    if (isNaN(i)) {
262        return '';
263    }
264    var minus = '';
265    if (i < 0) {
266        minus = '-';
267    }
268    i = Math.abs(i);
269    var n = new String(i);
270    var a = [];
271    while (n.length > 3) {
272        var nn = n.substr(n.length - 3);
273        a.unshift(nn);
274        n = n.substr(0, n.length - 3);
275    }
276    if (n.length > 0) {
277        a.unshift(n);
278    }
279    n = a.join(delimiter);
280    if (d.length < 1) {
281        amount = n;
282    }
283    else {
284        amount = n + '.' + d;
285    }
286    amount = minus + amount;
287    return amount;
288}
289
290// Populate Category's Products Property Data
291function prodPropertyData(productdata, productID, option) {
292    var propertyString = '';
293    var prodprops = productdata.Where('$.Product.ID==' + productID).First();
294    //for (var sn = 0; sn < productdata.length; sn++) {
295    //    if (productdata[sn].Product.ID === productID) {
296        for (var sn1 = 0; sn1 < prodprops.Properties.length; sn1++) {
297            //switch (prodprops.Properties[sn1].N) {
298            switch (true) {
299                    //case "Sale":
300					case prodprops.Properties[sn1].N == "Sale":
301                    if (prodprops.Properties[sn1].V.toLowerCase() === "yes") {
302                            if (option === 'class') {
303                                propertyString += ' prodSale'
304                            }
305                        }
306                        break;
307                   // case "New":
308                    case prodprops.Properties[sn1].N == "New":
309                    if (prodprops.Properties[sn1].V.toLowerCase() === "yes") {
310                            if (option === 'class') {
311                                propertyString += ' prodNew'
312                            }
313                        }
314                        break;
315                    //case "Out of Stock":
316                    case prodprops.Properties[sn1].N == "Out of Stock":
317                    if (prodprops.Properties[sn1].V.toLowerCase() === "yes") {
318                            if (option === 'class') {
319                                propertyString += ' prodOutStock'
320                            }
321                        }
322                        break;
323                    //case "Custom Product Tag":
324                    case prodprops.Properties[sn1].N == "Custom Product Tag":
325                    if (prodprops.Properties[sn1].V.length > 0) {
326                            if (option === 'class') {
327                                propertyString += ' prodCustomTag';
328                                $('head').append('<style>.prodCell[pid="' + productID + '"] .prodImg.prodCustomTag a::before {background-image: url(/DSN/' + stappConfig.cfgDSN + '/Commerce/ProductTags/' + prodprops.Properties[sn1].V+'.png);}</style>');
329                            }
330                        }
331                        break;
332                    //case "MSRP":
333                    case prodprops.Properties[sn1].N == "MSRP":
334                    if (prodprops.Properties[sn1].V && prodprops.Properties[sn1].V.length > 0) {
335                            var prodMSRP = parseFloat(prodprops.Properties[sn1].V).toFixed(2);
336                            prodMSRP = CommaFormatted(prodMSRP);
337                            if (option === 'MSRP' && prodMSRP !== "") {
338                                propertyString = '<label class="prodPriceMSRPLabel">' + stappConfig.cfgCatMSRPLabel + '</label> <div class="prodPropMSRP">$' + prodMSRP + '</div>';
339                            }
340                        }
341                        break;
342						
343						
344					
345                    //case "Cinemark Exclusive":
346                    case prodprops.Properties[sn1].N == "Cinemark Exclusive":
347                   // case "Exclusive":
348                    //case prodprops.Properties[sn1].N == "Exclusive":
349                    if (prodprops.Properties[sn1].V.length > 0) {
350                            if (option === 'class') {
351                                propertyString += ' prodExclusive';
352                                $('head').append('<style>.prodCell[pid="' + productID + '"] .prodImg.prodCustomTag a::before {background-image: url(/DSN/' + stappConfig.cfgDSN + '/Commerce/ProductTags/' + prodprops.Properties[sn1].V+'.png);}</style>');
353                            }
354                        }
355                        break;
356					
357                    //case "Limited Time Offer":
358                    case prodprops.Properties[sn1].N == "Limited Time Offer":
359                    if (prodprops.Properties[sn1].V.length > 0) {
360                            if (option === 'class') {
361                                propertyString += ' prodLimited';
362                                $('head').append('<style>.prodCell[pid="' + productID + '"] .prodImg.prodCustomTag a::before {background-image: url(/DSN/' + stappConfig.cfgDSN + '/Commerce/ProductTags/' + prodprops.Properties[sn1].V+'.png);}</style>');
363                            }
364                        }
365                        break;
366						
367                   //case "Limited Time Offer":
368                    case prodprops.Properties[sn1].N == "Limited Time Offer":
369                    if (prodprops.Properties[sn1].V.length > 0) {
370                            if (option === 'class') {
371                                propertyString += ' prodLimited';
372                                $('head').append('<style>.prodCell[pid="' + productID + '"] .prodImg.prodCustomTag a::before {background-image: url(/DSN/' + stappConfig.cfgDSN + '/Commerce/ProductTags/' + prodprops.Properties[sn1].V+'.png);}</style>');
373                            }
374                        }
375                        break;
376						
377					//test
378                    case prodprops.Properties[sn1].N == option: //if the propery Name matches the option 
379                    if (prodprops.Properties[sn1].V.length > 0) {
380							propertyString = '<span class="prod'+option.replace(/\s/g, '')+'Label">' + option + ':&nbsp;</span>' + prodprops.Properties[sn1].V + '';
381                        }
382                        break;
383						
384                }
385            }
386        //}
387    //}
388    return propertyString;
389}
390
391// Set Social Links
392var socialLinks = '',
393    slinkFacebook = {platform:"Facebook", href:stappConfig.cfgFb.replace(/(^\w+:|^)\/\//, ''), icon:"fab fa-facebook-f"},
394    slinkInsta = {platform:"Instagram", href:stappConfig.cfgInsta.replace(/(^\w+:|^)\/\//, ''), icon:"fab fa-instagram"},
395    slinkTwitter = {platform:"Twitter", href:stappConfig.cfgTwitter.replace(/(^\w+:|^)\/\//, ''), icon:"fa-brands fa-square-x-twitter"},
396    slinkYT = {platform:"YouTube", href:stappConfig.cfgYouTube.replace(/(^\w+:|^)\/\//, ''), icon:"fab fa-youtube"},
397    slinkPin = {platform:"Pinterest", href:stappConfig.cfgPinterest.replace(/(^\w+:|^)\/\//, ''), icon:"fab fa-pinterest"},
398    slinkSnap = {platform:"Snapchat", href:stappConfig.cfgSnapchat.replace(/(^\w+:|^)\/\//, ''), icon:"fab fa-snapchat-ghost"},
399    slinkLinkedIn = { platform: "LinkedIn", href: stappConfig.cfgLinkedIn.replace(/(^\w+:|^)\/\//, ''), icon: "fab fa-linkedin" },
400    slinkTikTok = { platform: "TikTok", href: stappConfig.cfgTikTok.replace(/(^\w+:|^)\/\//, ''), icon: "fab fa-tiktok" },
401    slinkMail = {platform:"Mail", href:stappConfig.cfgSocialMail.replace(/(^\w+:|^)\/\//, ''), icon:"far fa-envelope"},
402    slinkSocial = [slinkFacebook, slinkInsta, slinkTwitter, slinkSnap, slinkTikTok, slinkYT, slinkPin, slinkLinkedIn, slinkMail];
403
404slinkSocial.forEach(function(entry) {
405    var socialTarget = "_blank";
406    if (entry.href.length > 0) {
407        if (entry.platform === "Mail") {
408            entry.href = "mailto:" + entry.href;
409            socialTarget = "_top";
410        } else {
411            entry.href = "http://" + entry.href;
412        }
413        socialLinks = socialLinks +
414            '<li class="nav-item social-link-' + entry.platform.toLowerCase() + '">' +
415            '<a class="nav-link" href="' + entry.href + '" title="' + entry.platform 
415+ '" target="' + socialTarget + '" rel="noreferrer">' +
416            '<i class="' + entry.icon + '"></i>' +
417            '</a>' +
418            '</li>';
419    }
420});
421
422$(document).ready(function() {
423    $('.nav-ui-social').html(window.socialLinks);
424
425    $(".nav-ui-search-btn.dropdown-toggle").on("click", function () {
426        setTimeout(function () { $('.nav-ui-search-dropdown #SearchText').focus(); }, 300);
427    });
428
429    $(".megaMenu-item").each(function (el) {
430        if ($(this).find("ul").length === 0) {
431            $(this).removeClass("megaMenuChild-hasChild")
432        }
433    });
434
435    $(".megaMenu-list").each(function (el) {
436        if ($(this).find("li.megaMenuChild-hasChild").length === 0) {
437            $(this).removeClass("megaMenu-hasChild")
438        }
439    });
440
441    try {
442        $('[data-toggle="tooltip"]').tooltip();
443    } catch (error) {
444        //nothing
445    }
446
447    if (stappConfig.cfgMenuSticky === "true") {
448        var navbar_height = 0;
449        var announce_height = 0;
450        if ($('.announcement-bar').outerHeight() != undefined) {
451            announce_height = $('.announcement-bar').outerHeight();
452        }
453        window.addEventListener('scroll', function () {
454            var scroll_amount = $(document).height() - $(body).height();
455		//console.log("scroll_amount: " + scroll_amount);
456            if ($('body').hasClass("desktop")) {
457                if (window.scrollY > announce_height && scroll_amount > 500) {
458                    $(".desktop .row-menu").addClass('fixed-top');
459                    navbar_height = $('.mainMenu').outerHeight(true);
460                    document.body.style.paddingTop = navbar_height + 'px';
461                    $('.announcement-bar').addClass("d-none");
462                } else {
463                    $('.announcement-bar').removeClass("d-none");
464                    $(".desktop .row-menu").removeClass('fixed-top');
465                    document.body.style.paddingTop = '0';
466                }
467            }
468        });
469        window.addEventListener('resize', function () {
470            if ($('body').hasClass("desktop")) { } else {
471                $('.announcement-bar').removeClass("d-none");
472                $(".row-menu").removeClass('fixed-top');
473                document.body.style.paddingTop = '0';
474            }
475        });
476    }
477
478});
479
480// Set  Product Image Heights
481function setProductImages() {
482    $('.MainProdBox').each(function () {
483        var prodImg = $(this).find('img');
484        $(this).css('max-height', $(this).width());
485        $(this).css('height', '100%');
486        $(this).css('height', $(this).width());
487    });
488
489    $('.ProductThumbGridBox').each(function () {
490        $(this).css('max-height', $(this).width());
491        $(this).css('height', '100%');
492        $(this).css('height', $(this).width());
493    });
494
495    $('.ProdThumbsBox > img').each(function () {
496        $(this).css('max-height', $(this).width());
497        $(this).css('height', '100%');
498        $(this).css('height', $(this).width());
499    });
500
501    $('.featured-wrap .featured-img a > img').each(function () {
502        $(this).css('max-height', $(this).parent().width());
503        $(this).css('height', $(this).parent().width());
504    });
505
506}
507
508// Set Category & Product List View Image Heights
509function setImages() {
510    $('.categoryImg').each(function () {
511        var padOffset = $(this).width() - 0;
512        $(this).css('max-height', $(this).width());
513        $(this).css('height', '100%');
514        $(this).css('height', $(this).width());
515        $(this).find('img').css('max-height', padOffset);
516    });
517
518    $('.featured-shop-img').each(function () {
519        var padOffset = $(this).width() - 0;
520        $(this).css('max-height', $(this).width());
521        $(this).css('height', '100%');
522        $(this).css('height', $(this).width());
523        $(this).find('img').css('max-height', padOffset);
524    });
525
526    $('.prodImg').each(function () {
527        $(this).css('max-height', $(this).width());
528        $(this).css('height', '100%');
529        $(this).css('height', $(this).width());
530    });
531    setProductImages();
532}
533
534// Set Modal Image Heights
535function setImagesModal() {
536    $('#bootCart-related .prodImg').each(function () {
537        $(this).css('max-height', $(this).width());
538        $(this).css('height', '100%');
539        $(this).css('height', $(this).width());
540    });
541}
542
543// Adjust Product Description Dropdown Status
544function setProdDescWrapper() {
545    if (stappConfig.cfgOpenDescMobile.toLowerCase() !== "false") {
546        if ($(window).width() < 768) {
547            if (stappConfig.cfgOpenDescMobile.toLowerCase() === "false") {
548                $('.COMProdDescLink').addClass('collapsed').attr('aria-expanded', 'false');
549                $('#COMProdDesc').removeClass('show');
550            } else if (stappConfig.cfgOpenDescMobile.toLowerCase() === "true") {
551                $('.COMProdDescLink').removeClass('collapsed').attr('aria-expanded', 'true');
552                $('#COMProdDesc').addClass('show');
553            }
554        } else {
555            if (stappConfig.cfgOpenDescDesktop.toLowerCase() === "false") {
556                $('.COMProdDescLink').addClass('collapsed').attr('aria-expanded', 'false');
557                $('#COMProdDesc').removeClass('show');
558            } else if (stappConfig.cfgOpenDescDesktop.toLowerCase() === "true") {
559                $('.COMProdDescLink').removeClass('collapsed').attr('aria-expanded', 'true');
560                $('#COMProdDesc').addClass('show');
561            }
562        }
563    }
564}
565
566// Wrap Product Details on Checkout Screen
567function chkoutProductWrapper() {
568    setTimeout(function () {
569        $('.RestCart_CartItem.productDetails').each(function () {
570            var chkoutWrap = $(this).closest('.productFullWrap');
571            if ($(window).width() < 768) {
572                chkoutWrap.find('.prod_trans').prepend($(this));
573            } else {
574                chkoutWrap.find('.RestCart_CartItem.productImage').after($(this));
575            }
576        });
577    }, 200);
578}
579
580function setMenuActivity() {
581    var docWidth = document.body.clientWidth + getScrollbarWidth();
582    if (isMobile.apple.tablet || docWidth < 992) {
583        if ($('#mainMenu').attr('data-type') === "inline" || $('#mainMenu').attr('data-type') === "both") {
584            $('#mainMenuNav').find('.dropdown-toggle').each(function () {
585                $(this).addClass('prevent-dropdown-toggle').removeClass('dropdown-toggle').attr({
586                    "data-toggle": "dropdown",
587                    "data-hover": ""
588                });
589            });
590        } else {
591            $('#mainMenuNav').find('.dropdown-toggle').each(function () {
592                $(this).attr({
593                    "data-toggle": "dropdown",
594                    "data-hover": ""
595                });
596            });
597        }
598    } else {
599        if ($('#mainMenu').attr('data-type') === "inline" || $('#mainMenu').attr('data-type') === "both") {
600            $('#mainMenuNav').find('.prevent-dropdown-toggle').each(function () {
601                $(this).addClass('dropdown-toggle').removeClass('prevent-dropdown-toggle').attr({
602                    "data-toggle": "",
603                    "data-hover": "dropdown"
604                });
605            });
606        } else {
607            $('#mainMenuNav').find('.dropdown-toggle').each(function () {
608                if ( $(this).parent().hasClass('nav-ui-inline-util-search') ) {
609                    $(this).attr({
610                        "data-toggle": "dropdown",
611                        "data-hover": ""
612                    });
613                } else {
614                    $(this).attr({
615                        "data-toggle": "",
616                        "data-hover": "dropdown"
617                    });
618                }
619            });
620        }
621    }
622}
623
624// Prevent Mouse Close on Sidemenu Links & Trigger Back Button
625$('.sideMenuNavWrap .dropdown-menu').on("click.bs.dropdown", function (e) {
626    if(event.target.tagName.toLowerCase() !== 'a') {
627        if(event.target.tagName.toLowerCase() !== 'ion-icon') {
628            if (!event.target.classList.contains('sideMenuNavBack')){
629                e.stopPropagation();
630                e.preventDefault();
631            }
632        }
633    }
634});
635
636// Set Viewport Classes & Positioning
637function setViewportClass() {
638    var docWidth = document.body.clientWidth + getScrollbarWidth();
639
640    $('body').addClass('shop-id-' + stappConfig.cfgShopID);
641    $('body').addClass('grp-id-' + stappConfig.cfgGroupID); //can be used for grp specific css
642
643    if (docWidth < 992) { // If viewport is Small Desktop (eBook, small laptop, etc)
644        // Set Fluid Width
645        bodyDirectDiv.addClass('container-fluid').removeClass('container');
646
647        // Set Body Classes
648        $('body').addClass('mobile').removeClass('desktop mobile-sm');
649
650        // Change Dropdown To Click
651        setMenuActivity();
652
653        // Set #topBar Background Image
654        if (stappConfig.cfgMobileTopBarBg.length > 1) { $('#topBar').css('background-image', 'url("' + stappConfig.cfgMobileTopBarBg + '")'); }
655
656        if (docWidth < 768) { // If viewport is Tablet
657            $('body').addClass('mobile-sm').removeClass('mobile-xs');
658        }
659
660        if (docWidth < 576) { // If viewport is Mobile
661            $('body').addClass('mobile-xs').removeClass('mobile-sm');
662
663            checkPageFilter();
664
665        }
666
667        if (stappConfig.cfgFullPageWidth) {
668            $(".container").addClass('container-fluid').removeClass('container');
669        }
670
671    } else {
672        // If viewport is Desktop (window width > 991)
673        // Set Standard Width
674        if (stappConfig.cfgFullPageWidth) {
675            $(".container").addClass('container-fluid').removeClass('container');
676        } else {
677            bodyDirectDiv.removeClass('container-fluid').addClass('container');
678        }
679
680        // Set Body Classes
681        $('body').addClass('desktop').removeClass('mobile mobile-sm mobile-xs');
682        $('#topBar').css('backgroundImage', '');
683
684
685        if (stappConfig.cfgFilterDisplay == "modal") {
686            $('#customFiltersWrap').appendTo('#bootFilters .modal-body');
687            $('#customFiltersWrap').prependTo('.COMFilterProductsSearch');
688        }
689
690        setMenuActivity();
691    }
692
693    // Toggle dropdown appearance depending on resolution
694    $(".nav-item a[data-hover='dropdown']").parent().hover(function () {
695        if ($(window).width() >= 991) {
696            $(this).addClass("show");
697        }
698    }, function () {
699        if ($(window).width() >= 991) {
700            $(this).removeClass("show");
701        }
702    });
703
704    $('.dropdown-has-content').hover(function () {
705        if ($(window).width() >= 991) {
706            $(this).parent().css('overflow', 'visible');
707        }
708    }, function () {
709        if ($(window).width() >= 991) {
710            $(this).parent().css('overflow', '');
711        }
712    });
713}
714setViewportClass();
715
716// Set custom branding text or image on page
717function setBrandImg() {
718    if (stappConfig.cfgBrandImg === "1") {
719        var cfgBrand = $.trim(stappConfig.cfgBrand);
720        $('.navbar-brand,.nav-side-logo').html(cfgBrand); //load config file
721    } else {
722        var cfgBrand = $.trim(stappConfig.cfgShopName);
723        $('.navbar-brand,.nav-side-logo').text(cfgBrand); //load config file
724    }
725}
726
727setBrandImg();
728
729// Keep child category submenus in top menu range
730function subMenuConstruct() {
731    var docWidth = document.body.clientWidth + getScrollbarWidth();
732    if (docWidth >= 992) {
733        $('.navbar-nav > .nav-item > .dropdown-menu > .dropdown-item > .dropdown-stage').each(function () {
734            var menuBase = $('#mainMenuNav').outerWidth();
735
736            //var subDropMenuWidth = $(this).closest('.dropdown-menu').outerWidth();
737            var subItem = $(this).closest('.nav-item').outerWidth();
738            var subItemLeft = $(this).closest('.nav-item').position().left;
739            var subDropMenuLeft = $(this).closest('.dropdown-menu').position().left;
740
741            var subStageLeft = Math.ceil(subItemLeft + (subItem - subDropMenuLeft));
742
743            var offsetCalc = (menuBase + 1) - subStageLeft;
744            var offsetCalcLeft = Math.ceil((subItemLeft - 1) + subDropMenuLeft);
745
746            if ($(this).closest('.dropdown-menu').length > 0) {
747                if (offsetCalc >= (menuBase * 0.4)) {
748                    // If dropdown stage width >= 40% of menu width then extend to right
749                    $(this).css('width', offsetCalc);
750                } else {
751                    // If dropdown stage width < 40% of menu width (close to the end) then reverse text/image order and extend to left
752                    $(this).css({
753                        'width': offsetCalcLeft,
754                        'right': '100%',
755                        'left': 'unset',
756                        'flexDirection': 'row-reverse'
757                    });
758                }
759            }
760        });
761    }
762}
763subMenuConstruct();
764
765// Custom Filters
766function checkPageFilter(){
767    var filterWrap = $('#customFiltersWrap');
768    if ($('.filter-ui').length) {
769        if (filterWrap.hasClass('sidebar')) {
770            if (document.body.clientWidth < 992) {
771                filterWrap.appendTo('#modal-filters-body').addClass('filterModal');
772                $('.filter-modal').removeClass('d-none');
773                $('#bootFilters').addClass('mobile-full-screen');
774                $('.filterButtons').show();
775            } else {
776                $('#bootFilters').modal('hide');
777                $('#sideMenuWrap').prepend(filterWrap);
778                $('#customFilters').removeAttr('style');
779                $('.filter-modal').addClass('d-none');
780                $('.filterButtons').hide();
781                $('#bootFilters').removeClass('mobile-full-screen');
782            }
783        } else if (!filterWrap.hasClass('filtersInlineWrap')) {
784            if (document.body.clientWidth < 992) {
785                filterWrap.appendTo('#modal-filters-body').addClass('filterModal');
786                $('.filter-modal').removeClass('d-none');
787                $('#bootFilters').addClass('mobile-full-screen');
788                $('.filterButtons').show();
789            } else {
790                $('#customFilters').removeAttr('style');
791                filterWrap.appendTo('#bootFilters .modal-body').removeClass('filterMobile');
792                $('.filterButtons').hide();
793                $('#bootFilters').removeClass('mobile-full-screen');
794            }
795        } else if (filterWrap.hasClass('filtersInlineWrap')) {
796            if (document.body.clientWidth < 576) {
797                filterWrap.appendTo('#modal-filters-body').addClass('filterModal').removeClass('collapse');
798                $('.filter-modal').removeClass('d-none');
799                $('#bootFilters').addClass('mobile-full-screen');
800                $('.filterButtons').show();
801                $('#filterToggle').replaceWith('<a id="filterToggle" href="#" class="btn btn-primary" data-toggle="modal" data-target="#bootFilters" target="_self"><i class="fas fa-filter"></i> Filter Products</a>')
802            } else {
803                $('#customFilters').removeAttr('style');
804                filterWrap.insertAfter('.filter-ui').removeClass('filterMobile').addClass('collapse');
805                $('#blackout').removeClass('filterMobile');
806                $('.filter-ui').show();
807                $('.filterButtons').hide();
808                $('#bootFilters').removeClass('mobile-full-screen');
809                $('#filterToggle').replaceWith('<a id="filterToggle" data-toggle="collapse" href="#customFiltersWrap" role="button" aria-expanded="false" aria-controls="customFiltersWrap"><i class="fas fa-filter"></i> Filter Products</a>')
810
811            }
812        }
813    }
814    if (document.body.clientWidth < 576) {
815        //$('#customFiltersWrap').css({ 'width': '0px' });
816    } else {
817        if (filterWrap.hasClass('sidebar') && document.body.clientWidth < 992) {
818            //$('#customFiltersWrap').css({ 'width': '0px' });
819        } else {
820            $('#customFiltersWrap').css({ 'width': 'initial' });
821        }
822    }
823    setTimeout(function(){
824        if (document.body.clientWidth >= 992 && filterWrap.hasClass('sidebar')) {
825            $('#customFiltersWrap').css({'width':$('#customFiltersWrap').outerWidth()+'px'});
826        }
827    },2000);
828}
829
830checkPageFilter();
831
832function applyFiltersMenu() {
833    $('#bootFilters .modal-header button').click();
834}
835
836function closeMobileFilters() {
837    $('#customFiltersWrap.filterMobile').animate({ 'width': '0px' }, 200);
838    $('#blackout').css({
839        'opacity':'0',
840        'pointer-events':'none'
841    });
842    $('#customFilters').removeClass('filtersOpen');
843    $('body').removeClass('noscroll');
844}
845
846function openMobileFilters() {
847    if ($('#customFilters').hasClass('filtersOpen')) {
848        closeMobileFilters();
849    } else {
850        $('body').addClass('noscroll');
851        $('#customFilters').addClass('filtersOpen');
852        $('#customFiltersWrap.filterMobile').animate({ 'width': '60vw' }, 200);
853        $('#blackout').css({
854            'opacity': '0.75',
855            'pointer-events': 'all'
856        });
857        $('.filterMobile #customFilters').fadeIn(200);
858    }
859}
860
861// Check Scrollability
862function checkScroll() {
863    var docHeight = document.getElementById("body").scrollHeight;
864    var winHeight = window.innerHeight;
865    if (docHeight > winHeight) {
866        $('#body').addClass('overflow');
867    } else {
868        $('#body').removeClass('overflow');
869    }
870}
871
872// Scroll To Anchor
873function scrollToAnchor(aid) {
874    var aTag = $("a[name='" + aid + "']");
875    $('html,body').animate({scrollTop: aTag.offset().top}, 'fast');
876}
877
878// Reset Dropdowns
879function resetDropdowns() {
880    $('.nav-ui-user-menu').removeClass('show').attr('aria-expanded', 'false');
881    $('.nav-ui-user-menu .dropdown-menu').removeClass('show');
882}
883
884// Construct Hero
885$('.hero').each(function (hero) {
886    hero = $(this);
887    var heroDataHeight = hero.attr('data-hero-height'),
888        heroDataType = hero.attr('data-type'),
889        heroImg = hero.children('img'),
890        heroParent = hero.parent().parent(),
891        catBanImg = $(document).find('.categoryBanner').children('img'),
892        catBanInlineImg = $(document).find('.categoryBanner').parent().children('img');
893    if ($(this).is('ul')) {
894        hero.addClass('slider');
895    } else {
896        if ($(this).hasClass('categoryBanner')) {
897            if (catBanInlineImg.length > 0) {
898                hero.css({
899                    'backgroundImage': 'url("' + catBanInlineImg.attr('src') + '")'
900                });
901            } else {
902                hero.css({
903                    'backgroundImage': 'url("' + catBanImg.attr('src') + '")'
904                });
905            }
906        } else {
907            if (heroImg.length > 0) {
908                if (typeof heroDataHeight !== typeof undefined && heroDataHeight !== false) {
909                    hero.css({
910                        'backgroundImage': 'url("' + heroImg.attr('src') + '")'
911                    });
912                    heroImg.remove();
913                } else {
914                    hero.addClass('hero-img')
915                }
916            }
917        }
918    }
919
920    if (typeof heroDataHeight !== typeof undefined && heroDataHeight !== false) {
921        hero.css({
922            "height": heroDataHeight + "px"
923        });
924
925        if (!heroParent.hasClass('row-content')) {
926            heroParent.css({
927                'height': heroDataHeight + 'px',
928                'maxHeight': heroDataHeight + 'px',
929                'minHeight': heroDataHeight + 'px'
930            });
931        }
932    }
933
934    if (typeof heroDataType !== typeof undefined && heroDataType !== false) {
935        if (heroDataType = "media") {
936            hero.addClass('slider-media');
937        }
938    }
939
940    if (hero.hasClass('fullscreen')) {
941        hero.parent().parent().addClass('hero-stage fullscreen');
942    }
943
944});
945
946// Parse YouTube URL
947function youtube_parser(url){
948    var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
949    var match = url.match(regExp);
950    return (match&&match[7].length==11)? match[7] : false;
951}
952
953// Media Slider Construct
954$('.slider').each(function (slider) {
955    slider = $(this);
956
957    var sliderId = slider.attr("id"),
958        sliderClasses = slider.attr("class");
959		
960		
961		
962		
963		
964	//jose slickslider plugin - start 12/5/22
965	var defaultSliderConfig = ''; //'{';
966	if (slider[0].hasAttribute("data-slider-dots")) {
967		defaultSliderConfig += "&quot;dots&quot;:" + slider.attr("data-slider-dots") + ", ";
968    }
969	if (slider[0].hasAttribute("data-slider-arrows")) {
970		defaultSliderConfig += "&quot;arrows&quot;
970:" + slider.attr("data-slider-arrows") + ", ";
971    }
972	if (slider[0].hasAttribute("data-slider-fade")) {
973		defaultSliderConfig += "&quot;fade&quot;:" + slider.attr("data-slider-fade") + ", ";
974    }
975	if (slider[0].hasAttribute("data-slider-autoplay")) {
976		defaultSliderConfig += "&quot;autoplay&quot;:" + slider.attr("data-slider-autoplay") + ", ";
977    }
978	//remove any last comma and spaces
979	if(defaultSliderConfig != ""){
980		defaultSliderConfig = defaultSliderConfig.replace(/,\s*$/, "");
981		defaultSliderConfig = ' data-slick="{' + defaultSliderConfig + '}"';
982	}
983	//jose slickslider plugin - start 12/5/22
984	
985	
986	
987	
988    if (slider[0].hasAttribute("data-slider-syncnav")) {
989        var sliderSync = " data-slider-syncnav='" + slider.attr("data-slider-syncnav") + "'";
990    } else {
991        var sliderSync = '';
992    }
993
994    if (slider[0].hasAttribute("data-slider-count")) {
995        var sliderCount = " data-slider-count='" + slider.attr("data-slider-count") + "'";
996    } else {
997        var sliderCount = '';
998    }
999
1000    if (slider[0].hasAttribute("data-slider-scroll")) {
1001        var sliderScroll = " data-slider-scroll='" + slider.attr("data-slider-scroll") + "'";
1002    } else {
1003        var sliderScroll = '';
1004    }
1005
1006    var sliderHeight = $(this).attr('data-slider-height'),
1007        setSliderHeight = '';
1008
1009    if (typeof sliderHeight !== typeof undefined && sliderHeight !== false) {
1010        if (sliderHeight !== '') {
1011            $(this).css({'height' : sliderHeight + 'px','max-height': sliderHeight + 'px'});
1012            setSliderHeight = 'height: ' + sliderHeight + 'px; max-height:' + sliderHeight + 'px';
1013        }
1014
1015    } else {
1016        setSliderHeight = '';
1017    }
1018
1019    if (typeof sliderId !== typeof undefined) {
1020		console.log( "sliderId: " + sliderId );
1021        if (sliderId !== "") {
1022            sliderId = 'id="' + sliderId + '" ';
1023        } else {
1024            sliderId = '';
1025        }
1026    } else {
1027        sliderId = '';
1028    }
1029	
1030	
1031
1032    // slider.contents().wrapAll('<div ' + sliderId + 'class="' + sliderClasses + '" style="' + setSliderHeight + '"' + sliderSync + sliderCount + sliderScroll +' />');
1033    slider.contents().wrapAll('<div ' + sliderId + 'class="' + sliderClasses + '" style="' + setSliderHeight + '"' + sliderSync + sliderCount + sliderScroll + (defaultSliderConfig != "" ? defaultSliderConfig : "") +' />');
1034
1035    var sliderListItem = slider.find('li');
1036
1037    sliderListItem.each(function () {
1038        var element = this,
1039            eleClass = $(this).attr("class");
1040
1041        $(element).find(".caption-wrap").appendTo($(this).find("a"));
1042
1043        var mediaLink = $(element).contents().not($(element).children()).filter(function () {
1044            return this.nodeType === 3
1045        });
1046
1047        if ($(this).is(':contains("youtube.com")')) {
1048            var vidStart = $(this).attr('data-video-start'),
1049                vidStartLink = "",
1050                vidPlaylist = $(this).attr('data-video-playlist'),
1051                vidPlaylistLink = "",
1052                vidLoop = $(this).attr('data-video-loop'),
1053                vidLoopLink = "";
1054
1055            $(mediaLink).wrapAll('<div class="media" />');
1056            $(element).contents().wrapAll('<div class="item item-youtube" style="' + setSliderHeight + '"/>');
1057
1058            var elementItem = $(element).children('.item');
1059
1060            if (typeof vidStart !== typeof undefined && vidStart !== false) {
1061                vidStartLink = "&amp;start=" + vidStart;
1062                $(elementItem).attr({
1063                    'data-video-start': vidStart
1064                });
1065            }
1066
1067            var header = $(this).find(':header');
1068            $(header).text($.trim($(header).text()));
1069            $(header).wrap('<p class="caption" />').contents().unwrap();
1070
1071            var linktext = $(this).find('.media');
1072            $(linktext).text($.trim($(linktext).text()));
1073
1074            var link = $(linktext).text();
1075            link = youtube_parser(link);
1076
1077            if (typeof vidLoop !== typeof undefined && vidLoop !== false && vidLoop !== "0" && vidLoop === "1") {
1078                vidPlaylistLink = "&amp;playlist=" + link;
1079            } else {
1080                if (typeof vidPlaylist !== typeof undefined && vidPlaylist !== false) {
1081                    vidPlaylistLink = "&amp;playlist=" + vidPlaylist;
1082                }
1083            }
1084
1085            var linkURL = 'https://www.youtube.com/embed/' + link + '?enablejsapi=1&amp;controls=0&amp;fs=0&amp;iv_load_policy=3&amp;rel=0&amp;showinfo=0&amp;mute=1&amp;muted=1&amp;loop=1&amp;autopause=0&amp;background=0' + vidPlaylistLink + vidStartLink + ';';
1086
1087            $(this).find('.media').html('<iframe allowfullscreen="" class="embed-player slide-media" allow="autoplay;" frameborder="0" height="520" src="' + linkURL + '" width="980"></iframe>');
1088            $(this).find('.media').contents().unwrap();
1089
1090            $(this).contents().unwrap();
1091        }
1092
1093        // If Vimeo Video
1094        if ($(this).is(':contains("vimeo.com")') && $(this).is(':not(:contains(".mp4"))')) {
1095            var vidStart = $(this).attr('data-video-start');
1096
1097            $(mediaLink).wrapAll('<div class="media" />');
1098            $(element).contents().wrapAll('<div class="item item-vimeo" style="' + setSliderHeight + '" />');
1099
1100            var elementItem = $(element).children('.item');
1101
1102            if (typeof vidStart !== typeof undefined && vidStart !== false) {
1103                $(elementItem).attr({
1104                    'data-video-start': vidStart
1105                });
1106            }
1107
1108            var header = $(this).find(':header');
1109            $(header).text($.trim($(header).text()));
1110            $(header).wrap('<p class="caption" />').contents().unwrap();
1111
1112            var linktext = $(this).find('.media');
1113            $(linktext).text($.trim($(linktext).text()));
1114
1115            var link = $(linktext).text();
1116            var linkURL = link + '?api=1&amp;byline=0&amp;portrait=0&amp;title=0&amp;background=1&amp;mute=1&amp;muted=1&amp;loop=1&amp;autoplay=0&amp;autopause=0&amp;background=0';
1117
1118            $(this).find('.media').html('' +
1119                '<iframe allowfullscreen="" class="embed-player slide-media" frameborder="0" height="520" mozallowfullscreen="" src="'
1120                + linkURL +
1121                '" webkitallowfullscreen="" width="980">' +
1122                '</iframe>');
1123            $(this).find('.media').contents().unwrap();
1124
1125            $(this).contents().unwrap();
1126        }
1127
1128        // If local .mp4 video
1129        if ($(this).is(':contains(".mp4")')) {
1130            $(mediaLink).wrapAll('<div class="media" />');
1131            $(element).contents().wrapAll('<div class="item item-video" style="' + setSliderHeight + '" />');
1132
1133            var header = $(this).find(':header');
1134            $(header).text($.trim($(header).text()));
1135            $(header).wrap('<p class="caption" />').contents().unwrap();
1136
1137            var poster = $(this).find('img');
1138            if (poster.length > 0) {
1139                poster = poster.attr('src');
1140            } else {
1141                poster = "";
1142            }
1143
1144            var linktext = $(this).find('.media');
1145            $(linktext).text($.trim($(linktext).text()));
1146
1147            var linkURL = $(linktext).text();
1148
1149            $(this).find('.media').html('' +
1150                '<video class="slide-video slide-media" loop="true" muted="true" autoplay="true" playsinline="" poster="' + poster + '" preload="auto" type="video/mp4">' +
1151                '<source src="' + linkURL + '" type="video/mp4" />' +
1152                '</video>');
1153            $(this).find('img').remove();
1154            $(this).find('.media').contents().unwrap();
1155            $(this).find(':header').wrap('<p class="caption" />').contents().unwrap();
1156            $(this).contents().unwrap();
1157        }
1158
1159        // If item is only an image
1160        if ($(this).find('img').length > 0 && $(this).is(':not(:contains(".mp4"))')) {
1161            if (eleClass !== undefined && eleClass.length > 0) {
1162                eleClass = ' ' + eleClass;
1163            } else {
1164                eleClass = '';
1165            }
1166
1167            $(element).contents().wrapAll('<div class="item item-image' + eleClass + '" style="' + setSliderHeight + '" />');
1168
1169            var elementItem = $(element).find('.item'),
1170                header = $(this).find(':header');
1171
1172            var srcURL = $(elementItem).find('img').attr('src'),
1173                linkURL = $(elementItem).find('img').parent(),
1174                linkWrapper = $(elementItem).find('img').parent(),
1175                captionActive = $(elementItem).find('.caption-wrap');
1176
1177            $(elementItem).find('img').removeAttr('style');
1178
1179            if (setSliderHeight != '') {
1180                elementItem.css({
1181                    'backgroundImage': 'url("' + srcURL + '")'
1182                });
1183                $(elementItem).find('img').first().remove();
1184            }
1185
1186            if (setSliderHeight == '' && captionActive.length == 0) {
1187                if (linkURL.is("a")) {
1188                    linkURL = linkURL.attr('href');
1189                    $(elementItem).prepend('<div class="slide-image slide-media"><a href="' + linkURL + '"><img class="image-entity" src="' + srcURL + '" /></a></div>');
1190                    linkWrapper.remove();
1191                }
1192            }
1193
1194   
1195
1196            $(this).contents().unwrap();
1197        }
1198    });
1199    slider.contents().unwrap();
1200});
1201
1202// Slider Video Compiler
1203var slideWrapper = $(".slider"),
1204    iframes = slideWrapper.find('.embed-player'),
1205    lazyImages = slideWrapper.find('.slide-image'),
1206    lazyCounter = 0;
1207
1208// POST commands to YouTube or Vimeo API
1209function postMessageToPlayer(player, command) {
1210    if (player == null || command == null) return;
1211    player.contentWindow.postMessage(JSON.stringify(command), "*");
1212}
1213
1214// When the slide is changing
1215function playPauseVideo(slick, control) {
1216    var currentSlide, slideType, startTime, player, video;
1217
1218    currentSlide = slick.find(".slick-current");
1219    slideType = currentSlide.attr("class").split(" ")[1];
1220    player = currentSlide.find("iframe").get(0);
1221    startTime = currentSlide.data("video-start");
1222
1223    if (slideType === "item-vimeo") {
1224        switch (control) {
1225            case "play":
1226                if ((startTime != null && startTime > 0) && !currentSlide.hasClass('started')) {
1227                    currentSlide.addClass('started');
1228                    postMessageToPlayer(player, {
1229                        "method": "setCurrentTime",
1230                        "value": startTime
1231                    });
1232                }
1233                postMessageToPlayer(player, {
1234                    "method": "play",
1235                    "value": 1
1236                });
1237                break;
1238            case "pause":
1239                postMessageToPlayer(player, {
1240                    "method": "pause",
1241                    "value": 1
1242                });
1243                break;
1244        }
1245    } else if (slideType === "item-youtube") {
1246        switch (control) {
1247            case "play":
1248                postMessageToPlayer(player, {
1249                    "event": "command",
1250                    "func": "mute"
1251                });
1252                postMessageToPlayer(player, {
1253                    "event": "command",
1254                    "func": "playVideo"
1255                });
1256                break;
1257            case "pause":
1258                postMessageToPlayer(player, {
1259                    "event": "command",
1260                    "func": "pauseVideo"
1261                });
1262                break;
1263        }
1264    } else if (slideType === "item-video") {
1265        video = currentSlide.children("video").get(0);
1266        if (video != null) {
1267            if (control === "play") {
1268                video.play();
1269            } else {
1270                video.pause();
1271            }
1272        }
1273    }
1274}
1275
1276// Resize player
1277function resizePlayer(iframes, ratio) {
1278    if (!iframes[0]) return;
1279    var win = $(".slider"),
1280        width = win.width(),
1281        playerWidth,
1282        height = win.height(),
1283        playerHeight,
1284        ratio = ratio || 16 / 9;
1285
1286    iframes.each(function () {
1287        var current = $(this);
1288        if (width / ratio < height) {
1289            playerWidth = Math.ceil(height * ratio);
1290            current.width(playerWidth).height(height).css({
1291                left: (width - playerWidth) / 2,
1292                top: 0
1293            });
1294        } else {
1295            playerHeight = Math.ceil(width / ratio);
1296            current.width(width).height(playerHeight).css({
1297                left: 0,
1298                top: (height - playerHeight) / 2
1299            });
1300        }
1301    });
1302    $(slideWrapper).css('transition', '');
1303}
1304
1305// Check Product Input Quantity
1306function checkQty(element, val, min) {
1307    var $qty = $(element).closest('.COMProdQtyInput').find('input'),
1308        currentVal = parseInt(val),
1309        tgtMinus = element,
1310        tgtAdd = $(element).closest('.COMProdQtyInput').children('.add'),
1311        qtyMin = parseInt($qty.attr('data-qtyMin')),
1312        qtyMax = parseInt($qty.attr('data-qtyMax')),
1313        qtyInc = parseInt(stprodConfig.cfgPurchaseIncrement);
1314
1315    if (qtyMin == 0) { qtyMin = 1 };
1316    if (qtyMin < qtyInc) { qtyMin = qtyInc };
1317    if (isNaN(qtyMax) || qtyMax <= 1) { qtyMax = 100000 };
1318     
1319    if (currentVal <= qtyMin && qtyMin !== 0) {
1320        tgtMinus.attr('disabled', '').addClass('noselect');
1321    } else {
1322        tgtMinus.removeAttr('disabled').removeClass('noselect');
1323    }
1324
1325    if (!isNaN(qtyMax)) {
1326        if (currentVal >= qtyMax && qtyMax !== 0) {
1327            tgtAdd.attr('disabled', '').addClass('noselect');
1328        } else {
1329            tgtAdd.removeAttr('disabled').removeClass('noselect');
1330        }
1331    }
1332}
1333
1334function megaMenuLink() {
1335    $('.megaMenu').parent('.nav-item').css('position','inherit');
1336}
1337
1338var addSidelinkInfo = function(e) {
1339    // position: {className:'', icon:'', linkTo:'', text:''}
1340    if (document.getElementsByClassName('nav-heading-info')[0] !== undefined) {
1341        const setContainer = document.getElementsByClassName('nav-heading-info')[0].nextElementSibling;
1342        Element.prototype.appendBefore = function (element) {
1343            element.parentNode.insertBefore(this, element);
1344        }, false;
1345        Element.prototype.appendAfter = function (element) {
1346            element.parentNode.insertBefore(this, element.nextSibling);
1347        }, false;
1348        if (setContainer.classList.contains('nav-side-links')) {
1349            let setList = setContainer.getElementsByClassName('list-item');
1350            for (let i in e) {
1351                if (e.hasOwnProperty(i)) {
1352                    var linkFrame = document.createElement('li');
1353                    linkFrame.classList.add('list-item');
1354                    if (typeof e[i].linkTo !== "undefined") {
1355                        var linkBuild = document.createElement('a');
1356                        linkBuild.href = e[i].linkTo;
1357                        if (typeof e[i].className !== "undefined")
1358                            linkBuild.classList.add(e[i].className);
1359                        if (typeof e[i].text !== "undefined")
1360                            linkBuild.innerHTML = e[i].icon.toString() + e[i].text.toString();
1361                        linkFrame.append(linkBuild)
1362                    }
1363                    if ((i) <= setList.length) {
1364                        linkFrame.appendBefore(setList[i - 1])
1365                    } else {
1366                        linkFrame.appendAfter(setList[setList.length - 1])
1367                    }
1368                }
1369            }
1370        }
1371    }
1372};
1373
1374// Page Loaded Functions
1375function onInit() {
1376    setViewportClass();
1377    checkScroll();
1378    setImages();
1379    setProdDescWrapper();
1380    megaMenuLink();
1381}
1382
1383//Set Row Fullwidth
1384function setFullwidth() {
1385    $(document).find('.fullwidth').each(function () {
1386        var topRow = $(this).closest("[id^=row-]");
1387        topRow.addClass('row-fullwidth');
1388    });
1389}
1390
1391// Construct Product Description Dropdown
1392var scrollPane = document.querySelector('.scroller');
1393var ps;
1394if (scrollPane) {
1395    ps = new PerfectScrollbar(scrollPane);
1396}
1397
1398// DOM Ready
1399$(document).ready(function () {
1400    // Custom Filters Blackout
1401    $('#blackout').click(function () {
1402        closeMobileFilters();
1403    });
1404
1405    // Add to cart animation
1406    $("body").on('click', '#addtocartBTXXXXXX', function(event) {
1407        event.preventDefault();
1408
1409        //Doesn't animate on mobile
1410        if ($(window).width() > 480) {
1411            var ql_isbig = false;
1412            if ($(".ql_products_big").length > 0) {
1413                var $imageToMove = $(this).parents(".COMProdContainer").find(".MainProdBox > a").children("img");
1414                ql_isbig = true;
1415            }else{
1416                // var $imageToMove = $(this).parents(".product_thumbnail_wrap").children("img");
1417                var $imageToMove = $(this).parents(".COMProdContainer").find(".MainProdBox > a").children("img");
1418                ql_isbig = true;
1419            }
1420            //if has a second iamge then select that one.
1421            if ($imageToMove.length > 1 && ql_isbig === false) {
1422                $imageToMove = $imageToMove.eq(1);
1423            }else{
1424                $imageToMove = $imageToMove.eq(0);
1425            }
1426            var $parentImage = $imageToMove.parent();
1427            var test = $imageToMove.offset();
1428            var test_width = $imageToMove.width();
1429
1430            //Clon the image to apply changes to that.
1431            var $clonedImage = $imageToMove.clone();
1432            $clonedImage.appendTo("body");
1433            //Position the image in the right place
1434            $clonedImage.css({
1435                position: 'absolute',
1436                top: test.top,
1437                left: test.left
1438            });
1439            $clonedImage.width(test_width);
1440            //get the cart position
1441            var cart_pos = $(".cart-link").offset();
1442            //Start animation
1443            $clonedImage.addClass('ql_item_moving');
1444            $("body").addClass('ql_adding_tocart');
1445            // setTimeout(function(){ $("body").removeClass('ql_adding_tocart'); $clonedImage.remove(); }, 2500);
1446            $clonedImage.css({
1447                top: cart_pos.top - 40,
1448                left: cart_pos.left
1449            });
1450            $clonedImage.width(25);
1451        };
1452
1453    }); //on click add to cart
1454
1455    // Load all page functions
1456    onInit();
1457
1458    // Construct Nav Background Overlay
1459    if (!(stappConfig.cfgMobileBgOverlay === "")) {
1460        $('.nav-side-logo, #topBar').addClass('nav-overlay');
1461    }
1462
1463    // Set Header to Fullwidth
1464    function setHeaderFullwidth() {
1465        $('#header').each(function () {
1466            var topRow = $("[id^=row-]");
1467            if ($(this).closest(topRow).hasClass("row-fullwidth")) {
1468                $(this).addClass('fullwidth');
1469                $(this).closest(topRow).children('.col').removeClass('fullwidth');
1470            }
1471        });
1472    }
1473    setHeaderFullwidth();
1474
1475    // Set Row Fullwidth
1476    setFullwidth();
1477
1478    // Set Mobile Slide-out Menu Header Background Image
1479    if (stappConfig.cfgMobileSideBarBg.length > 1) {
1480        $('.nav-side-logo').css('background-image', 'url("' + stappConfig.cfgMobileSideBarBg + '")');
1481    }
1482
1483    // Update Product Description Dropdown
1484    $('.COMProdDescLink').click(function () {
1485        setTimeout(function () {
1486            if (scrollPane) {
1487                ps.update();
1488            }
1489        }, 300);
1490    });
1491
1492    // URL To Tab
1493    function checkParentEle(target, selector) {
1494        return [target.parentNode].some(function (el) {
1495            return el !== target && el.classList.contains(selector);
1496        });
1497    }
1498
1499    function hashTab() {
1500        if (location.hash.length > 0) {
1501            var a = location.hash.split('#')[1];
1502            if (
1503                a !=="mobileSearch" &&
1504                a !=="categoryFiltered" &&
1505                a !=="Items" &&
1506                a !=="Identity" &&
1507                a !=="ShippingAddress" &&
1508                a !== "PaymentInput" &&
1509                a !== "searchFiltered" &&
1510                a !== "Summary" &&
1511                a !== "openedMenu"
1512            ) {
1513                var b = document.getElementById(a),
1514                    c = b.parentNode,
1515                    d = c.querySelectorAll('.tab-pane'),
1516                    e = document.querySelectorAll('a[href="#' + a + '"]')[0],
1517                    f = e.parentNode,
1518                    g = f.querySelectorAll('[role="tab"]'),
1519                    i, ii;
1520                if (b) {
1521                    if (checkParentEle(b, 'tab-content')) {
1522                        history.pushState("", document.title, window.location.pathname + window.location.search);
1523                        for (i = 0; i < d.length; i++) {
1524                            d[i].classList.remove('active','show');
1525                        }
1526                        for (ii = 0; ii < g.length; ii++) {
1527                            g[ii].setAttribute('aria-selected','false');
1528                            g[ii].classList.remove('active');
1529                        }
1530                        b.classList.add('active','show');
1531                        e.setAttribute('aria-selected','true');
1532                        e.classList.add('active');
1533                    }
1534                }
1535            }
1536        }
1537    }
1538    hashTab();
1539    window.addEventListener("hashchange", hashTab(), false);
1540
1541    // Initialize Slider
1542    slideWrapper.on("init", function (slick) {
1543        slick = $(slick.currentTarget);
1544        setTimeout(function () {
1545            playPauseVideo(slick, "play");
1546        }, 1000);
1547        resizePlayer(iframes, 16 / 9);
1548    });
1549    slideWrapper.on("beforeChange", function (event, slick) {
1550        slick = $(slick.$slider);
1551        playPauseVideo(slick, "pause");
1552    });
1553    slideWrapper.on("afterChange", function (event, slick) {
1554        slick = $(slick.$slider);
1555        playPauseVideo(slick, "play");
1556    });
1557    slideWrapper.on("lazyLoaded", function (event, slick, image, imageSource) {
1558        lazyCounter++;
1559        if (lazyCounter === lazyImages.length) {
1560            lazyImages.addClass('show');
1561            // slideWrapper.slick("slickPlay");
1562        }
1563    });
1564
1565    // Construct Slider
1566    /*if (slideWrapper.hasAttr('data-slider-count')){
1567        var slideCount = slideWrapper.attr('data-slider-count');
1568    } else {
1569        var slideCount = 0;
1570    }*/
1571
1572    slideWrapper.each(function() {
1573        var sliderCenterMode = false,
1574            sliderFocusOnSelect = false;
1575
1576        if (typeof $(this).attr('data-slider-syncnav') !== typeof undefined) {
1577            var slideSyncNav = "." + $(this).attr('data-slider-syncnav');
1578            if (!slideSyncNav.length > 0) {
1579                slideSyncNav = '';
1580            }
1581        }
1582
1583        if (typeof $(this).attr('data-slider-count') !== typeof undefined) {
1584            var slideCountSet = '';
1585            slideCountSet = $(this).attr('data-slider-count');
1586            if (slideCountSet.length > 0) {
1587                slideCountSet = parseInt(slideCountSet);
1588                sliderCenterMode = true;
1589                sliderFocusOnSelect = true;
1590            } else {
1591                slideCountSet = 1;
1592            }
1593        }
1594
1595        if (typeof $(this).attr('data-slider-scroll') !== typeof undefined) {
1596            var slideScrollSet = '';
1597            slideScrollSet = $(this).attr('data-slider-scroll');
1598            if (slideScrollSet.length > 0) {
1599                slideScrollSet = parseInt(slideScrollSet);
1600                sliderCenterMode = true;
1601                sliderFocusOnSelect = true;
1602            } else {
1603                slideScrollSet = 1;
1604            }
1605        }
1606        if (!$(this).hasClass('slick-initialized')) {
1607            $(this).slick({
1608                // fade:true,
1609                slidesToShow: slideCountSet,
1610                slidesToScroll: slideScrollSet,
1611                asNavFor: slideSyncNav,
1612                centerMode: sliderCenterMode,
1613                focusOnSelect: sliderFocusOnSelect,
1614                autoplaySpeed: 4000,
1615                // lazyLoad: "progressive",
1616                pauseOnHover: false,
1617                lazyLoad: 'ondemand',
1618                speed: 600,
1619                arrows: false,
1620                dots: true,
1621                cssEase: "cubic-bezier(0.87, 0.03, 0.41, 0.9)",
1622                responsive: [
1623                    {
1624                        breakpoint: 992,
1625                        settings: {
1626                            adaptiveHeight: true
1627                        }
1628                    }
1629                ]
1630            });
1631        }
1632    });
1633
1634	//original
1635	/*
1636	  $('.minus,.add').on('click', function (inputTarget) {
1637        if ($(this).closest('.COMProdQtyInput').find('input') !== undefined) {
1638            inputTarget = $(this);
1639            var $qty = $(this).closest('.COMProdQtyInput').find('input'),
1640                currentVal = parseInt($qty.val()),
1641                tgtMinus = $(this).closest('.COMProdQtyInput').children('.minus'),
1642                tgtAdd = $(this).closest('.COMProdQtyInput').children('.add'),
1643                qtyMin = parseInt($qty.attr('data-qtyMin')),
1644                qtyMax = parseInt($qty.attr('data-qtyMax')),
1645                qtyInc = parseInt(stprodConfig.cfgPurchaseIncrement),
1646                isAdd = $(this).hasClass('add');
1647
1648            if (qtyMin == 0) { qtyMin = 1 };
1649            if (qtyMin < qtyInc) { qtyMin = qtyInc };
1650            if (isNaN(qtyMax) || qtyMax <= 1) { qtyMax = 100000 };
1651
1652            if (inputTarget.is('[disabled]')) {
1653                event.preventDefault();
1654            }
1655            else {
1656                if ((currentVal - qtyMin) % qtyInc !== 0) {
1657                    var high, low, rem;
1658                    rem = currentVal - qtyMin;
1659                    if (rem < 0) { rem = rem * -1; }
1660                    low = currentVal - (rem % qtyInc);
1661                    high = low + qtyInc;
1662                    if (inputTarget.hasClass("minus")) {
1663                        if (low == 0) { low = 1 }
1664                        if (low > qtyMax) { low = qtyMax }
1665                        $qty.val(low);
1666                    }
1667                    if (inputTarget.hasClass("add")) {
1668                        if (high > qtyMax) { high = qtyMax }
1669                        $qty.val(high);
1670                    }
1671                } else {
1672
1673                    var adjustVal;
1674                    if (qtyInc > 1) {
1675                        adjustVal = parseInt(qtyInc);
1676                    } else {
1677                        adjustVal = 0;
1678                    }
1679
1680                    !isNaN(currentVal) && $qty.val(
1681                        isAdd ? (adjustVal > 1 ? currentVal + adjustVal : ++currentVal) : (currentVal > 0 ? (adjustVal > 1 ? currentVal - adjustVal : --currentVal) : currentVal)
1682                    );
1683
1684                    currentVal = parseInt($qty.val())
1685
1686                    if (currentVal <= qtyMin && qtyMin !== 0) {
1687                        tgtMinus.attr('disabled', '').addClass('noselect');
1688                    } else {
1689                        tgtMinus.removeAttr('disabled').removeClass('noselect');
1690                    }
1691
1692                    if (!isNaN(qtyMax)) {
1693                        if (currentVal >= qtyMax && qtyMax !== 0) {
1694                            tgtAdd.attr('disabled', '').addClass('noselect');
1695                        } else {
1696                            tgtAdd.removeAttr('disabled').removeClass('noselect');
1697                        }
1698                    }
1699                }
1700
1701                UpdateProduct(true);
1702            }
1703
1704            checkQty(tgtMinus, currentVal, qtyMin);
1705        }
1706    });
1707	*/
1708	
1709    // Toggle Quantity Input (delegated so it keeps working after option/variant updates)
1710    $(document).off('click', '.COMProdQtyInput .minus, .COMProdQtyInput .add');
1711    $(document).on('click', '.COMProdQtyInput .minus, .COMProdQtyInput .add', function (e) {
1712
1713        var $wrap = $(this).closest('.COMProdQtyInput');
1714        var $qty = $wrap.find('input');
1715
1716        // No qty input found - nothing to do
1717        if ($qty.length === 0) return;
1718
1719        // Ignore disabled buttons
1720        if ($(this).is('[disabled]')) {
1721            e.preventDefault();
1722            return;
1723        }
1724
1725        var currentVal = parseInt($qty.val(), 10),
1726            tgtMinus = $wrap.children('.minus'),
1727            tgtAdd = $wrap.children('.add'),
1728            qtyMin = parseInt($qty.attr('data-qtyMin'), 10),
1729            qtyMax = parseInt($qty.attr('data-qtyMax'), 10),
1730            qtyInc = parseInt(stprodConfig.cfgPurchaseIncrement, 10),
1731            isAdd = $(this).hasClass('add');
1732
1733        if (isNaN(qtyInc) || qtyInc < 1) { qtyInc = 1; }
1734        if (isNaN(qtyMin) || qtyMin === 0) { qtyMin = 1; }
1735        if (qtyMin < qtyInc) { qtyMin = qtyInc; }
1736        if (isNaN(qtyMax) || qtyMax <= 1) { qtyMax = 100000; }
1737
1738        // If the current value is invalid, start at min
1739        if (isNaN(currentVal)) { currentVal = qtyMin; }
1740
1741        if ((currentVal - qtyMin) % qtyInc !== 0) {
1742            var high, low, rem;
1743            rem = currentVal - qtyMin;
1744            if (rem < 0) { rem = rem * -1; }
1745            low = currentVal - (rem % qtyInc);
1746            high = low + qtyInc;
1747
1748            if ($(this).hasClass("minus")) {
1749                if (low === 0) { low = 1; }
1750                if (low > qtyMax) { low = qtyMax; }
1751                $qty.val(low);
1752            }
1753            if ($(this).hasClass("add")) {
1754                if (high > qtyMax) { high = qtyMax; }
1755                $qty.val(high);
1756            }
1757        } else {
1758
1759            var adjustVal = (qtyInc > 1) ? parseInt(qtyInc, 10) : 0;
1760
1761            if (!isNaN(currentVal)) {
1762                $qty.val(
1763                    isAdd
1764                        ? (adjustVal > 1 ? currentVal + adjustVal : (currentVal + 1))
1765                        : (currentVal > 0 ? (adjustVal > 1 ? currentVal - adjustVal : (currentVal - 1)) : currentVal)
1766                );
1767            }
1768
1769            currentVal = parseInt($qty.val(), 10);
1770
1771            if (currentVal <= qtyMin && qtyMin !== 0) {
1772                tgtMinus.attr('disabled', '').addClass('noselect');
1773            } else {
1774                tgtMinus.removeAttr('disabled').removeClass('noselect');
1775            }
1776
1777            if (!isNaN(qtyMax)) {
1778                if (currentVal >= qtyMax && qtyMax !== 0) {
1779                    tgtAdd.attr('disabled', '').addClass('noselect');
1780                } else {
1781                    tgtAdd.removeAttr('disabled').removeClass('noselect');
1782                }
1783            }
1784        }
1785
1786        UpdateProduct(true);
1787        checkQty(tgtMinus, currentVal, qtyMin);
1788    });
1789
1790    $("#ProductQuantity, .ProductGridSingleQuantity").click(function () {
1791        $(this).select();
1792    });
1793
1794    // Trigger Mobile Menu
1795    var mobileInlineMenuButton = $(document).find('#mainMenu > button');
1796    var mobileInlineMenu = $('#mainMenuNav');
1797
1798    mobileInlineMenuButton.on('click touch', function () {
1799        if ($(this).hasClass('collapsed')) {
1800            $(this).closest('#mainMenu').css('zIndex', '5');
1801            $('#mainMenu').closest('[id^="row-"]').css('zIndex', 'inherit');
1802            $('body').append('<div class="modal-backdrop fade" style="z-index: 4; cursor:pointer;" />');
1803            setTimeout(function () {
1804                $('.modal-backdrop').addClass('show');
1805            }, 0);
1806        } else {
1807            if (mobileInlineMenu.hasClass('show')) {
1808                $(this).closest('#mainMenu').css('zIndex', '');
1809                $('#mainMenu').closest('[id^="row-"]').css('zIndex', '');
1810                $('.modal-backdrop').removeClass('show');
1811                setTimeout(function () {
1812                    $('.modal-backdrop').remove();
1813                }, 200);
1814            }
1815        }
1816    });
1817
1818    // Trigger Modal Close
1819    $(document).on('click touch', function (e) {
1820        var tar = e.target;
1821        if ($(tar).hasClass('modal-backdrop') && !mobileInlineMenu.hasClass('collapsed') && !mobileInlineMenu.hasClass('collapsing')) {
1822            var mobileInlineMenuHeight = $(mobileInlineMenu).height();
1823            mobileInlineMenuButton.addClass('collapsed').attr('aria-expanded', 'false');
1824
1825            mobileInlineMenu.removeClass('collapse').css('height', mobileInlineMenuHeight + 'px').removeClass('show').addClass('collapsing');
1826            mobileInlineMenu.css('height', '0px');
1827            $('.modal-backdrop').removeClass('show');
1828
1829            mobileInlineMenuButton.closest('#mainMenu').css('zIndex', '');
1830
1831            setTimeout(function () {
1832                $('.modal-backdrop').remove();
1833                mobileInlineMenu.css('height', '').removeClass('collapsing').addClass('collapse');
1834            }, 400);
1835        }
1836    });
1837
1838    // Remove document follow on link click with # anchor
1839    $('a[href="#"]:not(#back-to-top)').click(function (e) {
1840        e.preventDefault ? e.preventDefault() : e.returnValue = false;
1841    });
1842
1843    // Photo Modal
1844    var $photoSrc;
1845
1846    $('.photo-btn').click(function () {
1847        $photoSrc = '';
1848        $photoSrc = $(this).attr("image-src");
1849        $('#mediaModal').modal('show');
1850        $('#mediaModal .modal-body').html('<img class="w-100" src="' + $photoSrc + '">')
1851    });
1852/*
1853    // Video Modal
1854    var $videoSrc;
1855
1856    $('.video-btn').click(function() {
1857        $videoSrc = $(this).attr("src");
1858        $('#videoModal').modal('show');
1859    });
1860
1861    $('.video-btn-image').click(function () {
1862        $videoSrc = $(this).attr("video-src");
1863        $('#videoModal').modal('show');
1864    });
1865
1866    $('#videoModal').on('shown.bs.modal', function (e) {
1867        $("#video").attr('src',$videoSrc + "?autoplay=1&amp;loop=0&amp;mute=0&amp;controls=0&amp;enablejsapi=1&amp;rel=0&amp;showinfo=0" );
1868    });
1869    // stop playing the youtube video when closed
1870    $('#videoModal').on('hide.bs.modal', function (e) {
1871        $("#video").attr('src', '../blank.html');
1872        $videoSrc = '';
1873    });*/
1874// Video Modal
1875var $videoSrc = "";
1876
1877// If .video-btn is an <img> thumbnail, DON'T use its src unless it's actually an embed URL.
1878// Leave this handler only if you really have elements where src IS the video URL.
1879$('.video-btn').off('click').on('click', function () {
1880  $videoSrc = $(this).attr("src") || "";
1881  $('#videoModal').modal('show');
1882});
1883
1884$('.video-btn-image').off('click').on('click', function () {
1885  $videoSrc = $(this).attr("video-src") || $(this).data("video-src") || "";
1886  $('#videoModal').modal('show');
1887});
1888
1889$('#videoModal').off('shown.bs.modal').on('shown.bs.modal', function () {
1890  if (!$videoSrc) return;
1891
1892  // If the URL already has ?, append with &; otherwise use ?
1893  var joiner = ($videoSrc.indexOf('?') >= 0) ? '&' : '?';
1894
1895  // IMPORTANT: use real & (NOT &amp;)
1896  var params = "autoplay=1&loop=0&mute=0&controls=1&enablejsapi=1&rel=0&showinfo=0";
1897
1898  $("#video").attr('src', $videoSrc + joiner + params);
1899});
1900
1901// stop playing the youtube video when closed
1902$('#videoModal').off('hide.bs.modal').on('hide.bs.modal', function () {
1903  $("#video").attr('src', 'about:blank'); // or '../blank.html'
1904  $videoSrc = "";
1905});
1906	
1907	
1908	
1909	
1910	
1911
1912    // Back To Top
1913    function backToTop() {
1914        if ($('#back-to-top').length > 0) {
1915            var scrollTrigger = 100,
1916                scrollTop = $(window).scrollTop();
1917            if (scrollTop > scrollTrigger) {
1918                $('#back-to-top').addClass('show');
1919            } else {
1920                $('#back-to-top').removeClass('show');
1921            }
1922        }
1923        /*if ($('#customFiltersWrap.filterMobile #customFiltersToggle').length > 0) {
1924            var scrollTriggerF = 50,
1925                scrollTopF = $(window).scrollTop();
1926            if (scrollTopF > scrollTriggerF) {
1927                $('.mobile #customFiltersToggle').addClass('show');
1928            } else {
1929                $('.mobile #customFiltersToggle').removeClass('show');
1930            }
1931        }*/
1932    }
1933
1934    backToTop();
1935
1936    $(document).on('scroll', function () {
1937        backToTop();
1938    });
1939
1940    $('#back-to-top').on('click', function (e) {
1941        e.preventDefault();
1942        $('html,body').animate({
1943            scrollTop: 0
1944        }, 700);
1945    });
1946
1947});
1948
1949// Go back
1950function goBack() {
1951    window.history.back();
1952}
1953
1954window.onload = function () {
1955    chkoutProductWrapper();
1956};
1957
1958// Set body display when page is ready
1959
1960// Construct hero fullscreen
1961function heroFullcreenInit() {
1962    var yPosition = 0;
1963    // var stage = document.getElementsByClassName('hero-stage')[0];
1964    if (document.getElementsByClassName("mainMenu")[0] !== undefined) {
1965        var stage = document.getElementsByClassName("mainMenu")[0].parentNode;
1966    }
1967
1968    if (typeof stage !== typeof undefined) {
1969        // yPosition += (stage.offsetTop - stage.scrollTop + stage.clientTop);
1970        yPosition += (stage.getBoundingClientRect().height * -1);
1971    }
1972
1973    var navHeight = Math.ceil(yPosition);
1974
1975    if ($('.hero.fullscreen').length) {
1976        $('.hero-stage').css('marginTop', navHeight);
1977        $('.hero-stage.fullscreen').css('position', 'relative');
1978        $('.hero.fullscreen:not(.slider)').css('visibility', 'visible');
1979    }
1980}
1981
1982// May be unnecessary? - Above init function translates better
1983function heroFullcreen() {
1984    heroFullcreenInit();
1985    // var navHeightSet = $('#header').outerHeight();
1986    // var navHeight = Math.ceil((navHeightSet + 2) * -1);
1987    // if ($('.hero.fullscreen').length) {
1988    //     $('.hero-stage').css('marginTop', navHeight);
1989    //     $('.hero-stage.fullscreen').css('position', 'relative');
1990    //     $('.hero.fullscreen:not(.slider)').css('visibility', 'visible');
1991    // }
1992}
1993
1994setTimeout(function () {
1995    heroFullcreenInit();
1996    checkScroll();
1997    setImages();
1998}, 500);
1999
2000setTimeout(function () {
2001    $(document).find('body').css('opacity', '1');
2002}, 500);
2003
2004// Re-initialize functions when resizing window
2005function windowMorphListener() {
2006    if (stappConfig.cfgSubBarInlineUtils == "true") {
2007        $('#navToolbar .nav-ui-inline-util-search').removeClass('show');
2008        $('#navToolbar .nav-ui-inline-util-search .dropdown-menu').removeClass('show');
2009    }
2010
2011    $(slideWrapper).css('transition', 'none');
2012    resizePlayer(iframes, 16 / 9);
2013
2014    setTimeout(function () {
2015        checkPageFilter();
2016        setImages();
2017        $('html').removeAttr('style');
2018        if (stappConfig.cfgFilterDisplay !== "sidebar") {
2019            if (document.body.clientWidth < 576) {
2020                $('#customFiltersWrap').animate({'width': '0px'}, 200);
2021            } else {
2022                $('#customFiltersWrap').removeAttr('style');
2023            }
2024        }
2025        $('#body').removeClass('mobilemodalOpen');
2026        $('#blackout').css({
2027            'opacity':'0',
2028            'pointer-events':'none'
2029        });
2030    }, 200);
2031
2032    setViewportClass();
2033    checkScroll();
2034    setProdDescWrapper();
2035
2036    resetDropdowns();
2037    subMenuConstruct();
2038
2039    chkoutProductWrapper();
2040
2041    setFullwidth();
2042
2043    if ($(window).width() >= 991) {
2044        setTimeout(function () {
2045            heroFullcreen();
2046        }, 300);
2047    }
2048
2049    if (scrollPane) {
2050        ps.update();
2051    }
2052}
2053
2054$("#account-tab a").on("click",function() {
2055    windowMorphListener();
2056});
2057
2058window.addEventListener("orientationchange", function() {
2059    windowMorphListener();
2060});
2061
2062window.addEventListener("resize", function() {
2063    windowMorphListener();
2064}, false);
2065
2066$(document).ready(function() {
2067
2068    heroFullcreenInit();
2069
2070    // Featured Products Slider
2071    $('.featured-slider.featured-products').each(function() {
2072        $(this).slick({
2073            lazyLoad: 'ondemand',
2074            arrows: true,
2075            dots: true,
2076            infinite: true,
2077            slidesToShow: stappConfig.cfgFeaturedCount,
2078            autoplay: (stappConfig.cfgFeaturedAutoPlay === 'true') ? true : false,
2079            autoplaySpeed: 4000,
2080            slidesToScroll: (stappConfig.cfgFeaturedAutoPlay === 'true') ? 1 : stappConfig.cfgFeaturedCount,
2081            initialSlide: (stappConfig.cfgFeaturedRandom === 'true') ? Math.floor(Math.random() * $(this).find('.featured-img').length) : 0,
2082            responsive: [
2083                {
2084                    breakpoint: 992,
2085                    settings: {
2086                        slidesToShow: 3,
2087                        slidesToScroll: 3,
2088                        infinite: true,
2089                        dots: true
2090                    }
2091                },
2092                {
2093                    breakpoint: 768,
2094                    settings: {
2095                        slidesToShow: 2,
2096                        slidesToScroll: 2
2097                    }
2098                },
2099                {
2100                    breakpoint: 576,
2101                    settings: {
2102                        slidesToShow: 1,
2103                        slidesToScroll: 1
2104                    }
2105                }
2106            ]
2107        })
2108    });
2109
2110    // Featured Cart Products Slider
2111    $('.featured-slider.featured-cart-products').each(function () {
2112        $(this).slick({
2113            lazyLoad: 'ondemand',
2114            arrows: true,
2115            dots: true,
2116            infinite: true,
2117            slidesToShow: stappConfig.cfgFeaturedCartCatCount,
2118            autoplay: (stappConfig.cfgFeaturedCartCatAutoPlay === 'true') ? true : false,
2119            autoplaySpeed: 4000,
2120            slidesToScroll: (stappConfig.cfgFeaturedCartCatAutoPlay === 'true') ? 1 : stappConfig.cfgFeaturedCartCatCount,
2121            initialSlide: (stappConfig.cfgFeaturedCartCatRandom === 'true') ? Math.floor(Math.random() * $(this).find('.featured-img').length) : 0,
2122            responsive: [
2123                {
2124                    breakpoint: 992,
2125                    settings: {
2126                        slidesToShow: 3,
2127                        slidesToScroll: 3,
2128                        infinite: true,
2129                        dots: true
2130                    }
2131                },
2132                {
2133                    breakpoint: 768,
2134                    settings: {
2135                        slidesToShow: 2,
2136                        slidesToScroll: 2
2137                    }
2138                },
2139                {
2140                    breakpoint: 576,
2141                    settings: {
2142                        slidesToShow: 1,
2143                        slidesToScroll: 1
2144                    }
2145                }
2146            ]
2147        })
2148    });
2149
2150    //Featured Categories Slider
2151    $('.featured-slider.featured-categories').each(function () {
2152        $(this).slick({
2153            lazyLoad: 'ondemand',
2154            arrows: true,
2155            dots: true,
2156            infinite: true,
2157            slidesToShow: stappConfig.cfgFeaturedShopCount,
2158            autoplay: (stappConfig.cfgFeaturedShopAutoPlay === 'true') ? true : false,
2159            autoplaySpeed: 4000,
2160            slidesToScroll: (stappConfig.cfgFeaturedShopAutoPlay === 'true') ? 1 : stappConfig.cfgFeaturedShopCount,
2161            initialSlide: (stappConfig.cfgFeaturedShopRandom === 'true') ? Math.floor(Math.random() * $(this).find('.featured-img').length) : 0,
2162            responsive: [
2163                {
2164                    breakpoint: 992,
2165                    settings: {
2166                        slidesToShow: 3,
2167                        slidesToScroll: 3,
2168                        infinite: true,
2169                        dots: true
2170                    }
2171                },
2172                {
2173                    breakpoint: 768,
2174                    settings: {
2175                        slidesToShow: 2,
2176                        slidesToScroll: 2
2177                    }
2178                },
2179                {
2180                    breakpoint: 576,
2181                    settings: {
2182                        slidesToShow: 1,
2183                        slidesToScroll: 1
2184                    }
2185                }
2186            ]
2187        })
2188    });
2189
2190    // Featured Products Slider Two
2191    $('.featured-slider.featured-products-two').each(function () {
2192        $(this).slick({
2193            lazyLoad: 'ondemand',
2194            arrows: true,
2195            dots: true,
2196            infinite: true,
2197            slidesToShow: stappConfig.cfgFeaturedCountTwo,
2198            autoplay: (stappConfig.cfgFeaturedAutoPlayTwo === 'true') ? true : false,
2199            autoplaySpeed: 4000,
2200            slidesToScroll: (stappConfig.cfgFeaturedAutoPlayTwo === 'true') ? 1 : stappConfig.cfgFeaturedCountTwo,
2201            initialSlide: (stappConfig.cfgFeaturedRandomTwo === 'true') ? Math.floor(Math.random() * $(this).find('.featured-img').length) : 0,
2202            responsive: [
2203                {
2204                    breakpoint: 992,
2205                    settings: {
2206                        slidesToShow: 3,
2207                        slidesToScroll: 3,
2208                        infinite: true,
2209                        dots: true
2210                    }
2211                },
2212                {
2213                    breakpoint: 768,
2214                    settings: {
2215                        slidesToShow: 2,
2216                        slidesToScroll: 2
2217                    }
2218                },
2219                {
2220                    breakpoint: 576,
2221                    settings: {
2222                        slidesToShow: 1,
2223                        slidesToScroll: 1
2224                    }
2225                }
2226            ]
2227        })
2228    });
2229
2230    // Featured Products Slider Three
2231    $('.featured-slider.featured-products-three').each(function () {
2232        $(this).slick({
2233            lazyLoad: 'ondemand',
2234            arrows: true,
2235            dots: true,
2236            infinite: true,
2237            slidesToShow: stappConfig.cfgFeaturedCountThree,
2238            autoplay: (stappConfig.cfgFeaturedAutoPlayThree === 'true') ? true : false,
2239            autoplaySpeed: 4000,
2240            slidesToScroll: (stappConfig.cfgFeaturedAutoPlayThree === 'true') ? 1 : stappConfig.cfgFeaturedCountThree,
2241            initialSlide: (stappConfig.cfgFeaturedRandomThree === 'true') ? Math.floor(Math.random() * $(this).find('.featured-img').length) : 0,
2242            responsive: [
2243                {
2244                    breakpoint: 992,
2245                    settings: {
2246                        slidesToShow: 3,
2247                        slidesToScroll: 3,
2248                        infinite: true,
2249                        dots: true
2250                    }
2251                },
2252                {
2253                    breakpoint: 768,
2254                    settings: {
2255                        slidesToShow: 2,
2256                        slidesToScroll: 2
2257                    }
2258                },
2259                {
2260                    breakpoint: 576,
2261                    settings: {
2262                        slidesToShow: 1,
2263                        slidesToScroll: 1
2264                    }
2265                }
2266            ]
2267        })
2268    });
2269	if($.fn.slick){
2270    // Related Slider Construct
2271    $('#related-wrap').slick({
2272        lazyLoad: 'ondemand',
2273        arrows: true,
2274        dots: false,
2275        infinite: true,
2276        slidesToShow: stappConfig.cfgProductRelatedCount,
2277        autoplay: false,
2278        autoplaySpeed: 2000,
2279        //slidesToScroll: stappConfig.cfgProductRelatedCount,
2280        responsive: [
2281            {
2282                breakpoint: 992,
2283                settings: {
2284                    slidesToShow: 3,
2285                    slidesToScroll: 3,
2286                    infinite: true,
2287                    dots: true
2288                }
2289            },
2290            {
2291                breakpoint: 768,
2292                settings: {
2293                    slidesToShow: 2,
2294                    slidesToScroll: 2
2295                }
2296            },
2297            {
2298                breakpoint: 576,
2299                settings: {
2300                    slidesToShow: 1,
2301                    slidesToScroll: 1
2302                }
2303            }
2304        ]
2305    });
2306
2307    // Recently Viewed Slider Construct
2308    $('#recently-viewed-wrap').slick({
2309        lazyLoad: 'ondemand',
2310        arrows: true,
2311        dots: false,
2312        infinite: true,
2313        slidesToShow: stappConfig.cfgProductRelatedCount,
2314        autoplay: false,
2315        autoplaySpeed: 2000,
2316        //slidesToScroll: stappConfig.cfgProductRelatedCount,
2317        responsive: [
2318            {
2319                breakpoint: 992,
2320                settings: {
2321                    slidesToShow: 3,
2322                    slidesToScroll: 3,
2323                    infinite: true,
2324                    dots: true
2325                }
2326            },
2327            {
2328                breakpoint: 768,
2329                settings: {
2330                    slidesToShow: 2,
2331                    slidesToScroll: 2
2332                }
2333            },
2334            {
2335                breakpoint: 576,
2336                settings: {
2337                    slidesToShow: 1,
2338                    slidesToScroll: 1
2339                }
2340            }
2341        ]
2342    });
2343}
2344    // Category Pagination
2345    $(document).find('#pageStatus a').on('click',function(e){
2346        //console.log('hit')
2347        var a = $('#pageStatus .current > a').position().left;
2348        $('.pagination-bar').css({'left': a+'px'})
2349    })
2350
2351
2352    //Loader Hide
2353    $("#loaderContainer").hide().addClass('hiddenLC');
2354    $('body').removeClass('loaderActive'); 
2355
2356});
2357
2358
2359if(document.getElementById) {
2360	window.alert = function(txt) {
2361		createCustomAlert(txt);
2362	}
2363}
2364
2365function createCustomAlert(txt) {
2366	var d = document;
2367
2368	if(d.getElementById("modalAlertContainer")) return;
2369
2370	var mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
2371	mObj.id = "modalAlertContainer";
2372	mObj.style.height = d.documentElement.scrollHeight + "px";
2373	
2374	var alertObj = mObj.appendChild(d.createElement("div"));
2375	alertObj.id = "alertBox";
2376	if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
2377	alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";
2378	alertObj.style.visiblity="visible";
2379
2380	var msg = alertObj.appendChild(d.createElement("p"));
2381	msg.innerHTML = txt;
2382
2383	var btn = alertObj.appendChild(d.createElement("a"));
2384	btn.id = "closeBtn";
2385    btn.className = "FormButtons btn btn-primary"
2386	btn.appendChild(d.createTextNode("OK"));
2387	btn.href = "#";
2388	btn.focus();
2389	btn.onclick = function() { removeCustomAlert();return false; }
2390
2391	alertObj.style.display = "block";
2392	
2393}
2394
2395function removeCustomAlert() {
2396	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalAlertContainer"));
2397}
2398
2399function setiframesize(iframeid) {
2400    $("#" + iframeid).css("height", document.getElementById(iframeid).contentWindow.document.body.scrollHeight + "px");
2401}

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.