


$(function() {
    var bookingResourcesTranslations = {
        room: "Room",
        found: "found",
        moreInfo: "Learn more",
        lessInfo: "Less info",
    };



setTimeout(function(){
    var baseAvailabilityCalendarUrl = $("#availabilityCalendarTarget").attr("href");

    if (typeof(availabilityCalendarOccupancyData) == "function"){

        if (window.location.href.toLowerCase().indexOf("startdate") > 0)
        {
            delayedAvailabilityCalendarInit([]);
        }
        else
        {
            // call ajax to return initial availability summaries
            $.ajax({
                type: "GET",
                url: baseAvailabilityCalendarUrl + "?shortname=BrookeLodgeBT45&start=2024-12-09&end=2025-03-31&referer=myweb",
                dataType: "json",
                success: function(response) {
                    delayedAvailabilityCalendarInit(response);
                },
                error: function(response) {
                    console.error(response);
                }
            });
        }
    }
    else{
        console.error("AC is enabled but availabilityCalendarOccupancyData is undefined!");
    }
}, 500);

function delayedAvailabilityCalendarInit(initialAvailabilitySummary){
    var occupancyData = availabilityCalendarOccupancyData();

    var availabilityData = {
        initialEarliestDate: "2024-12-09",
        initialFurthestDate: "2025-03-31",
        initialData: eviivo.availabilityCalendar.prodData.postProcessData(initialAvailabilitySummary)
    };

    var initialData = eviivo.availabilityCalendar.data(availabilityData, occupancyData);
    initialData.hasInitialAvailabilityData = initialAvailabilitySummary != null && initialAvailabilitySummary.length > 0;
    var baseAvailabilityCalendarUrl = $("#availabilityCalendarTarget").attr("href");
    var ajaxRequestUrl = baseAvailabilityCalendarUrl + "?shortname=BrookeLodgeBT45&referer=myweb";

    var availabilityCalendarAjaxRequest = eviivo.availabilityCalendar.ajax(initialData, ajaxRequestUrl, "2026-12-31");

    var availabilityCalendarLogic = eviivo.availabilityCalendar.logic(initialData);



var resources = {
    dateDisplayFormat: "d M yy",
    limitOfData: "If you wish to book this far in advance, please contact us directly on {PhoneNumber}",
    dataLoading: "We're checking availability for you...",
    forcedMinLos: "{LengthOfStay} night minimum stay required",
    selectDatesError: "Use the calendar | to select dates for your stay",
    checkInIncompatible: "Please select new stay dates",
    checkOutIncompatible: "Please select a new check-out date",
    roomFilter: {
        summaryFormat: "{SelectedRooms} / {TotalRooms} Room",
        summaryFormatPlural: "{SelectedRooms} / {TotalRooms} Rooms",
        requirementsSummary: "{AvailableRooms} Room matches your occupancy",
        requirementsSummaryPlural: "{AvailableRooms} Rooms match your occupancy"
    },
    occupancySelector: {
        summaryFormatNoChildren: "{adults} Adult(s), {rooms} Room",
        summaryFormatNoChildrenPlural: "{adults} Adult(s), {rooms} Rooms",
        summaryFormat: "{adults} Adult(s) {children} Children {rooms} Room",
        summaryFormatPlural: "{adults} Adult(s) {children} Children {rooms}Rooms",
        adults: "{NumAdults} Adult(s)",
        children: "{NumChildren} Children",
        roomTitle: "Room {roomNum}",
        roomCountOption: "{roomNum} Room",
        roomCountOptionPlural: "{roomNum} Rooms"
    },
    tooltips: {
        "arrival": {
            ".arr-past":"",
            ".arr-available":"",
            ".arr-cannotArrive":"No check in",
            ".arr-cannotArrive.arr-minLos":"No check in",
            ".arr-forcedDeparture":"Unavailable",
            ".arr-closed":"Unavailable",
            ".arr-afterClosed":"Unavailable",
            ".arr-unknown":"Unavailable",
        },
        "departure": {
            ".dep-past":"",
            ".dep-beforeCheckInDate.arr-available":"New check-in date ?",
            ".dep-beforeCheckInDate.arr-cannotArrive":"No check in",
            ".dep-beforeCheckInDate.arr-cannotArrive.arr-minLos":"Unavailable",
            ".dep-beforeCheckInDate.arr-forcedDeparture":"Unavailable",
            ".dep-beforeCheckInDate.arr-closed":"Unavailable",
            ".dep-beforeCheckInDate.arr-afterClosed":"Unavailable",
            ".dep-beforeCheckInDate.arr-unknown":"Unavailable",
            ".dep-checkInDate":" ", 
            ".dep-cannotDepart.dep-minLos":"No check in",
            ".dep-available":"Check out",
            ".dep-cannotDepart.dep-ctd":"No checkout",
            ".dep-forcedDeparture.dep-maxLos":"Check out",
            ".dep-forcedDeparture":"Check out",
            ".dep-closed":"Unavailable",
            ".dep-afterClosed.arr-available":"New check-in date ?",
            ".dep-afterClosed.arr-cannotArrive":"No check in",
            ".dep-afterClosed.arr-cannotArrive.arr-minLos":"Unavailable",
            ".dep-afterClosed.arr-forcedDeparture":"Unavailable",
            ".dep-afterClosed.arr-closed":"Unavailable",
            ".dep-afterClosed.arr-afterClosed":"Unavailable",
            ".dep-afterClosed.arr-unknown":"Unavailable",
            ".dep-unknown":"Unavailable",
        },
        "selected": {
            ".selected-past":"",
            ".selected-beforeCheckInDate.arr-available":"New Check-in date ?",
            ".selected-beforeCheckInDate.arr-cannotArrive":"No check in",
            ".selected-beforeCheckInDate.arr-cannotArrive.arr-minLos":"Unavailable",
            ".selected-beforeCheckInDate.arr-forcedDeparture":"Unavailable",
            ".selected-beforeCheckInDate.arr-closed":"Unavailable",
            ".selected-beforeCheckInDate.arr-afterClosed":"Unavailable",
            ".selected-beforeCheckInDate.arr-unknown":"Unavailable",
            ".selected-checkInDate":" ", 
            ".selected-checkInDate.selected-lastNight":"Minimum {LengthOfStay} night stay",
            ".selected-interim":"Minimum {LengthOfStay} night stay",
            ".selected-interim.selected-lastNight":"Minimum {LengthOfStay} night stay",
            ".selected-checkOutDate.dep-available":"Your check-out",
            ".selected-checkOutDate.dep-cannotDepart.dep-ctd":"Your check-out",
            ".selected-checkOutDate.dep-forcedDeparture.dep-maxLos":"Your check-out",
            ".selected-checkOutDate.dep-forcedDeparture":"Your check-out",
            ".selected-checkOutDate.dep-closed":"Your check-out",
            ".selected-checkOutDate.dep-afterClosed":"Unavailable",
            ".selected-afterCheckOutDate.dep-available":"New check-out date ?",
            ".selected-afterCheckOutDate.dep-cannotDepart.dep-ctd":"No checkout",
            ".selected-afterCheckOutDate.dep-cannotDepart.dep-minLos":"New check-out date ?",
            ".selected-afterCheckOutDate.dep-forcedDeparture.dep-maxLos":"New check-out date ?",
            ".selected-afterCheckOutDate.dep-forcedDeparture":"New check-out date ?",
            ".selected-afterCheckOutDate.dep-closed":"Unavailable",
            ".selected-afterCheckOutDate.dep-afterClosed.arr-available":"New check-in date ?",
            ".selected-afterCheckOutDate.dep-afterClosed.arr-cannotArrive":"No check in",
            ".selected-afterCheckOutDate.dep-afterClosed.arr-cannotArrive.arr-minLos":"Unavailable",
            ".selected-afterCheckOutDate.dep-afterClosed.arr-forcedDeparture":"Unavailable",
            ".selected-afterCheckOutDate.dep-afterClosed.arr-closed":"Unavailable",
            ".selected-afterCheckOutDate.dep-afterClosed.arr-afterClosed":"Unavailable",
            ".selected-afterCheckOutDate.dep-afterClosed.arr-unknown":"Unavailable",
            ".selected-unknown":"Unavailable",
            ".selected-checkOutDate.dep-cannotDepart.dep-minLos":""
        }
    }
};

resources.tooltips.searchDone = resources.tooltips.selected;

    var availabilityCalendarSettings = {
        roomsLimit: 4,
        cultureLanguageCode: "en-GB",
        resources: resources,
        monthsToShow: 3,
        preloadMonths: 2, //NOTE: the preloadMonths needs to be 1 month greater then the buffer date
        property: { TelephoneNumber: " 442879634800" }
    };

    var availabilityCalendar = eviivo.availabilityCalendar.ui.main(availabilityCalendarLogic, availabilityCalendarAjaxRequest, availabilityCalendarSettings);
    availabilityCalendar.updateUi();

    delayedInitPromoFeature(availabilityCalendar.triggerSearch);
}
    eviivo.smoothScrolling.init();
    eviivo.popup.init();
    eviivo.urgentMessage.init();
    eviivo.combinedInventory.init({
         maxInventory: 4,
         resources: {
             soldout: "Sold Out",
             select: "Select",
         }
    });

    
    eviivo.imageMainGallery.init({
        initializeGalleryByDefault: true,
        initializeGalleryOnClick: false,
        showVirtualTour: false,
        initializeGalleryForRooms: true
    });

    
    eviivo.thumbsWithLightBox.init({
        carouselImageSize: 0,
    });

    
    eviivo.reviews.init({
        propertyReviewsUrl: "/booking/reviews/BrookeLodgeBT45",
        resources:{
            ReadMore: "Read more",
            ReadLess: "Less info"
        },
        ajaxLoaderResources: {
            loadingUpdateResults: "Finding guest reviews...",
            loadingSlowSystemWarning: "We&#39;re still finding guest reviews...",
            loadingRefreshingIssueWarning: "Hmmmm.... something is not right. Please try to",
            ajaxFailText: "Something is not right, please try to",
            refreshPageText: "refresh the page"
        }
    });

    
    eviivo.propertiesNearby.init({
        ajaxLoaderResources: {
            loadingUpdateResults: "Finding other great properties nearby...",
            loadingSlowSystemWarning: "We&#39;re still finding you the other great properties nearby...",
            loadingRefreshingIssueWarning: "Hmmmm.... something is not right. Please try to",
            ajaxFailText: "Something is not right, please try to",
            refreshPageText: "refresh the page"
        }
    });




    //enable jquery UI tooltip (only for specific targeted cp-tip items)
    $(".cp-tip").tooltip({
        position: {
            my: "center bottom-15",
            at: "center top",
            using: function (position, feedback) {
                $(this).css(position);
                $("<div>")
    .addClass("arrow")
    .addClass(feedback.vertical)
    .addClass(feedback.horizontal)
    .appendTo(this);
    }
    },
    content: function ()
    {
    return $(this).prop('title');
    }
    });


    $(".accordion-rooms a.accordion-rooms-toggle").on("click", function () {
    if ($('.intro-description').length) {
    $(this).parent().siblings(".intro-description").slideToggle("slow");
    }
    $(this).siblings(".accordion").slideToggle("slow");
    $(this).parent().toggleClass("expanded");
    var textDefault = bookingResourcesTranslations.moreInfo;
    var textExpanded = bookingResourcesTranslations.lessInfo;
    $(this).text(function (i, text) {
    return text === textExpanded ? textDefault : textExpanded;
    });


    });
    // Close error/notice box
    var $closeControl = $(".cp-close");
    $closeControl.on("click", function () {
    $(this).parent().parent().hide();

    });

    
    eviivo.stickyContainer.init({
    resources: {
    room: bookingResourcesTranslations.room,
    found: bookingResourcesTranslations.found
    }
    });

    $('#accept-cookies').on("click", function () {
    var currentCookieSession = window.eviivo.webcore.cookieManager.getCookie('userSettings');
    if (currentCookieSession)
    {
    window.eviivo.webcore.cookieManager.setCookie('userSettings', currentCookieSession.concat('&' + 'cookienotification' + '=accepted'), 30);
    }

    $('.cookiebar').remove();
    });

    $(".section-block-title").click(function() {
    var $parent = $(this).closest('.section-collapsed');
    var $details = $parent.find(".section-block-details");

    $details.slideToggle(300, function() {
    $parent.toggleClass('section-expanded', $details.is(':visible'));
    });
    });


    $.widget("custom.iconselectmenu", $.ui.selectmenu, {
    _renderItem: function (ul, item) {
    var li = $("<li>", { text: item.label });
        if (item.disabled) {
        li.addClass("ui-state-disabled");
        }
        $("<span>", {
            style: item.element.attr("data-style"),
            "class": "ui-icon " + item.element.attr("data-class")
            })
            .appendTo(li);
            return li.appendTo(ul);
            }
            });

            //Let stry to disabled zooming for mobile screens
            if (/iphone|ipod|android|blackberry|opera mini|opera mobi|skyfire|maemo|windows phone|palm|iemobile|symbian|symbianos|fennec/i.test(navigator.userAgent.toLowerCase())) {
            $("meta[name='viewport']").attr("content", "width=device-width, initial-scale=1.0, maximum-scale=1.0");
            }
            



    eviivo.bookingFlow.init();

    function delayedInitPromoFeature(searchTrigger){
        eviivo.promos.init({
            resources: {
                apply: "Apply",
                unlockSpecials: "Click to unlock our exclusive deals",
                enterPromoCode: "Enter your code or member ID"
            },
            queryString: {
                promoCode: "pce",
                askForPromoInstantDeal: "peid"
            },
            cookie:
            {
                flags:{
                    promotionCode: "pc_flags",
                    instantDeal: "pid_flags"
                }
            },
            bannerTypes: {
                webExclusivePromoCode: "WXC",
                webExclusiveInstantDeal: "WXI",
                webExclusivePromoCodeFail: "WXCF",
                webExclusiveBannerWarning: "WXWARN",
                webExclusivePromoCodeUnlocked: "WXPU"
            },
            captcha: {
                siteKey: "6LdAbAoUAAAAAMuXWv2p3tnpik9AdCDyLRbpfeaB"
            },
            searchTrigger: searchTrigger
        });

        eviivo.promos.codeValidator.init({
            callback: eviivo.promos.onCodeValid,
            resources: {
                promoValidationMessage: "Your promo code is invalid or has expired!",
                promoValidationEmptyCode: "Promo code cannot be empty!"
            }
        });
    }



    eviivo.mapView.init({
        googleMapsApiUrl: "//maps.googleapis.com/maps/api/js?key=AIzaSyATEX9MS2dbXC7Nlg_pvMN-6xXM1jfXIfc&amp;v=3&amp;callback=",
        lat: "54.752912",
        lng: "-6.593918",
        resources: {
            switchToMap: "View Map",
            switchToImage: "View Images"
        },
        showMapByDefault: false
    });

    eviivo.bookingSystem.managePageLogin.init({
        popupHeaderTitle: "Manage a reservation",
        ajaxUrl: "/manage/RetrieveOrderCancellationPermissions",
        referrerShortName: "MyWeb",
        propertyShortName: "BrookeLodgeBT45",
        requestVerificationToken: "gXSsfWASBHGvUBZ-XQtQ1ujAnvTfMN1WQ_-ji_A4uE1Uzo1UqYHtBCIX2VQTq4FfpexsAzMCIduFGr2dl_uu36FYgbM1:WPbroUiv6BmSVNzRr1f1A1xWr5DDSkTTs_4bt1ahR2n_1etwII5Gxdydqqo_SpVN9OV0YzTAkVw6_rhZ3Eu66LV_tMw1",
        ajaxLoaderResources: {
            loadingUpdateResults: "Validating booking reference and email address...",
            loadingSlowSystemWarning: "We&#39;re still trying to cancel your booking... thanks for your patience",
            loadingRefreshingIssueWarning: "Hmmmm.... something is not right. Please try to",
            ajaxFailText: "Something is not right, please try to",
            refreshPageText: "refresh the page"
        }
    });

    
    $('#bookingTermsAndConditionsLink').on("click", function() {
    $.ajax({
    type: "GET",
    url: $(this).data("get-popup-data-url"),
    dataType: "html",
    success: function(response) {
    eviivo.popup.display({
    html: response,
    bodyClass: "dialogue-large is--scrollable space-pre-line"
    });
    },
    error: function(response) {
    eviivo.popup.display({
    html: response,
    bodyClass: "dialogue-medium is--scrollable"
    });
    }
    });
    return false;
    });

    $(".mod-currency li a").on("click",function(){
    function inCurrentUrlAppendOrReplaceParam(paramName, paramValue)
    {
    var url = window.location.href;
    url = url.split("#")[0];
    if (url.indexOf(paramName + "=") >= 0)
    {
    var indexOf = url.indexOf(paramName);
    var prefix = url.substring(0, indexOf);
    var suffix = url.substring(indexOf);
    suffix = suffix.substring(suffix.indexOf("=") + 1);
    suffix = (suffix.indexOf("&") >= 0) ? suffix.substring(suffix.indexOf("&")) : "";
    url = prefix + paramName + "=" + paramValue + suffix;
    }
    else
    {
    if (url.indexOf("?") < 0)
    url += "?" + paramName + "=" + paramValue;
    else
    url += "&" + paramName + "=" + paramValue;
    }

    return url;
    }

    var selectedCurrency = $(this).data('value');
    window.location.href =  inCurrentUrlAppendOrReplaceParam('currency', selectedCurrency);
    });

    $(".language-inner a").on("click", function (e) {
    e.preventDefault();

    var currentUrl = window.location.href.toLowerCase();
    var currentUrlQueryString = '';
    var indexOfQuestionMark = currentUrl.indexOf('?');
    if (indexOfQuestionMark > 0) {
    currentUrlQueryString = '?' + currentUrl.substring(indexOfQuestionMark + 1);
    }

    var newCulture = $(this).attr('data-value');

    var partBeforeQueryString = indexOfQuestionMark > 0
    ? currentUrl.substring(0, indexOfQuestionMark)
    : currentUrl;

    var indexOfP = currentUrl.indexOf('/p/');
    var newUrl = indexOfP == -1
    ? buildViaUrl(currentUrl, newCulture, currentUrlQueryString)
    : buildPartnersUrl(partBeforeQueryString, indexOfP, newCulture, currentUrlQueryString);

    window.location.href = newUrl;
    });

    function buildViaUrl(currentUrl, newCulture, currentUrlQueryString) {
    var urlPath = getUrlPath(currentUrl);

    // trim '/'
    urlPath = urlPath.replace(/^\/|\/$/g, "");

    var splitedUrlPath = urlPath.split("/");
    var maybeCulture = splitedUrlPath[0];
    var newUrl = isCulture(maybeCulture)
    ? "/" + newCulture + "/" + splitedUrlPath.slice(1, splitedUrlPath.length).join("/")
    : "/" + newCulture + "/" + splitedUrlPath.join("/");

    if (currentUrlQueryString) {
    newUrl += currentUrlQueryString;
    }

    return newUrl;
    }

    function getUrlPath(url) {
    var a = document.createElement('a');
    a.href = url;
    return a.pathname;
    }

    function isCulture(culture) {
    var splitedCulture = culture.split("-");

    return splitedCulture.length == 2
    && splitedCulture[0].length == 2
    && splitedCulture[1].length == 2;
    }

    function buildPartnersUrl(partBeforeQueryString, indexOfP, newCulture, currentUrlQueryString)
    {
    var parameters = partBeforeQueryString.substring(indexOfP + '/p/'.length).split('/');

    var propertyCountryFromUrl = parameters[0];
    var propertyRegionFromUrl = parameters[1];
    var propertyCityFromUrl = parameters[2];

    var filterTranslations = eviivo.filterTranslations;

    var propertyCountryName = filterTranslations
    ? filterTranslations.PropertyCountries[newCulture] || propertyCountryFromUrl
    : propertyCountryFromUrl;

    var propertyRegionName = filterTranslations
    ? filterTranslations.PropertyRegions[newCulture] || propertyRegionFromUrl
    : propertyRegionFromUrl;

    var propertyCityName = filterTranslations
    ? filterTranslations.PropertyCities[newCulture] || propertyCityFromUrl
    : propertyCityFromUrl;

    parameters[0] = propertyCountryName;
    parameters[1] = propertyRegionName;
    parameters[2] = propertyCityName;

    var newUrl = '/|langPlaceholder|/'.replace('|langPlaceholder|', newCulture) + '/p/' + parameters.join('/');
    if (currentUrlQueryString) {
    var currentUrlQueryString = translateUrlQueryString(currentUrlQueryString, filterTranslations, newCulture);
    newUrl += currentUrlQueryString;
    }

    return newUrl;
    }

    function translateUrlQueryString(currentUrlQueryString, filterTranslations, newCulture) {
    var keys = eviivo.utils.queryStringHelper.getAllKeys(currentUrlQueryString);

    translateCountry(keys, filterTranslations, newCulture);
    translateRegion(keys, filterTranslations, newCulture);
    translateCity(keys, filterTranslations, newCulture);
    translateCluster(keys, filterTranslations, newCulture);
    translateDestination(keys, filterTranslations, newCulture);
    translateTags(keys, filterTranslations, newCulture);

    return eviivo.utils.queryStringHelper.toString(keys, true);
    }

    function translateCountry(keys, filterTranslations, newCulture) {
    if (eviivo.utils.queryStringHelper.keyExists(keys, "country")) {
    var translatedCountry = filterTranslations.Countries[newCulture];
    if (translatedCountry) {
    eviivo.utils.queryStringHelper.updateKey(keys, "country", translatedCountry);
    }
    }
    }

    function translateRegion(keys, filterTranslations, newCulture) {
    if (eviivo.utils.queryStringHelper.keyExists(keys, "region")) {
    var translatedRegion = filterTranslations.Regions[newCulture];
    if (translatedRegion) {
    eviivo.utils.queryStringHelper.updateKey(keys, "region", translatedRegion);
    }
    }
    }

    function translateCity(keys, filterTranslations, newCulture) {
    if (eviivo.utils.queryStringHelper.keyExists(keys, "city")) {
    var translatedCity = filterTranslations.Cities[newCulture];
    if (translatedCity) {
    eviivo.utils.queryStringHelper.updateKey(keys, "city", translatedCity);
    }
    }
    }

    function translateCluster(keys, filterTranslations, newCulture) {
    if (eviivo.utils.queryStringHelper.keyExists(keys, "clustername")) {
    var translatedCluster = filterTranslations.Clusters[newCulture];
    if (translatedCluster) {
    eviivo.utils.queryStringHelper.updateKey(keys, "clustername", encodeUrlParameter(translatedCluster));
    }
    }
    }

    function translateDestination(keys, filterTranslations, newCulture) {
    if (eviivo.utils.queryStringHelper.keyExists(keys, "destination")) {
    var destinationType = eviivo.utils.queryStringHelper.getWithRegex(keys, "destinationtype");
    if (destinationType == "country") {
    var translatedCountry = filterTranslations.Countries[newCulture];
    if (translatedCountry) {
    eviivo.utils.queryStringHelper.updateKey(keys, "destination", translatedCountry);
    }
    } else if (destinationType == "region") {
    var translatedCountry = filterTranslations.Countries[newCulture];
    var translatedRegion = filterTranslations.Regions[newCulture];
    if (translatedCountry && translatedRegion) {
    var destination = translatedRegion + "---" + translatedCountry;
    eviivo.utils.queryStringHelper.updateKey(keys, "destination", destination);
    }
    } else if (destinationType == "city") {
    var translatedCountry = filterTranslations.Countries[newCulture];
    var translatedRegion = filterTranslations.Regions[newCulture];
    var translatedCity = filterTranslations.Cities[newCulture];
    if (translatedCountry && translatedRegion && translatedCity) {
    var destination = translatedCity + "---" + translatedRegion + "---" + translatedCountry;
    eviivo.utils.queryStringHelper.updateKey(keys, "destination", destination);
    } else if (translatedCountry && translatedCity) {
    var destination = translatedCity + "---" + translatedCountry;
    eviivo.utils.queryStringHelper.updateKey(keys, "destination", destination);
    }
    } else if (destinationType == "cluster") {
    var translatedCluster = filterTranslations.Clusters[newCulture];
    if (translatedCluster) {
    eviivo.utils.queryStringHelper.updateKey(keys, "destination", encodeUrlParameter(translatedCluster));
    }
    } else if (destinationType == "postcode") {
    var translatedCountry = filterTranslations.Countries[newCulture];
    var translatedRegion = filterTranslations.Regions[newCulture];

    var destination = eviivo.utils.queryStringHelper.getWithRegex(keys, "destination");
    var postcode = getPostcodeFromDestination(destination);

    if (translatedCountry && translatedRegion) {
    destination = postcode + "---" + translatedRegion + "---" + translatedCountry;
    eviivo.utils.queryStringHelper.updateKey(keys, "destination", destination);
    } else if (translatedCountry) {
    destination = postcode + "---" + translatedCountry;
    eviivo.utils.queryStringHelper.updateKey(keys, "destination", destination);
    }
    }
    }
    }

    function translateTags(keys, filterTranslations, newCulture) {
    if (eviivo.utils.queryStringHelper.keyExists(keys, "tag")) {
    var translatedTags = filterTranslations.ListOfTags;
    if (translatedTags && translatedTags.length > 0) {
    var combinedTags = translatedTags.map(function (x) { return x[newCulture] }).join(",");
    eviivo.utils.queryStringHelper.updateKey(keys, "tag", combinedTags);
    }
    }
    }

    function encodeUrlParameter(str) {
    var spaceExp = new RegExp("\\ ", "g");
    var commaExp = new RegExp("\\,", "g");
    var forwardSlashExp = new RegExp("\\%2F", "g");

    str = str.replace(commaExp, "--");
    str = str.replace(spaceExp, "-");
    str = str.replace(forwardSlashExp, "-");
    return str;
    }

    function getPostcodeFromDestination(destination)
    {
    if (destination) {
    return destination.split("---")[0];
    }

    return null;
    }
    });

    