


$(function() {
    var bookingResourcesTranslations = {
        room: "Cottage",
        found: "found",
        moreInfo: "Learn more",
        lessInfo: "Less info",
        };




eviivo.availabilitySearch.init({
    isDefaultReferrer: true,
    defaultNightsServiced: null,
    roomsLimit: 8,
    cultureLanguageCode: "en-GB",
    
    baseSearchUrl: "/en-GB/rooms-cottages",
    
    resources:
    {
        adults: "Adult(s)",
        children: "Child(ren)",
        room: "Cottage",
        rooms: "Cottages",
        roomAdded: "{0} Cottage added",
        roomsAdded: "{0} Cottages added"
    }
});
    
delayedInitPromoFeature(eviivo.availabilitySearch.triggerSearch);



        eviivo.smoothScrolling.init();
        eviivo.popup.init();
        eviivo.combinedInventory.init({
            maxInventory: 8,
            resources: {
                soldout: "Sold Out",
                select: "Select",
            }
        });

        
        eviivo.imageMainGallery.init({
        initializeGalleryByDefault: true,
        initializeGalleryOnClick: false,
        initializeGalleryForRooms: true,
        });

        
        

    //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();
    });

    $.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.instantWebMenu.init();

                    
                eviivo.mapView.init({
                googleMapsApiUrl: "//maps.googleapis.com/maps/api/js?key=AIzaSyCtPYb_pV8h_-HxZJIEJ_pJBuPel7LUz5s&amp;v=3&amp;callback=",
                lat: "60.965421",
                lng: "-149.135837",
                resources: {
                switchToMap: "View Map",
                switchToImage: "View Images"
                },
                showMapByDefault: false
                });
            
        eviivo.bookingSystem.managePageLogin.init({
        popupHeaderTitle: "Manage a reservation",
        ajaxUrl: "/instantweb/manage/RetrieveOrderCancellationPermissions",
        referrerShortName: "MyWeb",
        propertyShortName: "CrrgHsAccmmdtns99587",
        requestVerificationToken: "7LgWY_gAV8T3Qbi8WHpTGWPlygjQQflGcyKwk_y9t5XQqC_YCcpIIzh2uajDb-Z9sS5w_IikrMBLgtAHgTCzvM_bfac1:q7nkmbxQXm5nfebqEVd_yWy_gos1MBgRZ2u2FhYQSiI_Mp73Pabdcw5AqpRvoY-JwheAufR_lBEQDQH2B18bstmvLeA1",
        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"
        }
        });

        });

        
