


$(function() {
    var bookingResourcesTranslations = {
        room: "Casa de Campo",
        found: "Encontrado",
        moreInfo: "Más información ",
        lessInfo: "Menos información ",
        };




eviivo.availabilitySearch.init({
    isDefaultReferrer: true,
    defaultNightsServiced: null,
    roomsLimit: 8,
    cultureLanguageCode: "es-ES",
    
    baseSearchUrl: "/es-ES/rooms-cottages",
    
    resources:
    {
        adults: "Adulto(s)",
        children: "Niño(s)",
        room: "Casa de Campo",
        rooms: "Casas de campo",
        roomAdded: "{0} Casa de Campo añadido",
        roomsAdded: "{0} Casas de campo añadido"
    }
});
    
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: "Haga clic para conseguir nuestras ofertas exclusivas",
        enterPromoCode: "Introduzca su c&#243;digo de identificaci&#243;n o n&#250;mero de socio"
        },
        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: "Su c&#243;digo promocional no es v&#225;lido o ha caducado.",
        promoValidationEmptyCode: "Debe introducir el 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 imágenes"
                },
                showMapByDefault: false
                });
            
        eviivo.bookingSystem.managePageLogin.init({
        popupHeaderTitle: "Gestionar una reserva",
        ajaxUrl: "/instantweb/manage/RetrieveOrderCancellationPermissions",
        referrerShortName: "MyWeb",
        propertyShortName: "CrrgHsAccmmdtns99587",
        requestVerificationToken: "wgLu4BW6EIQApP6ArrKb8C8V8DSqwzg5hX8x7twKJ_50Uf8sh2jViERBsuyTbf4DcbKwO-HumuX2Blh3jbggcyGXSOg1:RJBooVT5xchs31AFjdhvMUfWEkSVJkru3OD07GfDJtQs0MLFAb0L9NtwVJfN3ShvworGc-7fgjFndN_PD_x1eYD-puM1",
        ajaxLoaderResources: {
        loadingUpdateResults: "Validando referencia de la reserva y direcci&#243;n de correo electr&#243;nico...",
        loadingSlowSystemWarning: "Estamos intentando cancelar su reserva. Gracias por su paciencia.",
        loadingRefreshingIssueWarning: "Vaya, algo no funciona correctamente. Por favor, intente",
        ajaxFailText: "Algo no funciona correctamente. Por favor, intente",
        refreshPageText: "actualice la p&#225;gina"
        }
        });

        });

        
