// src: pep-ui    
window.PEP = window.PEP || {};
window.PEP.Config = window.PEP.Config || {};
window.PEP.Config.SiteId = window.PEP.Config.SiteId || 'dcl';
window.PEP.Config.DEVICE_PROFILE = window.PEP.Config.DEVICE_PROFILE || {"IS_MOBILE":false,"IS_DESKTOP":true,"IS_TABLET":false,"IS_IPAD":false};
window.PEP.Config.PreferredLanguage = window.PEP.Config.PreferredLanguage || "en-us";
window.PEP.Config.BaseUrlLocale = window.PEP.Config.BaseUrlLocale || "en-us";
window.PEP.Config.Toggles = window.PEP.Config.Toggles || {"Feature":{"dclDarkTheme":true,"enableMemoryMaker":true,"finderUseUrlFriendlyIdsForLocations":true,"finderMapFacilityServiceSnapshotServiceEnabledForCoreData":true,"finderMapFacilityServiceSnapshotServiceEnabled":true,"finderTypeDestinations":true,"finderHideMyPlans":true,"finderDetailsEnableShopDetailsPages":true,"finderDetailsDiningEventsInclusive":true,"finderMapFacilityServiceStorageEnabled":true,"finderMapFacilityServiceValidationEnabled":true,"finderMapFacilityServiceFilteringEnabled":true,"finderMapFacilityServiceBypassFilteringForProducts":true,"authzIntegrationUseFullDomainPath":true,"myWishList":true,"enableUrlRewriting":true,"enableSiteSpecificTimeZones":true,"participantsCanRemoveThemselvesFromDiningReservation":true},"Flow":{"homepageRightRailFastPass":true,"analyticsFramework":true,"finderListingFacetsAnalyticsTracking":true,"enableDayGuestTicketLinkingInGuideMe":true,"responsiveHelpAndSupport":true,"responsiveSearch":true,"enableCartPlusResponsive":true,"memoryMakerPermissions":true,"showMagicBandTrackingData":true,"finderFacetTracking":true,"VGFResortEnable":true,"rfidCardManagement":true,"magicBandTease":true,"fastPassPlus":true,"photoPass":true,"magicBand":true,"annualPassholderAffiliations":true,"memoryMaker":true,"personalMagic":true,"ticket":true,"onlineCheckIn":true,"mmPlusRollout":true,"mainEntrancePassFunctionality":true,"pleaseWait":true,"restrictMagicBandCountryList":true,"finderResponsiveLazyLoad":true,"authzIntegration":true,"DPVBResortEnable":true,"enableGffPreorderRestrictions":true,"enableDisneyWorldAnnualProduct":true,"ticketModsEnabled":true,"dclDarkTheme":true,"checkoutRequireGovtId":true,"enableClaimFlowLogs":true,"newItineraryDayViewAccess":true,"newMyReservationsPageAccess":true,"ticketsEnabled":true,"ticketModsConsumerEnabled":true,"ticketModsTradeEnabled":true,"ticketsThemeParkEnabled":true,"ticketsSpecialEventEnabled":true,"ticketsWaterParkEnabled":true,"ticketsNBAExperienceEnabled":true,"ticketsMemoryMakerEnabled":true,"ticketsParkingEnabled":true},"Release":{"enableLodgingXUp":true,"finderResponsiveAsynchronousLoad":true,"enableUniversalHomepageQuickQuote":true,"ticketsAPEnhancements":true,"finderCalendarsMonthView":true,"displayZeroDollarFlow":true,"hazardousMaterialsAck":true,"disableExpirationDate":true,"enhancedRetrievePage":true,"putAnalyticsModelInMetaTag":true,"clearSensitiveFormData":true,"cartPhotoPass":true,"profileEnableDisneyIdAuthZ":true,"profileEnableECommerceAddressValidation":true,"pricingSummaryReArchBookingRoomOnly":true,"pricingSummaryReArchBookingPackages":true,"enableAnnualPassLink":true,"magicBandEnableGraphicDesign":true,"backendHoldDaysWdw":true,"backendHoldDaysDlr":true,"profileMepAddGuestPlugin":true,"profileFnFTypeAheadServiceCallMigration":true,"profileMyMagicPlusTypeAheadPlugin":true,"signInSignOutLink":true,"guideMeWithTaAndDwm":true,"profileMct20Compliance":true,"updateGuestDineReservationWithTaAndDwm":true,"apRenewalLandingPageWdw":true,"apRenewalLandingPageDlr":true,"dineWithTaAndDwm":true,"expressCheckoutDvicBanner":true,"directToRoom":true,"dlrDinePrepay":true,"childRegMovedToOlci":true,"pricingSummaryReArchBookingTickets":true,"profileEnableGuestControllerVersionFive":true,"pricingSummaryReArchBookingDoubleDeckerPackage":true,"dclEdocsSecureLink":true,"finderCalendarsFacet":true,"livePersonPlatform":true,"removeOlciGate":true,"dclTravelAgentManagedPlans":true,"expressCheckoutFlight":true,"profileEnableDisneyId":true,"profileJwtAuthentication":true,"expressCheckoutPaymentModernization":true,"profileEncryptedCsrf":true,"finderEnableElasticsearch":true,"profileSnowballRedesign":true,"myPlansSpaIsReleased":true,"olciSfToRoomCheckinApiMigration":true,"profileEnableEpcMarketingText":true,"profileRemoveSwidCookies":true,"profileStartMDXClearCookies":true,"confirmationRedesignEnhanced":true,"CareGiverFilter":true,"destinationInTermsAndConditions":true,"magicBandEnableBuildABand":true,"expressCheckoutMarketingOptExclution":true,"enableAccertifyBeacon":true,"prioritizeDcmOnConfirmationPage":true,"expressCheckoutCreditCardTranslationsOverride":true,"enableAccertifyData":true,"billingAddressErrorCopy":true,"cartPageSplunkErrorFix":true,"internationalizationLanguageToggle":true,"enableDirectToRoom2":true,"inlineFieldValidationErrors":true,"fixAnalyticsEmptyProducts":true,"inlineErrorsLog":true,"bypassTravelAgencyEndpoint":true,"enableBoltNbaExperienceTicketSales":true,"buildABandShowPremiumBandNotice":true,"useMySAddStateErr":true,"showGiftCardAsPaymentRoomOnlyDlr":true,"cartErrorsLogRestriction":true,"useMyShippingAddressTruncateFix":true,"AddRoomFormLogErr":true,"useMyShippingBlockedByPhone":true,"purchaseClickLog":true,"ariaExpandedAttributeEcCart":true,"finderEnableSearchService":true,"enableDTRUrgencyMessaging":true,"enableTutorial":true,"enableSearchServiceFaq":true,"saveReservationDataOnCookie":true,"giftCardSubTypeForMod":true,"enableNonStdExpAccess":true,"enableDTRPhase2":true,"expressCheckoutEnableAlertIcon":true,"fallbackExpirationFromPaymentForm":true,"autocompleteGuestPrefix":true,"enableEA":true,"fieldsetFormControlsPaymentSectionEc":true,"dclAwsMigrationSwitch":true,"profileEnableLightbox":true,"vcoWidgetScopeToggle":true,"enableFloridaResidencyFallback":true}};
PEP.syndication =  PEP.syndication || {};
PEP.syndication.firstRun = (PEP.syndication.firstRun !== undefined) ? PEP.syndication.firstRun : true;
PEP.isPepSyndicated = PEP.isPepSyndicated || false;
var head = document.getElementsByTagName('head')[0];
(function () {
    function init() {
        var temp = document.createElement('div'),
            target = document.getElementById('dcl-legal-footer'),
            syndicationBundle = PEP.isPepSyndicated ?
                '//secure.cdn5.wdpromedia.com/media/pep/live/media/modules/syndicated/bd89e8-globalSyndicationBundle.simplified.min.js' :
                '//secure.cdn5.wdpromedia.com/media/pep/live/media/modules/syndicated/20ed4f-globalSyndicationBundle.js';
                    var fontObserverFragment = document.createDocumentFragment();
            fontObserverFragment.appendChild(createJSElement('//secure.cdn2.wdpromedia.com/media/pep/live/media/site/js/dfd173-fontFaceObserverBundle.min.js'));
            head.appendChild(fontObserverFragment);
        
        // Write styles and scripts to head
        // only ever do this once per page so that we do not double up when we syndicate both header and footers

        
        if (PEP.syndication.firstRun) {
            PEP.syndication.firstRun = false;
            var jsFragment = document.createDocumentFragment();

            temp.innerHTML = "<style type=\"text\/css\"> .pepSyndicatedComponent { display: none; }<\/style><link href=\"\/\/secure.cdn4.wdpromedia.com\/media\/pep\/live\/media\/site\/css\/syndication\/4b6e1d-screen.globalSyndication.responsiveMode.css\" media=\"screen\" rel=\"stylesheet\" type=\"text\/css\" ><link href=\"\/\/secure.cdn1.wdpromedia.com\/media\/pep\/live\/media\/site\/css\/1a4e29-fontFace.css\" media=\"screen\" rel=\"stylesheet\" type=\"text\/css\" ><link href=\"\/\/secure.cdn3.wdpromedia.com\/media\/pep\/live\/media\/site\/css\/ui-plus\/1fd144-dclmdx-icons.css\" media=\"screen\" rel=\"stylesheet\" type=\"text\/css\" ><link href=\"\/\/secure.cdn4.wdpromedia.com\/media\/pep\/live\/media\/site\/css\/layout\/468fec-gsc-theme.css\" media=\"screen\" rel=\"stylesheet\" type=\"text\/css\" ><script type=\"text\/javascript\">\n    \/\/<!--\n    var _cookieName = \"WDPROView\";var _cookieVersion = 2;var _cookieDomain = \"\";var _cookiePath = \"\/\";    \/\/-->\n<\/script>\n<script type=\"text\/javascript\" src=\"\/\/secure.cdn4.wdpromedia.com\/media\/pep\/live\/media\/shared\/wdpro-js\/responsive\/device\/14c582-wdpro.device.profiling.js\"><\/script>\n<script type=\"text\/javascript\">\n    \/\/<!--\n    if (typeof WDPRO_DeviceProfiling != \"undefined\" && WDPRO_DeviceProfiling.preferredView === undefined) { WDPRO_DeviceProfiling.init(); }    \/\/-->\n<\/script>";
            if (!document.querySelector('script[src*="otSDKStub.js"]')) {
                            }
            while (temp.firstChild) {
                // filter out text nodes if they exist. We do not want those in the head
                if (temp.firstChild.nodeType === 3) {
                    temp.removeChild(temp.firstChild);
                } else {
                    head.appendChild(temp.firstChild);
                }
            }

                            if (typeof jQuery === 'undefined') {
                    readyJS(head.appendChild(createJSElement('//secure.cdn2.wdpromedia.com/media/pep/live/media/shared/wdpro-js/lib/jquery/895323-jquery-1.11.3.min.js')));
                    readyJS(head.appendChild(createJSElement('//secure.cdn4.wdpromedia.com/media/pep/live/media/site/js/jquery/pepJqueryShim/611972-jquery.deprecated.shim.js')));
                    readyJS(head.appendChild(createJSElement('//secure.cdn1.wdpromedia.com/media/pep/live/media/shared/jquery-ui/js/2b2a5e-jquery-ui.min.js')));
                } else if (typeof jQuery.ui === 'undefined') {
                    readyJS(head.appendChild(createJSElement('//secure.cdn4.wdpromedia.com/media/pep/live/media/site/js/jquery/pepJqueryShim/611972-jquery.deprecated.shim.js')));
                    readyJS(head.appendChild(createJSElement('//secure.cdn1.wdpromedia.com/media/pep/live/media/shared/jquery-ui/js/2b2a5e-jquery-ui.min.js')));
                }

                if (typeof Modernizr === 'undefined') {
                    readyJS(head.appendChild(createJSElement('//secure.cdn4.wdpromedia.com/media/pep/live/media/shared/wdpro-js/lib/modernizr/72dd58-modernizr-version.min.js')));
                }

                var scriptList = [
                    '//secure.cdn3.wdpromedia.com/media/pep/live/media/modules/syndicated/f618fc-globalSyndication.min.js',
                    syndicationBundle
                ];

                waitOnJqueryReadyJS(scriptList);

                    }

        var content = "<div id=\"pageContainerSyndicated\"class=\"pepSyndicatedComponent responsive-mode  dsf-loading \"><div class=\"icon-web-font dcl\"><div class=\"pepGlobalFooter\"><footer class=\"d-all t-all m-all\">\n<div id=\"wdwLegalFooter\" >\n    <div id=\"gde_footerContainer\">\n        <div id=\"gde_footerContents\">\n                        <div id=\"gde_footerLegalContainer\">\n                                <div class=\"gde_footerLegalLinks\">\n                    <ul>\n                                                <li>\n                            <a class=\"guestServicesModalOpener\" target=\"_self\" name=\"&amp;lid=global_footer\/legal\/guest_service\" href=\"https:\/\/disneycruise.disney.go.com\/#\">Help & Guest Services<span class=accessibleText> - Opens Dialog<\/span><\/a><div id=\"guestServicesModalOpener\" data-plugins='[[\"pepModalUIPlus\",{\"dialogLauncher\":\".guestServicesModalOpener\",\"closeButton\":{\"label\":\"Close\",\"position\":\"last\",\"category\":\"primary\"},\"title\":\"What would you like help with?\",\"modal\":true,\"isForm\":false,\"mobile\":false,\"backgroundClose\":true,\"customClass\":\"guest-services-modal-uiplus-container\"}]]' style=\"display:none\"><div id=\"guestServicesModalBody\" class=\"uiPlus\"><p><a href=\"https:\/\/disneycruise.disney.go.com\/help\/\">Disney Cruise Line<\/a><\/p><p><a href=\"https:\/\/disney.go.com\/guestservices\">Disney.com<\/a><\/p><\/div><\/div>                        <\/li>\n                                                                            <li><a target=\"_self\" name=\"&amp;lid=DCL_Footer_Terms_of_Use\" href=\"https:\/\/disneytermsofuse.com\/\">Terms of Use<\/a><\/li><li><a target=\"_self\" name=\"&amp;lid=global_footer\/legal\/legal_notices\" href=\"https:\/\/help.disney.com\/articles\/en_US\/FAQ\/Legal-Notices\">Legal Notices<\/a><\/li><li><a target=\"_self\" name=\"&amp;lid=DCL_Footer_Privacy_Policy\" href=\"https:\/\/disneyprivacycenter.com\/\">Privacy Policy<\/a><\/li><li><a target=\"_self\" name=\"&amp;lid=DCL_Footer_Do_Not_Sell_My_Info\" href=\"https:\/\/privacyportal-de.onetrust.com\/webform\/64f077b5-2f93-429f-a005-c0206ec0738e\/0a4f1f0b-7130-421f-971d-ef578c0bce6d\">Do Not Sell My Personal Information<\/a><\/li><li><a target=\"_self\" name=\"&amp;lid=DCL_Footer_Childrens_Online_Privacy_Policy\" href=\"https:\/\/disneyprivacycenter.com\/kids-privacy-policy\/english\/\">Children's Online Privacy Policy<\/a><\/li><li><a target=\"_self\" name=\"&amp;lid=DCL_Footer_Your_California_Privacy_Rights\" href=\"https:\/\/disneyprivacycenter.com\/notice-to-california-residents\/\">Your California Privacy Rights<\/a><\/li><li><a target=\"_self\" name=\"&amp;lid=DCL_Footer_Internet-Based_Ads\" href=\"http:\/\/preferences-mgr.truste.com\/?type=disneycolor&amp;affiliateId=115\">Interest-Based Ads<\/a><\/li><li><a target=\"_self\" name=\"&amp;lid=DCL_Footer_Internet-Based_Ads\" href=\"https:\/\/privacy.thewaltdisneycompany.com\/en\/current-privacy-policy\/cookies-policy\/\">Cookie Policy<\/a><\/li>                    <\/ul>\n                <\/div>\n                                <div class=\"gde_footerCopyText\">\u00a9 Disney, All Rights Reserved<\/div>\n                            <\/div>\n        <\/div>\n    <\/div>\n<\/div>\n<\/footer><\/div><\/div><\/div>";
        // Write html content
        if (target) {
            target.innerHTML = content;
        }

        
    }
    init();
})();

