PageSourceSearch

https://blackrivercheese.com/wp-content/themes/brc_theme/js/scripts.js?ver=1.2

js blackrivercheese.com collected 2026-09-26 12:56:19 UTC 64,006 bytes, 2,557 lines download raw bytes

1var searchTimer;
2var newScroll;
3var tInterval = 5;
4var yInterval = 10;
5var maxScroll;
6var currentWinWidth;
7var pageLocation;
8var currentTouch;
9var boxGroup;
10
11$(function () {
12
13    currentWinWidth = $(window).width();
14
15    $(window).resize(function () {
16        slideSizeInit();
17        footerMenuInit();
18
19
20        if ($(window).width() != currentWinWidth) {
21            currentWinWidth = $(window).width();
22            boxesInit();
23        }
24
25        recipeSearchInit();
26        matchRecipeCols();
27        newsBoxAdjust();
28        matchCols();
29        mobScroll();
30
31    });
32
33    $('#search-button').click(function () {
34
35        $('#top-nav input').focus();
36        $('#top-nav input').addClass('active');
37
38        if (!$(this).hasClass('ready')) {
39            $(this).addClass('ready');
40        } else {
41            $('#top-nav form.search').submit();
42        }
43
44    });
45
46    $('#recipe-search-button').click(function () {
47        $(this).blur();
48    });
49
50    $('#top-nav input').blur(function () {
51        //$(this).removeClass('active');
52    });
53
54    $('.mob-menu-open').click(function () {
55        $('#mob-top-nav').fadeIn('fast');
56    });
57
58    $(".back-to-top").click(function () {
59        $(window).scrollTop(0);
60    });
61
62    $('#mob-top-nav .close-menu').click(function () {
63        $('#mob-top-nav').fadeOut('fast');
64    });
65
66    $('#search-button-mob').click(function () {
67
68        var space = $(window).width() - $('#mob-top-nav .close-menu').outerWidth() - $('#mob-top-nav .mob-top-nav-container').outerWidth() + 20;
69
70        $('#mob-top-nav input').focus();
71        $('#mob-top-nav input').addClass('active');
72        $('#mob-top-nav input').css('width', space + 'px');
73
74        if (!$(this).hasClass('ready')) {
75            $(this).addClass('ready');
76        } else {
77            $('#mob-top-nav form.search').submit();
78        }
79
80    });
81
82    $('#mob-top-nav>ul>li>a').click(function () {
83
84        var listHeight = 0;
85        var subActive;
86
87        $(this).parent().siblings('li').each(function () {
88
89            if ($(this).find('li.active').length > 0) {
90                subActive = $(this).find('li.active');
91                subActive.removeClass('active');
92                subActive.children('ul').css('height', '0px')
93            }
94
95            $(this).removeClass('active');
96            $(this).children('ul').css('height', '0px');
97
98        });
99
100
101        if (!$(this).parent().hasClass('active')) {
102
103            $(this).parent().addClass('active');
104            $(this).siblings('ul').children().each(function () {
105
106                listHeight += $(this).outerHeight();
107
108            });
109
110            $(this).siblings('ul').css('height', listHeight + 'px');
111
112        } else {
113
114            $(this).parent().removeClass('active');
115            $(this).siblings('ul').css('height', '0px');
116
117        }
118
119    });
120
121
122
123
124    //New ing
125    $("select#add-new-ing").click(function (e) {
126        addNewIng(e);
127    });
128
129
130    $('#mob-top-nav>ul li ul li h5 a').click(function () {
131        openMobMenuInner(this);
132    });
133
134    $('#mob-top-nav>ul li ul li>span').click(function () {
135        openMobMenuInner($(this).siblings('h5').children('a'));
136    });
137
138    $('#footer-nav .footer-nav-container h3').click(function () {
139
140        var listHeight = 0;
141
142        $(this).parent().siblings('li').each(function () {
143
144            $(this).removeClass('active');
145            $(this).children('ul').css('height', '0px');
146
147        });
148
149        $(this).siblings('ul').children().each(function () {
150
151            listHeight += $(this).outerHeight();
152
153        });
154
155        if (!$(this).parent().hasClass('active')) {
156            $(this).siblings('ul').css('height', listHeight + 'px');
157            $(this).parent().addClass('active');
158        } else {
159            $(this).parent().removeClass('active');
160            $(this).siblings('ul').css('height', '0px');
161        }
162
163
164    });
165
166    $("#homeCarousel").on('slid.bs.carousel', function () {
167        if ($('#homeCarousel .item.active').hasClass('invert')) {
168            $('ol.carousel-indicators').addClass('invert');
169        } else {
170            $('ol.carousel-indicators').removeClass('invert');
171        }
172    });
173
174    if ($('#homeCarousel')[0]) {
175
176        $('#homeCarousel')[0].addEventListener("touchstart", handleStart);
177        $('#homeCarousel')[0].addEventListener("touchend", handleEnd);
178
179    }
180
181    $(".products-details-boxes a").click(function () {
182
183        productBoxClick(this, false);
184
185    });
186
187    $('.product-detail-panel-container .close-panel').click(function () {
188        $(".products-details-boxes a").parent().removeClass('active');
189        $('.product-detail-panel').height(0);
190    });
191
192    $('.recipe-rating').mousemove(function (e) {
193
194        var offset = $(this).offset();
195        var per = (e.pageX - offset.left - 3) / 194;
196
197        if (!$(this).hasClass('sending') && !$(this).hasClass('rated')) {
198            $(this).attr('class', 'recipe-rating');
199
200            if (per < 0.02) {
201                $(this).addClass('no-stars');
202            } else if (per < 0.12) {
203                $(this).addClass('half-stars');
204            } else if (per < 0.22) {
205                $(this).addClass('one-stars');
206            } else if (per < 0.32) {
207                $(this).addClass('one-half-stars');
208            } else if (per < 0.42) {
209                $(this).addClass('two-stars');
210            } else if (per < 0.52) {
211                $(this).addClass('two-half-stars');
212            } else if (per < 0.62) {
213                $(this).addClass('three-stars');
214            } else if (per < 0.72) {
215                $(this).addClass('three-half-stars');
216            } else if (per < 0.82) {
217                $(this).addClass('four-stars');
218            } else if (per < 0.92) {
219                $(this).addClass('four-half-stars');
220            } else {
221                $(this).addClass('five-stars');
222            }
223
224        }
225
226    });
227
228    $('.recipe-rating').mouseleave(function () {
229
230        var rating = $(this).attr('data-rating');
231
232        if (!$(this).hasClass('sending') && !$(this).hasClass('rated')) {
233            $(this).attr('class', 'recipe-rating');
234            $(this).addClass(rating);
235        }
236
237
238    });
239
240    $('.recipe-rating').click(function (e) {
241
242        var offset = $(this).offset();
243        var recipeID = $(this).attr('data-id');
244        var per = (e.pageX - offset.left - 3) / 194;
245        var userRating;
246
247        if (!$(this).hasClass('sending') && !$(this).hasClass('rated')) {
248
249            if (per < 0.02) {
250                $(this).attr('data-rating', 'no-stars');
251                userRating = 0;
252            } else if (per < 0.12) {
253                $(this).attr('data-rating', 'half-stars');
254                userRating = 0.5;
255            } else if (per < 0.22) {
256                $(this).attr('data-rating', 'one-stars');
257                userRating = 1;
258            } else if (per < 0.32) {
259                $(this).attr('data-rating', 'one-half-stars');
260                userRating = 1.5;
261            } else if (per < 0.42) {
262                $(this).attr('data-rating', 'two-stars');
263                userRating = 2;
264            } else if (per < 0.52) {
265                $(this).attr('data-rating', 'two-half-stars');
266                userRating = 2.5;
267            } else if (per < 0.62) {
268                $(this).attr('data-rating', 'three-stars');
269                userRating = 3;
270            } else if (per < 0.72) {
271                $(this).attr('data-rating', 'three-half-stars');
272                userRating = 3.5;
273            } else if (per < 0.82) {
274                $(this).attr('data-rating', 'four-stars');
275                userRating = 4;
276            } else if (per < 0.92) {
277                $(this).attr('data-rating', 'four-half-stars');
278                userRating = 4.5;
279            } else {
280                $(this).attr('data-rating', 'five-stars');
281                userRating = 5;
282            }
283
284            //send rating
285
286            $('.recipe-rating').addClass('sending');
287
288            $.ajax({
289                type: 'POST',
290                url: MyAjax.ajaxurl,
291                async: true,
292                data: {
293                    action: 'rate_recipe',
294                    recipe_rating: userRating,
295                    recipe_id: recipeID
296                }
297            }).done(function (data) {
298
299
300                $('.recipe-rating').removeClass('sending');
301                $('.recipe-rating').addClass('rated');
302
303
304            });
305
306        }
307
308    });
309
310    $('a.video-thumb').click(function () {
311        var vID = $(this).attr('data-vid');
312        var href = $(this).attr('data-href');
313
314        $('#vid-container .view-all-btn a').attr('href', href);
315        $('#vid-popout-mask').fadeIn('fast');
316
317        player = new YT.Player('ytplayer', {
318            height: '270',
319            width: '480',
320            videoId: vID,
321            playerVars: {
322                rel: 0
323            }
324        });
325
326    });
327
328    $('.vid-placeholder').click(function () {
329        $(this).remove();
330        landingPlayer.playVideo();
331    });
332
333    $('#vid-container').click(function (e) {
334        e.stopPropagation();
335    });
336
337    $('#vid-popout-mask').click(function () {
338        closeVideo();
339    });
340
341    $('#vid-close').click(function () {
342        closeVideo();
343    });
344
345    $('#createsend-subscribe input#input-email-top').keydown(function () {
346        $('#createsend-subscribe .email-format-err').fadeOut('fast');
347    });
348
349
350    $('.view-more-search-results').click(function () {
351
352        var page = $('.search-results-set.hidden').first();
353
354        $(this).fadeOut();
355
356        $(page).removeClass('hidden');
357    });
358
359    $('.search-form-container button').click(function () {
360        $('.search-results-container').addClass('updating');
361    });
362
363    $('.search-icon').click(function () {
364        $('#mod-searchsearchword').focus();
365    });
366
367
368
369    $('#xxxcontact-form form').submit(function (e) {
370
371        var rx = /^[\w\.-]+@[\w\.-]+\.\w+$/i;
372        var emailInput = $('#contact-form input[name=email]');
373        var fnameInput = $('#contact-form input[name=first_name]');
374        var lnameInput = $('#contact-form input[name=last_name]');
375        var rcapInput = $('#contact-form input[name=rcap]');
376        var comment = $('textarea#comment_ta');
377        var cat = $('#contact-form select[name=contact_cat]');
378        var prod = $('#contact-form select[name=product_sub_cat]');
379        var valid = true;
380
381
382        $('#contact-form .alert-danger').hide();
383
384        if (!rx.test(emailInput.val())) {
385
386            $('#contact-form .alert-danger').show();
387            emailInput.addClass('has-error');
388            valid = false;
389
390        }
391
392        if (fnameInput.val() == '') {
393
394            $('#contact-form .alert-danger').show();
395            fnameInput.addClass('has-error');
396            valid = false;
397
398        }
399
400        if (lnameInput.val() == '') {
401
402            $('#contact-form .alert-danger').show();
403            lnameInput.addClass('has-error');
404            valid = false;
405
406        }
407
408        if (comment.val() == '') {
409
410            $('#contact-form .alert-danger').show();
411            comment.addClass('has-error');
412            valid = false;
413
414        }
415
416        if (cat.val() == 'product_question' && prod.val() == null) {
417
418            $('#contact-form .alert-danger').show();
419            prod.addClass('has-error');
420            valid = false;
421
422        }
423
424        if (valid) {
425
426            grecaptcha.ready(function () {
427                valid = false;
428                grecaptcha.execute('6LdUCeghAAAAAJSWNcDnK0PoTycmTzgY_m7jPJ7o', {action: 'BRCsubmit'}).then(function (token) {
429                    rcapInput.val(token);
430                    valid = true;
431                });
432            });
433
434        }
435
436
437        if (!valid) { //
438
439            e.preventDefault();
440
441        } else {
442
443            $('.sending-data').show('fast');
444            $('#contact-form button').hide('fast');
445
446        }
447
448
449    });
450
451    $('#contact-form input, #contact-form textarea, #contact-form select').focus(function () {
452        $(this).removeClass('has-error');
453    });
454
455    $('#contact-form-landing form').submit(function (e) {
456
457        var rx = /^[\w\.-]+@[\w\.-]+\.\w+$/i;
458        var emailInput = $('#contact-form-landing input[name=email]');
459        var fnameInput = $('#contact-form-landing input[name=first_name]');
460        var lnameInput = $('#contact-form-landing input[name=last_name]');
461
462        var sector = $('#contact-form-landing select[name=health_sector]');
463        var prov = $('#contact-form-landing select[name=state_prov]');
464        var lang = $('#contact-form-landing select[name=lang_pref]');
465
466        var valid = true;
467
468        $('#contact-form-landing .alert-danger').hide();
469
470        if (!rx.test(emailInput.val())) {
471
472            $('#contact-form-landing .alert-danger').show();
473            emailInput.addClass('has-error');
474            valid = false;
475
476        }
477
478        if (fnameInput.val() == '') {
479
480            $('#contact-form-landing .alert-danger').show();
481            fnameInput.addClass('has-error');
482            valid = false;
483
484        }
485
486        if (lnameInput.val() == '') {
487
488            $('#contact-form-landing .alert-danger').show();
489            lnameInput.addClass('has-error');
490            valid = false;
491
492        }
493
494        if (sector.val() == null) {
495
496            $('#contact-form-landing .alert-danger').show();
497            sector.addClass('has-error');
498            valid = false;
499
500        }
501
502        if (prov.val() == null) {
503
504            $('#contact-form-landing .alert-danger').show();
505            prov.addClass('has-error');
506            valid = false;
507
508        }
509
510        if (lang.val() == null) {
511
512            $('#contact-form-landing .alert-danger').show();
513            lang.addClass('has-error');
514            valid = false;
515
516        }
517
518        if (grecaptcha.getResponse() == '') {
519
520            $('#recaptcha-error.alert-danger').show('fast');
521            valid = false;
522
523        } else {
524
525            $('#recaptcha-error.alert-danger').hide('fast');
526
527        }
528
529        if (!valid) { //
530
531            e.preventDefault();
532
533        }
534
535    });
536
537    $('#contact-form-landing input, #contact-form-landing textarea, #contact-form-landing select').focus(function () {
538        $(this).removeClass('has-error');
539    });
540
541
542    $('select[name=contact_cat]').change(function () {
543
544        var cat = $(this).val();
545
546        if (cat == 'product_question') {
547
548            $('#prod-extras').show('fast');
549
550
551        } else {
552
553            $('#prod-extras').hide('fast');
554
555        }
556
557        setTimeout(function () {
558            jfn.initPanels();
559        }, 500);
560
561    });
562
563    $('.n-anchor').click(function (e) {
564
565        anchorBind(e, this);
566
567    });
568
569    slideSizeInit();
570    footerMenuInit();
571    mobScroll();
572
573    if ($('body.scroll-check').length > 0) {
574        $(window).scroll(function () {
575            newsScroll();
576        });
577    }
578
579    $(window).scroll(function () {
580        mobScroll();
581    });
582
583    $('#apply-hub li').click(function () {
584
585        panelExpand(this, true);
586
587    });
588
589    $('#reports-hub li').click(function () {
590
591        panelExpand(this, false);
592
593    });
594
595    $('.faq-content>ul>li').click(function (e) {
596
597        panelExpand(this, true);
598
599    });
600
601    $('#faq-main li').each(function () {
602
603        if ($(this).hasClass('pre-open')) {
604            panelExpand(this, true);
605        }
606
607    });
608
609    $('#map-container li.expandable').click(function () {
610
611        panelExpand(this, false);
612
613    });
614
615
616    $('#map-container ul a').click(function (e) {
617        e.stopPropagation();
618        mapLocate(this, $(this).attr('data-loc'));
619    });
620
621    $('.recent-issues h3').click(function () {
622
623        var panelHeight = 0;
624        var panel = $(this).siblings('.expandable-panel');
625
626        panelHeight += panel.children('ul').outerHeight() + 10;
627
628        if (!$(this).hasClass('active')) {
629            panel.css('height', panelHeight + 'px');
630            $(this).addClass('active');
631        } else {
632            $(this).removeClass('active');
633            panel.css('height', '0px');
634        }
635
636
637    });
638
639    $('.email-share').click(function () {
640        emailShare(this);
641    });
642
643    $('#load-more-news').click(function () {
644        getNews(this);
645    });
646
647    $('#custom-share a').click(function () {
648
649
650        var url = window.location;
651
652        FB.ui(
653                {
654                    method: 'share',
655                    href: url,
656                },
657                //callback
658
659                        function (response) {
660                            if (response && !response.error_message) {
661
662                                //
663
664                            } else {
665                                //
666                            }
667                        }
668                );
669
670            });
671
672    $('select#country').change(function () {
673
674        var country = $(this).val();
675
676        $('select#state_prov option').each(function () {
677
678            var spIn = $(this).attr('data-country');
679
680            if (spIn == country) {
681                $(this).removeClass('hidden');
682            } else {
683                $(this).addClass('hidden');
684            }
685
686        });
687
688    });
689
690
691    // $("#date").datepicker();
692
693    $('.amount-validate').keyup(function () {
694        validateAmt(this);
695    });
696
697    boxesInit();
698    recipeSearchInit();
699    carouselTextInit();
700    calcSubtotals();
701
702    setTimeout(function () {
703        matchRecipeCols();
704        matchCols();
705    }, 1000);
706
707    carouselTextInit();
708
709    setTimeout(function () {
710        preOpenProduct();
711        scrollViewInit();
712    }, 1000);
713
714    //updateRecipeFilters($('#all-recipes-filter').prop('checked'));
715
716    setTimeout(function () {
717        newsBoxAdjust();
718    }, 500);
719
720    window.onpopstate = function (e) {
721        productSubNav(e);
722    };
723
724    navDropdownCount();
725
726
727});
728
729
730function slideSizeInit() {
731
732    var itemH;
733    var itemW = $('.carousel-inner').outerWidth();
734    var winH = $(window).height();
735    var mastH = $('#homeCarousel').offset();
736    var newPad, aRatio;
737
738    if (typeof mastH !== 'undefined') {
739
740        if (itemW < 768) {
741
742            newPad = (winH - mastH.top) / itemW * 100;
743            $('.carousel-inner .item').css('padding-bottom', newPad + '%');
744
745            itemH = $('.carousel-inner').outerHeight();
746
747            aRatio = itemH / itemW;
748
749            if (aRatio > 0.4) {
750                $('#homeCarousel').addClass('full-height');
751                $('#homeCarousel').removeClass('full-width');
752            } else {
753                $('#homeCarousel').removeClass('full-height');
754                $('#homeCarousel').addClass('full-width');
755            }
756
757
758
759        } else {
760            $('.carousel-inner .item').removeAttr('style');
761            $('#homeCarousel').removeClass('full-height');
762            $('#homeCarousel').addClass('full-width');
763        }
764
765        if (aRatio > 0.5) {
766            $('#homeCarousel').addClass('portrait');
767            $('#homeCarousel').removeClass('landscape');
768        } else {
769            $('#homeCarousel').addClass('landscape');
770            $('#homeCarousel').removeClass('portrait');
771        }
772
773    }
774
775
776}
777
778function footerMenuInit() {
779
780    var winH = $(window).width();
781    var href;
782
783    if (winH > 480) {
784
785        $('#footer-nav ul').removeAttr('style');
786
787    }
788
789    $('#footer-nav h3 a').each(function () {
790
791        if (winH <= 480) {
792
793            $('#footer-nav h3 a').attr('href', 'javascript:void(0)');
794
795        } else {
796
797            href = $(this).attr('data-href');
798
799            $(this).attr('href', href);
800
801        }
802
803    });
804
805}
806
807function tintCols() {
808
809    var winH = $(window).width();
810    var href;
811    var content;
812    var s_elem;
813    var a;
814
815
816    if (winH <= 736) {
817
818        content = '<div class="tintup" data-id="gayleasocialhub" data-columns="2" data-count="4" data-mobilescroll="true" data-clickformore="false" data-infinitescroll="false" data-paginate="true" data-noButtons="true" data-expand="true" data-personalization-id="855498"></div>';
819
820        if (typeof s_elem === 'undefined') {
821            s_elem = $('#t_emb');
822            a = document.createElement('script');
823            a.async = 1;
824            a.src = "https://cdn.hypemarks.com/pages/a5b5e5.js";
825            s_elem[0].parentNode.insertBefore(a, s_elem[0]);
826
827        }
828
829
830        $('#tint-container').html(content);
831
832        if (typeof HM === 'undefined') {
833            //
834        } else {
835            HM.render();
836        }
837
838
839    } else {
840
841        content = '<div class="tintup" data-id="gayleasocialhub" data-columns="4" data-count="4" data-mobilescroll="true" data-clickformore="false" data-infinitescroll="false" data-paginate="false" data-noButtons="true" data-expand="true" data-personalization-id="855498"></div>';
842
843        $('#tint-container').html(content);
844
845        if (typeof s_elem === 'undefined') {
846            s_elem = $('#t_emb');
847            a = document.createElement('script');
848            a.async = 1;
849            a.src = "https://cdn.hypemarks.com/pages/a5b5e5.js";
850            s_elem[0].parentNode.insertBefore(a, s_elem[0]);
851
852        }
853
854        if (typeof HM === 'undefined') {
855            //
856        } else {
857            //HM.init()
858            HM.render();
859        }
860
861    }
862
863}
864
865function productBoxClick(e, np) {
866
867    var rowCount = 0;
868    var colCount = 0;
869    var vertOffset = 0;
870    var currentOffset;
871    var firstRowCols = 0;
872    var targetRow;
873    var clones = [];
874    var firstParentOffset;
875    var currentParentOffset;
876    var currentPanelRow;
877    var boxCount = 0;
878    var rowHeight = 0;
879    var currentScroll;
880    var dir;
881    var scrollReduce = 0;
882    var scrollCorrect = 0;
883    var panelHeight;
884    var panelHTML;
885    var boxCollection;
886    var eID;
887    var activeOffset = $(e).parent().offset();
888    var rx = /.+\/(products|produits|employment|commitment|ingredients|ingredients-fr|about-gay-lea|notre-cooperative|engagement-social|carrieres)\/[\w-]+\//;
889    var basePath = rx.exec(window.location.href);
890
891    boxGroup = $(e).attr('data-group');
892
893    if (typeof boxGroup == 'undefined') {
894        boxGroup = '';
895    } else {
896        boxGroup = '.' + boxGroup;
897    }
898
899    boxCollection = $('.products-details-boxes' + boxGroup + ' > div');
900
901
902    //shrink the detail panel
903
904    //$('.product-detail-panel').height(0);
905
906    if (!basePath) {
907        //console.log(basePath);
908    }
909
910    if (!$(e).parent().hasClass('active')) {
911
912        $('.products-details-boxes' + boxGroup + ' a').parent().removeClass('active');
913
914        $(e).parent().addClass('active');
915        panelHTML = $(e).siblings().html();
916        $('.details-target-wrapper' + boxGroup).html(panelHTML);
917
918        $('.details-target-wrapper' + boxGroup + ' a.n-anchor').click(function (e) {
919            anchorBind(e, this);
920        });
921
922        if (!np && basePath) {
923            eID = $(e).parent().attr('id');
924            history.pushState('state', "", basePath[0] + eID.replace('det-', '') + '/');
925        }
926
927
928        $(boxCollection).each(function () {
929
930            boxCount++;
931
932            currentOffset = $(this).offset();
933            currentParentOffset = $(this).parent().offset();
934
935            if (!firstParentOffset) {
936
937                firstParentOffset = currentParentOffset;
938                rowHeight = $(this).outerHeight();
939
940            }
941
942
943            if (currentOffset.top > vertOffset) {
944
945                rowCount++;
946                vertOffset = currentOffset.top;
947                colCount = 1;
948
949
950            } else {
951                colCount++;
952            }
953
954            if (activeOffset.top == currentOffset.top) {
955                targetRow = rowCount;
956            }
957
958            if (rowCount == 1) {
959                firstRowCols++;
960            }
961
962            if (!currentPanelRow && currentParentOffset.top > firstParentOffset.top) {
963
964                //this is the lower section
965                currentPanelRow = rowCount - 1;
966
967            }
968
969        });
970
971
972        if (!currentPanelRow) {
973            currentPanelRow = rowCount;
974        }
975
976        if (targetRow != currentPanelRow) {
977
978
979            //we need to do the shift
980            var i = 0;
981            var j;
982            var insertPoint = targetRow * firstRowCols;
983
984            var sections = $('.products-details-boxes' + boxGroup);
985            var targetSection;
986
987            if (insertPoint > boxCollection.length) {
988                insertPoint = boxCollection.length;
989            }
990
991
992            if (targetRow < currentPanelRow) {
993
994                //shiftdown
995
996                targetSection = sections[1];
997
998                $(boxCollection).each(function () {
999
1000                    i++;
1001
1002                    if (i > insertPoint) {
1003
1004                        clones.push($(this).clone());
1005                        $(this).remove();
1006
1007                    }
1008
1009                });
1010
1011                for (j in clones) {
1012
1013                    $(targetSection).append(clones[j]);
1014                    $(clones[j]).click(function () {
1015                        productBoxClick(this, false);
1016                    });
1017                }
1018
1019
1020            } else {
1021
1022                //shiftup
1023
1024                i = currentPanelRow * firstRowCols;
1025
1026                targetSection = sections[0];
1027
1028                $(sections[1]).children().each(function () {
1029
1030                    i++;
1031
1032                    if (i <= insertPoint) {
1033
1034                        clones.push($(this).clone());
1035                        $(this).remove();
1036
1037                    }
1038
1039
1040                });
1041
1042                for (j in clones) {
1043
1044                    $(targetSection).append(clones[j]);
1045
1046                }
1047
1048                scrollReduce = $('.product-detail-panel' + boxGroup).outerHeight();
1049                scrollCorrect = scrollReduce;
1050
1051            }
1052
1053
1054        }
1055
1056        //show panel
1057        currentScroll = $(window).scrollTop();
1058        //initial scroll correct
1059        $(window).scrollTop(currentScroll - scrollCorrect);
1060        currentScroll = $(window).scrollTop();
1061
1062        //panelHeight = $('.product-detail-panel-container' + boxGroup).outerHeight();
1063        //$('.product-detail-panel' + boxGroup).height(panelHeight);
1064
1065        setTimeout(function () {
1066            setPanelHeight($('.product-detail-panel-container' + boxGroup), $('.product-detail-panel' + boxGroup).height(panelHeight));
1067        }, 250);
1068
1069
1070
1071        //scroll
1072
1073        if (currentScroll < activeOffset.top - scrollReduce) {
1074            dir = 'down';
1075        } else {
1076            dir = 'up';
1077        }
1078
1079
1080        setTimeout(function () {
1081            smoothScroll(activeOffset.top - scrollReduce, dir);
1082        }, 200);
1083
1084        //$(window).scrollTop(activeOffset.top - scrollReduce);
1085
1086    } else {
1087        $(e).parent().removeClass('active')
1088        $('.product-detail-panel' + boxGroup).height(0);
1089    }
1090
1091    //redo event listeners
1092
1093    $('.products-details-boxes a').off('click');
1094
1095    $('.products-details-boxes a').click(function () {
1096        productBoxClick(this, false);
1097    });
1098
1099}
1100
1101function setPanelHeight(sourceE, targetE) {
1102
1103    var panelHeight = $(sourceE).outerHeight();
1104    $(targetE).height(panelHeight);
1105
1106}
1107
1108function smoothScroll(y, d) {
1109
1110    if (d == 'down') {
1111
1112        newScroll = $(window).scrollTop() + yInterval;
1113
1114        if (newScroll < y) {
1115            $(window).scrollTop(newScroll);
1116            if (!(newScroll > $(window).scrollTop())) {
1117
1118            }
1119            setTimeout(function () {
1120                smoothScroll(y, d);
1121            }, tInterval);
1122        }
1123
1124    } else {
1125
1126        newScroll = $(window).scrollTop() - yInterval;
1127
1128        if (newScroll >= y) {
1129            $(window).scrollTop(newScroll);
1130            setTimeout(function () {
1131                smoothScroll(y, d);
1132            }, tInterval);
1133
1134        }
1135    }
1136
1137}
1138
1139function boxesInit() {
1140
1141    var sectionWrappers = $('.box-group-wrapper');
1142
1143    var sections = $(".products-details-boxes");
1144    var boxCollection = $(".products-details-boxes > div");
1145    var boxProperties;
1146    var lastRowCount;
1147    var lastRowBox;
1148    var targetSection = sections[0];
1149    var clones = [];
1150    var j;
1151
1152    //redo event listeners
1153
1154    $(".products-details-boxes a").off('click');
1155
1156    $(".products-details-boxes a").click(function () {
1157        productBoxClick(this, false);
1158    });
1159
1160    //close all panels
1161
1162    $('.product-detail-panel').height(0);
1163    $(".products-details-boxes a").parent().removeClass('active');
1164    $(boxCollection).removeAttr('style');
1165
1166
1167    $(sectionWrappers).each(function () {
1168
1169
1170
1171        sections = $(this).find(".products-details-boxes");
1172        boxCollection = $(this).find(".products-details-boxes > div");
1173        targetSection = sections[0];
1174        clones = [];
1175
1176        $(sections[1]).children().each(function () {
1177
1178            clones.push($(this).clone());
1179            $(this).remove();
1180
1181        });
1182
1183        for (j in clones) {
1184
1185            $(targetSection).append(clones[j]);
1186
1187        }
1188
1189        boxProperties = getBoxProperties(boxCollection);
1190
1191        lastRowCount = boxCollection.length - (boxProperties.rowCount - 1) * boxProperties.firstRowCols;
1192
1193        if (lastRowCount != boxProperties.firstRowCols) {
1194
1195            lastRowBox = (boxProperties.rowCount - 1) * boxProperties.firstRowCols;
1196
1197            $(boxCollection[lastRowBox]).css('margin-left', 100 * (boxProperties.firstRowCols - lastRowCount) / (2 * boxProperties.firstRowCols) + '%');
1198
1199        }
1200
1201    });
1202
1203}
1204
1205function getBoxProperties(boxCollection) {
1206
1207    var boxProps = {
1208        rowCount: 0,
1209        colCount: 0,
1210        vertOffset: 0,
1211        firstRowCols: 0,
1212    };
1213
1214    $(boxCollection).each(function () {
1215
1216        boxProps.currentOffset = $(this).offset();
1217        boxProps.currentParentOffset = $(this).parent().offset();
1218
1219        if (!boxProps.firstParentOffset) {
1220
1221            boxProps.firstParentOffset = boxProps.currentParentOffset;
1222
1223        }
1224
1225
1226        if (boxProps.currentOffset.top > boxProps.vertOffset) {
1227
1228            boxProps.rowCount++;
1229            boxProps.vertOffset = boxProps.currentOffset.top;
1230            boxProps.colCount = 1;
1231
1232
1233        } else {
1234            boxProps.colCount++;
1235        }
1236
1237
1238        if (boxProps.rowCount == 1) {
1239            boxProps.firstRowCols++;
1240        }
1241
1242
1243    });
1244
1245    return boxProps;
1246
1247}
1248
1249function recipeSearchInit() {
1250
1251    if ($(window).width() < 480) {
1252        $('.recipe-search input').attr('placeholder', 'Search');
1253    }
1254
1255}
1256
1257function matchRecipeCols() {
1258
1259    var mainHeight;
1260    var leftHeight, leftAdd;
1261    var diff;
1262    var currentHeight;
1263    var element;
1264
1265    var winWidth = $(window).width();
1266
1267    leftAdd = 0;
1268
1269    //strip any added style atts
1270
1271    $('.recipe-content div div').removeAttr('style');
1272
1273    if (winWidth > 900) {
1274
1275        mainHeight = $('.main-column').outerHeight();
1276        leftHeight = $('.left-column').outerHeight();
1277
1278        diff = Math.abs(mainHeight - leftHeight);
1279
1280        if (leftHeight > mainHeight) {
1281
1282            //increase instructions
1283            element = $('.main-column .instructions');
1284
1285        } else {
1286
1287            //increase products
1288            element = $('.left-column .products-used');
1289
1290
1291            if (element.length == 0) {
1292                //increase ingredients
1293                element = $('.left-column .ingredients');
1294                leftAdd = 20;
1295            }
1296        }
1297
1298        currentHeight = $(element).height();
1299        $(element).height(currentHeight + diff + leftAdd);
1300
1301    }
1302
1303}
1304
1305function matchCols() {
1306    var rightHeight;
1307    var leftHeight;
1308    var diff;
1309    var currentHeight;
1310    var leftElement = $('.match-column.left-column');
1311    var rightElement = $('.match-column.right-column');
1312
1313    var winWidth = $(window).width();
1314
1315    //strip any added style atts
1316
1317    $('.match-column').removeAttr('style');
1318
1319    if (winWidth > 900) {
1320
1321        rightHeight = $(rightElement).outerHeight();
1322        leftHeight = $(leftElement).outerHeight();
1323
1324        diff = Math.abs(rightHeight - leftHeight);
1325
1326        if (leftHeight > rightHeight) {
1327
1328            currentHeight = $(leftElement).outerHeight();
1329            $(rightElement).outerHeight(currentHeight);
1330            $(leftElement).outerHeight(currentHeight);
1331
1332        } else {
1333
1334            currentHeight = $(rightElement).outerHeight();
1335            $(leftElement).outerHeight(currentHeight);
1336            $(rightElement).outerHeight(currentHeight);
1337
1338        }
1339
1340
1341    }
1342}
1343
1344function carouselTextInit() {
1345
1346    var carWidth = $(window).width();
1347    var left = (carWidth - 1220) / 2;
1348
1349    if (left < 30) {
1350        left = 30;
1351    }
1352
1353    $('.carousel-inner .carousel-content-left h2').css('left', left + 'px');
1354
1355    left += 10;
1356
1357    $('.carousel-inner .carousel-content-left a').css('left', left + 'px');
1358
1359}
1360
1361function preOpenProduct() {
1362
1363    var element;
1364    var boxCollection = $(".products-details-boxes > div");
1365
1366    $(boxCollection).each(function () {
1367        if ($(this).hasClass('pre-open')) {
1368
1369            element = $(this).children('a');
1370            productBoxClick(element, true);
1371
1372        }
1373    });
1374
1375}
1376
1377function closeVideo() {
1378    $('#vid-popout-mask').fadeOut('fast', function () {
1379        $('iframe#ytplayer').remove();
1380        $('.embed-responsive').append('<div id="ytplayer" class="embed-responsive-item"></div>');
1381
1382    });
1383}
1384
1385function handleStart(e) {
1386    currentTouch = e.touches[0].pageX;
1387}
1388
1389function handleEnd(e) {
1390
1391    if (e.changedTouches[0].pageX - currentTouch > 30) {
1392        handleSwipeRight();
1393    } else if (currentTouch - e.changedTouches[0].pageX > 30) {
1394        handleSwipeLeft();
1395    }
1396
1397}
1398
1399function handleSwipeRight() {
1400    $("#homeCarousel").carousel('prev');
1401}
1402
1403function handleSwipeLeft() {
1404    $("#homeCarousel").carousel('next');
1405}
1406
1407function updateRecipeFilters(recipeMain) {
1408
1409    var allcount = 0;
1410    var checkcount = 0;
1411
1412    if (recipeMain && $('#all-recipes-filter').prop('checked')) {
1413
1414        $('.checkbox-sub input').prop('checked', true);
1415
1416    } else if (recipeMain && !$('#all-recipes-filter').prop('checked')) {
1417
1418        $('.checkbox-sub input').prop('checked', false);
1419
1420    } else {
1421
1422        $('.checkbox-sub input').each(function () {
1423
1424            allcount++;
1425
1426            if ($(this).prop('checked')) {
1427                checkcount++;
1428            }
1429
1430        });
1431
1432        if (allcount > 1 && allcount == checkcount) {
1433            $('#all-recipes-filter').prop('indeterminate', false);
1434            $('#all-recipes-filter').prop('checked', true);
1435        } else if (checkcount == 0) {
1436            $('#all-recipes-filter').prop('indeterminate', false);
1437            $('#all-recipes-filter').prop('checked', false);
1438        } else {
1439            $('#all-recipes-filter').prop('checked', false);
1440            $('#all-recipes-filter').prop('indeterminate', true);
1441        }
1442
1443    }
1444
1445}
1446
1447function newsScroll() {
1448
1449    var winScroll = $(window).scrollTop();
1450    var staticFilter = $('#static-filter').offset();
1451    var winWidth = $(window).width();
1452    var adjust = 0;
1453
1454    var environmentHub = $('#environment-hub').offset();
1455    var animalWelfareHub = $('#animal-welfare').offset();
1456    var communityHub = $('#basic-hub').offset();
1457    var valuesHub = $('.news-hub').offset();
1458    var accessHub = $('#access-health-hub').offset();
1459
1460    var formHub = $('#contact-form').offset();
1461    var callHub = $('#give-us-call').offset();
1462    var locationsHub = $('#locations').offset();
1463
1464
1465
1466    if (winWidth < 992) {
1467        adjust = 80;
1468    } else if (winWidth < 737) {
1469        adjust = 60;
1470    }
1471
1472    if (winScroll > staticFilter.top - adjust) {
1473        $('#sticky-filter').show();
1474        $('#static-filter').addClass('transparent');
1475    } else {
1476        $('#sticky-filter').hide();
1477        $('#static-filter').removeClass('transparent');
1478    }
1479
1480    if (environmentHub && winScroll <= environmentHub.top - 200) {
1481        $('#sticky-filter li.active').removeClass('active');
1482        $('#static-filter li.active').removeClass('active');
1483    }
1484
1485    if (environmentHub && winScroll > environmentHub.top - 200) {
1486        findScrollLink('#environment-hub');
1487    }
1488
1489    if (animalWelfareHub && winScroll > animalWelfareHub.top - 200) {
1490        findScrollLink('#animal-welfare');
1491    }
1492
1493    if (communityHub && winScroll > communityHub.top - 200) {
1494        findScrollLink('#basic-hub');
1495    }
1496
1497    if (valuesHub && winScroll > valuesHub.top - 200) {
1498        findScrollLink('.news-hub');
1499    }
1500
1501    if (accessHub && winScroll > accessHub.top - 200) {
1502        findScrollLink('#access-health-hub');
1503    }
1504
1505    if (formHub && winScroll <= formHub.top - 200) {
1506        $('#sticky-filter li.active').removeClass('active');
1507        $('#static-filter li.active').removeClass('active');
1508    }
1509
1510    if (formHub && winScroll > formHub.top - 200) {
1511        findScrollLink('#contact-form');
1512    }
1513
1514    if (callHub && winScroll > callHub.top - 200) {
1515        findScrollLink('#give-us-call');
1516    }
1517
1518    if (locationsHub && winScroll > locationsHub.top - 200) {
1519        findScrollLink('#locations');
1520    }
1521
1522}
1523
1524function mobScroll() {
1525
1526    var winScroll = $(window).scrollTop();
1527    var staticMenu = $('#main-nav').offset();
1528    var winWidth = $(window).width();
1529    var adjust = 10;
1530
1531    if (winWidth < 737) {
1532        adjust = 8;
1533    }
1534
1535    if (typeof staticMenu !== 'undefined') {
1536
1537        if (winScroll > staticMenu.top - adjust) {
1538            $('#sticky-main-nav').addClass('active');
1539        } else {
1540            $('#sticky-main-nav').removeClass('active');
1541        }
1542
1543    }
1544
1545}
1546
1547function newsBoxAdjust() {
1548
1549    var i, pElement, pHeight, hElement, hHeight, text, words, snippet, over, leftover, newHeight, hSnippet;
1550    var sep = /\s+/;
1551    var maxHeight = 199;
1552
1553    $('a.news-link.scan > div').each(function () {
1554
1555        $(this).parent('a').removeClass('scan');
1556
1557        hElement = $(this).find('h3.mod-title');
1558
1559        $(hElement).text('');
1560        $(this).find('.headings-wrapper').removeAttr('style');
1561
1562        hHeight = $(hElement).outerHeight();
1563
1564        snippet = '';
1565        i = 0;
1566        over = false;
1567
1568        text = $(this).find('h3.full-title').text();
1569        words = text.split(sep);
1570
1571        for (i in words) {
1572
1573            $(hElement).text(snippet + ' ' + words[i] + ' ...');
1574            hHeight = $(hElement).outerHeight();
1575
1576            if (hHeight < 76 && !over) {
1577
1578                snippet += ' ' + words[i];
1579
1580            } else if (!over) {
1581
1582                snippet += ' ...';
1583                over = true;
1584
1585            }
1586
1587        }
1588
1589        $(hElement).text(snippet);
1590
1591        pElement = $(this).find('p.mod-snippet');
1592        hElement = $(this).find('.headings-wrapper');
1593
1594
1595        $(pElement).text('');
1596        $(pElement).removeAttr('style');
1597
1598        pHeight = $(pElement).outerHeight();
1599        hHeight = $(hElement).outerHeight();
1600
1601        snippet = '';
1602        i = 0;
1603        over = false;
1604
1605        text = $(this).find('p.full-snippet').text();
1606
1607        words = text.split(sep);
1608
1609        for (i in words) {
1610
1611            $(pElement).text(snippet + ' ' + words[i] + ' ...');
1612            pHeight = $(pElement).outerHeight();
1613
1614            if (pHeight + hHeight < maxHeight && !over) {
1615
1616                snippet += ' ' + words[i];
1617
1618            } else if (!over) {
1619
1620                snippet += ' ...';
1621                over = true;
1622
1623            }
1624
1625
1626        }
1627
1628        $(pElement).text(snippet);
1629        pHeight = $(pElement).outerHeight();
1630
1631        if ($(pElement).outerHeight() + hHeight <= maxHeight) {
1632
1633            leftover = maxHeight - pHeight;
1634            //newHeight = Math.floor(leftover / 22) * 22 - 27;
1635            //$(pElement).outerHeight(newHeight);
1636            $(hElement).outerHeight(leftover);
1637
1638        }
1639
1640    });
1641
1642}
1643
1644function createSendSubmit(token) {
1645
1646    var email = $('input#input-email-top').val();
1647    var name = $('input#input-name-top').val();
1648    var source = $('input#input-source').val();
1649    var list = $('input#input-list').val();
1650
1651    var rx = /^[^@]+@[\w\.-]+\.\w+$/i;
1652
1653    if (!rx.test(email)) {
1654        $('.email-format-err').fadeIn('fast');
1655
1656    } else {
1657        $('.subscribe-sending').fadeIn('fast');
1658
1659        $.ajax({
1660            type: 'POST',
1661            url: MyAjax.ajaxurl,
1662            async: true,
1663            data: {
1664                action: 'createsend',
1665                name: name,
1666                email: email,
1667                source: source,
1668                list: list,
1669                rcap: token
1670            }
1671        }).done(function (data) {
1672
1673            if (data == 'success') {
1674                $('.newsletter-signup-container form button').hide();
1675                $('.subscribe-sending').fadeOut('fast');
1676                $('.grecaptcha-badge').hide('fast');
1677                $('.createsend-thank-you').fadeIn('slow');
1678                matchCols();
1679            } else {
1680
1681            }
1682
1683        });
1684    }
1685
1686}
1687
1688function scrollViewInit() {
1689
1690    var offset;
1691
1692    $('#static-filter .n-anchor').each(function () {
1693
1694        if ($(this).parent().hasClass('active')) {
1695
1696            var target = $(this).attr('href');
1697            offset = $(target).offset();
1698
1699            smoothScroll(offset.top - 50, 'down');
1700
1701        }
1702
1703    });
1704
1705    var preScroll = $('.pre-scroll');
1706
1707    if (preScroll.length > 0) {
1708
1709        offset = $(preScroll).offset();
1710        smoothScroll(offset.top - 50, 'down');
1711
1712    }
1713
1714}
1715
1716function anchorBind(e, t) {
1717
1718    e.preventDefault();
1719
1720    var target = $(t).attr('href');
1721
1722    $('.n-anchor').each(function () {
1723
1724        $(this).parent().removeClass('active');
1725
1726        if ($(this).attr('href') == target) {
1727            $(this).parent().addClass('active');
1728        }
1729
1730    });
1731
1732
1733    var offset = $(target).offset();
1734    var currentScroll = $(window).scrollTop();
1735    var dir;
1736
1737    if (currentScroll < offset.top) {
1738        dir = 'down';
1739    } else {
1740        dir = 'up';
1741    }
1742
1743    smoothScroll(offset.top - 50, dir);
1744
1745}
1746
1747function panelExpand(t, s) {
1748
1749    var panelHeight = 0;
1750    var activeOffset = $(t).offset();
1751    var targetElement;
1752    var targetOffset;
1753    var currentScroll;
1754    var scrollReduce = 0;
1755    var dir;
1756    var scrollPos;
1757    var hasActive = false;
1758
1759    maxScroll = $(document).height() - $(window).height();
1760
1761    $(t).siblings('li').each(function () {
1762
1763        if ($(this).hasClass('active')) {
1764            targetElement = $(this);
1765            hasActive = true;
1766        }
1767
1768        $(this).removeClass('active');
1769        $(this).children('.expandable-panel').css('height', '0px');
1770
1771    });
1772
1773
1774    $(t).find('.content-calc').each(function () {
1775
1776        panelHeight += $(this).outerHeight() + 10;
1777
1778    });
1779
1780    if (panelHeight == 0) {
1781
1782        $(t).find('p').each(function () {
1783
1784            panelHeight += $(this).outerHeight() + 10;
1785        });
1786
1787    }
1788
1789
1790    if (!$(t).hasClass('active')) {
1791        $(t).children('.expandable-panel').css('height', panelHeight + 'px');
1792        $(t).addClass('active');
1793    } else {
1794        $(t).removeClass('active');
1795        $(t).children('.expandable-panel').css('height', '0px');
1796    }
1797
1798    if (s) {
1799
1800        currentScroll = $(window).scrollTop();
1801
1802        //scroll
1803        if (hasActive) {
1804
1805            targetOffset = targetElement.offset();
1806
1807            if (targetOffset.top >= activeOffset.top) {
1808                scrollReduce = 0;
1809            } else {
1810                scrollReduce = targetElement.find('.content-calc').outerHeight();
1811            }
1812
1813        } else {
1814            scrollReduce = 0;
1815        }
1816
1817
1818        if (currentScroll < activeOffset.top - scrollReduce) {
1819            dir = 'down';
1820        } else {
1821            dir = 'up';
1822        }
1823
1824        scrollPos = activeOffset.top - scrollReduce;
1825        scrollPos = (scrollPos > maxScroll) ? maxScroll : scrollPos;
1826
1827        setTimeout(function () {
1828
1829            smoothScroll(scrollPos - 80, dir);
1830        }, 200);
1831
1832    }
1833
1834}
1835
1836
1837
1838function productSubNav(e) {
1839
1840    var rx = /[^\/]+$/;
1841    var slug = rx.exec(window.location.pathname);
1842
1843    if (slug != null) {
1844        var element = $('#det-' + slug[0] + ' a');
1845        if (element.length > 0) {
1846            productBoxClick(element, true);
1847        }
1848    } else {
1849        //window.location.reload();
1850    }
1851
1852
1853}
1854
1855function navDropdownCount() {
1856
1857    $('#main-nav .dropdown .nav-container > ul > li').each(function () {
1858
1859        var items = $(this).find('li');
1860
1861        if (items.length == 0) {
1862            $(this).children('h3').addClass('no-border');
1863        }
1864
1865    });
1866}
1867
1868var map;
1869var marker;
1870var propMarkers;
1871var mainMarker;
1872var infowindows = [];
1873
1874var mapCenter = {lat: 55, lng: -90};
1875var mapZoom = 4;
1876
1877var headOffice = {
1878    pos: {lat: 43.658882, lng: -79.606225},
1879    map: map,
1880    icon: '/wp-content/themes/glwptheme/images/map-pin-g.png',
1881    info: '<strong>Head Office Gay Lea Foods<br />Co-Operative Ltd</strong><br />5200 Orbitor Dr.<br />Mississauga On<br />L4W 5B4<br />(905) 283-5300<br />(800) 268-0508',
1882    infoFR: '<strong>Siège social Aliments Gay Lea<br />Co-Operative Ltd</strong><br />5200 Orbitor Dr.<br />Mississauga On<br />L4W 5B4<br />(905) 283-5300<br />(800) 268-0508',
1883    slug: 'headoffice',
1884    label: 'Head Office',
1885    labelFR: 'Siège social'
1886};
1887
1888var markerArray = [
1889
1890    {
1891        pos: {lat: 50.978013, lng: -113.997279},
1892        map: map,
1893        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
1894        info: '<strong>Alberta Cheese<br /></strong><br />2730-84 Avenue SE,<br />Calgary, AB<br />T2C 1C7',
1895        infoFR: '<strong>Alberta Cheese<br /></strong><br />2730-84 Avenue SE,<br />Calgary, AB<br />T2C 1C7',
1896        slug: 'alberta',
1897        label: 'Alberta Cheese',
1898        labelFR: ''
1899    },
1900    {
1901        pos: {lat: 42.979821, lng: -80.034156},
1902        map: map,
1903        icon: '/wp-content/themes/glwptheme/images/map-pin-dairy-bar.png',
1904        info: "<strong>Hewitt’s Dairy Bar<br /></strong><br />4210 Highway 6<br />Hagersville, Ontario<br />N0A 1H0",
1905        infoFR: "<strong>Bar laitier Hewitt’s<br /></strong><br />4210 Highway 6<br />Hagersville, Ontario<br />N0A 1H0",
1906        slug: 'hewitts-store',
1907        label: 'Hewitt’s Dairy Bar',
1908        labelFR: 'Bar laitier Hewitt’s'
1909    },
1910    {
1911        pos: {lat: 42.9559104, lng: -80.0427175},
1912        map: map,
1913        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
1914        info: "<strong>Hewitt’s Dairy<br /></strong><br />128 King Street East<br />Hagersville, Ontario<br />N0A 1H0",
1915        infoFR: '<strong>Hewitt’s Dairy<br /></strong><br />128 King Street East<br />Hagersville, Ontario<br />N0A 1H0',
1916        slug: 'hewitts',
1917        label: 'Hewitt’s Dairy',
1918        labelFR: 'Hewitt’s Dairy'
1919    },
1920    {
1921        pos: {lat: 43.250742, lng: -79.785610},
1922        map: map,
1923        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
1924        info: "<strong>Salerno<br /></strong><br />20 Morley Street,<br />Hamilton Ontario,<br />L8H 3R7<br />905-544-6281",
1925        infoFR: '<strong>Salerno<br /></strong><br />20 Morley Street,<br />Hamilton Ontario,<br />L8H 3R7<br />905-544-6281',
1926        slug: 'salerno',
1927        label: 'Salerno',
1928        labelFR: 'Salerno'
1929    },
1930    {
1931        pos: {lat: 43.966779, lng: -77.033925},
1932        map: map,
1933        icon: '/wp-content/themes/glwptheme/images/map-pin-retail.png',
1934        info: "<strong>Black River Cheese<br /></strong><br />913 County Road 13,<br />R.R. #2, Milford<br />Ontario K0K 2P0",
1935        infoFR: '<strong>Black River Cheese<br /></strong><br />913 County Road 13,<br />R.R. #2, Milford<br />Ontario K0K 2P0',
1936        slug: 'blackriver',
1937        label: 'Black River Cheese',
1938        labelFR: 'Black River Cheese'
1939    },
1940    {
1941        pos: {lat: 44.392373, lng: -77.472545},
1942        map: map,
1943        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
1944        info: "<strong>Ivanhoe Cheese<br /></strong><br />11301 Hwy 62 R.R. 5<br />Madoc, ON, Canada<br />K0K2K0",
1945        infoFR: '<strong>Ivanhoe Cheese<br /></strong><br />11301 Hwy 62 R.R. 5<br />Madoc, ON, Canada<br />K0K2K0',
1946        slug: 'ivanhoe',
1947        label: 'Ivanhoe Cheese',
1948        labelFR: 'Ivanhoe Cheese'
1949    },
1950    {
1951        pos: {lat: 44.001848, lng: -81.285977},
1952        map: map,
1953        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
1954        info: "<strong>Teeswater Creamery<br /></strong><br />21 Clinton St. N.<br />Teeswater ON<br />N0G 2S0",
1955        infoFR: '<strong>Teeswater Creamery<br /></strong><br />21 Clinton St. N.<br />Teeswater ON<br />N0G 2S0',
1956        slug: 'teeswater',
1957        label: 'Teeswater Creamery',
1958        labelFR: 'Teeswater Creamery'
1959    },
1960    {
1961        pos: {lat: 43.722957, lng: -79.525567},
1962        map: map,
1963        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
1964        info: "<strong>Clayson<br /></strong><br />100 Clayson Rd.<br />Toronto ON<br />M9M 2G7",
1965        infoFR: '<strong>Clayson<br /></strong><br />100 Clayson Rd.<br />Toronto ON<br />M9M 2G7',
1966        slug: 'clayson',
1967        label: 'Clayson',
1968        labelFR: 'Clayson'
1969    },
1970    {
1971        pos: {lat: 43.558085, lng: -80.270535},
1972        map: map,
1973        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
1974        info: "<strong>Guelph<br /></strong><br />21 Speedvale Ave. W.<br />Guelph ON<br />N1H 1J5",
1975        infoFR: '<strong>Guelph<br /></strong><br />21 Speedvale Ave. W.<br />Guelph ON<br />N1H 1J5',
1976        slug: 'guelph',
1977        label: 'Guelph',
1978        labelFR: 'Guelph'
1979    },
1980    {
1981        pos: {lat: 43.5586721, lng: -80.274112},
1982        map: map,
1983        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
1984        info: "<strong>Delta<br /></strong><br />23 Speedvale Ave. W<br />Guelph ON<br />N1H 1J5",
1985        infoFR: '<strong>Delta<br /></strong><br />23 Speedvale Ave. W<br />Guelph ON<br />N1H 1J5',
1986        slug: 'guelph-delta',
1987        label: 'Delta',
1988        labelFR: 'Delta'
1989    },
1990    {
1991        pos: {lat: 43.766299, lng: -79.539655},
1992        map: map,
1993        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
1994        info: "<strong>Longlife<br /></strong><br />180 Ormont Dr.<br />Toronto ON<br />M9L 1N7<br />",
1995        infoFR: '<strong>Longlife<br /></strong><br />180 Ormont Dr.<br />Toronto ON<br />M9L 1N7<br />',
1996        slug: 'longlife',
1997        label: 'Longlife',
1998        labelFR: 'Longlife'
1999    },
2000    {
2001        pos: {lat: 44.296074, lng: -77.547357},
2002        map: map,
2003        icon: '/wp-content/themes/glwptheme/images/map-pin-mfng.png',
2004        info: "<strong>Stirling Creamery<br /></strong><br />1 Front St.<br />Stirling ON<br />K0K 3E0",
2005        infoFR: '<strong>Stirling Creamery<br /></strong><br />1 Front St.<br />Stirling ON<br />K0K 3E0',
2006        slug: 'stirling',
2007        label: 'Stirling Creamery',
2008        labelFR: 'Stirling Creamery'
2009    },
2010    {
2011        pos: {lat: 45.559237, lng: -73.415208},
2012        map: map,
2013        icon: '/wp-content/themes/glwptheme/images/map-pin-dist.png',
2014        info: "<strong>Boucherville<br /></strong><br />165 Rue J A Bombardier<br />Boucherville QC<br />J4B 8P1",
2015        infoFR: '<strong>Boucherville<br /></strong><br />165 Rue J A Bombardier<br />Boucherville QC<br />J4B 8P1',
2016        slug: 'boucherville',
2017        label: 'Boucherville',
2018        labelFR: 'Boucherville'
2019    },
2020    {
2021        pos: {lat: 49.834496, lng: -97.165436},
2022        map: map,
2023        icon: '/wp-content/themes/glwptheme/images/map-pin-partner.png',
2024        info: "<strong>MDI Holdings Corp.<br /></strong><br />70 Irene Street<br />Winnipeg, MB<br />R3T 4E1",
2025        infoFR: '<strong>MDI Holdings Corp.<br /></strong><br />70 Irene Street<br />Winnipeg, MB<br />R3T 4E1',
2026        slug: 'mdi',
2027        label: 'MDI Holdings Corp.',
2028        labelFR: 'MDI Holdings Corp.'
2029    },
2030    {
2031        pos: {lat: 44.374624, lng: -78.730642},
2032        map: map,
2033        icon: '/wp-content/themes/glwptheme/images/map-pin-partner.png',
2034        info: "<strong>Mariposa Dairy<br /></strong><br />201 St George Street<br />Lindsay, ON,<br />K9V 5Z9",
2035        infoFR: '<strong>Mariposa Dairy<br /></strong><br />201 St George Street<br />Lindsay, ON,<br />K9V 5Z9',
2036        slug: 'mariposa',
2037        label: 'Mariposa Dairy',
2038        labelFR: 'Mariposa Dairy'
2039    },
2040    {
2041        pos: {lat: 42.6727895, lng: -81.0128626},
2042        map: map,
2043        icon: '/wp-content/themes/glwptheme/images/map-pin-museum.png',
2044        info: "<strong>Gay Lea Dairy Museum<br /></strong><br />48075 Jamestown Line, RR #2<br />Aylmer, ON.<br />N5H 2R2",
2045        infoFR: '<strong>Musée laitier Gay Lea<br /></strong><br />48075 Jamestown Line, RR #2<br />Aylmer, ON.<br />N5H 2R2',
2046        slug: 'museum',
2047        label: 'Gay Lea Dairy Museum',
2048        labelFR: 'Musée laitier Gay Lea'
2049    },
2050    {
2051        pos: {lat: 43.7263164, lng: -79.5297464},
2052        map: map,
2053        icon: '/wp-content/themes/glwptheme/images/map-pin-dist.png',
2054        info: "<strong>CPW<br /></strong><br />401 Clayson Rd,<br />Toronto, ON,<br />M9M 2H4",
2055        infoFR: '<strong>CPW<br /></strong><br />401 Clayson Rd,<br />Toronto, ON,<br />M9M 2H4',
2056        slug: 'cpw',
2057        label: 'CPW',
2058        labelFR: 'CPW'
2059    },
2060    {
2061        pos: {lat: 43.7644118, lng: -79.5566619},
2062        map: map,
2063        icon: '/wp-content/themes/glwptheme/images/map-pin-dist.png',
2064        info: "<strong>Barmac<br /></strong><br />1700 Ormont Dr.,<br />Toronto, ON,<br />M9L 2V4",
2065        infoFR: '<strong>Barmac<br /></strong><br />1700 Ormont Dr.,<br />Toronto, ON,<br />M9L 2V4',
2066        slug: 'barmac',
2067        label: 'Barmac',
2068        labelFR: 'Barmac'
2069    },
2070    {
2071        pos: {lat: 43.6165189, lng: -79.7781788},
2072        map: map,
2073        icon: '/wp-content/themes/glwptheme/images/map-pin-dist.png',
2074        info: "<strong>Brampton<br /></strong><br />7855 Heritage Rd.,<br />Brampton, ON,<br />L6Y 0N3",
2075        infoFR: '<strong>Brampton<br /></strong><br />7855 Heritage Rd.,<br />Brampton, ON,<br />L6Y 0N3',
2076        slug: 'brampton',
2077        label: 'Brampton',
2078        labelFR: 'Brampton'
2079    }
2080
2081];
2082
2083function initMap() {
2084
2085    var lang = $('html').attr('lang');
2086    var winWidth = $(window).width();
2087
2088    if (winWidth < 480) {
2089        mapZoom = 10;
2090        mapCenter = headOffice.pos
2091    }
2092
2093    map = new google.maps.Map(document.getElementById('prop-map'), {
2094        zoom: mapZoom,
2095        center: mapCenter
2096    });
2097
2098    if (lang != 'fr-FR') {
2099
2100        propMarkers = markerArray.map(function (location) {
2101
2102            return new google.maps.Marker({
2103                position: location.pos,
2104                map: map,
2105                icon: location.icon,
2106                title: location.label,
2107                info: location.info,
2108                slug: location.slug
2109            });
2110
2111        });
2112
2113
2114
2115        mainMarker = new google.maps.Marker({
2116            position: headOffice.pos,
2117            map: map,
2118            icon: headOffice.icon,
2119            title: headOffice.label,
2120            info: headOffice.info,
2121            slug: headOffice.slug
2122        });
2123
2124
2125
2126    } else {
2127
2128        propMarkers = markerArray.map(function (location) {
2129
2130            return new google.maps.Marker({
2131                position: location.pos,
2132                map: map,
2133                icon: location.icon,
2134                title: location.labelFR,
2135                info: location.infoFR,
2136                slug: location.slug
2137            });
2138
2139        });
2140
2141        mainMarker = new google.maps.Marker({
2142            position: headOffice.pos,
2143            map: map,
2144            icon: headOffice.icon,
2145            title: headOffice.labelFR,
2146            info: headOffice.infoFR,
2147            slug: headOffice.slug
2148        });
2149
2150    }
2151
2152    var markerCluster = new MarkerClusterer(map, propMarkers, {
2153        gridSize: 30,
2154        styles: [{
2155                url: '/wp-content/themes/glwptheme/images/cluster-1.png',
2156                height: 48,
2157                width: 48,
2158                anchor: [48, 0],
2159                textColor: '#ffffff',
2160                textSize: 22
2161            }]
2162    });
2163
2164
2165    for (var i in propMarkers) {
2166        propMarkers[i].addListener('click', function () {
2167
2168            for (var j in infowindows) {
2169
2170                infowindows[j].close(map);
2171
2172            }
2173
2174            infowindows.push(new google.maps.InfoWindow({
2175                content: this.info,
2176                pos: this.position,
2177                title: this.title
2178            }));
2179            infowindows[infowindows.length - 1].open(map, this);
2180        });
2181    }
2182
2183    mainMarker.addListener('click', function () {
2184        var infowindow = new google.maps.InfoWindow({
2185            content: mainMarker.info,
2186            pos: mainMarker.position
2187        });
2188        infowindow.open(map, this);
2189    });
2190
2191}
2192
2193function mapLocate(t, loc) {
2194
2195    var infoMarker;
2196
2197    $(t).parent().parent('li').siblings().removeClass('active');
2198    $(t).parent().parent('li').siblings('li').children('.expandable-panel').css('height', '0px');
2199    $('#map-container ul li a').removeClass('active');
2200    $(t).addClass('active');
2201
2202
2203    for (var j in infowindows) {
2204
2205        infowindows[j].close(map);
2206
2207    }
2208
2209    maxScroll = $(document).height() - $(window).height();
2210    var targetOffset = $('#map-canvas').offset();
2211    var winW = $(window).width();
2212
2213    if (loc == 'headoffice') {
2214
2215        map.setZoom(13);
2216        map.panTo(mainMarker.position);
2217
2218        infoMarker = mainMarker;
2219
2220    } else {
2221
2222        for (var i in propMarkers) {
2223
2224            if (propMarkers[i].slug == loc) {
2225
2226                switch (loc) {
2227                    case 'guelph-delta':
2228                    case 'guelph':
2229                    case 'clayson':
2230                    case 'longlife':
2231                    case 'cpw':
2232
2233                        map.setZoom(18);
2234                        break;
2235
2236                    case 'barmac':
2237
2238                        map.setZoom(16);
2239                        break;
2240
2241
2242                    case 'hewitts-store':
2243                    case 'hewitts':
2244
2245
2246                        map.setZoom(14);
2247                        break;
2248
2249
2250                    case 'ivanhoe':
2251                    case 'salerno':
2252                    case 'stirling':
2253                    case 'brampton':
2254
2255                        map.setZoom(13);
2256                        break;
2257
2258                    default:
2259                        map.setZoom(10);
2260                        break;
2261
2262                }
2263
2264                map.panTo(propMarkers[i].position);
2265
2266                infoMarker = propMarkers[i];
2267            }
2268
2269        }
2270
2271    }
2272
2273    if (winW < 900) {
2274
2275        setTimeout(function () {
2276            smoothScroll(targetOffset.top - 100, 'down');
2277        }, 200);
2278
2279    }
2280
2281    infowindows.push(new google.maps.InfoWindow({
2282        content: infoMarker.info,
2283        pos: infoMarker.position,
2284        title: infoMarker.title
2285    }));
2286
2287    infowindows[infowindows.length - 1].open(map, infoMarker);
2288
2289}
2290
2291function emailShare(t) {
2292
2293    var title = $(t).attr('data-title');
2294    var href = location.href;
2295    var body = title + "\n\r" + href;
2296
2297    location = 'mailto:?subject=Gay%20Lea%20Foods%20Recipe&body=' + title.replace(/\+/g, '%20') + "%20-%20" + encodeURI(href);
2298
2299}
2300
2301function getNews(t) {
2302
2303    var newsIDs = $(t).attr('data-ids');
2304    $('#load-more-news').hide();
2305    $('.news-loading').show();
2306
2307    $.ajax({
2308        type: 'POST',
2309        url: MyAjax.ajaxurl,
2310        async: true,
2311        data: {
2312            action: 'more_news',
2313            news_ids: newsIDs,
2314            news_path: window.location.pathname
2315        }
2316    }).done(function (data) {
2317
2318        var result = JSON.parse(data);
2319
2320        $('.news-loading').hide();
2321
2322        $('.add-news-container').append(result[0]);
2323
2324        if (result[1].length > 0) {
2325            $('#load-more-news').attr('data-ids', result[1]);
2326            $('#load-more-news').show();
2327        }
2328
2329        newsBoxAdjust();
2330
2331
2332    });
2333
2334}
2335
2336function findScrollLink(hrefAttr) {
2337
2338    $('.n-anchor').each(function () {
2339
2340        if ($(this).attr('href') == hrefAttr) {
2341
2342            $(this).parent('li').addClass('active');
2343
2344            $(this).parent('li').siblings('li').each(function () {
2345
2346                if ($(this).children('a').attr('href') != hrefAttr) {
2347                    $(this).removeClass('active');
2348                }
2349
2350            });
2351
2352        }
2353
2354    });
2355
2356}
2357
2358function validateAmt(t) {
2359
2360    var rx = /[0-9]*,?[0-9]*,?[0-9]*,?[0-9]*\.?[0-9]{0,2}$/;
2361    var valid = rx.exec($(t).val());
2362
2363    $(t).val(valid[0]);
2364
2365    calcSubtotals();
2366
2367}
2368
2369
2370function calcSubtotals() {
2371
2372    var i, val, el;
2373    var total = 0;
2374    for (i = 1; i < 4; i++) {
2375
2376        val = $('#b-item-' + i + '-cost').val();
2377
2378        if (typeof val != 'undefined') {
2379
2380            val = val.replace(/,/g, '');
2381            val = parseFloat(val);
2382
2383            if (isNaN(val)) {
2384                val = 0;
2385            }
2386
2387            total += val;
2388        }
2389
2390    }
2391
2392    $('#b-subtotal').text('$' + total.toLocaleString('us-EN', {minimumFractionDigits: 2, maximumFractionDigits: 2}));
2393
2394    total = 0;
2395
2396    for (i = 1; i < 7; i++) {
2397
2398        if (typeof val != 'undefined') {
2399            val = $('#item-' + i + '-cost').val().replace(/,/g, '');
2400            val = parseFloat(val);
2401
2402            if (isNaN(val)) {
2403                val = 0;
2404            }
2405            total += val;
2406
2407        }
2408    }
2409
2410    $('#subtotal').text('$' + total.toLocaleString('us-EN', {minimumFractionDigits: 2, maximumFractionDigits: 2}));
2411
2412
2413}
2414
2415function openMobMenuInner(t) {
2416
2417
2418
2419    var listHeight = 0;
2420    var oldListHeight = $('#mob-top-nav>ul>li.active li.active ul').outerHeight();
2421    var parentPanel = $(t).parent().parent().parent();
2422    var parentHeight = parentPanel.outerHeight();
2423
2424    if (!oldListHeight) {
2425        oldListHeight = 0;
2426    }
2427
2428    $(t).parent().parent().siblings('li').each(function () {
2429
2430        $(this).removeClass('active');
2431        $(this).children('ul').css('height', '0px');
2432
2433    });
2434
2435    $(t).parent().siblings('ul').children().each(function () {
2436
2437        listHeight += $(this).outerHeight();
2438
2439    });
2440
2441    if (!$(t).parent().parent().hasClass('active')) {
2442
2443        $(t).parent().parent().addClass('active');
2444        $(t).parent().siblings('ul').css('height', listHeight + 'px');
2445        parentPanel.css('height', parentHeight + listHeight - oldListHeight + 'px');
2446
2447    } else {
2448
2449        $(t).parent().parent().removeClass('active');
2450        $(t).parent().siblings('ul').css('height', '0px');
2451        parentPanel.css('height', parentHeight - listHeight + 'px');
2452
2453    }
2454
2455}
2456
2457//
2458function addNewIng(e) {
2459    var text = $('select#add-new-ing option:selected').text();
2460
2461}
2462
2463
2464function checkCaptcha(token) {
2465
2466    var valid = true;
2467
2468    if (grecaptcha.getResponse() == '') {
2469
2470        $('#recaptcha-error.alert-danger').show('fast');
2471        valid = false;
2472
2473    } else {
2474
2475        var rx = /^[\w\.-]+@[\w\.-]+\.\w+$/i;
2476
2477
2478        var emailInput = $('#contact-form input[name=email]');
2479        var fnameInput = $('#contact-form input[name=first_name]');
2480        var lnameInput = $('#contact-form input[name=last_name]');
2481        var comment = $('textarea#comment_ta');
2482        var cat = $('#contact-form select[name=contact_cat]');
2483        var prod = $('#contact-form select[name=product_sub_cat]');
2484        
2485
2486        var valid = true;
2487
2488
2489        $('#contact-form .alert-danger').hide();
2490
2491        if (!rx.test(emailInput.val())) {
2492
2493            $('#contact-form .alert-danger').show();
2494            emailInput.addClass('has-error');
2495            valid = false;
2496
2497        }
2498
2499        if (fnameInput.val() == '') {
2500
2501            $('#contact-form .alert-danger').show();
2502            fnameInput.addClass('has-error');
2503            valid = false;
2504
2505        }
2506
2507        if (lnameInput.val() == '') {
2508
2509            $('#contact-form .alert-danger').show();
2510            lnameInput.addClass('has-error');
2511            valid = false;
2512
2513        }
2514
2515        if (comment.val() == '') {
2516
2517            $('#contact-form .alert-danger').show();
2518            comment.addClass('has-error');
2519            valid = false;
2520
2521        }
2522
2523        if (cat.val() == 'product_question' && prod.val() == null) {
2524
2525            $('#contact-form .alert-danger').show();
2526            prod.addClass('has-error');
2527            valid = false;
2528
2529        }
2530
2531        if (grecaptcha.getResponse() == '') {//false//
2532
2533            $('#recaptcha-error.alert-danger').show('fast');
2534            valid = false;
2535
2536        } else {
2537
2538            $('#recaptcha-error.alert-danger').hide('fast');
2539
2540        }
2541
2542
2543        if (!valid) { //
2544
2545            //e.preventDefault();
2546
2547        } else {
2548
2549            $('.sending-data').show('fast');
2550            $('#contact-form button').hide('fast');
2551            $('form#contact-form-form').submit();
2552
2553        }
2554
2555    }
2556
2557}

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.