


$(function() {
    var bookingResourcesTranslations = {
        room: "Cottage",
        found: "Encontrado",
        moreInfo: "Mais informação sobre este quarto",
        lessInfo: "Menos informação sobre este quarto",
        };




eviivo.availabilitySearch.init({
    isDefaultReferrer: true,
    defaultNightsServiced: null,
    roomsLimit: 8,
    cultureLanguageCode: "pt-PT",
    
    baseSearchUrl: "/pt-PT/rooms-cottages",
    
    resources:
    {
        adults: "Adulto(s)",
        children: "Criança(s)",
        room: "Cottage",
        rooms: "Chalés",
        roomAdded: "{0} Cottage adicionado",
        roomsAdded: "{0} Chalés adicionado"
    }
});
    
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: "Aplicar",
        unlockSpecials: "Clique para obter a sua promo&#231;&#227;o imediatamente ",
        enterPromoCode: "Introduza o seu c&#243;digo ou n&#250;mero de s&#243;cio"
        },
        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: "Ups, o c&#243;digo que introduziu &#233; inv&#225;lido ou expirou!",
        promoValidationEmptyCode: "&#201; necess&#225;rio inserir o c&#243;digo promocional"
        }
        });
        }

        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: "Ver mapa",
                switchToImage: "Ver imagens"
                },
                showMapByDefault: false
                });
            
        eviivo.bookingSystem.managePageLogin.init({
        popupHeaderTitle: "Gerir reserva",
        ajaxUrl: "/instantweb/manage/RetrieveOrderCancellationPermissions",
        referrerShortName: "MyWeb",
        propertyShortName: "CrrgHsAccmmdtns99587",
        requestVerificationToken: "NwAEuc-yvuAzCHH5qDBsd2q2UUzczu54aqeQwktj4qYMlVq_tUUHY5uyguCZ7w4d0s0-irka3-uYlpvNonSUOUNogfk1:kFjrVdncWD0bEA3yPufdP5nXIqORHKMbp071kC4WLFwwSfvbIqzLyBQJPHvQ70cjW3XjqGOtluk-u2Ala2fdp4qdlf81",
        ajaxLoaderResources: {
        loadingUpdateResults: "A validar o seu endere&#231;o de email e refer&#234;ncia de reserva",
        loadingSlowSystemWarning: "Ainda estamos a tentar proceder ao cancelamento da sua reserva ... obrigado pela sua compreens&#227;o",
        loadingRefreshingIssueWarning: "Hmmmm .... algo n&#227;o est&#225; certo. Por favor, tente",
        ajaxFailText: "Algo inesperado aconteceu, por favor, tente",
        refreshPageText: "Atualize a p&#225;gina"
        }
        });

        });

        