function loadVersion2Libraries() {
    var scriptList = [];

    if (jQuery && typeof jQuery.ui === 'undefined') {
        readyJS(head.appendChild(createJSElement('//secure.cdn1.wdpromedia.com/media/pep/live/media/shared/jquery-ui/js/2b2a5e-jquery-ui.min.js')));
    }

    if (typeof Modernizr === 'undefined') {
        scriptList.push('//secure.cdn4.wdpromedia.com/media/pep/live/media/shared/wdpro-js/lib/modernizr/72dd58-modernizr-version.min.js');
    }

    scriptList.push('//secure.cdn3.wdpromedia.com/media/pep/live/media/modules/syndicated/f618fc-globalSyndication.min.js');

    if (PEP.isPepSyndicated) {
        scriptList.push('//secure.cdn5.wdpromedia.com/media/pep/live/media/modules/syndicated/bd89e8-globalSyndicationBundle.simplified.min.js');
    } else {
        scriptList.push('//secure.cdn5.wdpromedia.com/media/pep/live/media/modules/syndicated/20ed4f-globalSyndicationBundle.js');
    }
    waitOnJqueryReadyJS(scriptList);
}

// Create js element
function createJSElement(src) {
    var jsElement = document.createElement('script');
    jsElement.setAttribute("type", "text/javascript");
    jsElement.setAttribute("src", src);
    return jsElement;
}

