/* Minification failed. Returning unminified contents.
(418,48-49): run-time error JS1195: Expected expression: )
(418,51-52): run-time error JS1195: Expected expression: >
(424,1-2): run-time error JS1002: Syntax error: }
(432,1-2): run-time error JS1002: Syntax error: }
(448,16-17): run-time error JS1003: Expected ':': (
(448,23-24): run-time error JS1100: Expected ',': {
(454,9-10): run-time error JS1002: Syntax error: }
(458,21-22): run-time error JS1197: Too many errors. The file might not be a JavaScript file: ,
 */
/**
 * Initializes component specific javascript after the whole page was loaded and after a partial update was performed.
 * (for partial update only the updated part is analyzed)
 *
 * Usage: add data-component-class attribute to the component that will use the javascript, with full namespace and class name as its attribute value.
 *
 * Two parameters will be passed to the contstructor:
 * - jquery element
 * - value of data-component-parm attribute
 *         if this value is JSON, it will be deserialized.
 */

/**
 *  Initialize javascript of all components on the current page.
 */
function InitComponentsFromPage() {
    if (!window.jQuery) {
        if (window.Dlw.DevMode) {
            window.console.error("jQuery not available, components could not be loaded");
        }
        return;
    }

    if (window.Dlw.DevMode) {
        console.debug("data-component-classes initialization");
        console.time("data-component-classes initialization");
    }

    var count = 0;
    jQuery("[data-component-class]").each(function () {
        count++;
        var el = jQuery(this);
        _initializeComponent(el);
    });

    if (window.Dlw.DevMode) {
        console.info("data-component-classes initialized: " + count + " components on page");
        console.timeEnd("data-component-classes initialization");
    }
}

/**
 * Initializes javascript of components in a given array of jQuery elements.
 * Each element can be data-jscomponent element and / or can contain data-jscomponent elements
 */
function InitComponentsFromPartialUpdate(jAddedElement) {
    if (!jAddedElement || jAddedElement.length == 0) {
        if (window.Dlw.DevMode) {
            console.debug("data-component-class can't initialize from an empty or non-existing jQuery element, ignoring");
        };
        return;
    }

    if (window.Dlw.DevMode) {
        console.debug("data-component-class partially updated element initializations");
        console.time("data-component-class partially updated element initializations");
    }

    var count = 0;
    // search for data-component-classes in the element and the element itself.
    jAddedElement.find("[data-component-class]").addBack("[data-component-class]").each(function () {
        count++;
        _initializeComponent(jQuery(this));
    });

    if (window.Dlw.DevMode) {
        console.info("data-component-class initialized " + count + " component(s) from partially updated element");
        console.timeEnd("data-component-class partially updated element initializations");
    }
}

function _initializeComponent(el) {
    var componentClass = el.attr("data-component-class");

    var nsparts = componentClass.split(".");
    var nsparent = window[nsparts[0]];
    for (var i = 1; i < nsparts.length; i++) {
        if (!nsparent) {
            break;
        }
        nsparent = nsparent[nsparts[i]];
    }

    var lComponentClass = nsparent;
    if (!lComponentClass) {
        if (window.Dlw.DevMode) {
            console.error("Couldn't find " + componentClass);
        }
        return;
    }

    var parmText = el.attr("data-component-parm");
    var parm = null;
    if (parmText) {
        try {
            parm = JSON.parse(parmText);
        } catch (e) {
            parm = parmText;
        }
    }

    var instance = new lComponentClass(el, parm);
    el[0].component = instance; // Store instance of component class on element to be used by javascript.
    if (window.Dlw.DevMode) {
        console.debug("data-component-class " + componentClass + " initialized");
    }
}

function getCurrentComponent(selector) {
    var el = $(selector);
    var parentWithComponent = el.parents("[data-component-class]");
    return parentWithComponent[0].component;
}

// When a form is replaced by a newer version through a partial update,
// we need to reset validation, as old elements are still cached.
// Validation for adding new forms is handled already (see document.ready > document.change)
function ResetExistingFormValidation(e) {
    // will match 'replace' (default) and 'replace-with'
    if (e.mode.toUpperCase().indexOf("REPLACE") !== 0)
        return;
    if (!e.jTarget || !e.jTarget.length)
        return;
    // did we replace a FORM?
    var $form = e.jTarget.closest("FORM");
    if (!$form.length)
        return;
    // Remove old elements that are still cached
    $form.removeData("validator");
    $form.removeData("unobtrusiveValidation");
    // Now parse again to get validation on the new elements
    jQuery.validator.unobtrusive.parse($form);
}

// Initialize javascript for components
jQuery(document).ready(function () {
    InitComponentsFromPage();
});

// Bind event handler for partial updates:
// When components are dynamically added, their javascript should be initialized as well.
jQuery(document).on("targetUpdated", function (e) {
    ResetExistingFormValidation(e);
    InitComponentsFromPartialUpdate(e.jAddedElement);
});

// When ajax update fails because of a error returned by the server, 
// we want to show that error to the frontend (when in debug mode)
jQuery(document).on("targetUpdateFailed", function (e) {
    if (jQuery("meta[itemprop=developmentmode]").length < 1) {
        return;
    }

    // based on http://www.w3schools.com/jsref/met_win_open.asp
    // Open a new window
    var targetUpdateFailedWindow = window.open("", "targetUpdateFailedWindow");
    // Text in the new window
    targetUpdateFailedWindow.document.write(e.responseText);
});


// Fix for when there are partialviews in partial views
// then the ajax.success option is not enough.
jQuery(document).ready(function () {
    jQuery(document).change(function () {
        jQuery.validator.unobtrusive.parse(jQuery(document));
    });
});

// Auto-submit dropdowns when they have data-ajax-submit="true"
jQuery(document).on("change", "form[data-ajax=true] select[data-ajax-submit=true]", function (evt) {
    var form = jQuery(evt.target).parents("form")[0];
    jQuery(form).trigger("submit");
});;
var devmode = false;

// Check if meta tag is defined by ASP bundling.
var meta = document.querySelector('head meta[itemprop="developmentmode"]');
if (meta && meta.content === 'true') {
    devmode = true;
}

Window.Dlw = {
    DevMode: devmode
};
window.Dlw = Window.Dlw;

