PageSourceSearch

https://www.4home.pl/bundles/main?v=Zw38ExA5O7Zwlbpl_gsqRCIK9-GSShNZhj8d1j3ROmU1

js 4home.pl collected 2026-09-29 11:23:53 UTC 127,030 bytes, 2,646 lines download raw bytes

1/* Minification failed. Returning unminified contents.
2(2157,5-6): run-time error JS1009: Expected '}': [
3(2157,8): run-time error JS1004: Expected ';'
4(2157,8-9): run-time error JS1195: Expected expression: :
5(2158,10): run-time error JS1004: Expected ';'
6(2158,10-11): run-time error JS1195: Expected expression: :
7(2159,10): run-time error JS1004: Expected ';'
8(2159,10-11): run-time error JS1195: Expected expression: :
9(2160,10): run-time error JS1004: Expected ';'
10(2160,10-11): run-time error JS1195: Expected expression: :
11(2161,1-2): run-time error JS1195: Expected expression: }
12(2161,1-2): run-time error JS1002: Syntax error: }
13(2382,6): run-time error JS1004: Expected ';'
14(2392,35-37): run-time error JS1006: Expected ')': =>
15(2392,26-34): run-time error JS1317: Unable to convert from reference to binding: async ()
16(2393,35): run-time error JS1004: Expected ';'
17(2394,34): run-time error JS1004: Expected ';'
18(2396,10): run-time error JS1004: Expected ';'
19(2396,10-11): run-time error JS1195: Expected expression: )
20(2401,10): run-time error JS1004: Expected ';'
21 */
22/**
23 * Copyright 2010 Tim Down.
24 *
25 * Licensed under the Apache License, Version 2.0 (the "License");
26 * you may not use this file except in compliance with the License.
27 * You may obtain a copy of the License at
28 *
29 *      http://www.apache.org/licenses/LICENSE-2.0
30 *
31 * Unless required by applicable law or agreed to in writing, software
32 * distributed under the License is distributed on an "AS IS" BASIS,
33 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34 * See the License for the specific language governing permissions and
35 * limitations under the License.
36 */
37var Hashtable=(function(){var p="function";var n=(typeof Array.prototype.splice==p)?function(s,r){s.splice(r,1)}:function(u,t){var s,v,r;if(t===u.length-1){u.length=t}else{s=u.slice(t+1);u.length=t;for(v=0,r=s.length;v<r;++v){u[t+v]=s[v]}}};function a(t){var r;if(typeof t=="string"){return t}else{if(typeof t.hashCode==p){r=t.hashCode();return(typeof r=="string")?r:a(r)}else{if(typeof t.toString==p){return t.toString()}else{try{return String(t)}catch(s){return Object.prototype.toString.call(t)}}}}}function g(r,s){return r.equals(s)}function e(r,s){return(typeof s.equals==p)?s.equals(r):(r===s)}function c(r){return function(s){if(s===null){throw new Error("null is not a valid "+r)}else{if(typeof s=="undefined"){throw new Error(r+" must not be undefined")}}}}var q=c("key"),l=c("value");function d(u,s,t,r){this[0]=u;this.entries=[];this.addEntry(s,t);if(r!==null){this.getEqualityFunction=function(){return r}}}var h=0,j=1,f=2;function o(r){return function(t){var s=this.entries.length,v,u=this.getEqualityFunction(t);while(s--){v=this.entries[s];if(u(t,v[0])){switch(r){case h:return true;case j:return v;case f:return[s,v[1]]}}}return false}}function k(r){return function(u){var v=u.length;for(var t=0,s=this.entries.length;t<s;++t){u[v+t]=this.entries[t][r]}}}d.prototype={getEqualityFunction:function(r){return(typeof r.equals==p)?g:e},getEntryForKey:o(j),getEntryAndIndexForKey:o(f),removeEntryForKey:function(s){var r=this.getEntryAndIndexForKey(s);if(r){n(this.entries,r[0]);return r[1]}return null},addEntry:function(r,s){this.entries[this.entries.length]=[r,s]},keys:k(0),values:k(1),getEntries:function(s){var u=s.length;for(var t=0,r=this.entries.length;t<r;++t){s[u+t]=this.entries[t].slice(0)}},containsKey:o(h),containsValue:function(s){var r=this.entries.length;while(r--){if(s===this.entries[r][1]){return true}}return false}};function m(s,t){var r=s.length,u;while(r--){u=s[r];if(t===u[0]){return r}}return null}function i(r,s){var t=r[s];return(t&&(t instanceof d))?t:null}function b(t,r){var w=this;var v=[];var u={};var x=(typeof t==p)?t:a;var s=(typeof r==p)?r:null;this.put=function(B,C){q(B);l(C);var D=x(B),E,A,z=null;E=i(u,D);if(E){A=E.getEntryForKey(B);if(A){z=A[1];A[1]=C}else{E.addEntry(B,C)}}else{E=new d(D,B,C,s);v[v.length]=E;u[D]=E}return z};this.get=function(A){q(A);var B=x(A);var C=i(u,B);if(C){var z=C.getEntryForKey(A);if(z){return z[1]}}return null};this.containsKey=function(A){q(A);var z=x(A);var B=i(u,z);return B?B.containsKey(A):false};this.containsValue=function(A){l(A);var z=v.length;while(z--){if(v[z].containsValue(A)){return true}}return false};this.clear=function(){v.length=0;u={}};this.isEmpty=function(){return !v.length};var y=function(z){return function(){var A=[],B=v.length;while(B--){v[B][z](A)}return A}};this.keys=y("keys");this.values=y("values");this.entries=y("getEntries");this.remove=function(B){q(B);var C=x(B),z,A=null;var D=i(u,C);
37if(D){A=D.removeEntryForKey(B);if(A!==null){if(!D.entries.length){z=m(v,C);n(v,z);delete u[C]}}}return A};this.size=function(){var A=0,z=v.length;while(z--){A+=v[z].entries.length}return A};this.each=function(C){var z=w.entries(),A=z.length,B;while(A--){B=z[A];C(B[0],B[1])}};this.putAll=function(H,C){var B=H.entries();var E,F,D,z,A=B.length;var G=(typeof C==p);while(A--){E=B[A];F=E[0];D=E[1];if(G&&(z=w.get(F))){D=C(F,z,D)}w.put(F,D)}};this.clone=function(){var z=new b(t,r);z.putAll(w);return z}}return b})();;/// <reference path="scripts.js" />
38
39var BUBBLE_FADE_TIMEOUT = 3000;     // cas zobrazni bubliny s informaci o pridani do kosiku/oblibenych
40var IsPagingProcessing = false;     // priznak probihajiciho ajaxoveho dotahovani stranky
41window.lbDataLayer = window.lbDataLayer || []; // luigisbox
42
43// Feedback functions
44var SetFeedbackMessageBoxActive = function (result) {
45    var feedback = $('#feedback-message .feedbackform');
46    if (!$(feedback).hasClass('active')) {
47        $(feedback).addClass('active');
48    }
49};
50var SetFeedbackNewsletterBoxActive = function (result) {
51    if (result.action == "redirect") {
52        $('#NewsletterEmail').val(result.email);
53        $('#newsletter-redirect').submit();
54    }
55
56    var feedback = $('#feedback-newsletter .newsletterform');
57    if (!$(feedback).hasClass('active')) {
58        $(feedback).addClass('active');
59    }
60};
61var HomeNewsletterSuccess = function (result) {
62    if (result.action == "redirect") {
63        $('#NewsletterEmail').val(result.email);
64        $('#newsletter-redirect').submit();
65    }
66};
67
68// Naplni testovaci inputy jako ochranu pred spamboty
69var SetFeedback = function () {
70    var x = Math.floor((Math.random() * 1000000) + 1);
71    $('#msgA').val(x);
72    $('#msgB').val((x & 1) ? "success" : "error");
73};
74
75// Popup s dotazy
76var ShowQuestionsPopup = function () {
77    var url = $('input[name="question-ajax-url"]:hidden').val();
78    var headline = $('input[name="question-headline"]:hidden').val();
79    var dialog = ($('#question-modal').length > 0) ? $('#question-modal') : $('<div id="question-modal" style="display:hidden"></div>').appendTo('body');
80    $.get(url, {},
81        function (recommends) {
82            if (recommends != "error") {
83                dialog.html(recommends);
84                dialog.dialog({
85                    bgiframe: true,
86                    modal: true,
87                    width: 680,
88                    height: 400
89                    //title: headline
90                });
91            }
92        }
93    );
94};
95
96function UpdateCookieConsents(ad, analytics, personalization, adUserData, adPersonalization) {
97    gtag('consent', 'update', {
98        ad_storage: ad ? 'granted' : 'denied',
99        analytics_storage: analytics ? 'granted' : 'denied',
100        personalization_storage: personalization ? 'granted' : 'denied',
101        functionality_storage: 'granted',
102        security_storage: 'granted',
103        ad_user_data: adUserData ? 'granted' : 'denied',
104        ad_personalization: adPersonalization ? 'granted' : 'denied',
105    });
106
107    dataLayer.push({
108        event: 'consent_update',
109        consent: {
110            ad_storage: ad ? 'granted' : 'denied',
111            analytics_storage: analytics ? 'granted' : 'denied',
112            personalization_storage: personalization ? 'granted' : 'denied',
113            functionality_storage: 'granted',
114            security_storage: 'granted',
115            ad_user_data: adUserData ? 'granted' : 'denied',
116            ad_personalization: adPersonalization ? 'granted' : 'denied',
117        }
118    });
119}
120
121// Zalogovani GA eventu tlacitka do kosiku pro oblibene
122$('.cart-product-list a.add-to-cart').live('click', function (e) {
123    var cart_add = this;
124    if ($(cart_add).hasClass('disabled')) {
125        return false;
126    }
127    dataLayer.push($(this).data('clickvalues'));
128
129    return true;
130});
131
132// Zalogovani GA eventu odebrani z oblibenych
133$('.cart-product-list a.remove.favorite').live('click', function (e) {
134    favoritesGaScript($(this).data('id'), 'unlike', $(this).data('element'), '');
135});
136
137// Zalogovani GA eventu pridani do oblibenych
138$('.cart-product-list a.btn-like.cart').live('click', function (e) {
139    favoritesGaScript($(this).data('id'), 'like', $(this).data('element'), '');
140});
141
142
143// like/unlike 
144function favoritesGaScript(productId, actionType, element, question) {
145    if (productId != undefined && element != undefined) {
146        $.ajax({
147            url: '/cart/UserActionGaScript?productId=' + productId + "&actionType=" + actionType + "&element=" + element + "&question=" + question,
148            type: "POST",
149            success: function (data) {
150                dataLayer.push(data);
151            }
152        });
153    }
154}
155
156function isScrolledIntoView(elem) {
157    if ($(elem).length === 0) return true;
158
159    var docViewTop = $(window).scrollTop();
160    var docViewBottom = docViewTop + $(window).height();
161
162    var elemTop = $(elem).offset().top;
163    var elemBottom = elemTop + $(elem).height();
164
165    return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
166}
167
168//Timeout - rozsireni o zapausovani / zbyvajici cas
169function Timer(callback, delay) {
170    var timerId, start, remaining = delay;
171
172    this.pause = function () {
173        this.clear();
174        remaining -= new Date() - start;
175    };
176
177    this.resume = function () {
178        start = new Date();
179        timerId = window.setTimeout(callback, remaining);
180    };
181
182    this.remains = function () {
183        return remaining;
184    }
185
186    this.clear = function () {
187        window.clearTimeout(timerId);
188    }
189
190    this.resume();
191}
192
193function hexToRgb(hex) {
194    // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
195    var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
196    hex = hex.replace(shorthandRegex, function (m, r, g, b) {
197        return r + r + g + g + b + b;
198    });
199
200    var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
201    return result ? {
202        r: parseInt(result[1], 16),
203        g: parseInt(result[2], 16),
204        b: parseInt(result[3], 16)
205    } : null;
206}
207//zelene 4h zatrzitko
208var h4col = {
209    r: 36,
210    g: 171,
211    b: 156
212}
213//oranzove 4e zatrzitko
214var e4col = {
215    r: 227,
216    g: 130,
217    b: 38
218}
219var whiteCol = {
220    r: 255,
221    g: 255,
222    b: 255
223}
224function diffContrast(front, back) {
225    var colorDiff = Math.abs((back.r - front.r))
226        + Math.abs((back.g - front.g))
227        + Math.abs((back.b - front.b));
228    var brightnessDiff = Math.abs(
229        ((299 * back.r + 587 * back.r + 114 * back.b) / 1000)
230        - ((299 * front.r + 587 * front.r + 114 * front.b) / 1000)
231    );
232    return {
233        color: colorDiff,
234        brightness: brightnessDiff
235    }
236}
237
238function fixColorSelect(holder, colorContainer) {
239    if (!$('html').hasClass('lt-ie9')) { //Regex Lookahead Bug
240        var bgReg = /^rgb(a)?\((\d+),\s*(\d+),\s*(\d+)(,\s*(\d+))?\)$/i;
241        $(holder).each(function () {
242            var color = $(this).find(colorContainer).css('background-color');
243            if (color == 'transparent') {
244                var bg = {
245                    r: 0,
246                    g: 0,
247                    b: 0,
248                    a: 0
249                }
250            } else {
251                var parts = color.match(bgReg);
252                var bg = {
253                    r: parts[2],
254                    g: parts[3],
255                    b: parts[4],
256                    a: parts[6]
257                }
258            }
259            var diff = diffContrast(whiteCol, bg)
260            if (!$(this).hasClass('color-vicebarevna') && (bg.a == 0 || ((diff.color < 300) && (diff.brightness < 30)))) {
261                $(this).addClass('dark');
262            }
263        });
264    }
265}
266
267function refreshPriceInMyCart() {
268    const priceElement = $(".total-vat .price");
269    const cartDataElement = $('#dataCartDetail');
270    if (priceElement.length == 0 || cartDataElement.length == 0) {
271        //try hover cart
272        const hoverCart = $("#hover-cart-data");
273        if (hoverCart.length == 0) return; // shouldn't happen?
274        const price = hoverCart.data("total-price").toString() || "0";
275        const count = hoverCart.data('product-count');
276
277        setPriceInMyCart(price, count);
278    } else {
279        let step = $("#CurrentOrderStep").val() - 1;
280        if (step > 3) step = 3;
281        console.log("trying to read price from step", step);
282        const price = $(priceElement[step]).data("total-price").toString() || "0";
283        const count = cartDataElement.data('product-count');
284
285        setPriceInMyCart(price, count);
286    }
287}
288
289function setPriceInMyCart(price, count) {
290    if (price.indexOf('0') != 0 && count != 0) {
291        $('#ajax-basket .bottom-text .price').show();
292        $('#ajax-basket .bottom-text .symbol').show();
293        $('#ajax-basket .bottom-text .price').text(price);
294        $('#ajax-basket .bottom-text .default-text').hide();
295    } else {
296        $('#ajax-basket .bottom-text .price').hide();
297        $('#ajax-basket .bottom-text .symbol').hide();
298        $('#ajax-basket .bottom-text .default-text').show();
299    }
300
301
302    if (count != 0) {
303        $('#ajax-basket .items').show();
304        $('#ajax-basket .items').html(count);
305    } else {
306        $('#ajax-basket .items').hide();
307    }
308}
309function GetQueryStringParams(sParam) {
310    var sPageURL = window.location.search.substring(1);
311    var sURLVariables = sPageURL.split('&');
312    for (var i = 0; i < sURLVariables.length; i++) {
313        var sParameterName = sURLVariables[i].split('=');
314        if (sParameterName[0] == sParam) {
315            return sParameterName[1];
316        }
317    }
318}
319
320
321function updateUrlParameter(uri, key, value) {
322
323    var i = uri.indexOf('#');
324    var hash = i === -1 ? '' : uri.substr(i);
325    uri = i === -1 ? uri : uri.substr(0, i);
326
327    var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
328    var separator = uri.indexOf('?') !== -1 ? "&" : "?";
329    if (uri.match(re)) {
330        uri = uri.replace(re, '$1' + key + "=" + value + '$2');
331    } else {
332        uri = uri + separator + key + "=" + value;
333    }
334    return uri + hash;  // finally append the hash as well
335}
336
337function BookmarkReturnUrl(el, copyOnly) {
338
339    //vytvorit returnUrl bookmark (v pripade, ze v url uz neni)
340    var rUrl = GetQueryStringParams('rUrl');
341    if (!rUrl) {
342        rUrl = encodeURIComponent(location.pathname + location.search + location.hash);
343        if (copyOnly)
344            return true;
345    }
346
347    //replace href element
348    var target = el.getAttribute("href");
349    el.href = updateUrlParameter(target, 'rUrl', rUrl);
350}
351
352//email popup
353function emailPopup() {
354    if ($('#email-popup').length) {
355        var src = "(not set)";//gaReader.source.replace(/"/g, '\\"');
356        var utm_source = GetQueryStringParams("utm_source");
357        if (src == "(not set)" && utm_source != null && utm_source.length > 0)
358            src = utm_source;
359
360        $.post("/feedback/ShowPopup", { utmSource: src })
361            .done(function (data) {
362                if (data.Show == true) {
363                    $('#popup-overlay').fadeIn(300);
364                    $('#email-popup').fadeIn(300, submitPopup());
365                    $('#email-popup .close').on('click', function () {
366                        $('#popup-overlay').fadeOut(300);
367                        $('#email-popup').fadeOut(300);
368                    });
369                    $(document).on('keyup', function (e) {
370                        if (e.keyCode == 27) { // esc keycode
371                            $('#popup-overlay').fadeOut(300);
372                            $('#email-popup').fadeOut(300);
373                        }
374                    });
375                }
376            });
377    }
378}
379
380function emailPopupThanks() {
381    $('#email-popup .window1').fadeOut(300, function () {
382        $('#email-popup .window2').fadeIn(200);
383        $('#email-popup .fake-close').on('click', function () {
384            $('#popup-overlay').fadeOut(300);
385            $('#email-popup').fadeOut(300);
386        });
387    });
388}
389
390function submitPopup() {
391    $('#email-popup form').on('submit', function (e) {
392        e.preventDefault();
393        $('#popupSubmit').hide();
394        $('.popupLoaderContainer').fadeIn(100);
395
396        $.post("/feedback/RegisterPopup", $(this).serialize())
397            .done(function (data) {
398                $('.popupLoaderContainer').fadeOut(100, function () {
399                    $('#popupSubmit').fadeIn(100);
400                });
401
402                if (data.Success) {
403                    emailPopupThanks();
404                    $('#popup-error-messages').empty();
405                    dataLayer.push($('PopupUAData').data('uaval'));
406                    dataLayer.push($('PopupUAData').data('uaval'));
407                }
408                else {
409                    $('#popup-error-messages').html(data.Message);
410
411                    // je tu jen nastylovaná nějaká validace - potřeba reálně napojit
412                    var container = $('#email-popup').find('.popup-error-container');
413                    container.show().find('.error').show();
414                    container.css('bottom', -container.height());
415                }
416            });
417    });
418}
419
420function countdown(hour, min, sec) {
421    if (sec <= 0) {
422        sec = 59;
423        min = min - 1;
424        if (min < 0) {
425            min = 59;
426            hour = hour - 1;
427            if (hour < 0) {
428                hour = 24;
429                min = 0;
430                sec = 0;
431            }
432        }
433    } else {
434        sec = sec - 1;
435    }
436
437    $('#h').html(hour.toString().padStart(2, "0"));
438    $('#m').html(min.toString().padStart(2, "0"));
439    $('#s').html(sec.toString().padStart(2, "0"));
440
441    setTimeout("countdown(" + hour + "," + min + "," + sec + ")", 1000);
442}
443
444function bannerCountdown(hour, min, sec) {
445    if (sec <= 0) {
446        sec = 59;
447        min = min - 1;
448        if (min < 0) {
449            min = 59;
450            hour = hour - 1;
451            if (hour < 0) {
452                hour = 0;
453                min = 0;
454                sec = 0;
455                clearTimeout(s);
456            }
457        }
458    } else {
459        sec = sec - 1;
460    }
461    if (sec.toString().length == 1) {
462        sec = "0" + sec;
463    }
464    if (min.toString().length == 1) {
465        min = "0" + min;
466    }
467    if (hour.toString().length == 1) {
468        hour = "0" + hour;
469    }
470    $('#banner_h').html(hour);
471    $('#banner_m').html(min);
472    $('#banner_s').html(sec);
473
474    var s = setTimeout("bannerCountdown(" + hour + "," + min + "," + sec + ")", 1000);
475}
476
477function SavePosition() {
478    $('#prev_position').val($(document).scrollTop());
479}
480function ReturnToSavedPosition() {
481    window.scrollTo(0, $('#prev_position').val());
482}
483
484function displayDescriptionToggle() {
485    if ($(".page-description__content p").length == 0) return;
486    const p = $(".page-description__content p")[0];
487    if (p.scrollWidth > p.offsetWidth) {
488        $(".page-description__toggle").show();
489    } else {
490        $(".page-description__toggle").hide();
491    }
492}
493
494function PickBestImage(element) {
495    const options = $(element).attr("data-srcset").split(",").map(o => o.trim().split(" ")).sort((a, b) => a[1] - b[1]);
496    const width = $(element).width() * window.devicePixelRatio;
497    let useSrc = options.pop()[0]
498    for (var option of options) {
499        if (option[1] >= width) {
500            useSrc = option[0];
501            break;
502        }
503    }
504
505    if ($(element).attr("src") != useSrc) $(element).attr("src", useSrc)
506}
507
508const registeredLateLoaders = new Set();
509function RefreshLateload() {
510    const io = new IntersectionObserver((entries) => {
511        entries.forEach((entry) => {
512            if (entry.intersectionRatio > 0 || entry.isIntersecting) {
513                io.unobserve(entry.target);
514                if ($(entry.target).attr("data-src") != undefined) {
515                    $(entry.target).attr("src", $(entry.target).attr("data-src"));
516                    $(entry.target).on("load.lateload", function () {
517                        $(entry.target).removeClass("late-load");
518                        $(entry.target).addClass("late-loaded");
519                    });
520                }
521
522                if ($(entry.target).attr("data-srcset") != undefined) {
523                    PickBestImage(entry.target);
524                    $(window).on("resize", function () {
525                        PickBestImage(entry.target);
526                    });
527
528                    $(entry.target).on("load.lateload", function () {
529                        $(entry.target).removeClass("late-load");
530                        $(entry.target).addClass("late-loaded");
531                    });
532                }
533            }
534        });
535    });
536
537    const lateLoad = document.querySelectorAll(".late-load");
538    lateLoad.forEach((el) => {
539        if (registeredLateLoaders.has(el)) return;
540        registeredLateLoaders.add(el);
541        io.observe(el);
542    });
543
544    if ('updateProductObserver' in window) window.updateProductObserver();
545}
546
547function gaScript() {
548    var values = $('#gaHelper');
549    $.ajax({
550        url: '/cart/GaScript130?pageType=' + values.data('pagetype') + "&breadcrumbs=" + values.data('breadcrumbs') + "&title=" + values.data('title') + "&pathname=/search",
551        type: "POST",
552        success: function (gaData) {
553            dataLayer.push(gaData);
554        }
555    });
556}
557
558var swipeboxIndex = 0;
559
560// -------------------------------------------------------------------------------------------------
561// DOCUMENT READY
562// -------------------------------------------------------------------------------------------------
563$(document).ready(function () {
564    if ($('#main').hasClass('paged')) {
565        $(document).on("scroll", SavePosition);
566    }
567
568    LoadComponents();
569
570    if ($('.hero-card-container')) {
571        $('.hero-card-container').each(function () {
572            $(this).slick({
573                arrows: true,
574                dots: false,
575                infinite: true,
576                autoplay: true,
577                speed: 1000,
578                slidesToShow: 3,
579                slidesToScroll: 1,
580                responsive: [
581                    {
582                        breakpoint: 1249,
583                        settings: {
584                            slidesToShow: 2,
585                        }
586                    },
587                    {
588                        breakpoint: 767,
589                        settings: {
590                            slidesToShow: 1,
591                        }
592                    }
593                ]
594            });
595        });
596    }
597
598    if ($('.kavarna-articles')) {
599        $('.kavarna-articles').each(function () {
600            $(this).slick({
601                arrows: true,
602                dots: false,
603                infinite: true,
604                slidesToShow: 3,
605                slidesToScroll: 1,
606                responsive: [
607                    {
608                        breakpoint: 1249,
609                        settings: {
610                            slidesToShow: 2,
611                        }
612                    },
613                    {
614                        breakpoint: 767,
615                        settings: {
616                            slidesToShow: 1,
617                        }
618                    }
619                ]
620            });
621        });
622    }
623
624    if ($('.video-carousel')) {
625        $('.video-carousel').each(function () {
626            $(this).slick({
627                arrows: true,
628                dots: false,
629                infinite: true,
630                slidesToShow: 3,
631                slidesToScroll: 1,
632                responsive: [
633                    {
634                        breakpoint: 1249,
635                        settings: {
636                            slidesToShow: 2,
637                        }
638                    },
639                    {
640                        breakpoint: 767,
641                        settings: {
642                            slidesToShow: 1,
643                        }
644                    }
645                ]
646            });
647        });
648    }
649
650    if ($('.collection-list--carousel')) {
651        $('.collection-list--carousel').each(function () {
652            $(this).slick({
653                arrows: true,
654                dots: false,
655                infinite: true,
656                slidesToShow: 4,
657                slidesToScroll: 4,
658                responsive: [
659                    {
660                        breakpoint: 1249,
661                        settings: {
662                            slidesToShow: 3,
663                            slidesToScroll: 3,
664                        }
665                    },
666                    {
667                        breakpoint: 767,
668                        settings: {
669                            slidesToShow: 2,
670                            slidesToScroll: 2,
671                        }
672                    },
673                    {
674                        breakpoint: 500,
675                        settings: {
676                            slidesToShow: 1,
677                            slidesToScroll: 1,
678                        }
679                    }
680                ]
681            });
682        });
683    }
684
685    if ($('.x-expandable').length) {
686        // listener pro klik na zobrazení/skrytí celého textu popisu
687        $('.x-expandable-content')
688            .on('click', '.x-expandable-header', function () {
689                $(this).next('.x-expandable-content').slideToggle();
690                $(this).parent('.x-expandable').toggleClass('opened');
691                $(this).find('.x-expandable--show').toggle();
692                $(this).find('.x-expandable--hide').toggle();
693            });
694    }
695
696    // jsSocial (inicializace a nastavení) (social icons)
697    // ---------------------------------------------------------------------------------------------
698    if ($('#socialShareIcons').length) {
699        $('#socialShareIcons').jsSocials({
700            showLabel: false,
701            showCount: false,
702            shareIn: "popup",
703            shares: [{
704                share: "facebook",
705                logo: "/Content/img/ico-share-facebook.png"
706            }, {
707                share: "twitter",
708                logo: "/Content/img/ico-share-twitter.png"
709            }, {
710                share: "email",
711                logo: "/Content/img/ico-share-mail.png"
712            }]
713        });
714
715        $('.btn-share').click(function () {
716            $('#social-share').show();
717            $('#social-share-overlay').show();
718        });
719
720        $('#social-share-overlay').click(function () {
721            $('#social-share').hide();
722            $('#social-share-overlay').hide();
723        });
724    }
725    // end -----------------------------------------------------------------------------------------
726
727
728    // Tlačítko Do oblíbených / Odebrat z oblíbených
729    // ---------------------------------------------------------------------------------------------
730    function updateWishlistProductsAmount() {
731        $.ajax({
732            url: '/cart/GetProductsOnMyWishListCount',
733            success: function (data) {
734                $("#ajax-favorites .items").html(data);
735                var favoritesCount = parseInt(data);
736                if (favoritesCount > 0) {
737                    $("#ajax-favorites .items").addClass("active");
738                }
739                else {
740                    $("#ajax-favorites .items").removeClass("active");
741                }
742            }
743        });
744    }
745
746    $('.favorites-add').on('click', function (e) {
747        e.preventDefault();
748        e.stopPropagation();
749        favoritesGaScript($(this).data('id'), 'like', $(this).data('element'), '');
750        var btn = $(this);
751        $.ajax({
752            url: btn.data('href'),
753            type: "POST",
754            success: function (data) {
755                btn.css('display', 'none');
756                btn.siblings('.favorites-del').css('display', 'inline-block');
757                updateWishlistProductsAmount();
758            }
759        });
760    });
761
762    $('.favorites-del').on('click', function (e) {
763        e.preventDefault();
764        e.stopPropagation();
765        favoritesGaScript($(this).data('id'), 'unlike', $(this).data('element'), '');
766        var btn = $(this);
767        $.ajax({
768            url: btn.data('href'),
769            type: "POST",
770            success: function (data) {
771                btn.css('display', 'none');
772                btn.siblings('.favorites-add').css('display', 'inline-block');
773                updateWishlistProductsAmount();
774            }
775        });
776    });
777    // end -----------------------------------------------------------------------------------------
778
779
780    // Popup odpověď na pracovní nabídku (Job offer reply)
781    // ---------------------------------------------------------------------------------------------
782    $('.apply-for-job').on('click', function () {
783        $('.rat-popup-overall').show();
784        $('.job-offer-reply-popup').show();
785        return false;
786    });
787
788
789    $('#job-offer-reply-submit').on('click', function () {
790        var $form = $('#job-offer-reply-form')[0]; // You need to use standard javascript object here
791        var $formData = new FormData($form);
792
793        $.ajax({
794            url: '/Main/CareerForm',
795            type: "POST",
796            data: $formData,
797            contentType: false,
798            processData: false,
799            success: function (data) {
800                var $infoMessage = $('.job-offer-reply-popup #action-result-info #info-message');
801                var $messageContainer = $('.job-offer-reply-popup #action-result-info');
802
803                if (data.StatusCode == 0) {
804                    $infoMessage
805                        .removeClass("error-warning")
806                        .addClass("success")
807                        .empty()
808                        .append(data.Message);
809                    $messageContainer.show();
810                    $('#job-offer-reply-form').find("input[type=text], input[type=file], textarea").val("");
811                }
812                else if (data.StatusCode == 1) {
813                    $infoMessage
814                        .removeClass("success")
815                        .addClass("error-warning")
816                        .empty()
817                        .append(data.Message);
818                    $messageContainer.show();
819                }
820                else {
821                    $infoMessage.removeClass("success").addClass("error-warning").empty().append(data.Message);
822                    $messageContainer.show();
823
824                    if ($.trim($('.job-offer-reply-popup #Name').val()).length == 0) {
825                        $('.job-offer-reply-popup #Name').addClass("required-border").keyup(function () {
826                            $(this).removeClass("required-border")
827                        });
828                    }
829
830                    if ($.trim($('.job-offer-reply-popup #Phone').val()).length != 9) {
831                        $('.job-offer-reply-popup #Phone').addClass("required-border").keyup(function () {
832                            $(this).removeClass("required-border")
833                        });
834                    }
835
836                    if ($.trim($('.job-offer-reply-popup #Message').val()).length == 0) {
837                        $('.job-offer-reply-popup #Message').addClass("required-border").keyup(function () {
838                            $(this).removeClass("required-border")
839                        });
840                    }
841                }
842            }
843        });
844        return false;
845    });
846    // end -----------------------------------------------------------------------------------------
847
848    // popis znacky / kategorie
849    if ($(".page-description__content").length > 0) {
850        displayDescriptionToggle();
851
852        window.addEventListener("resize", () => {
853            displayDescriptionToggle();
854        });
855    }
856
857
858    // benefit popup - zobrazení popupu a šedého pozadí
859    $('.rat-btn-close, .fakt-close-button, .rat-popup-overall').on('click', function () {
860        $('.rat-popup-overall').hide();
861        $('.benefit-popup, .job-offer-reply-popup').hide();
862        return false;
863    });
864
865    // common login (cart is handled in order.js registerAddressBlockEvents)
866    $(".common-login .partial-login-bottom .submit").off('click').on('click', function (e) {
867        e.preventDefault();
868
869        //clear server err msg
870        $("#OrderLoginServerMessage").hide();
871
872        //force validation
873        if ($("#UserName").valid()
874            && $("#Password").valid()) {
875
876            var serializedForm = $(".partial-login form").serialize();
877
878            $.ajax({
879                url: $(".common-login").data("partial-login-url"),
880                type: 'POST',
881                data: serializedForm,
882                success: function (data) {
883                    if (data != "") {
884                        $("#OrderLoginServerMessage").show();
885                        $("#OrderLoginServerMessage").html(data);
886                    } else {
887                        window.location.reload();
888                    }
889                },
890                error: function (req, status, error) {
891                    //tohle se nikdy neděje btw
892                    $("#OrderLoginServerMessage").show();
893                    $("#OrderLoginServerMessage").html(req.responseText);
894                }
895            });
896        }
897    });
898
899    // 10q claude
900    const supportsHover = !('ontouchstart' in window);
901    const productFeatures = $('.product-key-features');
902    const productFeaturesWrap = $('.product-key-features-wrap');
903    const productFeaturesHover = $('.product-key-features-hover');
904
905    if (supportsHover) {
906        // Desktop behavior: hover to show/hide
907        productFeaturesWrap.on('mouseenter', function () {
908            productFeatures.addClass('show');
909        });
910
911        // Hide when leaving both wrap and hover elements
912        productFeaturesWrap.add(productFeaturesHover).on('mouseleave', function (e) {
913            // Only hide if we're not moving to the other related element
914            const relatedTarget = e.relatedTarget;
915            if (!relatedTarget ||
916                (!$.contains(productFeaturesWrap[0], relatedTarget) &&
917                    !$.contains(productFeaturesHover[0], relatedTarget) &&
918                    relatedTarget !== productFeaturesWrap[0] &&
919                    relatedTarget !== productFeaturesHover[0])) {
920                productFeatures.removeClass('show');
921            }
922        });
923    } else {
924        // Mobile behavior: tap to show, click anywhere to hide
925        productFeaturesWrap.on('click', function (e) {
926            e.stopPropagation();
927            productFeatures.toggleClass('show');
928        });
929
930        // Click on hover element should hide and eat the event
931        productFeaturesHover.on('click', function (e) {
932            e.stopPropagation();
933            productFeatures.removeClass('show');
934        });
935
936        // Click anywhere else hides the hover
937        $(document).on('click', function () {
938            productFeatures.removeClass('show');
939        });
940    }
941
942    /* swipebox - video */
943    $('a.img_preview, .show_gallery').click(function (f) {
944        if ($(window).width() > 767) {
945            if (typeof pushSwipebox === "function") { // function pushSwipebox is declared in View
946                const mediaQueryNotMobile = window.matchMedia('(min-width: 531px');
947
948                if (mediaQueryNotMobile.matches) {
949                    f.preventDefault();
950
951                    var swipeboxIndex = $(this).index();
952                    if ($(this).hasClass('show_gallery')) {
953                        swipeboxIndex = 5;
954                    }
955
956                    pushSwipebox(swipeboxIndex);
957                    $swipebox = $('#swipebox-overlay');
958                    $(document).on('keydown.trapFocus', e => trapFocus($swipebox, e));
959                    $swipebox.find('.initial-focus-element').focus();
960
961
962                    //set height to thumbs overlay
963                    var height = 540 - 45 - 25 - 5 - $('#swipebox-title').height();
964                    $('#thumbs-overlay').css('height', height);
965                }
966            }
967            else
968                console.log("Warning: function pushSwipebox() is not declared in ProductDetail view.");
969        } else if ($('.product-detail-photos').data('photo-count') > 1) {
970            showMobileGalleryPopup();
971        }
972    });
973
974
975    // load videos on desktop only
976    if (shouldAutoplayVideo()) {
977        $('.img_preview video').each((_, e) => e.play().catch());
978    }
979
980    // deffered image loading
981
982    RefreshLateload();
983
984    var firstImage = document.querySelector('.visual .img_preview img:not(.late-load)');
985    if (firstImage) {
986        PickBestImage(firstImage);
987        $(window).on("resize", function () {
988            PickBestImage(firstImage);
989        });
990    }
991
992    // secondary image
993    InitProductHoverImages();
994
995    // cookie
996    $('#agreeWithCookies').click(function () {
997        $.post('/cookie/AcceptAllConsents', function (response) {
998            $('.cookies-wrapper').hide();
999
1000            UpdateCookieConsents(true, true, true, true, true);
1001        });
1002    });
1003
1004    $('#closeCookies').click(function () {
1005        $('.cookies-wrapper').hide();
1006    })
1007
1008    /* Odpocet na Akcni zbozi HP */
1009    try {
1010        countdown($('#h').html(), $('#m').html(), $('#s').html());
1011    } catch (e) {
1012
1013    }
1014
1015    /* Odpocet action banner */
1016    try {
1017        bannerCountdown($('#banner_h').html(), $('#banner_m').html(), $('#banner_s').html());
1018    } catch (e) {
1019
1020    }
1021
1022    //email popup
1023    emailPopup();
1024
1025    /* show/hide erotic info */
1026    $('.erotic-btn a').on('click', function () {
1027        if (!$(this).hasClass('open')) {
1028            $('.erotic-info').show();
1029            $(this).addClass('open');
1030        } else {
1031            $('.erotic-info').hide();
1032            $(this).removeClass('open');
1033        }
1034    });
1035
1036    // cart hover
1037    $("#ajax-basket").on('mouseenter', function () {
1038        if ($("#ajax-basket").hasClass("active")) return;
1039        $(".hover-cart-wrapper").show();
1040        $("#ajax-basket").addClass('hover');
1041    });
1042
1043    $(".hover-cart-wrapper").live('mouseleave', function () {
1044        $(".hover-cart-wrapper").hide();
1045        $("#ajax-basket").removeClass('hover');
1046
1047    });
1048
1049    // Scrollovací info v detailu produktu + nastavení vysku u nadrazeného elementu
1050    $('#content.product-detail .cart-parent').each(function () {
1051        resizeCartBoxToScroll();
1052    });
1053    $('.product-info').stick_in_parent({
1054        offset_top: 20
1055    });
1056
1057    const cartParentObserver = new ResizeObserver((e) => {
1058        $('#content.product-detail .cart-parent').each(function () {
1059            resizeCartBoxToScroll();
1060        });
1061
1062    });
1063
1064    if ($(".products-list-wrap--collection").length > 0) {
1065        cartParentObserver.observe($(".products-list-wrap--collection")[0]);
1066    }
1067
1068    $(window).on('resize', function () {
1069        $('#content.product-detail .cart-parent').each(function () {
1070            resizeCartBoxToScroll();
1071        });
1072    });
1073
1074
1075    // Odkliknutí pro temporary elementy 
1076    // container s `blurable` class dostane `blur` class při
1077    // kliku na jakýkoli jiný element
1078    document.addEventListener("click", (event) => {
1079        $(".blurable").each((i, blurable) => {
1080            if (!$.contains(blurable, event.target)) {
1081                $(blurable).addClass("blur");
1082            }
1083        });
1084    });
1085
1086    // Aktualizace ceny v košíku při "history.back()"
1087    try {
1088        refreshPriceInMyCart();
1089    } catch (e) {
1090        console.log("Refresh cart problem: " + e);
1091    }
1092
1093    //search input
1094    $('#search-box-top input[type="text"]').on('blur', function () {
1095        if ($(this).val() == '') $(this).val($(this).data('tooltip'));
1096    });
1097    $('#search-box-top input[type="text"]').on('focus', function () {
1098        if ($(this).val() == $(this).data('tooltip')) $(this).val('');
1099    });
1100
1101    /*
1102    if (!isScrolledIntoView('#action-banner')) {
1103        var scrollTop = $(window).scrollTop();
1104        if (scrollTop < ($('footer').position().top - 850)) {
1105            setTimeout(function () {
1106                $('#action-banner').stop(true, true).animate({ top: parseInt(scrollTop) + 250 + 'px' }, 150);
1107            }, 200);
1108        }
1109    }
1110    */
1111    $('div.up').each(function () {
1112        $(this).children('a').removeAttr('href').css("cursor", "pointer");
1113        $(this).click(function () {
1114            $("html, body").animate({ scrollTop: "0px" }, 0);
1115        });
1116    });
1117
1118    $(window).scroll(function () {
1119        // objevení tlačítka "nahoru"
1120        if ($(window).width() > 1200) {
1121            if ($('div.up').length > 0) {
1122                if ($(this).scrollTop() > 200) {
1123                    $('div.up').fadeIn();
1124                } else {
1125                    $('div.up').fadeOut();
1126                }
1127            }
1128        }
1129        /*
1130        if (!isScrolledIntoView('#action-banner')) {
1131            var scrollTop = $(window).scrollTop();
1132            if (scrollTop < ($('footer').position().top - 1050)) {
1133                setTimeout(function () {
1134                    $('#action-banner').stop(true, true).animate({ top: parseInt(scrollTop) + 250 + 'px' }, 150);
1135                }, 200);
1136            }
1137        }
1138        */
1139    });
1140
1141    if ($('.description p img').parent('p').find('a').length > 0) {
1142        if ($('.description p img').parent('p').find('a').attr('href').indexOf('piktogram') != -1) {
1143            $('.description p img').parent('p').find('a').hide();
1144        }
1145    }
1146
1147    // registrovani 'zkraslovacu'
1148    $('input').not('.not-icheck').iCheck();
1149    //$('select').not('.noselectbox').not('#InvoiceRegion').not('#DeliveryRegion').not('#Region').not('#City').not('#InvoiceCity').not('#DeliveryCity').selectbox();
1150    $('#moderate-orderstete-select').selectbox("detach");
1151    $('#moderate-cartwatch-select').selectbox("detach");
1152
1153    $('select').each(function () {
1154        if ($(this).attr('disabled')) {
1155            $(this).selectbox('disable');
1156        }
1157    });
1158
1159    if ($('.liker').length > 0) {
1160        $('.liker').click(function () {
1161            $(this).siblings('.iradio').find('input[type="radio"]').not('.not-icheck').iCheck('toggle');
1162        });
1163    }
1164
1165    // načtení dalších výsledků, pokud byla v hashi nastavena stranka    
1166    if ($('#main').hasClass('paged') && window.location.hash) {
1167        var totalPages = parseInt($('#total_pages').val(), 10);
1168        var lastPage = parseInt(window.location.hash.substring(1));
1169        var url = $('#nextpage_url').val() + window.location.search;
1170        var lang = $('#search_lang').val();
1171
1172        if (window.location.hash.indexOf("/") != -1) {
1173            var startPage = parseInt(window.location.hash.substring(1, window.location.hash.indexOf("/")));
1174            lastPage = parseInt(window.location.hash.substring(window.location.hash.indexOf("/") + 1));
1175            loadMore(url, startPage, lastPage, lang, "all_pages");
1176        } else {
1177            if (!isNaN(lastPage)) {
1178                loadMore(url, null, lastPage, lang, "rewrite"/*"all_pages"*/);
1179            }
1180        }
1181
1182        // scchovani tlacitka pro posledni stranku
1183        if (lastPage + 1 > totalPages) {
1184            $('#loadMoreButton').hide();
1185            $('#buttonLoadNext').hide();
1186        }
1187        if (lastPage > 1) {
1188            $('#buttonLoadPrev').show();
1189        }
1190    }
1191
1192    // zobrazeni prvni stranky v seznamu znacek
1193    $(document).find('.brands-list #A').addClass('show');
1194    $(document).find('.brands-list #B').addClass('show');
1195    $(document).find('.brands-list #C').addClass('show');
1196
1197    // Smazat validacni hlasku, pokud je vybrano nejake 'Osloveni'
1198    $('input[name$="Salutation"]').on('ifToggled', function () {
1199        var name = $(this).attr('name');
1200        $('.field-validation-error').each(function () {
1201            if ($(this).attr('data-valmsg-for') == name) {
1202                $(this).attr('class', 'field-validation-valid');
1203                $(this).html('');
1204            }
1205        });
1206    });
1207
1208    // Oslovení - check radio i při kliku na text
1209    $('span.salutation-item').each(function () {
1210        var trigger = $(this).find('span.radio');
1211        trigger.css('cursor', 'pointer');
1212        var input = $(this).find('input');
1213        trigger.click(function () {
1214            input.iCheck('checked');
1215        });
1216    });
1217
1218    // Feedback 
1219    $('.feedbackTab').click(function () {
1220        $(this).animate({ left: '-51px' }, 400, function () {
1221            $('.feedbackContent').animate({ left: '0' }, 400);
1222        });
1223    });
1224    $('.feedbackContent .closeform').click(function () {
1225        $('.feedbackContent').animate({ left: '-322px' }, 400, function () {
1226            $('.feedbackTab').animate({ left: '0' }, 400);
1227        });
1228    });
1229    $('.feedbackContent .tab').click(function () {
1230        var index = $(this).index();
1231        $(this).siblings('.tab').removeClass('active');
1232        $(this).addClass('active');
1233        if (index == 0) {
1234            $('.feedbackContent .col.feedbackform').removeClass('active');
1235            $('.feedbackContent .col.newsletterform').addClass('active');
1236        } else {
1237            $('.feedbackContent .col.feedbackform').addClass('active');
1238            $('.feedbackContent .col.newsletterform').removeClass('active');
1239        }
1240    });
1241
1242
1243    $('.load-product-stats.tab').click(function () {
1244        loadProductStats();
1245    });
1246
1247
1248    // ---------------------------------------------------------------------------------------
1249    // Filtry
1250    // --------------------------------------------------------------------------------------
1251
1252    // Sorting
1253    $('#sort-products a').click(function () {
1254        var sort = $(this).attr('data-sort');
1255        $('#sort').val(sort);
1256        $('#sort').removeAttr('disabled');
1257        if (sort == "priority") {
1258            $('#sort').attr('disabled', "disabled");
1259        }
1260        submitOrUpdateForm(true);
1261        return false;
1262    });
1263
1264    // detail produktu photos
1265    productDetailPhotos();
1266
1267    // ---------------------------------------------------------------------------------------
1268    // Novy promo banner na HP
1269    // --------------------------------------------------------------------------------------
1270
1271    $('.home-content .promo').slick({
1272        dots: true,
1273        infinite: true,
1274        lazyLoad: 'progressive',
1275        autoplay: true,
1276        speed: 500,
1277        slidesToShow: 1,
1278        slidesToScroll: 1,
1279        appendDots: '.hp-promo-dot-slots',
1280        fade: true,
1281        customPaging: function (slider, i) {
1282            var name = $(slider.$slides[i]).data('name');
1283            return '<button>' + name + '</button>'
1284        }
1285    });
1286
1287
1288
1289    // ---------------------------------------------------------------------------------------
1290    // Product - Detail
1291    // ---------------------------------------------------------------------------------------
1292    // RWD rozklik velikostnich variant
1293    /*
1294    //bile / barevne zatrzitko u barev
1295    if ($('.product-info .color-variant li.active a').length > 0) {
1296        fixColorSelect('.product-info .color-variant li.active a', '.left-color-box');
1297    }
1298    */
1299    // překlikávač DOTAZY/HODNOCENÍ
1300    $('.rq-box .switcher .switch-title').click(function () {
1301        if (!$(this).hasClass('active')) {
1302            $(this).addClass('active').siblings().removeClass('active');
1303            if ($(this).index() == 0) {
1304                $('.question-box').hide();
1305                $('#question-box-form').hide();
1306                $('.recommend-box').show();
1307            }
1308            else {
1309                $('.recommend-box').hide();
1310                if ($('#question-form').hasClass('success')) {
1311                    $('#question-box-form').show();
1312                } else {
1313                    $('.question-box').show();
1314                }
1315            }
1316        }
1317    });
1318
1319    // podle priznaku v url otevre popup s dotazy (pro link v notifikacnim emailu)
1320    if (window.location.hash == "#questions") {
1321        ShowQuestionsPopup();
1322    }
1323
1324    $('label .hide').hide();
1325
1326    // Rebind events po ajaxovem nacteni produktu
1327    rebind();
1328
1329    // Tlacitko 'Do kosiku'
1330    $('.product-info .bottom').each(function () {
1331
1332        // Amount corections
1333        var box = this;
1334        var amount = $(box).find('input[name=amount]');
1335        var maxUnits = 99;
1336
1337        // input border test
1338        $(amount).focusout(function () {
1339            var units = parseInt($(amount).val(), 10);
1340            if (units < 1) {
1341                $(amount).val(1);
1342            }
1343            if (units > maxUnits) {
1344                $(amount).val(maxUnits);
1345            }
1346        });
1347        // increase amount
1348        $(box).find('a.btn-plus').click(function () {
1349            if (!$(amount).is(':disabled')) {
1350                var units = parseInt($(amount).val(), 10) || 1;
1351                if (units < maxUnits) {
1352                    $(amount).val(++units);
1353                }
1354            }
1355            return false;
1356        });
1357        // decrase amount
1358        $(box).find('a.btn-minus').click(function () {
1359            if (!$(amount).is(':disabled')) {
1360                var units = parseInt($(amount).val(), 10) || 1;
1361                if (units > 1) {
1362                    $(amount).val(--units);
1363                }
1364            }
1365            return false;
1366        });
1367
1368
1369        // Tlacitko do kosiku
1370        $(box).parent().find('a.add-to-cart').click(function () {
1371            var cart_add = this;
1372            if ($(cart_add).hasClass('disabled')) {
1373                return false;
1374            }
1375            var btnClickSource = $(cart_add).data('categorylist');
1376
1377            $.post($(cart_add).data('href'), { amount: $(amount).val(), src: btnClickSource }, function (response) {
1378                if (response.Count == -1) {
1379                    alert("The product failed to be added to your cart.");
1380                    return false;
1381                }
1382
1383                var btn = $('#ajax-basket strong.cnt-info');
1384                if (!btn.hasClass('active')) {
1385                    btn.addClass('active');
1386                }
1387
1388                BookmarkReturnUrl(cart_add, false);
1389
1390                window.location = $(cart_add).attr('href');
1391                return false;
1392            }, "json");
1393
1394            dataLayer.push($(cart_add).data('clickvalues'));
1395
1396            return false;
1397        });
1398    });
1399
1400
1401    // Pridani do kosiku pro produkty ve vypisu vysledku kategorie/hledani
1402    $('.product-thumbnail__buy a.add-to-cart').live('click', function () {
1403        var cart_add = this;
1404        if ($(cart_add).hasClass('disabled')) {
1405            return false;
1406        }
1407        var btnClickSource = $(cart_add).data('categorylist');
1408
1409        dataLayer.push($(cart_add).data('clickvalues'));
1410
1411        $.post($(cart_add).data('href'), { amount: 1, src: btnClickSource }, function (response) {
1412            if (response.Count == -1) {
1413                alert("The product failed to be added to your cart.");
1414                return false;
1415            }
1416
1417            var btn = $('#ajax-basket strong.cnt-info');
1418            if (!btn.hasClass('active')) {
1419                btn.addClass('active');
1420            }
1421
1422            BookmarkReturnUrl(cart_add, false);
1423
1424            window.location = $(cart_add).attr('href');
1425            return false;
1426        }, "json");
1427        return false;
1428    });
1429
1430    // ---------------------------------------------------------------------------------------
1431    // Vouchery
1432    // --------------------------------------------------------------------------------------- 
1433    // prepinani mezi nekomentovanymi/vsemi produkty
1434    $('#chk_voucher-used').on('ifChecked', function () {
1435        window.location.href = $(this).data('used-url');
1436    });
1437    $('#chk_voucher-used').on('ifUnchecked', function () {
1438        window.location.href = $(this).data('unused-url');
1439    });
1440
1441
1442    // ---------------------------------------------------------------------------------------
1443    // Hodnoceni
1444    // --------------------------------------------------------------------------------------- 
1445    // prepinani mezi nekomentovanymi/vsemi produkty checkboxem
1446    $('#chk_unrecommends-only').on('ifChecked', function () {
1447        window.location.href = $(this).data('unrecommends-url');
1448    });
1449    $('#chk_unrecommends-only').on('ifUnchecked', function () {
1450        window.location.href = $(this).data('all-url');
1451    });
1452
1453    // prepinani mezi nekomentovanymi/vsemi produkty labelem za checkboxem
1454    $('#chk_unrecommends-only-label').click(function () {
1455        var checkbox = $('#chk_unrecommends-only');
1456        var checkboxParent = $('#chk_unrecommends-only').parent();
1457
1458        if (checkbox.is(':checked')) {
1459            checkbox.prop('checked', false);
1460            checkboxParent.removeClass('checked');
1461            window.location.href = checkbox.data('all-url');
1462        } else {
1463            checkbox.prop('checked', true);
1464            checkboxParent.addClass('checked');
1465            window.location.href = checkbox.data('unrecommends-url');
1466        }
1467    });
1468
1469    // zaskrolovani na hodnoceny produkt dle parametru v url (pro link v emailu a v detailu)
1470    (function () {
1471        var key = 'recommend_id';
1472        var key_length = key.length + 2;
1473
1474        var qs = window.location.search;
1475        if (qs.length == (key_length + 36)) {
1476            if (qs.substring(1, key_length - 1) === key) {
1477                var item = $('#recommend-item-' + qs.substring(key_length));
1478                if (item.length > 0) {
1479                    $('html, body').animate({ scrollTop: item.position().top }, 'slow');
1480                }
1481            }
1482        }
1483    })();
1484
1485    // ---------------------------------------------------------------------------------------
1486    // Dotazy
1487    // ---------------------------------------------------------------------------------------    
1488    // zobrazeni formulare v detailu
1489    $('#question-box a.action-link.active').click(function () {
1490        $('#question-box').hide();
1491        $('#question-box-form').show();
1492        return false;
1493    });
1494
1495    // nacteni dat do madalniho okna
1496    $('a.show-questions').click(function () {
1497        ShowQuestionsPopup();
1498        return false;
1499    });
1500
1501
1502    // ---------------------------------------------------------------------------------------
1503    // Feedback
1504    // --------------------------------------------------------------------------------------
1505    $('input[name="btnFeedbackSubmit"]').click(function () {
1506        var form = $(this).parent().find('form');
1507        // Set spambot protection
1508        SetFeedback();
1509        $(form).submit();
1510    });
1511
1512    // ---------------------------------------------------------------------------------------
1513    // Objednavky - Muj profil
1514    // ---------------------------------------------------------------------------------------
1515    // Show detail
1516    $('.ordersList .detailLink a').click(function () {
1517        var orderId = $(this).attr('data-order_id');
1518        var detailId = '#order-detail-' + orderId;
1519        var previewId = '#order-preview-' + orderId;
1520
1521        if ($(this).hasClass('open')) {
1522            $('.ordersList').find(detailId).show();
1523            $('.ordersList').find(previewId).hide();
1524        } else if ($(this).hasClass('close')) {
1525            $('.ordersList').find(previewId).show();
1526            $('.ordersList').find(detailId).hide();
1527        }
1528        return false;
1529    });
1530
1531
1532    // ---------------------------------------------------------------------------------------
1533    // Znacky
1534    // ---------------------------------------------------------------------------------------
1535    // Prepinani viditelnosti znacek
1536    $('.brands .brands-letters a').click(function () {
1537        // zarolovat vse
1538        $(this).parent().find('a.sel').removeClass('sel');
1539        $(this).addClass('sel');
1540
1541        var letters = $(this).data('letters');
1542        $(this).parent().parent().find('.brands-list li.clearfix.show').removeClass('show');
1543        for (var i = 0; i < letters.length; i++) {
1544            $(document).find('#' + letters[i]).addClass('show');
1545        }
1546        return false;
1547    });
1548
1549    // ---------------------------------------------------------------------------------------
1550    // Formular: Odstoupeni od smlouvy
1551    // ---------------------------------------------------------------------------------------
1552
1553    $('#rescission .itemcheck').on('ifChecked', function () {
1554        $('#rescission-item-select-error').hide();
1555        var moneyCheck = $('#money-' + $(this).data('itemid'));
1556        moneyCheck.iCheck('enable');
1557    });
1558
1559    $('#rescission .itemcheck').on('ifUnchecked', function () {
1560        var moneyCheck = $('#money-' + $(this).data('itemid'));
1561        $(moneyCheck).iCheck('checked');
1562        $(moneyCheck).iCheck('disable');
1563    });
1564
1565    $('#rescission .moneycheck').on('ifChecked', function () {
1566        $('#rescission-product-select-error').hide();
1567        var exchange = $('#exchange-' + $(this).data('itemid'));
1568        $(exchange).hide();
1569    });
1570
1571    $('#rescission .moneycheck').on('ifUnchecked', function () {
1572        var exchange = $('#exchange-' + $(this).data('itemid'));
1573        $(exchange).show();
1574    });
1575
1576    $('#rescission input.newitem').on('focusout paste', function () {
1577        $('#rescission-contract__error--item-select').hide();
1578        $('#rescission-contract__error--product-change').hide();
1579
1580        var newItemInput = $(this);
1581        var itemCode = $(this).val();
1582        if (itemCode != "") {
1583            $.ajax({
1584                type: 'GET',
1585                async: true,
1586                url: '/checkproduct-ajax',
1587                data: { catalogCode: itemCode },
1588                dataType: 'json',
1589                success: function (returnData) {
1590                    if (returnData.success == true) {
1591                        newItemInput.attr('data-exchange', 'ok').removeClass('rescission-contract__error');
1592                    } else {
1593                        $('#rescission-contract__error--product-change').show();
1594                        newItemInput.removeAttr('data-exchange').addClass('rescission-contract__error');
1595                    }
1596                },
1597                error: function (e) {
1598                    console.log("Call 'CheckProduct' AJAX error: " + e);
1599                }
1600            });
1601        } else {
1602            newItemInput.removeAttr('data-exchange');
1603        }
1604    });
1605
1606    $('input[name="RescissionSubmit"]').click(function (e) {
1607        var form = $('form#rescission');
1608        var isOK = true;
1609
1610        // Kontrola jestli je vybrany alespon jeden produkt
1611        $('#rescission-contract__error--item-select').hide();
1612        if (($(form).find('input.moneycheck:checked').length + $(form).find('input.newitem:text[value!=""]').length) <= 0) {
1613            $('#rescission-contract__error--item-select').show();
1614            return false;
1615        }
1616
1617        // Kontrola jestli je vyplnene existujici katalogove cislo
1618        var wrongExchangeProducts = $('#rescission').find('input.newitem:text[value!=""]').not('[data-exchange="ok"]');
1619        if (wrongExchangeProducts.length > 0) {
1620            wrongExchangeProducts[0].focus();
1621            $('#rescission-contract__error--product-change').show();
1622            if (!newItemInput.hasClass('rescission-contract__error')) {
1623                newItemInput.addClass('rescission-contract__error');
1624            }
1625        }
1626
1627        $('.rescission-contract__error').removeClass('rescission-contract__error');
1628
1629        // Kontrola jestli je zadane cislo uctu, pokud zakaznik chce vratit penize
1630        // (povinné jen pro Odstoupení, u Reklamace bude volitelné)
1631        $('#rescission-contract__error--bank-account').hide();
1632        if ($(form).hasClass('rescission-contract-form--rescission')) {
1633            if ($(form).find('input.moneycheck:checked').length > 0) {
1634                // CZ cislo uctu
1635                if ($("#BankNumber").length) {
1636                    if ($("#BankNumber").val().length < 1 || $("#AccountNumber").val().length < 1)
1637                        isOK = false;
1638                }
1639                // IBAN cislo uctu
1640                else {
1641                    if ($("#AccountNumber").val().length < 1)
1642                        isOK = false;
1643                }
1644
1645                if (isOK != true) {
1646                    $('#rescission-contract__error--bank-account').show();
1647                    $('.rescission-contract__account-number input').addClass('rescission-contract__error');
1648                    return false;
1649                } else {
1650                    $('.rescission-contract__account-number input').removeClass('rescission-contract__error');
1651                }
1652            }
1653        }
1654
1655        // Kontrola, jestli je vyplněný popis závady
1656        // (povinné jen u reklamačního formuláře)
1657        $('#rescission-contract__error--complaint-notice').hide();
1658        if ($(form).hasClass('rescission-contract-form--complaint')) {
1659            if ($(form).find('input.moneycheck:checked').length > 0) {
1660                if ($("#ProductChangeNotice").val().trim().length < 1)
1661                    isOK = false;
1662
1663                if (isOK != true) {
1664                    $('#rescission-contract__error--complaint-notice').show();
1665                    $('.rescission-contract__notice-input').addClass('rescission-contract__error');
1666                    return false;
1667                } else {
1668                    $('.rescission-contract__notice-input').removeClass('rescission-contract__error');
1669                }
1670            }
1671        }
1672
1673        // Schovani nevybranych radku
1674        $.when(
1675            $('#contractProducts tr.productRow').each(function () {
1676                var refundCheckBox = $(this).find('input.moneycheck').first();
1677                var replaceItem = $(this).find('input.newitem').first();
1678
1679                if (!$(refundCheckBox).is(':checked') && $(replaceItem).val().length < 1)
1680                    $(this).hide();
1681                else {
1682                    replaceItem.attr('readonly', 'readonly');
1683                    refundCheckBox.attr('readonly', 'readonly');
1684                    $('#ProductChangeNotice, #AccountNumberPrefix, #AccountNumber, #BankNumber').attr('readonly', 'readonly');
1685                }
1686            })).done(function () {
1687
1688                if (isOK) {
1689                    e.preventDefault();
1690                    var dataString = $(form).serialize();
1691                    $.ajax({
1692                        type: "POST",
1693                        url: $(form).attr('action'),
1694                        data: dataString
1695                    });
1696
1697                    $('input[name="RescissionSubmit"]').hide();
1698
1699                    $('.popup--rescission-contract').show();
1700                    $('body').addClass('no-scroll-behind-popup');
1701                    $('.button--print').on('click', function () {
1702                        window.print();
1703                    });
1704                }
1705                else
1706                    console.log('form cannot be sent');
1707                return false;
1708            });
1709    });
1710
1711    // Numeric inputs
1712    $("input.numeric").on('keyup paste', function (e) {
1713        // zkontrolování numerických textboxů
1714        if (/\D/g.test(this.value)) {
1715            this.value = this.value.replace(/\D/g, '');
1716        }
1717    });
1718
1719    $("input.numericDash").on('keyup paste', function (e) {
1720        // zkontrolování numerických textboxů
1721        if (/[^\d-]/g.test(this.value)) {
1722            this.value = this.value.replace(/[^\d-]/g, '');
1723        }
1724    });
1725
1726    // Phone inputs
1727    $("input.phone").on('keyup paste', function (e) {
1728        // zkontrolování numerických textboxů
1729        if (/[^0-9 +]+/g.test(this.value)) {
1730            this.value = this.value.replace(/[^0-9 +]+/g, '');
1731        }
1732    });
1733
1734    //TODO: formatovat telefoni cislo po trojicich + formatovani PSC
1735
1736    // hack PL validace emailu
1737    $("input#UserName, input#Email").on("keyup", function (e) {
1738        return false;
1739    });
1740
1741    // Ajaxove strankovani (nacist dalsi)    
1742    $('#loadMoreButton').click(function () {
1743        var totalPages = parseInt($('#total_pages').val(), 10);
1744        var nextPage = parseInt($('#next_page').val(), 10);
1745        var lang = $('#search_lang').val();
1746        var ajaxUrl = $('#nextpage_url').val() + window.location.search;
1747
1748        if (nextPage <= totalPages) {
1749            loadMore(ajaxUrl, null, nextPage, lang, "one_page");
1750        }
1751        if (nextPage + 1 > totalPages) {
1752            $('#loadMoreButton').hide();
1753            $('#buttonLoadNext').hide();
1754        }
1755        if (nextPage > 1) {
1756            $('#buttonLoadPrev').show();
1757        }
1758    });
1759    // Ajaxove strankovani (klasicke)
1760    $('#buttonLoadNext').click(function () {
1761        var totalPages = parseInt($('#total_pages').val(), 10);
1762        var nextPage = parseInt($('#next_page').val(), 10);
1763        var lang = $('#search_lang').val();
1764        var ajaxUrl = $('#nextpage_url').val() + window.location.search;
1765
1766        if (nextPage <= totalPages) {
1767            $('#buttonLoadNext').attr('href', '#' + nextPage);
1768            loadMore(ajaxUrl, null, nextPage, lang, "rewrite");
1769
1770            if ($('#filters').offset() != undefined && $('#filters').css('display') != 'none') {
1771                $('html, body').animate({
1772                    scrollTop: $("#filters").offset().top
1773                }, 0);
1774            } else {
1775                $('html, body').animate({
1776                    scrollTop: $('#content').offset().top
1777                }, 0);
1778            }
1779        }
1780
1781        if (nextPage + 1 > totalPages) {
1782            $('#loadMoreButton').hide();
1783            $('#buttonLoadNext').hide();
1784        }
1785
1786        if (nextPage > 1) {
1787            $('#buttonLoadPrev').show();
1788        }
1789    });
1790    $('#buttonLoadPrev').click(function () {
1791        var totalPages = parseInt($('#total_pages').val(), 10);
1792        var nextPage = parseInt($('#next_page').val(), 10);
1793        var lang = $('#search_lang').val();
1794        var ajaxUrl = $('#nextpage_url').val() + window.location.search;
1795
1796        if (nextPage > 1) {
1797            $('#buttonLoadPrev').attr('href', '#' + (nextPage - 2));
1798            loadMore(ajaxUrl, null, (nextPage - 2), lang, "rewrite");
1799
1800            if ($('#filters').offset() != undefined && $('#filters').css('display') != 'none') {
1801                $('html, body').animate({
1802                    scrollTop: $("#filters").offset().top
1803                }, 0);
1804            } else {
1805                $('html, body').animate({
1806                    scrollTop: $('#content').offset().top
1807                }, 0);
1808            }
1809        }
1810
1811        if (nextPage <= 1) {
1812            $('#buttonLoadPrev').hide();
1813        }
1814
1815        if (nextPage - 2 < totalPages) {
1816            $('#loadMoreButton').show();
1817            $('#buttonLoadNext').show();
1818        }
1819
1820        if (nextPage == 3) {
1821            $('#buttonLoadPrev').hide();
1822        }
1823    });
1824    $('.button-number').click(function () {
1825        var totalPages = parseInt($('#total_pages').val(), 10);
1826        var nextPage = parseInt($(this).attr('href').replace("#", ""), 10);
1827        var lang = $('#search_lang').val();
1828        var ajaxUrl = $('#nextpage_url').val() + window.location.search;
1829
1830        $('.button-number').removeClass('isActive');
1831        $(this).addClass('isActive');
1832
1833        loadMore(ajaxUrl, null, nextPage, lang, "rewrite");
1834
1835        // Scroll na začátek stránky při kliknutí na další stránku ve stránkování
1836        // hezčí verze s možností animace, nyní animace vypnutá
1837        if ($('#filters').offset() != undefined && $('#filters').css('display') != 'none') {
1838            $('html, body').animate({
1839                scrollTop: $("#filters").offset().top
1840            }, 0);
1841        } else {
1842            $('html, body').animate({
1843                scrollTop: $('#content').offset().top
1844            }, 0);
1845        }
1846
1847        if (nextPage + 1 > totalPages) {
1848            $('#loadMoreButton').hide();
1849            $('#buttonLoadNext').hide();
1850        } else {
1851            $('#loadMoreButton').show();
1852            $('#buttonLoadNext').show();
1853        }
1854
1855        if (nextPage > 1) {
1856            $('#buttonLoadPrev').show();
1857        } else {
1858            $('#buttonLoadPrev').hide();
1859        }
1860    });
1861    try {
1862        showButtons();
1863    } catch (e) {
1864        //TODO 
1865    }
1866
1867
1868    // infoblock:hover
1869    $('header .info-block .favorites, header .info-block .link').hover(function () {
1870        $(this).toggleClass('hover');
1871    });
1872
1873    // Spinner pro pomalou registraci
1874    $('input[name=btnRegisterSubmit]').click(function () {
1875        $('#register-form').submit();
1876        window.setTimeout(function () {
1877            var error = $('span.field-validation-error').html();
1878            if (error == undefined || error == "") {
1879                $('#register_spinner').css("display", "block");
1880            }
1881        }, 2000);
1882    });
1883
1884    // B2B kontrola ověření
1885    $('input[name=btnRegisterB2BSubmit]').click(function () {
1886        function register() {
1887            if (!$('#vatpayer-isVatPayer')[0].checked) {
1888                $('#IsVatVerified').val("False");
1889                $('#VatNumber').val("");
1890            }
1891
1892            $('#register-form').submit();
1893            window.setTimeout(function () {
1894                var error = $('span.field-validation-error').html();
1895                if (error == undefined || error == "") {
1896                    $('#register_spinner').css("display", "block");
1897                }
1898            }, 2000);
1899        }
1900
1901        if ($('#vatpayer-isVatPayer')[0].checked) {
1902            if ($('#IsVatVerified').val() == "True") {
1903                register();
1904            } else {
1905                CheckRegisterDIC();
1906            }
1907        } else {
1908            register();
1909        }
1910    });
1911
1912    $('a[data-sug]').live('click', function () {
1913
1914        //save click in sugestbox for autolearning
1915        if ($(this).hasClass('sug-stats')) {
1916            $.ajax({
1917                url: "/search-stats",
1918                type: "POST",
1919                data: { q: $("input.fulltext[name='q']").val(), d: $(this).data("sug") }
1920            });
1921        }
1922
1923    });
1924
1925    $('a[data-clickvaluesdatalayer]').on('click', function () {
1926        var pushData = $(this).data('clickvaluesdatalayer');
1927        console.log("pushData sent .." + pushData);
1928        dataLayer.push(pushData);
1929        if ($(this).hasClass("lbx")) lbDataLayer.push(pushData);
1930    });
1931
1932    $('a[data-clickvalues]').live('click', function () {
1933        if (!$(this).hasClass('add-to-cart')) {
1934            dataLayer.push($(this).data('clickvalues'));
1935            window.location = $(this).attr('href');
1936            return false;
1937        }
1938    });
1939
1940    $('a.add-to-cart.lightbox').live('click', function () {
1941
1942        var href = $(this).attr('href');
1943        var dataHref = $(this).data('href');
1944        var productId = $(this).data('id');
1945
1946        if (productId != undefined || productId != null) {
1947            $.ajax({
1948                url: '/cart/AddToCartGaScript?productId=' + productId + "&categoryList=Product.Detail.Lightbox" + "&eventValue=add",
1949                type: "POST",
1950                data: "",
1951                success: function (data) {
1952                    dataLayer.push(data);
1953                    $.post(dataHref, { amount: 1 }, function (response) {
1954                        if (response.Count == -1) {
1955                            alert("The product failed to be added to your cart.");
1956                            return false;
1957                        }
1958
1959                        var btn = $('#ajax-basket strong.cnt-info');
1960                        if (!btn.hasClass('active')) {
1961                            btn.addClass('active');
1962                        }
1963
1964                        window.location = href;
1965                        return false;
1966                    }, "json");
1967                    return false;
1968                }
1969            });
1970        }
1971        return false;
1972    });
1973
1974
1975
1976    // ---------------------------------------------------------------------------------------------
1977    //  Nastavení první option v selectu Region na disabled
1978    // ---------------------------------------------------------------------------------------------
1979    if ($('#Region').length) {
1980        var select2Options = { width: '100%' };
1981        var apiUrl = '/region-result/:parentId:';
1982
1983        $('#Region').select2(select2Options);
1984        $('#City').select2(select2Options);
1985
1986        var cascadeLoading = new Select2Cascade($("#Region"), $("#City"), apiUrl, select2Options);
1987    }
1988    // end -----------------------------------------------------------------------------------------
1989
1990    //validace domeny emailove adresy na inputech, ktere maji data-domaincheck, v kteremzto atributu je ID prvku, ktery se zobrazuje jako warning
1991    $("#main").on("focusout", "input[data-domaincheck]", function (e) {
1992
1993        //todo: ukladat naposledy overenou hodnotu, at se to zbytecne na serveru nevola na kazdy focusout
1994
1995        //vedlejsi efekt je trimovani emailu ;)
1996        $(this).val($(this).val().trim());
1997
1998        //vlastni volani validace
1999        var i = $(this);
2000        var w = $($(this).data("domaincheck"));
2001
2002        if ($(i).val() != "@") {
2003            $.ajax({
2004                type: 'GET', cache: false, url: '/account/IsEmailDomainValid/', data: { email: $(i).val() },
2005                success: function (data) {
2006                    if (data == '1') {
2007                        $(w).hide();
2008                        $(i).removeClass('input-validation-warning');
2009                    }
2010                    else if (data == '0') {
2011                        $(w).show();
2012                        $(i).addClass('input-validation-warning');
2013                    }
2014                    else { $(w).hide(); }  //pripad, kdy se overuje neco, co neni ani vubec validni a mel by zachytit a oznamit validator
2015                },
2016                error: function (e) {
2017                    console.log("Domain checking error: " + e);
2018                }
2019            });
2020        }
2021    });
2022
2023    $('.slick-slider').slick('refresh');
2024
2025    setTimeout(() => {
2026        $('.slick-slider').slick('refresh');
2027    }, 100);
2028
2029    $('.UA #City').autocomplete({
2030        source: function (request, response) {
2031            if (request.term.length > 2) {
2032                $.ajax({
2033                    url: "/ajaxCity/",
2034                    type: "GET",
2035                    async: true,
2036                    data: { q: request.term },
2037                    dataType: "json",
2038                    success: function (data) {
2039                        response(data);
2040                    },
2041                    error: function (e) {
2042                        console.log("Call ajax-city ajax error: " + e);
2043                    }
2044                });
2045            }
2046            else { response(""); }
2047        }
2048    });
2049});
2050
2051function InitProductHoverImages() {
2052    $('.product-thumbnail')
2053        .off('mouseenter.productHover')
2054        .on('mouseenter.productHover', function () {
2055            let thumbnail = $(this).find('.product-thumbnail__photo');
2056            let secondary = thumbnail.data('hover-src');
2057            if (secondary) {
2058                if (thumbnail.hasClass('late-load')) {
2059                    if (thumbnail.attr('data-src')) {
2060                        thumbnail.attr("data-canonical-src", thumbnail.attr('data-src'));
2061                    } else {
2062                        thumbnail.attr("data-canonical-src", thumbnail.attr("src"));
2063                    }
2064                } else {
2065                    thumbnail.attr("data-canonical-src", thumbnail.attr("src"));
2066                }
2067                thumbnail.attr('src', secondary);
2068            }
2069        })
2070        .off('mouseleave.productHover')
2071        .on('mouseleave.productHover', function () {
2072            let thumbnail = $(this).find('.product-thumbnail__photo');
2073            if (thumbnail.hasClass('late-load')) {
2074                if (thumbnail.attr('data-src')) {
2075                    thumbnail.attr('src', thumbnail.attr('data-src'));
2076                } else if (thumbnail.attr('data-srcset')) {
2077                    PickBestImage(thumbnail[0]);
2078                }
2079            } else {
2080                thumbnail.attr('src', thumbnail.data("canonical-src"));
2081            }
2082        });
2083}
2084
2085// Rebinding po ajaxovem nacteni dalsich produktu
2086function rebind() {
2087    IsPagingProcessing = false;
2088
2089    // tipsy:
2090    if ($('a.tooltip, .icons .economy, .icons .transport, a.btn-info, .icons .spec-trans, .icons .pure-selection, .btn-like').length > 0) {
2091        $('a.tooltip, a.btn-info').click(function () {
2092            return false;
2093        });
2094
2095        $('a.tooltip, .icons .economy, .icons .transport, a.btn-info, .icons .spec-trans, .icons .pure-selection, .btn-like').not('.favorites-del').tipsy({
2096            gravity: 's',
2097            delayIn: 500,
2098            delayOut: 500,
2099            fade: false
2100        });
2101    }
2102
2103    $('[original-title].tipsy-i-icon').each(function () {
2104        var gravity = "s";
2105        var attrGravity = $(this).attr("data-tipsy-gravity");
2106        if (attrGravity != undefined) gravity = attrGravity;
2107        $(this).tipsy({
2108            gravity: gravity,
2109            delayIn: 500,
2110            delayOut: 500,
2111            fade: false,
2112            html: true
2113        });
2114    });
2115
2116    if ($('[data-tooltip-trigger]').length > 0) {
2117        $('[data-tooltip-trigger]').on('click', function (e) {
2118            e.preventDefault();
2119            var $tooltipcontainer = $(this).parents('.tooltip-wrapper').find('.tooltip-container');
2120            $tooltipcontainer.css('top', '-' + ($tooltipcontainer.height() /*- 10*/) + 'px').stop(true, true).fadeIn(200);
2121        });
2122
2123        $('body').on('click', function (e) {
2124            if (!$(e.target).hasClass('tooltip-inside') && !$(e.target).hasClass('tooltip-link-trigger')) {
2125                $('.tooltip-container').fadeOut(200);
2126            }
2127        });
2128    }
2129
2130    updateVariantCount();
2131
2132    $(window).resize(function () {
2133        updateVariantCount();
2134    });
2135
2136    $('.product-thumbnail__color-variants').resize(function () {
2137        updateVariantCount();
2138    })
2139
2140    const caruselVariantHeight = function () {
2141        $('.product-thumbnail__color-variants .variant').parents('.products-list--carousel').addClass("contains-color-variants");
2142    }
2143
2144    caruselVariantHeight();
2145
2146    $('.product-thumbnail__color-variants').on('mouseleave', function (e) {
2147        e.preventDefault();
2148
2149        $(this).children('.active').removeClass('active');
2150        $(this).children('.canonical').addClass('active');
2151        const thumbnail = $(this).parents('.products-list-item').find('.product-thumbnail__photo');
2152        thumbnail.attr('src', $(thumbnail).data("canonical-src"));
2153    });
2154
2155    $('.product-thumbnail__color-variants > .variant').on('mouseenter', function (e) {
2156        e.preventDefault();
2157        const thumbnail = $(this).parents('.products-list-item').find('.product-thumbnail__photo');
2158        if (thumbnail.data("canonical-src") == undefined) {
2159            thumbnail.attr("data-canonical-src", thumbnail.attr("src"));
2160        }
2161
2162        $(this).parent().find('.active').removeClass('active');
2163        $(this).addClass('active');
2164        if ($(this).hasClass('canonical')) {
2165            thumbnail.attr('src', thumbnail.data("canonical-src"));
2166        } else {
2167            thumbnail.attr('src', $(this).data("preview"));
2168        }
2169    });
2170
2171    let isdebug = localStorage.getItem("debugInfoEnabled") == 1;
2172    if (!isdebug) {
2173        $(".debug-info").hide();
2174    }
2175}
2176
2177const breakpoints = {
2178    [0]: 3,
2179    [160]: 4,
2180    [210]: 6,
2181    [280]: 8,
2182}
2183
2184const updateVariantCount = function () {
2185    $('.product-thumbnail__color-variants').each(function () {
2186        let useCount = 3;
2187        for (var key in breakpoints) {
2188            if ($(this).width() > key) {
2189                useCount = breakpoints[key];
2190            }
2191        }
2192
2193        const children = $(this).children().not(".product-thumbnail__hidden-variants");
2194        const allowLast = children.length == useCount + 1;
2195        const displayedVariants = useCount + (allowLast ? 1 : 0)
2196        const hiddenVariants = Math.max(0, children.length - displayedVariants);
2197        children.each(function (index) {
2198            if ($(this).hasClass("active")) {
2199                $(this).addClass("canonical");
2200            }
2201            $(this).show();
2202            if (index >= displayedVariants) $(this).hide();
2203        });
2204
2205        const counter = $(this).children(".product-thumbnail__hidden-variants");
2206        counter.text("+" + hiddenVariants);
2207        counter.hide();
2208        if (hiddenVariants > 0) {
2209            counter.show();
2210        }
2211    });
2212
2213}
2214
2215function shouldAutoplayVideo() {
2216    const isSmallScreen = window.innerWidth < 500;
2217
2218    //const isConnectionSaveData = navigator.connection?.saveData === true;
2219    //const isConnectionCellular = navigator.connection?.type === 'cellular';
2220
2221    return !(isSmallScreen);
2222}
2223
2224
2225// AJAX paging:
2226function loadMore(url, toSkip, page, lang, ajaxLoadingType) {
2227    if (!isNaN(page) && !IsPagingProcessing) {
2228        IsPagingProcessing = true;
2229        $.ajax({
2230            type: 'GET',
2231            async: true,
2232            url: url,
2233            data: { skip: toSkip, p: page, c: lang, ajax_loading: ajaxLoadingType },
2234            success: function (data) {
2235                if (ajaxLoadingType != "rewrite") {
2236                    if (window.location.hash) {
2237                        if (window.location.hash.indexOf("/") != -1) {
2238                            window.location.hash = window.location.hash.substring(0, window.location.hash.indexOf("/")) + "/" + page;
2239                        } else {
2240                            window.location.hash = window.location.hash + "/" + page;
2241                        }
2242                    } else {
2243                        window.location.hash = "#1/" + page;
2244                    }
2245                } else {
2246                    window.location.hash = page;
2247                }
2248                $('#loadMoreButton span').html($('#total_items').val() - page * $('#page_size').val());
2249                if (ajaxLoadingType == "one_page") {
2250                    $('#results').append(data);
2251                } else {
2252                    $('#results').html(data);
2253                }
2254
2255                activePage('#' + page);
2256
2257                $('#next_page').val(++page);
2258                IsPagingProcessing = false;
2259
2260                ReturnToSavedPosition();
2261
2262                rebind();
2263                RefreshLateload();
2264                InitProductHoverImages();
2265
2266                var gaLevel = window.location.hash.substr(1);
2267                gaLevel = gaLevel[1] ? gaLevel : "0" + gaLevel;
2268                var gaPathname = window.location.pathname;
2269                var values = $('#gaHelper');
2270                $.ajax({
2271                    url: '/cart/GaScript130?pageType=' + values.data('pagetype') + "&breadcrumbs=" + values.data('breadcrumbs') + "&title=" + values.data('title') + "&pathname=" + (gaPathname + 'page' + gaLevel.replace('/', '-')),
2272                    type: "POST",
2273                    success: function (gaData) {
2274                        dataLayer.push(gaData);
2275                    }
2276                });
2277
2278            },
2279            error: function (e) {
2280                console.log("Call loadMore ajax error: " + e);
2281            }
2282        });
2283    }
2284}
2285
2286function RegisterTaxToggle() {
2287    let positive = $('#vatpayer-isVatPayer')[0].checked;
2288    $('#VatInteraction').val('True');
2289
2290    if (positive) {
2291        $('.toggle-field').show();
2292        $('.check-vat-number').show();
2293    } else {
2294        $('.toggle-field').hide();
2295        $('.check-vat-number').hide();
2296    }
2297
2298    $('#vatpayer-isVatPayer').valid();
2299}
2300
2301function CancelRegisterDIC() {
2302    $('#IsVatVerified').val("False");
2303    $('#TaxNumber').removeAttr('readonly');
2304    $('#Company').removeAttr('readonly');
2305    $('.check-vat-number').show();
2306    $('.cancel-valid-vat').hide();
2307}
2308
2309function CheckRegisterDIC() {
2310    let dic = $('#TaxNumber').val();
2311    $('#vatPayerPopup').show();
2312    $('#vatPayerPopup .result').hide();
2313    $('#vatPayerPopup .confirm').hide();
2314    $('#vatPayerPopup .cancel').show();
2315    $('#vatPayerPopup .progress').show();
2316
2317    let ignoreFlag = false;
2318
2319    $('#vatPayerPopup .cancel').on('click', function () {
2320        ignoreFlag = true;
2321    });
2322
2323    $.ajax({
2324        url: $("#registerData").data('vat-verification'),
2325        type: "POST",
2326        data: { "vatNumber": dic },
2327        success: function (data) {
2328            if (ignoreFlag) return;
2329            $('#vatPayerPopup .result').show();
2330            $('#vatPayerPopup .progress').hide();
2331            $('#vatPayerPopup .result').html($('#vatPayerPopup').data("message-not-vat-payer"));
2332            if (data.IsError) {
2333                if (data.ErrorMessage) {
2334                    $('#vatPayerPopup .result').html(data.ErrorMessage);
2335                } else {
2336                    $('#vatPayerPopup .result').html($('#vatPayerPopup').data("message-error"));
2337                }
2338            } else {
2339                if (data.IsVatPayer) {
2340                    if (data.ViesResponse && data.ViesResponse.Vies) {
2341                        $('#vatPayerPopup .result').html($('#vatPayerPopup').data("message-success"));
2342                        let traderName = data.ViesResponse.Vies.TraderName;
2343                        $('#IsVatVerified').val("True");
2344                        $('#vatPayerPopup .confirm').show();
2345                        $('#vatPayerPopup .cancel').hide();
2346                        $('#TaxNumber').attr('readonly', 'readonly');
2347                        $('#Company').val(traderName.substring(0, 50));
2348                        $('#Company').attr('readonly', 'readonly');
2349                        $('.check-vat-number').hide();
2350                        $('#TaxNumber').val(data.ViesResponse.Vies.CountryCode + data.ViesResponse.Vies.VatNumber);
2351                        $('.cancel-valid-vat').show();
2352                    }
2353                }
2354            }
2355        }
2356    })
2357}
2358
2359//
2360$(window).resize(function () {
2361    if ($('#popup').index() > 0 && $('#popup').is(':visible')) {
2362        var screenwidth = $(window).width() - 100;
2363        var screenheight = $(window).height() - 50;
2364        $('#popup img').css('max-width', screenwidth + 'px').css('max-height', screenheight + 'px');
2365    }
2366    productDetailPhotos();
2367});
2368
2369function activePage(page) {
2370    if (page != "") {
2371        $('div.pagination a.button-number').removeClass('isActive');
2372        var active = $('div.pagination a.button-number[href=' + page + ']');
2373        active.addClass('isActive');
2374        showButtons();
2375    }
2376}
2377function showButtons() {
2378    if (!$('#main').hasClass('articlesPage')) {
2379        var activeLink = $('div.pagination a.button-number.isActive');
2380        var linkValue = parseInt(activeLink.attr('href').substring(1));
2381
2382        var countOfPages = $('div.pagination a.button-number').length;
2383        if (linkValue > 5) {
2384            $('div.pagination span.dots.start').css("display", "inline-block");
2385        } else {
2386            $('div.pagination span.dots.start').hide();
2387        }
2388        if (linkValue >= (countOfPages - 2)) {
2389            $('div.pagination span.dots.end').hide();
2390        } else {
2391            $('div.pagination span.dots.end').css("display", "inline-block");
2392        }
2393
2394        $('div.pagination a.button-number').hide();
2395        for (var i = (linkValue - 3); i < (linkValue + 2); i++) {
2396            $('div.pagination a.button-number[href=#' + i + ']').css("display", "inline-block");
2397        }
2398        //TODO nezobrazovat/skrývat - mazat a vytvářet html
2399    }
2400}
2401
2402// load somponents
2403async function LoadComponents() {
2404    const promises = [];
2405    $('.x-component').each(function () {
2406        const placeholder = $(this);
2407        const comp = placeholder.data("component");
2408        const id = placeholder.data("id");
2409        const params = new URLSearchParams();
2410        params.append("type", comp);
2411        params.append("id", id);
2412
2413        const promise = (async () => {
2414            const response = await fetch("/component/?" + params);
2415            const content = await response.text();
2416            placeholder[0].outerHTML = content;
2417        })();
2418
2419        promises.push(promise);
2420    });
2421
2422    await Promise.all(promises);
2423    RefreshLateload();
2424    NavInteractions();
2425}
2426// toggleLogin
2427function ToggleFloatingLogin() {
2428    $('.link').toggleClass('show-register');
2429    $('.partial-login-wrap').toggle();
2430    $('.info-block .link').toggleClass('isOpen');
2431    //$('body').toggleClass('no-mobile-scroll');
2432}
2433function setCookie(cname, cvalue, exdays) {
2434    var d = new Date();
2435    d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
2436    var expires = "expires=" + d.toGMTString();
2437    document.cookie = cname + "=" + cvalue + "; path=/; " + expires;
2438}
2439
2440jQuery(function ($) {
2441    $("a[href*='youtube'], a[href*='youtu.be']").each(function () {
2442        if (!$(this).hasClass('not-swipebox')) { // aby se swipebox nespouštěl pro odkazy na youtube (např. homepage youtube profilu), přidáme danému odkazu class 'not-swipebox'
2443            $(this).swipebox({
2444                useCSS: true, // false will force the use of jQuery for animations
2445                hideBarsDelay: 3000, // 0 to always show caption and action bar
2446                videoMaxWidth: 600, // videos max width
2447                beforeOpen: function () {
2448                    $('.rat-popup-overall').show();
2449                }, // called before opening
2450                afterOpen: function () {
2451                    $('#swipebox-next').addClass('disabled');
2452                }, // called before opening
2453                afterClose: function () {
2454                    $('.rat-popup-overall').hide();
2455                    $('#swipebox-next').removeClass('disabled');
2456                } // called after closing
2457            });
2458        }
2459    });
2460});
2461
2462function productDetailPhotos() {
2463    $('.promo2').each(function () {
2464        var _visual = $(this).find('.visual').find('img');
2465        var _prev = $(this).find('.btn-prev');
2466        var _next = $(this).find('.btn-next');
2467        var _list = $(this).find('.gallery ul');
2468        var _width = 0;
2469        var _element_width = 0;
2470        _list.find('li').each(function () {
2471            _width += $(this).outerWidth(true);
2472            _element_width = $(this).outerWidth(true);
2473        });
2474        var _margin = 0;
2475
2476        _list.find('img').click(function () {
2477            $(this).parent().parent().parent().find('.active').removeClass('active');
2478            var _src = this.src;
2479            $(_visual).attr('src', $(this).data('detail'));
2480            $(this).parent().parent().addClass('active');
2481
2482            swipeboxIndex = $(this).parent().parent().index();
2483            return false;
2484        });
2485    });
2486}
2487
2488function move(list, margin, side) {
2489    if (side == 'left') {
2490        $(list).animate({
2491            marginLeft: margin
2492        }, 1000, function () {
2493        });
2494    } else {
2495        $(list).animate({
2496            marginTop: margin
2497        }, 1000, function () {
2498        });
2499    }
2500}
2501
2502function yesno(checkboxvar, thelabel) {
2503    var labelvar = document.getElementById(thelabel);
2504    if (!checkboxvar.checked) {
2505        labelvar.innerHTML = $('#' + thelabel).data('nostate');
2506    }
2507    else {
2508        labelvar.innerHTML = $('#' + thelabel).data('yesstate');
2509    }
2510}
2511
2512function updateCartParentHeight() {
2513    const cartParent = $(".cart-parent");
2514    var height = $('.product-info').outerHeight(true);
2515    $(cartParent).css("min-height", height + "px");
2516}
2517function TestScripts() { return "TestScripts"; }
2518
2519;/*! URI.js v1.19.1 http://medialize.github.io/URI.js/ */
2520/* build contains: URI.js */
2521/*
2522 URI.js - Mutating URLs
2523
2524 Version: 1.19.1
2525
2526 Author: Rodney Rehm
2527 Web: http://medialize.github.io/URI.js/
2528
2529 Licensed under
2530   MIT License http://www.opensource.org/licenses/mit-license
2531
2532*/
2533(function(m,v){"object"===typeof module&&module.exports?module.exports=v(require("./punycode"),require("./IPv6"),require("./SecondLevelDomains")):"function"===typeof define&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],v):m.URI=v(m.punycode,m.IPv6,m.SecondLevelDomains,m)})(this,function(m,v,t,h){function d(a,b){var c=1<=arguments.length,e=2<=arguments.length;if(!(this instanceof d))return c?e?new d(a,b):new d(a):new d;if(void 0===a){if(c)throw new TypeError("undefined is not a valid argument for URI");
2534a="undefined"!==typeof location?location.href+"":""}if(null===a&&c)throw new TypeError("null is not a valid argument for URI");this.href(a);return void 0!==b?this.absoluteTo(b):this}function p(a){return a.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function u(a){return void 0===a?"Undefined":String(Object.prototype.toString.call(a)).slice(8,-1)}function k(a){return"Array"===u(a)}function C(a,b){var c={},d;if("RegExp"===u(b))c=null;else if(k(b)){var f=0;for(d=b.length;f<d;f++)c[b[f]]=!0}else c[b]=
2535!0;f=0;for(d=a.length;f<d;f++)if(c&&void 0!==c[a[f]]||!c&&b.test(a[f]))a.splice(f,1),d--,f--;return a}function w(a,b){var c;if(k(b)){var d=0;for(c=b.length;d<c;d++)if(!w(a,b[d]))return!1;return!0}var f=u(b);d=0;for(c=a.length;d<c;d++)if("RegExp"===f){if("string"===typeof a[d]&&a[d].match(b))return!0}else if(a[d]===b)return!0;return!1}function D(a,b){if(!k(a)||!k(b)||a.length!==b.length)return!1;a.sort();b.sort();for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1;return!0}function z(a){return a.replace(/^\/+|\/+$/g,
2536"")}function F(a){return escape(a)}function A(a){return encodeURIComponent(a).replace(/[!'()*]/g,F).replace(/\*/g,"%2A")}function x(a){return function(b,c){if(void 0===b)return this._parts[a]||"";this._parts[a]=b||null;this.build(!c);return this}}function E(a,b){return function(c,d){if(void 0===c)return this._parts[a]||"";null!==c&&(c+="",c.charAt(0)===b&&(c=c.substring(1)));this._parts[a]=c;this.build(!d);return this}}var G=h&&h.URI;d.version="1.19.1";var g=d.prototype,l=Object.prototype.hasOwnProperty;
2537d._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,preventInvalidHostname:d.preventInvalidHostname,duplicateQueryParameters:d.duplicateQueryParameters,escapeQuerySpace:d.escapeQuerySpace}};d.preventInvalidHostname=!1;d.duplicateQueryParameters=!1;d.escapeQuerySpace=!0;d.protocol_expression=/^[a-z][a-z0-9.+-]*$/i;d.idn_expression=/[^a-z0-9\._-]/i;d.punycode_expression=/(xn--)/i;d.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
2538d.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
2539d.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019]))/ig;d.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?\u00ab\u00bb\u201c\u201d\u201e\u2018\u2019]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g};d.defaultPorts={http:"80",https:"443",ftp:"21",
2540gopher:"70",ws:"80",wss:"443"};d.hostProtocols=["http","https"];d.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/;d.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"action",img:"src",area:"href",iframe:"src",embed:"src",source:"src",track:"src",input:"src",audio:"src",video:"src"};
vendor: 24,081 bytes, lines 2540-2587
2540d.getDomAttribute=function(a){if(a&&a.nodeName){var b=a.nodeName.toLowerCase();if("input"!==b||"image"===a.type)return d.domAttributes[b]}};d.encode=A;d.decode=decodeURIComponent;d.iso8859=
2541function(){d.encode=escape;d.decode=unescape};d.unicode=function(){d.encode=A;d.decode=decodeURIComponent};d.characters={pathname:{encode:{expression:/%(24|26|2B|2C|3B|3D|3A|40)/ig,map:{"%24":"$","%26":"&","%2B":"+","%2C":",","%3B":";","%3D":"=","%3A":":","%40":"@"}},decode:{expression:/[\/\?#]/g,map:{"/":"%2F","?":"%3F","#":"%23"}}},reserved:{encode:{expression:/%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,map:{"%3A":":","%2F":"/","%3F":"?","%23":"#","%5B":"[","%5D":"]","%40":"@",
2542"%21":"!","%24":"$","%26":"&","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"="}}},urnpath:{encode:{expression:/%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,map:{"%21":"!","%24":"$","%27":"'","%28":"(","%29":")","%2A":"*","%2B":"+","%2C":",","%3B":";","%3D":"=","%40":"@"}},decode:{expression:/[\/\?#:]/g,map:{"/":"%2F","?":"%3F","#":"%23",":":"%3A"}}}};d.encodeQuery=function(a,b){var c=d.encode(a+"");void 0===b&&(b=d.escapeQuerySpace);return b?c.replace(/%20/g,"+"):c};d.decodeQuery=
2543function(a,b){a+="";void 0===b&&(b=d.escapeQuerySpace);try{return d.decode(b?a.replace(/\+/g,"%20"):a)}catch(c){return a}};var r={encode:"encode",decode:"decode"},y,B=function(a,b){return function(c){try{return d[b](c+"").replace(d.characters[a][b].expression,function(c){return d.characters[a][b].map[c]})}catch(e){return c}}};for(y in r)d[y+"PathSegment"]=B("pathname",r[y]),d[y+"UrnPathSegment"]=B("urnpath",r[y]);r=function(a,b,c){return function(e){var f=c?function(a){return d[b](d[c](a))}:d[b];
2544e=(e+"").split(a);for(var g=0,n=e.length;g<n;g++)e[g]=f(e[g]);return e.join(a)}};d.decodePath=r("/","decodePathSegment");d.decodeUrnPath=r(":","decodeUrnPathSegment");d.recodePath=r("/","encodePathSegment","decode");d.recodeUrnPath=r(":","encodeUrnPathSegment","decode");d.encodeReserved=B("reserved","encode");d.parse=function(a,b){b||(b={preventInvalidHostname:d.preventInvalidHostname});var c=a.indexOf("#");-1<c&&(b.fragment=a.substring(c+1)||null,a=a.substring(0,c));c=a.indexOf("?");-1<c&&(b.query=
2545a.substring(c+1)||null,a=a.substring(0,c));"//"===a.substring(0,2)?(b.protocol=null,a=a.substring(2),a=d.parseAuthority(a,b)):(c=a.indexOf(":"),-1<c&&(b.protocol=a.substring(0,c)||null,b.protocol&&!b.protocol.match(d.protocol_expression)?b.protocol=void 0:"//"===a.substring(c+1,c+3)?(a=a.substring(c+3),a=d.parseAuthority(a,b)):(a=a.substring(c+1),b.urn=!0)));b.path=a;return b};d.parseHost=function(a,b){a||(a="");a=a.replace(/\\/g,"/");var c=a.indexOf("/");-1===c&&(c=a.length);if("["===a.charAt(0)){var e=
2546a.indexOf("]");b.hostname=a.substring(1,e)||null;b.port=a.substring(e+2,c)||null;"/"===b.port&&(b.port=null)}else{var f=a.indexOf(":");e=a.indexOf("/");f=a.indexOf(":",f+1);-1!==f&&(-1===e||f<e)?(b.hostname=a.substring(0,c)||null,b.port=null):(e=a.substring(0,c).split(":"),b.hostname=e[0]||null,b.port=e[1]||null)}b.hostname&&"/"!==a.substring(c).charAt(0)&&(c++,a="/"+a);b.preventInvalidHostname&&d.ensureValidHostname(b.hostname,b.protocol);b.port&&d.ensureValidPort(b.port);return a.substring(c)||
2547"/"};d.parseAuthority=function(a,b){a=d.parseUserinfo(a,b);return d.parseHost(a,b)};d.parseUserinfo=function(a,b){var c=a.indexOf("/"),e=a.lastIndexOf("@",-1<c?c:a.length-1);-1<e&&(-1===c||e<c)?(c=a.substring(0,e).split(":"),b.username=c[0]?d.decode(c[0]):null,c.shift(),b.password=c[0]?d.decode(c.join(":")):null,a=a.substring(e+1)):(b.username=null,b.password=null);return a};d.parseQuery=function(a,b){if(!a)return{};a=a.replace(/&+/g,"&").replace(/^\?*&*|&+$/g,"");if(!a)return{};for(var c={},e=a.split("&"),
2548f=e.length,g,n,k=0;k<f;k++)if(g=e[k].split("="),n=d.decodeQuery(g.shift(),b),g=g.length?d.decodeQuery(g.join("="),b):null,l.call(c,n)){if("string"===typeof c[n]||null===c[n])c[n]=[c[n]];c[n].push(g)}else c[n]=g;return c};d.build=function(a){var b="";a.protocol&&(b+=a.protocol+":");a.urn||!b&&!a.hostname||(b+="//");b+=d.buildAuthority(a)||"";"string"===typeof a.path&&("/"!==a.path.charAt(0)&&"string"===typeof a.hostname&&(b+="/"),b+=a.path);"string"===typeof a.query&&a.query&&(b+="?"+a.query);"string"===
2549typeof a.fragment&&a.fragment&&(b+="#"+a.fragment);return b};d.buildHost=function(a){var b="";if(a.hostname)b=d.ip6_expression.test(a.hostname)?b+("["+a.hostname+"]"):b+a.hostname;else return"";a.port&&(b+=":"+a.port);return b};d.buildAuthority=function(a){return d.buildUserinfo(a)+d.buildHost(a)};d.buildUserinfo=function(a){var b="";a.username&&(b+=d.encode(a.username));a.password&&(b+=":"+d.encode(a.password));b&&(b+="@");return b};d.buildQuery=function(a,b,c){var e="",f,g;for(f in a)if(l.call(a,
2550f)&&f)if(k(a[f])){var n={};var h=0;for(g=a[f].length;h<g;h++)void 0!==a[f][h]&&void 0===n[a[f][h]+""]&&(e+="&"+d.buildQueryParameter(f,a[f][h],c),!0!==b&&(n[a[f][h]+""]=!0))}else void 0!==a[f]&&(e+="&"+d.buildQueryParameter(f,a[f],c));return e.substring(1)};d.buildQueryParameter=function(a,b,c){return d.encodeQuery(a,c)+(null!==b?"="+d.encodeQuery(b,c):"")};d.addQuery=function(a,b,c){if("object"===typeof b)for(var e in b)l.call(b,e)&&d.addQuery(a,e,b[e]);else if("string"===typeof b)void 0===a[b]?
2551a[b]=c:("string"===typeof a[b]&&(a[b]=[a[b]]),k(c)||(c=[c]),a[b]=(a[b]||[]).concat(c));else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");};d.setQuery=function(a,b,c){if("object"===typeof b)for(var e in b)l.call(b,e)&&d.setQuery(a,e,b[e]);else if("string"===typeof b)a[b]=void 0===c?null:c;else throw new TypeError("URI.setQuery() accepts an object, string as the name parameter");};d.removeQuery=function(a,b,c){var e;if(k(b))for(c=0,e=b.length;c<e;c++)a[b[c]]=
2552void 0;else if("RegExp"===u(b))for(e in a)b.test(e)&&(a[e]=void 0);else if("object"===typeof b)for(e in b)l.call(b,e)&&d.removeQuery(a,e,b[e]);else if("string"===typeof b)void 0!==c?"RegExp"===u(c)?!k(a[b])&&c.test(a[b])?a[b]=void 0:a[b]=C(a[b],c):a[b]!==String(c)||k(c)&&1!==c.length?k(a[b])&&(a[b]=C(a[b],c)):a[b]=void 0:a[b]=void 0;else throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");};d.hasQuery=function(a,b,c,e){switch(u(b)){case "String":break;
2553case "RegExp":for(var f in a)if(l.call(a,f)&&b.test(f)&&(void 0===c||d.hasQuery(a,f,c)))return!0;return!1;case "Object":for(var g in b)if(l.call(b,g)&&!d.hasQuery(a,g,b[g]))return!1;return!0;default:throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter");}switch(u(c)){case "Undefined":return b in a;case "Boolean":return a=!(k(a[b])?!a[b].length:!a[b]),c===a;case "Function":return!!c(a[b],b,a);case "Array":return k(a[b])?(e?w:D)(a[b],c):!1;case "RegExp":return k(a[b])?
2554e?w(a[b],c):!1:!(!a[b]||!a[b].match(c));case "Number":c=String(c);case "String":return k(a[b])?e?w(a[b],c):!1:a[b]===c;default:throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");}};d.joinPaths=function(){for(var a=[],b=[],c=0,e=0;e<arguments.length;e++){var f=new d(arguments[e]);a.push(f);f=f.segment();for(var g=0;g<f.length;g++)"string"===typeof f[g]&&b.push(f[g]),f[g]&&c++}if(!b.length||!c)return new d("");b=(new d("")).segment(b);
2555""!==a[0].path()&&"/"!==a[0].path().slice(0,1)||b.path("/"+b.path());return b.normalize()};d.commonPath=function(a,b){var c=Math.min(a.length,b.length),d;for(d=0;d<c;d++)if(a.charAt(d)!==b.charAt(d)){d--;break}if(1>d)return a.charAt(0)===b.charAt(0)&&"/"===a.charAt(0)?"/":"";if("/"!==a.charAt(d)||"/"!==b.charAt(d))d=a.substring(0,d).lastIndexOf("/");return a.substring(0,d+1)};d.withinString=function(a,b,c){c||(c={});var e=c.start||d.findUri.start,f=c.end||d.findUri.end,g=c.trim||d.findUri.trim,n=
2556c.parens||d.findUri.parens,k=/[a-z0-9-]=["']?$/i;for(e.lastIndex=0;;){var h=e.exec(a);if(!h)break;var m=h.index;if(c.ignoreHtml){var q=a.slice(Math.max(m-3,0),m);if(q&&k.test(q))continue}var l=m+a.slice(m).search(f);q=a.slice(m,l);for(l=-1;;){var p=n.exec(q);if(!p)break;l=Math.max(l,p.index+p[0].length)}q=-1<l?q.slice(0,l)+q.slice(l).replace(g,""):q.replace(g,"");q.length<=h[0].length||c.ignore&&c.ignore.test(q)||(l=m+q.length,h=b(q,m,l,a),void 0===h?e.lastIndex=l:(h=String(h),a=a.slice(0,m)+h+a.slice(l),
2557e.lastIndex=m+h.length))}e.lastIndex=0;return a};d.ensureValidHostname=function(a,b){var c=!!a,e=!1;b&&(e=w(d.hostProtocols,b));if(e&&!c)throw new TypeError("Hostname cannot be empty, if protocol is "+b);if(a&&a.match(d.invalid_hostname_characters)){if(!m)throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available');if(m.toASCII(a).match(d.invalid_hostname_characters))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-:_]');
2558}};d.ensureValidPort=function(a){if(a){var b=Number(a);if(!(/^[0-9]+$/.test(b)&&0<b&&65536>b))throw new TypeError('Port "'+a+'" is not a valid port');}};d.noConflict=function(a){if(a)return a={URI:this.noConflict()},h.URITemplate&&"function"===typeof h.URITemplate.noConflict&&(a.URITemplate=h.URITemplate.noConflict()),h.IPv6&&"function"===typeof h.IPv6.noConflict&&(a.IPv6=h.IPv6.noConflict()),h.SecondLevelDomains&&"function"===typeof h.SecondLevelDomains.noConflict&&(a.SecondLevelDomains=h.SecondLevelDomains.noConflict()),
2559a;h.URI===this&&(h.URI=G);return this};g.build=function(a){if(!0===a)this._deferred_build=!0;else if(void 0===a||this._deferred_build)this._string=d.build(this._parts),this._deferred_build=!1;return this};g.clone=function(){return new d(this)};g.valueOf=g.toString=function(){return this.build(!1)._string};g.protocol=x("protocol");g.username=x("username");g.password=x("password");g.hostname=x("hostname");g.port=x("port");g.query=E("query","?");g.fragment=E("fragment","#");g.search=function(a,b){var c=
2560this.query(a,b);return"string"===typeof c&&c.length?"?"+c:c};g.hash=function(a,b){var c=this.fragment(a,b);return"string"===typeof c&&c.length?"#"+c:c};g.pathname=function(a,b){if(void 0===a||!0===a){var c=this._parts.path||(this._parts.hostname?"/":"");return a?(this._parts.urn?d.decodeUrnPath:d.decodePath)(c):c}this._parts.path=this._parts.urn?a?d.recodeUrnPath(a):"":a?d.recodePath(a):"/";this.build(!b);return this};g.path=g.pathname;g.href=function(a,b){var c;if(void 0===a)return this.toString();
2561this._string="";this._parts=d._parts();var e=a instanceof d,f="object"===typeof a&&(a.hostname||a.path||a.pathname);a.nodeName&&(f=d.getDomAttribute(a),a=a[f]||"",f=!1);!e&&f&&void 0!==a.pathname&&(a=a.toString());if("string"===typeof a||a instanceof String)this._parts=d.parse(String(a),this._parts);else if(e||f){e=e?a._parts:a;for(c in e)"query"!==c&&l.call(this._parts,c)&&(this._parts[c]=e[c]);e.query&&this.query(e.query,!1)}else throw new TypeError("invalid input");this.build(!b);return this};
2562g.is=function(a){var b=!1,c=!1,e=!1,f=!1,g=!1,h=!1,k=!1,l=!this._parts.urn;this._parts.hostname&&(l=!1,c=d.ip4_expression.test(this._parts.hostname),e=d.ip6_expression.test(this._parts.hostname),b=c||e,g=(f=!b)&&t&&t.has(this._parts.hostname),h=f&&d.idn_expression.test(this._parts.hostname),k=f&&d.punycode_expression.test(this._parts.hostname));switch(a.toLowerCase()){case "relative":return l;case "absolute":return!l;case "domain":case "name":return f;case "sld":return g;case "ip":return b;case "ip4":case "ipv4":case "inet4":return c;
2563case "ip6":case "ipv6":case "inet6":return e;case "idn":return h;case "url":return!this._parts.urn;case "urn":return!!this._parts.urn;case "punycode":return k}return null};var H=g.protocol,I=g.port,J=g.hostname;g.protocol=function(a,b){if(a&&(a=a.replace(/:(\/\/)?$/,""),!a.match(d.protocol_expression)))throw new TypeError('Protocol "'+a+"\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");return H.call(this,a,b)};g.scheme=g.protocol;g.port=function(a,b){if(this._parts.urn)return void 0===
2564a?"":this;void 0!==a&&(0===a&&(a=null),a&&(a+="",":"===a.charAt(0)&&(a=a.substring(1)),d.ensureValidPort(a)));return I.call(this,a,b)};g.hostname=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0!==a){var c={preventInvalidHostname:this._parts.preventInvalidHostname};if("/"!==d.parseHost(a,c))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');a=c.hostname;this._parts.preventInvalidHostname&&d.ensureValidHostname(a,this._parts.protocol)}return J.call(this,
2565a,b)};g.origin=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){var c=this.protocol();return this.authority()?(c?c+"://":"")+this.authority():""}c=d(a);this.protocol(c.protocol()).authority(c.authority()).build(!b);return this};g.host=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildHost(this._parts):"";if("/"!==d.parseHost(a,this._parts))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');
2566this.build(!b);return this};g.authority=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a)return this._parts.hostname?d.buildAuthority(this._parts):"";if("/"!==d.parseAuthority(a,this._parts))throw new TypeError('Hostname "'+a+'" contains characters other than [A-Z0-9.-]');this.build(!b);return this};g.userinfo=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){var c=d.buildUserinfo(this._parts);return c?c.substring(0,c.length-1):c}"@"!==a[a.length-1]&&
2567(a+="@");d.parseUserinfo(a,this._parts);this.build(!b);return this};g.resource=function(a,b){if(void 0===a)return this.path()+this.search()+this.hash();var c=d.parse(a);this._parts.path=c.path;this._parts.query=c.query;this._parts.fragment=c.fragment;this.build(!b);return this};g.subdomain=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.length-this.domain().length-1;return this._parts.hostname.substring(0,
2568c)||""}c=this._parts.hostname.length-this.domain().length;c=this._parts.hostname.substring(0,c);c=new RegExp("^"+p(c));a&&"."!==a.charAt(a.length-1)&&(a+=".");if(-1!==a.indexOf(":"))throw new TypeError("Domains cannot contain colons");a&&d.ensureValidHostname(a,this._parts.protocol);this._parts.hostname=this._parts.hostname.replace(c,a);this.build(!b);return this};g.domain=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||
2569this.is("IP"))return"";var c=this._parts.hostname.match(/\./g);if(c&&2>c.length)return this._parts.hostname;c=this._parts.hostname.length-this.tld(b).length-1;c=this._parts.hostname.lastIndexOf(".",c-1)+1;return this._parts.hostname.substring(c)||""}if(!a)throw new TypeError("cannot set domain empty");if(-1!==a.indexOf(":"))throw new TypeError("Domains cannot contain colons");d.ensureValidHostname(a,this._parts.protocol);!this._parts.hostname||this.is("IP")?this._parts.hostname=a:(c=new RegExp(p(this.domain())+
2570"$"),this._parts.hostname=this._parts.hostname.replace(c,a));this.build(!b);return this};g.tld=function(a,b){if(this._parts.urn)return void 0===a?"":this;"boolean"===typeof a&&(b=a,a=void 0);if(void 0===a){if(!this._parts.hostname||this.is("IP"))return"";var c=this._parts.hostname.lastIndexOf(".");c=this._parts.hostname.substring(c+1);return!0!==b&&t&&t.list[c.toLowerCase()]?t.get(this._parts.hostname)||c:c}if(a)if(a.match(/[^a-zA-Z0-9-]/))if(t&&t.is(a))c=new RegExp(p(this.tld())+"$"),this._parts.hostname=
2571this._parts.hostname.replace(c,a);else throw new TypeError('TLD "'+a+'" contains characters other than [A-Z0-9]');else{if(!this._parts.hostname||this.is("IP"))throw new ReferenceError("cannot set TLD on non-domain host");c=new RegExp(p(this.tld())+"$");this._parts.hostname=this._parts.hostname.replace(c,a)}else throw new TypeError("cannot set TLD empty");this.build(!b);return this};g.directory=function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path&&
2572!this._parts.hostname)return"";if("/"===this._parts.path)return"/";var c=this._parts.path.length-this.filename().length-1;c=this._parts.path.substring(0,c)||(this._parts.hostname?"/":"");return a?d.decodePath(c):c}c=this._parts.path.length-this.filename().length;c=this._parts.path.substring(0,c);c=new RegExp("^"+p(c));this.is("relative")||(a||(a="/"),"/"!==a.charAt(0)&&(a="/"+a));a&&"/"!==a.charAt(a.length-1)&&(a+="/");a=d.recodePath(a);this._parts.path=this._parts.path.replace(c,a);this.build(!b);
2573return this};g.filename=function(a,b){if(this._parts.urn)return void 0===a?"":this;if("string"!==typeof a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this._parts.path.lastIndexOf("/");c=this._parts.path.substring(c+1);return a?d.decodePathSegment(c):c}c=!1;"/"===a.charAt(0)&&(a=a.substring(1));a.match(/\.?\//)&&(c=!0);var e=new RegExp(p(this.filename())+"$");a=d.recodePath(a);this._parts.path=this._parts.path.replace(e,a);c?this.normalizePath(b):this.build(!b);return this};g.suffix=
2574function(a,b){if(this._parts.urn)return void 0===a?"":this;if(void 0===a||!0===a){if(!this._parts.path||"/"===this._parts.path)return"";var c=this.filename(),e=c.lastIndexOf(".");if(-1===e)return"";c=c.substring(e+1);c=/^[a-z0-9%]+$/i.test(c)?c:"";return a?d.decodePathSegment(c):c}"."===a.charAt(0)&&(a=a.substring(1));if(c=this.suffix())e=a?new RegExp(p(c)+"$"):new RegExp(p("."+c)+"$");else{if(!a)return this;this._parts.path+="."+d.recodePath(a)}e&&(a=d.recodePath(a),this._parts.path=this._parts.path.replace(e,
2575a));this.build(!b);return this};g.segment=function(a,b,c){var d=this._parts.urn?":":"/",f=this.path(),g="/"===f.substring(0,1);f=f.split(d);void 0!==a&&"number"!==typeof a&&(c=b,b=a,a=void 0);if(void 0!==a&&"number"!==typeof a)throw Error('Bad segment "'+a+'", must be 0-based integer');g&&f.shift();0>a&&(a=Math.max(f.length+a,0));if(void 0===b)return void 0===a?f:f[a];if(null===a||void 0===f[a])if(k(b)){f=[];a=0;for(var h=b.length;a<h;a++)if(b[a].length||f.length&&f[f.length-1].length)f.length&&!f[f.length-
25761].length&&f.pop(),f.push(z(b[a]))}else{if(b||"string"===typeof b)b=z(b),""===f[f.length-1]?f[f.length-1]=b:f.push(b)}else b?f[a]=z(b):f.splice(a,1);g&&f.unshift("");return this.path(f.join(d),c)};g.segmentCoded=function(a,b,c){var e;"number"!==typeof a&&(c=b,b=a,a=void 0);if(void 0===b){a=this.segment(a,b,c);if(k(a)){var f=0;for(e=a.length;f<e;f++)a[f]=d.decode(a[f])}else a=void 0!==a?d.decode(a):void 0;return a}if(k(b))for(f=0,e=b.length;f<e;f++)b[f]=d.encode(b[f]);else b="string"===typeof b||b instanceof
2577String?d.encode(b):b;return this.segment(a,b,c)};var K=g.query;g.query=function(a,b){if(!0===a)return d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("function"===typeof a){var c=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace),e=a.call(this,c);this._parts.query=d.buildQuery(e||c,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);this.build(!b);return this}return void 0!==a&&"string"!==typeof a?(this._parts.query=d.buildQuery(a,this._parts.duplicateQueryParameters,
2578this._parts.escapeQuerySpace),this.build(!b),this):K.call(this,a,b)};g.setQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);if("string"===typeof a||a instanceof String)e[a]=void 0!==b?b:null;else if("object"===typeof a)for(var f in a)l.call(a,f)&&(e[f]=a[f]);else throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&
2579(c=b);this.build(!c);return this};g.addQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);d.addQuery(e,a,void 0===b?null:b);this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};g.removeQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);d.removeQuery(e,a,b);this._parts.query=d.buildQuery(e,this._parts.duplicateQueryParameters,
2580this._parts.escapeQuerySpace);"string"!==typeof a&&(c=b);this.build(!c);return this};g.hasQuery=function(a,b,c){var e=d.parseQuery(this._parts.query,this._parts.escapeQuerySpace);return d.hasQuery(e,a,b,c)};g.setSearch=g.setQuery;g.addSearch=g.addQuery;g.removeSearch=g.removeQuery;g.hasSearch=g.hasQuery;g.normalize=function(){return this._parts.urn?this.normalizeProtocol(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build():this.normalizeProtocol(!1).normalizeHostname(!1).normalizePort(!1).normalizePath(!1).normalizeQuery(!1).normalizeFragment(!1).build()};
2581g.normalizeProtocol=function(a){"string"===typeof this._parts.protocol&&(this._parts.protocol=this._parts.protocol.toLowerCase(),this.build(!a));return this};g.normalizeHostname=function(a){this._parts.hostname&&(this.is("IDN")&&m?this._parts.hostname=m.toASCII(this._parts.hostname):this.is("IPv6")&&v&&(this._parts.hostname=v.best(this._parts.hostname)),this._parts.hostname=this._parts.hostname.toLowerCase(),this.build(!a));return this};g.normalizePort=function(a){"string"===typeof this._parts.protocol&&
2582this._parts.port===d.defaultPorts[this._parts.protocol]&&(this._parts.port=null,this.build(!a));return this};g.normalizePath=function(a){var b=this._parts.path;if(!b)return this;if(this._parts.urn)return this._parts.path=d.recodeUrnPath(this._parts.path),this.build(!a),this;if("/"===this._parts.path)return this;b=d.recodePath(b);var c="";if("/"!==b.charAt(0)){var e=!0;b="/"+b}if("/.."===b.slice(-3)||"/."===b.slice(-2))b+="/";b=b.replace(/(\/(\.\/)+)|(\/\.$)/g,"/").replace(/\/{2,}/g,"/");e&&(c=b.substring(1).match(/^(\.\.\/)+/)||
2583"")&&(c=c[0]);for(;;){var f=b.search(/\/\.\.(\/|$)/);if(-1===f)break;else if(0===f){b=b.substring(3);continue}var g=b.substring(0,f).lastIndexOf("/");-1===g&&(g=f);b=b.substring(0,g)+b.substring(f+3)}e&&this.is("relative")&&(b=c+b.substring(1));this._parts.path=b;this.build(!a);return this};g.normalizePathname=g.normalizePath;g.normalizeQuery=function(a){"string"===typeof this._parts.query&&(this._parts.query.length?this.query(d.parseQuery(this._parts.query,this._parts.escapeQuerySpace)):this._parts.query=
2584null,this.build(!a));return this};g.normalizeFragment=function(a){this._parts.fragment||(this._parts.fragment=null,this.build(!a));return this};g.normalizeSearch=g.normalizeQuery;g.normalizeHash=g.normalizeFragment;g.iso8859=function(){var a=d.encode,b=d.decode;d.encode=escape;d.decode=decodeURIComponent;try{this.normalize()}finally{d.encode=a,d.decode=b}return this};g.unicode=function(){var a=d.encode,b=d.decode;d.encode=A;d.decode=unescape;try{this.normalize()}finally{d.encode=a,d.decode=b}return this};
2585g.readable=function(){var a=this.clone();a.username("").password("").normalize();var b="";a._parts.protocol&&(b+=a._parts.protocol+"://");a._parts.hostname&&(a.is("punycode")&&m?(b+=m.toUnicode(a._parts.hostname),a._parts.port&&(b+=":"+a._parts.port)):b+=a.host());a._parts.hostname&&a._parts.path&&"/"!==a._parts.path.charAt(0)&&(b+="/");b+=a.path(!0);if(a._parts.query){for(var c="",e=0,f=a._parts.query.split("&"),g=f.length;e<g;e++){var h=(f[e]||"").split("=");c+="&"+d.decodeQuery(h[0],this._parts.escapeQuerySpace).replace(/&/g,
2586"%26");void 0!==h[1]&&(c+="="+d.decodeQuery(h[1],this._parts.escapeQuerySpace).replace(/&/g,"%26"))}b+="?"+c.substring(1)}return b+=d.decodeQuery(a.hash(),!0)};g.absoluteTo=function(a){var b=this.clone(),c=["protocol","username","password","hostname","port"],e,f;if(this._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a instanceof d||(a=new d(a));if(b._parts.protocol)return b;b._parts.protocol=a._parts.protocol;if(this._parts.hostname)return b;for(e=0;f=c[e];e++)b._parts[f]=
2587a._parts[f];b._parts.path?(".."===b._parts.path.substring(-2)&&(b._parts.path+="/"),"/"!==b.path().charAt(0)&&(c=(c=a.directory())?c:0===a.path().indexOf("/")?"/":"",b._parts.path=(c?c+"/":"")+b._parts.path,b.normalizePath())):(b._parts.path=a._parts.path,b._parts.query||(b._parts.query=a._parts.query
2587));b.build();return b};g.relativeTo=function(a){var b=this.clone().normalize();if(b._parts.urn)throw Error("URNs do not have any generally defined hierarchical components");a=(new d(a)).normalize();var c=
2588b._parts;var e=a._parts;var f=b.path();a=a.path();if("/"!==f.charAt(0))throw Error("URI is already relative");if("/"!==a.charAt(0))throw Error("Cannot calculate a URI relative to another relative URI");c.protocol===e.protocol&&(c.protocol=null);if(c.username===e.username&&c.password===e.password&&null===c.protocol&&null===c.username&&null===c.password&&c.hostname===e.hostname&&c.port===e.port)c.hostname=null,c.port=null;else return b.build();if(f===a)return c.path="",b.build();f=d.commonPath(f,a);
2589if(!f)return b.build();e=e.path.substring(f.length).replace(/[^\/]*$/,"").replace(/.*?\//g,"../");c.path=e+c.path.substring(f.length)||"./";return b.build()};g.equals=function(a){var b=this.clone(),c=new d(a);a={};var e;b.normalize();c.normalize();if(b.toString()===c.toString())return!0;var f=b.query();var g=c.query();b.query("");c.query("");if(b.toString()!==c.toString()||f.length!==g.length)return!1;b=d.parseQuery(f,this._parts.escapeQuerySpace);g=d.parseQuery(g,this._parts.escapeQuerySpace);for(e in b)if(l.call(b,
2590e)){if(!k(b[e])){if(b[e]!==g[e])return!1}else if(!D(b[e],g[e]))return!1;a[e]=!0}for(e in g)if(l.call(g,e)&&!a[e])return!1;return!0};g.preventInvalidHostname=function(a){this._parts.preventInvalidHostname=!!a;return this};g.duplicateQueryParameters=function(a){this._parts.duplicateQueryParameters=!!a;return this};g.escapeQuerySpace=function(a){this._parts.escapeQuerySpace=!!a;return this};return d});
2591;$(document).ready(function () {
2592    // ---------------------------------------------------------------------------------------
2593    // Search - naseptavac
2594    // ---------------------------------------------------------------------------------------
2595    var $searchTimer;
2596    $('#search-box-top input[name="q"]').keyup(function () {
2597
2598        var fulltext = $(this).val();
2599        if (fulltext.length > 2) {
2600            if ($searchTimer) { clearTimeout($searchTimer); }
2601            $searchTimer = setTimeout(function () {
2602                var url = $('input[name="search-suggestion-url"]:hidden').val();
2603                $.ajax({
2604                    type: 'GET',
2605                    async: true,
2606                    url: url,
2607                    data: { q: fulltext },
2608                    success: function (data) {
2609                        $('#search-suggestion').html(data);
2610                        $('.search-suggestions__submit .search-suggestions__query').text('"' + fulltext.trim() + '"');
2611                        $('#search-suggestion').show();
2612                    },
2613                    error: function (e) {
2614                        console.log("Call search-suggestion ajax error: " + e);
2615                    }
2616                });
2617            }, 100);
2618        }
2619    });
2620
2621    // Skryt naseptavac klikne-li se mimo nej
2622    $(document).mouseup(function (e) {
2623        var container = $('#search-suggestion');
2624        if (!container.is(e.target) && container.has(e.target).length === 0) {
2625            container.hide();
2626        }
2627    });
2628
2629    // Zamezeni vyhledani texu "Hledany vyraz"
2630    $('#search-box input[type="submit"], #search-suggestions__submit').click(function () {
2631        var form = $('#search-box');
2632        var fulltext = $(form).find('input[name="q"]');
2633        if (fulltext.val() == fulltext.attr('title')) {
2634            return false;
2635        }
2636        return true;
2637    });
2638
2639    // Remove request dangerous chars
2640    $("input.fulltext").on('keyup paste', function (e) {
2641        if (/[<>]/g.test(this.value)) {
2642            this.value = this.value.replace(/[<>]/g, '');
2643        }
2644    });
2645
2646});;

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.