// Create OneTrust js element
function createOneTrustJSElement(oneTrustScriptUrl, dataDomain) {
    var oneTrustScript = document.createElement('script');
    oneTrustScript.setAttribute("type", "text/javascript");
    oneTrustScript.setAttribute("charset", "UTF-8");
    oneTrustScript.setAttribute("data-document-language", true);
    oneTrustScript.setAttribute("data-ignore-ga", true);
    oneTrustScript.setAttribute("src", oneTrustScriptUrl);
    oneTrustScript.setAttribute("data-domain-script", dataDomain);
    oneTrustScript.addEventListener('load', function() {
        var optanonWrapperScript = document.createElement('script');
        optanonWrapperScript.type = 'text/javascript';
        optanonWrapperScript.innerHTML = 
            'function OptanonWrapper() {' +
                'var eOT = new Event("OneTrustGroupsUpdated");' +
                'document.dispatchEvent(eOT);' +
            '}';
        head.appendChild(optanonWrapperScript);
    });
    head.appendChild(oneTrustScript);
}

// check if dom is ready
function readyJS(func) {
    var readyScript = document.createElement("script");
    if (readyScript.readyState) {  //IE
        readyScript.onreadystatechange = function() {
            if (readyScript.readyState == "loaded" ||
                readyScript.readyState == "complete"){
                readyScript.onreadystatechange = null;
                func;
            }
        };
    } else {  //Others
        readyScript.onload = function(){
            func;
        };
    }
}