if (Window.Dlw.DevMode) {
    console.debug("Javascript development mode is active.");
}
;
// include api
if ($('script[src="https://www.youtube.com/iframe_api"]').length === 0) {
    var tag = document.createElement('script');
    tag.src = "https://www.youtube.com/iframe_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}

function onYouTubeIframeAPIReady() {
    $(".youtube-video-container").each(function () {
        var youtubeId = $(this).attr("data-youtubeid");
        var rel = $(this).attr("data-youtube-rel");
        var iframeId = $(this).find('.player').attr('id');
        if (youtubeId !== '') {
            new YT.Player(iframeId, {
                videoId: youtubeId,
                events: {
                    'onReady': onPlayerReady
                },
                playerVars: { rel: rel }
            });
        }
    });

    // Dispatch custom event that we can catch in typescript
    var event = document.createEvent('CustomEvent');
    event.initCustomEvent('YouTubeIframeAPIReady', false, false, null);
    document.dispatchEvent(event);
}

// multi youtube-video-container elements
function onPlayerReady(event) {
    $('.youtube-video-container').each(function () {
        if ($(this).closest('.media-carousel-item').hasClass('carousel-active')) {
            $(this).find('.video-control-play').css('pointer-events', 'auto');
            $(this).find('.media-carousel-video-control-play').css('pointer-events', 'auto');
        }
        $(this).find('.video-control-play.fluid-only').css('pointer-events', 'auto');
        //auto play
        if (!$(this).closest('.media-carousel-wrapper').find('.btn-carousel-prev').is(':visible')) {
            if (($(this).closest('.media-carousel-item').attr("data-video-auto-play") === "true") && ($(this).closest('.media-carousel-item').hasClass('carousel-active'))) {
                if (event.target.a.id === $(this).closest('.youtube-video-container').find('.player').attr('id')) {
                    $(this).find('.img-youtube').hide();
                    $(this).find('img').hide();
                    $(this).find('.media-carousel-video-control-play').hide();
                    event.target.playVideo();
                }
            }
        }
        //play onclick
        $(this).find('.video-control-play').on('click', function () {
            $(this).closest('.youtube-video-container').find('.img-youtube').hide();
            $(this).closest('.media-carousel-item.carousel-active').find('.media-description').hide();

            if ($(this).data("target-video") === $(this).closest('.youtube-video-container').find('.player').attr('id')) {
                event.target.playVideo();
            }
        });

        $(this).find('.media-carousel-video-control-play').on('click', function () {
            $(this).hide();
            $(this).closest('.youtube-video-container').find('img').hide();
            $(this).closest('.media-carousel-item.carousel-active').find('.media-description').hide();
            if (event.target.a.id === $(this).closest('.youtube-video-container').find('.player').attr('id')) {
                event.target.playVideo();
            }
        });
        $(this).closest('.media-carousel-wrapper').find('.carousel-dot').on('click', function () {
            event.target.pauseVideo();
            $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active .youtube-video-container').find('.video-control-play').css('pointer-events', 'auto');
            $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active .youtube-video-container').find('.media-carousel-video-control-play').css('pointer-events', 'auto');
            //auto play
            if (($(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active').attr("data-video-auto-play") === "true")) {
                if (event.target.a.id === ($(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active .youtube-video-container').find('.player').attr('id'))) {
                    $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active .youtube-video-container').find('.img-youtube').hide();
                    $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active .youtube-video-container').find('img').hide();
                    $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active .youtube-video-container').find('.media-carousel-video-control-play').hide();

                    event.target.playVideo();
                }
            }
        });
        //mobile
        if ($(this).closest('.media-carousel-wrapper').find('.btn-carousel-prev').is(':visible')) {
            $(this).find('.media-carousel-video-control-play').on('click', function () {
                $(this).closest('.youtube-video-container').find('.player').css('position', 'relative');
            });

            $(this).closest('.media-carousel-wrapper').find('.btn-carousel-prev').on('click', function () {
                event.target.pauseVideo();
                $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active').find('.player').css('position', 'absolute');
                $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active').find('.media-carousel-video-control-play').show();
                $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active').find('.media-carousel-video-control-play').css('pointer-events', 'auto');
            });
            $(this).closest('.media-carousel-wrapper').find('.btn-carousel-next').on('click', function () {
                event.target.pauseVideo();
                $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active').find('.player').css('position', 'absolute');
                $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active').find('.media-carousel-video-control-play').show();
                $(this).closest('.media-carousel-wrapper').find('.media-carousel-item.carousel-active').find('.media-carousel-video-control-play').css('pointer-events', 'auto');

            });
        }
    });
}

// for Interactive hotspot
window.onYouTubePlayerAPIReady = function () {
    $('.interactive-youtube-player').each(function () {
        var idIframe = $(this).attr('id');
        var youtubeId = $(this).attr("data-youtubeid");
        if (youtubeId !== '') {
            new YT.Player(idIframe, {
                videoId: youtubeId,
                autoplay: 1,
                loop: 1,
                events: {
                    'onReady': onInteractivePlayerReady,
                    'onStateChange': onPlayerStateChange
                }
            });
        }
    });
};

function onPlayerStateChange(event) {
    if (event.data === YT.PlayerState.ENDED) {
        event.target.playVideo();
        event.target.mute();
    }
}

function onInteractivePlayerReady(event) {
    event.target.playVideo();
    event.target.mute();
};
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var AcademyVideo = /** @class */ (function () {
            function AcademyVideo(jqueryElement, params) {
                var _this = this;
                this.jqueryElement = jqueryElement;
                this.params = params;
                jqueryElement.on("click", "[data-js-video-play-target]", function (e) {
                    var $videoButton = $(e.currentTarget);
                    var videoId = $videoButton.find("[data-js-video-id]").attr("data-js-video-id");
                    playVideo(videoId);
                });
                jqueryElement.on("click", "[data-js='btn-close-video']", function (e) {
                    stopVideo();
                });
                document.addEventListener('YouTubeIframeAPIReady', function (e) {
                    _this.player = new YT.Player(_this.params.playerId, {
                        videoId: params.initialVideoId,
                        events: {
                            'onReady': onPlayerReady,
                            'onStateChange': onPlayerStateChange
                        }
                    });
                    function onPlayerReady(event) {
                    }
                    function onPlayerStateChange(event) {
                        if (event.data === 0) {
                            var finishedVideoId = event.target.previousVideo().getVideoUrl().split('&v=')[1];
                            var finishedVideoCarouselElement = jqueryElement.find("[data-js-video-id='" + finishedVideoId + "']");
                            var nextVideoId = finishedVideoCarouselElement.parents("[data-js='carousel-item']").next()
                                .find("[data-js-video-id]").attr("data-js-video-id");
                            var hasNextVideo = nextVideoId != null;
                            if (hasNextVideo) {
                                playVideo(nextVideoId);
                            }
                        }
                    }
                });
                var playVideo = function (videoId) {
                    // Update data above video player
                    var videoName = jqueryElement.find("[data-js-video-id='" + videoId + "']").attr("data-js-video-name");
                    var $videoNamePopUp = jqueryElement.find("[data-popup-id='" + params.popUpId + "']").find("[data-js='video-name']");
                    $videoNamePopUp.html(videoName);
                    // Set and play video in player
                    _this.player.cueVideoById(videoId);
                    _this.player.nextVideo();
                    _this.player.playVideo();
                };
                var stopVideo = function () {
                    _this.player.stopVideo();
                };
            }
            return AcademyVideo;
        }());
        Web.AcademyVideo = AcademyVideo;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=AcademyVideo.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var Accordion = /** @class */ (function () {
            function Accordion(jqueryElement) {
                var self = this;
                $('.accordion-container .accordion-item .accordion-item-title', jqueryElement).on('click', function (e) {
                    var accordionItem = $(e.target).closest(".accordion-item");
                    if (accordionItem.hasClass('accordion-active')) {
                        accordionItem.removeClass('accordion-active');
                    }
                    else {
                        var activeItems = accordionItem.closest(".accordion-container").find(".accordion-active");
                        activeItems.removeClass('accordion-active');
                        accordionItem.addClass('accordion-active');
                        self.triggerDataLayerPush(accordionItem);
                    }
                });
            }
            Accordion.prototype.triggerDataLayerPush = function (jqueryElement) {
                var value = $(jqueryElement).children("[data-value]").attr("data-value");
                dataLayer.push({ 'event': 'cropFAQ', 'value': value });
            };
            return Accordion;
        }());
        Web.Accordion = Accordion;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=Accordion.js.map;
// Switching tabs
$("[data-js='tab-all-comments']").on("click", () => {
    $("#tab-all-comments").show();
    $("#tab-pending-approval").hide();

    $("#tab-heading-pending-approval").toggleClass("epi-tabView-navigation-item epi-tabView-navigation-item-selected");
    $("#tab-heading-all-comments").toggleClass("epi-tabView-navigation-item epi-tabView-navigation-item-selected");
});

$("[data-js='tab-pending-approval']").on("click", () => {
    $("#tab-pending-approval").show();
    $("#tab-all-comments").hide();

    $("#tab-heading-pending-approval").toggleClass("epi-tabView-navigation-item epi-tabView-navigation-item-selected");
    $("#tab-heading-all-comments").toggleClass("epi-tabView-navigation-item epi-tabView-navigation-item-selected");
});

// Buttons
$("body").on("click", "[data-js='btn-accept']", (e) => {
    var commentId = $(event.target).data("comment");
    var pageId = $("[data-js-page-id]").data("js-page-id");

    $.ajax({
        type: "POST",
        url: "/Comments/ApproveComment",
        data:
        {
            "commentId": commentId,
            "blogOverviewPageId": pageId
        },
        dataType: "html",
        success(data) {
            if (data !== null) {
                var succeeded = data === "true";

                handleAjaxStateUpdateResult(commentId, succeeded, true);
            }
        }
    });
});

$("body").on("click", "[data-js='btn-reject']", (e) => {
    var commentId = $(event.target).data("comment");
    var pageId = $("[data-js-page-id]").data("js-page-id");

    $.ajax({
        type: "POST",
        url: "/Comments/RejectComment",
        data:
        {
            "commentId": commentId,
            "blogOverviewPageId": pageId
        },
        dataType: "html",
        success(data) {
            if (data !== null) {
                var succeeded = data === "true";

                handleAjaxStateUpdateResult(commentId, succeeded, false);
            }
        }
    });
});

function handleAjaxStateUpdateResult(commentId, succeeded, approved) {
    if (succeeded) {
        // Hide error
        $("#status-message").hide();

        // If in pending approval tab, hide comment
        var commentSelector = ".js-tab-pending-approval [data-comment='" + commentId + "']";
        $(commentSelector).closest(".comment-box").hide();

        // If in all comments tab, update state
        var commentAllSelector = ".js-tab-all [data-comment='" + commentId + "']";
        console.log(commentAllSelector);
        var commentHeading = $(commentAllSelector).parents(".media-body").children(".media-heading");
        console.log(commentHeading);

        if ($(commentHeading).hasClass("Published") || $(commentHeading).hasClass("Rejected")) {
            $(commentHeading).toggleClass("Published Rejected");
        } else {
            if (approved){
                $(commentHeading).addClass("Published");
            } else {
                $(commentHeading).addClass("Rejected");
            }
        }

        //TODO update state when comment in other tab is updated (eg. Pending comment is accepted - update state in all comments)
    } else {
        // Show error
        $("#status-message").show();
    }
}

// Pagination
$("body").on("click", "[data-js='btn-page']", (e) => {
    var pageId = $("[data-js-page-id]").data("js-page-id");
    var pageLanguage = $("[data-js-page-language]").data("js-page-language");

    var button = $(e.target).closest("a");
    var pending = button.parents("#tab-pending-approval").length > 0;
    var paginationPage = parseInt(button.data("js-page"));

    $.ajax({
        type: "POST",
        url: "/Comments/GetComments",
        data:
        {
            "blogOverviewPageId": pageId,
            "language": pageLanguage,
            "pending": pending,
            "page": paginationPage
        },
        dataType: "html",
        success(data) {
            if (pending) {
                $("[data-js='container-comments-approval']").html(data);
                // All pages not bold in same tab
                $(".js-tab-pending-approval .epi-cmsButton-tools").removeClass("btn-active");
                $();
            } else {
                $("[data-js='container-comments-all']").html(data);
                // All pages not bold in same tab
                $(".js-tab-all .epi-cmsButton-tools").removeClass("btn-active");
                $();
            }

            // Set new active page bold       
            $(button).addClass("btn-active");
        }
    });
});;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var AuthorOverview = /** @class */ (function () {
            function AuthorOverview(jqueryElement) {
                var authors = $(jqueryElement).find("[data-js-author]");
                // Make all authors after 5th one visible
                if (authors.length > 5) {
                    authors.slice(5, authors.length).hide();
                }
                $(jqueryElement).on("click", ".js-arrow-back:not(.disabled-arrow)", function () {
                    var lastDisplayedAuthor = authors.filter(":visible").last();
                    lastDisplayedAuthor.hide();
                    var firstHiddenAuthor = authors.filter(":hidden").toArray()
                        .filter(function (element) { return parseInt($(element).data("js-author-index")) <
                        parseInt(lastDisplayedAuthor.data("js-author-index")); }).shift();
                    $(firstHiddenAuthor).show();
                    checkArrows(jqueryElement);
                });
                $(jqueryElement).on("click", ".js-arrow-next:not(.disabled-arrow)", function () {
                    var firstDisplayedAuthor = authors.filter(":visible").first();
                    firstDisplayedAuthor.hide();
                    var firstHiddenAuthor = authors.filter(":hidden").toArray()
                        .filter(function (element) { return parseInt($(element).data("js-author-index")) >
                        parseInt(firstDisplayedAuthor.data("js-author-index")); }).shift();
                    $(firstHiddenAuthor).show();
                    checkArrows(jqueryElement);
                });
                var checkArrows = function (jqueryElement) {
                    if (authors.last().is(":visible")) {
                        $(jqueryElement).find(".js-arrow-next").addClass("disabled-arrow");
                    }
                    else {
                        $(jqueryElement).find(".js-arrow-next").removeClass("disabled-arrow");
                    }
                    if (authors.first().is(":visible")) {
                        $(jqueryElement).find(".js-arrow-back").addClass("disabled-arrow");
                    }
                    else {
                        $(jqueryElement).find(".js-arrow-back").removeClass("disabled-arrow");
                    }
                };
            }
            return AuthorOverview;
        }());
        Web.AuthorOverview = AuthorOverview;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=AuthorOverview.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var BlogDetail = /** @class */ (function () {
            function BlogDetail(jqueryElement, params) {
                var _this = this;
                this.jqueryElement = jqueryElement;
                this.pageId = params.pageId;
                this.getCommentsUrl = params.getCommentsUrl;
                $(document).ready(function () {
                    _this.bindInitialEvents();
                    // Get first page of comments.
                    _this.getComments(1);
                });
            }
            BlogDetail.prototype.getComments = function (pageNumber) {
                var _this = this;
                $.ajax({
                    type: 'POST',
                    url: this.getCommentsUrl,
                    context: this,
                    data: {
                        "pageId": this.pageId,
                        "language": $("html").attr("lang"),
                        "pageNumber": pageNumber
                    }
                }).done(function (data) {
                    if (data != null) {
                        _this.jqueryElement.find("[data-container=load-more-comments]").replaceWith(data);
                    }
                    _this.bindLoadMoreCommentsButton();
                    _this.bindEvents();
                });
            };
            // Called when a new comment has been added by the visitor
            BlogDetail.prototype.onSuccessAddComment = function (data) {
                if ($("[data-js='btn-update-comment-submit-div']").hasClass("u-hide")) {
                    var repliedCommentId = this.jqueryElement.find("[data-js='new-comment-parent-id']").val();
                    var isReply = repliedCommentId != "";
                    // Append comment in comments-tree
                    if (isReply) {
                        var repliedComment = this.jqueryElement.find("[data-js-id='" + repliedCommentId + "']");
                        repliedComment.parent().append(data);
                    }
                    else {
                        this.jqueryElement.find("#blog-detail-comments").prepend(data);
                    }
                    // Update total comments
                    var totalCommentsContainer = this.jqueryElement.find("[data-content=total-comment-count]");
                    if (totalCommentsContainer) {
                        var totalCommentsText = totalCommentsContainer.text();
                        if (totalCommentsText) {
                            var totalComments = Number(totalCommentsText);
                            totalCommentsContainer.text(totalComments + 1);
                        }
                    }
                }
                else {
                    setTimeout(function () { location.reload(); }, 1000);
                }
                // Show thank you message & hide form
                var $thankYouMessage, $commentForm;
                if (isReply) {
                    var $repliedCommentContainer = this.jqueryElement.find("[data-js-id='" + repliedCommentId + "']");
                    $thankYouMessage = $($repliedCommentContainer.find("div[data-js='comment-thank-you-message']"));
                    $commentForm = $(this.jqueryElement.find("div[data-js='reply-form']"));
                }
                else {
                    var $newCommentContainer = this.jqueryElement.find("[data-js='form-new-comment']");
                    $thankYouMessage = $($newCommentContainer.find("div[data-js='comment-thank-you-message']"));
                    $commentForm = $(this.jqueryElement.find("div[data-js='comment-form']"));
                }
                $thankYouMessage.show();
                $commentForm.hide();
                // Clear the comment form
                $commentForm.find("[data-js-reset]").val("");
                this.bindEvents();
            };
            BlogDetail.prototype.bindLoadMoreCommentsButton = function () {
                var _this = this;
                // Clicked load more button
                this.jqueryElement.find("[data-function='load-more-comments']").click(function (eventObj) {
                    var pageNumber = $(eventObj.currentTarget).data("page-number");
                    _this.getComments(pageNumber);
                });
            };
            BlogDetail.prototype.bindInitialEvents = function () {
                this.jqueryElement.find("[data-js='comments-toggle']").click(function () {
                    $(".js-blog-comments").toggleClass("is-open");
                });
            };
            BlogDetail.prototype.bindEvents = function () {
                var _this = this;
                this.jqueryElement.find("[data-js='edit-comment']").click(function (e) {
                    var blogItem = $(e.target).parents("[data-js='comment-item']");
                    var id = blogItem.attr("data-js-id");
                    var name = blogItem.find("[data-js='name']").text();
                    var message = blogItem.find("[data-js='message']").text();
                    //Make sure input form is visible
                    _this.jqueryElement.find("div[data-js='comment-thank-you-message']").hide();
                    _this.jqueryElement.find("div[data-js='comment-form']").show();
                    //trim spaces
                    name = $.trim(name);
                    message = $.trim(message);
                    //prefill comment form
                    $("#AddCommentViewModel_Name").val(name);
                    $("#AddCommentViewModel_Message").val(message);
                    $("#AddCommentViewModel_CommentId").val(id);
                    //switch submit button
                    $("[data-js='btn-new-comment-submit-div']").addClass("u-hide");
                    $("[data-js='btn-update-comment-submit-div']").removeClass("u-hide");
                    $('html, body').animate({
                        scrollTop: $("[data-js='comments-form']").offset().top - 150
                    }, 500);
                });
                this.jqueryElement.find("[data-js='delete-comment']").click(function (e) {
                    var blogItem = $(e.target).parents("[data-js='comment-item']");
                    var id = blogItem.attr("data-js-id");
                    $.ajax({
                        type: 'POST',
                        url: '/BlogDetail/DeleteComment',
                        data: {
                            "commentId": id
                        },
                        dataType: 'json',
                        success: function (data) {
                            if (data === true) {
                                location.reload();
                            }
                        }
                    });
                });
                this.jqueryElement.on("click", "[data-js='reply-comment']", function (e) {
                    var $comment = $(e.currentTarget);
                    var commentId = $comment.closest("[data-js-id]").attr("data-js-id");
                    var $replyForm = _this.jqueryElement.find("[data-js='new-reply-form-container']");
                    $replyForm.find("[data-js='new-comment-parent-id']").val(commentId);
                    var $replyFormContainer = $comment.closest("[data-js='comment-info']").find("[data-js='reply-form-container']").first();
                    $replyFormContainer.append($replyForm);
                    // Make sure form is visible & thank you message is hidden
                    var $thankYouMessage = $replyFormContainer.find("div[data-js='comment-thank-you-message']");
                    $thankYouMessage.hide();
                    $replyFormContainer.find("div[data-js='reply-form']").show();
                    $replyForm.show();
                    $replyFormContainer.show();
                });
                var $subscribe = jQuery("[data-js='blog-subscribe']");
                var $subscribeTrigger = $subscribe.find("[data-js='blog-subcribe-trigger']");
                var $subscribeClose = $subscribe.find("[data-js='blog-subscribe-close']");
                $subscribeTrigger.on('click', function () {
                    $subscribe.toggleClass("is-active");
                });
                $subscribeClose.on('click', function () {
                    $subscribe.removeClass("is-active");
                });
            };
            return BlogDetail;
        }());
        Web.BlogDetail = BlogDetail;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=BlogDetail.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var BlogOverview = /** @class */ (function () {
            function BlogOverview(jqueryElement, params) {
                this.jqueryElement = jqueryElement;
                this.loadMoreUrl = params.loadMoreUrl;
                this.categoryId = params.categoryId;
                InitNewsletterForm();
                this.bindEvents();
                function InitNewsletterForm() {
                    $('[data-js="newsletter-form"]').find(".Form__Element:not(.Form__Element--stacked)").addClass("Form__Element--stacked");
                }
            }
            BlogOverview.prototype.bindEvents = function () {
                var _this = this;
                var self = this;
                var inViewBlogs = "[data-in-view=blogs]";
                inView(inViewBlogs)
                    .on("enter", function () {
                    var container = self.jqueryElement.find(inViewBlogs);
                    var pageNumber = container.data("page-number");
                    self.GetMoreArticles(container, pageNumber, self.categoryId);
                });
                // Clicked load more button
                var container = this.jqueryElement.find("[data-get-more=blogs]");
                container.click(function (eventObject) {
                    var pageNumber = $(eventObject.currentTarget).data("page-number");
                    _this.GetMoreArticles(container, pageNumber, _this.categoryId);
                });
            };
            BlogOverview.prototype.GetMoreArticles = function (container, pageNumber, category) {
                $.ajax({
                    type: 'POST',
                    url: this.loadMoreUrl,
                    data: {
                        "pageNumber": pageNumber,
                        "categoryId": category
                    },
                    context: this,
                    dataType: 'html',
                    success: function (data) {
                        if (data != null) {
                            container.replaceWith(data);
                            this.bindEvents();
                        }
                    },
                    beforeSend: function () {
                        $("#progress").show();
                    },
                    complete: function () {
                        $("#progress").hide();
                    },
                });
            };
            return BlogOverview;
        }());
        Web.BlogOverview = BlogOverview;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=BlogOverview.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var Cookie = /** @class */ (function () {
            function Cookie(jqueryElement, parameters) {
                this.params = parameters;
                $(jqueryElement).find(".js-submitConsents").click(function () {
                    //TODO: this code doesn't run due to scoping issue
                    var uncheckedCheckboxes = jqueryElement.find(".FormChoice__Input--Checkbox:not(:checked)");
                    var notAllowedCategories = new Array();
                    for (var i = 0; i < uncheckedCheckboxes.length; i++) {
                        notAllowedCategories.push($(uncheckedCheckboxes[i]).siblings("[value^='consent_']").attr("value"));
                    }
                    var gtmNotAllowedCategoriesString = notAllowedCategories.join("|");
                    dataLayer.push({ 'event': 'gdpr-delete-cookies', 'deleteCookieCategories': gtmNotAllowedCategoriesString });
                    $('body').removeClass('has-cookie');
                });
            }
            return Cookie;
        }());
        Web.Cookie = Cookie;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=Cookie.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var CookieMessage = /** @class */ (function () {
            function CookieMessage(jqueryElement, parameters) {
                this.params = parameters;
                var self = this;
                this.cookiePublisher = new Web.CookiePublisher();
                $.post(self.params.areConsentsConfiguredUrl, function (data) {
                    if (data == "True") {
                        $("body").removeClass("has-cookie");
                    }
                    else {
                        $("body").addClass("has-cookie");
                    }
                });
                $(jqueryElement).find(".js-accept-cookie").click(function () {
                    self.cookiePublisher.onCookieAccepted();
                    $.post(self.params.acceptAllUrl, function () {
                        $("body").removeClass("has-cookie");
                    });
                    //adjust toast-message position
                    $(".toast-message").removeClass("avoid-cookie");
                });
            }
            return CookieMessage;
        }());
        Web.CookieMessage = CookieMessage;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=CookieMessage.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var CountryLanguageSelections = /** @class */ (function () {
            function CountryLanguageSelections(jqueryElement, parameters) {
                var _this = this;
                this.hasFetchedUserSite = false;
                this.params = parameters;
                $("[data-popup-id='language-selection']").on("click", function () {
                    if (!_this.hasFetchedUserSite) {
                        _this.hasFetchedUserSite = true;
                        $.ajax({
                            type: "POST",
                            url: _this.params.getLocalSiteUrl,
                            data: {},
                            dataType: "html",
                            success: function (data) {
                                $("[data-js='user-local-site']", jqueryElement).html(data);
                            }
                        });
                    }
                });
            }
            return CountryLanguageSelections;
        }());
        Web.CountryLanguageSelections = CountryLanguageSelections;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=CountryLanguageSelections.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var CropOverviewFilter = /** @class */ (function () {
            function CropOverviewFilter(jqueryElement, params) {
                this.params = params;
                this.page = 1;
                this.jqueryElement = jqueryElement;
                this.registerEvents();
                this.fetchData(this.replaceRender);
            }
            CropOverviewFilter.prototype.registerEvents = function () {
                var self = this;
                //Switch view between grid and list modes
                $('.view-mode .grid-mode', this.jqueryElement).on('click', function () {
                    $('.selected-view-mode').removeClass('selected-view-mode');
                    $(this).addClass('selected-view-mode');
                    $('.crop-overview-list').attr('class', 'crop-overview-list grid-view');
                    self.fixFlexLayout();
                });
                $('.view-mode .list-mode', this.jqueryElement).on('click', function () {
                    $('.selected-view-mode').removeClass('selected-view-mode');
                    $(this).addClass('selected-view-mode');
                    $('.crop-overview-list').attr('class', 'crop-overview-list list-view');
                });
                //Crop over-view .loadmore-btn
                $('.loadmore-crop-overview .loadmore-btn', this.jqueryElement).on('click', function () {
                    self.fetchData(self.appendRender);
                });
                $('.textbox', this.jqueryElement).keyup(function (event) {
                    if (event.which == 13) {
                        //event.preventDefault();
                        //reset page 
                        self.page = 1;
                        self.fetchData(self.replaceRender);
                    }
                });
                $('.checkbox-category', this.jqueryElement).change(function (e) {
                    //e.preventDefault();
                    //reset page 
                    self.page = 1;
                    self.fetchData(self.replaceRender);
                });
            };
            CropOverviewFilter.prototype.fetchData = function (renderHandler) {
                var self = this;
                $.ajax({
                    type: 'POST',
                    url: this.params.searchUrl,
                    data: this.getQueryParameters(),
                    dataType: 'json',
                    success: function (data) {
                        if (renderHandler) {
                            renderHandler(data);
                        }
                        self.fixFlexLayout();
                        //Update the total result if Mr Cong wants
                        $('.result-counter span').text(data.TotalResult);
                        self.page++;
                        if (data.PageNumber >= data.TotalPage) {
                            $('.loadmore-crop-overview', self.jqueryElement).hide();
                        }
                        else {
                            $('.loadmore-crop-overview', self.jqueryElement).show();
                        }
                    },
                    error: function (jqXHR) {
                        console.log('error: ' + jqXHR);
                    },
                    complete: function (jqXHR) {
                        console.log('complete: ' + jqXHR);
                    }
                });
            };
            CropOverviewFilter.prototype.appendRender = function (data) {
                $(data.Html).appendTo('.crop-overview-list');
            };
            CropOverviewFilter.prototype.replaceRender = function (data) {
                $('.crop-overview-list', this.jqueryElement).empty();
                $(data.Html).appendTo('.crop-overview-list');
            };
            //Crop grid-view flexbox special-treatment
            CropOverviewFilter.prototype.fixFlexLayout = function () {
                var emptyItem;
                $('.crop-overview-item.is-empty', this.jqueryElement).remove();
                $('.crop-overview-list.grid-view', this.jqueryElement).each(function () {
                    emptyItem = [];
                    for (var i = 0; i < $(this).find('.crop-overview-item').length; i++) {
                        emptyItem.push($('<li class="crop-overview-item is-empty"></li>'));
                    }
                    $(this).append(emptyItem);
                });
            };
            CropOverviewFilter.prototype.getQueryParameters = function () {
                var categories = [];
                $('.form-checkbox input:checked', this.jqueryElement).each(function (i, e) {
                    categories.push($(e).attr('category-id'));
                });
                var keyword = $('.textbox', this.jqueryElement).val();
                return {
                    keyword: keyword,
                    categories: categories,
                    page: this.page,
                    blockId: this.params.blockId
                };
            };
            return CropOverviewFilter;
        }());
        Web.CropOverviewFilter = CropOverviewFilter;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=CropOverviewFilter.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var DealerLocator = /** @class */ (function () {
            function DealerLocator(jqueryElement, parm) {
                this.ICON_BASE_URL = '/Content/images/';
                this.isInit = true;
                this.params = parm;
                this.jqueryElement = jqueryElement;
                this.initState();
                this.registerEvents();
                this.markers = [];
                this.query = { blockId: this.params.blockId };
                this.loadDealers();
            }
            DealerLocator.prototype.initState = function () {
                //Hide map on mobile by default
                if ($('.nav-menu').is(':visible')) {
                    $('.toggle-dealer-map', this.jqueryElement).removeClass('map-on');
                    $('.toggle-dealer-map', this.jqueryElement).find('span').text($('.toggle-dealer-map', this.jqueryElement).attr('data-text-show'));
                    $('.map-wrapper', this.jqueryElement).addClass('hide-map');
                }
            };
            DealerLocator.prototype.initMap = function (lat, lng) {
                //Map style, please dont change it if you don't know how it works
                var netafim_map_style = [
                    { "featureType": "administrative", "elementType": "labels.text.fill", "stylers": [{ "color": "#444444" }] },
                    { "featureType": "landscape", "elementType": "all", "stylers": [{ "color": "#f2f2f2" }] },
                    { "featureType": "poi", "elementType": "all", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "road", "elementType": "all", "stylers": [{ "saturation": -100 }, { "lightness": 45 }] },
                    { "featureType": "road.highway", "elementType": "all", "stylers": [{ "visibility": "simplified" }] },
                    { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [{ "color": "#ffffff" }] },
                    { "featureType": "road.arterial", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "transit", "elementType": "all", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "water", "elementType": "all", "stylers": [{ "color": "#dde6e8" }, { "visibility": "on" }] }
                ];
                //Creating a new maps
                var opt = {
                    center: { lat: lat, lng: lng },
                    clickableIcons: true,
                    keyboardShortcuts: false,
                    fullscreenControlOptions: false,
                    zoom: 13,
                    minZoom: 3,
                    maxZoom: 13,
                    streetViewControl: false,
                    disableDefaultUI: true,
                    mapTypeControl: false,
                    scaleControl: false,
                    zoomControl: true,
                    draggable: true,
                    scrollwheel: false,
                    styles: netafim_map_style
                };
                var map = new google.maps.Map(document.getElementById("netafim-dealer-map"), opt);
                return map;
            };
            DealerLocator.prototype.loadDealers = function () {
                var self = this;
                var query = this.query;
                query.searchTextName = $("#search-dealer-name", self.jqueryElement).val();
                query.searchText = $("#search-dealer", self.jqueryElement).val();
                query.radiusSearch = ($("#search-dealer-radius").length ? $("#search-dealer-radius").val() : 0);
                $.ajax({
                    type: "POST",
                    url: this.params.searchDealersUrl,
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(query),
                    success: function (data) {
                        self.populateDealers(data, query.latitude, query.longitude);
                        $('#btnSearchDealer').removeClass('searching');
                        if (query.searchText && dataLayer) {
                            dataLayer.push({
                                'event': 'dealerSearch',
                                'searchQuery': query.searchText,
                            });
                        }
                    }
                });
            };
            DealerLocator.prototype.populateDealers = function (data, lat, lng) {
                var dealers = $.parseJSON(data);
                this.populateMap(dealers);
                this.populateViews(dealers);
            };
            DealerLocator.prototype.populateMap = function (dealers) {
                var self = this;
                self.markers = new Array();
                var lat = this.query.latitude || 59.325;
                var lng = this.query.longitude || 18.070;
                var map = this.initMap(lat, lng);
                var bounds = new google.maps.LatLngBounds();
                //Adding Markers to the existing maps
                for (var i = 0, length = dealers.length; i < length; i++) {
                    var dealer = dealers[i];
                    for (var j = 0; j < dealer.dealers.length; j++) {
                        this.createMaker(dealer.dealers[j], dealer.category_type, dealer.category_pin, dealer.category_color, map, bounds);
                    }
                }
                if (dealers.length <= 0) // update fitbound
                 {
                    var position = new google.maps.LatLng(lat, lng);
                    bounds.extend(position);
                }
                map.fitBounds(bounds);
                // Marker clustering
                self.markerClusterer = new MarkerClusterer(map, this.markers, { imagePath: "/Content/images/m" });
            };
            DealerLocator.prototype.createMaker = function (dealer, type, pin, color, map, bounds) {
                var _this = this;
                var position = new google.maps.LatLng(dealer.lat, dealer.lng);
                var options = {
                    position: position,
                    map: map,
                    icon: pin,
                    animation: google.maps.Animation.DROP,
                    title: dealer.name
                };
                var infoWindow = new google.maps.InfoWindow();
                var marker = new google.maps.Marker(options);
                // Add marker to js list of markers
                this.markers.push(marker);
                bounds.extend(position);
                var content = this.infoBox(type, dealer.logo, dealer.name, dealer.email, dealer.address, dealer.tel, color);
                google.maps.event.addListener(marker, 'click', (function (marker, content, infoWindow) {
                    if (infoWindow)
                        infoWindow.close();
                    return function () {
                        infoWindow.setContent(content);
                        if (_this.prevInfoWindow != null) {
                            _this.prevInfoWindow.close();
                        }
                        infoWindow.open(map, marker);
                        _this.prevInfoWindow = infoWindow;
                        google.maps.event.addListener(map, 'click', function () {
                            if (infoWindow)
                                infoWindow.close();
                        });
                    };
                })(marker, content, infoWindow));
            };
            DealerLocator.prototype.populateViews = function (dealer_data) {
                $('.dealer-accordion').html(this.generateAccordionData(dealer_data));
                $('.dealer-accordion .accordion-container .accordion-item .accordion-item-title').on('click', function () {
                    if ($(this).parent().hasClass('accordion-active')) {
                        $(this).parent().removeClass('accordion-active');
                    }
                    else {
                        $(this).parents('.accordion-container').find('.accordion-active').removeClass('accordion-active');
                        $(this).parent().addClass('accordion-active');
                    }
                });
                if ($("#search-dealer", this.jqueryElement).val() !== '' && dealer_data.length === 1) {
                    if (!$('.dealer-accordion .accordion-item').first().hasClass('accordion-active')) {
                        $('.dealer-accordion .accordion-item').first().addClass('accordion-active');
                    }
                }
                $('.accordion-item-content-dealer').each(function () {
                    var len = $(this).find('.dealer-wrapper').length;
                    var divs = $(this).find('.dealer-wrapper');
                    for (var i = 0; i < len; i += 3) {
                        divs.slice(i, i + 3).wrapAll('<div class="dealer-row"></div>');
                    }
                });
            };
            DealerLocator.prototype.generateAccordionData = function (data) {
                var html = '';
                var totalFoundItems = 0;
                html += '<div class="container"><div class="row"><div class="col-xs-12"><div class="component-inner"><div class="accordion-container has-shadow-desktop"><div class="accordion-inner"><ul>';
                if (data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        var expand = data[i].category_is_expanded === true ? "accordion-active" : "";
                        html += '<li class="accordion-item ' + expand + '"><div class="accordion-item-title"><p><img alt="' + data[i].category_name + '" src="' + data[i].category_icon + '">' + data[i].category_name + '</p></div><div class="accordion-item-content"><div class="accordion-item-content-dealer">';
                        //Loop for each dealer-row
                        // html += '<div class="dealer-row">';
                        for (var j = 0; j < data[i].dealers.length; j++) {
                            html += this.generateDealerItem(data[i].category_type, data[i].dealers[j].logo, data[i].dealers[j].name, data[i].dealers[j].email, data[i].dealers[j].address, data[i].dealers[j].tel, data[i].category_color, data[i].dealers[j].website, data[i].dealers[j].direction);
                            totalFoundItems++;
                        }
                        html += '</div></div></li>';
                    }
                }
                else {
                    html += '';
                }
                html += '</ul></div></div></div></div></div></div>';
                this.generateSummary(totalFoundItems, this.query.searchText, this.query.radiusSearch);
                return html;
            };
            DealerLocator.prototype.generateSummary = function (amountResults, searchTerm, radius) {
                // Only generate summary after actual search
                if (!this.isInit) {
                    var html = "";
                    if (radius > 0) {
                        html = this.params.labelResultsRadius;
                        html = html.replace("{radius}", "<b>" + radius + "</b>");
                        html = html.replace("{distanceUnit}", "<b>" + this.params.labelDistanceUnit + "</b>");
                    }
                    else {
                        html = this.params.labelResults;
                    }
                    html = html.replace("{numberOfResults}", "<b>" + amountResults + "</b>");
                    html = html.replace("{searchTerm}", "<b>" + searchTerm + "</b>");
                    $('[data-js="search-results-title"]', this.jqueryElement).html(html);
                }
                this.isInit = false;
            };
            DealerLocator.prototype.registerEvents = function () {
                var _this = this;
                var self = this;
                var input = document.getElementById('search-dealer');
                var searchBox = new google.maps.places.SearchBox(input);
                searchBox.addListener('places_changed', function () {
                    var places = searchBox.getPlaces();
                    if (places && places.length > 0) {
                        self.query.latitude = places[0].geometry.location.lat();
                        self.query.longitude = places[0].geometry.location.lng();
                    }
                    else {
                        self.query.latitude = self.query.longitude = null;
                    }
                });
                $('.use-current-location a', self.jqueryElement).on('click', function () {
                    if ("geolocation" in navigator) {
                        navigator.geolocation.getCurrentPosition(function (position) {
                            self.query.latitude = position.coords.latitude;
                            self.query.longitude = position.coords.longitude;
                            var geocoder = new google.maps.Geocoder();
                            var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
                            geocoder.geocode({ 'latLng': latlng }, function (results, status) {
                                if (status == google.maps.GeocoderStatus.OK) {
                                    console.log(results);
                                    if (results[1]) {
                                        //formatted address
                                        var address = results[0].formatted_address;
                                        $(input).val(address);
                                    }
                                }
                            });
                        });
                    }
                    else {
                        console.log("Browser doesn't support geolocation!");
                    }
                });
                $('.toggle-dealer-map', self.jqueryElement).on('click', function () {
                    $(this).toggleClass('map-on');
                    if ($(this).hasClass('map-on')) {
                        $(this).find('span').text($(this).data('text-hide'));
                    }
                    else {
                        $(this).find('span').text($(this).data('text-show'));
                    }
                    $('.map-wrapper').toggleClass('hide-map');
                });
                $('#btnSearchDealer', self.jqueryElement).on('click', function () {
                    $(_this).addClass('searching');
                    self.selectFirstLocationWhenNoLocationIsSelected(function () { return self.loadDealers(); });
                });
                $("#search-dealer-name", self.jqueryElement).on('keyup', function (e) {
                    if (e.keyCode === 13) {
                        self.loadDealers();
                    }
                });
                $("#search-dealer", self.jqueryElement).on('keyup', function (e) {
                    if (e.keyCode === 13) {
                        self.selectFirstLocationWhenNoLocationIsSelected(function () { return self.loadDealers(); });
                    }
                });
                $(input).on('change', function (e) {
                    // reset value
                    self.query.latitude = self.query.longitude = null;
                });
            };
            //hack to force first google maps autocomplete location when the user clicks search without selecting a location from google maps autocomplete list
            //based on source: https://stackoverflow.com/questions/7865446/google-maps-places-api-v3-autocomplete-select-first-option-on-enter
            DealerLocator.prototype.selectFirstLocationWhenNoLocationIsSelected = function (callback) {
                var self = this;
                if (self.query.latitude == null && self.query.longitude == null) {
                    var firstResult = $(".pac-container .pac-item:first").text();
                    var geocoder = new google.maps.Geocoder();
                    geocoder.geocode({ "address": firstResult }, function (results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            var lat = results[0].geometry.location.lat(), lng = results[0].geometry.location.lng(), placeName = results[0].address_components[0].long_name;
                            self.query.latitude = lat;
                            self.query.longitude = lng;
                            self.query.searchText = placeName;
                        }
                        callback();
                    });
                }
                else {
                    callback();
                }
            };
            ;
            DealerLocator.prototype.registerControlEvents = function () {
                var self = this;
                $('.toggle-dealer-map', self.jqueryElement).on('click', function () {
                    $(this).toggleClass('map-on');
                    if ($(this).hasClass('map-on')) {
                        $(this).find('span').text($(this).data('text-hide'));
                    }
                    else {
                        $(this).find('span').text($(this).data('text-show'));
                    }
                    $('#netafim-dealer-map', self.params).toggleClass('show-dealer-map');
                });
            };
            DealerLocator.prototype.generateDealerItem = function (type, logo, name, email, address, tel, color, website, direction) {
                var html = '';
                html = '<div class="dealer-wrapper ' + color + '" data-dealer-type="' + type + '">';
                if (this.hasContent(logo)) {
                    html += '<img class="dealer-logo" alt= "' + name + '" src= "' + logo + '" >';
                }
                if (this.hasContent(name)) {
                    html += '<h5>' + name + ' </h5>';
                }
                if (this.hasContent(address)) {
                    html += '<div class="dealer-address"><p>' + address + '</p></div>';
                }
                if (this.hasContent(tel)) {
                    html += '<div class="dealer-phone"><a href="tel:' + tel + '">' + tel + '</a></div>';
                }
                html += '<div class="dealer-accessibility">';
                if (this.hasContent(email)) {
                    html += "<a href=\"mailto:" + email + "\" class=\"dealer-icon-mail\"><span>" + this.params.emailLabel + "</span></a>";
                }
                if (this.hasContent(website)) {
                    html += '<a class="dealer-icon-website" target="_blank" href="' + website + '"><span>' + this.params.websiteLabel + '</span></a>';
                }
                if (this.hasContent(direction)) {
                    html += '<a class="dealer-icon-direction" target="_blank" href="' + direction + '"><span>' + this.params.directionsLabel + '</span></a>';
                }
                html += '</div></div>';
                return html;
            };
            DealerLocator.prototype.infoBox = function (type, logo, name, email, address, tel, color) {
                var html = '<div class="dealer-info-window ' + color + '" data-dealer-type="' + type + '">';
                if (this.hasContent(logo)) {
                    html += '<img alt="' + name + '" src="' + logo + '">';
                }
                if (this.hasContent(name)) {
                    html += '<h5>' + name + '</h5>';
                }
                html += '<p>';
                if (this.hasContent(address)) {
                    html += address;
                }
                if (this.hasContent(tel)) {
                    html += '<br>' + tel;
                }
                html += '</p>';
                if (this.hasContent(email)) {
                    html += "<div class=\"dealer-accessibility\">\n                            <a href=\"mailto:" + email + "\" class=\"dealer-icon-mail\">\n                                " + email + "\n                            </a>\n                         </div>";
                }
                html += '</div>';
                return html;
            };
            DealerLocator.prototype.hasContent = function (content) {
                return content != '' && content != null && content != undefined;
            };
            return DealerLocator;
        }());
        Web.DealerLocator = DealerLocator;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=DealerLocator.js.map;
var BMap, BMapLib, BMAP_ANIMATION_DROP, BMAP_ANCHOR_BOTTOM_RIGHT, BMAP_NAVIGATION_CONTROL_ZOOM;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var DealerLocatorWithBaiduMap = /** @class */ (function () {
            function DealerLocatorWithBaiduMap(jqueryElement, parm) {
                this.ICON_BASE_URL = '/Content/images/';
                this.isInit = true;
                this.params = parm;
                this.query = { blockId: this.params.blockId };
                this.jqueryElement = jqueryElement;
                this.initState();
                this.map = this.initMap();
                this.registerEvents();
                this.loadDealers();
            }
            DealerLocatorWithBaiduMap.prototype.initState = function () {
                //Hide map on mobile by default
                if ($('.nav-menu').is(':visible')) {
                    $('.toggle-dealer-map', this.jqueryElement).removeClass('map-on');
                    $('.toggle-dealer-map', this.jqueryElement).find('span').text($('.toggle-dealer-map', this.jqueryElement).attr('data-text-show'));
                    $('.map-wrapper', this.jqueryElement).addClass('hide-map');
                }
            };
            DealerLocatorWithBaiduMap.prototype.initMap = function (lat, lng) {
                var netafim_map_style = [
                    { "featureType": "administrative", "elementType": "labels.text.fill", "stylers": [{ "color": "#444444" }] },
                    { "featureType": "landscape", "elementType": "all", "stylers": [{ "color": "#f2f2f2" }] },
                    { "featureType": "poi", "elementType": "all", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "road", "elementType": "all", "stylers": [{ "saturation": -100 }, { "lightness": 45 }] },
                    { "featureType": "road.highway", "elementType": "all", "stylers": [{ "visibility": "simplified" }] },
                    { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [{ "color": "#ffffff" }] },
                    { "featureType": "road.arterial", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "transit", "elementType": "all", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "water", "elementType": "all", "stylers": [{ "color": "#dde6e8" }, { "visibility": "on" }] }
                ];
                lat = lat || 39.9387488;
                lng = lng || 116.3687133;
                var map = new BMap.Map("netafim-map-baidu");
                map.centerAndZoom(new BMap.Point({ lat: lat, lng: lng }), 6);
                map.disable3DBuilding();
                map.setMapStyle({ styleJson: netafim_map_style });
                map.enableKeyboard();
                map.addControl(new BMap.NavigationControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM }));
                return map;
            };
            DealerLocatorWithBaiduMap.prototype.loadDealers = function () {
                var self = this;
                var query = this.query;
                query.searchTextName = $("#search-dealer-name", self.jqueryElement).val();
                query.searchText = $("#search-dealer", self.jqueryElement).val();
                query.radiusSearch = ($("#search-dealer-radius").length ? $("#search-dealer-radius").val() : 0);
                $.ajax({
                    type: "POST",
                    url: this.params.searchDealersUrl,
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(query),
                    success: function (data) {
                        self.populateDealers(data, query.latitude, query.longitude);
                        $('#btnSearchDealer').removeClass('searching');
                        if (query.searchText) {
                            dataLayer.push({
                                'event': 'dealerSearch',
                                'searchQuery': query.searchText,
                            });
                        }
                    }
                });
            };
            DealerLocatorWithBaiduMap.prototype.populateDealers = function (data, lat, lng) {
                this.map.clearOverlays();
                var dealersGroup = $.parseJSON(data);
                var myOptions = {
                    closeIconUrl: this.ICON_BASE_URL + "close-infobox-baidu.png",
                    closeIconMargin: "10px 10px",
                    offset: new BMap.Size(-75, 35),
                    enableAutoPan: true,
                    alignBottom: false
                };
                var points = [];
                var infoBoxes = [];
                var selt = this;
                for (var i = 0, length = dealersGroup.length; i < length; i++) {
                    var dealerGroup = dealersGroup[i];
                    for (var j = 0; j < dealerGroup.dealers.length; j++) {
                        // add markers
                        var dealer = dealerGroup.dealers[j];
                        var content = this.infoBox(dealerGroup.category_type, dealer.logo, dealer.name, dealer.email, dealer.address, dealer.tel, dealerGroup.category_color);
                        var locationInfoWindow = new BMapLib.InfoBox(this.map, content, myOptions);
                        var point = new BMap.Point(parseFloat(dealer.lng), parseFloat(dealer.lat) + 0.00022);
                        infoBoxes.push(locationInfoWindow);
                        points.push(point);
                        var icon_pin = new BMap.Icon(dealerGroup.category_pin, new BMap.Size(28, 35));
                        var mapMarker = new BMap.Marker(point, { icon: icon_pin });
                        this.map.addOverlay(mapMarker);
                        mapMarker.setAnimation(BMAP_ANIMATION_DROP);
                        mapMarker.addEventListener("click", (function (mapMarker, i) {
                            return function () {
                                for (var b = 0; b < infoBoxes.length; b++) {
                                    infoBoxes[b].close();
                                }
                                infoBoxes[i].open(mapMarker);
                                selt.registerContactForm('.dealer-info-window');
                            };
                        })(mapMarker, i));
                    }
                }
                this.map.setViewport(points);
                this.populateViews(dealersGroup);
                this.registerContactForm('.dealer-accordion');
            };
            DealerLocatorWithBaiduMap.prototype.populateViews = function (dealer_data) {
                $('.dealer-accordion').html(this.generateAccordionData(dealer_data));
                $('.dealer-accordion .accordion-container .accordion-item .accordion-item-title').on('click', function () {
                    if ($(this).parent().hasClass('accordion-active')) {
                        $(this).parent().removeClass('accordion-active');
                    }
                    else {
                        $(this).parents('.accordion-container').find('.accordion-active').removeClass('accordion-active');
                        $(this).parent().addClass('accordion-active');
                    }
                });
                if ($("#search-dealer", this.jqueryElement).val() !== '' && dealer_data.length === 1) {
                    if (!$('.dealer-accordion .accordion-item').first().hasClass('accordion-active')) {
                        $('.dealer-accordion .accordion-item').first().addClass('accordion-active');
                    }
                }
                $('.accordion-item-content-dealer').each(function () {
                    var len = $(this).find('.dealer-wrapper').length;
                    var divs = $(this).find('.dealer-wrapper');
                    for (var i = 0; i < len; i += 3) {
                        divs.slice(i, i + 3).wrapAll('<div class="dealer-row"></div>');
                    }
                });
            };
            DealerLocatorWithBaiduMap.prototype.generateAccordionData = function (data) {
                var html = '';
                var totalFoundItems = 0;
                html += '<div class="container"><div class="row"><div class="col-xs-12"><div class="component-inner"><div class="accordion-container has-shadow-desktop"><div class="accordion-inner"><ul>';
                if (data.length > 0) {
                    for (var i = 0; i < data.length; i++) {
                        var expand = data[i].category_is_expanded === true ? "accordion-active" : "";
                        html += '<li class="accordion-item ' + expand + '"><div class="accordion-item-title"><p><img alt="' + data[i].category_name + '" src="' + data[i].category_icon + '">' + data[i].category_name + ' (' + data[i].dealers.length + ')</p></div><div class="accordion-item-content"><div class="accordion-item-content-dealer">';
                        //Loop for each dealer-row
                        // html += '<div class="dealer-row">';
                        for (var j = 0; j < data[i].dealers.length; j++) {
                            html += this.generateDealerItem(data[i].category_type, data[i].dealers[j].logo, data[i].dealers[j].name, data[i].dealers[j].email, data[i].dealers[j].address, data[i].dealers[j].tel, data[i].category_color, data[i].dealers[j].website, data[i].dealers[j].direction);
                            totalFoundItems++;
                        }
                        html += '</div></div></li>';
                    }
                }
                else {
                    html += '';
                }
                html += '</ul></div></div></div></div></div></div>';
                this.generateSummary(totalFoundItems, this.query.searchText, this.query.radiusSearch);
                return html;
            };
            DealerLocatorWithBaiduMap.prototype.generateSummary = function (amountResults, searchTerm, radius) {
                // Only generate summary after actual search
                if (!this.isInit) {
                    var html = "";
                    if (radius > 0) {
                        html = this.params.labelResultsRadius;
                        html = html.replace("{radius}", "<b>" + radius + "</b>");
                        html = html.replace("{distanceUnit}", "<b>" + this.params.labelDistanceUnit + "</b>");
                    }
                    else {
                        html = this.params.labelResults;
                    }
                    html = html.replace("{numberOfResults}", "<b>" + amountResults + "</b>");
                    html = html.replace("{searchTerm}", "<b>" + searchTerm + "</b>");
                    $('[data-js="search-results-title"]', this.jqueryElement).html(html);
                }
                this.isInit = false;
            };
            DealerLocatorWithBaiduMap.prototype.registerEvents = function () {
                var self = this;
                var input = document.getElementById('search-dealer');
                //var searchBox = new google.maps.places.SearchBox(input);
                //searchBox.addListener('places_changed', function () {
                //    var places = searchBox.getPlaces();
                //    if (places && places.length > 0) {
                //        self.query.latitude = places[0].geometry.location.lat();
                //        self.query.longitude = places[0].geometry.location.lng();
                //    } else {
                //        self.query.latitude = self.query.longitude = null;
                //    }
                //});
                $('.use-current-location a', self.jqueryElement).on('click', function () {
                    if ("geolocation" in navigator) {
                        navigator.geolocation.getCurrentPosition(function (position) {
                            self.query.latitude = position.coords.latitude;
                            self.query.longitude = position.coords.longitude;
                            var geocoder = new BMap.Geocoder();
                            geocoder.getLocation(new BMap.Point(position.coords.latitude, position.coords.longitude), function (result) {
                                var location = (result) ? result.address : "";
                                if (result) {
                                    $('#search-dealer').val(location);
                                }
                            });
                        });
                    }
                    else {
                        console.log("Browser doesn't support geolocation!");
                    }
                });
                $('.toggle-dealer-map', self.jqueryElement).on('click', function () {
                    $(this).toggleClass('map-on');
                    if ($(this).hasClass('map-on')) {
                        $(this).find('span').text($(this).data('text-hide'));
                    }
                    else {
                        $(this).find('span').text($(this).data('text-show'));
                    }
                    $('.map-wrapper').toggleClass('hide-map');
                });
                var autocomplete = new BMap.Autocomplete({
                    "input": "search-dealer"
                });
                autocomplete.addEventListener("onconfirm", function (e) {
                    var myValue = e.item.value.province + e.item.value.city + e.item.value.district + e.item.value.street + e.item.value.business;
                    self.setPlace(self, myValue);
                });
                $('#btnSearchDealer', self.jqueryElement).on('click', function () {
                    $(this).addClass('searching');
                    self.loadDealers();
                });
                $(input).on('change', function (e) {
                    // reset value
                    self.query.latitude = self.query.longitude = null;
                });
            };
            DealerLocatorWithBaiduMap.prototype.setPlace = function (self, myValue) {
                var local;
                function myFun() {
                    var pp = local.getResults().getPoi(0).point;
                    self.query.latitude = pp.lat;
                    self.query.longitude = pp.lng;
                }
                local = new BMap.LocalSearch(self.map, {
                    onSearchComplete: myFun
                });
                local.search(myValue);
            };
            DealerLocatorWithBaiduMap.prototype.registerControlEvents = function () {
                var self = this;
                $('.toggle-dealer-map', self.jqueryElement).on('click', function () {
                    $(this).toggleClass('map-on');
                    if ($(this).hasClass('map-on')) {
                        $(this).find('span').text($(this).data('text-hide'));
                    }
                    else {
                        $(this).find('span').text($(this).data('text-show'));
                    }
                    $('#netafim-dealer-map', self.params).toggleClass('show-dealer-map');
                });
            };
            DealerLocatorWithBaiduMap.prototype.generateDealerItem = function (type, logo, name, email, address, tel, color, website, direction) {
                var html = '';
                html = '<div class="dealer-wrapper ' + color + '" data-dealer-type="' + type + '">';
                if (this.hasContent(logo)) {
                    html += '<img class="dealer-logo" alt= "' + name + '" src= "' + logo + '" >';
                }
                if (this.hasContent(name)) {
                    html += '<h5>' + name + ' </h5>';
                }
                if (this.hasContent(address)) {
                    html += '<div class="dealer-address"><p>' + address + '</p></div>';
                }
                if (this.hasContent(tel)) {
                    html += '<div class="dealer-phone"><a href="tel:' + tel + '">' + tel + '</a></div>';
                }
                html += '<div class="dealer-accessibility">';
                if (this.hasContent(email)) {
                    html += '<a class="dealer-icon-chat" href="javascript:void(0);" data-open="popup-overlay" data-popup-id="dealer-locator-contact-form" data-dealer-email="' + email + '"><span>' + this.params.contactFormLabel + '</span></a>';
                }
                if (this.hasContent(website)) {
                    html += '<a class="dealer-icon-website" target="_blank" href="' + website + '"><span>' + this.params.websiteLabel + '</span></a>';
                }
                if (this.hasContent(direction)) {
                    html += '<a class="dealer-icon-direction" target="_blank" href="' + direction + '"><span>' + this.params.directionsLabel + '</span></a>';
                }
                html += '</div></div>';
                return html;
            };
            DealerLocatorWithBaiduMap.prototype.infoBox = function (type, logo, name, email, address, tel, color) {
                var html = '<div class="dealer-info-window ' + color + '" data-dealer-type="' + type + '">';
                if (this.hasContent(logo)) {
                    html += '<img alt="' + name + '" src="' + logo + '">';
                }
                if (this.hasContent(name)) {
                    html += '<h5>' + name + '</h5>';
                }
                html += '<p>';
                if (this.hasContent(address)) {
                    html += address;
                }
                if (this.hasContent(tel)) {
                    html += '<br>' + tel;
                }
                html += '</p>';
                if (this.hasContent(email)) {
                    html += "<div class=\"dealer-accessibility\">\n                            " + (this.params.showContactFormInInfoBox
                        ? "<a href=\"javascript:void(0);\" data-open=\"popup-overlay\" data-popup-id=\"dealer-locator-contact-form\" data-dealer-email=\"" + email + "\" class=\"dealer-icon-chat\">\n                                                    " + this.params.contactFormLabel + "\n                                           </a>"
                        : "") + "\n                            <a href=\"mailto:" + email + "\" class=\"dealer-icon-mail\">\n                                " + email + "\n                            </a>\n                         </div>";
                }
                html += '</div>';
                return html;
            };
            DealerLocatorWithBaiduMap.prototype.hasContent = function (content) {
                return content != '' && content != null && content != undefined;
            };
            DealerLocatorWithBaiduMap.prototype.registerContactForm = function (parentEle) {
                var self = this;
                if (self.params.contactFormUrl === "" && self.params.hiddenFieldName === "")
                    return;
                if (self.params.contactFormUrl !== "") {
                    var ele = $(parentEle + ' .dealer-accessibility .dealer-icon-chat', self.jqueryElement);
                    ele.attr("href", self.params.contactFormUrl !== null ? self.params.contactFormUrl : "#");
                    return;
                }
                if (self.params.hiddenFieldName !== "") {
                    // Open overlay
                    $(parentEle + ' a[data-open="popup-overlay"]', self.jqueryElement).on('click', function (e) {
                        $('body').addClass('no-scroll');
                        var dealerEmail = $(this).attr("data-dealer-email");
                        if (dealerEmail !== '') {
                            self.addHideFieldToContactForm(dealerEmail);
                        }
                        var popupId = $(this).attr("data-popup-id");
                        $('.popup-overlay[data-popup-id="' + popupId + '"]').addClass('show-popup');
                        e.preventDefault();
                    });
                    return;
                }
            };
            DealerLocatorWithBaiduMap.prototype.addHideFieldToContactForm = function (dealerEmail) {
                var self = this;
                if ($("[context-aware] input[name='" + self.params.hiddenFieldName + "']", self.jqueryElement).length) {
                    $("[context-aware] input[name='" + self.params.hiddenFieldName + "']", self.jqueryElement).val(dealerEmail);
                }
                else {
                    $("[context-aware]", self.jqueryElement).each(function () {
                        var $context = $(this);
                        var hiddenMetadata = '<input name=\"' + self.params.hiddenFieldName + '\" value=\"' + dealerEmail + '\"' +
                            'type =\"hidden\" class=\"Form__Element FormHidden FormHideInSummarized Form__Element--Filled\">';
                        $context.find("form.EPiServerForms").each(function () {
                            $(this).find(".Form__MainBody section#__field_").append(hiddenMetadata);
                        });
                    });
                }
            };
            return DealerLocatorWithBaiduMap;
        }());
        Web.DealerLocatorWithBaiduMap = DealerLocatorWithBaiduMap;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=DealerLocatorWithBaiduMap.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var DepartmentOverview = /** @class */ (function () {
            function DepartmentOverview(jqueryElement, param) {
                $('.btn-filter-department', jqueryElement).on('click', function () {
                    var self = this;
                    if (param != null && param.jobFilterId != null && param.jobFilterId != '' && param.jobFilterId != undefined) {
                        // find all job filter component in this page
                        $("#" + param.jobFilterId).each(function (i, element) {
                            var department = $(self).attr('data-department');
                            // Pre-fill the department selection
                            var departmentSelection = $("select.department", element);
                            departmentSelection.val(department);
                            // reset the location
                            $("select.location", element).val('');
                            // Trigger the event.
                            departmentSelection.trigger('change');
                        });
                    }
                });
            }
            return DepartmentOverview;
        }());
        Web.DepartmentOverview = DepartmentOverview;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=DepartmentOverview.js.map;
var dataLayer;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var DownloadsBlock = /** @class */ (function () {
            function DownloadsBlock(jqueryElement) {
                $('.download-item', $(jqueryElement).parent()).each(function () {
                    $(this).click(function () {
                        var fileName = $(this).attr("data-title");
                        if (dataLayer) {
                            dataLayer.push({
                                'event': 'fileDownload',
                                'downloadName': fileName
                            });
                        }
                    });
                });
            }
            return DownloadsBlock;
        }());
        Web.DownloadsBlock = DownloadsBlock;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=DownloadsBlock.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var FloatingSharing = /** @class */ (function () {
            function FloatingSharing(jqueryElement, params) {
                var _this = this;
                this.isShareaholic = params.isShareaholic;
                this.siteId = params.siteId;
                this.scriptUrl = params.scriptUrl;
                this.cookiePublisher = new Web.CookiePublisher();
                var isAllowedToShow = Web.CookieUtil.readCookie("consent_social"); // TODO: Name
                if (isAllowedToShow) {
                    this.displayFloatingCta();
                }
                this.cookiePublisher.subscribeOnCookieAccepted(function () {
                    _this.displayFloatingCta();
                });
            }
            FloatingSharing.prototype.displayFloatingCta = function () {
                var sharingTag = document.createElement('script');
                sharingTag.setAttribute("type", "text/javascript");
                sharingTag.setAttribute("src", this.scriptUrl);
                sharingTag.setAttribute("data-cfasync", "false");
                sharingTag.setAttribute("async", "async");
                if (this.isShareaholic) {
                    sharingTag.setAttribute("data-shr-siteid", this.siteId);
                }
                document.getElementsByTagName("head")[0].appendChild(sharingTag);
            };
            return FloatingSharing;
        }());
        Web.FloatingSharing = FloatingSharing;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=FloatingSharing.js.map;
var $$epiforms, epi, grecaptcha;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var FormContainerBlock = /** @class */ (function () {
            function FormContainerBlock(jqueryElement, param) {
                //Fixing Episerver FromChoice
                $('.netafim-form .FormChoice label', jqueryElement).each(function () {
                    var newHtml = $(this).find('.FormChoice__Input--Checkbox').clone().wrap('<div/>').parent().html() + '<span>' + $(this).text() + '</span>';
                    $(this).html(newHtml);
                });
                $(".netafim-form .EPiServerForms .FormSubmitButton", jqueryElement).on("click", function () {
                    if ($(".netafim-form .EPiServerForms .Form__Success__Message").length > 0) {
                        $(".extra-information", jqueryElement).hide();
                    }
                });
                $("[context-aware]", jqueryElement).each(function () {
                    var $context = $(this);
                    var hiddenMetadata = '', metadata = $context
                        .find('[public-identity-metadata] > input[public-identity-value]')
                        .map(function () {
                        var $prop = $(this);
                        hiddenMetadata += '<input name=\"' + param.hiddenFieldName + '\" value=\"' + $prop.attr('public-identity-value') + '\"' +
                            'type =\"hidden\" class=\"Form__Element FormHidden FormHideInSummarized Form__Element--Filled\">';
                    });
                    $context
                        .find("form.EPiServerForms")
                        .each(function () {
                        $(this).find(".Form__MainBody section#__field_").append(hiddenMetadata);
                    });
                    if ($context.find(".Form__Element_ReferringPage").length && param.referringPageUrl !== "") {
                        $context.find(".Form__Element_ReferringPage").val(param.referringPageUrl);
                    }
                });
                // Episerver forms hooks
                if (typeof $$epiforms !== 'undefined') {
                    $$epiforms(document).ready(function myfunction() {
                        $(".EPiServerForms .result", jqueryElement).hide(); //hide everything on init
                        $$epiforms(".EPiServerForms").on("formsSubmitted", function (event, param1, param2) {
                            if (event.type === "formsSubmitted" && event.isFinalizedSubmission) {
                                $(window).scrollTop($(".EPiServerForms .Form__Status", jqueryElement).position().top);
                                sendToGtm();
                            }
                        });
                    });
                }
                // Eloqua forms
                $(jqueryElement).find("div[data-js='eloqua-form-container'] form").on("submit", function (e) {
                    if ($(jqueryElement).find('.LV_invalid_field').length !== 0)
                        return;
                    e.preventDefault();
                    var form = $(e.currentTarget);
                    var url = form.attr('action');
                    var data = form.serialize();
                    $.ajax({
                        url: url,
                        type: 'post',
                        data: data,
                        success: function () {
                            var template = $(jqueryElement).find("div[data-js='eloqua-thank-you-message']").removeClass("u-hide");
                            form.replaceWith(template);
                            sendToGtm();
                        },
                        error: function () {
                            var template = $(jqueryElement).find("div[data-js='eloqua-error-message']").removeClass("u-hide");
                            form.replaceWith(template);
                        }
                    });
                });
                var sendToGtm = function () {
                    if (typeof dataLayer !== 'undefined' && param.gtmFormCategory !== 'None') {
                        dataLayer.push({
                            'event': 'formSubmission',
                            'formCategory': param.gtmFormCategory
                        });
                    }
                };
            }
            return FormContainerBlock;
        }());
        Web.FormContainerBlock = FormContainerBlock;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=FormContainerBlock.js.map;
(function ($) {
    if (typeof __MapElements !== "undefined") {
        $.each(__MapElements || [], function (i, mapElementInfo) {
            var mapEl = $("#" + mapElementInfo.guid + '_locationPicker');

            if (!mapEl || mapEl.length < 1) {
                return;
            }

            var mapsProvider = mapEl.attr("data-js-mapsProvider");
            var storeCoordinates = mapEl.attr("data-js-store-coords") === "True";

            // Listen to custom event
            mapEl[0].addEventListener('coordinatesChanged', (e) => {
                if (storeCoordinates) {
                    var lat = mapEl.find('#latitude').val();
                    var lng = mapEl.find('#longitude').val();

                    mapEl.find('[data-js="submit-value"]')
                        .val(lat + ";" + lng);
                } else {
                    var address = mapEl.find('#search-location').val();

                    mapEl.find('[data-js="submit-value"]')
                        .val(address);
                }
            }, false);

            // Init map
            if (mapsProvider === "GoogleMaps") {
                initGoogleMaps(mapEl);
            }

            if (mapsProvider === "BaiduMaps") {
                initBaiduMaps(mapEl);
            }
        });
    }

    function initGoogleMaps(mapEl) {
        var options = {
            enableHighAccuracy: true,
            timeout: 5000,
            maximumAge: 0
        };

        navigator.geolocation.getCurrentPosition(success, error, options);

        function success(pos) {
            this.lat = pos.coords.latitude;
            this.lng = pos.coords.longitude;

            mapEl.find('#map').locationpicker({
                location: { latitude: this.lat, longitude: this.lng },
                mapTypeId: google.maps.MapTypeId.HYBRID,
                radius: 100,
                inputBinding: {
                    locationNameInput: mapEl.find('#search-location'),
                    latitudeInput: mapEl.find('#latitude'),
                    longitudeInput: mapEl.find('#longitude')
                },
                enableAutocomplete: true,
                onchanged: (currentLocation, radius, isMarkerDropped) => {
                    mapEl[0].dispatchEvent(new Event('coordinatesChanged'));
                },
                oninitialized: (component) => {
                    mapEl[0].dispatchEvent(new Event('coordinatesChanged'));
                }
            });
        }

        function error(err) {
            console.warn(`ERROR(${err.code}): ${err.message}`);
        }
    }

    function initBaiduMaps(mapEl) {
        var map;

        var createMap = () => {
            // Create map
            map = new BMap.Map("map");
            map.setMapType(BMAP_SATELLITE_MAP);

            // Set map to current user location
            var geolocation = new BMap.Geolocation();
            geolocation.getCurrentPosition(function (r) {
                if (this.getStatus() == 0) { //BMAP_STATUS_SUCCESS retrieved successfully. Corresponding value "0"
                    setMapToPoint(r.point);
                } else {
                    console.log('failed to retrieve user location' + this.getStatus());
                }
            }, { enableHighAccuracy: true });


            // Auto complete the search bar
            var autoComplete = new BMap.Autocomplete({
                "input": "search-location",
                "location": map
            });

            // Auto complete event listener, clicking on search result
            autoComplete.addEventListener("onconfirm", e => {
                getSearchResultPoint(e.item.value).then((point) => {
                    if (point !== undefined) {
                        setMapToPoint(point);
                    }
                });
            });

            // Map click event listener, indicating current location
            map.addEventListener("click", e => {
                setMapToPoint(e.point);
            });
        }

        var setMapToPoint = (point) => {
            map.centerAndZoom(point, 20);

            // Clear map
            map.clearOverlays();

            // Marker indicating location
            var marker = new BMap.Marker(point);
            map.addOverlay(marker);

            // Store location coordinates for submission
            $('#latitude').val(point.lat);
            $('#longitude').val(point.lng);

            // Store location name for submission
            mapEl[0].dispatchEvent(new Event('coordinatesChanged'));
        }

        var getSearchResultPoint = (searchResult) => {
            return new Promise((resolve) => {
                var searchResultAddress = searchResult.province + searchResult.city + searchResult.district + searchResult.street + searchResult.business;

                var geocoder = new BMap.Geocoder();
                geocoder.getPoint(searchResultAddress, (searchResultPoint) => {
                    resolve(searchResultPoint);
                });
            });
        }

        // Set Map events
        var setMapEvent = () => {
            map.enableDragging();
            map.enableScrollWheelZoom();
            map.enableDoubleClickZoom();
            map.enableKeyboard();
        }

        // Set Map Controllers
        var addMapControl = () => {
            var BMAP_ANCHOR_TOP_LEFT, BMAP_NAVIGATION_CONTROL_LARGE;
            var ctrl_nav = new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE });

            map.addControl(ctrl_nav);
        }

        createMap();
        setMapEvent();
        addMapControl();
    }

})($$epiforms || $);;
var BMAP_SATELLITE_MAP;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var MapProvider;
        (function (MapProvider) {
            MapProvider[MapProvider["Google"] = 0] = "Google";
            MapProvider[MapProvider["Baidu"] = 1] = "Baidu";
        })(MapProvider || (MapProvider = {}));
        var MapElement = /** @class */ (function () {
            function MapElement(jqueryElement, params) {
                var _this = this;
                this.lat = 0.00;
                this.lng = 0.00;
                this.initGoogleMaps = function (locationInputField) {
                    var options = {
                        enableHighAccuracy: true,
                        timeout: 5000,
                        maximumAge: 0
                    };
                    navigator.geolocation.getCurrentPosition(success, error, options);
                    function success(pos) {
                        this.lat = pos.coords.latitude;
                        this.lng = pos.coords.longitude;
                        $(locationInputField).find('#map').locationpicker({
                            location: { latitude: this.lat, longitude: this.lng },
                            mapTypeId: google.maps.MapTypeId.HYBRID,
                            radius: 100,
                            inputBinding: {
                                locationNameInput: $(locationInputField).find('#search-location'),
                                latitudeInput: $(locationInputField).find('#latitude'),
                                longitudeInput: $(locationInputField).find('#longitude')
                            },
                            enableAutocomplete: true,
                            onchanged: function (currentLocation, radius, isMarkerDropped) {
                                $(locationInputField)[0].dispatchEvent(new Event('coordinatesChanged'));
                            },
                            oninitialized: function (component) {
                                $(locationInputField)[0].dispatchEvent(new Event('coordinatesChanged'));
                            }
                        });
                    }
                    function error(err) {
                        console.warn("ERROR(" + err.code + "): " + err.message);
                        //init locationpicker with default coordinates.
                    }
                };
                this.initBaiduMaps = function (locationInputField) {
                    var map;
                    var createMap = function () {
                        // Create map
                        map = new BMap.Map("map");
                        map.setMapType(BMAP_SATELLITE_MAP);
                        // Set map to current user location
                        var geolocation = new BMap.Geolocation();
                        geolocation.getCurrentPosition(function (r) {
                            if (this.getStatus() == 0) { //BMAP_STATUS_SUCCESS retrieved successfully. Corresponding value "0"
                                setMapToPoint(r.point);
                            }
                            else {
                                console.log('failed to retrieve user location' + this.getStatus());
                            }
                        }, { enableHighAccuracy: true });
                        // Auto complete the search bar
                        var autoComplete = new BMap.Autocomplete({
                            "input": "search-location",
                            "location": map
                        });
                        // Auto complete event listener, clicking on search result
                        autoComplete.addEventListener("onconfirm", function (e) {
                            getSearchResultPoint(e.item.value).then(function (point) {
                                if (point !== undefined) {
                                    setMapToPoint(point);
                                }
                            });
                        });
                        // Map click event listener, indicating current location
                        map.addEventListener("click", function (e) {
                            setMapToPoint(e.point);
                        });
                    };
                    var setMapToPoint = function (point) {
                        map.centerAndZoom(point, 20);
                        // Clear map
                        map.clearOverlays();
                        // Marker indicating location
                        var marker = new BMap.Marker(point);
                        map.addOverlay(marker);
                        // Store location coordinates for submission
                        $('#latitude').val(point.lat);
                        $('#longitude').val(point.lng);
                        // Store location name for submission
                        $(locationInputField)[0].dispatchEvent(new Event('coordinatesChanged'));
                    };
                    var getSearchResultPoint = function (searchResult) {
                        return new Promise(function (resolve) {
                            var searchResultAddress = searchResult.province + searchResult.city + searchResult.district + searchResult.street + searchResult.business;
                            var geocoder = new BMap.Geocoder();
                            geocoder.getPoint(searchResultAddress, function (searchResultPoint) {
                                resolve(searchResultPoint);
                            });
                        });
                    };
                    // Set Map events
                    var setMapEvent = function () {
                        map.enableDragging();
                        map.enableScrollWheelZoom();
                        map.enableDoubleClickZoom();
                        map.enableKeyboard();
                    };
                    // Set Map Controllers
                    var addMapControl = function () {
                        var BMAP_ANCHOR_TOP_LEFT, BMAP_NAVIGATION_CONTROL_LARGE;
                        var ctrl_nav = new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_LEFT, type: BMAP_NAVIGATION_CONTROL_LARGE });
                        map.addControl(ctrl_nav);
                    };
                    createMap();
                    setMapEvent();
                    addMapControl();
                };
                this.jqueryElement = jqueryElement;
                this.params = params;
                if (params.mapProvider == MapProvider.Google) {
                    this.initGoogleMaps(jqueryElement);
                }
                if (params.mapProvider == MapProvider.Baidu) {
                    this.initBaiduMaps(jqueryElement);
                }
                jqueryElement[0].addEventListener('coordinatesChanged', function (e) {
                    if (_this.params.storeCoordinates) {
                        var lat = $(jqueryElement).find('#latitude').val();
                        var lng = $(jqueryElement).find('#longitude').val();
                        $(jqueryElement).find('#' + _this.params.formElementId)
                            .val(lat + ";" + lng);
                    }
                    else {
                        var address = $(jqueryElement).find('#search-location').val();
                        $(jqueryElement).find('#' + _this.params.formElementId)
                            .val(address);
                    }
                }, false);
            }
            return MapElement;
        }());
        Web.MapElement = MapElement;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=MapElement.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var RecaptchaValidators = /** @class */ (function () {
            function RecaptchaValidators(jqueryElement, param) {
                (function ($) {
                    var originalGetCustomElementValue = epi.EPiServer.Forms.Extension.getCustomElementValue;
                    // extend the EpiForm JavaScript API in ViewMode
                    $.extend(true, epi.EPiServer.Forms, {
                        /// extend the Validator to validate Visitor's value in Clientside.
                        /// Serverside's Fullname of the Validator instance is used as object key (Case-sensitve) to lookup the Clientside validate function.        
                        Validators: {
                            "Netafim.WebPlatform.Web.Features.FormElementBlocks.Validation.RecaptchaValidator": function (fieldName, fieldValue, validatorMetaData) {
                                // validate recaptcha element
                                if (fieldValue) {
                                    return { isValid: true };
                                }
                                return { isValid: false, message: param.invalidMessage };
                            }
                        },
                        Extension: {
                            getCustomElementValue: function ($element) {
                                if ($element.hasClass("FormRecaptcha")) {
                                    // for recaptcha element
                                    var widgetId = $element.data("epiforms-recaptcha-widgetid");
                                    if (widgetId != undefined && grecaptcha) {
                                        return grecaptcha.getResponse(widgetId);
                                    }
                                    else {
                                        return null;
                                    }
                                }
                                // if current element is not our job, let others process
                                return originalGetCustomElementValue.apply(this, [$element]);
                            }
                        }
                    });
                    // reset reCAPTCH elements in target form
                    function resetRecaptchaElements(target) {
                        var reCaptchaElements = $(".FormRecaptcha", target);
                        $.each(reCaptchaElements, function (index, element) {
                            var widgetId = $(element).data("epiforms-recaptcha-widgetid");
                            if (widgetId != undefined && grecaptcha) {
                                grecaptcha.reset(widgetId);
                            }
                        });
                    }
                    $(".EPiServerForms").on("formsReset formsNavigationPrevStep", function (event) {
                        resetRecaptchaElements(event.target);
                    });
                    $(".EPiServerForms").on("formsStepValidating", function (event) {
                        if (event.isValid === true) {
                            return;
                        }
                        // reset reCAPTCHA element if validation failed
                        resetRecaptchaElements(event.target);
                    });
                })($$epiforms || $);
            }
            return RecaptchaValidators;
        }());
        Web.RecaptchaValidators = RecaptchaValidators;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=RecaptchaValidators.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var CtaDownload = /** @class */ (function () {
            function CtaDownload(jqueryElement, parameter) {
                var _this = this;
                this.params = parameter;
                this.jqueryElements = jqueryElement;
                $('.popup-overlay .btn-close', jqueryElement).on("click", function () {
                    resetForm();
                });
                if (this.params.isEloquaForm) {
                    $("div[data-js='eloqua-form-container'] form", jqueryElement).on("submit", function (e) {
                        handleEloquaFormSubmit(e);
                    });
                }
                else {
                    $(".download-overlay .cta-email-download", jqueryElement).on("click", function (e) {
                        handleEpiFormSubmit();
                    });
                }
                var resetForm = function () {
                    // Clear e-mail field
                    $('.download-overlay #clientEmail', jqueryElement).val('');
                    // Hide potential errors
                    showHideMessage(".error-message", false);
                    showHideMessage(".invalid-email-message", false);
                };
                var handleEloquaFormSubmit = function (e) {
                    e.preventDefault();
                    if ($(jqueryElement).find('.LV_invalid_field').length !== 0)
                        return;
                    var form = $(e.currentTarget);
                    var url = form.attr('action');
                    var data = form.serialize();
                    $.ajax({
                        url: url,
                        type: 'post',
                        data: data,
                        success: function () {
                            var template = $(jqueryElement).find("div[data-js='eloqua-thank-you-message']").removeClass("u-hide");
                            form.replaceWith(template);
                        },
                        error: function () {
                            var template = $(jqueryElement).find("div[data-js='eloqua-error-message']").removeClass("u-hide");
                            form.replaceWith(template);
                        }
                    });
                    saveSubmissionData("info@eloqua.com", false);
                    return true;
                };
                var handleEpiFormSubmit = function () {
                    var _validEmail = true;
                    var _privacyPolicyAccepted = true;
                    var email = $(".download-overlay #clientEmail", jqueryElement).val();
                    var privacyChecked = $('#privacyCheckbox', jqueryElement).is(':checked');
                    if (email) {
                        showHideMessage(".error-message", false);
                        if (isEmail(email)) {
                            showHideMessage(".invalid-email-message", false);
                        }
                        else {
                            showHideMessage(".invalid-email-message", true);
                            _validEmail = false;
                        }
                    }
                    else {
                        showHideMessage(".invalid-email-message", false);
                        showHideMessage(".error-message", true);
                        _validEmail = false;
                    }
                    if (privacyChecked) {
                        showHideMessage(".error-message.privacy-nok", false);
                    }
                    else {
                        showHideMessage(".error-message.privacy-nok", true);
                        _privacyPolicyAccepted = false;
                    }
                    if (!_validEmail || !_privacyPolicyAccepted)
                        return false;
                    saveSubmissionData(email, true);
                    return true;
                };
                var saveSubmissionData = function (email, isEpiForm) {
                    $.ajax({
                        type: 'POST',
                        url: _this.params.downloadActionUrl,
                        data: {
                            blockId: _this.params.blockId,
                            clientEmail: email,
                            isEpiForm: isEpiForm
                        },
                        dataType: "json",
                        success: function (data) {
                            if (data.status) {
                                performDownload(email, isEpiForm);
                            }
                            else {
                                showHideMessage(".error-message", true);
                                $('.download-overlay .error-message', jqueryElement).text(data.message);
                                return;
                            }
                        }
                    });
                };
                var performDownload = function (email, isEpiForm) {
                    var documentUrl = _this.params.downloadUrl;
                    if (!startsWith(documentUrl, "http://") && !startsWith(documentUrl, "https://")) {
                        documentUrl = window.location.origin + documentUrl;
                    }
                    setDownloadCookie(email);
                    window.open(documentUrl, "_blank");
                    if (isEpiForm) {
                        closePopUp();
                    }
                };
                var showHideMessage = function (cssClass, isShow) {
                    if (isShow) {
                        $('.download-overlay ' + cssClass, jqueryElement).show();
                    }
                    else {
                        $('.download-overlay ' + cssClass, jqueryElement).hide();
                    }
                };
                var closePopUp = function () {
                    $('#clientEmail', jqueryElement).val('');
                    $('body').removeClass('no-scroll');
                    $('.popup-overlay').removeClass('show-popup');
                    $('nav').removeClass('show-nav');
                    $('.nav-content').removeClass('show-nav-content');
                };
                var setDownloadCookie = function (email) {
                    document.cookie = "email_cta_download=" + email;
                };
                var isEmail = function (emailAddress) {
                    var pattern = new RegExp(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/);
                    return pattern.test(emailAddress);
                };
            }
            return CtaDownload;
        }());
        Web.CtaDownload = CtaDownload;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=CtaDownload.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var GenericListing = /** @class */ (function () {
            function GenericListing(jqueryElement) {
                //Crop over-view .loadmore-btn
                $('.loadmore-crop-overview .loadmore-btn', jqueryElement).on('click', function () {
                    var url = $(jqueryElement).attr('url-action');
                    var data = JSON.parse($('#query', jqueryElement).val());
                    $.ajax({
                        url: url,
                        data: data,
                        dataType: 'html',
                        method: 'POST',
                        cache: false,
                        success: function (res) {
                            var newQuery = $(res).find('#query');
                            if (newQuery) {
                                $('#query', jqueryElement).val(newQuery.val());
                            }
                            if ($(res).find('#endOfResult').length) { // Last page --> remove the show more view
                                $('#cropOverViewShowMore', jqueryElement).remove();
                            }
                            var html = $(res).find('.crop-overview-list').html();
                            $(html).appendTo('.crop-overview-list');
                            fixFlexLayout();
                        },
                        error: function (jqXHR) {
                        }
                    });
                });
                //Switch view between grid and list modes
                $('.view-mode .grid-mode').on('click', function () {
                    $('.selected-view-mode').removeClass('selected-view-mode');
                    $(this).addClass('selected-view-mode');
                    $('.crop-overview-list').attr('class', 'crop-overview-list grid-view');
                    fixFlexLayout();
                });
                $('.view-mode .list-mode').on('click', function () {
                    $('.selected-view-mode').removeClass('selected-view-mode');
                    $(this).addClass('selected-view-mode');
                    $('.crop-overview-list').attr('class', 'crop-overview-list list-view');
                });
                function fixFlexLayout() {
                    var emptyItem;
                    $('.crop-overview-item.is-empty').remove();
                    $('.crop-overview-list.grid-view').each(function () {
                        emptyItem = [];
                        for (var i = 0; i < $(this).find('.crop-overview-item').length; i++) {
                            emptyItem.push($('<li class="crop-overview-item is-empty"></li>'));
                        }
                        $(this).append(emptyItem);
                    });
                }
            }
            return GenericListing;
        }());
        Web.GenericListing = GenericListing;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=Listing.js.map;
