

$(function() {
var searchTrigger;
    
        eviivo.availabilitySearch.init({
        roomsLimit: 8,
        cultureLanguageCode: "",
        baseSearchUrl: "/bedrooms",
        resources:
        {
        adults: "Adult(s)",
        children: "Children",
        rooms: "Room (s)",
        }
        });

        searchTrigger = eviivo.availabilitySearch.triggerSearch;
    
        eviivo.smoothScrolling.init();
        eviivo.popup.init();
        eviivo.imageMainGallery.init({
            initializeGalleryByDefault: true,
            initializeGalleryOnClick: false,
            initializeGalleryForRooms: true,
            });
        var showMapByDefault = false;

    
    //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
    $(".accordion a.accordion-toggle").on("click", function () {
    $(this).siblings(".accordion-content").slideToggle("slow");
    $(this).parent().toggleClass("active");
    
    });


    //Accordion rooms needs to be moved to separate js file
    $(".accordion-rooms a.accordion-rooms-toggle").on("click", function () {
    if ($(".main").hasClass("instantweb")) {
    $(this).parent().siblings(".intro-description").slideToggle("slow");
    }

    $(this).siblings(".accordion").slideToggle("slow");
    $(this).parent().toggleClass("expanded");
    var textDefault = "Learn more about this room";
    var textExpanded = "Less about this room";
    $(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: "Room",
    found: "found"
    }
    });

    $('#accept-cookies').on("click", function () {
    var currentCookieSession = Cookies.get('userSettings');
    Cookies.set('userSettings', currentCookieSession.concat('&' + 'cookienotification' + '=accepted'), { expires: 3650 });
    $('.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.bookingSystem.managePageLogin.init({
    popupHeaderTitle: "Manage a reservation",
    ajaxUrl: "/instantweb/manage/RetrieveOrderCancellationPermissions",
    referrerShortName: "MyWeb",
    propertyShortName: "StoneHseBP81",
    requestVerificationToken: "6Sb8DGyXnTaiRxuH10twd95jyKdyhTruJVNZVnJX45CfGQsLPeudK2-nx-hHB96AKJdKdyUWYXB4Z9mH-quKAIGHc1w1:UNSs8jtQJcxd1LGKHejhyd6QttNZFnlWv4_R0ELOLnt7r861Vk9LHtCyiQO8TkGGISkG6rGGeYvL51XeeOGkrJr_Lpw1",
    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"
                        }
    });



        
            eviivo.bookingFlow.init();
        

        
            eviivo.mapView.init({
            googleMapsApiUrl: "//maps.googleapis.com/maps/api/js?v=3&amp;key=AIzaSyDriVcF3kOAtmDbqmJO6CB_ZVUaW-ytyWM&amp;callback=",
            lat: "51.484359",
            lng: "-9.369017",
            resources: {
            switchToMap: "View Map",
            switchToImage: "View Images"
            },
            showMapByDefault: showMapByDefault
            });
        

    window.eviivo.instantWebMenu.init();
        
            eviivo.roomImages.init();
            window.eviivo.instantWebMenu.initSearchBar();

            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!"
            }
            });
        
    });

    