/**
 * Wait to load the given Script(s) until jQuery is available
 * - check for jQuery and Modernizr, if not loaded (undefined), wait for .3 sec
 * - max wait is 3 seconds before proceeding
 */
function waitOnJqueryFragment(jsFragment) {
    var callCount = 0,
        maxWait = 10; // 10 * .3 = 3 seconds
    if (arguments.length > 1) {
        callCount = arguments[1];
    }
    if (callCount < maxWait && (typeof jQuery  === 'undefined' || typeof jQuery.ui === 'undefined' || typeof Modernizr === 'undefined')) {
        setTimeout(function() { waitOnJqueryFragment(jsFragment, ++callCount); }, 300);
    } else {
        document.getElementsByTagName('head')[0].appendChild(jsFragment);
    }
}
function waitOnJqueryReadyJS(scriptList) {
    var callCount = 0,
        maxWait = 10; // 10 * .3 = 3 seconds
    if (arguments.length > 1) {
        callCount = arguments[1];
    }
    if (callCount < maxWait && (typeof jQuery  === 'undefined' || typeof jQuery.ui === 'undefined' || typeof Modernizr === 'undefined')) {
        setTimeout(function() { waitOnJqueryReadyJS(scriptList, ++callCount); }, 500);
    } else {
        var size = scriptList.length,
            head = document.getElementsByTagName('head')[0];
        for(var i = 0; i < size; i++) {
            readyJS(head.appendChild(createJSElement(scriptList[i])));
        }
    }
}

// TODO: Remove this when we have a better solution
// https://jira-nge.disney.com/browse/GIT-8927
// Force syndicated footer to load plugins
// This issue happens when the footer is intentionally loaded after the header
(function () {
    try {
        jQuery(function($) {
            try{
                $('#mobileMoreLinks').pepAutoPlugin();
            } catch (error) {
                // Do nothing
            }
        });
    } catch (error) {
        // Do nothing
    }
})();

