var snEvents = (function () {
    function snEvents() {
        this.cache = {};
        if (snEvents._instance) {
            throw new Error("The Logger is a singleton class and cannot be created!");
        }
        snEvents._instance = this;
    }
    snEvents.getInstance = function () {
        return snEvents._instance;
    };
    snEvents.prototype.pub = function (id) {
        var p = [];
        for (var _i = 1; _i < arguments.length; _i++) {
            p[_i - 1] = arguments[_i];
        }
        var args = [].slice.call(arguments, 1);
        if (!this.cache[id]) {
            this.cache[id] = {
                callbacks: [],
                args: [args]
            };
        }
        for (var i = 0, il = this.cache[id].callbacks.length; i < il; i++) {
            this.cache[id].callbacks[i].apply(null, args);
        }
    };
    snEvents.prototype.sub = function (id, fn) {
        if (!this.cache[id]) {
            this.cache[id] = {
                callbacks: [fn],
                args: []
            };
        }
        else {
            this.cache[id].callbacks.push(fn);
        }
    };
    snEvents.prototype.unsub = function (id, fn) {
        var index;
        if (!this.cache[id]) {
            return;
        }
        if (!fn) {
            this.cache[id] = {
                callbacks: [],
                args: []
            };
        }
        else {
            index = this.cache[id].callbacks.indexOf(fn);
            if (index > -1) {
                this.cache[id].callbacks = this.cache[id].callbacks.slice(0, index).concat(this.cache[id].callbacks.slice(index + 1));
            }
        }
    };
    snEvents._instance = new snEvents();
    return snEvents;
}());
//# sourceMappingURL=sn.app.events.js.map
var Utility = (function () {
    function Utility() {
    }
    Utility.GetWindowHeight = function () {
        var windowHeight = (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight);
        return windowHeight;
    };
    Utility.GetWindowWidth = function () {
        var windowWidth = (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth);
        return windowWidth;
    };
    Utility.HasClass = function (ele, cls) {
        var classMatch = ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
        return classMatch != null && classMatch.length > 0;
    };
    Utility.AddClass = function (ele, cls) {
        if (ele != null) {
            if (!this.HasClass(ele, cls)) {
                ele.className += " " + cls;
            }
        }
    };
    Utility.RemoveClass = function (ele, cls) {
        if (ele != null) {
            if (this.HasClass(ele, cls)) {
                var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
                ele.className = ele.className.replace(reg, ' ');
            }
        }
    };
    Utility.Offset = function (el) {
        var rect = el.getBoundingClientRect(), scrollLeft = window.pageXOffset || document.documentElement.scrollLeft, scrollTop = window.pageYOffset || document.documentElement.scrollTop;
        return { top: rect.top + scrollTop, left: rect.left + scrollLeft };
    };
    Utility.restrictToPhoneNumber = function (event) {
        var k;
        document.all ? k = event.keyCode : k = event.which;
        return (k < 58 || (k > 90 && k < 106) || k == 107);
    };
    Utility.showLoader = function (el, message) {
        if (message === void 0) { message = ""; }
        Utility.AddClass(document.getElementById("loader-wrapper"), "show");
        if (message != "") {
            var messageEl = document.getElementById("loadermessage");
            if (messageEl != null) {
                messageEl.innerText = message;
            }
        }
    };
    Utility.hideLoader = function (el) {
        Utility.RemoveClass(document.getElementById("loader-wrapper"), "show");
        var messageEl = document.getElementById("loadermessage");
        if (messageEl != null) {
            messageEl.innerText = "";
        }
    };
    Utility.getDeviceContext = function () {
        var windowWidth = this.GetWindowWidth();
        if (windowWidth < 768) {
            return DeviceContext.Mobile;
        }
        else {
            if (windowWidth < 1200) {
                return DeviceContext.Tablet;
            }
            else {
                return DeviceContext.Desktop;
            }
        }
    };
    Utility.currentYPosition = function () {
        if (window.pageYOffset)
            return window.pageYOffset;
        if (document.documentElement && document.documentElement.scrollTop)
            return document.documentElement.scrollTop;
        if (document.body.scrollTop)
            return document.body.scrollTop;
        return 0;
    };
    Utility.elmYPosition = function (el) {
        var y = el.offsetTop;
        return y;
    };
    Utility.smoothScroll = function (el, offset) {
        if (offset === void 0) { offset = 0; }
        var startY = Utility.currentYPosition();
        var stopY = Utility.elmYPosition(el) - offset;
        var distance = stopY > startY ? stopY - startY : startY - stopY;
        console.log("page offset: " + window.pageYOffset + " startY: " + startY + " stopY: " + stopY + " distance: " + distance);
        if (distance == 0 || startY < stopY) {
            return;
        }
        var speed = Math.round(distance / 100);
        if (speed >= 20)
            speed = 20;
        var step = Math.round(distance / 50);
        var leapY = stopY > startY ? startY + step : startY - step;
        var timer = 0;
        if (stopY > startY) {
            for (var i = startY; i < stopY; i += step) {
                setTimeout("window.scrollTo(0, " + leapY + ")", timer * speed);
                leapY += step;
                if (leapY > stopY)
                    leapY = stopY;
                timer++;
            }
            return;
        }
        for (var i = startY; i > stopY; i -= step) {
            setTimeout("window.scrollTo(0, " + leapY + ")", timer * speed);
            leapY -= step;
            if (leapY < stopY)
                leapY = stopY;
            timer++;
        }
    };
    Utility.getFormattedDate = function (date) {
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        var year = date.getFullYear();
        return day + "/" + month + "/" + year;
    };
    Utility.getWindowHeight = function () {
        if (!navigator.userAgent.match(/iphone|ipod|ipad/i)) {
            return window.innerHeight;
        }
        else {
            var _dims = { w: 0, h: 0 };
            var _axis = void 0;
            _axis = window.innerHeight > window.innerWidth ? 0 : 90;
            var ruler = document.createElement('div');
            ruler.style.position = 'fixed';
            ruler.style.height = '100vh';
            ruler.style.width = "0";
            ruler.style.top = "0";
            document.documentElement.appendChild(ruler);
            _dims.w = _axis === 90 ? ruler.offsetHeight : window.innerWidth;
            _dims.h = _axis === 90 ? window.innerWidth : ruler.offsetHeight;
            document.documentElement.removeChild(ruler);
            ruler = null;
            console.log("window.innerHeight = " + window.innerHeight);
            if (Math.abs(_axis) !== 90) {
                console.log("ios height = " + _dims.h);
                return _dims.h;
            }
            console.log("ios height = " + _dims.w);
            return _dims.w;
        }
    };
    Utility.addUrlParam = function (key, value) {
        key = encodeURI(key);
        value = encodeURI(value);
        var kvp = document.location.search.substr(1).split('&');
        var i = kvp.length;
        var x;
        while (i--) {
            x = kvp[i].split('=');
            if (x[0] == key) {
                x[1] = value;
                kvp[i] = x.join('=');
                break;
            }
        }
        if (i < 0) {
            kvp[kvp.length] = [key, value].join('=');
        }
        document.location.search = kvp.join('&');
    };
    Utility.getUrlParam = function (key, urladdress) {
        if (urladdress === void 0) { urladdress = ""; }
        if (urladdress == "")
            urladdress = self.location.toString();
        urladdress = window.location.search.substring(1);
        var vars = urladdress.split("&");
        var query_string = {};
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            var keypart = decodeURIComponent(pair[0]);
            var value = decodeURIComponent(pair[1]);
            if (typeof query_string[keypart] === "undefined") {
                query_string[keypart] = decodeURIComponent(value);
            }
            else if (typeof query_string[keypart] === "string") {
                var arr = [query_string[keypart], decodeURIComponent(value)];
                query_string[keypart] = arr;
            }
            else {
                query_string[keypart].push(decodeURIComponent(value));
            }
        }
        return query_string[key];
    };
    Utility.getCookie = function (name) {
        var nameLenPlus = (name.length + 1);
        return document.cookie
            .split(';')
            .map(function (c) { return c.trim(); })
            .filter(function (cookie) {
            return cookie.substring(0, nameLenPlus) === name + "=";
        })
            .map(function (cookie) {
            return decodeURIComponent(cookie.substring(nameLenPlus));
        })[0] || null;
    };
    Utility.setCookie = function (name, val, days) {
        var date = new Date();
        var value = val;
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        document.cookie = name + "=" + value + "; expires=" + date.toUTCString() + "; path=/";
    };
    return Utility;
}());
var MD5;
(function (MD5) {
    function md5cycle(x, k) {
        var a = x[0], b = x[1], c = x[2], d = x[3];
        a = ff(a, b, c, d, k[0], 7, -680876936);
        d = ff(d, a, b, c, k[1], 12, -389564586);
        c = ff(c, d, a, b, k[2], 17, 606105819);
        b = ff(b, c, d, a, k[3], 22, -1044525330);
        a = ff(a, b, c, d, k[4], 7, -176418897);
        d = ff(d, a, b, c, k[5], 12, 1200080426);
        c = ff(c, d, a, b, k[6], 17, -1473231341);
        b = ff(b, c, d, a, k[7], 22, -45705983);
        a = ff(a, b, c, d, k[8], 7, 1770035416);
        d = ff(d, a, b, c, k[9], 12, -1958414417);
        c = ff(c, d, a, b, k[10], 17, -42063);
        b = ff(b, c, d, a, k[11], 22, -1990404162);
        a = ff(a, b, c, d, k[12], 7, 1804603682);
        d = ff(d, a, b, c, k[13], 12, -40341101);
        c = ff(c, d, a, b, k[14], 17, -1502002290);
        b = ff(b, c, d, a, k[15], 22, 1236535329);
        a = gg(a, b, c, d, k[1], 5, -165796510);
        d = gg(d, a, b, c, k[6], 9, -1069501632);
        c = gg(c, d, a, b, k[11], 14, 643717713);
        b = gg(b, c, d, a, k[0], 20, -373897302);
        a = gg(a, b, c, d, k[5], 5, -701558691);
        d = gg(d, a, b, c, k[10], 9, 38016083);
        c = gg(c, d, a, b, k[15], 14, -660478335);
        b = gg(b, c, d, a, k[4], 20, -405537848);
        a = gg(a, b, c, d, k[9], 5, 568446438);
        d = gg(d, a, b, c, k[14], 9, -1019803690);
        c = gg(c, d, a, b, k[3], 14, -187363961);
        b = gg(b, c, d, a, k[8], 20, 1163531501);
        a = gg(a, b, c, d, k[13], 5, -1444681467);
        d = gg(d, a, b, c, k[2], 9, -51403784);
        c = gg(c, d, a, b, k[7], 14, 1735328473);
        b = gg(b, c, d, a, k[12], 20, -1926607734);
        a = hh(a, b, c, d, k[5], 4, -378558);
        d = hh(d, a, b, c, k[8], 11, -2022574463);
        c = hh(c, d, a, b, k[11], 16, 1839030562);
        b = hh(b, c, d, a, k[14], 23, -35309556);
        a = hh(a, b, c, d, k[1], 4, -1530992060);
        d = hh(d, a, b, c, k[4], 11, 1272893353);
        c = hh(c, d, a, b, k[7], 16, -155497632);
        b = hh(b, c, d, a, k[10], 23, -1094730640);
        a = hh(a, b, c, d, k[13], 4, 681279174);
        d = hh(d, a, b, c, k[0], 11, -358537222);
        c = hh(c, d, a, b, k[3], 16, -722521979);
        b = hh(b, c, d, a, k[6], 23, 76029189);
        a = hh(a, b, c, d, k[9], 4, -640364487);
        d = hh(d, a, b, c, k[12], 11, -421815835);
        c = hh(c, d, a, b, k[15], 16, 530742520);
        b = hh(b, c, d, a, k[2], 23, -995338651);
        a = ii(a, b, c, d, k[0], 6, -198630844);
        d = ii(d, a, b, c, k[7], 10, 1126891415);
        c = ii(c, d, a, b, k[14], 15, -1416354905);
        b = ii(b, c, d, a, k[5], 21, -57434055);
        a = ii(a, b, c, d, k[12], 6, 1700485571);
        d = ii(d, a, b, c, k[3], 10, -1894986606);
        c = ii(c, d, a, b, k[10], 15, -1051523);
        b = ii(b, c, d, a, k[1], 21, -2054922799);
        a = ii(a, b, c, d, k[8], 6, 1873313359);
        d = ii(d, a, b, c, k[15], 10, -30611744);
        c = ii(c, d, a, b, k[6], 15, -1560198380);
        b = ii(b, c, d, a, k[13], 21, 1309151649);
        a = ii(a, b, c, d, k[4], 6, -145523070);
        d = ii(d, a, b, c, k[11], 10, -1120210379);
        c = ii(c, d, a, b, k[2], 15, 718787259);
        b = ii(b, c, d, a, k[9], 21, -343485551);
        x[0] = add32(a, x[0]);
        x[1] = add32(b, x[1]);
        x[2] = add32(c, x[2]);
        x[3] = add32(d, x[3]);
    }
    function cmn(q, a, b, x, s, t) {
        a = add32(add32(a, q), add32(x, t));
        return add32((a << s) | (a >>> (32 - s)), b);
    }
    function ff(a, b, c, d, x, s, t) {
        return cmn((b & c) | ((~b) & d), a, b, x, s, t);
    }
    function gg(a, b, c, d, x, s, t) {
        return cmn((b & d) | (c & (~d)), a, b, x, s, t);
    }
    function hh(a, b, c, d, x, s, t) {
        return cmn(b ^ c ^ d, a, b, x, s, t);
    }
    function ii(a, b, c, d, x, s, t) {
        return cmn(c ^ (b | (~d)), a, b, x, s, t);
    }
    function md51(s) {
        var txt = '';
        var n = s.length, state = [1732584193, -271733879, -1732584194, 271733878], i;
        for (i = 64; i <= s.length; i += 64) {
            md5cycle(state, md5blk(s.substring(i - 64, i)));
        }
        s = s.substring(i - 64);
        var tail = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
        for (i = 0; i < s.length; i++)
            tail[i >> 2] |= s.charCodeAt(i) << ((i % 4) << 3);
        tail[i >> 2] |= 0x80 << ((i % 4) << 3);
        if (i > 55) {
            md5cycle(state, tail);
            for (i = 0; i < 16; i++)
                tail[i] = 0;
        }
        tail[14] = n * 8;
        md5cycle(state, tail);
        return state;
    }
    function md5blk(s) {
        var md5blks = [], i;
        for (i = 0; i < 64; i += 4) {
            md5blks[i >> 2] = s.charCodeAt(i) + (s.charCodeAt(i + 1) << 8) + (s.charCodeAt(i + 2) << 16) + (s.charCodeAt(i + 3) << 24);
        }
        return md5blks;
    }
    var hex_chr = '0123456789abcdef'.split('');
    function rhex(n) {
        var s = '', j = 0;
        for (; j < 4; j++)
            s += hex_chr[(n >> (j * 8 + 4)) & 0x0F] + hex_chr[(n >> (j * 8)) & 0x0F];
        return s;
    }
    function hex(x) {
        for (var i = 0; i < x.length; i++)
            x[i] = rhex(x[i]);
        return x.join('');
    }
    function md5(s) {
        return hex(md51(s));
    }
    var add32 = function (a, b) {
        return (a + b) & 0xFFFFFFFF;
    };
    if (md5('hello') != '5d41402abc4b2a76b9719d911017c592') {
        add32 = function (x, y) {
            var lsw = (x & 0xFFFF) + (y & 0xFFFF), msw = (x >> 16) + (y >> 16) + (lsw >> 16);
            return (msw << 16) | (lsw & 0xFFFF);
        };
    }
    MD5.encrypt = function (s) {
        return md5(s);
    };
})(MD5 || (MD5 = {}));
//# sourceMappingURL=sn.app.utility.js.map
var DeviceContext;
(function (DeviceContext) {
    DeviceContext[DeviceContext["Mobile"] = 0] = "Mobile";
    DeviceContext[DeviceContext["Tablet"] = 1] = "Tablet";
    DeviceContext[DeviceContext["Desktop"] = 2] = "Desktop";
})(DeviceContext || (DeviceContext = {}));
var Shared = (function () {
    function Shared() {
    }
    Shared.ToggleScrollbar = function (el) {
        if (el != null) {
            console.log(el.scrollHeight);
            console.log(Utility.GetWindowHeight());
            if (el.scrollHeight > Utility.GetWindowHeight()) {
                el.style.overflowY = "scroll";
                document.documentElement.style.overflowY = "hidden";
            }
            else {
                el.style.overflowY = "initial";
                if (el.scrollHeight == Utility.GetWindowHeight()) {
                    document.documentElement.style.overflowY = "hidden";
                }
                else {
                    document.documentElement.style.overflowY = "initial";
                }
            }
        }
        else {
            el.style.overflowY = "initial";
            document.documentElement.style.overflowY = "initial";
        }
    };
    Shared.getParameterByName = function (name, url) {
        if (!url)
            url = window.location.href;
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url);
        if (!results)
            return null;
        if (!results[2])
            return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));
    };
    Shared.gotoraq = function (url) {
        PageLogger.LogEstPageStep(null, EstablishmentStep.GotoRaq, "raq-start");
        window.location.href = url;
    };
    return Shared;
}());
//# sourceMappingURL=sn.app.shared.js.map
var snDateRange = (function () {
    function snDateRange(showClearDates, service) {
        if (showClearDates === void 0) { showClearDates = false; }
        this._showClearDates = showClearDates;
        this._service = service;
        this._callbacks = [];
        this._dateRange = $([]).add($("#Checkin")).add($("#Checkout"));
        var self = this;
        this.initializeDates(self);
    }
    snDateRange.prototype.initializeDates = function (self) {
        if (($("#Checkin").length) || ($("#Checkout").length)) {
            this._dateRange.dateRange({
                showAvailability: false,
                showClearDates: this._showClearDates,
                autoToDateFocus: true,
                autoOpenFromDate: false,
                minDate: new Date(),
                showButtonPanel: true,
                unavailableDates: $([]),
                onClose: function (fromTo, date, changed, otherDate, toDateClosed) {
                    $(".ui-date-picker.checkin").val($("#Checkin").val());
                    $(".ui-date-picker.checkout").val($("#Checkout").val());
                    if (fromTo) {
                    }
                    if (toDateClosed && date != null) {
                        self._callbacks.forEach(function (callback) {
                            callback.call(null);
                        });
                    }
                },
                onClear: function () {
                    $("#Checkin").val("Check-in");
                    $("#Checkout").val("Check-out");
                    self._service.callback(self._service);
                }
            });
        }
    };
    snDateRange.prototype.onClose = function (callback) {
        this._callbacks.push(callback);
    };
    return snDateRange;
}());
//# sourceMappingURL=sn.app.daterange.js.map
var snSearch = (function () {
    function snSearch(mobileBreakpoint, service) {
        var _this = this;
        this._mobileBreakpoint = mobileBreakpoint;
        this._service = service;
        var _self = this;
        searchBox = $("#SearchFilterFilterSearchTerm");
        searchBoxUrl = $("#SearchFilterURL");
        searchCheckIn = $(".checkin");
        searchCheckOut = $(".checkout");
        searchGuests = $("#dd-guests");
        this.initDates();
        document.getElementById("btnSearch").addEventListener("click", function (e) { return _this.onSearchClick(e, _self, "searchbutton"); });
    }
    snSearch.prototype.initDates = function () {
        var _this = this;
        var dates = new snDateRange(true, this._service);
        dates.onClose(function (event) {
            _this.onSearchClick(event, _this, "datepicker");
        });
    };
    snSearch.prototype.onSearchClick = function (e, self, context) {
        var searchBoxUrl = $("#SearchFilterURL");
        if ($("#Checkin").val() !== "") {
            if ($("#Checkout").val() === "") {
                $.scrollTo($("#Checkout"), 600, {
                    offset: -30,
                    onAfter: function () {
                        $("#Checkout").focus();
                    }
                });
            }
            if ($("#Checkin").val() !== null && $("#Checkout").val() !== null) {
                if ($("#Checkin").val() !== "") {
                    if ($("#Checkout").val() === "") {
                        $.scrollTo($("#Checkout"), 600, {
                            offset: -30,
                            onAfter: function () {
                                $("#Checkout").focus();
                            }
                        });
                    }
                }
                else {
                    $("#missing-dates").hide();
                    $("#Checkin").focus();
                }
            }
            if ((Utility.getDeviceContext() !== DeviceContext.Mobile) ||
                (Utility.getDeviceContext() === DeviceContext.Mobile && context === "searchbutton")) {
                if (searchBoxUrl.val() === "undefined") {
                    window.location.href = "/search/mainsearch.aspx?term=" + $("#SearchFilterFilterSearchTerm").val();
                }
                else {
                    if (searchBoxUrl.val() === document.getElementById("huburl").value) {
                        snEvents.getInstance().pub("searchcriteriachange", self._service);
                    }
                    else {
                        self.setPageAndUrl(searchBoxUrl.val(), self);
                        window.location.href = searchBoxUrl.val() !== "undefined"
                            ? searchBoxUrl.val()
                            : "/search/mainsearch.aspx?term=" + $("#SearchFilterFilterSearchTerm").val();
                    }
                }
            }
        }
    };
    snSearch.prototype.setPageAndUrl = function (url, self) {
        var querystring = "";
        var checkInDate = new Date(searchCheckIn.val());
        var checkOutDate = new Date(searchCheckOut.val());
        var guests = searchGuests.val();
        if (checkInDate.valueOf() > 0 && checkOutDate.valueOf() > 0) {
            querystring += "?checkin=" +
                Utility.getFormattedDate(checkInDate) +
                "&checkout=" +
                Utility.getFormattedDate(checkOutDate);
        }
        querystring += (querystring.length > 0 ? "&" : "?") + "guests=" + guests;
        if (querystring.length > 0) {
            querystring = querystring.replace(/,/g, "|");
        }
        searchBoxUrl.val(url + querystring);
    };
    return snSearch;
}());
//# sourceMappingURL=sn.app.search.js.map
var DisplayType;
(function (DisplayType) {
    DisplayType[DisplayType["Modal"] = 0] = "Modal";
    DisplayType[DisplayType["Slide"] = 1] = "Slide";
})(DisplayType || (DisplayType = {}));
var Modal = (function () {
    function Modal(modalName, selector, openSelectors, closeSelectors, displayType, maxWidthPercentage, maxWidthPixels, showOnMobileOnly, mobileBreakpoint, showOverlay) {
        var _this = this;
        if (displayType === void 0) { displayType = DisplayType.Modal; }
        if (maxWidthPercentage === void 0) { maxWidthPercentage = 100; }
        if (maxWidthPixels === void 0) { maxWidthPixels = 100; }
        if (showOnMobileOnly === void 0) { showOnMobileOnly = false; }
        if (mobileBreakpoint === void 0) { mobileBreakpoint = 360; }
        if (showOverlay === void 0) { showOverlay = false; }
        this.Visible = false;
        this.Active = false;
        this.Selector = selector;
        this.OpenSelectors = openSelectors;
        this.CloseSelectors = closeSelectors;
        this.MaxWidthPercentage = maxWidthPercentage;
        this.MaxWidthPixels = maxWidthPixels;
        this.ShowOnMobileOnly = showOnMobileOnly;
        this.MobileBreakpoint = mobileBreakpoint;
        this.ModalElement = document.querySelector(this.Selector);
        this.ModalName = modalName;
        this.ShowOverlay = showOverlay;
        var self = this;
        for (var o = 0; o < this.OpenSelectors.length; o++) {
            var elements = document.querySelectorAll(this.OpenSelectors[o]);
            for (var e = 0; e < elements.length; e++) {
                var openEl = elements[e];
                if (displayType === DisplayType.Modal) {
                    openEl.addEventListener("click", function (e) { return _this.onShow(e, self); });
                }
                else {
                    openEl.addEventListener("click", function (e) { return _this.onSlideIn(e, self); });
                }
            }
        }
        for (var c = 0; c < this.CloseSelectors.length; c++) {
            var elements = document.querySelectorAll(this.CloseSelectors[c]);
            for (var e = 0; e < elements.length; e++) {
                var closeEl = elements[e];
                if (displayType === DisplayType.Modal) {
                    closeEl.addEventListener("click", function (e) { return _this.onHide(e, self, true); });
                }
                else {
                    closeEl.addEventListener("click", function (e) { return _this.onSlideOut(e, self, true); });
                }
            }
        }
        if (displayType === DisplayType.Modal) {
            window.addEventListener("resize", function (e) { return _this.onInstantModalWindowResize(e, self); });
        }
        else {
            window.addEventListener("resize", function (e) { return _this.onSlideModalWindowResize(e, self); });
        }
        snEvents.getInstance().sub("overlayclick", function (e) {
            self.onSlideOut(e, self, false);
        });
    }
    Modal.prototype.onShow = function (e, modal) {
        e.preventDefault;
        Utility.AddClass(modal.ModalElement, "full-screen");
        Shared.ToggleScrollbar(modal.ModalElement);
        modal.Visible = true;
        snEvents.getInstance().pub("modalshow", modal);
    };
    Modal.prototype.onHide = function (e, modal, internal) {
        if (internal === void 0) { internal = false; }
        if (e != null) {
            e.preventDefault;
        }
        Utility.RemoveClass(document.body, "noscroll");
        Utility.RemoveClass(modal.ModalElement, "full-screen");
        Shared.ToggleScrollbar(modal.ModalElement);
        modal.Visible = false;
        if (internal) {
            snEvents.getInstance().pub("modalhide", modal);
        }
    };
    Modal.prototype.onSlideIn = function (e, modal) {
        e.preventDefault;
        modal.Visible = true;
        var width = this.GetMaxWidth();
        var left = this.GetLeftPosition();
        modal.ModalElement.style.width = width.toString() + "px";
        modal.ModalElement.style.left = left;
        modal.ModalElement.style.opacity = "1";
        modal.ModalElement.style.zIndex = "50";
        modal.ModalElement.style.transition = "0.7s";
        modal.ModalElement.style.padding = "0";
        modal.ModalElement.style.background = "#fff";
        var closeButton = modal.ModalElement.querySelector(".close");
        var mobileCloseButtons = modal.ModalElement.querySelectorAll(".modal-close-slide,.modal-close-slide-arrow");
        var content = modal.ModalElement.querySelector(".slidecontent");
        if (closeButton != null) {
            closeButton.style.width = width.toString() + "px";
            closeButton.style.left = "initial";
        }
        for (var i_1 = 0; i_1 < mobileCloseButtons.length; i_1++) {
            var mobileCloseButton = mobileCloseButtons[i_1];
            if (mobileCloseButton != null) {
                mobileCloseButton.style.width = width.toString() + "px";
                mobileCloseButton.style.left = "initial";
            }
        }
        Shared.ToggleScrollbar(modal.ModalElement);
        snEvents.getInstance().pub("modalslidein", modal);
    };
    Modal.prototype.onSlideOut = function (e, modal, internal) {
        if (modal.Visible) {
            if (e != null) {
                e.preventDefault;
            }
            modal.ModalElement.style.overflowY = "initial";
            document.documentElement.style.overflowY = "initial";
            modal.ModalElement.style.left = "100%";
            var closeButton = modal.ModalElement.querySelector(".modal-close-slide");
            if (closeButton != null) {
                closeButton.style.left = "100%";
            }
            closeButton = modal.ModalElement.querySelector(".modal-close-slide-arrow");
            if (closeButton != null) {
                closeButton.style.left = "100%";
            }
            modal.Visible = false;
            modal.ModalElement.style.zIndex = "30";
        }
        snEvents.getInstance().pub("modalslideout", modal);
    };
    Modal.prototype.onSlideModalWindowResize = function (e, modal) {
        if (modal.Visible) {
            var width = this.GetMaxWidth();
            var left = this.GetLeftPosition();
            modal.ModalElement.style.transitionProperty = "none";
            modal.ModalElement.style.width = width.toString() + "px";
            modal.ModalElement.style.left = left;
            var closeButton = modal.ModalElement.querySelector(".close");
            var mobileCloseButtons = modal.ModalElement.querySelectorAll(".modal-close-slide,.modal-close-slide-arrow");
            if (closeButton != null) {
                closeButton.style.width = width.toString() + "px";
                closeButton.style.left = "initial";
            }
            for (var i_2 = 0; i_2 < mobileCloseButtons.length; i_2++) {
                var mobileCloseButton = mobileCloseButtons[i_2];
                if (mobileCloseButton != null) {
                    mobileCloseButton.style.width = width.toString() + "px";
                    mobileCloseButton.style.left = "initial";
                }
            }
            if (width > this.MobileBreakpoint) {
                if (this.ShowOnMobileOnly) {
                    modal.onSlideOut(null, modal, true);
                }
            }
        }
    };
    Modal.prototype.onInstantModalWindowResize = function (e, modal) {
        if (modal.Visible) {
            var width = Utility.GetWindowWidth();
            if (width > this.MobileBreakpoint) {
                modal.onHide(null, modal);
            }
        }
    };
    Modal.prototype.GetMaxWidth = function () {
        return Math.min(Utility.GetWindowWidth() * this.MaxWidthPercentage / 100, this.MaxWidthPixels);
    };
    Modal.prototype.GetLeftPosition = function () {
        return (Utility.GetWindowWidth() - Math.min(Utility.GetWindowWidth() * this.MaxWidthPercentage / 100, this.MaxWidthPixels)).toString() + "px";
    };
    return Modal;
}());
//# sourceMappingURL=sn.app.modal.js.map
var Overlay = (function () {
    function Overlay(selector, showClass) {
        this._element = null;
        this._element = document.querySelector(selector);
        this._showClass = showClass;
        var self = this;
        snEvents.getInstance().sub("modalslidein", function (item) {
            if (item.ShowOverlay) {
                self.show();
            }
        });
        snEvents.getInstance().sub("modalslideout", function (item) {
            self.hide();
        });
        snEvents.getInstance().sub("modalhide", function (item) {
            self.hide();
        });
        this._element.addEventListener("click", function () {
            snEvents.getInstance().pub("overlayclick");
            self.hide();
        });
    }
    Overlay.prototype.show = function () {
        Utility.AddClass(this._element, this._showClass);
    };
    Overlay.prototype.hide = function () {
        Utility.RemoveClass(this._element, this._showClass);
    };
    return Overlay;
}());
//# sourceMappingURL=sn.app.overlay.js.map
var snGallery = (function () {
    function snGallery() {
    }
    snGallery.prototype.init = function () {
        var _this = this;
        var screenOptions = {};
        screenOptions.enabled = false;
        screenOptions.nativeFS = true;
        var sliderOptions = {};
        sliderOptions.controlNavigation = "none",
            sliderOptions.controlsInside = false,
            sliderOptions.imageScaleMode = "none",
            sliderOptions.imageScalePadding = 0,
            sliderOptions.imageAlignCenter = false,
            sliderOptions.loop = true,
            sliderOptions.navigateByClick = false,
            sliderOptions.numImagesToPreload = 0,
            sliderOptions.arrowsNav = false,
            sliderOptions.arrowsNavAutoHide = false,
            sliderOptions.arrowsNavHideOnTouch = false,
            sliderOptions.keyboardNavEnabled = false,
            sliderOptions.fadeinLoadedSlide = true,
            sliderOptions.globalCaption = false,
            sliderOptions.fullscreen = screenOptions;
        $(".royalSlider").royalSlider(sliderOptions);
        $(".royalSlider").each(function (index) {
            var slider = $($(".royalSlider")[index]).royalSlider().data("royalSlider");
            slider.ev.on("rsDragStart", function (e) {
                _this.fetch(slider, null);
            });
            slider.ev.on("rsSlideClick", function (event, originalEvent) {
                snEvents.getInstance().pub("slideclick", slider.slider.data("url"));
                originalEvent.stopPropagation();
            });
            slider.slider.parent("div.rsWrapper").on("click", ".gallery-left", function () {
                _this.fetch(slider, function () { slider.prev(); });
            });
            slider.slider.parent("div.rsWrapper").on("click", ".gallery-right", function () {
                _this.fetch(slider, function () { slider.next(); });
            });
            slider.ev.on("rsAfterContentSet", function (e, slideObject) {
                $(slideObject.content[0]).find("img").lazyload({ threshold: 100, placeholder: "/res/img/no-image-logo.png" });
            });
        });
        $(document).on("mouseenter", ".gallery-left", function () {
            $(".gallery-left").stop().fadeTo("fast", 1);
            $(".gallery-right").stop().fadeTo("fast", 0.8);
        });
        $(document).on("mouseleave", ".gallery-left", function () {
            $(".gallery-left").stop().fadeTo("fast", 0.8);
        });
        $(document).on("mouseenter", ".gallery-right", function () {
            $(".gallery-right").stop().fadeTo("fast", 1);
            $(".gallery-left").stop().fadeTo("fast", 0.8);
        });
        $(document).on("mouseleave", ".gallery-right", function () {
            $(".gallery-right").stop().fadeTo("fast", 0.8);
        });
        $(".card .images img").lazyload({ threshold: 100, placeholder: "/res/img/no-image-logo.png" });
        $(".card-h .images img").lazyload({ threshold: 100, placeholder: "/res/img/no-image-logo.png" });
    };
    snGallery.prototype.fetch = function (slider, onDone) {
        var alreadyLoaded = slider.slider.data("images-loaded");
        if (alreadyLoaded) {
            if (onDone != null)
                onDone();
            return;
        }
        ;
        var url = "/listing/GetListItemImages/";
        var model = {
            spid: slider.slider.data("image-spid"),
            currentImageIndex: slider.currSlideId
        };
        $.ajax({
            type: "POST",
            url: url,
            data: model,
            beforeSend: function () { }
        })
            .done(function (response) {
            $(response).filter("a").each(function (i) {
                slider.appendSlide($(response)[i]);
            });
            if (onDone != null) {
                onDone();
            }
            slider.slider.data("images-loaded", "true");
        })
            .fail(function () {
        });
    };
    return snGallery;
}());
//# sourceMappingURL=sn.app.gallery.js.map
sn.app.map = sn.app.map ||
    {
        Data: [],
        Markers: [{}],
        Zoom: 10,
        MapInstances: [],
        InfoWindow: null,
        EnableDragSearch: true,
        SearchFunction: function () {
        },
        SearchOnLoad: false,
        ShowInitialOverlay: false,
        ShowTools: false,
        ShowLegend: false,
        ContentMarkers: [],
        Service: null,
        initContentHomePage: function () {
            var $window = $(window), mapInstances = [], $pluginInstance = $(".map")
                .lazyLoadGoogleMaps({
                callback: function (container, map) {
                    var $container = $(container), center = new google.maps.LatLng(Number($container.attr("data-lat")), Number($container.attr("data-lng")));
                    map.setOptions({
                        zoom: 15,
                        center: center,
                        scrollwheel: false,
                        styles: [{ featureType: "poi", stylers: [{ visibility: "off" }] }]
                    });
                    var marker = new google.maps.Marker({ position: center, map: map });
                    $.data(map, "center", center);
                    var infowindow = new google.maps.InfoWindow({ maxWidth: 300 });
                    infowindow.setContent($("#mapInfoWindow").val());
                    infowindow.open(map, marker);
                    map.panBy(0, -80);
                    mapInstances.push(map);
                    var updateCenter = function () { $.data(map, "center", map.getCenter()); };
                    google.maps.event.addListener(map, "dragend", updateCenter);
                    google.maps.event.addListener(map, "zoom_changed", updateCenter);
                    google.maps.event.addListenerOnce(map, "idle", function () { $container.addClass("is-loaded"); });
                },
                api_key: "AIzaSyB16lAbslq9Y69-wzYl-nwW8OxJMdo2f4I"
            });
            $window.on("resize", $pluginInstance.debounce(1000, function () {
                $.each(mapInstances, function () {
                    this.setCenter($.data(this, "center"));
                    if (this.getDiv().offsetHeight === 300) {
                        this.panBy(0, -80);
                    }
                });
            }));
        },
        initEstablishmentHomePage: function () {
            var $window = $(window), mapInstances = [], $pluginInstance = $(".map")
                .lazyLoadGoogleMaps({
                callback: function (container, map) {
                    var $container = $(container), center = new google.maps.LatLng(Number($container.attr("data-lat")), Number($container.attr("data-lng")));
                    var poiSetting = $(".nav-staff").length > 0 ? "on" : "off";
                    map.setOptions({
                        zoom: 17,
                        center: center,
                        mapTypeControl: false,
                        scrollwheel: false,
                        styles: [{ featureType: "poi", stylers: [{ visibility: poiSetting }] }]
                    });
                    var marker = new google.maps.Marker({ position: center, map: map });
                    $.data(map, "center", center);
                    var infowindow = new google.maps.InfoWindow({ maxWidth: 300 });
                    infowindow.setContent($("#mapInfoWindow").val());
                    infowindow.open(map, marker);
                    map.panBy(0, -80);
                    mapInstances.push(map);
                    var updateCenter = function () { $.data(map, "center", map.getCenter()); };
                    google.maps.event.addListener(map, "dragend", updateCenter);
                    google.maps.event.addListener(map, "zoom_changed", updateCenter);
                    google.maps.event.addListenerOnce(map, "idle", function () {
                        $container.addClass("is-loaded");
                        setTimeout(function () {
                            if (document.getElementsByClassName('infoWindow').length > 0) {
                                ko.cleanNode(document.getElementsByClassName('infoWindow')[0]);
                                ko.applyBindings(sn.app.esthomepagev3.ViewModel, document.getElementsByClassName('infoWindow')[0]);
                            }
                        }, 200);
                    });
                },
                api_key: "AIzaSyB16lAbslq9Y69-wzYl-nwW8OxJMdo2f4I"
            });
            $window.on("resize", $pluginInstance.debounce(1000, function () {
                $.each(mapInstances, function () {
                    this.setCenter($.data(this, "center"));
                    if (this.getDiv().offsetHeight === 300) {
                        this.panBy(0, -80);
                    }
                });
            }));
        },
        initRootLocation: function () {
            var $window = $(window), mapInstances = [], $pluginInstance = $(".map")
                .lazyLoadGoogleMaps({
                callback: function (container, map) {
                    var $container = $(container), center = new google.maps.LatLng(Number($container.attr("data-lat")), Number($container.attr("data-lng")));
                    map.setOptions({
                        zoom: 15,
                        center: center,
                        scrollwheel: false,
                        mapTypeControl: false,
                        styles: [{ featureType: "poi", stylers: [{ visibility: "off" }] }]
                    });
                    var marker = new google.maps.Marker({ position: center, map: map });
                    $.data(map, "center", center);
                    var infowindow = new google.maps.InfoWindow({ maxWidth: 300 });
                    infowindow.setContent($("#mapInfoWindow").val());
                    infowindow.open(map, marker);
                    map.panBy(0, -80);
                    mapInstances.push(map);
                    var updateCenter = function () { $.data(map, "center", map.getCenter()); };
                    google.maps.event.addListener(map, "dragend", updateCenter);
                    google.maps.event.addListener(map, "zoom_changed", updateCenter);
                    google.maps.event.addListenerOnce(map, "idle", function () { $container.addClass("is-loaded"); });
                },
                api_key: "AIzaSyB16lAbslq9Y69-wzYl-nwW8OxJMdo2f4I"
            });
            $window.on("resize", $pluginInstance.debounce(1000, function () {
                $.each(mapInstances, function () {
                    this.setCenter($.data(this, "center"));
                    if (this.getDiv().offsetHeight === 300) {
                        this.panBy(0, -80);
                    }
                });
            }));
        },
        initListingMap: function (zoomLevel, enableDragSearch, searchOnLoad, showInitialOverlay, showTools, showLegend, showThings, service) {
            this.EnableDragSearch = true;
            this.SearchOnLoad = searchOnLoad;
            this.ShowInitialOverlay = showInitialOverlay;
            this.ShowTools = false;
            this.ShowLegend = false;
            this.Service = service;
            var $window = $(window);
            var $pluginInstance = $(".map")
                .lazyLoadGoogleMaps({
                callback: function (container, map) {
                    var _this = this;
                    $("body").append("<script src=\"/res/ext/mapmarkerlabel/markerwithlabel.js\"></script>");
                    $("body").append("<script src=\"/res/ext/mapinfobox/infobox.js\"></script>");
                    $("body").append("<script src=\"/res/ext/maptooltip/tooltip.js\"></script>");
                    if (!sn.app.map.ShowLegend) {
                        $("#legend").hide();
                    }
                    var $container = $(container), center = new google.maps.LatLng(Number($container.attr("data-lat")), Number($container.attr("data-lng")));
                    if ($container.attr("data-lat") != null) {
                        sn.app.map.Zoom = Number($container.attr("data-zoom"));
                    }
                    if (!(sn.app.map.Zoom > 0)) {
                        sn.app.map.Zoom = 10;
                    }
                    map.setOptions({
                        zoom: sn.app.map.Zoom,
                        center: center,
                        scrollwheel: false,
                        panControl: true,
                        mapTypeControl: false,
                        mapTypeId: "roadmap",
                        zoomControlOptions: {
                            style: google.maps.ZoomControlStyle.LARGE,
                            position: google.maps.ControlPosition.RIGHT_CENTER
                        },
                        panControlOptions: { position: google.maps.ControlPosition.LEFT_TOP },
                        styles: [{ featureType: "poi", stylers: [{ visibility: "off" }] }]
                    });
                    googleMapWidth = $container.css("width");
                    googleMapHeight = $container.css("height");
                    sn.app.map.InfoWindow = new google.maps.InfoWindow({ maxWidth: 300 });
                    var i;
                    for (i = 0; i < sn.app.map.Data.length; i++) {
                        var item = sn.app.map.Data[i];
                        sn.app.map.createMarker(map, item);
                    }
                    $.data(map, "center", center);
                    sn.app.map.MapInstances.push(map);
                    google.maps.event.addListener(map, "dragend", function () {
                        sn.app.map.searchAndRefresh(map);
                    });
                    google.maps.event.addListener(map, "zoom_changed", function () {
                        sn.app.map.searchAndRefresh(map);
                    });
                    google.maps.event.addListenerOnce(map, "idle", function () {
                        $container.addClass("is-loaded");
                        if (sn.app.map.SearchOnLoad) {
                            $("#mapNorthEastLat").val(map.getBounds().getNorthEast().lat());
                            $("#mapNorthEastLng").val(map.getBounds().getNorthEast().lng());
                            $("#mapSouthWestLat").val(map.getBounds().getSouthWest().lat());
                            $("#mapSouthWestLng").val(map.getBounds().getSouthWest().lng());
                        }
                    });
                    sn.app.map.refreshMap();
                    $("#btn-enter-full-screen")
                        .click(function () {
                        $(".map")
                            .css({
                            position: "fixed",
                            top: 0,
                            left: 0,
                            width: "100%",
                            height: "100%",
                            backgroundColor: "white"
                        });
                        $("#map-container")
                            .css({
                            height: "100%"
                        });
                        google.maps.event.trigger(map, "resize");
                        $("#btn-enter-full-screen").toggle();
                        $("#btn-exit-full-screen").toggle();
                        return false;
                    });
                    function ThingsToDoControl(controlDiv, map) {
                        var controlUI = document.createElement('div');
                        controlUI.style.backgroundColor = '#fff';
                        controlUI.style.border = '2px solid #fff';
                        controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)';
                        controlUI.style.cursor = 'pointer';
                        controlUI.style.marginBottom = '22px';
                        controlUI.style.textAlign = 'center';
                        controlUI.style.margin = '10px';
                        controlUI.style.width = '145px';
                        controlDiv.appendChild(controlUI);
                        var controlText = document.createElement('div');
                        controlText.style.fontSize = '16px';
                        controlText.innerHTML = '<div class="l-db l-pr check-box">' +
                            '<input style="margin: 3px" id="checkboxThingsToDo" type="checkbox" class="cb-filter"><label>' +
                            '<a class="lnk-filter">' +
                            'Things To Do' +
                            '</a>' +
                            '</label>' +
                            '</div>';
                        controlUI.appendChild(controlText);
                        controlUI.addEventListener('click', function () {
                            var checkBox = document.getElementById("checkboxThingsToDo");
                            ;
                            if (checkBox.checked == false) {
                                sn.app.map.addThingsToDoMarkers();
                                checkBox.checked = true;
                            }
                            else {
                                sn.app.map.clearThingsToDoMarkers();
                                checkBox.checked = false;
                            }
                        });
                    }
                    if (sn.app.map.ShowInitialOverlay &&
                        window.matchMedia &&
                        window.matchMedia("(max-width: 40em)").matches) {
                        sn.app.map.toggleControls(map, false);
                        $("#map").prepend($(".map-disable-overlay"));
                        $(".map-disable-overlay").show();
                        $(".enable-map")
                            .click(function () {
                            $(".map-disable-overlay")
                                .slideToggle("slow", function () {
                                sn.app.map.toggleControls(map, true);
                            });
                        });
                    }
                    else {
                        if (sn.app.map.ShowTools) {
                            $(".map-tools").show();
                        }
                        else {
                            $(".map-tools").hide();
                        }
                    }
                    $(".refresh-map")
                        .click(function () {
                        event.preventDefault();
                        _this.refreshAndSearch(map);
                    });
                },
                api_key: "AIzaSyB16lAbslq9Y69-wzYl-nwW8OxJMdo2f4I"
            });
            $window.on("resize", $pluginInstance.debounce(1000, function () {
                $.each(sn.app.map.MapInstances, function () {
                    this.setCenter($.data(this, "center"));
                    if (this.getDiv().offsetHeight === 300) {
                        this.panBy(0, -85);
                    }
                });
            }));
        },
        readyToRefresh: function (isReady) {
            if (isReady) {
                $(".refresh-map").addClass("blue");
                $(".refresh-map .circle-s")
                    .fadeToggle("slow", function () {
                    $(this).fadeToggle();
                });
            }
            else {
                $(".refresh-map").removeClass("blue");
            }
        },
        toggleControls: function (map, bool) {
            map.setOptions({
                draggable: bool,
                zoomControl: bool,
                scrollwheel: bool,
                disableDoubleClickZoom: !bool,
                scaleControl: bool,
                panControl: bool
            });
            if ($(".map-tools").length) {
                if (bool && sn.app.map.ShowTools) {
                    $(".map-tools").slideToggle();
                }
                else {
                    $(".map-tools").hide();
                }
            }
        },
        createContentMarker: function (map, item) {
            var marker = new google.maps.Marker({
                position: new google.maps.LatLng(item.Latitude, item.Longitude),
                icon: sn.app.map.getIcon(item.PlaceTypeId),
                map: map
            });
            marker.setMap(map);
            sn.app.map.createToolTip(marker, item.Name, map);
            google.maps.event.addListener(marker, "click", function () {
                sn.app.map.EnableShowLabelHover = false;
                map.panTo(new google.maps.LatLng(item.Latitude, item.Latitude));
                $(".infoBox").hide();
                var infobox = new InfoBox({
                    content: "<div class='infobox-wrapper'><div class='map-infobox info-window-img'><div><a href='" + item.Url + "'>" + item.Name + "</a></div><div><img src='" + item.MainImageUrl + "'/></div></div>",
                    disableAutoPan: false,
                    maxWidth: 175,
                    pixelOffset: new google.maps.Size(-140, 0),
                    zIndex: null,
                    boxStyle: {
                        background: "url('/res/img/tipbox.gif') no-repeat",
                        opacity: 0.95,
                        width: "200px",
                        padding: 0,
                        margin: 0
                    },
                    closeBoxMargin: "-11px -8px 0px 0px",
                    closeBoxURL: "/res/img/close.png",
                    infoBoxClearance: new google.maps.Size(1, 1)
                });
                infobox.open(map, this);
            });
            sn.app.map.ContentMarkers.push(marker);
        },
        getIcon: function (typeid) {
            var iconName;
            switch (typeid) {
                case 1:
                case 2:
                case 4:
                case 5:
                case 7:
                case 8:
                case 9:
                case 11:
                case 24:
                case 25:
                case 26:
                    iconName = typeid;
                    break;
                default:
                    iconName = "other";
            }
            return "/images/icons/maps/" + iconName + ".png";
        },
        createToolTip: function (marker, name, map) {
            var tooltipOptions = {
                marker: marker,
                content: name,
                map: map
            };
            var tooltip = new Tooltip(tooltipOptions);
        },
        createMarker: function (map, item) {
            var markerInfoModel = {
                spid: item.spid,
                id: item.id,
                type: item.type,
                mainimageid: item.mainimageid,
                mainimageurl: item.mainimageurl,
                alttext: item.alttext,
                url: item.url,
                name: item.name,
                accomtypes: item.accomtypes,
                maxoccupancy: item.maxoccupancy,
                reviewcount: item.reviewcount,
                latitude: item.latitude,
                longitude: item.longitude,
                instantbook: item.instantbook,
                displayprice: item.displayprice,
                displaycurrency: item.displayCurrency,
                markerType: item.markerType,
                isEnquirable: item.isEnquirable,
                special: item.special
            };
            var marker = new MarkerWithLabel({
                position: new google.maps.LatLng(item.latitude, item.longitude),
                icon: item.instantbook ? "/images/icons/maps/available.png" : "/images/icons/maps/request.png",
                map: map,
                infomodel: markerInfoModel
            });
            marker.setMap(map);
            ;
            google.maps.event.addListener(marker, "click", function () {
                sn.app.map.EnableShowLabelHover = false;
                map.panTo(new google.maps.LatLng(this.infomodel.latitude, this.infomodel.longitude));
                $(".infoBox").hide();
                var infobox = new InfoBox({
                    content: "<div class=\"l-fl map-infobox\" id=\"searchLoaderImage\"><img src=\"/Content/flow/img/loader.gif\" /></div>",
                    disableAutoPan: false,
                    maxWidth: 175,
                    pixelOffset: new google.maps.Size(-140, 0),
                    zIndex: null,
                    boxStyle: {
                        background: "url('/res/img/tipbox.gif') no-repeat",
                        opacity: 0.95,
                        width: "200px",
                        padding: 0,
                        margin: 0
                    },
                    closeBoxMargin: "-11px -8px 0px 0px",
                    closeBoxURL: "/res/img/close.png",
                    infoBoxClearance: new google.maps.Size(1, 1)
                });
                infobox.open(map, this);
                if (item.markerType === "accommodation") {
                    $.ajax({
                        url: "/Listing/GetEstablishmentMapInfoWindowContent/",
                        type: "POST",
                        data: this.infomodel,
                        dataType: "html",
                        success: function (html) {
                            infobox
                                .setContent("<div class='infobox-wrapper'><div class='map-infobox info-window-img'>" + html + "</div></div>");
                            $(".info-window-img img[data-remote-url]").dynamicImages(".info-window-img");
                            $("img[src='/res/img/close.png']")
                                .css({
                                "z-index": 10,
                                "position": "absolute",
                                "cursor": "pointer",
                                "top": 0,
                                "right": 0,
                                "margin": "-11px -8px"
                            });
                            $(".addremove-shortlist")
                                .click(function (event) {
                                sn.app.shortListTriggered(event, event.currentTarget);
                            });
                            $(".addremove-shortlist .icon-heart-1").stop().fadeTo("fast", 0.65);
                        }
                    });
                }
                else if (item.markerType === "destination") {
                    this.infomodel.LocationId = this.infomodel.id;
                    $.ajax({
                        url: "/Listing/GetDestinationMapInfoWindowContent/",
                        type: "POST",
                        data: this.infomodel,
                        dataType: "html",
                        success: function (html) {
                            infobox
                                .setContent("<div class='infobox-wrapper'><div class='map-infobox'>" + html + "</div></div>");
                            $("img[src='/res/img/close.png']")
                                .css({
                                "z-index": 10,
                                "position": "absolute",
                                "cursor": "pointer",
                                "top": 0,
                                "right": 0,
                                "margin": "-11px -8px"
                            });
                        }
                    });
                }
            });
            sn.app.map.createToolTip(marker, marker.infomodel.name, map);
            sn.app.map.Markers.push(marker);
        },
        EnableShowLabelHover: false,
        updateMarkerAvailability: function (spid, isavailable) {
            var r = $.grep(sn.app.map.Markers, function (e) { return (e != null); });
            if (r.length > 0) {
                var themarker = r[0];
                if (themarker.infomodel.spid === spid) {
                    if (themarker.infomodel.spid > 0) {
                        themarker.infomodel.instantbook = isavailable;
                        if (isavailable) {
                            themarker
                                .setContent("'<i class=\"icon-location map-marker " + themarker.infomodel.markerType + " available\"></i>");
                        }
                        else {
                            themarker
                                .setContent("'<i class=\"icon-location map-marker " + themarker.infomodel.markerType + " onrequest\"></i>");
                        }
                    }
                }
            }
        },
        refresh: function () {
            var maxItems = 30;
            if (sn.app.map.Data.length < 30) {
                maxItems = sn.app.map.Data.length;
            }
            for (var i = 0; i < maxItems; i++) {
                var item = sn.app.map.Data[i];
                sn.app.map.createMarker(sn.app.map.MapInstances[0], item);
            }
        },
        addThingsToDoMarkers: function () {
            if (typeof contentResults !== "undefined")
                for (var i = 0; i < contentResults.length; i++) {
                    var item = contentResults[i];
                    sn.app.map.createContentMarker(sn.app.map.MapInstances[0], item);
                }
        },
        clearThingsToDoMarkers: function () {
            for (var i = 0; i < sn.app.map.ContentMarkers.length; i++) {
                var marker = sn.app.map.ContentMarkers[i];
                marker.setMap(null);
            }
            sn.app.map.ContentMarkers.length = 0;
        },
        clearMarkers: function () {
            for (var i = 0; i < sn.app.map.Markers.length; i++) {
                var marker = sn.app.map.Markers[i];
                marker.setMap(null);
            }
            sn.app.map.Markers.length = 0;
        },
        clearMarkersAvailability: function () {
            for (var i = 0; i < sn.app.map.Markers.length; i++) {
                var marker = sn.app.map.Markers[i];
                marker.setIcon("/res/img/gmaps/marker-blue-drop.png");
                marker.infomodel.instantbook = false;
            }
        },
        initMap: function (mapZoomLevel, enableDragSearch, fnSearch) {
            if (typeof (results) == "undefined" || results.length === 0) {
                sn.app.map.Data = [];
            }
            else {
                sn.app.map.Data = results;
            }
            sn.app.map.Zoom = mapZoomLevel;
            sn.app.map.init(mapZoomLevel, enableDragSearch, fnSearch);
        },
        refreshMap: function () {
            if (typeof (results) == "undefined" || results.length === 0) {
                sn.app.map.Data = [];
            }
            else {
                sn.app.map.Data = results;
            }
            sn.app.map.refresh();
        },
        searchThingsToDoAndRefresh: function (map) {
            $("#mapNorthEastLat").val(map.getBounds().getNorthEast().lat());
            $("#mapNorthEastLng").val(map.getBounds().getNorthEast().lng());
            $("#mapSouthWestLat").val(map.getBounds().getSouthWest().lat());
            $("#mapSouthWestLng").val(map.getBounds().getSouthWest().lng());
            sn.app.contentlisting.search(false, true);
            sn.app.map.clearThingsToDoMarkers();
        },
        searchAndRefresh: function (map) {
            $("#mapNorthEastLat").val(map.getBounds().getNorthEast().lat());
            $("#mapNorthEastLng").val(map.getBounds().getNorthEast().lng());
            $("#mapSouthWestLat").val(map.getBounds().getSouthWest().lat());
            $("#mapSouthWestLng").val(map.getBounds().getSouthWest().lng());
            if (sn.app.map.EnableDragSearch) {
                this.Service.getResults(this.Service);
                sn.app.map.readyToRefresh(false);
            }
            sn.app.map.readyToRefresh(true);
        },
        updateMarkerActivity: function (spid) {
            var theMap = sn.app.map.MapInstances[0];
            if (theMap) {
                var r = $.grep(sn.app.map.Markers, function (e) { return (e != null); });
                if (r.length > 0) {
                    var themarker = r[0];
                    if (themarker.infomodel.spid === spid) {
                        if (themarker.infomodel.spid > 0) {
                            var m = new MarkerWithLabel({
                                position: new google.maps.LatLng(themarker.infomodel.latitude, themarker.infomodel.longitude),
                                icon: {
                                    path: google.maps.SymbolPath.CIRCLE,
                                    scale: 0
                                },
                                map: theMap,
                                draggable: true,
                                labelAnchor: new google.maps.Point(0, 10),
                                labelClass: "activity",
                                id: spid,
                                labelContent: "Booked!"
                            });
                            console.log(m);
                            console.log(spid);
                            window.setTimeout(function () { m.setMap(null); }, 5000);
                        }
                    }
                }
            }
        }
    };