var _this = this;
function setBreadCrumbBg() {
    var breadcrumb = $('.breadcrumb').first().parents('.component');
    var breadcrumb_next = breadcrumb.next('div').find('section.component').first();
    if (breadcrumb_next.hasClass('gray-bg')) {
        breadcrumb.addClass('gray-bg');
    }
}
setBreadCrumbBg();
//sidebar navigation
$('.sidebar-nav-menu').on('click', function () {
    $('.sidebar-navigation').toggleClass('show-nav');
});
//Boolean function for opening popup
function popupIsAvailable() {
    //For BE developers, please set this cookie value after the form is submitted
    if (document.cookie.indexOf("email_entered=") >= 0) {
        return false;
    }
    else {
        return true;
    }
}
// Open overlay
$('a[data-open="popup-overlay"]').on('click', function (e) {
    var popupId = $(this).attr("data-popup-id");
    if (popupId === "cta-download-overlay" && !popupIsAvailable()) {
        var documentUrl = $(this).attr("data-download-url");
        if (!startsWith(documentUrl, "http://") && !startsWith(documentUrl, "https://")) {
            documentUrl = window.location.origin + documentUrl;
        }
        window.open(documentUrl, "_blank");
    }
    else {
        $('body').addClass('no-scroll');
        $('.popup-overlay[data-popup-id="' + popupId + '"]').addClass('show-popup');
    }
    e.preventDefault();
});
// Close overlay
$('.popup-overlay .btn-close').on('click', function () {
    $('body').removeClass('no-scroll');
    $('.popup-overlay').removeClass('show-popup');
    $('nav').removeClass('show-nav');
    $('.nav-content').removeClass('show-nav-content');
});
//Accordion menu
$('.accordion-container .accordion-item .accordion-item-title').on('click', function (e) {
    e.preventDefault();
    var this_wrapper = $(this).parents('.accordion-container');
    var this_container = $(this).parent();
    if (!this_container.hasClass('accordion-active')) {
        this_wrapper.find('.accordion-item').removeClass('accordion-active');
        this_container.addClass('accordion-active');
    }
    else {
        this_container.removeClass('accordion-active');
    }
});
/* Duplicate functions (in other file)
//Watermark parallaxing on scroll
function netafimParallax() {
    var scrollAmount = $(window).scrollTop();
    var windowsize = $(window).width();
    //Only parallax on tablet landscape and higher
    if (windowsize >= 980) {
        $('.has-parallax').each(function () {
            var scrolled = (($(this).offset().top - scrollAmount) * 0.25) + 'px';
            $(this).css({ "transform": "translate(0," + scrolled + ")" });
        });
    }
    else {
        $('.has-parallax').each(function () {
            $(this).css({ "transform": "translate(0px,0px)" });
        });
    }
}
function verticalTextScroll() {
    if ($('.vertical-text').is(":visible")) {
        var scrollAmount = $(window).scrollTop();
        $('.vertical-text').each(function () {
            var this_container = $(this).parents('.component');
            var this_container_height = this_container.height();
            $(this).css("opacity", 1 - ((scrollAmount - (this_container.offset().top + this_container_height - 490)) / 200));
            if ((scrollAmount + 90 > this_container.offset().top) && (scrollAmount < this_container.offset().top + this_container_height - 300)) {
                $(this).addClass('fixed-top');
            } else {
                $(this).removeClass('fixed-top');
            }
        });
    }
}*/
function wowAnimate() {
    var scrollAmount = $(window).scrollTop();
    var mintranslateY = 0;
    var maxtranslateY = 15;
    $('div[class*="wow-animation"]').each(function () {
        var blockPosition = $(this).parents('.image-arrow').offset().top;
        var translateY = ((maxtranslateY - ((scrollAmount - (blockPosition - 900)) / 10)) < mintranslateY) ? mintranslateY : (maxtranslateY - ((scrollAmount - (blockPosition - 900)) / 10));
        $(this).css('opacity', ((scrollAmount - (blockPosition - 900)) / 200) - 1);
        $(this).find('.wow-icon').css({ "transform": "translateY(" + translateY + "px)" });
        if (scrollAmount > blockPosition - 500) {
            $(this).find('.wow-rada').addClass('animate');
        }
        else {
            $(this).find('.wow-rada').removeClass('animate');
        }
    });
}
function transparentImageAmimate() {
    var scrollAmount = $(window).scrollTop();
    $('.transparent-image').each(function () {
        var blockPosition = $(this).parents('.fluid-img').offset().top;
        $(this).css("opacity", ((scrollAmount - (blockPosition - 600)) / 300));
    });
}
function updateHeight(carousel) {
    $(carousel).find('.item').css('height', '');
    var maxHeight = 0;
    $(carousel).find('.item').each(function () {
        if ($(this).outerHeight() > maxHeight) {
            maxHeight = $(this).outerHeight();
        }
    });
    $(carousel).find('.item').css('height', maxHeight);
    console.log('height updated');
}
$(window).on('scroll', function () {
    netafimParallax();
    verticalTextScroll();
    wowAnimate();
    transparentImageAmimate();
});
$(window).on('resize', function () {
    netafimParallax();
    updateCarousel();
});
$(window).on('load', function () {
    $('.three-items-carousel-wrapper').each(function (index, carousel) {
        updateHeight(carousel);
    });
});
$('.carousel-wrapper').each(function (index, carousel) {
    carousel.defaultNumberOfItems = 5;
    carousel.itemWidth = $(this).find('.link-box-item').outerWidth(true);
    carousel.currentCarouselItem = 0;
    carousel.moveCarousel = function (itemWidth, currentCarouselItem) {
        var moveDistance = itemWidth * currentCarouselItem;
        $(carousel).find('.link-box-item').css('transform', 'translateX(' + -moveDistance + 'px)');
    };
    carousel.updateArrow = function () {
        if (carousel.currentCarouselItem === $(carousel).find('.link-box-item').length - carousel.defaultNumberOfItems) {
            $(carousel).find('.nav-arrow-right').addClass('disabled-arrow');
        }
        else {
            $(carousel).find('.nav-arrow-right').removeClass('disabled-arrow');
        }
        if (carousel.currentCarouselItem === 0) {
            $(carousel).find('.nav-arrow-left').addClass('disabled-arrow');
        }
        else {
            $(carousel).find('.nav-arrow-left').removeClass('disabled-arrow');
        }
    };
    carousel.updateArrow();
    if ($(carousel).find('.link-box-item').length <= carousel.defaultNumberOfItems) {
        $(carousel).find('.nav-arrow').addClass('hidden');
        $(carousel).find('.items-list').addClass('link-box');
    }
    else {
        $(carousel).find('.nav-arrow').removeClass('hidden');
        $(carousel).find('.items-list').removeClass('link-box');
    }
    $(carousel).find('.nav-arrow-right').on('click', function () {
        if (carousel.currentCarouselItem === $(carousel).find('.link-box-item').length - carousel.defaultNumberOfItems) {
            return;
        }
        carousel.currentCarouselItem++;
        carousel.moveCarousel(carousel.itemWidth, carousel.currentCarouselItem);
        carousel.updateArrow();
    });
    $(carousel).find('.nav-arrow-left').on('click', function () {
        if (carousel.currentCarouselItem === 0) {
            return;
        }
        carousel.currentCarouselItem--;
        carousel.moveCarousel(carousel.itemWidth, carousel.currentCarouselItem);
        carousel.updateArrow();
    });
});
$('.three-items-carousel-wrapper').each(function (index, carousel) {
    carousel.defaultNumberOfItems = 3;
    carousel.itemWidth = $(this).find('.item').width();
    carousel.currentCarouselItem = 0;
    carousel.moveCarousel = function (itemWidth, currentCarouselItem) {
        var moveDistance = itemWidth * currentCarouselItem;
        $(carousel).find('.item').css('transform', 'translateX(' + -moveDistance + 'px)');
    };
    carousel.updateArrow = function () {
        if (carousel.currentCarouselItem === $(carousel).find('.item').length - carousel.defaultNumberOfItems) {
            $(carousel).find('.nav-arrow-right').addClass('disabled-arrow');
        }
        else {
            $(carousel).find('.nav-arrow-right').removeClass('disabled-arrow');
        }
        if (carousel.currentCarouselItem === 0) {
            $(carousel).find('.nav-arrow-left').addClass('disabled-arrow');
        }
        else {
            $(carousel).find('.nav-arrow-left').removeClass('disabled-arrow');
        }
    };
    // updateHeight(carousel);
    carousel.updateArrow();
    if ($(carousel).find('.item').length <= carousel.defaultNumberOfItems) {
        $(carousel).find('.nav-arrow').addClass('hidden');
    }
    else {
        $(carousel).find('.nav-arrow').removeClass('hidden');
    }
    $(carousel).find('.nav-arrow-right').on('click', function () {
        if (carousel.currentCarouselItem === $(carousel).find('.item').length - carousel.defaultNumberOfItems) {
            return;
        }
        carousel.currentCarouselItem++;
        carousel.moveCarousel(carousel.itemWidth, carousel.currentCarouselItem);
        carousel.updateArrow();
    });
    $(carousel).find('.nav-arrow-left').on('click', function () {
        if (carousel.currentCarouselItem === 0) {
            return;
        }
        carousel.currentCarouselItem--;
        carousel.moveCarousel(carousel.itemWidth, carousel.currentCarouselItem);
        carousel.updateArrow();
    });
});
function updateCarousel() {
    $('.carousel-wrapper').each(function (index, carousel) {
        carousel.itemWidth = $(carousel).find('.link-box-item').outerWidth(true);
        carousel.moveCarousel(carousel.itemWidth, carousel.currentCarouselItem);
    });
    $('.three-items-carousel-wrapper').each(function (index, carousel) {
        carousel.itemWidth = $(carousel).find('.item').outerWidth(true);
        carousel.moveCarousel(carousel.itemWidth, carousel.currentCarouselItem);
        updateHeight(carousel);
    });
}
$('.icon-show-img').on('click', function (e) {
    $(_this).toggleClass('active');
    if ($(window).width() < 1023) {
        if ($(_this).hasClass('active')) {
            $('body').css('overflow-y', 'hidden');
        }
        else {
            $('body').css('overflow-y', 'auto');
        }
    }
});
function startsWith(str, word) {
    return str.lastIndexOf(word, 0) === 0;
}
//# sourceMappingURL=basic.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var headerSearchInput = '[data-js="input-header-search"]';
        var headerSearchButton = '[data-js="btn-header-search"]';
        var NewHeader = /** @class */ (function () {
            function NewHeader(jqueryElement, params) {
                this.jqueryElement = jqueryElement;
                this.parameters = params;
                this.eventHandlers();
            }
            NewHeader.prototype.eventHandlers = function () {
                var _this = this;
                $('.js-toggle-search').on('click', function () {
                    $('.js-search').toggleClass('is-active');
                    $(this).toggleClass('is-active');
                    // close navigation
                    $('.js-nav-wrapper').removeClass('is-active');
                    $('.js-toggle-nav').removeClass('is-active');
                    $(".js-doormat").removeClass("is-active");
                    $('.js-header').removeClass('is-open');
                });
                $(headerSearchButton).on('click', function (e) {
                    e.preventDefault();
                    var searchText = $(headerSearchInput).val();
                    var url = _this.parameters.searchPageUrl + "?searchText=" + searchText;
                    window.location.href = url;
                });
                $('.js-toggle-nav').on('click', function () {
                    $('.js-nav-wrapper').toggleClass('is-active');
                    $(this).toggleClass('is-active');
                    $(".js-doormat").removeClass("is-active");
                    $('.js-header').toggleClass('is-open');
                    // close search
                    $('.js-search').removeClass('is-active');
                    $('.js-toggle-search').removeClass('is-active');
                });
                $(window).resize(function () {
                    if ($('.js-header').outerWidth() >= 1200) {
                        updateHeaderHeight();
                    }
                });
                if ($('.js-header').outerWidth() <= 1199) {
                    $('.js-doormat-tab').removeClass('is-active');
                    $('.js-toggle-doormat').on('click', function (e) {
                        e.preventDefault();
                        $(this).closest('.js-doormat').toggleClass('is-active').siblings().removeClass('is-active');
                        return false;
                    });
                    $('.js-toggle-doormat-tab').on('click', function () {
                        $(this).closest('.js-doormat-tab').toggleClass('is-active').siblings().removeClass('is-active');
                    });
                }
                else {
                    updateHeaderHeight();
                    $(window).scroll(function () {
                        var scroll = $(window).scrollTop();
                        if (scroll >= 30) {
                            $(".js-header").addClass("is-scrolled");
                        }
                        else {
                            $(".js-header").removeClass("is-scrolled");
                        }
                    });
                    $('.js-toggle-doormat-tab').on('mouseover', function () {
                        $(this).parent('.js-doormat-tab').addClass('is-active').siblings().removeClass('is-active');
                    });
                    $('.c-doormat--products').on('mouseleave', function () {
                        $(this).find('.is-active').removeClass('is-active');
                        $($(this).find('.js-doormat-tab')[0]).addClass('is-active');
                    });
                }
                function updateHeaderHeight() {
                    document.documentElement.style.setProperty('--brand__wrapper-offset--padding-top', $('.js-header').outerHeight() + "px");
                }
            };
            return NewHeader;
        }());
        Web.NewHeader = NewHeader;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=NewHeader.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var HotspotSystem = /** @class */ (function () {
            function HotspotSystem(jqueryElement) {
                var css_string = '<style type="text/css">@media (min-width: 1024px){';
                $('.c-hotspot__item', jqueryElement).each(function () {
                    var img_width = $(this).parent().find('.c-hotspot__image-bg').data('width');
                    var img_height = $(this).parent().find('.c-hotspot__image-bg').data('height');
                    if ($(this).data('x') < (img_width - 140)) {
                        css_string += '#' + $(this).attr('id') + '{top:calc(' + $(this).data('y') / img_height * 100 + '% - 17px);left:calc(' + $(this).data('x') / img_width * 100 + '% - 17px);}';
                    }
                    else {
                        css_string += '#' + $(this).attr('id') + '{top:calc(' + $(this).data('y') / img_height * 100 + '% - 17px);left:calc(100% - 140px);}';
                    }
                });
                $('.c-hotspot__link', jqueryElement).each(function () {
                    var img_width = $(this).parent().find('.c-hotspot__image-bg').data('width');
                    var img_height = $(this).parent().find('.c-hotspot__image-bg').data('height');
                    css_string += '#' + $(this).attr('id') + '{top:calc(' + $(this).data('y') / img_height * 100 + '% - 28px);left:calc(' + $(this).data('x') / img_width * 100 + '% - 28px);}';
                });
                $('.c-hotspot__link:odd', jqueryElement).addClass("delay-animation");
                $('.c-hotspot__item:odd', jqueryElement).addClass("delay-animation");
                css_string += "}</style>";
                $(css_string).appendTo("head");
                //We need to disable "overflow" of the component container
                $('.c-hotspot', jqueryElement).parents('.component').css('overflow', 'visible');
                //Click to toggle hotspot-desc
                $('.c-hotspot__item', jqueryElement).on('click', function (e) {
                    if ($(e.target).parent().addBack().is('.c-hotspot-item__desc')) {
                        e.stopPropagation();
                    }
                    else {
                        if ($(this).hasClass('hotspot-selected')) {
                            e.stopPropagation();
                        }
                        else {
                            $('.hotspot-selected').removeClass('hotspot-selected');
                            $(this).addClass('hotspot-selected');
                            var max_width = $(this).closest('.c-hotspot').width() - 140;
                            var max_height = parseInt($(this).parent().find('.c-hotspot__image-bg').data('height')) / 2;
                            //Check position to avoid hiding .hotspot-desc
                            if ($(this).offset().left <= 180) {
                                $(this).find('.c-hotspot-item__desc').css('left', 0);
                            }
                            if ($(this).data('x') >= max_width) {
                                $(this).find('.c-hotspot-item__desc').css('right', 0);
                                $(this).find('.c-hotspot-item__desc').css('left', 'auto');
                            }
                            //Setup arrow-up or arrow-down
                            if ($(this).data('y') <= max_height) {
                                $(this).find('.c-hotspot-item__desc').addClass('arrow-up');
                            }
                            else {
                                $(this).find('.c-hotspot-item__desc').addClass('arrow-down');
                            }
                        }
                    }
                });
                $('.c-hotspot__item .c-hotspot-item__desc .btn-close').on('click', function () {
                    $(this).parents('.c-hotspot__item').removeClass('hotspot-selected');
                });
            }
            return HotspotSystem;
        }());
        Web.HotspotSystem = HotspotSystem;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=HotspotSystem.js.map;
