


$(function() {
    var bookingResourcesTranslations = {
        room: "Room",
        found: "found",
        moreInfo: "Learn more",
        lessInfo: "Less info",
    };




eviivo.availabilitySearch.init({
    isDefaultReferrer: true,
    defaultNightsServiced: 0,
    roomsLimit: 8,
    cultureLanguageCode: "en-GB",
    
    baseSearchUrl: "/en-GB/rooms",
    
    resources:
    {
        adults: "Adult(s)",
        children: "Children",
        room: "Room",
        rooms: "Rooms",
        roomAdded: "{0} Room added",
        roomsAdded: "{0} Rooms added"
    }
});
    
delayedInitPromoFeature(eviivo.availabilitySearch.triggerSearch);



    eviivo.smoothScrolling.init();
    eviivo.popup.init();

    
    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
    $(".accordion a.accordion-toggle").on("click", function () {
    $(this).siblings(".accordion-content").slideToggle("slow");
    $(this).parent().toggleClass("active");
    });


    $(".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 = Cookies.get('userSettings');
    if (currentCookieSession)
    {
        Cookies.set('userSettings', currentCookieSession.concat('&' + 'cookienotification' + '=accepted'), { expires: 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: "55.117359",
        lng: "-6.074742",
        resources: {
            switchToMap: "View Map",
            switchToImage: "View Images"
        },
        showMapByDefault: false
    });

    eviivo.bookingSystem.managePageLogin.init({
        popupHeaderTitle: "Manage a reservation",
        ajaxUrl: "",
        referrerShortName: "MyWeb",
        propertyShortName: "GlennEireannHseBT44",
        requestVerificationToken: "OnDfRFDf3iQ8tMRaiXbFQiw6rdyRS9u8lyscWCSjHhvmJzIWntd8Q0CCoa_X7r2swIduZq5jYXyo0BoQJyCy2oYTfdg1:Uefkd2HTu2G6caumfEQnTwFGsiMpAgoFtMqWdU6k-n9cY7R6cQzkYQgp_UQT3dP2K5nZ0O4JOCeCP8swBop_zXicjW41",
        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"
        }
    });

});


