PageSourceSearch

https://www.dexion.de/Static/js/main.js

js dexion.de collected 2026-10-04 01:39:27 UTC 81,373 bytes, 2,166 lines download raw bytes

1$(function () {
2    initRemoveOldCCCookie();
3    autoPlayVideoModal();
4    //initNewsletter();
5    initPostAjaxForm();
6    initProductFilter();
7    initListPager();
8    initNewsListFilter();
9    initDownloadModelOpen();
10    initRemoveProductFilter();
11    initMegaMenuFunctions();
12    initMegaMenuFunctions();
13    initBSMenuClickFix();
14    initSubDropDown();
15    //initCookieCon();
16    initCookieCon3();
17    //initModalOnMouseOut();
18
19    //$('.init-large-display-slider').css('visibility', 'hidden')
20    //$('.init-standard-carousel').css('visibility', 'hidden')
21    //$('.large-carousel-with-nav').css('visibility', 'hidden')
22
23});
24$(window)
25    .on("load",
26        function () {
27
28            // On init, remove the class that we use to initilay hide all slides but the first one
29            $('.has-slider').on('init', function () {
30                $(this).removeClass('slider-pre-init');
31            });
32                
33            initSlick();
34            initDataLayerAndGtag();
35
36        });
37
38        
39window.dataLayer = window.dataLayer || [];
40function gtag(){dataLayer.push(arguments);}
41
42function initRemoveOldCCCookie(){
43    function checkAndRemoveOldCookie() {
44        // Helper function to get a cookie value by name
45        function getCookie(name) {
46            const cookies = document.cookie.split('; ');
47            for (const cookie of cookies) {
48                const [key, value] = cookie.split('=');
49                if (key === name) {
50                    return decodeURIComponent(value);
51                }
52            }
53            return null;
54        }
55    
56        // Helper function to delete a cookie by name
57        function deleteCookie(name) {
58            const hostname = window.location.hostname; // Current domain
59            const path = "/"; // Default path
60        
61            // Try deleting with the domain explicitly
62            document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path}; domain=${hostname};`;
63        
64            // Also try deleting without the domain (if it was set without a domain explicitly)
65            document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path};`;
66        }
67    
68        const cookieName = "cc_cookie";
69        const cookieValue = getCookie(cookieName);
70    
71        if (cookieValue) {
72            try {
73                // Try to parse the cookie value as JSON
74                const parsedValue = JSON.parse(cookieValue);
75    
76                // Check if it's the old format by looking for the "level" key
77                if (parsedValue.level && Array.isArray(parsedValue.level)) {
78                    // It's the old cookie, so remove it
79                    console.log("Old cookie detected. Removing...");
80                    deleteCookie(cookieName);
81                } else {
82                    console.log("Cookie is in the new format. No action needed.");
83                }
84            } catch (e) {
85                // If parsing fails, it's not JSON, possibly an old or corrupted cookie
86                console.log("Unable to parse cookie. Removing as a precaution...");
87                deleteCookie(cookieName);
88            }
89        } else {
90            console.log("Cookie not found.");
91        }
92    }
93    
94    // Run the function
95    checkAndRemoveOldCookie();
96}
97
98function initDataLayerAndGtag(){
99
100    const preferences = CookieConsent.getUserPreferences();
101
102    if (Array.isArray(preferences.acceptedCategories) && preferences.acceptedCategories.includes('analytics_cookies')) {
103
104        gtag('consent', 'update', {
105            'analytics_storage': 'granted'
106        });
107        dataLayer.push({ 'event': 'CC-Group2-Allowed' });
108    } else {
109        gtag('consent', 'update', {
110            'analytics_storage': 'denied'
111        });
112    }
113
114    if (Array.isArray(preferences.acceptedCategories) && preferences.acceptedCategories.includes('ad_cookies')) {
115
116        gtag('consent', 'update', {
117            'ad_storage': 'granted',
118            'ad_user_data': 'granted',
119            'ad_personalization': 'granted'
120        });
121        dataLayer.push({ 'event': 'CC-Group3-Allowed' });
122
123    } else {
124        gtag('consent', 'update', {
125            'ad_storage': 'denied',
126            'ad_user_data': 'denied',
127            'ad_personalization': 'denied'
128        });
129    }
130
131    // // Define dataLayer and the gtag function.
132    // // Moved to top of site in html
133    // // Default ad_storage to 'denied'.
134    // gtag('consent', 'default', {
135    //     'ad_storage': 'denied',
136    //     'ad_user_data': 'denied',
137    //     'ad_personalization': 'denied',
138    //     'analytics_storage': 'denied'
139    // });
140}
141
142function initSlick() {
143    
144    var slickPrevArrow =
145        '<button type="button" data-role="none" class="slick-prev slick-arrow" aria-label="Previous" role="button" style=""><svg class="icon icon-sm fill"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/Static/gfx/svg_icons/sprite-out/sprite-in.svg#arrow-left"></use></svg></button>';
146    var slickNextArrow =
147        '<button type="button" data-role="none" class="slick-next slick-arrow" aria-label="Previous" role="button" style=""><svg class="icon icon-sm fill"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/Static/gfx/svg_icons/sprite-out/sprite-in.svg#arrow-right"></use></svg></button>';
148
149
150    var slickPrevArrowXS =
151        '<button type="button" data-role="none" class="visible-xs slick-prev slick-arrow" aria-label="Previous" role="button" style=""><svg class="icon icon-sm fill"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/Static/gfx/svg_icons/sprite-out/sprite-in.svg#arrow-left"></use></svg></button>';
152    var slickNextArrowXS =
153        '<button type="button" data-role="none" class="visible-xs slick-next slick-arrow" aria-label="Previous" role="button" style=""><svg class="icon icon-sm fill"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/Static/gfx/svg_icons/sprite-out/sprite-in.svg#arrow-right"></use></svg></button>';
154
155    var slickPrevArrowIconMd =
156        '<button type="button" data-role="none" class="slick-prev slick-arrow-md" aria-label="Previous" role="button" style=""><svg class="icon icon-md fill"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/Static/gfx/svg_icons/sprite-out/sprite-in.svg#arrow-left"></use></svg></button>';
157    var slickNextArrowIconMd =
158        '<button type="button" data-role="none" class="slick-next slick-arrow-md" aria-label="Previous" role="button" style=""><svg class="icon icon-md fill"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/Static/gfx/svg_icons/sprite-out/sprite-in.svg#arrow-right"></use></svg></button>';
159
160    var slickPrevArrowIconLg =
161        '<button type="button" data-role="none" class="slick-prev slick-arrow-lg" aria-label="Previous" role="button" style=""><svg class="icon icon-lg fill"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/Static/gfx/svg_icons/sprite-out/sprite-in.svg#arrow-left"></use></svg></button>';
162    var slickNextArrowIconLg =
163        '<button type="button" data-role="none" class="slick-next slick-arrow-lg" aria-label="Previous" role="button" style=""><svg class="icon icon-lg fill"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/Static/gfx/svg_icons/sprite-out/sprite-in.svg#arrow-right"></use></svg></button>';
164
165    $('.init-standard-carousel').slick({
166        adaptiveHeight: true,
167        prevArrow: slickPrevArrow,
168        nextArrow: slickNextArrow
169    });
170    $('.init-large-display-slider').slick({
171        slidesToShow: 1,
172        slidesToScroll: 1,
173        arrows: true,
174        fade: true,
175        prevArrow: slickPrevArrowXS,
176        nextArrow: slickNextArrowXS,
177        asNavFor: '.init-slider-nav'
178    });
179    if ($(".init-slider-nav").length) {
180        var breakpointMd = 991;
181        var $initSliderNav = $(".init-slider-nav");
182        var slidesToShow = $initSliderNav.data("slides-shown");
183        var slidesToShowMd = $initSliderNav.data("slides-shown-md");
184
185        if ($initSliderNav.data("responsive")) {
186        
187        }
188
189        if (slidesToShow < 1) {
190            slidesToShow = 5;
191        }
192        $('.init-slider-nav').slick({
193            slidesToShow: slidesToShow,
194            slidesToScroll: 1,
195            asNavFor: '.init-large-display-slider',
196            dots: false,
197            centerMode: false,
198            focusOnSelect: true,
199            prevArrow: slickPrevArrow,
200            nextArrow: slickNextArrow,
201            responsive: [{
202                breakpoint: breakpointMd,
203                settings: {
204                    slidesToShow: slidesToShowMd
205                }
206            }]
207        });
208    }
209    
210    $('.init-standard-multi-quote-carousel').slick({
211        slidesToShow: 4,
212        slidesToScroll: 1,
213        arrows: true,
214        prevArrow: slickPrevArrowIconLg,
215        nextArrow: slickNextArrowIconLg
216    });
217    $('.init-standard-multi-carousel').slick({
218        slidesToShow: 5,
219        slidesToScroll: 1,
220        arrows: true,
221        prevArrow: slickPrevArrowIconLg,
222        nextArrow: slickNextArrowIconLg
223    });
224    $('.init-standard-multi-carousel-mobile').slick({
225        slidesToShow: 2,
226        slidesToScroll: 1,
227        arrows: true,
228        prevArrow: slickPrevArrowIconMd,
229        nextArrow: slickNextArrowIconMd
230    });
231
232    // Specific initialization for ImageCarouselBlock with centered thumbnails
233    $('.init-image-carousel-display-slider').slick({
234        slidesToShow: 1,
235        slidesToScroll: 1,
236        arrows: true,
237        fade: true,
238        prevArrow: slickPrevArrowXS,
239        nextArrow: slickNextArrowXS,
240        asNavFor: '.init-image-carousel-slider-nav'
241    });
242    
243    if ($(".init-image-carousel-slider-nav").length) {
244        var breakpointMd = 991;
245        var $initImageCarouselSliderNav = $(".init-image-carousel-slider-nav");
246        var slidesToShow = $initImageCarouselSliderNav.data("slides-shown");
247        var slidesToShowMd = $initImageCarouselSliderNav.data("slides-shown-md");
248
249        if (slidesToShow < 1) {
250            slidesToShow = 5;
251        }
252        $('.init-image-carousel-slider-nav').slick({
253            slidesToShow: slidesToShow,
254            slidesToScroll: 1,
255            asNavFor: '.init-image-carousel-display-slider',
256            dots: false,
257            centerMode: true,  // This enables centering for ImageCarouselBlock
258            focusOnSelect: true,
259            prevArrow: slickPrevArrow,
260            nextArrow: slickNextArrow,
261            responsive: [{
262                breakpoint: breakpointMd,
263                settings: {
264                    slidesToShow: slidesToShowMd,
265                    centerMode: true
266                }
267            }]
268        });
269    }
270}
271
272
273//FUNCTION TO GET AND AUTO PLAY YOUTUBE VIDEO FROM DATATAG
274function autoPlayVideoModal() {
275    // Use event delegation to handle dynamically added elements
276    $("body").on("click", '[data-toggle="modal"][data-videoid]', function () {
277        var $button = $(this);
278        var theModal = $button.data("target");
279        var videoId = $button.attr("data-videoid");
280        var videoNetwork = $button.data("videoNetwork");
281        var origin = window.location.protocol + "//" + window.location.host;
282        var videoSRC, videoSRCauto;
283        
284        if (videoNetwork === "YouTube") {
285            // Use youtube-nocookie.com for better compatibility
286            videoSRC = "https://www.youtube-nocookie.com/embed/" + videoId;
287            // Only add origin if it's not a local/development domain (to avoid Error 153 with FormLoader conflicts)
288            if (origin.indexOf('localhost') === -1 && origin.indexOf('.local') === -1 && origin.indexOf('127.0.0.1') === -1) {
289                videoSRCauto = videoSRC + "?autoplay=1&origin=" + encodeURIComponent(origin) + "&enablejsapi=1";
290            } else {
291                videoSRCauto = videoSRC + "?autoplay=1&enablejsapi=1";
292            }
293        }
294        else if (videoNetwork === "Vimeo") {
295            videoSRC = "https://player.vimeo.com/video/" + videoId;
296            videoSRCauto = videoSRC + "?autoplay=1";
297        }
298        
299        if (videoSRCauto) {
300            // Remove any existing handlers to prevent stacking, then add new ones
301            $(theModal).off("shown.bs.modal.video hidden.bs.modal.video");
302            $(theModal).on("shown.bs.modal.video", function () {
303                var $iframeContainer = $(theModal + ' .embed-responsive');
304                var $existingIframe = $(theModal + ' iframe');
305                
306                // FormLoader modifies existing iframes, causing YouTube Error 153
307                // Replace the iframe entirely with a fresh one to avoid FormLoader interference
308                $existingIframe.remove();
309                
310                // Create fresh iframe with video src
311                var $newIframe = $('<iframe>', {
312                    'class': 'embed-responsive-item',
313                    'src': videoSRCauto,
314                    'allow': 'accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share',
315                    'allowFullScreen': '',
316                    'frameBorder': '0',
317                    'referrerpolicy': 'strict-origin-when-cross-origin',
318                    'title': 'YouTube video player'
319                });
320                
321                $iframeContainer.append($newIframe);
322            }).on("hidden.bs.modal.video", function () {
323                // Clear iframe src when modal closes to stop video playback
324                $(theModal + ' iframe').attr('src', '');
325            });
326        }
327    });
328
329}
330/*
331
332
333$(function () {
334    $("#newsletterblockForm").on('submit', function (e) {
335
336        e.preventDefault() // prevent the form's normal submission
337
338        $("#newsletterblockForm").on('submit', function (e) {
339
340            e.preventDefault() // prevent the form's normal submission
341
342            var dataToPost = $(this).serialize();
343
344            $.post("/Newsletter/NewsletterBlock3", { model: $(this).serialize() }, function (data) {
345                $("#LastName").val('wow');
346            }).fail(function () {
347                alert('error');
348            });
349        })
350    })
351})
352*/
353
354function initPostAjaxForm() {
355    $(".js-ajax-form").submit(function(e) {
356        e.preventDefault();
357        var cuvid = getCookie("cuvid", false); //Special tracking code from clickdimensions
358        if (!cuvid) {
359            console.error("No cuvid found!");
360        }
361        $("input[name$='Cuvid']", $(this)).val(cuvid);
362
363        var $form = $(this);
364
365        var isDownloadForm = false,
366            isSignupForm = false,
367            isPopupForm = false;
368        if ($form.is("#pdf-dl-form")) {
369            isDownloadForm = true;
370        }
371        if ($form.is("#signup-form")) {
372            isSignupForm = true;
373        }
374        if ($form.is(".popup-form")) {
375            isPopupForm = true;
376        }
377        $.ajax({
378            type: 'POST',
379            url: $form.attr('action'),
380            data: $form.serialize(),
381            success: function (response) {
382                //alert(response);
383                if ($(".js-cookie-save-details",$form).is(":checked")) {
384                    saveDetailsToCookie($form);
385                }
386                if (isDownloadForm) {
387                    resumeDownload(downloadURL, downloadName, false);
388                    if ($("#downloadModal").is(":visible")) {
389                        $('#downloadModal').modal('hide');
390                    }
391                }
392                if (isSignupForm) {
393                    //clearSignupForm($form);
394                    var signupMessage = $(".js-form-message").html();
395                    $(".subHeader", "#signup-form").html(signupMessage);
396                }
397                if (isPopupForm) {
398                    var redirectLocation = $("input[name=AfterSubmissionURL]", $form).val();
399                    window.location.replace(redirectLocation);
400                }
401            }
402        });
403
404
405
406    });
407
408    function onSuccess() {
409        //firstnameTxt.val('');
410        //lastnameTxt.val('');
411        //epostTxt.val('Thanks for signing up!');
412    }
413}
414
415//function clearSignupForm($form) {
416//    $("input", $form).each(function() {
417//        $(this).val("");
418//    });
419//}
420
421function initNewsletter() {
422    //$('.btn-submit-newsletter-js').click(function (e) {
423    //    e.preventDefault()            
424    //    var form = $(this).parents('form:first');
425    //    var dataToPost = form.serialize();
426
427    //    $.post("/Newsletter/SignUpForNewsletter", { model: dataToPost }, function (data) {
428    //        $("#LastName", form).val('wow');
429    //        }).fail(function () {
430    //            alert('error');
431    //        });
432           
433    //})
434
435    $('#btn-submit-newsletter').click(function (e) {
436        e.preventDefault();
437
438        var form = $('#clickdimensionsForm');
439        var $inputs = $('#clickdimensionsForm :input');
440        var valid = true;
441        var hpDetected = false; //honeypot anti spam
442
443        var firstnameTxt;
444        var lastnameTxt;
445        var epostTxt;
446
447        $inputs.each(function () {
448            if ($(this).is('[leadfield]')) {
449                if ($(this).attr('leadfield') == 'firstname') {
450                    if ($(this).val() == '') {
451                        valid = false;
452                        $(this).addClass('pdf-newsletterform-error');
453                    } else {
454                        firstnameTxt = $(this);
455                        $(this).removeClass('pdf-newsletterform-error');
456                    }
457                }
458                if ($(this).attr('leadfield') == 'lastname') {
459                    if ($(this).val() == '') {
460                        valid = false;
461                        $(this).addClass('pdf-newsletterform-error');
462                    } else {
463                        lastnameTxt = $(this);
464                        $(this).removeClass('pdf-newsletterform-error');
465                    }
466                }
467                if ($(this).attr('leadfield') == 'emailaddress1') {
468                    if ($(this).val() == '') {
469                        valid = false;
470                        $(this).addClass('pdf-newsletterform-error');
471                    }
472
473                    if (!isEmail($(this).val())) {
474                        valid = false;
475                        $(this).addClass('pdf-newsletterform-error');
476                    } else {
477                        epostTxt = $(this);
478                        $(this).removeClass('pdf-newsletterform-error');
479                    }
480                }
481                if ($(this).attr('leadfield') == 'hp') {//honeypot anti spam
482                    if ($("#hp-field").val()) {
483                        hpDetected = true;
484                    }
485                }
486            }
487        });
488
489        if (hpDetected) {//honeypot anti spam
490            
491            $.ajax({
492                type: 'POST',
493                url: window.location,
494                data: form.serialize(),
495                success: function (response) {
496                    alert(response);
497                }
498            });
499
500            firstnameTxt.val('');
501            lastnameTxt.val('');
502            epostTxt.val('Thanks for signing up!');
503        }
504
505
506        if (valid && !hpDetected) {
507
508            $.ajax({
509                type: 'POST',
510                url: form.attr('action'),
511                data: form.serialize(),
512                success: function (response) {
513                    alert(response);
514                }
515            });
516
517            firstnameTxt.val('');
518            lastnameTxt.val('');
519            epostTxt.val('Thanks for signing up!');
520        }
521    })
522}
523
524//function clearNewsLetterFields()
525//{
526//    var $inputs = $('#clickdimensionsForm :input');
527
528//    $inputs.each(function () {
529//        if ($(this).is('[leadfield]')) {
530//            if ($(this).attr('leadfield') == 'firstname') {
531//                if ($(this).val() == '') {
532//                    valid = false;
533//                    $(this).addClass('pdf-newsletterform-error');
534//                } else {
535//                    firstname = $(this).val();
536//                    $(this).removeClass('pdf-newsletterform-error');
537//                }
538//            }
539//            if ($(this).attr('leadfield') == 'lastname') {
540//                if ($(this).val() == '') {
541//                    valid = false;
542//                    $(this).addClass('pdf-newsletterform-error');
543//                } else {
544//                    lastname = $(this).val();
545//                    $(this).removeClass('pdf-newsletterform-error');
546//                }
547//            }
548//            if ($(this).attr('leadfield') == 'emailaddress1') {
549//                if ($(this).val() == '') {
550//                    valid = false;
551//                    $(this).addClass('pdf-newsletterform-error');
552//                }
553
554//                if (!isEmail($(this).val())) {
555//                    valid = false;
556//                    $(this).addClass('pdf-newsletterform-error');
557//                } else {
558//                    emailaddress1 = $(this).val();
559//                    $(this).removeClass('pdf-newsletterform-error');
560//                    emailvalid = true;
561//                }
562//            }
563//        }
564//    });
565//}
566
567function initNewsListFilter()
568{
569    var roolLink = $("#RootLink_ID").val();
570    var useCache = $("#UseCache").val();
571
572    var $yearcontainer = $("#news-list-year-selector");
573    var $monthcontainer = $("#news-list-month-selector");
574
575    var roolLink = $("#RootLink_ID").val();
576    var useCache = $("#UseCache").val();
577    var count = 0;
578    
579
580    $(".attribute-item", $yearcontainer)
581        .on('click',
582            function (e) {
583                e.preventDefault();
584
585                var year = $(this).data("value");
586                $('#hYear').val(year);                
587                var month = $('#hMonth').val();
588                var currentLang = $('#currentLang').val();
589
590                $('#span-news-year').html($(this).html());//.html($(this).data("value"));
591
592                $.post("/FilterNewsList",
593                    { rootLinkId: roolLink, useCache: useCache, year: year, month: month, count: count, lang : currentLang },
594                    function (data) {
595                        $("#news-list-placeholder").html('');
596                        $("#news-list-placeholder").html(data);
597                        initListPager();
598                    })
599                .fail(function () {
600                    alert('error');
601                });
602            });
603
604    $(".attribute-item", $monthcontainer)
605        .on('click',
606            function (e) {
607                e.preventDefault();
608                
609                var month = $(this).data("value");
610                $('#hMonth').val(month);
611                var year = $('#hYear').val();
612
613                var currentLang = $('#currentLang').val();
614
615                $('#span-news-month').html($(this).html());
616
617                $.post("/FilterNewsList",
618                    { rootLinkId: roolLink, useCache: useCache, year: year, month: month, count: count, lang: currentLang },
619                    function (data) {
620                        $("#news-list-placeholder").html('');
621                        $("#news-list-placeholder").html(data);
622                        initListPager();
623                    })
624                .fail(function () {
625                    alert('error');
626                });
627            });
628
629    
630
631
632}
633
634
635function initRemoveProductFilter() {
636    //var $container = $("#attributes-selector");
637    $(".btn-attribute")//, $container)
638        .on('click',
639            function (e) {
640                e.preventDefault();
641                var roolLink = $("#RootLink_ID").val();
642                var useCache = $("#UseCache").val();
643                var removeId = $(this).data("value");
644                var currentLang = $("#currentLang").val();
645
646
647                var showProducts = $("#ShowProducts").val();
648                var showCaseStudies = $("#ShowCaseStudies").val();
649                var showAccessories = $("#ShowAccessories").val();
650                var allowedCategories = $("#AllowedCategories").val();
651                
652
653                $.post("/CategoriesNavigationPage/RemoveFilter",
654                    { id: removeId, useCache: useCache, rootId: roolLink, showProducts: showProducts, showCaseStudies: showCaseStudies, showAccessories: showAccessories, allowedCategories: allowedCategories, lang : currentLang },
655                        function (data) {
656                            $("#product-filter-categories-content").html(data);
657                            $.post("/CategoriesNavigationPage/ShowPartialFiltererAttributes",
658                                    { pageId: roolLink, allowedCategories: allowedCategories, lang: currentLang },
659                                    function (data) {
660                                        $("#attributes-container").html(data);
661                                        //initRemoveProductFilter();
662                                    })
663                                .fail(function () {
664                                    alert('error');
665                                });
666                            //$(this).hide();
667                        })
668                    .fail(function () {
669                        alert('error');
670                    });
671
672            });
673}
674
675
676
677function initProductFilter() {
678    var $container = $(".attributes-selector");
679    $(".attribute-item",$container)
680        .on('click',
681            function (e) {
682                e.preventDefault();
683                var roolLink = $("#RootLink_ID").val();
684                var useCache = $("#UseCache").val();
685                var currentLang = $("#currentLang").val();
686
687                var showProducts = $("#ShowProducts").val();
688                var showCaseStudies = $("#ShowCaseStudies").val();
689                var showAccessories = $("#ShowAccessories").val();
690                var allowedCategories = $("#AllowedCategories").val();
691
692                $.post("/CategoriesNavigationPage/ApplyFilter",
693                        { id: $(this).data("value"), useCache: useCache, rootId: roolLink, showProducts: showProducts, showCaseStudies: showCaseStudies, showAccessories: showAccessories, allowedCategories: allowedCategories, lang : currentLang },
694                        function (data) {
695                            $("#product-filter-categories-content").html(data);
696                            $.post("/CategoriesNavigationPage/ShowPartialFiltererAttributes",
697                                    { pageId: roolLink, allowedCategories: allowedCategories, lang: currentLang },
698                                    function (data) {
699                                        $("#attributes-container").html(data);
700                                        initRemoveProductFilter();
701                                    })
702                                .fail(function () {
703                                    alert('error');
704                                });
705                        })
706                    .fail(function () {
707                        alert('error');
708                    });
709
710
711            });
712
713    //$("#product-categories-items")
714    //    .on('change',
715    //        function(e) {
716    //            var roolLink = $("#RootLink_ID").val();
717    //            var useCache = $("#UseCache").val();
718
719    //            $.post("/CategoriesNavigationPage/ApplyFilter",
720    //                    { id: this.value, useCache: useCache, rootId: roolLink },
721    //                    function(data) {
722    //                        $("#product-filter-categories-content").html(data);
723    //                    })
724    //                .fail(function() {
725    //                    alert('error');
726    //                });
727
728    //        });
729}
730
731/*
732function initNewsletter() {
733    $('.btn-submit-newsletter-doit').click(function (e) {
734        e.stopImmediatePropagation();
735        e.preventDefault();
736        var currentBlock = $("#newsletterform").serializeArray();//Funkar ej
737
738
739        var name = $("#FirstName").val();
740        var lname = $("#LastName").val();
741        var email = $("#Email").val();
742        var remail = $("#ReceivingEmail").val();
743        
744        
745        $.post("/Newsletter/NewsletterBlock", { firstName: name, lastName: lname, email: email, receivingEmail: remail }, function (data) {
746                $("#LastName").val('wow');
747            }).fail(function () {
748                alert('error');
749            });
750
751        
752        $.post('/Newsletter/SignUpForNewsletter', { firstName: name, lastName: lname, email: email, receivingEmail: remail },
753                function (resultData, status) {
754                    if (status == "success") {
755                        if (resultData.success) {
756                            $("#LastName").val('wow2');
757                        }
758                    } else {
759                        $("#LastName").val('ops');
760                    }
761                });
762        
763
764
765        //$.post("/Newsletter/NewsletterBlock", function (data) {
766        //    alert('oh nelly');
767        //});       
768            
769
770        //$.ajax({
771        //    url: '/Newsletter/NewsletterBlock',
772        //    data: currentBlock, // alternatively try: {id: id}
773        //    type: 'POST',
774        //    success: function (data) { }
775        //});
776
777    });
778}
779*/
780
781
782/* http://www.bootply.com/66815
783*/
784function initListPager() {
785    var listElement = $('.pagination-list');    
786
787    var noitems = $('#pagination-items-per-page').val();
788
789    var perPage = parseInt(noitems);//2;
790    var numItems = listElement.children(".row").length;
791    var numPages = Math.ceil(numItems / perPage);
792
793    if (numPages > 1) {
794        $('.pagination').data("curr", 0);
795
796        var curr = 0;
797        while (numPages > curr) {
798            $('<li class="link"><a href="#" class="page_link">' + (curr + 1) + '</a></li>').insertBefore('li.next');
799            curr++;
800        }
801
802        $('.pagination li.link:first').addClass('active');
803
804        listElement.children().css('display', 'none');
805        listElement.children().slice(0, perPage).css('display', 'block');
806
807        $('.pagination li.link a').click(function (e) {
808            e.preventDefault();
809            var clickedPage = $(this).html().valueOf() - 1;
810            goTo(clickedPage, perPage);
811        });
812
813        $('.pagination li.prev').click(function (e) {
814            e.preventDefault();
815            previous();
816        });
817        function previous() {
818            var goToPage = parseInt($('.pagination').data("curr")) - 1;
819            if ($('.link.active').prev('.link').length == true) {
820                goTo(goToPage);
821            }
822        }
823
824        $('.pagination li.next').click(function (e) {
825            e.preventDefault();
826            next();
827        });
828        function next() {
829            goToPage = parseInt($('.pagination').data("curr")) + 1;
830            if ($('.link.active').next('.link').length == true) {
831                goTo(goToPage);
832            }
833        }
834
835        function goTo(page) {
836            var startAt = page * perPage,
837              endOn = startAt + perPage;
838            listElement.children().css('display', 'none').slice(startAt, endOn).css('display', 'block');
839            $('.pagination').data("curr", page);
840            $("li.active").removeClass("active");
841            $($("li.link")[page]).addClass("active");
842            $(window).scrollTop(0);
843        }
844    } else {
845        $(".pagination").hide();
846    }    
847}
848
849/* Download links popup form */
850$(document).ready(function () {
851    $("#btnAddSave")
852   .click(function (e) {
853       e.preventDefault();
854
855       var objectArray = $('#newPerson :input').serializeArray();
856
857       var form = $('#newPerson');
858
859       var dataToPost = "";
860       for (var i = 0; i < objectArray.length; i++) {
861           dataToPost += "&" + objectArray[i]["name"] + "=" + objectArray[i]["value"];
862       }
863
864       $.post("/Newsletter/AllowPdfDownload", { model: dataToPost }, function (data) {
865           if (data.success) {
866               closeDialog(data.firstname, data.lastname, data.email, data.phone, data.zipcode, data.city, data.company, data.usecookie);
867           } else {
868               $("#txtFirstName", form).val('no mucacho');
869           }
870       }).fail(function () {
871           alert('error');
872       });
873   });
874})
875
876var downloadURL = ""; //GlobalVar
877var downloadName = ""; //GlobalVar
878var showOnline = ""; //GlobalVar
879var requiresform = ""; //GlobalVar
880
881//$(document).ready(function () {
882//    $('#newPerson').dialog({
883//        autoOpen: false,
884//        draggable: false,
885//        resizable: false,
886//        modal: true,
887//        width: 400,
888//        title: 'Download file',
889//        Cancel: function () {
890//            $(this).dialog("close");
891//            //open: function (type, data) {
892//            //    $(this).parent().appendTo("form");
893//        }
894//    });
895//});
896
897//function showDialog(id) {
898//    var userdata = getCookie("constructorusername");
899//    var show = "true";
900//    if (show != "true") {
901//        resumeDownload(downloadURL);
902//        return false;
903//    }
904//    if (userdata != null && userdata != "") {
905//        //$('#newPerson input:checkbox').parents('label').css('display', 'none');
906//        var splitUserdata = userdata.split(":");
907//        // assign the values of the array to variables and write to the page
908//        var userFirstName = (splitUserdata[0]);
909//        var userEmail = (splitUserdata[1]);
910//        var userPhone = (splitUserdata[2]);
911//        var userZip = (splitUserdata[3]);
912//        var userCityState = (splitUserdata[4]);
913//        var userCompany = (splitUserdata[5]);
914//        var userLastName = (splitUserdata[6]);
915
916//        $("#txtFirstName").val(userFirstName);
917//        $("#txtLastName").val(userLastName);
918//        $("#txtEmail").val(userEmail);
919//        $("#txtPhone").val(userPhone);
920//        $("#txtZipcode").val(userZip);
921//        $("#txtCityState").val(userCityState);
922//        $("#txtCompany").val(userCompany);
923//    }
924//    $("#HiddenField1").val(window.downloadURL);    
925//    $('#pdfdwlink').val($("#HiddenField1").val())
926//    $("#show-online").val($(this).attr('data-show'));
927//    $('#' + id).dialog("open");
928//}
929function saveDetailsToCookie(form) {
930    var name = $(form).attr('id');
931    var data = $(".js-save-to-cookie", form).serializeJSON(); //Only save visible fields
932    setCookie(name, data, 360);
933}
934function loadFormFromCookie(form) {
935    var name = $(form).attr('id');
936    var data = getCookie(name, true);
937
938    if (typeof data === 'undefined' || data === "") {
939        return;
940    }
941
942    JSON.parse(data, function (key, value) {
943        if (typeof (value) !== 'object') {
944            var el = $(form).find('*[name="' + key + '"]');
945
946            if (el.is('input')) {
947                if (false) {
948                    // code formatting stub
949                } else if (el.attr('type') === 'number') {
950                    el.val(ensureNumber(value));
951                } else if (el.attr('type') === 'checkbox') {
952                    if (el.val() === value) $(el).prop('checked', true);
953                } else if (el.attr('type') === 'radio') {
954                    $.each(el, function (_, elc) {
955                        if (elc.value === value) $(elc).prop('checked', true);
956                    });
957                } else {
958                    el.val(value);
959                }
960            } else if (el.is('select')) {
961                el.val(value);
962            } else if (el.is('textarea')) {
963                el.val(value);
964            }
965        }
966    });
967};
968function closeDialog(firstname, lastname, email, phone, zipcode, citystate, company, allowCookie) {
969    var value = firstname + ":" + email + ":" + phone + ":" + zipcode + ":" + citystate + ":" + company + ":" + lastname;
970    if (allowCookie) {
971        setCookie("constructorusername", value, 360);
972    }
973    $("#downloadModal").modal("hide");
974    resumeDownload(downloadURL, downloadName);
975}
976
977function getCookie(c_name, base64Decode) {
978    var i, x, y, ARRcookies = document.cookie.split(";");
979    for (i = 0; i < ARRcookies.length; i++) {
980        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
981        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
982        x = x.replace(/^\s+|\s+$/g, "");
983        if (x == c_name) {
984            if (base64Decode) {
985                return atob(y);
986            }
987            return y;
988        }
989    }    
990}
991
992function setCookie(c_name, value, exdays) {
993    var exdate = new Date();
994    exdate.setDate(exdate.getDate() + exdays);
995    var c_value = btoa(JSON.stringify(value)) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
996    document.cookie = c_name + "=" + c_value;
997}
998
999
1000//$(document).ready(function () {
1001//    $("a.downloadlink").click(function (e) {
1002//        e.preventDefault();
1003//    });
1004
1005//    $('a.downloadlink').mousedown(function (e) {
1006
1007//        var event = e;
1008//        e.preventDefault();
1009//        if (event == null) {
1010//            event = window.event;
1011//        }
1012//        var mouseclick = event.button;
1013//        downloadURL = $(this).attr("data-id");
1014//        event.preventDefault();
1015
1016//        $('#' + 'newPerson').dialog("open");
1017
1018//        if (mouseclick == 0 || mouseclick == 1 || (mouseclick == 2 && downloadURL.indexOf('.pdf') != -1)) {
1019//            showDialog('newPerson');
1020//        }
1021
1022//        return false;
1023//    });
1024//});
1025
1026
1027function setcookiedataforpdf()
1028{
1029    var userdata = getCookie("constructorusername");
1030
1031    if (userdata) {
1032        var splitUserdata = userdata.split(":");
1033
1034        var $inputs = $('#clickdimensionsForm :input');
1035
1036        
1037        var myDictionary = {};
1038        for(i= 0; i < splitUserdata.length; i++)
1039        {
1040            myDictionary[splitUserdata[i].split(',')[0]] = splitUserdata[i].split(',')[1];
1041        }
1042
1043        $inputs.each(function () {
1044            if ($(this).is('[leadfield]')) {
1045                //alert($(this).val()); //alert($(this).attr('leadfield'));
1046                if ($(this).attr('leadfield') == 'firstname')
1047                    $(this).val(myDictionary['firstname']);
1048                if ($(this).attr('leadfield') == 'lastname')
1049                    $(this).val(myDictionary['lastname']);
1050                if ($(this).attr('leadfield') == 'emailaddress1') {
1051                    $(this).val(myDictionary['emailaddress1']);
1052                }
1053                if ($(this).attr('leadfield') == 'companyname')
1054                    $(this).val(myDictionary['companyname']);
1055                if ($(this).attr('leadfield') == 'address1_line1')
1056                    $(this).val(myDictionary['address1_line1']);
1057                if ($(this).attr('leadfield') == 'address1_postalcode')
1058                    $(this).val(myDictionary['address1_postalcode']);
1059                if ($(this).attr('leadfield') == 'address1_city')
1060                    $(this).val(myDictionary['address1_city']);
1061                if ($(this).hasClass('pdf-checkbox')) {
1062                    $(this).prop('checked', (myDictionary['savecookie']));
1063                }
1064                if ($(this).attr('leadfield') == 'address2_country')
1065                    $(this).val(myDictionary['address2_country']);
1066            }
1067        });
1068    
1069
1070
1071        //$inputs.each(function () {
1072        //    if ($(this).is('[leadfield]')) {
1073        //        //alert($(this).val()); //alert($(this).attr('leadfield'));
1074        //        if ($(this).attr('leadfield') == 'firstname')
1075        //            $(this).val(splitUserdata[0]);
1076        //        if ($(this).attr('leadfield') == 'lastname')
1077        //            $(this).val(splitUserdata[1]);
1078        //        if ($(this).attr('leadfield') == 'emailaddress1') {
1079        //            $(this).val(splitUserdata[2]);
1080        //        }
1081        //        if ($(this).attr('leadfield') == 'companyname')
1082        //            $(this).val(splitUserdata[3]);
1083        //        if ($(this).attr('leadfield') == 'address1_line1')
1084        //            $(this).val(splitUserdata[4]);
1085        //        if ($(this).attr('leadfield') == 'address1_postalcode')
1086        //            $(this).val(splitUserdata[5]);
1087        //        if ($(this).attr('leadfield') == 'address1_city')
1088        //            $(this).val(splitUserdata[6]);                
1089        //        if ($(this).hasClass('pdf-checkbox')) {
1090        //            $(this).prop('checked', (splitUserdata[7]));
1091        //        }
1092        //        if ($(this).attr('leadfield') == 'address2_country')
1093        //            $(this).val(splitUserdata[8]);
1094        //    }
1095        //});
1096
1097    }
1098}
1099
1100function cleardataforpdfform() {
1101        var $inputs = $('#clickdimensionsForm :input');
1102
1103        $inputs.each(function () {
1104            if ($(this).is('[leadfield]')) {
1105                //alert($(this).val()); //alert($(this).attr('leadfield'));
1106                if ($(this).attr('leadfield') == 'firstname') {
1107                    $(this).val('');
1108                    $(this).removeClass('pdf-form-error');
1109                }
1110                if ($(this).attr('leadfield') == 'lastname') {
1111                    $(this).val('');
1112                    $(this).removeClass('pdf-form-error');
1113                }
1114                if ($(this).attr('leadfield') == 'emailaddress1') {
1115                    $(this).val('');
1116                    $(this).removeClass('pdf-form-error');
1117                }
1118                if ($(this).attr('leadfield') == 'companyname') {
1119                    $(this).val('');
1120                    $(this).removeClass('pdf-form-error');
1121                }
1122                if ($(this).attr('leadfield') == 'address1_postalcode') {
1123                    $(this).val('');
1124                    $(this).removeClass('pdf-form-error');
1125                }
1126                if ($(this).attr('leadfield') == 'address1_city') {
1127                    $(this).val('');
1128                    $(this).removeClass('pdf-form-error');
1129                }
1130                if ($(this).hasClass('pdf-checkbox')) {
1131                    $(this).prop('checked', (''));
1132                }
1133                if ($(this).attr('leadfield') == 'address2_country') {
1134                    $(this).val('');
1135                    $(this).removeClass('pdf-form-error');
1136                }
1137                if ($(this).attr('leadfield') == 'address1_line1') {
1138                    $(this).val('');
1139                    $(this).removeClass('pdf-form-error');
1140                }
1141            }
1142        });    
1143}
1144
1145function initDownloadModelOpen() {
1146    $(".pdf-btn-link").click(function () {
1147        var d = $(this).attr('data-download');
1148        var fileholder = $("#FormFieldTopic", "#downloadModal"); //$('#downloadModal').find('#' + $('#FormFieldTopic').val());
1149        fileholder.val(fileholder.val().replace("{file_name}", d)); //('PDF Download notice ' + window.location.hostname + ' - ' + d);
1150        $('#pdf-form-emptyfield').hide();
1151        $('#pdf-form-email-error').hide();       
1152    });
1153
1154    $(".pdf-btn-dwnl-link").click(function () {
1155        var url = $(this).attr('data-id');
1156        var name = $(this).attr('data-download');
1157        var _showonline = $(this).data("showonline");;
1158
1159        resumeDownload(url,name, _showonline);
1160    });
1161
1162    
1163
1164    $('#downloadModal')
1165        .on('show.bs.modal',
1166            function (e) {
1167                var downloadButton = e.relatedTarget;
1168                console.log(downloadButton);
1169                downloadURL = $(downloadButton).data("id"); //GlobalVar
1170                downloadName = $(downloadButton).data("download"); //GlobalVar
1171                showOnline = $(downloadButton).data("showonline"); //GlobalVar
1172                //requiresform = $(downloadButton).data("requiresform"); //GlobalVar
1173                loadFormFromCookie($("form", this));
1174            });
1175
1176
1177    $("#close-pdf-form")
1178   .click(function (e) {
1179       cleardataforpdfform();
1180   });
1181
1182   // $("#postPdfForm")
1183   //.click(function (e) {
1184   //    $('#postPdfForm').prop('onclick', null).removeAttr('onclick');
1185   //    e.preventDefault();
1186
1187
1188   //    var valid = true;       
1189   //    var emailvalid = false;
1190
1191   //    var form = $('#clickdimensionsForm');       
1192
1193   //    var $inputs = $('#clickdimensionsForm :input');
1194
1195   //    var savecookie = true;
1196
1197   //    var firstname = "";
1198   //    var lastname = "";
1199   //    var emailaddress1 = "";
1200   //    var companyname = "";
1201   //    var address1_postalcode = "";
1202   //    var address1_city = "";
1203   //    var address1_line1 = "";
1204   //    var address2_country = "";
1205   //     var hpDetected = false;
1206       
1207   //    $inputs.each(function () {
1208   //        if ($(this).is('[leadfield]')) {
1209   //            if ($(this).attr('leadfield') == 'firstname')
1210   //            {
1211   //                if ($(this).val() == '') {
1212   //                    valid = false;
1213   //                    $(this).addClass('pdf-form-error');
1214   //                    $('#pdf-form-emptyfield').show();
1215   //                } else {
1216   //                    firstname = $(this).val();
1217   //                    $(this).removeClass('pdf-form-error');
1218   //                }
1219   //            }
1220   //            if ($(this).attr('leadfield') == 'lastname'){
1221   //                if ($(this).val() == '') {
1222   //                    valid = false;
1223   //                    $(this).addClass('pdf-form-error');
1224   //                    $('#pdf-form-emptyfield').show();
1225   //                } else {
1226   //                    lastname = $(this).val();
1227   //                    $(this).removeClass('pdf-form-error');
1228   //                }
1229   //            }
1230   //            if ($(this).attr('leadfield') == 'emailaddress1') {
1231   //                if ($(this).val() == '') {
1232   //                    valid = false;
1233   //                    $(this).addClass('pdf-form-error');
1234   //                    $('#pdf-form-emptyfield').show();
1235   //                }
1236
1237   //                if (!isEmail($(this).val())) {
1238   //                    valid = false;
1239   //                    $(this).addClass('pdf-form-error');
1240   //                    $('#pdf-form-email-error').show();
1241
1242   //                    if(!$(this).val() == '')
1243   //                     $('#pdf-form-emptyfield').hide();
1244
1245   //                } else {
1246   //                    emailaddress1 = $(this).val();
1247   //                    $(this).removeClass('pdf-form-error');
1248   //                    emailvalid = true;
1249   //                }
1250   //            }
1251   //            if ($(this).attr('leadfield') == 'companyname'){
1252   //                if ($(this).val() == '') {
1253   //                    valid = false;
1254   //                    $(this).addClass('pdf-form-error');
1255   //                    $('#pdf-form-emptyfield').show();
1256   //                } else {
1257   //                    companyname = $(this).val();
1258   //                    $(this).removeClass('pdf-form-error');
1259   //                }
1260   //            }
1261   //            if ($(this).attr('leadfield') == 'address1_postalcode'){
1262   //                if ($(this).val() == '') {
1263   //                    valid = false;
1264   //                    $(this).addClass('pdf-form-error');
1265   //                    $('#pdf-form-emptyfield').show();
1266   //                } else {
1267   //                    address1_postalcode = $(this).val();
1268   //                    $(this).removeClass('pdf-form-error');
1269   //                }
1270   //            }
1271   //            if ($(this).attr('leadfield') == 'address1_city'){
1272   //                if ($(this).val() == '') {
1273   //                    valid = false;
1274   //                    $(this).addClass('pdf-form-error');
1275   //                    $('#pdf-form-emptyfield').show();
1276   //                } else {
1277   //                    address1_city = $(this).val();
1278   //                    $(this).removeClass('pdf-form-error');
1279   //                }
1280   //            }
1281   //            if ($(this).attr('leadfield') == 'address1_line1') {
1282   //                if ($(this).val() == '') {
1283   //                    valid = false;
1284   //                    $(this).addClass('pdf-form-error');
1285   //                    $('#pdf-form-emptyfield').show();
1286   //                } else {
1287   //                    address1_line1 = $(this).val();
1288   //                    $(this).removeClass('pdf-form-error');
1289   //                }
1290   //            }
1291   //            if ($(this).attr('leadfield') == 'address2_country') {
1292   //                if ($(this).val() == '') {
1293   //                    valid = false;
1294   //                    $(this).addClass('pdf-form-error');
1295   //                    $('#pdf-form-emptyfield').show();
1296   //                } else {
1297   //                    address2_country = $(this).val();
1298   //                    $(this).removeClass('pdf-form-error');
1299   //                }
1300   //            }               
1301   //            if ($(this).attr('leadfield') == 'hp') {//honeypot anti spam
1302   //                if ($("#hp-field").val()) {
1303   //                    hpDetected = true;
1304   //                }
1305   //            }
1306
1307   //            if($(this).hasClass('pdf-checkbox')){
1308   //                savecookie = $(this).is(':checked');
1309   //            }
1310   //        }           
1311   //    });
1312
1313   //     if (hpDetected) {//honeypot anti spam
1314
1315   //        //});
1316   //         $.ajax({
1317   //             type: 'POST',
1318   //             url: window.location,
1319   //             data: form.serialize(),
1320   //             success: function (response) {
1321   //                 alert(response);
1322   //             }
1323   //         });
1324
1325   //         firstnameTxt.val('');
1326   //         lastnameTxt.val('');
1327   //         epostTxt.val('Thanks for signing up!');
1328   //     }
1329
1330   //     if (valid && !hpDetected) {
1331
1332   //        $('#pdf-form-emptyfield').hide();
1333   //        $('#pdf-form-email-error').hide();
1334   //        $.ajax({
1335   //            type: 'POST',
1336   //            url: form.attr('action'),
1337   //            data: form.serialize(),
1338   //            success: function (response) {
1339   //                alert(response);
1340   //            }
1341   //        });
1342
1343   //        if(savecookie)
1344   //        {
1345   //            //var value = firstname + ":" + lastname + ":" + emailaddress1 + ":" + companyname + ":" + address1_postalcode + ":" + address1_city + ":" + savecookie;
1346   //            var value = 'firstname,' + firstname +
1347   //                ":" + 'lastname,' + lastname +
1348   //                ":" + 'emailaddress1,' + emailaddress1 +
1349   //                ":" + 'companyname,' + companyname +
1350   //                ":" + 'address1_line1,' + address1_line1 +
1351   //                ":" + 'address1_postalcode,' + address1_postalcode +
1352   //                ":" + 'address1_city,' + address1_city +
1353   //                ":" + 'savecookie,' + savecookie +
1354   //                ":" + 'address2_country,' + address2_country;
1355
1356   //            setCookie("constructorusername", value, 20);
1357   //        } else {
1358   //            //empty cookie
1359   //            var value = "";
1360   //            setCookie("constructorusername", value, 20);
1361   //            //clear all the fields in the form
1362   //            cleardataforpdfform();
1363   //        }
1364   //        resumeDownload(downloadURL, downloadName, showOnline);
1365   //    }else{
1366   //        if(emailvalid)
1367   //            $('#pdf-form-email-error').hide();           
1368   //    }
1369
1370
1371   //});
1372}
1373
1374function isEmail(email) {
1375    var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
1376    return regex.test(email);
1377}
1378
1379function resumeDownload(url,name, showonline) {
1380    
1381
1382    //If it should be downloaded or shown online
1383    if (showonline === false) {
1384        $('#hiddendwl').attr('download', name);
1385    } else {
1386        $('#hiddendwl').removeAttr("download");
1387        $('#hiddendwl').attr('target', "_blank");
1388    }
1389    $('#hiddendwl').attr('href', url);
1390    $('#hiddendwl')[0].click();
1391    $('#hiddendwl').attr('download', '');
1392    $('#hiddendwl').attr('href', '');
1393    $('#hiddendwl').removeAttr("target");
1394    downloadURL = "";
1395    downloadName = "";
1396    showOnline = "";
1397
1398    //$('#close-pdf-form')[0].click();
1399    
1400}
1401
1402function initMegaMenuFunctions() {
1403    $(".btn-mega-manu-show-all")
1404       .on('click',
1405           function (e) {
1406               e.preventDefault();
1407
1408               var ul = $(this).parent().find('ul');
1409               var li = ul.children('li');
1410
1411               li.each(function () {
1412                   $(this).removeClass('mega-menu-hide-item');
1413               });
1414
1415               //var ul = $(this).parent();
1416               //var li = ul.children('li');
1417
1418               //li.each(function () {
1419               //    $(this).removeClass('mega-menu-hide-item');
1420               //});
1421           });
1422
1423    $('.btn-mega-manu-show-all').mouseenter(function () {
1424        var ul = $(this).parent().find('ul');
1425                   var li = ul.children('li');
1426
1427                   li.each(function () {
1428                       $(this).removeClass('mega-menu-hide-item');
1429                   });
1430                   $(this).hide();
1431    });
1432}
1433
1434function expandextraitems() {
1435 
1436    $(this).hide();
1437    var parent = $(this).parent();
1438    var ul = parent.find('ul');
1439               var li = ul.children('li');
1440
1441               li.each(function () {
1442                   $(this).removeClass('mega-menu-hide-item');
1443               });    
1444}
1445
1446function initModalOnMouseOut(modalId, showAfter) {
1447
1448    var showAfterMs = showAfter * 1000;
1449    console.log("initModalOnMouseOut armed: " + modalId + " showAfter: " + showAfter);
1450
1451    setTimeout(function () {
1452        addEvent(document, "mouseout", function (e) {
1453            e = e ? e : window.event;
1454            var from = e.relatedTarget || e.toElement;
1455            if (!from || from.nodeName == "HTML") {
1456                if (!document.cookie.match(modalId + "Shown") && !$(".modal").hasClass('in')) {
1457                    createCookie(modalId + "Shown", "true", 1);
1458                    $("#" + modalId).modal();
1459                }
1460            }
1461        });
1462    }, showAfterMs);
1463}
1464
1465function initTimedModal(modalId, showAfter) {
1466    var showAfterMs = showAfter * 1000;
1467    console.log("initTimedModal armed: " + modalId + " showAfter: " + showAfter);
1468    setTimeout(function () {
1469        if (!document.cookie.match(modalId + "Shown") && !$(".modal").hasClass('in')) {
1470            createCookie(modalId + "Shown", "true", 1);
1471            $("#" + modalId).modal();
1472        }
1473    }, showAfterMs);
1474
1475    
1476}
1477
1478function initBSMenuClickFix() {
1479    //$('.dropdown-menu').on("click.bs.dropdown", function (e) { e.stopPropagation(); e.preventDefault(); });
1480    $(document).on('click', 'header .dropdown-menu', function (e) {
1481        e.stopPropagation();
1482    });
1483}
1484
1485function initSubDropDown() {
1486    $(".js-sub-dropdown-toggle").click(function() { $(this).next(".js-sub-dropdown").toggleClass("hidden") });
1487}
1488
1489function setCookieInfo() {
1490    createCookie("CookieInfo", "true", 7);
1491
1492    var cookieNotifications = document.querySelectorAll("#cookie_info");
1493
1494    //cookieNotifications.forEach(function (cookie) { //IE11 Cant handle forEac
1494h
1495    //    cookie.style = "display:none; !important";
1496    //    cookie.classList.remove("visible-xs");
1497    //});
1498
1499    for (var i = 0, len = cookieNotifications.length; i < len; i++) {
1500        var cookie = cookieNotifications[i];
1501        cookie.style = "display:none; !important";
1502        cookie.classList.remove("visible-xs");
1503    }
1504    if (isIE()) {
1505		$("#cookie_info").hide();
1506    }
1507}
1508
1509function addEvent(obj, evt, fn) {
1510    if (obj.addEventListener) {
1511        obj.addEventListener(evt, fn, false);
1512    }
1513    else if (obj.attachEvent) {
1514        obj.attachEvent("on" + evt, fn);
1515    }
1516}
1517
1518function createCookie(name, value, days) {
1519    var expires = "";
1520    if (days) {
1521        var date = new Date();
1522        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
1523        expires = "; expires=" + date.toUTCString();
1524    }
1525    document.cookie = name + "=" + value + expires + "; path=/";
1526}
1527
1528function isIE() {
1529    ua = navigator.userAgent;
1530    /* MSIE used to detect old browsers and Trident used to newer ones*/
1531    var is_ie = ua.indexOf("MSIE ") > -1 || ua.indexOf("Trident/") > -1;
1532
1533    return is_ie;
1534}
1535
1536function handlePardotForm() {
1537    $(".required input, .required textarea", $("#pardot-form")).attr("required", "required");
1538    $("#pardot-form").submit(function (event) {
1539        var $this = $(this);
1540        $this.disable;
1541        //$("#pardot-form").data("pardot-submit", $("#pardot-form").attr("action"));
1542        var submitUrl = $this.attr("action");
1543        var redirectSuccess = $this.data("successfullSubmit");
1544        var redirectError = $this.data("unsuccessfullSubmit");
1545        var formData = $this.serialize();
1546
1547        console.log("Intercepted submit of " + $(this));
1548        event.preventDefault();
1549        postForm(submitUrl, formData, redirectSuccess, redirectError);
1550    });
1551
1552    function postForm(url, formData, redirectSuccess, redirectError) {
1553        var test123 = 123;
1554        $.ajax({
1555            type: "POST",
1556            url: url,
1557            data: formData,
1558            done: done(redirectSuccess),
1559            fail: fail(redirectError),
1560            dataType: "jsonp"
1561        });
1562    }
1563
1564    function done(redirectLink) {
1565        console.log("Done. Redirect to: " + redirectLink);
1566        //window.location = redirectLink;
1567    };
1568    function fail(redirectLink) {
1569        console.log("Fail. Redirect to: " + redirectLink);
1570        //window.location = redirectLink;
1571    };
1572}
1573
1574function initCookieCon3() {
1575    var necCookies = getNecCookieInformation();
1576    var group2Cookies = getGroup2CookieInformation();
1577    var group3Cookies = getGroup3CookieInformation();
1578    
1579    CookieConsent.run({
1580        onModalHide: ({modalName}) => {
1581            initCookieConsentSettingsButton();
1582        },
1583
1584        onFirstConsent: () => {
1585            logConsent();
1586        },
1587    
1588        onChange: () => {
1589            logConsent();
1590        },
1591
1592        cookie: {
1593            domain: (() => {
1594                const hostname = window.location.hostname;
1595                const knownPublicSuffixes = ['co.uk', 'com.au', 'com.cy'];
1596        
1597                const parts = hostname.split('.');
1598                const baseDomain = (() => {
1599                    for (const suffix of knownPublicSuffixes) {
1600                        if (hostname.endsWith(suffix)) {
1601                            const domainParts = hostname.split('.');
1602                            return '.' + domainParts.slice(-suffix.split('.').length - 1).join('.');
1603                        }
1604                    }
1605        
1606                    if (parts.length > 2) {
1607                        return '.' + parts.slice(-2).join('.');
1608                    }
1609        
1610                    return '.' + hostname;
1611                })();
1612        
1613                return baseDomain;
1614            })(),
1615        },
1616
1617        disablePageInteraction:true,
1618        guiOptions: {
1619            consentModal: {
1620                layout: 'bar',
1621                position: 'bottom center',
1622
1623            },
1624            preferencesModalOptions: {
1625                layout: 'box'
1626            }
1627        },
1628
1629
1630        categories: {
1631            necessary_cookies: {
1632                enabled: true,  // this category is enabled by default
1633                readOnly: true  // this category cannot be disabled
1634            },
1635            ad_cookies: {
1636
1637            },
1638/*            analytics_cookies: {},*/
1639            analytics_cookies: {
1640                //services: {
1641                //    ga: {
1642                //        label: 'Google Analytics',
1643                //        onAccept: () => {
1644                //            // enable ga
1645                //        },
1646                //        onReject: () => {
1647                //            // disable ga
1648                //        },
1649                //        cookies: [
1650                //            {
1651                //                name: /^(_ga|_gid)/,
1652                //                domain: "hejhej.com",
1653
1654                //            }
1655                //        ]
1656                //    },
1657                //    new_service: {
1658                //        label: 'Another Service',
1659                //        onAccept: () => {
1660                //            // enable new_service
1661                //        },
1662                //        onReject: () => {
1663                //            // disable new_service
1664                //        },
1665                //        cookies: [
1666                //            {
1667                //                name: 'cc_cookie',
1668                //                domain: window.location.hostname,
1669                //                path: '/',
1670                //                expiresAfterDays: 182,
1671                //                sameSite: 'Lax',
1672                //            }
1673                //        ]
1674                //    }
1675                //}
1676            }
1677        },
1678
1679        language: {
1680            default: 'en',
1681            translations: {
1682                en: {
1683                    consentModal: {
1684                        title: cookieConsentSettings.MainHeading + '<img src="/Static/img/cookie.png" alt="Cookie">',
1685                        description: cookieConsentSettings.MainContent,
1686                        acceptAllBtn: cookieConsentSettings.SettingsBtnAcceptAll,
1687                        acceptNecessaryBtn: '',
1688                        showPreferencesBtn: cookieConsentSettings.SettingsBtnSett
1688ings
1689                    },
1690                    preferencesModal: {
1691                        title: cookieConsentSettings.SettingsModalHeading,
1692                        acceptAllBtn: cookieConsentSettings.SettingsBtnAcceptAll,
1693                        acceptNecessaryBtn: '',
1694                        savePreferencesBtn: cookieConsentSettings.SettingsBtnSaveSettings,
1695                        closeIconLabel: 'Close modal EN',
1696                        sections: [
1697                            {
1698                                title: cookieConsentSettings.SettingsHeading,
1699                                description: cookieConsentSettings.SettingsContent
1700                            },
1701                            {
1702                                title: cookieConsentSettings.HeadingGroup1,
1703                                description: cookieConsentSettings.GroupDescription1,
1704
1705                                //this field will generate a toggle linked to the 'necessary' category
1706                                linkedCategory: 'necessary_cookies',
1707                                cookieTable: {
1708                                    caption: 'List of cookies',
1709                                    headers: {
1710                                        col1: cookieConsentSettings.SettingsCookieTableHeader1,
1711                                        col2: cookieConsentSettings.SettingsCookieTableHeader2,
1712                                        col3: cookieConsentSettings.SettingsCookieTableHeader3,
1713                                        col4: cookieConsentSettings.SettingsCookieTableHeader4,
1714                                        col5: cookieConsentSettings.SettingsCookieTableHeader5
1715                                    },
1716                                    body: necCookies
1717                                }
1718                            },
1719                            {
1720                                title: cookieConsentSettings.HeadingGroup2,
1721                                description: cookieConsentSettings.GroupDescription2,
1722
1723                                //this field will generate a toggle linked to the 'necessary' category
1724                                linkedCategory: 'analytics_cookies',
1725                                cookieTable: {
1726                                    caption: 'List of cookies',
1727                                    headers: {
1728                                        col1: cookieConsentSettings.SettingsCookieTableHeader1,
1729                                        col2: cookieConsentSettings.SettingsCookieTableHeader2,
1730                                        col3: cookieConsentSettings.SettingsCookieTableHeader3,
1731                                        col4: cookieConsentSettings.SettingsCookieTableHeader4,
1732                                        col5: cookieConsentSettings.SettingsCookieTableHeader5
1733                                    },
1734                                    body: group2Cookies
1735                                }
1736                            },
1737                            {
1738                                title: cookieConsentSettings.HeadingGroup3,
1739                                description: cookieConsentSettings.GroupDescription3,
1740                                linkedCategory: 'ad_cookies',
1741                                cookieTable: {
1742                                    caption: 'List of cookies',
1743                                    headers: {
1744                                        col1: cookieConsentSettings.SettingsCookieTableHeader1,
1745                                        col2: cookieConsentSettings.SettingsCookieTableHeader2,
1746                                        col3: cookieConsentSettings.SettingsCookieTableHeader3,
1747                                        col4: cookieConsentSettings.SettingsCookieTableHeader4,
1748                                        col5: cookieConsentSettings.SettingsCookieTableHeader5
1749                                    },
1750                                    body: group3Cookies
1751                                }
1752                            }
1753                        ]
1754                    }
1755                }
1756            }
1757        }
1758    });
1759    function initCookieConsentSettingsButton() {
1760        var settingsButton = $('<div id="cookieconsent--settings-button"><img src="/Static/img/cookie.png" alt="Cookie" style="width: 25px;"></div>');
1761
1762        $('body').append(settingsButton);
1763
1764        settingsButton.click(function () {
1765            CookieConsent.showPreferences();
1766        });
1767    };
1768
1769    function logConsent(){
1770
1771        // Retrieve all the fields
1772        const cookie = CookieConsent.getCookie();
1773        const preferences = CookieConsent.getUserPreferences();
1774
1775        if (Array.isArray(preferences.acceptedCategories) && preferences.acceptedCategories.includes('analytics_cookies')) {
1776
1777            gtag('consent', 'update', {
1778                'analytics_storage': 'granted'
1779            });
1780            dataLayer.push({ 'event': 'CC-Group2-Allowed' });
1781        } else {
1782            gtag('consent', 'update', {
1783                'analytics_storage': 'denied'
1784            });
1785        }
1786
1787        if (Array.isArray(preferences.acceptedCategories) && preferences.acceptedCategories.includes('ad_cookies')) {
1788
1789            gtag('consent', 'update', {
1790                'ad_storage': 'granted',
1791                'ad_user_data': 'granted',
1792                'ad_personalization': 'granted'
1793            });
1794            dataLayer.push({ 'event': 'CC-Group3-Allowed' });
1795
1796        } else {
1797            gtag('consent', 'update', {
1798                'ad_storage': 'denied',
1799                'ad_user_data': 'denied',
1800                'ad_personalization': 'denied'
1801            });
1802        }
1803
1804        const userConsent = {
1805            websiteId: document.location.host,
1806            consentId: cookie.consentId,
1807            acceptType: preferences.acceptType,
1808            acceptedCategories: preferences.acceptedCategories,
1809            rejectedCategories: preferences.rejectedCategories
1810        };
1811    
1812        // Send the data to your backend
1813        // replace "/your-endpoint-url" with your API
1814
1815        fetch('https://consent-logger-625464912170.europe-west1.run.app/log-consent', {
1816            method: 'POST',
1817            headers: {
1818                'Content-Type': 'application/json'
1819            },
1820            body: JSON.stringify(userConsent)
1821        });
1822    }
1823
1824    function checkCookieExists(cookieName) {
1825        return document.cookie.split(';').some((cookie) => cookie.trim().startsWith(cookieName + '='));
1826    }
1827
1828    //Show initCookieConsentSettingsButton() if consent is already given
1829    if (checkCookieExists('cc_cookie')) {
1830        initCookieConsentSettingsButton();
1831    }
1832}
1833
1834
1835/*var cookieconsent = initCookieConsent();*/
1836function initCookieCon() {
1837
1838    if (typeof cookieConsentSettings === 'undefined') {
1839        return;
1840    }
1841
1842    var necCookies = getNecCookieInformation();
1843    var group2Cookies = getGroup2CookieInformation();
1844    var group3Cookies = getGroup3CookieInformation();
1845
1846    cookieconsent.run({
1847        autorun: true,
1848        delay: 0,
1849        current_lang: 'en',
1850        //theme_css: "/Static/cookieconsent/cookieconsent.css",
1851        autoclear_cookies: true,
1852        force_consent: true,
1853        //autoload_css: true,
1854        cookie_expiration: cookieConsentSettings.CookieConsentExpirationDays,
1855    
1856    
1857        onChange: (cookies) => {
1858            console.log(cookies);
1859            logConsent(cookies);
1860        },
1861
1862
1863        onAccept: function (cookies) {
1864            console.log(cookies);
1865            logConsent(cookies);
1866
1867            initCookieConsentSettingsButton();
1868            
1869            if (cookieconsent.allowedCategory('analytics_cookies')) {
1870
1871                gtag('consent', 'update', {
1872                    'analytics_storage': 'granted'
1873                });
1874                dataLayer.push({ 'event': 'CC-Group2-Allowed' });
1875
1876                if (cookieConsentSettings.InsertJavaScripts) {
1877                    cookieConsentSettings.InsertJavaScripts.forEach(function (item, index) {
1878                        if (item[2] != "Group2")
1879                            return;
1880
1881                        if (item[0] == null) { //No Script SRC to load
1882                            if (item[1] != null) {
1883                                eval(item[1]);
1884                            }
1885                        } else { //Script SRC to load
1886                            cookieconsent.loadScript(item[0], function () {
1887                                if (item[1] != null) {
1888                                    eval(item[1]);
1889                                }
1890                            });
1891                        }
1892
1893                    });
1894                }
1895
1896                //cookieconsent.loadScript('https://www.google-analytics.com/analytics.js', function () {
1897                //    ga('create', 'UA-XXXXXXXX-Y', 'auto');  //replace UA-XXXXXXXX-Y with your tracking code
1898                //    ga('send', 'pageview');
1899                //});
1900            }
1901            if (cookieconsent.allowedCategory('ad_cookies')) {
1902
1903                gtag('consent', 'update', {
1904                    'ad_storage': 'granted',
1905                    'ad_user_data': 'granted',
1906                    'ad_personalization': 'granted'
1907                });
1908                dataLayer.push({ 'event': 'CC-Group3-Allowed' });
1909
1910                if (cookieConsentSettings.InsertJavaScripts) {
1911                    cookieConsentSettings.InsertJavaScripts.forEac
1911h(function (item, index) {
1912                        if (item[2] != "Group3")
1913                            return;
1914
1915                        if (item[0] == null) { //No Script SRC to load
1916                            if (item[1] != null) {
1917                                eval(item[1]);
1918                            }
1919                        } else { //Script SRC to load
1920                            cookieconsent.loadScript(item[0], function () {
1921                                if (item[1] != null) {
1922                                    eval(item[1]);
1923                                }
1924                            });
1925                        }
1926
1927                    });
1928                }
1929
1930                //console.log("Setting test cookie");
1931                //document.cookie = "test123=John Doe; domain=" + window.location.hostname + "; expires=Thu, 18 Dec 2021 12:00:00 UTC";
1932
1933                //cookieconsent.loadScript('https://analytics.clickdimensions.com/ts.js', function () {
1934                //});
1935                //var cdAnalytics = new clickdimensions.Analytics('analytics.clickdimensions.com');
1936                //cdAnalytics.setAccountKey('apcUBjDe4F0GnAmMcKr8YV');
1937                //cdAnalytics.setDomain('@(Request.Url.Host)');
1938                //cdAnalytics.setScore(typeof (cdScore) == "undefined" ? 0 : (cdScore == 0 ? null : cdScore));
1939                //cdAnalytics.trackPage();
1940
1941            }
1942        },
1943        gui_options: {
1944            consent_modal: {
1945                layout: 'bar',               // box/cloud/bar
1946                position: 'bottom center',     // bottom/top + left/right/center
1947                transition: 'slide'             // zoom/slide
1948            },
1949            settings_modal: {
1950                layout: 'box',                 // box/bar
1951                // position : 'left',           // left/right
1952                transition: 'slide'             // zoom/slide
1953            }
1954        },
1955        languages: {
1956            en: {
1957                consent_modal: {
1958                    title: cookieConsentSettings.MainHeading,
1959                    description: cookieConsentSettings.MainContent,//'Hi, this website uses essential cookies to ensure its proper operation and tracking cookies to understand how you interact with it. The latter will be set only upon approval. <a aria-label="Cookie policy" class="cc-link" href="#">Read more</a>',
1960                    primary_btn: {
1961                        text: cookieConsentSettings.SettingsBtnAcceptAll,
1962                        role: 'accept_all'				//'accept_selected' or 'accept_all'
1963                    },
1964                    secondary_btn: {
1965                        text: cookieConsentSettings.SettingsBtnSettings,
1966                        role: 'settings'				//'settings' or 'accept_necessary'
1967                    }
1968                },
1969                settings_modal: {
1970                    title: cookieConsentSettings.SettingsModalHeading,
1971                    save_settings_btn: cookieConsentSettings.SettingsBtnSaveSettings,
1972                    accept_all_btn: cookieConsentSettings.SettingsBtnAcceptAll,
1973                    cookie_table_headers: [
1974                        { col1: cookieConsentSettings.SettingsCookieTableHeader1 }, //Name
1975                        { col2: cookieConsentSettings.SettingsCookieTableHeader2 }, //Domain
1976                        { col3: cookieConsentSettings.SettingsCookieTableHeader3 }, //Expiration
1977                        { col4: cookieConsentSettings.SettingsCookieTableHeader4 }, //Description
1978                        { col5: cookieConsentSettings.SettingsCookieTableHeader5 } //Type
1979                    ],
1980                    blocks: [
1981                        {
1982                            title: cookieConsentSettings.SettingsHeading,//"Cookie usage",
1983                            description: cookieConsentSettings.SettingsContent//'I use cookies to ensure the basic functionalities of the website and to enhance your online experience. You can choose for each category to opt-in/out whenever you want.'
1984                        }, {
1985                            title: cookieConsentSettings.HeadingGroup1,
1986                            description: cookieConsentSettings.GroupDescription1, //'These 
1986cookies are essential for the proper functioning of my website. Without these cookies, the website would not work properly.',
1987                            toggle: {
1988                                value: 'necessary_cookies',
1989                                enabled: true,
1990                                readonly: true
1991                            },
1992                            cookie_table: necCookies
1993                        }, {
1994                            title: cookieConsentSettings.HeadingGroup2,
1995                            description: cookieConsentSettings.GroupDescription2, //'These cookies cookies collect information about how you use the website, which pages you visited and which links you clicked on. All of the data is anonymized and cannot be used to identify you.',
1996                            toggle: {
1997                                value: 'analytics_cookies',
1998                                enabled: cookieConsentSettings.HeadingGroup2AutoEnable,
1999                                readonly: false
2000                            },
2001                            cookie_table: group2Cookies
2002                            //cookie_table: [
2003                            //    {
2004                            //        col1: '_ga',
2005                            //        col2: 'google.com',
2006                            //        col3: '2 years',
2007                            //        col4: 'description ...',
2008                            //        col5: 'Permanent cookie'
2009                            //    },
2010                            //    {
2011                            //        col1: '_gat',
2012                            //        col2: 'google.com',
2013                            //        col3: '1 minute',
2014                            //        col4: 'description ...',
2015                            //        col5: 'Permanent cookie'
2016                            //    },
2017                            //    {
2018                            //        col1: '_gid',
2019                            //        col2: 'google.com',
2020                            //        col3: '1 day',
2021                            //        col4: 'description ...',
2022                            //        col5: 'Permanent cookie'
2023                            //    }
2024                            //]
2025                        }, {
2026                            title: cookieConsentSettings.HeadingGroup3,
2027                            description: cookieConsentSettings.GroupDescription3, //'These cookies cookies collect information about how you use the website, which pages you visited and which links you clicked on. All of the data is anonymized and cannot be used to identify you.',
2028                            toggle: {
2029                                value: 'ad_cookies',
2030                                enabled: cookieConsentSettings.HeadingGroup3AutoEnable,
2031                                readonly: false
2032                            },
2033                            cookie_table: group3Cookies
2034                        }
2035                        //, {
2036                        //    title: cookieConsentSettings.LowInSettingsHeading,
2037                        //    description: cookieConsentSettings.LowInSettingsContentInSettings,
2038                        //}
2039                    ]
2040                }
2041            }
2042        }
2043    });
2044
2045    function initCookieConsentSettingsButton() {
2046        var settingsButton = $('<div id="cookieconsent--settings-button"><img src="/Static/img/cookie.png" alt="Cookie" style="width: 25px;"></div>');
2047
2048        $('body').append(settingsButton);
2049
2050        settingsButton.click(function () {
2051            cookieconsent.showSettings();
2052        });
2053    }
2054}
2055
2056function getNecCookieInformation() {
2057
2058    if (window.necessaryCookiesConsentInformation == null)
2059        return "";
2060
2061    var necCookies = window.necessaryCookiesConsentInformation;
2062    var newObj = generateCookieConsentInfoObj(necCookies);
2063    return newObj;
2064}
2065
2066function getGroup2CookieInformation() {
2067
2068    if (window.group2CookiesConsentInformation == null)
2069        return "";
2070
2071    var necCookies = window.group2CookiesConsentInformation;
2072    var newObj = generateCookieConsentInfoObj(necCookies);
2073    return newObj;
2074}
2075
2076function getGroup3CookieInformation() {
2077
2078    if (window.group3CookiesConsentInformation == null)
2079        return "";
2080
2081    var necCookies = window.group3CookiesConsentInformation;
2082    var newObj = generateCookieConsentInfoObj(necCookies);
2083    return newObj;
2084}
2085
2086function generateCookieConsentInfoObj(input) {
2087    var retVal = [];
2088    input.forEach(function (item, index) {
2089        var itemObj = {
2090            col1: item[0],
2091            col2: item[1],
2092            col3: item[2],
2093            col4: item[3],
2094            col5: item[4]
2095        };
2096        retVal.push(itemObj);
2097    });
2098    return retVal;
2099}
2100
2101//function getInsertJavaScripts() {
2102
2103//    if (cookieConsentSettings.InsertJavaScripts == null)
2104//        return "";
2105
2106//    var scriptsToLoad = {
2107//        group1: [],
2108//        group2: [],
2109//        group3: []
2110//    };
2111
2112//    var scriptsToRun = {
2113//        group1: [],
2114//        group2: [],
2115//        group3: []
2116//    };
2117
2118//    cookieConsentSettings.InsertJavaScripts.forEach(function (item, index) {
2119//        var group;
2120//        if (item[2] != null) { //Group
2121//            group = item[2];
2122//        }
2123        
2124//        if (item[0] != null) { //ScriptToLoad
2125//            addScriptToLoadInGroup(group, item[0]);
2126//        }
2127//        if (item[1] != null) { //ScriptToRun
2128//            addScriptToRunInGroup(group, item[1]);
2129//        }
2130
2131//    });
2132
2133
2134//    function addScriptToLoadInGroup(group, item) {
2135//        switch (group) {
2136//        case "Group1":
2137//            scriptsToLoad.group1.push(item);
2138//            break;
2139//        case "Group2":
2140//            scriptsToLoad.group2.push(item);
2141//            break;
2142//        case "Group3":
2143//            scriptsToLoad.group3.push(item);
2144//            break;
2145//        }
2146//    }
2147
2148//    function addScriptToRunInGroup(group, item) {
2149//        switch (group) {
2150//        case "Group1":
2151//            scriptsToRun.group1.push(item);
2152//            break;
2153//        case "Group2":
2154//            scriptsToRun.group2.push(item);
2155//            break;
2156//        case "Group3":
2157//            scriptsToRun.group3.push(item);
2158//            break;
2159//        }
2160//    }
2161
2162//    return {
2163//        scriptsToLoad: scriptsToLoad,
2164//        scriptsToRun: scriptsToRun
2165//    };
2166//}

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.