

$(function() {
var searchTrigger;
    
        eviivo.availabilitySearch.init({
        roomsLimit: 8,
        cultureLanguageCode: "",
        baseSearchUrl: "/bedrooms",
        resources:
        {
        adults: "Adulto(s)",
        children: "Crianças",
        rooms: "Quarto(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 = "Mais informação sobre este quarto";
    var textExpanded = "Menos informação sobre este quarto";
    $(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: "Quarto",
    found: "Encontrado"
    }
    });

    $('#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: "Gerenciar uma reserva",
    ajaxUrl: "/instantweb/manage/RetrieveOrderCancellationPermissions",
    referrerShortName: "MyWeb",
    propertyShortName: "StoneHseBP81",
    requestVerificationToken: "pebL1lvmWrp3nIl3hczfO6DD6bG2zLmfNjVh41VT8ZBHK_lufXWGMjoFfMkBkOnrE807l9sGKhjb8XOI_9IJrD12KHw1:SZmsv5yvXGdNzH-s23JhsKXF9Muf0n-y7CnI2-YxwGVFGcANqp_FnU4ngasxB4Xz7RIzOMKvTFpH8qK72DXE3bXTHJQ1",
    ajaxLoaderResources: {
                            loadingUpdateResults: "Validando refer&#234;ncia da reserva e endere&#231;o de e-mail ...",
                            loadingSlowSystemWarning: "Ainda estamos tentando cancelar a sua reserva ... obrigado por sua paci&#234;ncia",
                            loadingRefreshingIssueWarning: "Hmmmm .... algo n&#227;o est&#225; certo. Por favor, tente",
                            ajaxFailText: "Algo n&#227;o est&#225; certo, por favor, tente",
                            refreshPageText: "Atualize a p&#225;gina"
                        }
    });



        
            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: "Ver mapa",
            switchToImage: "Ver imagens"
            },
            showMapByDefault: showMapByDefault
            });
        

    window.eviivo.instantWebMenu.init();
        
            eviivo.roomImages.init();
            window.eviivo.instantWebMenu.initSearchBar();

            eviivo.promos.init({
            resources: {
            apply: "Aplicar",
            unlockSpecials: "Clique para desbloquear a sua promo&#231;&#227;o especial",
            enterPromoCode: "Insira c&#243;digo ou 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: "O seu c&#243;digo promocional &#233; inv&#225;lido ou expirou!",
            promoValidationEmptyCode: "O c&#243;digo promocional n&#227;o pode estar vazio!"
            }
            });
        
    });

    