function showSpinner(spinnerId) {
    $("#"+spinnerId).show();
}

$("button[data-behavior='show-spinner']").click(function(e) {
    var loaderId = e.target.id.replace("btn", "spinner");
    showSpinner(loaderId);
});;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var InlinePdf = /** @class */ (function () {
            function InlinePdf(jqueryElement, params) {
                var _this = this;
                this.jqueryElement = jqueryElement;
                this.params = params;
                this.iframe = jqueryElement.find("#" + this.params.iframeId + "").get(0);
                var querystringKey = "file";
                this.focusOnCurrentFileButton(querystringKey, jqueryElement);
                jqueryElement.on("click", "[data-js-pdf-url]", function (e) {
                    var pdfUrl = $(e.currentTarget).attr("data-js-pdf-url");
                    var pdfId = $(e.currentTarget).attr("data-js-pdf-id");
                    _this.setParameter(querystringKey, pdfId);
                    loadPdf(pdfUrl);
                });
                jqueryElement.on("click", "a[target='pdf-renderer']", function (e) {
                    var pdfId = $(e.currentTarget).attr("data-js-pdf-id");
                    _this.setParameter(querystringKey, pdfId);
                    var pdfUrlFull = $(e.currentTarget).prop("href");
                    var pdfUrlParts = pdfUrlFull.split("#");
                    var pdfUrl = pdfUrlParts[0];
                    var pdfAnchor = pdfUrlParts.length === 2 ? pdfUrlParts[1] : "";
                    loadPdf(pdfUrl, pdfAnchor);
                });
                var loadPdf = function (pdfUrl, pdfAnchor) {
                    // If we request pdf that's already loaded, iframe won't update due to same url (without anchor)
                    // We fix this by adding a random querystring
                    if (_this.loadedPdf === pdfUrl) {
                        pdfUrl = pdfUrl + "?update=" + new Date().getTime() + "#" + pdfAnchor;
                    }
                    _this.iframe.contentWindow.location.href = pdfUrl;
                    _this.loadedPdf = pdfUrl;
                };
            }
            InlinePdf.prototype.setParameter = function (key, value) {
                // Construct URLSearchParams object instance from current URL querystring.
                var queryParams = new URLSearchParams(window.location.search);
                // Set new or modify existing parameter value. 
                queryParams.set(key, value);
                // Replace current querystring with the new one.
                history.replaceState(null, null, "?" + queryParams.toString());
            };
            InlinePdf.prototype.getParameter = function (key) {
                var queryParams = new URLSearchParams(window.location.search);
                return queryParams.get(key);
            };
            InlinePdf.prototype.focusOnCurrentFileButton = function (querystringKey, jqueryElement) {
                var currentFileId = this.getParameter(querystringKey);
                if (currentFileId !== null) {
                    jqueryElement.find("[data-js-pdf-id=" + currentFileId + "]").focus();
                }
            };
            return InlinePdf;
        }());
        Web.InlinePdf = InlinePdf;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=InlinePdf.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var JobFilter = /** @class */ (function () {
            function JobFilter(jqueryElement, parameter) {
                this.params = parameter;
                var self = this;
                //Job over-view
                $('.FormSelection select', jqueryElement).on('change', function () {
                    self.searchJobs(jqueryElement);
                });
            }
            JobFilter.prototype.getLocation = function (jqueryElement) {
                var seletedLocation = $('.FormSelection select.location', jqueryElement).val();
                if (seletedLocation)
                    return seletedLocation;
                return "";
            };
            JobFilter.prototype.getDepartment = function (jqueryElement) {
                var selectedDepartment = $('.FormSelection select.department', jqueryElement).val();
                if (selectedDepartment)
                    return selectedDepartment;
                return "";
            };
            JobFilter.prototype.searchJobs = function (jqueryElement) {
                $.ajax({
                    type: 'POST',
                    url: this.params.searchUrl,
                    data: {
                        "department": this.getDepartment(jqueryElement),
                        "location": this.getLocation(jqueryElement),
                        "blockId": this.params.blockId
                    },
                    dataType: 'html',
                    success: function (data) {
                        $(".data-result", jqueryElement).html(data);
                    }
                });
            };
            return JobFilter;
        }());
        Web.JobFilter = JobFilter;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=JobFilter.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var LifeCycle = /** @class */ (function () {
            function LifeCycle() {
                this.eventHandlers();
            }
            LifeCycle.prototype.eventHandlers = function () {
                var $readMore = jQuery('.js-lifecycle-item').find('.js-read-more-btn');
                jQuery($readMore).off().on("click", function (e) {
                    jQuery(e.currentTarget).parent().parent().find('.c-lifecycle-content-item-info-heading__text').toggleClass("u-hide");
                });
                var $readMoreLinkMobile = jQuery('.js-lifecycle-item').find('.js-mobile-read-more-link');
                jQuery($readMoreLinkMobile).off().on("click", function (e) {
                    jQuery(e.currentTarget).parent().addClass("u-hide");
                    jQuery(e.currentTarget).parent().parent().find(".js-lifecycle-mobile-text-long").addClass("u-show");
                });
            };
            return LifeCycle;
        }());
        Web.LifeCycle = LifeCycle;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=LifeCycle.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var MediaCarousel = /** @class */ (function () {
            function MediaCarousel(jqueryElement) {
                //Media carousel
                //Only generate carousel controllers when there are more than ONE .media-carousel-item
                function generateCarouselNavigation(target_wrapper) {
                    var newHtml = '';
                    $(target_wrapper).find('.media-carousel-item').each(function () {
                        newHtml += $(this).clone().wrap('<div/>').parent().html();
                    });
                    newHtml += $(target_wrapper).find('.carousel-controller').clone().wrap('<div/>').parent().html();
                    newHtml += $(target_wrapper).find('.carousel-navigation').clone().wrap('<div/>').parent().html();
                    $(target_wrapper).html(newHtml);
                    var number_of_dots = $(target_wrapper).find('.media-carousel-item').length;
                    $(target_wrapper).find('.media-carousel-item').first().addClass('carousel-active');
                    //If the first item has an auto-play video
                    var first_active_item = $(target_wrapper).find('.media-carousel-item.carousel-active');
                    if (!$(target_wrapper).find('.carousel-controller').find('.btn-carousel-prev').is(':visible')) {
                        if (first_active_item.attr("data-video-auto-play") === "true") {
                            first_active_item.find('video').show().trigger("play");
                            first_active_item.find('.btn-play').hide();
                            if (first_active_item.attr("data-show-text-onplay") === "true") {
                                first_active_item.find('.media-carousel-content').removeClass('inactive');
                                first_active_item.find('.media-carousel-title').show();
                                first_active_item.find('.media-description').show();
                            }
                            else {
                                first_active_item.find('.media-carousel-content').addClass('inactive');
                                first_active_item.find('.media-carousel-title').hide();
                                first_active_item.find('.media-description').hide();
                            }
                        }
                    }
                    if (number_of_dots > 1) {
                        $(target_wrapper).find('.carousel-dot span').hover(function () {
                            $(this).find('img').attr('src', $(this).find('img').attr('data-img'));
                        });
                        $(target_wrapper).find('.sliding-dots').css('height', number_of_dots * 100);
                        $(target_wrapper).find('.sliding-item .carousel-extra').html($(target_wrapper).find('.media-carousel-item').first().find('.carousel-extra-content').html());
                        $(target_wrapper).find('.carousel-dot').on('click', function () {
                            $(target_wrapper).find('.banner-bg').each(function (index) {
                                $(this).attr('style', 'background-image: url(' + $(this).attr('data-img') + ')');
                            });
                            $(target_wrapper).find('.video-container img').each(function (index) {
                                $(this).attr('src', $(this).attr('data-img'));
                            });
                            $(target_wrapper).find('.video-container video').each(function (index) {
                                $(this).attr('poster', $(this).attr('data-img'));
                            });
                            $('.fluid-img', jqueryElement).each(function () {
                                $(this).css('background-image', 'url(' + $(this).find('img').attr('data-img') + ')');
                            });
                            $('.fluid-video', jqueryElement).each(function () {
                                $(this).css('background-image', 'url(' + $(this).find('img').attr('data-img') + ')');
                            });
                            $(target_wrapper).find('.fluid-img img').each(function (index) {
                                $(this).attr('src', $(this).attr('data-img'));
                            });
                            $(target_wrapper).find('.sliding-item .carousel-extra').html('');
                            var pos_top = $(this).position().top;
                            var current_index = $(this).index() - 1;
                            var selected_carousel_item = $(target_wrapper).find('.media-carousel-item:eq(' + current_index + ')').find('.carousel-extra-content').html();
                            $(target_wrapper).find('.sliding-item').css('top', pos_top);
                            $(target_wrapper).find('.sliding-item .carousel-extra').html(selected_carousel_item);
                            $(target_wrapper).find('.media-carousel-item.carousel-active').removeClass('carousel-active');
                            $(target_wrapper).find('.media-carousel-item:eq(' + current_index + ')').addClass('carousel-active');
                            $(target_wrapper).find('.media-carousel-item video').trigger('pause');
                            //If autoplay attribute is set
                            if ($(target_wrapper).find('.media-carousel-item.carousel-active').attr("data-video-auto-play") === "true") {
                                $(target_wrapper).find('.media-carousel-item.carousel-active video').show().trigger("play");
                                if ($(target_wrapper).find('.media-carousel-item.carousel-active').attr("data-show-text-onplay") === "true") {
                                    $(target_wrapper).find('.media-carousel-item.carousel-active .btn-play').hide();
                                    $(target_wrapper).find('.media-carousel-item.carousel-active .media-carousel-title').show();
                                    $(target_wrapper).find('.media-carousel-item.carousel-active .media-carousel-content').removeClass('inactive');
                                    $(target_wrapper).find('.media-carousel-item.carousel-active .media-description').show();
                                }
                                else {
                                    $(target_wrapper).find('.media-carousel-item.carousel-active .btn-play').hide();
                                    $(target_wrapper).find('.media-carousel-item.carousel-active .media-carousel-title').hide();
                                    $(target_wrapper).find('.media-carousel-item.carousel-active .media-carousel-content').addClass('inactive');
                                    $(target_wrapper).find('.media-carousel-item.carousel-active .media-description').hide();
                                }
                            }
                            else {
                                $(target_wrapper).find('.media-carousel-item.carousel-active video').trigger("pause");
                                $(target_wrapper).find('.media-carousel-item.carousel-active .btn-play').show();
                                $(target_wrapper).find('.media-carousel-item.carousel-active .media-carousel-title').show();
                                $(target_wrapper).find('.media-carousel-item.carousel-active .media-carousel-content').removeClass('inactive');
                            }
                        });
                        $(target_wrapper).find('.carousel-controller').find('.btn-carousel-prev').on('click', function () {
                            $(target_wrapper).find('.banner-img').each(function (index) {
                                $(this).attr('src', $(this).attr('data-img') + ')');
                            });
                            $(target_wrapper).find('.video-container img').each(function (index) {
                                $(this).attr('src', $(this).attr('data-img'));
                            });
                            $(target_wrapper).find('.video-container video').each(function (index) {
                                $(this).attr('poster', $(this).attr('data-img'));
                            });
                            $(target_wrapper).find('.fluid-img img').each(function (index) {
                                $(this).attr('src', $(this).attr('data-img'));
                            });
                            var current_item_index = $(target_wrapper).find('.media-carousel-item.carousel-active').index();
                            if (current_item_index === 0) {
                                current_item_index = number_of_dots - 1;
                            }
                            else {
                                current_item_index = current_item_index - 1;
                            }
                            $(target_wrapper).find('.media-carousel-item.carousel-active').removeClass('carousel-active');
                            $(target_wrapper).find('.media-carousel-item:eq(' + current_item_index + ')').addClass('carousel-active');
                            $(target_wrapper).find('.media-carousel-item video').trigger('pause');
                            $(target_wrapper).find('.media-carousel-item.carousel-active video').hide();
                            $(target_wrapper).find('.media-carousel-item.carousel-active img.banner-img').show();
                            $(target_wrapper).find('.media-carousel-item.carousel-active .media-container .banner-bg').show();
                            $(target_wrapper).find('.media-carousel-item.carousel-active .fluid-video img').show();
                            $(target_wrapper).find('.media-carousel-item.carousel-active .video-control-play').show();
                            $(target_wrapper).find('.media-carousel-item.carousel-active .media-carousel-content').removeClass('inactive');
                        });
                        $(target_wrapper).find('.carousel-controller').find('.btn-carousel-next').on('click', function () {
                            $(target_wrapper).find('.banner-img').each(function (index) {
                                $(this).attr('src', $(this).attr('data-img') + ')');
                            });
                            $(target_wrapper).find('.video-container img').each(function (index) {
                                $(this).attr('src', $(this).attr('data-img'));
                            });
                            $(target_wrapper).find('.fluid-img img').each(function (index) {
                                $(this).attr('src', $(this).attr('data-img'));
                            });
                            var current_item_index = $(target_wrapper).find('.media-carousel-item.carousel-active').index();
                            if (current_item_index === (number_of_dots - 1)) {
                                current_item_index = 0;
                            }
                            else {
                                current_item_index = current_item_index + 1;
                            }
                            $(target_wrapper).find('.media-carousel-item.carousel-active').removeClass('carousel-active');
                            $(target_wrapper).find('.media-carousel-item:eq(' + current_item_index + ')').addClass('carousel-active');
                            $(target_wrapper).find('.media-carousel-item video').trigger('pause');
                            $(target_wrapper).find('.media-carousel-item.carousel-active video').hide();
                            $(target_wrapper).find('.media-carousel-item.carousel-active img.banner-img').show();
                            $(target_wrapper).find('.media-carousel-item.carousel-active .media-container .banner-bg').show();
                            $(target_wrapper).find('.media-carousel-item.carousel-active .fluid-video img').show();
                            $(target_wrapper).find('.media-carousel-item.carousel-active .video-control-play').show();
                            $(target_wrapper).find('.media-carousel-item.carousel-active .media-carousel-content').removeClass('inactive');
                        });
                    }
                    else {
                        $(target_wrapper).find('.carousel-navigation').hide();
                        $(target_wrapper).find('.carousel-controller').hide();
                    }
                    //Update video scale on IE
                    var ua = window.navigator.userAgent;
                    var trident = ua.indexOf('Trident/');
                    var edge = ua.indexOf('Edge/');
                    var _windowRatio = $(window).width() / $(window).height();
                    if (trident > 0 || edge > 0) {
                        // IE 11
                        $(target_wrapper).find('.media-carousel-item').each(function () {
                            var _video = $(this).find('video');
                            if ($(target_wrapper).hasClass('hero-banner')) {
                                _video.on('loadedmetadata', function () {
                                    var _videoRatio = this.videoWidth / this.videoHeight;
                                    if (_videoRatio >= _windowRatio) {
                                        $(this).css('height', $(window).height());
                                    }
                                    else {
                                        $(this).css('width', $(window).width());
                                    }
                                });
                            }
                            else {
                                _video.on('loadedmetadata', function () {
                                    var _videoRatio = this.videoWidth / this.videoHeight;
                                    var _videoContainerWidth = $(this).parent().width();
                                    var _videoContainerHeight = $(this).parent().height();
                                    var _carouselRatio = _videoContainerWidth / _videoContainerHeight;
                                    $(this).css('position', 'absolute');
                                    $(this).css('z-index', 0);
                                    $(this).css('height', 'auto');
                                    if (_videoRatio >= _carouselRatio) {
                                        $(this).css('height', _videoContainerHeight);
                                    }
                                    else {
                                        $(this).css('width', _videoContainerWidth);
                                    }
                                });
                            }
                        });
                    }
                }
                generateCarouselNavigation($('.media-carousel-wrapper', jqueryElement));
                $('video').on('play', (function () {
                    var activeItem = $(this).parents('.media-carousel-item.carousel-active');
                    if (activeItem.attr("data-show-text-onplay") === "true") {
                        activeItem.find('.media-description').show();
                    }
                    else {
                        activeItem.find('.media-description').hide();
                    }
                }));
                $('.btn-play', jqueryElement).on('click', function () {
                    $(this).hide();
                    var activeItem = $(this).parents('.media-carousel-item.carousel-active');
                    if (activeItem.attr("data-show-text-onplay") === "true") {
                        activeItem.find('.video-container img').hide();
                        activeItem.find('video').show();
                        activeItem.find('video').trigger('play');
                        activeItem.find('.media-carousel-title').show();
                        activeItem.find('.media-carousel-content').removeClass('inactive');
                    }
                    else {
                        activeItem.find('.video-container img').hide();
                        activeItem.find('video').show();
                        activeItem.find('video').trigger('play');
                        activeItem.find('.media-carousel-title').hide();
                        activeItem.find('.media-carousel-content').addClass('inactive');
                    }
                });
                $('.video-control-play', jqueryElement).on('click', function () {
                    $(this).hide();
                    //For richtext component
                    if ($(this).parents('.media-carousel-item').length) {
                        var activeItem = $(this).parents('.media-carousel-item.carousel-active');
                        activeItem.find('.video-container img').hide();
                        activeItem.find('video').show();
                        activeItem.find('.media-carousel-content').show();
                        activeItem.find('video').trigger('play');
                        activeItem.find('.media-carousel-title').hide();
                    }
                    else {
                        //For media-carousel-item
                        var fluidVideo = $(this).parents('.fluid-video');
                        fluidVideo.find('img').hide();
                        fluidVideo.find('video').css('position', 'relative').show();
                        fluidVideo.find('video').trigger('play');
                    }
                });
                // animation
                function heroBannerAnimate() {
                    var scrollAmount = $(window).scrollTop();
                    var maxBgPositionY = 100;
                    var maxtranslateX = 40;
                    var maxtranslateY = 10;
                    var bgPositionY = ((scrollAmount / 5) > maxBgPositionY) ? maxBgPositionY : (scrollAmount / 5);
                    var translateX = ((scrollAmount / 12.5) > maxtranslateX) ? maxtranslateX : (scrollAmount / 12.5);
                    var translateY = ((scrollAmount / 40) > maxtranslateY) ? maxtranslateY : (scrollAmount / 40);
                    $('.hero-banner', jqueryElement).find('.banner-bg').each(function () {
                        $(this).css({ "background-position-y": (bgPositionY) + "%" });
                    });
                    $('.hero-banner', jqueryElement).find('.line-up').each(function () {
                        $(this).css({ "transform": "translateX(" + -translateX + "px)" });
                    });
                    $('.hero-banner', jqueryElement).find('.line-down').each(function () {
                        $(this).css({ "transform": "translateX(" + translateX + "px)" });
                    });
                    $('.hero-banner', jqueryElement).find('.media-description').each(function () {
                        $(this).css({ "top": (55 + translateY + "%") });
                    });
                    $('.hero-banner', jqueryElement).find('.netafim-btn').each(function () {
                        $(this).css({ "transform": "translateX(" + translateX + "px)" });
                    });
                }
                // collapse / expand media carousel
                var restrictedHeightElement = $('.restricted-height', jqueryElement);
                restrictedHeightElement.find('.btn-play').on('click', function () {
                    var mediaCarouselItem = $(this).closest('.media-carousel-item');
                    mediaCarouselItem.removeClass("video-paused");
                    var original = mediaCarouselItem.find('video')[0];
                    var originalWidth = original.videoWidth;
                    var originalHeight = original.videoHeight;
                    var currentWidth = mediaCarouselItem.find('video').width();
                    var fullHeight = currentWidth * originalHeight / originalWidth;
                    mediaCarouselItem.find('.media-carousel-bg').height(fullHeight);
                    mediaCarouselItem.find('.pause-and-collapse').addClass('active');
                });
                restrictedHeightElement.find('.pause-and-collapse').on('click', function () {
                    $(this).removeClass('active');
                    var mediaCarouselItem = $(this).closest('.media-carousel-item');
                    mediaCarouselItem.addClass("video-paused");
                    mediaCarouselItem.find('.media-carousel-bg').height('');
                    mediaCarouselItem.find('video').trigger('pause');
                    mediaCarouselItem.find('.media-carousel-content').removeClass('inactive');
                    mediaCarouselItem.find('.btn-play').show();
                });
                restrictedHeightElement.find('.carousel-dot').on('click', function () {
                    var mediaCarouselWrapper = $(this).closest('.media-carousel-wrapper');
                    mediaCarouselWrapper.find('.media-carousel-bg').height('');
                    mediaCarouselWrapper.find('.pause-and-collapse').removeClass('active');
                });
                $(window).on('scroll', function () {
                    if (window.innerWidth >= 1024) {
                        heroBannerAnimate();
                    }
                });
            }
            return MediaCarousel;
        }());
        Web.MediaCarousel = MediaCarousel;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=MediaCarousel.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var ScrollDown = /** @class */ (function () {
            function ScrollDown(jqueryElement) {
                $(jqueryElement).find("[data-js=scrollDown]").click(function () {
                    var nextSibling = $(jqueryElement).parent("section").parent().parent().next();
                    //36 -> negative top in css
                    var scroll = $(nextSibling).offset().top - $("nav").height() + 36;
                    $('html, body').animate({
                        scrollTop: scroll
                    }, 1000);
                });
            }
            return ScrollDown;
        }());
        Web.ScrollDown = ScrollDown;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=ScrollDown.js.map;