//# sourceMappingURL=sn.app.map.js.map
var LocationFilterModel = (function () {
    function LocationFilterModel() {
        this.Refresh = true;
        this.NumberToSkip = 0;
        this.NumberToReturn = 18;
        this.Tags = new Array();
    }
    return LocationFilterModel;
}());
var snChildLocations = (function () {
    function snChildLocations() {
        this._numberOfLocationsLoaded = 0;
        this._allLocationsLoaded = false;
        this._tagcheckboxes = new Array();
        this._isPosting = false;
        var _self = this;
        this._locationId = document.getElementById("hd-locationId");
        this._childLocationsContainer = document.getElementById("ChildLocations");
        var tagcheckboxes = document.querySelectorAll(".tag-filter");
        for (var t = 0; t < tagcheckboxes.length; t++) {
            this._tagcheckboxes.push(tagcheckboxes[t]);
        }
        this.addTagClickListener();
        this.addInfiniteScrollListener();
    }
    snChildLocations.prototype.addTagClickListener = function () {
        var _this = this;
        var service = this;
        for (var c = 0; c < service._tagcheckboxes.length; c++) {
            (this._tagcheckboxes[c]).addEventListener("click", function (e) { return _this.onTagClick(e, service); });
        }
    };
    snChildLocations.prototype.addInfiniteScrollListener = function () {
        var _this = this;
        var service = this;
        service._childLocationsContainer.addEventListener("scroll", function (e) { return _this.onScroll(e, service); });
    };
    snChildLocations.prototype.onScroll = function (e, service) {
        if (!service._isPosting) {
            if (service._childLocationsContainer.scrollHeight - service._childLocationsContainer.scrollTop - Utility.GetWindowHeight() < 100) {
                service._isPosting = true;
                var model = service.getModel(service);
                model.NumberToSkip += service._numberOfLocationsLoaded;
                model.Refresh = false;
                service.getLocations(model, service);
            }
        }
    };
    snChildLocations.prototype.getModel = function (service) {
        var model = new LocationFilterModel();
        model.LocationId = parseInt(service._locationId.value);
        for (var t = 0; t < service._tagcheckboxes.length; t++) {
            if (service._tagcheckboxes[t].checked) {
                model.Tags.push(parseInt(service._tagcheckboxes[t].getAttribute("data-tag-id")));
            }
        }
        if (model.Tags.length == 0) {
            for (var t = 0; t < service._tagcheckboxes.length; t++) {
                model.Tags.push(parseInt(service._tagcheckboxes[t].getAttribute("data-tag-id")));
            }
        }
        return model;
    };
    snChildLocations.prototype.onTagClick = function (e, service) {
        service._allLocationsLoaded = false;
        service._numberOfLocationsLoaded = 0;
        var model = service.getModel(service);
        service.getLocations(model, service);
    };
    snChildLocations.prototype.getLocations = function (model, service) {
        if (!this._allLocationsLoaded) {
            var taggedLocationContainer_1 = document.getElementById("TaggedChildLocations");
            $.ajax({
                type: "POST",
                url: "/listing/getlocationsbytags/",
                data: model,
                beforeSend: function () {
                    if (model.Refresh) {
                        taggedLocationContainer_1.innerHTML = "";
                    }
                    Utility.showLoader(null);
                }
            })
                .done(function (data) {
                service._allLocationsLoaded = data.allLocationsLoaded;
                service._numberOfLocationsLoaded += data.resultCount;
                if (data.results.trim() !== "") {
                    $(data.results).appendTo(taggedLocationContainer_1);
                }
                else {
                    taggedLocationContainer_1.innerHTML = "No results found.  Please clear your filters above.";
                }
                Shared.ToggleScrollbar(document.getElementById("ChildLocations"));
                Utility.hideLoader(null);
                service._isPosting = false;
            });
        }
    };
    return snChildLocations;
}());
//# sourceMappingURL=sn.app.childlocations.js.map
var PageContext;
(function (PageContext) {
    PageContext[PageContext["Listing"] = 0] = "Listing";
    PageContext[PageContext["Map"] = 1] = "Map";
})(PageContext || (PageContext = {}));
var SlideContext;
(function (SlideContext) {
    SlideContext[SlideContext["None"] = 0] = "None";
    SlideContext[SlideContext["Filters"] = 1] = "Filters";
    SlideContext[SlideContext["ChildLocations"] = 2] = "ChildLocations";
    SlideContext[SlideContext["WishList"] = 3] = "WishList";
})(SlideContext || (SlideContext = {}));
var Filter = (function () {
    function Filter() {
    }
    return Filter;
}());
var SearchService = (function () {
    function SearchService(mobileBreakpoint, pageContext, mapZoomLevel, openInNewTab, Atest) {
        if (Atest === void 0) { Atest = true; }
        this._slideContext = SlideContext.None;
        this._mobileSearchClosed = true;
        this._missingDatesHidden = false;
        this._checkboxes = new Array();
        this._tagcheckboxes = new Array();
        this._dropdowns = new Array();
        this._links = new Array();
        this._reviewsToSkip = 0;
        this._listings = new Array();
        this.setupProperties();
        this._pageContext = pageContext;
        this._mobileBreakpoint = mobileBreakpoint;
        this._mapZoomLevel = mapZoomLevel;
        this._atest = Atest;
        this._btest = !Atest;
        this._openInNewTab = openInNewTab;
        this.SetPreviousDeviceContext();
        this.SetDeviceContext();
        this.ConfigureEventListeners();
        this.SubscribeToEvents();
        this.initModules();
        this.repositionReviews();
        this.loadMap();
        this.updateFilterCounts();
        this.ApplyFilterCountAndClearFilters(this);
        this.ApplyShortList(this);
        this.initializeReviews();
    }
    SearchService.prototype.initializeReviews = function () {
        $(document).on("click", ".content-review .see-more-less", function () {
            var link = $(this), reviewDescParent = link.parent(), reviewDesc = link.parent().find('span'), fullDesc = reviewDescParent.data("full-review"), truncatedDesc = reviewDescParent.data("truncated-review");
            if (link.text() === "see more") {
                link.text("see less");
                $(reviewDesc).html($(reviewDesc).html(fullDesc).text());
            }
            else {
                link.text("see more");
                reviewDesc.html(truncatedDesc);
            }
            $(".shapeshift").shapeshift({ gutterX: 20, gutterY: 20 });
        });
    };
    SearchService.prototype.loadMap = function () {
        var isMap = document.getElementById("ismap");
        if (isMap.value.toLowerCase() == "true") {
            this.getResults(this);
        }
    };
    SearchService.prototype.updateMap = function (service) {
        if (sn.app.map.MapInstances.length === 0) {
            sn.app.map.initListingMap(service._mapZoomLevel, false, true, true, true, true, true, service);
        }
        else {
            sn.app.map.refreshMap();
        }
    };
    SearchService.prototype.setupProperties = function () {
        this._filterCount = document.getElementById("FilterCount");
        this._floatingFilterCount = document.getElementById("FloatingFilterCount");
        this._clearFilters = document.getElementById("ClearFilters");
        this._clearFilters2 = document.getElementById("ClearFilters2");
        this._minPrice = document.getElementById("dd-minprice");
        this._maxPrice = document.getElementById("dd-maxprice");
        this._guests = document.getElementById("dd-guests");
        this._sort = document.getElementById("dd-sort");
        this._guestsDisplay = document.getElementById("GuestsDisplay");
        this._applyButtonParent = document.getElementById("ApplyFilters").parentElement;
        this._listingResults = document.getElementById("ListingResults");
        this._mapResults = document.getElementById("MapResults");
        this._resultCount = document.getElementById("ResultCount");
        this._pager = document.getElementById("Paging");
        this._reviewsContainer = document.getElementById("ReviewsContainer");
        this._moreReviews = document.getElementById("more-reviews");
        this._switchList = document.getElementById("SwitchList");
        this._switchMap = document.getElementById("SwitchMap");
        this._mapLink = document.getElementById("MapLink");
        this._explore = document.getElementById("Explore");
        this._northEastLat = document.getElementById("mapNorthEastLat");
        this._northEastLng = document.getElementById("mapNorthEastLng");
        this._southWestLat = document.getElementById("mapSouthWestLat");
        this._southWestLng = document.getElementById("mapSouthWestLng");
        this._checkIn = document.getElementById("Checkin");
        this._checkOut = document.getElementById("Checkout");
        this._missingDates = document.getElementById("missing-dates");
        this._locationId = document.getElementById("LocationId");
        this._h1Title = document.getElementById("H1Title");
        this._h2Title = document.getElementById("H2Title");
        this._specialsFilter = document.getElementById("f-specials");
        this._themeFeature = document.getElementById("themeFeature");
        this._baseUrl = document.getElementById("baseUrl");
        this._body = document.body;
        this._stickySearch = document.getElementById("search");
        this._stickyTopPosition = this._stickySearch.offsetTop;
        this._stickySearchWrapper = document.getElementById("StickySearch");
        this._mustUseStickySearch = document.getElementById("mustUseStickySearch").value.toLowerCase() == "true";
        this._shortListInput = document.getElementById("ShortListJson");
        var checkboxes = document.querySelectorAll(".cb-filter");
        var dropdowns = document.querySelectorAll(".dd-filter");
        var links = document.querySelectorAll(".lnk-filter");
        var tagcheckboxes = document.querySelectorAll(".tag-filter");
        var listings = document.querySelectorAll(".listing");
        for (var c = 0; c < checkboxes.length; c++) {
            this._checkboxes.push(checkboxes[c]);
        }
        for (var d = 0; d < dropdowns.length; d++) {
            this._dropdowns.push(dropdowns[d]);
        }
        for (var l = 0; l < links.length; l++) {
            this._links.push(links[l]);
        }
        for (var t = 0; t < tagcheckboxes.length; t++) {
            this._tagcheckboxes.push(tagcheckboxes[t]);
        }
        for (var listing = 0; listing < listings.length; listing++) {
            this._listings.push(listings[listing]);
        }
    };
    SearchService.prototype.repositionReviews = function () {
        if ($(".shapeshift").length > 0) {
            $(".shapeshift").shapeshift({ gutterX: 20, gutterY: 20 });
        }
    };
    SearchService.prototype.initModules = function () {
        var overlayModal = new Overlay("#window-overlay", "window-overlay");
        if (this._atest) {
            this._searchModal = new Modal("modal-search", "#search", [".mobile-search-display"], ["#CloseSearch"], DisplayType.Modal, 0, 0, false, 1200);
        }
        this._filterModal = new Modal("modal-filters", ".left-column", ["#OpenFilters", ".OpenFilter"], ["#ApplyFilters", "#CloseFilters", "#ClearFilters"], DisplayType.Slide, 100, 1200, true, 1200);
        var _self = this;
        var search = new snSearch(1200, _self);
        this._gallery = new snGallery();
        this._gallery.init();
    };
    SearchService.prototype.showHideMissingDates = function () {
    };
    SearchService.prototype.updateFilterCounts = function () {
        var filterResults = document.getElementById("filter-results");
        if (filterResults.value !== "") {
            var filterCounts = JSON.parse(filterResults.value);
            for (var i_1 = 0; i_1 < filterCounts.length; i_1++) {
                var el = document.getElementById("filter-" + filterCounts[i_1].id);
                if (el) {
                    el.href = filterCounts[i_1].u;
                    var input = document.getElementById("cb-" + filterCounts[i_1].id);
                    var count = el.querySelector(".count");
                    if (parseInt(filterCounts[i_1].c) === 0) {
                        Utility.AddClass(el, "link-disabled");
                        input.setAttribute("disabled", "true");
                        count.innerHTML = "";
                    }
                    else {
                        Utility.RemoveClass(el, "link-disabled");
                        input.removeAttribute("disabled");
                        count.innerHTML = "(" + filterCounts[i_1].c + ")";
                    }
                }
                else {
                    console.warn("Element with id \"filter-" + filterCounts[i_1].id + "\" does not exist.");
                }
            }
        }
    };
    SearchService.prototype.onApplyButtonClick = function (e, service) {
        service._applyButtonParent.style.display = "none";
        service.getResults(service);
    };
    SearchService.prototype.configureDesktopFilterEventListeners = function (service) {
        var _this = this;
        for (var c = 0; c < service._checkboxes.length; c++) {
            (service._checkboxes[c]).addEventListener("change", function (e) { return _this.onFilterChange(e, service); });
        }
        for (var d = 0; d < service._dropdowns.length; d++) {
            (service._dropdowns[d]).addEventListener("change", function (e) { return _this.onFilterChange(e, service); });
        }
    };
    SearchService.prototype.onListingClick = function (e, service) {
        var processRedirect = true;
        var target = e.target || e.srcElement;
        if (Utility.HasClass(target, "icon-heart-1")
            || Utility.HasClass(target, "icon-heart-empty")
            || Utility.HasClass(target, "icon-cancel-circled-1")
            || Utility.HasClass(target, "remove-favourites")
            || Utility.HasClass(target, "rsSlideClick")
            || Utility.HasClass(target, "rsArrowIcn")
            || Utility.HasClass(target, "rsArrow")
            || Utility.HasClass(target, "icon-right-open")
            || Utility.HasClass(target, "icon-left-open")
            || Utility.HasClass(target, "gallery-left")
            || Utility.HasClass(target, "gallery-right")
            || Utility.HasClass(target, "rsImg")
            || Utility.HasClass(target, "royalSlider")
            || Utility.HasClass(target, "toggle-description")
            || (!Utility.HasClass(target, "button") && target.href != null && target.href.length > 0 && !Utility.HasClass(target, "hub-title"))) {
            processRedirect = false;
        }
        if (processRedirect) {
            if (Utility.HasClass(target, "button") || Utility.HasClass(target, "hub-title")) {
                e.preventDefault();
            }
            var url = e.currentTarget.getAttribute("data-url");
            var requestId = getParameterByName("r");
            if (requestId != null && requestId.length > 0) {
                url = addParameter(url, "r", requestId);
            }
            if (Utility.getDeviceContext() != DeviceContext.Mobile) {
                if (this._openInNewTab) {
                    window.open(url, "_blank");
                }
                else {
                    document.location.href = url;
                }
            }
            else {
                document.location.href = url;
            }
        }
        else {
            if (Utility.HasClass(target, "toggle-description")) {
                var toggle = target;
                Utility.RemoveClass(toggle.parentElement.querySelector(".features"), "hide");
                Utility.RemoveClass(toggle.parentElement.querySelector(".description"), "hide");
                Utility.RemoveClass(toggle.parentElement.querySelector(".accom-types-mobile"), "hide");
                Utility.RemoveClass(toggle.parentElement.querySelector(".features"), "show");
                Utility.RemoveClass(toggle.parentElement.querySelector(".description"), "show");
                Utility.RemoveClass(toggle.parentElement.querySelector(".accom-types-mobile"), "show");
                if (Utility.HasClass(toggle, "up")) {
                    Utility.RemoveClass(toggle, "up");
                    Utility.AddClass(toggle.parentElement.querySelector(".features"), "show");
                    Utility.AddClass(toggle.parentElement.querySelector(".description"), "hide");
                    Utility.AddClass(toggle.parentElement.querySelector(".accom-types-mobile"), "hide");
                }
                else {
                    Utility.AddClass(toggle, "up");
                    Utility.AddClass(toggle.parentElement.querySelector(".features"), "hide");
                    Utility.AddClass(toggle.parentElement.querySelector(".description"), "show");
                    Utility.AddClass(toggle.parentElement.querySelector(".accom-types-mobile"), "show");
                }
            }
        }
    };
    SearchService.prototype.disableMissingDates = function (e, service) {
        service._missingDatesHidden = true;
        service.showHideMissingDates();
    };
    SearchService.prototype.ClearFilters = function (e, service) {
        e.preventDefault;
        service._checkIn.value = "";
        service._checkOut.value = "";
        if (document.getElementById("DatesDisplay") != null) {
            document.getElementById("DatesDisplay").innerHTML = "Select dates";
        }
        for (var c = 0; c < service._checkboxes.length; c++) {
            if (service._checkboxes[c].type.toLowerCase() == "checkbox") {
                service._checkboxes[c].checked = false;
            }
        }
        for (var d = 0; d < service._dropdowns.length; d++) {
            service._dropdowns[d].value = service._dropdowns[d].getAttribute("data-default");
        }
        service.getResults(service);
    };
    SearchService.prototype.ApplyShortList = function (service) {
        if (service._shortListInput.value !== "") {
            var shortListed = JSON.parse(service._shortListInput.value);
            if (shortListed != null) {
                for (var s = 0; s < shortListed.length; s++) {
                    $(".shortlist-tag .heart[data-spid=\"" + shortListed[s].SpId + "\"]").addClass("is-active");
                }
            }
        }
    };
    SearchService.prototype.ApplyFilterCountAndClearFilters = function (service) {
        var count = 0;
        for (var c = 0; c < service._checkboxes.length; c++) {
            if (service._checkboxes[c].checked) {
                count++;
            }
        }
        if (parseInt(service._minPrice.value) > parseInt(service._minPrice.getAttribute("data-default")) || parseInt(service._maxPrice.value) < parseInt(service._maxPrice.getAttribute("data-default"))) {
            count++;
        }
        service._filterCount.innerHTML = count > 0 ? "(" + count + (count == 1 ? " filter applied)" : " filters applied)") : "";
        service._floatingFilterCount.innerHTML = count > 0 ? count.toString() : "";
        service._clearFilters.innerHTML = count > 0 ? "Clear all" : "";
        if (count > 0) {
            service._clearFilters.style.display = "block";
            service._floatingFilterCount.style.display = "block";
        }
        else {
            Utility.RemoveClass(service._clearFilters, "show");
            service._clearFilters.style.display = "none";
            service._floatingFilterCount.style.display = "none";
        }
        service._clearFilters2 = document.getElementById("ClearFilters2");
        if (service._clearFilters2 != null) {
            service._clearFilters2.innerHTML = count > 0 ? "(Clear filters)" : "";
            if (count > 0) {
                service._clearFilters2.style.display = "inline-block";
            }
            else {
                service._clearFilters2.style.display = "none";
            }
            service._clearFilters2.addEventListener("click", function (e) { return service.ClearFilters(e, service); });
        }
    };
    SearchService.prototype.onFilterChange = function (e, service) {
        var target = e.target || e.srcElement;
        if (Utility.HasClass(target, "link-disabled")) {
            e.preventDefault();
            e.stopPropagation();
            return;
        }
        if (Utility.HasClass(target, "lnk-filter")) {
            e.preventDefault();
            e.stopPropagation();
            var inputCheckBox = target.parentElement.previousElementSibling;
            inputCheckBox.checked = !inputCheckBox.checked;
        }
        if (Utility.HasClass(target, "span-filter")) {
            e.preventDefault();
            e.stopPropagation();
            var inputCheckBox = target.parentElement.parentElement.previousElementSibling;
            inputCheckBox.checked = !inputCheckBox.checked;
        }
        if (Utility.HasClass(target, "cb-filter")) {
            e.stopPropagation();
        }
        if (target.id.toLowerCase() === "dd-minprice") {
            var options = service._maxPrice.getElementsByTagName("option");
            var minPrice = target;
            for (var i_2 = 0; i_2 < options.length; i_2++) {
                Utility.RemoveClass(options[i_2], "hide");
                if (parseInt(options[i_2].value) <= parseInt(minPrice.options[minPrice.selectedIndex].value)) {
                    Utility.AddClass(options[i_2], "hide");
                }
            }
        }
        if (target.id.toLocaleLowerCase() === "dd-maxprice") {
            var options = service._minPrice.getElementsByTagName("option");
            var maxPrice = target;
            for (var i_3 = 0; i_3 < options.length; i_3++) {
                Utility.RemoveClass(options[i_3], "hide");
                if (parseInt(options[i_3].value) >= parseInt(maxPrice.options[maxPrice.selectedIndex].value)) {
                    Utility.AddClass(options[i_3], "hide");
                }
            }
        }
        if (Utility.getDeviceContext() != DeviceContext.Mobile) {
            service.getResults(service);
            if (service._filterModal != null) {
                service._filterModal.onSlideOut(null, service._filterModal, false);
            }
        }
    };
    SearchService.prototype.AddSpecialsFilterLinkClickEventListener = function (service) {
        var _this = this;
        var link = document.getElementById("f-specials-link");
        if (link !== null) {
            link.addEventListener("click", function (e) { return _this.onSpecialsFilterLinkClick(e, service); });
        }
    };
    SearchService.prototype.onSpecialsFilterLinkClick = function (e, service) {
        e.preventDefault();
        e.stopPropagation();
        service._specialsFilter.click();
        if (Utility.getDeviceContext() == DeviceContext.Mobile) {
            document.getElementById("ApplyFilters").click();
        }
    };
    SearchService.prototype.AddPagerEventListener = function (service) {
        var _this = this;
        var pager = document.getElementById("Paging");
        if (pager != null) {
            var pagers = pager.querySelectorAll(".pager a");
            for (var i_4 = 0; i_4 < pagers.length; i_4++) {
                pagers[i_4].addEventListener("click", function (e) { return _this.onPageChange(e, service); });
            }
        }
    };
    SearchService.prototype.onGetReviews = function (e, service) {
        e.preventDefault();
        service._reviewsToSkip += parseInt($("#reviews").attr("data-count"));
        var model = {
            page: $("#page").val(),
            ItemsToSkip: service._reviewsToSkip,
            locationId: service._locationId.value
        };
        $.ajax({
            type: "POST",
            url: "/listing/getmorereviews/",
            data: model,
            beforeSend: function () {
                Utility.showLoader(null);
            }
        })
            .done(function (data) {
            if (!data.hasMoreReviews) {
                Utility.AddClass(service._moreReviews, "hide");
            }
            if (data.results !== "") {
                $(data.results).appendTo("#divShapeShiftWrapper");
                service.repositionReviews();
            }
            Utility.hideLoader(null);
        });
    };
    SearchService.prototype.onListMapToggle = function (e, service) {
        if (e.target.tagName.toLowerCase() == "a" || e.target.tagName.toLowerCase() == "img") {
            e.preventDefault();
            this._switchMap.checked = true;
        }
        if (this._switchMap.checked) {
            $(".switch-to-map").hide();
            $(".switch-to-list").show();
        }
        else {
            $(".switch-to-map").show();
            $(".switch-to-list").hide();
        }
        this._listingResults.innerHTML = "";
        if (this._resultCount != null) {
            this._resultCount.innerHTML = "";
        }
        service.getResults(service);
    };
    SearchService.prototype.SetPreviousDeviceContext = function () {
        this._previousDeviceContext = Utility.GetWindowWidth() < this._mobileBreakpoint ? DeviceContext.Mobile : DeviceContext.Desktop;
    };
    SearchService.prototype.SetDeviceContext = function () {
        this._deviceContext = Utility.GetWindowWidth() < this._mobileBreakpoint ? DeviceContext.Mobile : DeviceContext.Desktop;
    };
    SearchService.prototype.getResults = function (service, isPaging) {
        var _this = this;
        if (isPaging === void 0) { isPaging = false; }
        var model = new Filter();
        model.LocationId = parseInt(service._locationId.value);
        model.CheckIn = document.getElementById("Checkin").value;
        model.CheckOut = document.getElementById("Checkout").value;
        model.Guests = parseInt(service._guests.value);
        model.Sort = parseInt(service._sort.value);
        model.MinPrice = parseInt(service._minPrice.value);
        model.MaxPrice = parseInt(service._maxPrice.value);
        model.UseOldCallToAction = document.getElementById("hd-useOldCallToAction").value.toLowerCase() === "true";
        model.Specials = service._specialsFilter != null && service._specialsFilter.checked;
        model.FilterIds = new Array();
        model.Page = isPaging ? parseInt(document.getElementById("page").value) : 1;
        model.ThemeFeature = service._themeFeature != null ? service._themeFeature.value : "";
        model.BaseUrl = service._baseUrl != null ? service._baseUrl.value : "";
        model.SubLocationIds = document.getElementById("SubLocationIds").value;
        if (document.getElementById("SavedSearchId") != null) {
            model.SavedSearchId = parseInt(document.getElementById("SavedSearchId").value);
        }
        if (service._switchMap.checked) {
            model.Map = true;
            model.NorthEastLat = service._northEastLat.value;
            model.NorthEastLng = service._northEastLng.value;
            model.SouthWestLat = service._southWestLat.value;
            model.SouthWestLng = service._southWestLng.value;
            model.MapExists = document.getElementById("map") != null && sn.app.map.MapInstances.length > 0;
            Utility.RemoveClass(service._mapResults, "hide");
        }
        else {
            Utility.AddClass(service._mapResults, "hide");
        }
        for (var c = 0; c < service._checkboxes.length; c++) {
            if (service._checkboxes[c].checked && service._checkboxes[c].id.toLowerCase() !== "f-specials") {
                model.FilterIds.push(parseInt(service._checkboxes[c].getAttribute("data-id")));
            }
        }
        if (model.FilterIds && model.FilterIds.length > 0) {
            model.FilterIdsPipeSeparated = model.FilterIds.join("|");
        }
        $.ajax({
            type: "GET",
            url: "/Listing/Search1?",
            data: model,
            beforeSend: function () {
                if (model.Map) {
                    if (service._pager != null) {
                        Utility.AddClass(service._pager, "hide");
                    }
                    if (service._reviewsContainer != null) {
                        Utility.AddClass(service._reviewsContainer, "hide");
                    }
                }
                else {
                    Utility.showLoader(service._listingResults);
                    dataLayer === null || dataLayer === void 0 ? void 0 : dataLayer.push({
                        'checkin': model.CheckIn,
                        'checkout': model.CheckOut,
                        'destination': model.LocationId,
                        'guests': model.Guests,
                        'event': 'ajaxSearch'
                    });
                }
            }
        })
            .done(function (response) {
            sn.app.multipartialUpdate(response);
            if (model.Map) {
                service.updateMap(service);
            }
            else {
                Utility.RemoveClass(service._pager, "hide");
                Utility.RemoveClass(service._reviewsContainer, "hide");
                service._gallery.init();
                service.AddPagerEventListener(service);
                service.AddSpecialsFilterLinkClickEventListener(service);
                service.repositionReviews();
                _this._moreReviews = document.getElementById("more-reviews");
                if (service._moreReviews != null) {
                    service._moreReviews.addEventListener("click", function (e) { return _this.onGetReviews(e, service); });
                }
                var listings = document.querySelectorAll(".listing");
                service._listings = new Array();
                ;
                for (var listing_1 = 0; listing_1 < listings.length; listing_1++) {
                    service._listings.push(listings[listing_1]);
                }
                for (var listing = 0; listing < service._listings.length; listing++) {
                    (service._listings[listing]).addEventListener("click", function (e) { return service.onListingClick(e, service); });
                }
            }
            service.updateFilterCounts();
            service.ApplyFilterCountAndClearFilters(service);
            service.ApplyShortList(service);
            Utility.hideLoader(null);
            Utility.smoothScroll(service._h1Title);
            _this.pushState(model);
            _this.writeCookie(model);
        })
            .fail(function () {
            $("#overlay").show();
            $("#searchLoaderMessage").html('Eish! There was a problem with that request. Please try again. <br/><br/><a href="javascript:location.reload();">Click to Retry</a>');
        });
    };
    SearchService.prototype.pushState = function (model) {
        var querystring = "";
        if (Date.parse(model.CheckIn) && Date.parse(model.CheckOut)) {
            var formattedCheckInDate = Utility.getFormattedDate(new Date($(".checkin").val()));
            var formattedCheckOutDate = Utility.getFormattedDate(new Date($(".checkout").val()));
            querystring += "?checkin=" + formattedCheckInDate + "&checkout=" + formattedCheckOutDate;
        }
        else {
            if (document.getElementById("DatesDisplay") != null) {
                document.getElementById("DatesDisplay").innerHTML = "Select dates";
            }
        }
        if (model.Specials) {
            querystring += querystring === "" ? "?specials=2" : "&specials=2";
        }
        if (model.FilterIds && model.FilterIds.length > 0) {
            querystring += querystring === "" ? "?fid=" : "&fid=";
            querystring += model.FilterIds.join("|");
        }
        if (model.SubLocationIds && model.SubLocationIds.length > 0) {
            querystring += querystring === "" ? "?slids=" : "&slids=";
            querystring += model.SubLocationIds;
        }
        model.Page = parseInt($("#page")[0].value);
        var pushState = $("#baseUrl")[0].value + "/" + model.Page + querystring;
        pushState = window.location.host + "/" + pushState;
        pushState = pushState.replace("//", "/");
        pushState = window.location.protocol + "//" + pushState;
        history.pushState(model, "", pushState);
    };
    SearchService.prototype.writeCookie = function (model) {
        var src = Utility.getCookie("SRC") || 0;
        var crcy = Utility.getCookie("current-currency") || "ZAR";
        var cookievalue = "s:" + src + "|ci:" + Utility.getFormattedDate(new Date($(".checkin").val())) + "|co:" + Utility.getFormattedDate(new Date($(".checkout").val())) + "|a:" + model.Guests + "|ch:0|c:" + crcy;
        Utility.setCookie("cache.key", cookievalue, 1);
    };
    SearchService.prototype.callback = function (service) {
        service.getResults(service);
    };
    SearchService.prototype.ConfigureEventListeners = function () {
        var _this = this;
        var service = this;
        if (Utility.getDeviceContext() != DeviceContext.Mobile) {
            service.configureDesktopFilterEventListeners(service);
        }
        for (var listing = 0; listing < service._listings.length; listing++) {
            (service._listings[listing]).addEventListener("click", function (e) { return _this.onListingClick(e, service); });
        }
        for (var l = 0; l < service._links.length; l++) {
            (service._links[l]).addEventListener("click", function (e) { return _this.onFilterChange(e, service); });
        }
        service._clearFilters.addEventListener("click", function (e) { return _this.ClearFilters(e, service); });
        if (service._clearFilters2 != null) {
            service._clearFilters2.addEventListener("click", function (e) { return _this.ClearFilters(e, service); });
        }
        document.getElementById("ApplyFilters").addEventListener("click", function (e) { return _this.onApplyButtonClick(e, service); });
        document.getElementById("OpenFilters").addEventListener("click", function (e) { return _this.ShowMobileFilters(e, service, true); });
        document.getElementById("Checkin").addEventListener("focus", function (e) { return _this.disableMissingDates(e, service); });
        document.getElementById("Checkout").addEventListener("focus", function (e) { return _this.disableMissingDates(e, service); });
        this._missingDates.querySelector(".close").addEventListener("click", function (e) { return _this.disableMissingDates(e, service); });
        if (this._moreReviews != null) {
            this._moreReviews.addEventListener("click", function (e) { return _this.onGetReviews(e, service); });
        }
        this._guests.addEventListener("change", function (e) { return _this.onGuestsChange(e, service); });
        this._sort.addEventListener("change", function (e) { return _this.onSortChange(e, service); });
        this._switchList.addEventListener("click", function (e) { return _this.onListMapToggle(e, service); });
        this._switchMap.addEventListener("click", function (e) { return _this.onListMapToggle(e, service); });
        var mapLinks = document.querySelectorAll(".switch-to-map");
        for (var l = 0; l < mapLinks.length; l++) {
            (mapLinks[l]).addEventListener("click", function (e) { return _this.onListMapToggle(e, service); });
        }
        this._mapLink.addEventListener("click", function (e) { return _this.onListMapToggle(e, service); });
        if (this._explore != null) {
            this._loadedPopularLocationsImages = false;
            this._explore.addEventListener("click", function (e) {
                if (!_this._loadedPopularLocationsImages) {
                    var expelements = $(".filter-extras .images img");
                    expelements.each(function (idx, el) { $(el).trigger("appear"); });
                    _this._loadedPopularLocationsImages = true;
                }
            });
        }
        var popLinks = document.querySelectorAll(".slid_selector");
        for (var p = 0; p < popLinks.length; p++) {
            (popLinks[p]).addEventListener("click", function (e) {
                e.preventDefault();
                var isselected = $(e.currentTarget).attr("data-slid-selected") === "true";
                if (isselected) {
                    $(e.currentTarget).attr("data-slid-selected", "false");
                    $(e.currentTarget).removeClass("selected-slid");
                    $(".slidtick", $(e.currentTarget)).hide();
                }
                else {
                    $(e.currentTarget).attr("data-slid-selected", "true");
                    $(e.currentTarget).addClass("selected-slid");
                    $(".slidtick", $(e.currentTarget)).show();
                }
                var selectedSlids = document.querySelectorAll('[data-slid-selected="true"]');
                var slidscsv = "";
                for (var s = 0; s < selectedSlids.length; s++) {
                    slidscsv += $(selectedSlids[s]).data("slid");
                    if (s !== selectedSlids.length - 1) {
                        slidscsv += ",";
                    }
                }
                $("#SubLocationIds").val(slidscsv);
                service.getResults(service);
            });
        }
        if ($("#SubLocationIds").val() != null) {
            var preselectSubLocations = $("#SubLocationIds").val().split(",");
            for (var t = 0; t < preselectSubLocations.length; t++) {
                var poplink = document.querySelector("[data-slid=\"" + preselectSubLocations[t] + "\"]");
                if (poplink != null) {
                    $(poplink).attr("data-slid-selected", "true");
                }
            }
        }
        var selectedsublocations = document.querySelectorAll('[data-slid-selected="true"]');
        for (var r = 0; r < selectedsublocations.length; r++) {
            $(".slidtick", $(selectedsublocations[r])).show();
            $(selectedsublocations[r]).addClass("selected-slid");
        }
        var unselectedsublocations = document.querySelectorAll('[data-slid-selected="false"]');
        for (var q = 0; q < unselectedsublocations.length; q++) {
            $(".slidtick", $(unselectedsublocations[q])).hide();
            $(unselectedsublocations[q]).removeClass("selected-slid");
        }
        this.AddPagerEventListener(service);
        this.AddSpecialsFilterLinkClickEventListener(service);
        window.addEventListener("resize", function () { return _this.onWindowResize(service); });
        window.addEventListener("scroll", function () { return _this.onWindowScroll(service); });
    };
    SearchService.prototype.onGuestsChange = function (e, service) {
        if (service._guestsDisplay !== null) {
            service._guestsDisplay.innerHTML = parseInt(service._guests.value) == 1 ? "1 Guest" : service._guests.value + " Guests";
        }
        if (Utility.getDeviceContext() != DeviceContext.Mobile) {
            service.getResults(service);
        }
    };
    SearchService.prototype.onSortChange = function (e, service) {
        service.getResults(service);
    };
    SearchService.prototype.onWindowResize = function (service) {
        service.showHideMissingDates();
        service.repositionReviews();
        if (service._deviceContext == DeviceContext.Desktop && service._stickySearchWrapper != null) {
            service._stickySearchWrapper.style.display = "block";
        }
    };
    SearchService.prototype.onWindowScroll = function (service) {
        if (service._mustUseStickySearch) {
            if (service._body.scrollTop >= service._stickyTopPosition) {
                Utility.AddClass(service._stickySearch, "fixed");
            }
            else {
                Utility.RemoveClass(service._stickySearch, "fixed");
            }
        }
    };
    SearchService.prototype.onPageChange = function (e, service) {
        e.preventDefault();
        var page = parseInt(e.target.getAttribute("data-pageindex"));
        $("#page")[0].value = page.toString();
        service.getResults(service, true);
    };
    SearchService.prototype.ShowMobileFilters = function (e, service, show) {
        e.preventDefault;
        setTimeout(function () {
            var el = document.getElementById("filters");
            var applyButton = el.querySelector(".button-fixed-bottom");
            applyButton.style.display = "block";
        }, 700);
    };
    SearchService.prototype.SubscribeToEvents = function () {
        var _self = this;
        snEvents.getInstance().sub("searchcriteriachange", function (service) {
            if (Date.parse(document.getElementById("Checkin").value) && Date.parse(document.getElementById("Checkout").value)) {
                if (document.getElementById("DatesDisplay") != null) {
                    var checkIn = document.getElementById("Checkin").value;
                    document.getElementById("DatesDisplay").innerHTML = checkIn.substr(0, checkIn.length - 5) + " - " + document.getElementById("Checkout").value;
                }
                service.getResults(service);
            }
            if (service._searchModal != null) {
                service._searchModal.onHide(null, service._searchModal);
            }
        });
        snEvents.getInstance().sub("modalslidein", function (item) {
            if (item.ModalName === "modal-filters") {
                item.ModalElement.style.background = "#fff";
            }
            else {
                if (item.ModalName === "modal-locations") {
                    var model = new LocationFilterModel();
                    model.LocationId = parseInt(_self._locationId.value);
                    for (var t = 0; t < _self._tagcheckboxes.length; t++) {
                        if (_self._tagcheckboxes[t].checked) {
                            model.Tags.push(parseInt(_self._tagcheckboxes[t].getAttribute("data-tag-id")));
                        }
                    }
                    if (model.Tags.length == 0) {
                        for (var t = 0; t < _self._tagcheckboxes.length; t++) {
                            model.Tags.push(parseInt(_self._tagcheckboxes[t].getAttribute("data-tag-id")));
                        }
                    }
                    _self._childLocations.getLocations(model, _self._childLocations);
                }
            }
        });
        snEvents.getInstance().sub("modalslideout", function (item) {
            if (item.ModalName === "modal-filters") {
                item.ModalElement.style.background = "transparent";
                item.ModalElement.style.overflowY = "initial";
                var applyButtonParent = document.getElementById("ApplyFilters").parentElement;
                applyButtonParent.style.display = "none";
            }
            if (item.ModalName === "modal-locations") {
            }
        });
        snEvents.getInstance().sub("slideclick", function (url) {
            if (Utility.getDeviceContext() != DeviceContext.Mobile) {
                window.open(url, "_blank");
            }
            else {
                document.location.href = url;
            }
        });
        snEvents.getInstance().sub("modalshow", function (item) {
            if (item.ModalName === "modal-search") {
                _self._stickySearchWrapper.style.display = "block";
            }
        });
        snEvents.getInstance().sub("modalhide", function (item) {
            if (item.ModalName === "modal-search") {
                _self._stickySearchWrapper.style.display = "none";
            }
        });
    };
    return SearchService;
}());
//# sourceMappingURL=sn.app.hub.js.map