var close = document.getElementsByClassName("closebtn");
var i;

for (i = 0; i < close.length; i++) {
    close[i].onclick = function () {
        var div = this.parentElement;
        div.style.opacity = "0";
        setTimeout(function () { div.style.display = "none"; }, 600);
    }
};
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var SidebarNavigation = /** @class */ (function () {
            function SidebarNavigation() {
                this.eventHandlers();
            }
            SidebarNavigation.prototype.eventHandlers = function () {
                $('.js-toggle-floating-nav').on('click', function (e) {
                    console.log("toggled sidebar navigation");
                    e.preventDefault();
                    $('.js-floating-nav').toggleClass('is-open');
                    return false;
                });
            };
            return SidebarNavigation;
        }());
        Web.SidebarNavigation = SidebarNavigation;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=SidebarNavigation.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var NewsOverview = /** @class */ (function () {
            function NewsOverview(jqueryElement, parameter) {
                this.params = parameter;
                var self = this;
                $('.accordion-container .accordion-item .accordion-item-title', jqueryElement).on('click', function (e) {
                    var this_container = $(this).parent('.accordion-item');
                    var this_contentItem = $(this).siblings('.result');
                    if (!self.alreadyLoaded(this_contentItem)) {
                        // load news item.
                        self.searchNewsPages(this_container);
                    }
                });
                //Accordion menu
                $('.accordion-container .accordion-item .accordion-item-title', jqueryElement).on('click', function (e) {
                    e.preventDefault();
                    var this_wrapper = $(this).parents('.accordion-container');
                    var this_container = $(this).parent();
                    if (this_container.hasClass('accordion-active')) {
                        this_wrapper.find('.accordion-item').removeClass('accordion-active');
                        this_container.addClass('accordion-active');
                    }
                });
                $('.accordion-container .accordion-item .accordion-item-title', jqueryElement).on('click', function () {
                    $(this).parent().toggleClass('accordion-active');
                    $(this).parent().siblings().removeClass('accordion-active');
                });
            }
            NewsOverview.prototype.alreadyLoaded = function (this_contentItem) {
                return $('.accordion-item-content', $(this_contentItem)).length > 0;
            };
            NewsOverview.prototype.searchNewsPages = function (container) {
                $.ajax({
                    type: 'POST',
                    url: this.params.loadNewsUrl,
                    data: {
                        "blockId": this.params.blockId,
                        "year": $(container).attr('data-value')
                    },
                    dataType: 'html',
                    success: function (res) {
                        $(".data-result", container).html(res);
                    }
                });
            };
            return NewsOverview;
        }());
        Web.NewsOverview = NewsOverview;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=NewsOverview.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var OfficeLocator = /** @class */ (function () {
            function OfficeLocator(jqueryElement, parm) {
                this.ICON_BASE_URL = '/Content/images/';
                this.icon_email = this.ICON_BASE_URL + 'icon-mail.png';
                this.icon_website = this.ICON_BASE_URL + 'icon-globe.png';
                this.icon_direction = this.ICON_BASE_URL + 'icon-directions.png';
                this.params = parm;
                this.jqueryElement = jqueryElement;
                this.notNeedRenderForMobile = true;
                this.registerEvents();
                this.loadOffices({});
            }
            OfficeLocator.prototype.initMap = function (lat, lng) {
                var netafim_map_style = [
                    { "featureType": "administrative", "elementType": "labels.text.fill", "stylers": [{ "color": "#444444" }] },
                    { "featureType": "landscape", "elementType": "all", "stylers": [{ "color": "#f2f2f2" }] },
                    { "featureType": "poi", "elementType": "all", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "road", "elementType": "all", "stylers": [{ "saturation": -100 }, { "lightness": 45 }] },
                    { "featureType": "road.highway", "elementType": "all", "stylers": [{ "visibility": "simplified" }] },
                    { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [{ "color": "#ffffff" }] },
                    { "featureType": "road.arterial", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "transit", "elementType": "all", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "water", "elementType": "all", "stylers": [{ "color": "#dde6e8" }, { "visibility": "on" }] }
                ];
                lat = lat || 59.325;
                lng = lng || 18.070;
                //Creating a new maps
                var opt = {
                    center: { lat: lat, lng: lng },
                    clickableIcons: true,
                    keyboardShortcuts: false,
                    fullscreenControlOptions: false,
                    zoom: 13,
                    minZoom: 3,
                    maxZoom: 13,
                    streetViewControl: false,
                    disableDefaultUI: true,
                    mapTypeControl: false,
                    scaleControl: false,
                    zoomControl: true,
                    draggable: true,
                    scrollwheel: false,
                    styles: netafim_map_style
                };
                var map = new google.maps.Map(document.getElementById("netafim-map"), opt);
                return map;
            };
            OfficeLocator.prototype.loadOffices = function (query) {
                var self = this;
                $.ajax({
                    type: "POST",
                    url: this.params.searchOfficesUrl,
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(query),
                    success: function (data) {
                        self.populateOffices(data, query.Latitude, query.Longitude);
                    }
                });
            };
            OfficeLocator.prototype.populateOffices = function (data, lat, lng) {
                var offices = $.parseJSON(data);
                var map = this.initMap(lat, lng);
                var bounds = new google.maps.LatLngBounds();
                $('.netafim-map-result').html('');
                //Adding Markers to the existing maps
                for (var i = 0, length = offices.length; i < length; i++) {
                    var office = offices[i];
                    this.createMaker(office, map, bounds);
                    if (!this.notNeedRenderForMobile) // Add to mobile map
                        $('.netafim-map-result').append(this.resultBox(office.officeName, office.address, office.phone, office.fax, office.email, office.website, office.direction));
                }
                if (this.notNeedRenderForMobile)
                    this.notNeedRenderForMobile = false;
                if (offices.length <= 0) // update fitbound
                 {
                    // Add no result to the result for mobile mode
                    $('.netafim-map-result').append($('.no-result-wrapper', this.jqueryElement).html());
                    var position = new google.maps.LatLng(lat, lng);
                    bounds.extend(position);
                }
                map.fitBounds(bounds);
                if (offices.length <= 1) {
                    map.setZoom(5);
                }
                this.setControlState(lat && lng);
            };
            OfficeLocator.prototype.createMaker = function (office, map, bounds) {
                var _this = this;
                var position = new google.maps.LatLng(office.latitude, office.longitude);
                var options = {
                    position: position,
                    map: map,
                    icon: this.ICON_BASE_URL + 'icon-pin.png',
                    animation: google.maps.Animation.DROP,
                    title: office.title
                };
                var infoWindow = new google.maps.InfoWindow();
                var marker = new google.maps.Marker(options);
                bounds.extend(position);
                var content = this.infoBox(office.officeName, office.address, office.phone, office.fax, office.email, office.website, office.direction);
                google.maps.event.addListener(marker, 'click', (function (marker, content, infoWindow) {
                    if (infoWindow)
                        infoWindow.close();
                    return function () {
                        infoWindow.setContent(content);
                        if (_this.prevInfoWindow != null) {
                            _this.prevInfoWindow.close();
                        }
                        infoWindow.open(map, marker);
                        _this.prevInfoWindow = infoWindow;
                        google.maps.event.addListener(map, 'click', function () {
                            if (infoWindow)
                                infoWindow.close();
                        });
                    };
                })(marker, content, infoWindow));
            };
            OfficeLocator.prototype.registerEvents = function () {
                var self = this;
                var input = document.getElementById('search-location');
                var searchBox = new google.maps.places.SearchBox(input);
                searchBox.addListener('places_changed', function () {
                    var places = searchBox.getPlaces();
                    if (places && places.length > 0) {
                        var latlng = { Latitude: places[0].geometry.location.lat(), Longitude: places[0].geometry.location.lng() };
                        self.parseCountryAndLoadOffice(latlng);
                        self.gtmTracking(places[0].formatted_address);
                    }
                });
                $('#btn-clear-search').on('click', function () {
                    self.notNeedRenderForMobile = true;
                    self.loadOffices({});
                });
            };
            OfficeLocator.prototype.setControlState = function (enableClearButton) {
                if (enableClearButton) {
                    $("#btn-clear-search").show();
                }
                else {
                    $("#btn-clear-search").hide();
                    $("#search-location").val('');
                }
            };
            OfficeLocator.prototype.extractHostname = function (url) {
                var hostname;
                //find & remove protocol (http, ftp, etc.) and get hostname
                if (url.indexOf("://") > -1) {
                    hostname = url.split('/')[2];
                }
                else {
                    hostname = url.split('/')[0];
                }
                //find & remove port number
                hostname = hostname.split(':')[0];
                //find & remove "?"
                hostname = hostname.split('?')[0];
                return hostname;
            };
            // To address those who want the "root domain," use this function:
            OfficeLocator.prototype.extractRootDomain = function (url) {
                var domain = this.extractHostname(url), splitArr = domain.split('.'), arrLen = splitArr.length;
                //extracting the root domain here
                //if there is a subdomain 
                if (arrLen > 2) {
                    domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1];
                    //check to see if it's using a Country Code Top Level Domain (ccTLD) (i.e. ".me.uk")
                    if (splitArr[arrLen - 2].length == 2 && splitArr[arrLen - 1].length == 2) {
                        //this is using a ccTLD
                        domain = splitArr[arrLen - 3] + '.' + domain;
                    }
                }
                return domain;
            };
            OfficeLocator.prototype.infoBox = function (title, address, tel, fax, email, website, direction) {
                var html = '<div class="map-popup-container">';
                if (this.hasContent(title)) {
                    html += '<h3>' + title + '</h3><div class="map-col">';
                }
                if (this.hasContent(address)) {
                    html += '<p>' + address + '</p>';
                }
                if (this.hasContent(tel)) {
                    html += '<p><span class="blue-text">Tel</span><a href="tel:' + tel + '">' + tel + '</a><br>';
                }
                if (this.hasContent(fax)) {
                    html += '<p><span class="blue-text">Fax</span>' + fax + '</p>';
                }
                html += '</div><div class="map-col">';
                if (this.hasContent(email)) {
                    html += '<p><a href="mailto:' + email + '"><img alt="' + email + '" src="' + this.icon_email + '">' + email + '</a></p>';
                }
                if (this.hasContent(website)) {
                    var websiteDomain = this.extractHostname(website);
                    if (websiteDomain === location.hostname.replace('www.', '')) {
                        html += '<p><a href="' +
                            website +
                            '"><img alt="' +
                            website + '" src="' +
                            this.icon_website +
                            '">' +
                            website +
                            '</a></p>';
                    }
                    else {
                        html += '<p><a target="_blank" href="' +
                            website +
                            '"><img alt="' +
                            website + '" src="' +
                            this.icon_website +
                            '">' +
                            website +
                            '</a></p>';
                    }
                }
                if (this.hasContent(direction)) {
                    html += '<p><a href="' + direction + '" target="_blank"><img alt="Direction" src="' + this.icon_direction + '">Direction</a></p>';
                }
                if (this.params.showContactButton) {
                    html += '<a class="general-blue-btn contact-us-js">' + this.params.contactButtonText + '</a>';
                }
                html += '</div></div>';
                return html;
            };
            OfficeLocator.prototype.resultBox = function (title, address, tel, fax, email, website, direction) {
                var html = '<div class="address-box">';
                if (this.hasContent(title)) {
                    html += '<h3>' + title + '</h3>';
                }
                html += '<div class="address-content">';
                if (this.hasContent(address)) {
                    html += '<p>' + address + '</p>';
                }
                if (this.hasContent(tel)) {
                    html += '<p><span class="blue-text">Tel</span><span class="u-letter-spacing"><a href="tel:' + tel + '">' + tel + '</a></span></</p>';
                }
                if (this.hasContent(fax)) {
                    html += '<p><span class="blue-text">Fax</span><span class="u-letter-spacing">' + fax + '</span></p>';
                }
                if (this.hasContent(email)) {
                    html += '<p><a href="mailto:' + email + '"><img alt="' + email + '" src="' + this.icon_email + '">' + email + '</a></p>';
                }
                if (this.hasContent(website)) {
                    var websiteDomain = this.extractHostname(website);
                    if (websiteDomain === location.hostname.replace('www.', '')) {
                        html += '<p><a href="' +
                            website +
                            '"><img alt="' +
                            website + '" src="' +
                            this.icon_website +
                            '">' +
                            website +
                            '</a></p>';
                    }
                    else {
                        html += '<p><a target="_blank" href="' + website + '"><img alt="' + website + '" src="' + this.icon_website + '">' + website + '</a></p>';
                    }
                }
                if (this.hasContent(direction)) {
                    html += '<p><a href="' + direction + '" target="_blank"><img alt="Direction" src="' + this.icon_direction + '">Direction</a></p>';
                }
                html += '</div></div>';
                return html;
            };
            OfficeLocator.prototype.hasContent = function (content) {
                return content != '' && content != null && content != undefined;
            };
            OfficeLocator.prototype.gtmTracking = function (query) {
                if (dataLayer) {
                    dataLayer.push({
                        'event': 'locationSearch',
                        'searchQuery': query
                    });
                }
            };
            OfficeLocator.prototype.parseCountryAndLoadOffice = function (latlng) {
                var query = new google.maps.LatLng(latlng.Latitude, latlng.Longitude);
                var self = this;
                new google.maps.Geocoder().geocode({ 'latLng': query }, function (results, status) {
                    if (status == google.maps.GeocoderStatus.OK) {
                        if (results[1]) {
                            var countryCode = null;
                            var c, lc, component;
                            for (var r = 0, rl = results.length; r < rl; r += 1) {
                                var result = results[r];
                                if (!countryCode && result.types[0] === 'country') {
                                    countryCode = result.address_components[0].short_name;
                                    break;
                                }
                            }
                            if (countryCode) {
                                var officeQuery = { Country: countryCode, Latitude: latlng.Latitude, Longitude: latlng.Longitude };
                                self.loadOffices(officeQuery);
                            }
                        }
                    }
                });
            };
            return OfficeLocator;
        }());
        Web.OfficeLocator = OfficeLocator;
        $(".netafim-worldwide").on("click", ".contact-us-js", function () {
            $(".contact-us-popup-js").addClass("show-popup");
            $("body").addClass("no-scroll");
            $(".btn-close").on("click", function () {
                $(".contact-us-popup-js").removeClass("show-popup");
                $("body").removeClass("show-popup");
            });
        });
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=OfficeLocator.js.map;
var BMap, BMapLib, BMAP_ANIMATION_DROP, BMAP_ANCHOR_BOTTOM_RIGHT, BMAP_NAVIGATION_CONTROL_ZOOM;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var OfficeLocatorForChina = /** @class */ (function () {
            //private searchLocation: string='';
            function OfficeLocatorForChina(jqueryElement, parm) {
                this.ICON_BASE_URL = '/Content/images/';
                this.icon_email = this.ICON_BASE_URL + 'icon-mail.png';
                this.icon_website = this.ICON_BASE_URL + 'icon-globe.png';
                this.icon_direction = this.ICON_BASE_URL + 'icon-directions.png';
                this.params = parm;
                this.jqueryElement = jqueryElement;
                this.notNeedRenderForMobile = true;
                this.map = this.initMap();
                this.loadOffices({});
                this.registerEvents();
                this.clearSearchBox();
            }
            OfficeLocatorForChina.prototype.initMap = function (lat, lng) {
                var netafim_map_style = [
                    { "featureType": "administrative", "elementType": "labels.text.fill", "stylers": [{ "color": "#444444" }] },
                    { "featureType": "landscape", "elementType": "all", "stylers": [{ "color": "#f2f2f2" }] },
                    { "featureType": "poi", "elementType": "all", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "road", "elementType": "all", "stylers": [{ "saturation": -100 }, { "lightness": 45 }] },
                    { "featureType": "road.highway", "elementType": "all", "stylers": [{ "visibility": "simplified" }] },
                    { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [{ "color": "#ffffff" }] },
                    { "featureType": "road.arterial", "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "transit", "elementType": "all", "stylers": [{ "visibility": "off" }] },
                    { "featureType": "water", "elementType": "all", "stylers": [{ "color": "#dde6e8" }, { "visibility": "on" }] }
                ];
                lat = lat || 39.9387488;
                lng = lng || 116.3687133;
                var map = new BMap.Map("netafim-map-baidu");
                map.centerAndZoom(new BMap.Point({ lat: lat, lng: lng }), 6);
                map.disable3DBuilding();
                map.setMapStyle({ styleJson: netafim_map_style });
                map.enableKeyboard();
                map.addControl(new BMap.NavigationControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT, type: BMAP_NAVIGATION_CONTROL_ZOOM }));
                return map;
            };
            OfficeLocatorForChina.prototype.loadOffices = function (query) {
                var self = this;
                $.ajax({
                    type: "POST",
                    url: this.params.searchOfficesUrl,
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: JSON.stringify(query),
                    success: function (data) {
                        self.populateOffices(data, query.Latitude, query.Longitude);
                    }
                });
            };
            OfficeLocatorForChina.prototype.populateOffices = function (data, lat, lng) {
                this.map.clearOverlays();
                var offices = $.parseJSON(data);
                $('.netafim-map-result').html('');
                var icon_pin = new BMap.Icon(this.ICON_BASE_URL + 'icon-pin.png', new BMap.Size(28, 35));
                var myOptions = {
                    closeIconUrl: this.ICON_BASE_URL + "close-infobox-baidu.png",
                    closeIconMargin: "10px 10px",
                    offset: new BMap.Size(-75, 35),
                    enableAutoPan: true,
                    alignBottom: false
                };
                var points = [];
                var infoBoxes = [];
                for (var i = 0, length = offices.length; i < length; i++) {
                    var office = offices[i];
                    // add markers
                    var content = this.infoBox(office.officeName, office.address, office.phone, office.fax, office.email, office.website, office.direction);
                    var locationInfoWindow = new BMapLib.InfoBox(this.map, content, myOptions);
                    var point = new BMap.Point(parseFloat(office.longitude), parseFloat(office.latitude) + 0.00022);
                    infoBoxes.push(locationInfoWindow);
                    points.push(point);
                    var mapMarker = new BMap.Marker(point, { icon: icon_pin });
                    this.map.addOverlay(mapMarker);
                    mapMarker.setAnimation(BMAP_ANIMATION_DROP);
                    mapMarker.addEventListener("click", (function (mapMarker, i) {
                        return function () {
                            for (var b = 0; b < infoBoxes.length; b++) {
                                infoBoxes[b].close();
                            }
                            infoBoxes[i].open(mapMarker);
                        };
                    })(mapMarker, i));
                    if (!this.notNeedRenderForMobile) // Add to mobile map
                        $('.netafim-map-result').append(this.resultBox(office.officeName, office.address, office.phone, office.fax, office.email, office.website, office.direction));
                }
                this.map.setViewport(points);
            };
            OfficeLocatorForChina.prototype.extractHostname = function (url) {
                var hostname;
                //find & remove protocol (http, ftp, etc.) and get hostname
                if (url.indexOf("://") > -1) {
                    hostname = url.split('/')[2];
                }
                else {
                    hostname = url.split('/')[0];
                }
                //find & remove port number
                hostname = hostname.split(':')[0];
                //find & remove "?"
                hostname = hostname.split('?')[0];
                return hostname;
            };
            // To address those who want the "root domain," use this function:
            OfficeLocatorForChina.prototype.extractRootDomain = function (url) {
                var domain = this.extractHostname(url), splitArr = domain.split('.'), arrLen = splitArr.length;
                //extracting the root domain here
                //if there is a subdomain 
                if (arrLen > 2) {
                    domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1];
                    //check to see if it's using a Country Code Top Level Domain (ccTLD) (i.e. ".me.uk")
                    if (splitArr[arrLen - 2].length == 2 && splitArr[arrLen - 1].length == 2) {
                        //this is using a ccTLD
                        domain = splitArr[arrLen - 3] + '.' + domain;
                    }
                }
                return domain;
            };
            OfficeLocatorForChina.prototype.infoBox = function (title, address, tel, fax, email, website, direction) {
                var html = '<div class="map-popup-container-baidu">';
                if (this.hasContent(title)) {
                    html += '<h3>' + title + '</h3><div class="map-col">';
                }
                if (this.hasContent(address)) {
                    html += '<p>' + address + '</p>';
                }
                if (this.hasContent(tel)) {
                    html += '<p><span class="blue-text">Tel</span><span class="u-letter-spacing"><a href="tel:' + tel + '">' + tel + '</a></span><br>';
                }
                if (this.hasContent(fax)) {
                    html += '<p><span class="blue-text">Fax</span><span class="u-letter-spacing">' + fax + '</span></p>';
                }
                html += '</div><div class="map-col">';
                if (this.hasContent(email)) {
                    html += '<p><a href="mailto:' + email + '"><img alt="' + email + '" src="' + this.icon_email + '">' + email + '</a></p>';
                }
                if (this.hasContent(website)) {
                    var websiteDomain = this.extractHostname(website);
                    if (websiteDomain === location.hostname.replace('www.', '')) {
                        html += '<p><a href="' +
                            website +
                            '"><img alt="' +
                            website + '" src="' +
                            this.icon_website +
                            '">' +
                            website +
                            '</a></p>';
                    }
                    else {
                        html += '<p><a target="_blank" href="' +
                            website +
                            '"><img alt="' +
                            website + '" src="' +
                            this.icon_website +
                            '">' +
                            website +
                            '</a></p>';
                    }
                }
                if (this.hasContent(direction)) {
                    html += '<p><a href="' + direction + '" target="_blank"><img alt="Direction" src="' + this.icon_direction + '">Direction</a></p>';
                }
                html += '</div></div>';
                return html;
            };
            OfficeLocatorForChina.prototype.resultBox = function (title, address, tel, fax, email, website, direction) {
                var html = '<div class="address-box">';
                if (this.hasContent(title)) {
                    html += '<h3>' + title + '</h3>';
                }
                html += '<div class="address-content">';
                if (this.hasContent(address)) {
                    html += '<p>' + address + '</p>';
                }
                if (this.hasContent(tel)) {
                    html += '<p><span class="blue-text">Tel</span><a href="tel:' + tel + '">' + tel + '</a></p>';
                }
                if (this.hasContent(fax)) {
                    html += '<p><span class="blue-text">Fax</span>' + fax + '</p>';
                }
                if (this.hasContent(email)) {
                    html += '<p><a href="mailto:' + email + '"><img alt="' + email + '" src="' + this.icon_email + '">' + email + '</a></p>';
                }
                if (this.hasContent(website)) {
                    var websiteDomain = this.extractHostname(website);
                    if (websiteDomain === location.hostname.replace('www.', '')) {
                        html += '<p><a href="' +
                            website +
                            '"><img alt="' +
                            website + '" src="' +
                            this.icon_website +
                            '">' +
                            website +
                            '</a></p>';
                    }
                    else {
                        html += '<p><a target="_blank" href="' + website + '"><img alt="' + website + '" src="' + this.icon_website + '">' + website + '</a></p>';
                    }
                }
                if (this.hasContent(direction)) {
                    html += '<p><a href="' + direction + '" target="_blank"><img alt="Direction" src="' + this.icon_direction + '">Direction</a></p>';
                }
                html += '</div></div>';
                return html;
            };
            OfficeLocatorForChina.prototype.hasContent = function (content) {
                return content != '' && content != null && content != undefined;
            };
            OfficeLocatorForChina.prototype.setControlState = function (enableClearButton) {
                if (enableClearButton) {
                    $("#btn-clear-search").show();
                }
                else {
                    $("#btn-clear-search").hide();
                    $("#search-location").val('');
                }
            };
            OfficeLocatorForChina.prototype.gtmTracking = function (query) {
                if (dataLayer) {
                    dataLayer.push({
                        'event': 'locationSearch',
                        'searchQuery': query
                    });
                }
            };
            OfficeLocatorForChina.prototype.registerEvents = function () {
                var self = this;
                var autocomplete = new BMap.Autocomplete({
                    "input": "search-location"
                });
                autocomplete.addEventListener("onconfirm", function (e) {
                    //let location = $("#search-location").val();
                    //geocoder.getPoint(location,function(results) {
                    //    var officeQuery = { Country: "CN", Latitude: results[0].lat, Longitude: results.lng };
                    //    self.loadOffices(officeQuery);
                    //});
                    var myValue = e.item.value.province + e.item.value.city + e.item.value.district + e.item.value.street + e.item.value.business;
                    self.setPlace(myValue);
                });
            };
            OfficeLocatorForChina.prototype.clearSearchBox = function () {
                var self = this;
                $('#btn-clear-search').on('click', function () {
                    self.notNeedRenderForMobile = true;
                    self.loadOffices({});
                    self.setControlState(false);
                });
            };
            OfficeLocatorForChina.prototype.setPlace = function (myValue) {
                var local;
                var self = this;
                function myFun() {
                    var pp = local.getResults().getPoi(0).point;
                    var officeQuery = { Country: "CN", Latitude: pp.lat, Longitude: pp.lng };
                    self.loadOffices(officeQuery);
                    self.setControlState(true);
                    self.gtmTracking(local.getResults().keyword);
                }
                local = new BMap.LocalSearch(self.map, {
                    onSearchComplete: myFun
                });
                local.search(myValue);
            };
            return OfficeLocatorForChina;
        }());
        Web.OfficeLocatorForChina = OfficeLocatorForChina;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=OfficeLocatorForChina.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var ProductDetail = /** @class */ (function () {
            function ProductDetail(jqueryElement) {
                $('.fluid-img', $(jqueryElement).parent()).each(function () {
                    $(this).css('background-image', 'url(' + $(this).find('img').attr('src') + ')');
                });
                $('.fluid-video', $(jqueryElement).parent()).each(function () {
                    $(this).css('background-image', 'url(' + $(this).find('img').attr('src') + ')');
                });
                $('.video-control-play', jqueryElement).on('click', function () {
                    $(this).hide();
                    $(this).parents('.fluid-video').find('img').hide();
                    $(this).parents('.fluid-video').find('video').css('position', 'relative').show();
                    $(this).parents('.fluid-video').find('video').trigger('play');
                });
                function transparentImageAmimate() {
                    var scrollAmount = $(window).scrollTop();
                    $('.transparent-image', jqueryElement).each(function () {
                        var blockPosition = $(this).parents('.fluid-img').offset().top;
                        $(this).css("opacity", ((scrollAmount - (blockPosition - 600)) / 300));
                    });
                }
                $(window).on('scroll', function () {
                    transparentImageAmimate();
                });
                var userAgent, ieReg, ie;
                userAgent = window.navigator.userAgent;
                ieReg = /msie|Trident.*rv[ :]*11\./gi;
                ie = ieReg.test(userAgent);
                if (ie) {
                    $(".boxed-mode.rich-text .youtube-video-container").each(function () {
                        var $container = $(this);
                        $container.addClass("custom-object-fit");
                        $container.find('.video-control-play.fluid-only').on('click', function () {
                            $container.removeClass("custom-object-fit");
                        });
                    });
                }
            }
            return ProductDetail;
        }());
        Web.ProductDetail = ProductDetail;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=ProductDetail.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var ProductDetailFacets = /** @class */ (function () {
            function ProductDetailFacets(jqueryElement) {
                $('.js-load-more', jqueryElement).on('click', function () {
                    console.log("clicked load more button");
                    $(this).hide();
                    $('.js-facet-value', jqueryElement).removeClass("u-hide");
                });
            }
            return ProductDetailFacets;
        }());
        Web.ProductDetailFacets = ProductDetailFacets;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=ProductDetailFacets.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var FamilyMatrix = /** @class */ (function () {
            function FamilyMatrix(jqueryElement, parameter) {
                this.params = parameter;
                var self = this;
                var productCategoryId = $("#product-category-id", jqueryElement).val();
                if (parseInt(productCategoryId) > 0) {
                    //Crop over-view .loadmore-btn
                    $('.FormSelection select', jqueryElement).on('change', function () {
                        self.searchProductFamily(jqueryElement);
                    });
                }
            }
            FamilyMatrix.prototype.searchProductFamily = function (jqueryElement) {
                $.ajax({
                    type: 'POST',
                    url: this.params.searchProductsUrl,
                    data: {
                        "criteria": this.getAllCriteria(jqueryElement),
                        "blockId": this.params.blockId,
                        "productCategoryId": $("#product-category-id", jqueryElement).val(),
                        "criteriaTypeIds": this.getAllCriteriaTypeIds(jqueryElement)
                    },
                    dataType: 'html',
                    success: function (res) {
                        $(".data-result", jqueryElement).html(res);
                    }
                });
            };
            FamilyMatrix.prototype.getAllCriteria = function (jqueryElement) {
                var criteriaIds = [];
                $('.FormSelection select', jqueryElement).each(function (idx, item) {
                    criteriaIds[idx] = parseInt(($(item).val()).toString());
                });
                return criteriaIds;
            };
            FamilyMatrix.prototype.getAllCriteriaTypeIds = function (jqueryElement) {
                var criteriaTypeIds = [];
                $('.criteria-type', jqueryElement).each(function (idx, item) {
                    criteriaTypeIds[idx] = parseInt(($(item).attr("data-value")).toString());
                });
                return criteriaTypeIds;
            };
            return FamilyMatrix;
        }());
        Web.FamilyMatrix = FamilyMatrix;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=ProductFamilyListing.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var ProductFamilyQuickLink = /** @class */ (function () {
            function ProductFamilyQuickLink(jqueryElement) {
                var self = this;
                $(".FormSelection select", jqueryElement).on("change", function () {
                    self.goToFamilyDetailsPage(jqueryElement);
                });
            }
            ProductFamilyQuickLink.prototype.goToFamilyDetailsPage = function (jqueryElement) {
                var link = $(".FormSelection select", jqueryElement).val();
                if (link === "")
                    return;
                window.location.href = link;
            };
            return ProductFamilyQuickLink;
        }());
        Web.ProductFamilyQuickLink = ProductFamilyQuickLink;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=ProductFamilyQuickLink.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var Refiner = /** @class */ (function () {
            function Refiner(jqueryElement, params) {
                var _this = this;
                this.eventHandlers = function () {
                    // Function that moves facet option block to right position
                    function moveFacetSection() {
                        var $filterBtn = $(".c-facet-filter__btn");
                        var $mobileFacet = $(".js-facet-section-mobile");
                        var $desktopFacet = $(".js-facet-section-desktop");
                        if (!($filterBtn.is(':visible'))) {
                            if ($desktopFacet.children().length <= 0) {
                                var mobileFacetChildren = $mobileFacet.children().detach();
                                if (mobileFacetChildren.length > 0) {
                                    $desktopFacet.append(mobileFacetChildren);
                                }
                            }
                        }
                        else {
                            if ($mobileFacet.children().length <= 0) {
                                var desktopFacetChildren = $desktopFacet.children().detach();
                                if (desktopFacetChildren.length > 0) {
                                    $mobileFacet.append(desktopFacetChildren);
                                }
                            }
                        }
                        ;
                    }
                    var collapseFacets = function () {
                        var facetsToCollapse = _this.collapsedFacets;
                        for (var i = 0; i < facetsToCollapse.length; i++) {
                            var selector = "[data-target='" + facetsToCollapse[i] + "']";
                            var element = document.querySelector(selector);
                            if (element != null) {
                                // Update classes and attributes to get collapsed rendering
                                element.classList.remove("collapsed");
                                element.setAttribute("aria-expanded", "true");
                            }
                            var elementTarget = document.querySelector(facetsToCollapse[i]);
                            if (elementTarget != null) {
                                elementTarget.setAttribute("style", "");
                                elementTarget.classList.add("in");
                                elementTarget.setAttribute("aria-expanded", "true");
                            }
                            moveFacetSection();
                        }
                    };
                    var collapseFacetOptions = function () {
                        var facetOptionsToCollapse = _this.collapsedFacetOptions;
                        for (var i = 0; i < facetOptionsToCollapse.length; i++) {
                            var selector = "[data-js-facet-expand='" + facetOptionsToCollapse[i] + "']";
                            $(selector).parent().find(".js-facet-option-wrapper").removeClass("u-hide");
                            $(selector).parent().find(".js-more-btn").addClass("u-hide");
                        }
                    };
                    var collapseMobileFacets = function () {
                        if (_this.mobileFacetSectionIsCollapsed) {
                            $(".js-facet-section-mobile").addClass("in");
                            $(".js-facet-section-mobile").attr("aria-expanded", "true");
                        }
                    };
                    var refreshView = function (facet, facetOption, isActive) {
                        //console.log("sending to server: facet: " + facet + " facetOption: " + facetOption + " isActive:" + isActive + " query: " + $("#facet-query").val());
                        Refiner.block();
                        $.ajax({
                            type: "POST",
                            url: _this.updateUrl,
                            data: {
                                "blockId": $("#refiner-block").val(),
                                "currentQuery": $("#facet-query").val(),
                                "facet": facet,
                                "facetValue": facetOption,
                                "selectFacetValue": isActive
                            },
                            dataType: "html",
                            success: function (data) {
                                if (data != null) {
                                    $("#product-refiner-section").html(data);
                                    collapseFacets();
                                    collapseFacetOptions();
                                    collapseMobileFacets();
                                    setUrlParameter($("#facet-query").val());
                                    Refiner.unBlock();
                                }
                            }
                        });
                    };
                    var loadMoreProducts = function () {
                        Refiner.block();
                        $.ajax({
                            type: "POST",
                            url: _this.loadMoreUrl,
                            data: {
                                "blockId": $("#refiner-block").val(),
                                "currentQuery": $("#facet-query").val(),
                                "pageNumber": Number(getParameterFromCurrentQuery("page")) + 1
                            },
                            dataType: "html",
                            success: function (data) {
                                if (data != null) {
                                    // We should remove the current hidden fields
                                    removeQueryStateFields();
                                    // Append new data
                                    $("#refiner-products").append(data);
                                    // Update current query
                                    updateCurrentQuery();
                                    // Update Url
                                    setUrlParameter($("#facet-query").val());
                                }
                                Refiner.unBlock();
                            }
                        });
                    };
                    // Clicking a product family link
                    $("#product-refiner-section").on("click", ".js-product-family-item-link", function (e) {
                        var element = e.currentTarget;
                        var isEnabled = !element.classList.contains("disabled");
                        // Only do something when clicked link is not disabled
                        if (isEnabled) {
                            var isActive = !element.classList.contains("active");
                            var facet = $(e.currentTarget).data("js-facet");
                            var facetOption = $(e.currentTarget).data("js-facet-option");
                            refreshView(facet, facetOption, isActive);
                        }
                        else {
                            $(e.currentTarget).closest("a").popover("show");
                            $(".popover-title").css("background-color", "transparent");
                            $(".popover-title").css("border-bottom", "none");
                        }
                    });
                    // Hide popover if we click it's close button
                    $("html").on("click", "[data-js='family-pop-up-close']", function (e) {
                        $(".popover").hide();
                    });
                    // Checking a facet option within a facet
                    $("#product-refiner-section").on("click", ".js-facet-option", function (e) {
                        var element = e.currentTarget;
                        if (!element.disabled) {
                            var isActive = element.checked;
                            var facet = $(e.currentTarget).data("js-facet");
                            var facetOption = $(e.currentTarget).data("js-facet-option");
                            refreshView(facet, facetOption, isActive);
                        }
                    });
                    // Clicking on the close button of a current facet option in top
                    $("#product-refiner-section").on("click", ".js-facet-filter-item-close", function (e) {
                        var facet = $(e.currentTarget).data("js-facet");
                        var facetOption = $(e.currentTarget).data("js-facet-option");
                        refreshView(facet, facetOption, false);
                    });
                    // Clicking on load more button
                    $("#product-refiner-section").on("click", "#btn-load-more", function (e) {
                        loadMoreProducts();
                    });
                    // Clicking close button of active product family facet
                    $("#product-refiner-section").on("click", ".js-close-product-family", function (e) {
                        var element = $(e.currentTarget.parentElement).children("a").first();
                        var facet = element.data("js-facet");
                        var facetOption = element.data("js-facet-option");
                        refreshView(facet, facetOption, false);
                    });
                    // Collapsing a facet
                    $("#product-refiner-section").on("click", ".js-facet-collapse", function (e) {
                        var element = $(e.currentTarget)[0];
                        var isCollapsed = element.classList.contains("collapsed");
                        var attribute = element.getAttribute("data-target");
                        if (isCollapsed) {
                            _this.collapsedFacets.push(attribute);
                        }
                        else {
                            _this.collapsedFacets = _this.collapsedFacets.filter(function (el) { return el !== attribute; });
                        }
                        sessionStorage.setItem("collapsedFacets", JSON.stringify(_this.collapsedFacets));
                    });
                    // Collapsing a facet option show more
                    $("#product-refiner-section").on("click", ".js-more-btn", function (e) {
                        // Show all facet values
                        $(e.currentTarget.parentElement).children(".js-facet-option-wrapper").removeClass("u-hide"); // Regular facets
                        $(e.currentTarget.parentElement).find(".js-facet-option-wrapper").removeClass("u-hide"); // Product family
                        // Hide more button
                        $(e.currentTarget).addClass("u-hide");
                        // Read attribute
                        var attribute = $(e.currentTarget).attr("data-js-facet-expand");
                        // Add it
                        _this.collapsedFacetOptions.push(attribute);
                        sessionStorage.setItem("collapsedFacetOptions", JSON.stringify(_this.collapsedFacetOptions));
                    });
                    // Clicking mobile show facet button
                    $("#product-refiner-section").on("click", ".js-facet-section-mobile-collapse-btn", function (e) {
                        if ($(e.currentTarget).hasClass("collapsed")) {
                            _this.mobileFacetSectionIsCollapsed = true;
                        }
                        else {
                            _this.mobileFacetSectionIsCollapsed = false;
                        }
                    });
                    // On window reload, make sure facets are on right position
                    window.onload = function () {
                        moveFacetSection();
                    };
                    // On window resize, make sure facets are on right position
                    window.onresize = function () {
                        moveFacetSection();
                    };
                    // Update url in address bar without reloading page, for bookmarking and reloading without losing checked facets
                    function setUrlParameter(value) {
                        var pageUrl = "?" + value;
                        window.history.pushState(null, null, pageUrl);
                    }
                    function getParameterFromCurrentQuery(key) {
                        var array = $("#facet-query").val().split("&");
                        for (var i = 0; i < array.length; i++) {
                            var p = array[i].split("=");
                            if (p.find(function (x) { return x === key; })) {
                                return p[1];
                            }
                        }
                    }
                    function updateCurrentQuery() {
                        //Show/hide load more button
                        var isLastPage = $("#query-is-last-page").val();
                        if (isLastPage == "True") {
                            $("#btn-load-more").remove();
                        }
                        //Update x of {totalAmountProducts} products shown
                        //TODO: find better approach to become total products shown
                        var listCount = $("#query-list-count").val();
                        var previousCount = $("#load-more-count").text();
                        var currentCount = Number(listCount) + Number(previousCount);
                        var updatedQuery = $("#query-update").val();
                        $("#load-more-count").text(currentCount);
                        $("#facet-query").val(updatedQuery);
                    }
                    function removeQueryStateFields() {
                        $("#query-update").remove();
                        $("#query-is-last-page").remove();
                        $("#query-list-count").remove();
                    }
                    // Collapse facets on init (sessionstorage)
                    collapseFacets();
                    // Collapse facet options on init (sessionstorage)
                    collapseFacetOptions();
                };
                this.getDefaultCollapsedFacets = function () {
                    var result = new Array();
                    $("[data-js-initial-collapse='True']").each(function () {
                        result.push($(this).attr("data-target"));
                    });
                    return result;
                };
                this.updateUrl = params.updateUrl;
                this.loadMoreUrl = params.loadMoreUrl;
                if (sessionStorage.getItem("collapsedFacets") != undefined) {
                    this.collapsedFacets = JSON.parse(sessionStorage.getItem("collapsedFacets"));
                }
                else {
                    this.collapsedFacets = this.getDefaultCollapsedFacets();
                }
                if (sessionStorage.getItem("collapsedFacetOptions") != undefined) {
                    this.collapsedFacetOptions = JSON.parse(sessionStorage.getItem("collapsedFacetOptions"));
                }
                else {
                    this.collapsedFacetOptions = new Array();
                }
                this.eventHandlers();
            }
            Refiner.unBlock = function () {
                $(".spinner").hide();
                // Make arrow image visible again after loading
                $(".js-prod-img").addClass("image-arrow");
            };
            Refiner.block = function () {
                // Hide arrow image styling while loading
                $(".js-prod-img").removeClass("image-arrow");
                $(".spinner").show();
            };
            return Refiner;
        }());
        Web.Refiner = Refiner;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=Refiner.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var RelatedContent = /** @class */ (function () {
            function RelatedContent(jqueryElement) {
                function wowAnimate() {
                    var scrollAmount = $(window).scrollTop();
                    var mintranslateY = 0;
                    var maxtranslateY = 15;
                    $('div[class*="wow-animation"]', jqueryElement).each(function () {
                        var blockPosition = $(this).parents('.image-arrow').offset().top;
                        var translateY = ((maxtranslateY - ((scrollAmount - (blockPosition - 900)) / 10)) < mintranslateY) ? mintranslateY : (maxtranslateY - ((scrollAmount - (blockPosition - 900)) / 10));
                        $(this).css('opacity', ((scrollAmount - (blockPosition - 900)) / 200) - 1);
                        $(this).find('.wow-icon').css({ "transform": "translateY(" + translateY + "px)" });
                        if (scrollAmount > blockPosition - 500) {
                            $(this).find('.wow-rada').addClass('animate');
                        }
                        else {
                            $(this).find('.wow-rada').removeClass('animate');
                        }
                    });
                }
                $(window).on('scroll', function () {
                    wowAnimate();
                });
            }
            return RelatedContent;
        }());
        Web.RelatedContent = RelatedContent;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=RelatedContent.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var RichTextMediaBlock = /** @class */ (function () {
            function RichTextMediaBlock(jqueryElement) {
                $('.fluid-img', $(jqueryElement).parent()).each(function () {
                    $(this).css('background-image', 'url(' + $(this).find('img').attr('src') + ')');
                });
                $('.fluid-video', $(jqueryElement).parent()).each(function () {
                    $(this).css('background-image', 'url(' + $(this).find('img').attr('src') + ')');
                });
                $('.video-control-play', jqueryElement).on('click', function () {
                    $(this).hide();
                    if ($(this).parents('.fluid-video').find('iframe').attr('id')) {
                        $(this).parents('.fluid-video').find('img').css("visibility", "hidden");
                    }
                    else {
                        $(this).parents('.fluid-video').find('img').hide();
                    }
                    $(this).parents('.fluid-video').find('video').css('position', 'relative').show();
                    $(this).parents('.fluid-video').find('video').trigger('play');
                });
                function transparentImageAmimate() {
                    var scrollAmount = $(window).scrollTop();
                    $('.transparent-image', jqueryElement).each(function () {
                        var blockPosition = $(this).parents('.fluid-img').offset().top;
                        $(this).css("opacity", ((scrollAmount - (blockPosition - 600)) / 300));
                    });
                }
                $(window).on('scroll', function () {
                    transparentImageAmimate();
                });
                var userAgent, ieReg, ie;
                userAgent = window.navigator.userAgent;
                ieReg = /msie|Trident.*rv[ :]*11\./gi;
                ie = ieReg.test(userAgent);
                if (ie) {
                    $(".boxed-mode.rich-text .youtube-video-container").each(function () {
                        var $container = $(this);
                        $container.addClass("custom-object-fit");
                        $container.find('.video-control-play.fluid-only').on('click', function () {
                            $container.removeClass("custom-object-fit");
                        });
                    });
                }
            }
            return RichTextMediaBlock;
        }());
        Web.RichTextMediaBlock = RichTextMediaBlock;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=RichTextMediaBlock.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var timeOuts = new Array();
        var ROICalculator = /** @class */ (function () {
            function ROICalculator(jqueryElement, params) {
                var _this = this;
                this.roiViewModel = new ROIViewModel(params.irrigationMethods, (params.defaultIndex !== -1 ? params.defaultIndex : 0), params.highestProductionCost);
                ko.applyBindings(this.roiViewModel);
                $(jqueryElement).find(".js-nav-calc").find('button').on('click', function (e) {
                    clearTimeOuts();
                    _this.roiViewModel = new ROIViewModel(params.irrigationMethods, +$(e.currentTarget).attr('data-js-active'), params.highestProductionCost);
                    $(e.currentTarget).closest(".js-nav-calc").find(".active").removeClass("active");
                    $(e.currentTarget).addClass("active");
                });
            }
            return ROICalculator;
        }());
        Web.ROICalculator = ROICalculator;
        var ROIViewModel = /** @class */ (function () {
            function ROIViewModel(irrigationMethods, activeMethod, highestProductionCost) {
                var _this = this;
                this.irrigationMethods = irrigationMethods;
                this.methodViewModel = irrigationMethods[activeMethod];
                this.highestProductionCost = highestProductionCost;
                // Percentage should never be more than 100
                if (this.methodViewModel.averageYieldPercentage > 100) {
                    this.methodViewModel.averageYieldPercentage = 100;
                }
                $(function () {
                    MethodViewModel.reloadSlider('.js-calc-slider-1', _this.methodViewModel.averageYieldPercentage, _this.methodViewModel.averageYieldPercentage);
                    MethodViewModel.reloadSlider('.js-calc-slider-2', (_this.methodViewModel.productionCost / _this.highestProductionCost) * 100, _this.methodViewModel.productionCost);
                    MethodViewModel.clearDataPoints(".js-calc-yield-datapoints");
                    // ReSharper disable once TsResolvedFromInaccessibleModule
                    if (_this.methodViewModel.averageYieldDataPoints !== null) {
                        for (var i = 0; i < _this.methodViewModel.averageYieldDataPoints.length; i++) {
                            MethodViewModel.addDataPoint(".js-calc-yield-datapoints", _this.methodViewModel.averageYieldDataPoints[i].percentage, _this.methodViewModel.averageYieldDataPoints[i].label, _this.methodViewModel.averageYieldDataPoints[i].position);
                        }
                    }
                    MethodViewModel.clearDataPoints(".js-calc-cost-datapoints");
                    // ReSharper disable once TsResolvedFromInaccessibleModule
                    if (_this.methodViewModel.productionCostDataPoints !== null) {
                        for (var i = 0; i < _this.methodViewModel.productionCostDataPoints.length; i++) {
                            MethodViewModel.addDataPoint(".js-calc-cost-datapoints", _this.methodViewModel.productionCostDataPoints[i].percentage, _this.methodViewModel.productionCostDataPoints[i].label, _this.methodViewModel.productionCostDataPoints[i].position);
                        }
                    }
                    MethodViewModel.changeHtml(".js-calc-payback", _this.methodViewModel.paybackTime);
                    MethodViewModel.changeHtml(".js-calc-cycles", _this.methodViewModel.cycles);
                    MethodViewModel.changeHtml(".js-calc-average-yield", _this.methodViewModel.averageYield);
                });
            }
            return ROIViewModel;
        }());
        Web.ROIViewModel = ROIViewModel;
        var MethodViewModel = /** @class */ (function () {
            function MethodViewModel(averageYieldPercentage, averageYieldDataPoints, averageYield, productionCost, productionCostDataPoints, paybackTime, cycle) {
                this.averageYieldPercentage = averageYieldPercentage;
                this.averageYieldDataPoints = averageYieldDataPoints;
                this.averageYield = averageYield;
                this.productionCost = productionCost;
                this.productionCostDataPoints = productionCostDataPoints;
                this.paybackTime = paybackTime;
                this.cycles = cycle;
            }
            MethodViewModel.reloadSlider = function (selector, percentage, number) {
                this.animateValue(selector + "-number", 0, number, 2000);
                $(selector).addClass("notransition").attr("style", "bottom: calc(0% + 7px)");
                // ReSharper disable once TsNotResolved
                timeOuts.push(setTimeout(function () {
                    $(selector).removeClass("notransition").attr("style", "bottom: calc(" + percentage + "% + 7px)");
                }, 500));
                // Make text in same color
                var startColor = new Color(112, 221, 0);
                var endColor = new Color(247, 107, 28);
                if (selector === ".js-calc-slider-1") {
                    var startColor = new Color(247, 107, 28);
                    var endColor = new Color(112, 221, 0);
                }
                var color = getGradientColor(startColor, endColor, percentage);
                $(selector).closest(".calculator-bar-section").find(".calculator-bar__value").css('color', color);
            };
            MethodViewModel.animateValue = function (selector, start, end, duration) {
                var range = end - start;
                var obj = $(selector);
                if (range > 0) {
                    var current = start;
                    var increment = end > start ? 1 : -1;
                    var stepTime = Math.abs(Math.floor(duration / range));
                    var timer = setInterval(function () {
                        current += increment;
                        obj.text(current);
                        if (current === end) {
                            clearInterval(timer);
                        }
                    }, stepTime);
                }
                else {
                    obj.text("0");
                }
            };
            MethodViewModel.addDataPoint = function (selector, percentage, label, position) {
                var html = "";
                var positionModifier = position.toUpperCase() === "RIGHT" ? "u-text-right" : "";
                if (percentage === 0) {
                    html = '<div class="calculator-bar-slider-label__item calculator-bar-slider-label__item--first ' + positionModifier + '" style="bottom: 0;">' + label + '</div>';
                }
                else {
                    html = '<div class="calculator-bar-slider-label__item ' + positionModifier + '" style="bottom: calc(' + percentage + '% - 20px)">' + label + '</div>';
                }
                $(selector).append(html);
            };
            MethodViewModel.clearDataPoints = function (selector) {
                $(selector).empty();
            };
            MethodViewModel.changeHtml = function (selector, text) {
                // ReSharper disable once TsResolvedFromInaccessibleModule
                $(selector).html(text.toString());
            };
            return MethodViewModel;
        }());
        Web.MethodViewModel = MethodViewModel;
        var Color = /** @class */ (function () {
            function Color(r, g, b) {
                this.r = r;
                this.g = g;
                this.b = b;
            }
            return Color;
        }());
        Web.Color = Color;
        function clearTimeOuts() {
            timeOuts.forEach(function (timeout) {
                clearTimeout(timeout);
            });
            timeOuts = new Array();
        }
        function getGradientColor(color1, color2, percent) {
            var newColor = new Color(0, 0, 0);
            function makeChannel(a, b) {
                return (a + Math.round((b - a) * (percent / 100)));
            }
            function makeColorPiece(num) {
                num = Math.min(num, 255); // not more than 255
                num = Math.max(num, 0); // not less than 0
                var str = num.toString(16);
                if (str.length < 2) {
                    str = "0" + str;
                }
                return (str);
            }
            newColor.r = makeChannel(color1.r, color2.r);
            newColor.g = makeChannel(color1.g, color2.g);
            newColor.b = makeChannel(color1.b, color2.b);
            newColor.cssColor = "#" +
                makeColorPiece(newColor.r) +
                makeColorPiece(newColor.g) +
                makeColorPiece(newColor.b);
            return newColor.cssColor;
        }
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=ROICalculator.js.map;
var Netafim;
(function (Netafim) {
    var WebPlatform;
    (function (WebPlatform) {
        var Web;
        (function (Web) {
            var Features;
            (function (Features) {
                var ID_SEARCH_BUTTON = '#js-searchButton';
                var CLASS_PAGE_LINK = '.js-pageLink';
                var CLASS_NEXT_PAGE = '.js-nextPage';
                var CLASS_PREVIOUS_PAGE = '.js-previousPage';
                var CLASS_CATEGORY_FACET_LIST_ITEM = '.js-categoryFacetList';
                var CLASS_TYPE_FACET_LIST_ITEM = '.js-typeFacetList';
                var ID_CATEGORY_FACET_DROPDOWN = '#js-categoryFacetDropDown';
                var ID_TYPE_FACET_DROPDOWN = '#js-typeFacetDropDown';
                var Search = /** @class */ (function () {
                    function Search(jqueryElement, params) {
                        var _this = this;
                        this.parameters = params;
                        $(document).ready(function () {
                            if (_this.parameters.currentSearchText) {
                                jqueryElement.find("#js-searchTextField").val(_this.parameters.currentSearchText);
                            }
                        });
                        jqueryElement.on("click", ID_SEARCH_BUTTON, function (e) {
                            e.preventDefault();
                            _this.redirectToSearchResultPage(jqueryElement.find("#js-searchTextField").val(), null, null);
                        });
                        jqueryElement.on("click", CLASS_PREVIOUS_PAGE, function (e) {
                            var page = _this.parameters.currentPageNumber - 1;
                            if (page < 1)
                                return;
                            e.preventDefault();
                            _this.redirectToSearchResultPage(_this.parameters.currentSearchText, page, _this.parameters.currentCategory, _this.parameters.currentType);
                        });
                        jqueryElement.on("click", CLASS_NEXT_PAGE, function (e) {
                            if (_this.parameters.isThisTheLastPage)
                                return;
                            var page = _this.parameters.currentPageNumber + 1;
                            e.preventDefault();
                            _this.redirectToSearchResultPage(_this.parameters.currentSearchText, page, _this.parameters.currentCategory, _this.parameters.currentType);
                        });
                        jqueryElement.on("click", CLASS_PAGE_LINK, function (e) {
                            var page = $(e.currentTarget).attr("data-pageNumber");
                            e.preventDefault();
                            _this.redirectToSearchResultPage(_this.parameters.currentSearchText, parseInt(page), _this.parameters.currentCategory, _this.parameters.currentType);
                        });
                        $(jqueryElement).find(CLASS_CATEGORY_FACET_LIST_ITEM).on("click", function (e) {
                            var categoryKey = $(e.currentTarget).attr("data-key");
                            e.preventDefault();
                            if (!categoryKey)
                                categoryKey = null;
                            _this.redirectToSearchResultPage(_this.parameters.currentSearchText, _this.parameters.currentPageNumber, categoryKey, _this.parameters.currentType);
                        });
                        $(jqueryElement).find(CLASS_TYPE_FACET_LIST_ITEM).on("click", function (e) {
                            var typeKey = $(e.currentTarget).attr("data-key");
                            e.preventDefault();
                            if (!typeKey)
                                typeKey = null;
                            _this.redirectToSearchResultPage(_this.parameters.currentSearchText, _this.parameters.currentPageNumber, _this.parameters.currentCategory, typeKey);
                        });
                        $(jqueryElement).find(ID_CATEGORY_FACET_DROPDOWN).on("change", function (e) {
                            var categoryKey = $(e.currentTarget).find(":selected").val();
                            e.preventDefault();
                            _this.redirectToSearchResultPage(_this.parameters.currentSearchText, _this.parameters.currentPageNumber, categoryKey, _this.parameters.currentType);
                        });
                        $(jqueryElement).find(ID_TYPE_FACET_DROPDOWN).on("change", function (e) {
                            var typeKey = $(e.currentTarget).find(":selected").val();
                            e.preventDefault();
                            _this.redirectToSearchResultPage(_this.parameters.currentSearchText, _this.parameters.currentPageNumber, _this.parameters.currentCategory, typeKey);
                        });
                    }
                    Search.prototype.redirectToSearchResultPage = function (searchText, page, category, type) {
                        if (type === void 0) { type = null; }
                        var url = this.parameters.url + "?SearchText=" + searchText;
                        if (page) {
                            url = url + "&Page=" + page;
                        }
                        if (category) {
                            url = url + "&Category=" + category;
                        }
                        if (type) {
                            url = url + "&Type=" + type;
                        }
                        window.location.href = url;
                    };
                    return Search;
                }());
                Features.Search = Search;
            })(Features = Web.Features || (Web.Features = {}));
        })(Web = WebPlatform.Web || (WebPlatform.Web = {}));
    })(WebPlatform = Netafim.WebPlatform || (Netafim.WebPlatform = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=Search.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var SiteSuggestionPopUp = /** @class */ (function () {
            function SiteSuggestionPopUp(jqueryElement, parameters) {
                var _this = this;
                this.params = parameters;
                var declinedSuggestedSiteCookie = Web.CookieUtil.readCookie(this.params.declinedSuggestionCookieName);
                var hasDeclinedSuggestedSite = declinedSuggestedSiteCookie != null && declinedSuggestedSiteCookie === "true";
                if (!hasDeclinedSuggestedSite) {
                    $.ajax({
                        type: "POST",
                        url: this.params.fetchPopUpUrl,
                        data: { "currentPageId": this.params.currentPageId },
                        dataType: "html",
                        success: function (data) {
                            // There is a site-suggestion pop-up
                            if (data !== "") {
                                $("[data-js='user-site-suggestion']", jqueryElement).html(data);
                            }
                            // Closing pop-up
                            $("[data-js='user-site-suggestion']").on("click", "[data-popup-id='site-suggestion'] .btn-close", function (e) {
                                // Hide pop-up
                                $("[data-js='user-site-suggestion'] .show-popup").removeClass('show-popup');
                                // Set cookie
                                Web.CookieUtil.createCookie(_this.params.declinedSuggestionCookieName, true, 30);
                            });
                            // Collapsing and expanding sites overview
                            $("[data-js='user-site-suggestion']").on("click", "[data-popup-id='site-suggestion'] .js-view-all-link", function (e) {
                                $("[data-popup-id='site-suggestion'] .js-view-all-link").removeClass("u-show").addClass("u-hide");
                                $("[data-popup-id='site-suggestion'] .js-view-less-link").removeClass("u-hide").addClass("u-show");
                                $("[data-popup-id='site-suggestion'] .js-language-country-selector-overview").toggleClass("active");
                            });
                            $("[data-js='user-site-suggestion']").on("click", "[data-popup-id='site-suggestion'] .js-view-less-link", function (e) {
                                $("[data-popup-id='site-suggestion'] .js-view-less-link").removeClass("u-show").addClass("u-hide");
                                $("[data-popup-id='site-suggestion'] .js-view-all-link").removeClass("u-hide").addClass("u-show");
                                $("[data-popup-id='site-suggestion'] .js-language-country-selector-overview").toggleClass("active");
                            });
                        }
                    });
                }
            }
            return SiteSuggestionPopUp;
        }());
        Web.SiteSuggestionPopUp = SiteSuggestionPopUp;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=SiteSuggestionPopUp.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var hash;
        var SuccessStoryOverview = /** @class */ (function () {
            function SuccessStoryOverview(jqueryElement, parameter) {
                var self = this;
                this.params = parameter;
                this.jqueryElements = jqueryElement;
                hash = new Web.HashService();
                this.dataFilter = {
                    CropId: 0,
                    Country: '',
                    BigProject: false,
                    BlockId: this.params.blockId,
                    CurrentPage: 1,
                    HasHashData: false
                };
                self.doInitFilter();
                //Live search
                $('.live-search-list li', jqueryElement).each(function () {
                    $(this).attr('data-search-term', $(this).text().toLowerCase());
                });
                $('.live-search-box input', jqueryElement).on('focusin', function () {
                    $('.live-search-box input[type="text"]').each(function () {
                        if ($(this).next('.live-search-list').hasClass('show-search-list')) {
                            $(this).next('.show-search-list').removeClass('show-search-list');
                        }
                    });
                    $(this).parent().find('.live-search-list').addClass('show-search-list');
                });
                $('.live-search-list li', jqueryElement).on('click', function () {
                    var selectedText = $(this).text();
                    var selectedList = $(this).parent();
                    $(this).parent().siblings('.dropdown-textbox').attr('value', selectedText);
                    $(this).parent().removeClass('show-search-list');
                    //Start reloading the content below, this will be dealt by BE dev :)
                    //Code here....
                    if (selectedList.hasClass('crop-list')) {
                        self.dataFilter.CropId = parseInt($(this).data("value"));
                    }
                    else if (selectedList.hasClass('country-list')) {
                        self.dataFilter.Country = $(this).data("value");
                    }
                    if ($('#open-field-crop', jqueryElement).is(":checked")) {
                        self.dataFilter.BigProject = true;
                    }
                    else {
                        self.dataFilter.BigProject = false;
                    }
                    self.doUpdateFilter();
                });
                $('#open-field-crop', jqueryElement).change(function () {
                    if (this.checked) {
                        self.dataFilter.BigProject = true;
                    }
                    else {
                        self.dataFilter.BigProject = false;
                    }
                    self.doUpdateFilter();
                });
                $(document).on('click', function (e) {
                    if (!$(e.target).is('.live-search-item') && !$(e.target).is('.dropdown-textbox')) {
                        $('.show-search-list').removeClass('show-search-list');
                    }
                });
                $('.live-search-box input.dropdown-textbox', jqueryElement).on('keyup', function () {
                    var searchTerm = $(this).val().toLowerCase();
                    $('.live-search-list li').each(function () {
                        if ($(this).filter('[data-search-term *= ' + searchTerm + ']').length > 0 || searchTerm.length < 1) {
                            $(this).show();
                        }
                        else {
                            $(this).hide();
                        }
                    });
                });
                //success-stories-overview .loadmore-btn
                $('.load-more-row .loadmore-btn', jqueryElement).on('click', function () {
                    $(this).addClass('searching');
                    self.dataFilter.CurrentPage = self.dataFilter.CurrentPage + 1;
                    self.doLoadMore();
                });
            }
            SuccessStoryOverview.prototype.doInitFilter = function () {
                var _this = this;
                var hashObject = hash.getHash(this.params.blockId);
                if (hashObject != null) {
                    this.dataFilter.HasHashData = true;
                    this.dataFilter.CropId = parseInt(hashObject["crop"]);
                    this.dataFilter.Country = hashObject["country"];
                    this.dataFilter.BigProject = hashObject["bigProject"] === "true";
                    this.dataFilter.BlockId = parseInt(hashObject["contentId"]);
                    this.dataFilter.CurrentPage = parseInt(hashObject["currentPage"]);
                    this.doPrefillControl();
                }
                this.doAjax(function (data) { _this.replaceCallback(false, data); });
            };
            SuccessStoryOverview.prototype.doUpdateFilter = function () {
                var _this = this;
                this.dataFilter.CurrentPage = 1;
                this.dataFilter.HasHashData = false;
                this.doAjax(function (data) { _this.replaceCallback(true, data); });
            };
            SuccessStoryOverview.prototype.doLoadMore = function () {
                var _this = this;
                this.dataFilter.HasHashData = false;
                this.doAjax(function (data) { _this.appendCallback(data); });
            };
            SuccessStoryOverview.prototype.replaceCallback = function (isReplaceData, data) {
                $(".row .story-grid", this.jqueryElements).html(data.html);
                $(".result-counter span.result-number", this.jqueryElements).text(data.totalsResult);
                var repeatedText = "";
                if ((this.dataFilter.Country !== "" || this.dataFilter.CropId > 0) && parseInt(data.totalsResult) > 0) {
                    var country = this.dataFilter.Country !== "" ? this.getCountryNameByCode(this.dataFilter.Country) : "";
                    var crop = this.dataFilter.CropId > 0 ? this.getCropTextById(this.dataFilter.CropId) : "";
                    var hasAnd = country !== "" && crop !== "" ? " " + this.params.repeatedCriteriaTranslated + " " : "";
                    repeatedText = "for " + country + hasAnd + crop;
                }
                $(".result-counter span.repeated-criteria", this.jqueryElements).text(repeatedText);
                if (isReplaceData) {
                    this.bindHashToUrl();
                }
                this.setLoadMoreState(this.dataFilter.CurrentPage, data.totalPage);
            };
            SuccessStoryOverview.prototype.appendCallback = function (data) {
                $(data.html).appendTo($(".row .story-grid", this.jqueryElements));
                this.bindHashToUrl();
                this.setLoadMoreState(this.dataFilter.CurrentPage, data.totalPage);
                $('.load-more-row .loadmore-btn', this.jqueryElements).removeClass('searching');
            };
            SuccessStoryOverview.prototype.doAjax = function (successCallback) {
                $.ajax({
                    type: 'POST',
                    url: this.params.searchUrl,
                    data: this.dataFilter,
                    dataType: 'json',
                    success: function (data) {
                        successCallback(data);
                        console.log('success: ' + data);
                    },
                    error: function (jqXHR) {
                        console.log('error: ' + jqXHR);
                    },
                    complete: function (jqXHR) {
                        console.log('complete: ' + jqXHR);
                    }
                });
            };
            SuccessStoryOverview.prototype.bindHashToUrl = function () {
                var obj = {
                    crop: this.dataFilter.CropId,
                    country: this.dataFilter.Country,
                    bigProject: this.dataFilter.BigProject,
                    currentPage: this.dataFilter.CurrentPage
                };
                hash.setHash(this.params.blockId, obj);
            };
            SuccessStoryOverview.prototype.setLoadMoreState = function (currentPage, totalPage) {
                var loadMore = $('.load-more-row .loadmore-btn', this.jqueryElements);
                if (currentPage === totalPage || totalPage === 0) {
                    loadMore.hide();
                }
                else {
                    loadMore.show();
                }
            };
            SuccessStoryOverview.prototype.doPrefillControl = function () {
                $("#open-field-crop", this.jqueryElements).prop("checked", this.dataFilter.BigProject);
                if (this.dataFilter.CropId > 0) {
                    $(".crop-list", this.jqueryElements).siblings(".dropdown-textbox").attr("value", this.getCropTextById(this.dataFilter.CropId));
                }
                if (this.dataFilter.Country !== "") {
                    $(".country-list", this.jqueryElements).siblings(".dropdown-textbox").attr("value", this.getCountryNameByCode(this.dataFilter.Country));
                }
            };
            SuccessStoryOverview.prototype.getCountryNameByCode = function (countryCode) {
                var getCountry = "";
                $(".country-list li.live-search-item", this.jqueryElements).each(function () {
                    if ($(this).data('value') === countryCode) {
                        getCountry = $(this).text();
                        return false;
                    }
                });
                return getCountry;
            };
            SuccessStoryOverview.prototype.getCropTextById = function (cropId) {
                var cropText = "";
                $(".crop-list li.live-search-item", this.jqueryElements).each(function () {
                    if ($(this).data('value') === cropId) {
                        cropText = $(this).text();
                        return false;
                    }
                });
                return cropText;
            };
            return SuccessStoryOverview;
        }());
        Web.SuccessStoryOverview = SuccessStoryOverview;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=SuccessStoryOverview.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var SystemConfiguratorParametersBlock = /** @class */ (function () {
            function SystemConfiguratorParametersBlock(jqueryElement, parameter) {
                this.parameter = parameter;
                var self = this;
                var current_step = 1;
                checkStepOnMobile();
                function checkStepOnMobile() {
                    switch (current_step) {
                        case 1:
                            $('.show-this-step', jqueryElement).removeClass('show-this-step');
                            $('.config-form-progress .active-step', jqueryElement).removeClass('active-step');
                            $('.config-form-progress .form-step-1', jqueryElement).addClass('active-step');
                            $('.config-form-step', jqueryElement).first().addClass('show-this-step');
                            $('.config-form-step-navigation-button', jqueryElement).removeClass('last-step');
                            $('.config-form-step-navigation-button', jqueryElement).addClass('first-step');
                            break;
                        case 2:
                            $('.show-this-step', jqueryElement).removeClass('show-this-step');
                            $('.config-form-progress .active-step', jqueryElement).removeClass('active-step');
                            $('.config-form-progress .form-step-1', jqueryElement).addClass('active-step');
                            $('.config-form-progress .form-step-2', jqueryElement).addClass('active-step');
                            $('.config-form-step', jqueryElement).first().next().addClass('show-this-step');
                            $('.config-form-step-navigation-button', jqueryElement).removeClass('last-step');
                            $('.config-form-step-navigation-button', jqueryElement).removeClass('first-step');
                            break;
                        case 3:
                            $('.show-this-step', jqueryElement).removeClass('show-this-step');
                            $('.config-form-progress .form-step-1', jqueryElement).addClass('active-step');
                            $('.config-form-progress .form-step-2', jqueryElement).addClass('active-step');
                            $('.config-form-progress .form-step-3', jqueryElement).addClass('active-step');
                            $('.config-form-step', jqueryElement).last().addClass('show-this-step');
                            $('.config-form-step-navigation-button', jqueryElement).addClass('last-step');
                            $('.config-form-step-navigation-button', jqueryElement).removeClass('first-step');
                            break;
                    }
                }
                function validateStepConfig(step) {
                    var _valid = true;
                    if (step != "all") {
                        $('.config-form-step.show-this-step', jqueryElement).find('select').each(function () {
                            if ($(this).val() == null) {
                                $(this).parent().next('.error-message').show();
                                if (_valid) {
                                    _valid = false;
                                }
                            }
                            else {
                                $(this).parent().next('.error-message').hide();
                            }
                        });
                        $('.config-form-step.show-this-step', jqueryElement).find('input[type="number"]').each(function () {
                            if (!$(this).val()) {
                                $(this).parent().next('.error-message').show();
                                if (_valid) {
                                    _valid = false;
                                }
                            }
                            else if (($(this).attr("step") === "1") && (!$(this).val().match(/^\d+$/))) {
                                $(this).parent().next('.error-message').show();
                                if (_valid) {
                                    _valid = false;
                                }
                            }
                            else {
                                $(this).parent().next('.error-message').hide();
                            }
                        });
                    }
                    else {
                        $('.config-form-wrapper', jqueryElement).find('select').each(function () {
                            if ($(this).val() == null) {
                                $(this).parent().next('.error-message').show();
                                if (_valid) {
                                    _valid = false;
                                }
                            }
                            else {
                                $(this).parent().next('.error-message').hide();
                            }
                        });
                        $('.config-form-wrapper', jqueryElement).find('input[type="number"]').each(function () {
                            if (!$(this).val()) {
                                $(this).parent().next('.error-message').show();
                                if (_valid) {
                                    _valid = false;
                                }
                            }
                            else if (($(this).attr("step") === "1") && (!$(this).val().match(/^\d+$/))) {
                                $(this).parent().next('.error-message').show();
                                if (_valid) {
                                    _valid = false;
                                }
                            }
                            else {
                                $(this).parent().next('.error-message').hide();
                            }
                        });
                    }
                    if (_valid) {
                        return true;
                    }
                    else {
                        return false;
                    }
                }
                //Custom number input
                $('.config-form-wrapper .FormNumber', jqueryElement).each(function () {
                    var input = $(this).find('input[type="number"]').first();
                    var btnUp = $(this).find('.number-up');
                    var btnDown = $(this).find('.number-down');
                    var decimalWithComma = false;
                    var min = 0;
                    if (input.attr('min')) {
                        min = parseInt(input.attr('min'));
                    }
                    else {
                        min = 0;
                    }
                    var max = 0;
                    if (input.attr('max')) {
                        max = parseInt(input.attr('max'));
                    }
                    else {
                        var max = 1000;
                    }
                    btnUp.on('click', function () {
                        if (!input.val()) {
                            input.val(0);
                        }
                        decimalWithComma = (input.val().indexOf(',') > -1);
                        var oldValue = (decimalWithComma) ? parseFloat(input.val().replace(',', '.')) : parseFloat(input.val());
                        var precision = oldValue.toString().substr(oldValue.toString().indexOf('.')).length - 1;
                        if (oldValue >= max) {
                            var newVal = oldValue;
                        }
                        else {
                            var newVal = oldValue + 1;
                        }
                        input.val((decimalWithComma) ? newVal.toFixed(precision).replace('.', ',') : newVal.toFixed(precision));
                        input.trigger("change");
                    });
                    btnDown.on('click', function () {
                        if (!input.val()) {
                            input.val(0);
                        }
                        decimalWithComma = (input.val().indexOf(',') > -1);
                        var oldValue = (decimalWithComma) ? parseFloat(input.val().replace(',', '.')) : parseFloat(input.val());
                        var precision = oldValue.toString().substr(oldValue.toString().indexOf('.')).length - 1;
                        if (oldValue <= min) {
                            var newVal = oldValue;
                        }
                        else {
                            var newVal = oldValue - 1;
                        }
                        input.val((decimalWithComma) ? newVal.toFixed(precision).replace('.', ',') : newVal.toFixed(precision));
                        input.trigger("change");
                    });
                });
                $('.config-form-step-navigation-button .btn-next-step', jqueryElement).on('click', function () {
                    if (validateStepConfig("abc")) {
                        current_step = current_step + 1;
                    }
                    checkStepOnMobile();
                });
                $('.config-form-step-navigation-button .btn-previous-step', jqueryElement).on('click', function () {
                    current_step = current_step - 1;
                    checkStepOnMobile();
                });
                $('.config-form .extra-info-icon').on('click', function () {
                    if (!$(this).hasClass('show-extra-content')) {
                        $('.show-extra-content').removeClass('show-extra-content');
                        $(this).addClass('show-extra-content');
                    }
                    else {
                        $(this).removeClass('show-extra-content');
                    }
                });
                $('.config-form-step-navigation-button .btn-generate', jqueryElement).on('click', function (e) {
                    var validClientSide = validateStepConfig("all");
                    e.preventDefault();
                    if (!validClientSide)
                        return;
                    var element = this;
                    $.ajax({
                        url: self.parameter.actionVerifyUrl,
                        data: JSON.stringify({ 'data': {
                                RegionId: parseInt($("select[name='Region']").val()),
                                CropId: parseInt($("select[name='Crop']").val()),
                                PlotArea: parseInt($("input[name='PlotSize']").val()),
                                RowSpacing: parseFloat($("input[name='RowSpacing']").val()),
                                MaxAllowedIrrigationTimePerDay: parseInt($("input[name='MaxIrrigation']").val()),
                                WeeklyIrrigationInterval: parseInt($("input[name='IrrigationCycle']").val()),
                                FiltrationTypeId: parseInt($("input[name='Filtration']").val()),
                                WaterSourceId: parseInt($("input[name='WaterSource']").val())
                            } }),
                        contentType: "application/json; charset=utf-8",
                        traditional: true,
                        method: 'POST',
                        success: function (res) {
                            if (res.status === "Success") {
                                $(element).closest("form").submit();
                            }
                            else {
                                $(".system-configurator .notification", jqueryElement).text(res.message);
                            }
                        }
                    });
                });
            }
            return SystemConfiguratorParametersBlock;
        }());
        Web.SystemConfiguratorParametersBlock = SystemConfiguratorParametersBlock;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=SystemConfiguratorParameters.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var SystemConfiguratorResult = /** @class */ (function () {
            function SystemConfiguratorResult(jqueryElement) {
                $('.solution-product-more-info', jqueryElement).on('click', function () {
                    $(this).hide();
                    $(this).next('.solution-product-description').show();
                });
            }
            return SystemConfiguratorResult;
        }());
        Web.SystemConfiguratorResult = SystemConfiguratorResult;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=SystemConfiguratorResult.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var SystemConfiguratorStarted = /** @class */ (function () {
            function SystemConfiguratorStarted(jqueryElement) {
                function isEmail(emailAddress) {
                    var pattern = new RegExp(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/);
                    return pattern.test(emailAddress);
                }
                function validateStartForm() {
                    var _validName = true;
                    var _validEmail = true;
                    var _privacyPolicyAccepted = true;
                    var config_name = $('#clientName', jqueryElement).val();
                    var config_email = $('#clientEmail', jqueryElement).val();
                    var config_policy = $('#privacyCheckbox', jqueryElement).is(':checked');
                    if (config_name) {
                        $('#clientName', jqueryElement).next('.error-message').hide();
                        _validName = true;
                    }
                    else {
                        $('#clientName', jqueryElement).next('.error-message').show();
                        _validName = false;
                    }
                    if (config_email) {
                        $('#clientEmail', jqueryElement).next('.error-message').hide();
                        if (isEmail(config_email)) {
                            $('#clientEmail', jqueryElement).siblings('.invalid-email-message').hide();
                            _validEmail = true;
                        }
                        else {
                            $('#clientEmail', jqueryElement).siblings('.invalid-email-message').show();
                            _validEmail = false;
                        }
                    }
                    else {
                        $('#clientEmail', jqueryElement).siblings('.invalid-email-message').hide();
                        $('#clientEmail', jqueryElement).next('.error-message').show();
                        _validEmail = false;
                    }
                    if (config_policy) {
                        $('#privacyCheckbox', jqueryElement).siblings('.error-message').hide();
                        _privacyPolicyAccepted = true;
                    }
                    else {
                        $('#privacyCheckbox', jqueryElement).siblings('.error-message').show();
                        _privacyPolicyAccepted = false;
                    }
                    if (_validName && _validEmail && _privacyPolicyAccepted) {
                        return true;
                    }
                    else {
                        return false;
                    }
                }
                $('.config-form-get-started', jqueryElement).on('submit', function (e) {
                    if (!validateStartForm()) {
                        e.preventDefault();
                    }
                });
            }
            return SystemConfiguratorStarted;
        }());
        Web.SystemConfiguratorStarted = SystemConfiguratorStarted;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=SystemConfiguratorStarted.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var SystemConfiguratorSummary = /** @class */ (function () {
            function SystemConfiguratorSummary(jqueryElement) {
                $('.toggle-expand', jqueryElement).on('click', function () {
                    $(this).toggleClass('expand');
                    $(this).next('a').toggleClass('hidden');
                    $('.setting-summary').toggleClass('show-summary');
                });
                $('head').append('<link rel="stylesheet" href="/print-css" type="text/css"  media="print" />');
            }
            return SystemConfiguratorSummary;
        }());
        Web.SystemConfiguratorSummary = SystemConfiguratorSummary;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=SystemConfiguratorSummary.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var ToastMessage = /** @class */ (function () {
            function ToastMessage(jqueryElement, param) {
                if ($('.cookie').css('visibility') === 'visible') {
                    $('.toast-message', jqueryElement).addClass('avoid-cookie');
                }
                $(".toast-message", jqueryElement).find('.close-btn').on('click', function () {
                    $(".toast-message", jqueryElement).hide();
                });
                $(".toast-message", jqueryElement).ready(function () {
                    setTimeout(function () {
                        $(".toast-message", jqueryElement).addClass('toast-message-active');
                    }, (param.timeForShow * 1000));
                });
            }
            return ToastMessage;
        }());
        Web.ToastMessage = ToastMessage;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=ToastMessage.js.map;
//Watermark parallaxing on scroll
function netafimParallax() {
    var scrollAmount = $(window).scrollTop();
    var windowsize = $(window).width();
    //Only parallax on tablet landscape and higher
    if (windowsize >= 980) {
        $('.has-parallax').each(function () {
            var scrolled = (($(this).offset().top - scrollAmount) * 0.25) + 'px';
            $(this).css({ "transform": "translate(0," + scrolled + ")" });
        });
    }
    else {
        $('.has-parallax').each(function () {
            $(this).css({ "transform": "translate(0px,0px)" });
        });
    }
}
function verticalTextScroll() {
    if ($('.vertical-text').is(":visible")) {
        var scrollAmount = $(window).scrollTop();
        $('.vertical-text').each(function () {
            var this_container = $(this).parents('.component');
            var this_container_height = this_container.height();
            $(this).css("opacity", 1 - ((scrollAmount - (this_container.offset().top + this_container_height - 490)) / 200));
            if ((scrollAmount + 90 > this_container.offset().top) && (scrollAmount < this_container.offset().top + this_container_height - 300)) {
                $(this).addClass('fixed-top');
            }
            else {
                $(this).removeClass('fixed-top');
            }
        });
    }
}
$(window).on('scroll', function () {
    netafimParallax();
    verticalTextScroll();
});
$(window).on('resize', function () {
    netafimParallax();
});
//# sourceMappingURL=Parallax.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var Weather = /** @class */ (function () {
            function Weather(jqueryElement, params) {
                var _this = this;
                // Fetch weather info
                $.ajax({
                    type: "POST",
                    url: params.weatherFetchUrl,
                    headers: {
                        "Accept-Language": document.documentElement.lang
                    },
                    data: {
                        "blockId": params.blockId
                    },
                    dataType: "html",
                    success: function (data) {
                        var dataHtml = $(jQuery.parseHTML(data));
                        var weatherInfo = $('[data-js="weather-info"]', dataHtml).html();
                        $('[data-js="weather-placeholder"]', jqueryElement).html(weatherInfo);
                        var locationInfo = $('[data-js="location-info"]', dataHtml).html();
                        $("[data-js='location-placeholder']", jqueryElement).html(locationInfo);
                        _this.eventHandlers();
                    }
                });
            }
            Weather.prototype.eventHandlers = function () {
                // Weather forecast
                // Show extra info on hover. On mobile and tablet device show extra info on click.
                if ($(window).width() < 1200) {
                    $("body").on("click touch", ".js-weather-component-item", function (e) {
                        var closest = $(e.target.closest(".js-weather-component-item"));
                        $(closest).siblings().removeClass("active");
                        $(closest).toggleClass("active");
                    });
                }
                else {
                    $("body").on("mouseenter", ".js-weather-component-item", function (e) {
                        var closest = $(e.target.closest(".js-weather-component-item"));
                        $(closest).addClass("active");
                    });
                    $("body").on("mouseleave", ".js-weather-component-item", function (e) {
                        var closest = $(e.target.closest(".js-weather-component-item"));
                        $(closest).removeClass("active");
                    });
                }
            };
            return Weather;
        }());
        Web.Weather = Weather;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=Weather.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var NewsAndEventsOverview = /** @class */ (function () {
            function NewsAndEventsOverview(jqueryElement) {
                $('.article-item', jqueryElement).on('click', function () {
                    var url = $(this).data('href');
                    if (url != undefined && url != null) {
                        window.open(url, '_blank');
                        return false;
                    }
                });
                $('.whatsnew-box', jqueryElement).each(function () {
                    var box = $(this);
                    var number_of_items = $(this).find('.box-item').length;
                    box.find('.box-item').first().addClass('active');
                    $(this).find('.mobile-controller .btn-next').on('click', function () {
                        var current_item_index = box.find('.box-item').index(box.find('.box-item.active'));
                        if (current_item_index === (number_of_items - 1)) {
                            current_item_index = 0;
                        }
                        else {
                            current_item_index = current_item_index + 1;
                        }
                        box.find('.box-item.active').removeClass('active');
                        box.find('.box-item:eq(' + current_item_index + ')').addClass('active');
                    });
                    $(this).find('.mobile-controller .btn-prev').on('click', function () {
                        var current_item_index = box.find('.box-item').index(box.find('.box-item.active'));
                        if (current_item_index === 0) {
                            current_item_index = number_of_items - 1;
                        }
                        else {
                            current_item_index = current_item_index - 1;
                        }
                        box.find('.box-item.active').removeClass('active');
                        box.find('.box-item:eq(' + current_item_index + ')').addClass('active');
                    });
                    $(this).find('.box-item p').each(function () {
                        var len = $(this).text().trim().length;
                        var maxCharacter = 110;
                        if (len > maxCharacter) {
                            $(this).text($(this).text().substr(0, 110) + '...');
                        }
                    });
                });
                function makeHeightEqual() {
                    $('.news-and-events .box-item').height('');
                    for (var i = 0; i < 3; i++) {
                        var newsItemHeight = $('.news .whatsnew-box .box-item').eq(i).height();
                        var eventsItemHeight = $('.events .whatsnew-box .box-item').eq(i).height();
                        if (newsItemHeight !== eventsItemHeight) {
                            if (newsItemHeight > eventsItemHeight) {
                                $('.events .whatsnew-box .box-item').eq(i).height(newsItemHeight);
                            }
                            else {
                                $('.news .whatsnew-box .box-item').eq(i).height(eventsItemHeight);
                            }
                        }
                    }
                }
                if (($('.news-and-events').children().length > 1) && (window.innerWidth >= 1024)) {
                    makeHeightEqual();
                    $(window).on('resize', function () {
                        makeHeightEqual();
                    });
                }
            }
            return NewsAndEventsOverview;
        }());
        Web.NewsAndEventsOverview = NewsAndEventsOverview;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=NewsAndEventsOverview.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var CookiePublisher = /** @class */ (function () {
            function CookiePublisher() {
            }
            CookiePublisher.prototype.subscribeOnCookieAccepted = function (func) {
                PubSub.subscribe("cookie.accepted", func);
            };
            CookiePublisher.prototype.onCookieAccepted = function () {
                PubSub.publish("cookie.accepted", null);
            };
            return CookiePublisher;
        }());
        Web.CookiePublisher = CookiePublisher;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=CookiePublisher.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var CarouselArrow = /** @class */ (function () {
            function CarouselArrow(jqueryElement) {
                var self = this;
                this.carouselObject = {
                    defaultNumberOfItems: 0,
                    itemWidth: 0,
                    currentCarouselItem: 0,
                    moveCarousel: null,
                    updateArrow: null
                };
                $('.carousel-wrapper', jqueryElement).each(function (index, carousel) {
                    self.carouselObject.defaultNumberOfItems = 5;
                    self.carouselObject.itemWidth = $(this).find('.link-box-item').width();
                    self.carouselObject.currentCarouselItem = 0;
                    self.carouselObject.moveCarousel = function (itemWidth, currentCarouselItem) {
                        var moveDistance = itemWidth * currentCarouselItem;
                        $(carousel).find('.link-box-item').css('transform', 'translateX(' + -moveDistance + 'px)');
                    };
                    self.carouselObject.updateArrow = function () {
                        if (self.carouselObject.currentCarouselItem === $(carousel).find('.link-box-item').length - self.carouselObject.defaultNumberOfItems) {
                            $(carousel).find('.nav-arrow-right').addClass('disabled-arrow');
                        }
                        else {
                            $(carousel).find('.nav-arrow-right').removeClass('disabled-arrow');
                        }
                        if (self.carouselObject.currentCarouselItem === 0) {
                            $(carousel).find('.nav-arrow-left').addClass('disabled-arrow');
                        }
                        else {
                            $(carousel).find('.nav-arrow-left').removeClass('disabled-arrow');
                        }
                    };
                    self.carouselObject.updateArrow();
                    if ($(carousel).find('.link-box-item').length <= self.carouselObject.defaultNumberOfItems) {
                        $(carousel).find('.nav-arrow').addClass('hidden');
                        $(carousel).find('.items-list').addClass('link-box');
                    }
                    else {
                        $(carousel).find('.nav-arrow').removeClass('hidden');
                        $(carousel).find('.items-list').removeClass('link-box');
                    }
                    $(carousel).find('.nav-arrow-right').on('click', function () {
                        if (self.carouselObject.currentCarouselItem === $(carousel).find('.link-box-item').length - self.carouselObject.defaultNumberOfItems) {
                            return;
                        }
                        self.carouselObject.currentCarouselItem++;
                        self.carouselObject.moveCarousel(self.carouselObject.itemWidth, self.carouselObject.currentCarouselItem);
                        self.carouselObject.updateArrow();
                    });
                    $(carousel).find('.nav-arrow-left').on('click', function () {
                        if (self.carouselObject.currentCarouselItem === 0) {
                            return;
                        }
                        self.carouselObject.currentCarouselItem--;
                        self.carouselObject.moveCarousel(self.carouselObject.itemWidth, self.carouselObject.currentCarouselItem);
                        self.carouselObject.updateArrow();
                    });
                });
                $('.three-items-carousel-wrapper', jqueryElement).each(function (index, carousel) {
                    self.carouselObject.defaultNumberOfItems = 3;
                    self.carouselObject.itemWidth = $(this).find('.item').outerWidth(true);
                    self.carouselObject.currentCarouselItem = 0;
                    self.carouselObject.moveCarousel = function (itemWidth, currentCarouselItem) {
                        var moveDistance = itemWidth * currentCarouselItem;
                        $(carousel).find('.item').css('transform', 'translateX(' + -moveDistance + 'px)');
                    };
                    self.carouselObject.updateArrow = function () {
                        if (self.carouselObject.currentCarouselItem === $(carousel).find('.item').length - self.carouselObject.defaultNumberOfItems) {
                            $(carousel).find('.nav-arrow-right').addClass('disabled-arrow');
                        }
                        else {
                            $(carousel).find('.nav-arrow-right').removeClass('disabled-arrow');
                        }
                        if (self.carouselObject.currentCarouselItem === 0) {
                            $(carousel).find('.nav-arrow-left').addClass('disabled-arrow');
                        }
                        else {
                            $(carousel).find('.nav-arrow-left').removeClass('disabled-arrow');
                        }
                    };
                    self.carouselObject.updateArrow();
                    if ($(carousel).find('.item').length <= self.carouselObject.defaultNumberOfItems) {
                        $(carousel).find('.nav-arrow').addClass('hidden');
                    }
                    else {
                        $(carousel).find('.nav-arrow').removeClass('hidden');
                    }
                    $(carousel).find('.nav-arrow-right').on('click', function () {
                        if (self.carouselObject.currentCarouselItem === $(carousel).find('.item').length - self.carouselObject.defaultNumberOfItems) {
                            return;
                        }
                        self.carouselObject.currentCarouselItem++;
                        self.carouselObject.moveCarousel(self.carouselObject.itemWidth, self.carouselObject.currentCarouselItem);
                        self.carouselObject.updateArrow();
                    });
                    $(carousel).find('.nav-arrow-left').on('click', function () {
                        if (self.carouselObject.currentCarouselItem === 0) {
                            return;
                        }
                        self.carouselObject.currentCarouselItem--;
                        self.carouselObject.moveCarousel(self.carouselObject.itemWidth, self.carouselObject.currentCarouselItem);
                        self.carouselObject.updateArrow();
                    });
                });
                function updateCarousel() {
                    $('.carousel-wrapper', jqueryElement).each(function (index, carousel) {
                        self.carouselObject.itemWidth = $(carousel).find('.link-box-item').outerWidth(true);
                        self.carouselObject.moveCarousel(self.carouselObject.itemWidth, self.carouselObject.currentCarouselItem);
                    });
                    $('.three-items-carousel-wrapper', jqueryElement).each(function (index, carousel) {
                        self.carouselObject.itemWidth = $(carousel).find('.item').outerWidth(true);
                        self.carouselObject.moveCarousel(self.carouselObject.itemWidth, self.carouselObject.currentCarouselItem);
                    });
                }
                $(window).on('resize', function () {
                    updateCarousel();
                });
            }
            return CarouselArrow;
        }());
        Web.CarouselArrow = CarouselArrow;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=CarouselArrow.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var CookieUtil = /** @class */ (function () {
            function CookieUtil() {
            }
            CookieUtil.createCookie = function (name, value, days) {
                if (days) {
                    var date = new Date();
                    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
                    var expires = "; expires=" + date.toUTCString();
                }
                else {
                    var expires = "";
                }
                document.cookie = name + "=" + value + expires + "; path=/";
            };
            CookieUtil.readCookie = function (name) {
                var nameEQ = name + "=";
                var parts = document.cookie.split(';');
                for (var i = 0; i < parts.length; i++) {
                    var c = parts[i];
                    while (c.charAt(0) == ' ')
                        c = c.substring(1, c.length);
                    if (c.indexOf(nameEQ) == 0)
                        return c.substring(nameEQ.length, c.length);
                }
                return null;
            };
            return CookieUtil;
        }());
        Web.CookieUtil = CookieUtil;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=CookieUtil.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        var HashService = /** @class */ (function () {
            function HashService() {
            }
            HashService.prototype.setHash = function (contentId, hashObject) {
                var objectHashs = this.listObjectsFromHashUrl();
                if (objectHashs.length === 0) {
                    window.location.hash = this.parseObjectHashUrl(contentId, hashObject);
                }
                else {
                    var hash = "";
                    for (var i = 0; i < objectHashs.length; i++) {
                        // update exsited object
                        if (objectHashs[i].key !== contentId) {
                            hash += "&" + this.parseObjectHashUrl(objectHashs[i].key, objectHashs[i].data);
                        }
                    }
                    hash = this.parseObjectHashUrl(contentId, hashObject) + hash;
                    window.location.hash = hash;
                }
            };
            HashService.prototype.getHash = function (contentId) {
                var objectHashs = this.listObjectsFromHashUrl();
                if (objectHashs.length === 0)
                    return null;
                for (var i = 0; i < objectHashs.length; i++) {
                    if (objectHashs[i].key === contentId)
                        return objectHashs[i].data;
                }
                return null;
            };
            HashService.prototype.listObjectsFromHashUrl = function () {
                var res = [];
                var hashUrl = window.location.hash;
                if (!hashUrl)
                    return res;
                if (hashUrl.match("^#")) {
                    hashUrl = hashUrl.substring(1);
                }
                var hashSplit = hashUrl.split('contentId');
                if (hashSplit.length === 0)
                    return res;
                for (var i = 0; i < hashSplit.length; i++) {
                    var hashVal = hashSplit[i];
                    if (hashVal === "")
                        continue;
                    hashVal = "contentId" + hashVal;
                    var hashObject = this.parseHashUrlToObject(hashVal);
                    res.push({
                        key: parseInt(hashObject["contentId"]),
                        data: hashObject
                    });
                }
                return res;
            };
            HashService.prototype.parseObjectHashUrl = function (contentId, hashObject) {
                var hash = "";
                for (var key in hashObject) {
                    if (hashObject.hasOwnProperty(key)) {
                        if (hash !== "") {
                            hash += "&";
                        }
                        hash += key + "=" + encodeURIComponent(hashObject[key]);
                    }
                }
                if (!hashObject.hasOwnProperty("contentId"))
                    hash = "contentId=" + contentId + "&" + hash;
                return hash;
            };
            HashService.prototype.parseHashUrlToObject = function (query) {
                if (query) {
                    var params = {}, e;
                    var re = /([^&=]+)=?([^&]*)/g;
                    if (query.substr(0, 1) === '?') {
                        query = query.substr(1);
                    }
                    while (e = re.exec(query)) {
                        var k = decodeURIComponent(e[1].replace(/\+/g, ' '));
                        var v = decodeURIComponent(e[2].replace(/\+/g, ' '));
                        if (params[k] !== undefined) {
                            if (!$.isArray(params[k])) {
                                params[k] = [params[k]];
                            }
                            params[k].push(v);
                        }
                        else {
                            params[k] = v;
                        }
                    }
                    return params;
                }
                return null;
            };
            return HashService;
        }());
        Web.HashService = HashService;
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=HashService.js.map;
var Netafim;
(function (Netafim) {
    var Web;
    (function (Web) {
        // Multi-lingual ajax requirement, add own Accept-Language
        $(document).ajaxSend(function (event, jqxhr, settings) {
            jqxhr.setRequestHeader("Accept-Language", document.documentElement.lang);
        });
    })(Web = Netafim.Web || (Netafim.Web = {}));
})(Netafim || (Netafim = {}));
//# sourceMappingURL=Initializer.js.map;
