        var googletag = googletag || {};
        googletag.cmd = googletag.cmd || [];
        var pbjs = pbjs || {};
        pbjs.que = pbjs.que || [];

        /* Generated by WRDicts */
        var ipCC = 'US';
        var consentApplies = true;
        
        

    // Merge server data with existing wrserver object to avoid losing any previously set properties
    var serverData = {
  "Initialization": {
    "Id": 1,
    "Exception": null,
    "Status": 5,
    "IsCanceled": false,
    "IsCompleted": true,
    "IsCompletedSuccessfully": true,
    "CreationOptions": 0,
    "AsyncState": null,
    "IsFaulted": false
  },
  "ddict": {
    "dict": "enen",
    "dict_alt": "definition",
    "isDictionary": true,
    "isBase": false,
    "isMonolingual": true,
    "isVirtual": false,
    "isVirtualPlus": false,
    "isAutomatic": false,
    "isReversible": false,
    "showOtherSide": false,
    "hasOneSide": true,
    "addVirtualInGA": false,
    "isRightToLeft": false,
    "isAsian": false,
    "isWRDict": false,
    "isCollins": true,
    "isEspasa": false,
    "isMondadori": false,
    "isLarousse": false,
    "isLangenscheidt": false,
    "isConjugator": false,
    "forumIDs": "6,92",
    "defaultForumID": "6",
    "defaultForumName": "English Only",
    "forumTableName": "wr_thread_enen",
    "IsValidDictionary": true,
    "dict_OppositeDirection": "enen",
    "term_count": 0,
    "collocation_count": 0,
    "translation_count": 0,
    "stats_last_updated": null,
    "note": "Random House Learner\u0027s Dictionary: should i add this dictionary also ?",
    "last_update": null,
    "isSpaceAcceptedInCompounds": true
  },
  "ipcc": "US",
  "ipcc2": [
    "",
    ""
  ],
  "os": 0,
  "platform": 0,
  "browser": 1,
  "browserVersion": 0,
  "route": null,
  "IsVirtKeyboardNeeded": false,
  "servername": "wwwny2",
  "lineCount": {
    "regular": 0,
    "phrasal": 0,
    "compounds": 0
  },
  "ad": {
    "AdMode": 0,
    "AdModeName": null,
    "bGoogleOnly": false,
    "bUseParallelIntegration": false,
    "bEnableAmazon": false,
    "bEnablePrebid": false,
    "bEnableConfiant": false,
    "bPrebid": false,
    "bPrebid_forum": false,
    "bPrebid_728A": false,
    "bPrebid_300A": false,
    "bPrebid_300B": false,
    "bPrebid_728F_top": false,
    "bPrebid_728F_mid": false,
    "bPrebid_728F_bot": false,
    "bPrebid_m320x50": false,
    "bPrebid_mf320x50": false,
    "bPrebid_m300x250": false,
    "bPrebid_728x90mt": false,
    "bPrebid_indep": false,
    "bPrebid_abtest": false,
    "au728A": null,
    "au728x90mt": null,
    "au300A": null,
    "au300B": null,
    "aum320x50": null,
    "aumf320x50": null,
    "aum300x250": null,
    "bNoAds": false,
    "useConsent": false,
    "errors": null,
    "isForum": false,
    "runABTest": false,
    "RandomClass": null,
    "RandomNumber": 0,
    "RandomNumber10000": 0,
    "bLazyLoadingEnabled": false,
    "bEnableBlockThrough": false,
    "UseInlineCode": false,
    "IsTestAdPage": false,
    "auf728F_top": null,
    "auf728F_mid": null,
    "auf728F_bot": null,
    "bSnigelEnabled": false,
    "bWREnabled": false,
    "SnigelDesktopReqPercent": 50,
    "SnigelMobileReqPercent": 50
  },
  "wrTraceData": []
};
    if (typeof wrserver !== 'undefined' && wrserver !== null) {
        // Preserve existing wrTraceData if it exists and has content
        var existingTraceData = wrserver.wrTraceData;
        
        // Merge serverData into existing wrserver object
        Object.assign(wrserver, serverData);
        
        // Restore the existing wrTraceData if it was more populated than the server data
        if (existingTraceData && existingTraceData.length > 0 && 
            (!serverData.wrTraceData || serverData.wrTraceData.length === 0)) {
            wrserver.wrTraceData = existingTraceData;
        }
    } else {
        // If wrserver doesn't exist, create it with serverData
        var wrserver = serverData;
    }



        //#1376: This function write messages to the browser`s console but it checked first if they are allowed

            var consoleDebug = function(){};
            
        window.onerror = function (msg, url, noLigne, noColonne, erreur) {
            var chaine = msg.toLowerCase();
            var souschaine = "script error";
            
            // Ignore generic "Script error" messages (usually from cross-origin scripts)
            if (chaine.indexOf(souschaine) > -1){
		        console.log('Error ignored (script error): ', msg, erreur);
		        return false;
            }

            // Check if error is from a third-party domain
            if (url && url !== '') {
                // Ignore Chrome extension errors
                if (url.startsWith('chrome-extension://')) {
                    console.log('Error ignored (chrome extension): ', msg, 'from:', url, erreur);
                    return false;
                }
                
                var currentDomain = window.location.hostname;
                var errorUrl = new URL(url, window.location.href);
                var errorDomain = errorUrl.hostname;
                
                // List of known third-party domains to ignore
                var thirdPartyDomains = [
                    'googletagmanager.com',
                    'googlesyndication.com',
                    'doubleclick.net',
                    'amazon-adsystem.com',
                    'adsystem.amazon.com',
                    'facebook.com',
                    'connect.facebook.net',
                    'twitter.com',
                    'platform.twitter.com',
                    'google-analytics.com',
                    'googletagservices.com',
                    'gstatic.com',
                    'googleapis.com',
                    'youtube.com',
                    'ytimg.com'
                ];
                
                // Check if error is from current domain or a subdomain
                var isLocalError = errorDomain === currentDomain || 
                                 errorDomain === '' || 
                                 errorDomain.endsWith('.' + currentDomain) ||
                                 errorDomain === 'wordreference.com' ||
                                 errorDomain.endsWith('.wordreference.com');
                
                // Check if error is from known third-party domain
                var isThirdParty = thirdPartyDomains.some(function(domain) {
                    return errorDomain === domain || errorDomain.endsWith('.' + domain);
                });
                
                if (isThirdParty || !isLocalError) {
                    console.log('Error ignored (third-party): ', msg, 'from:', errorDomain, erreur);
                    return false;
                }
            }

            // Filter out common third-party script error patterns
            var ignoredPatterns = [
                "evaluating 'xf.element.extend'",
                "non-error promise rejection",
                "network error",
                "loading chunk",
                "loading css chunk",
                "dynamically imported module",
                "script load error",
                "adsbygoogle",
                "googletag",
                "facebook",
                "twitter",
                "instagram",
                "tiktok",
                "snapchat"
            ];
            
            for (var i = 0; i < ignoredPatterns.length; i++) {
                if (chaine.indexOf(ignoredPatterns[i]) > -1) {
                    console.log('Error ignored (pattern match): ', msg, erreur);
                    return false;
                }
            }

	        reportError('forumIframeHead.aspx', msg, url, noLigne, noColonne, JSON.stringify(erreur));

            return false;
        };

        //Log the error in the server
        function reportError(Source, Message, URL, Line, Column, ObjectError){
            var message = {
		        'Source': Source,
		        'Message': Message,
		        'URL': URL,
                'OriginalURL': location.href,
		        'Line': Line,
		        'Column': Column,
                'country': 'US',
		        'ObjectError': ObjectError
	        };

	        var xhr = new XMLHttpRequest();
	        xhr.open("POST", 'https://www.wordreference.com/home/errorReport.aspx', true);

	        //Envoie les informations du header adaptées avec la requête
	        xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

	        xhr.onreadystatechange = function() {
		        if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
			        console.log("> Error report sent successfully:", Message);
		        }
	        }
	        xhr.send("error=" + encodeURIComponent(JSON.stringify(message)));
        }



                //This function is needed by cookie_warning.aspx
                function inIframe () {
                    try {
                        return window.self !== window.top;
                    } catch (e) {
                        return true;
                    }
                }
            
        



    


        console.log(`>> Custom ad solution: Prebid Only`);
        


        
            var googletag = googletag || {};
            googletag.cmd = googletag.cmd || [];
            //Set the delay before starting the auction

            //This will send an event to GA
            function sendGAEvent(category, action, label, value, callback){
                gtag('event', action, {
                    'event_category': category,
                    'event_label': label,
                    'value': value,
                    'non_interaction': true,
                    'event_callback': function() {
                            callback();
                        }
                });
            }
        
    
    

            //This will send an event to GA
            function sendGAEvent(category, action, label, value, callback){
                gtag('event', action, {
                    'event_category': category,
                    'event_label': label,
                    'value': value,
                    'non_interaction': true,
                    'event_callback': function() {
                            callback();
                        }
                });
            }

            var consentReady = false;
            var consentExec = function() {
                window.wrconsent = window.wrconsent || {};
                window.wrconsent.gdpr = window.wrconsent.gdpr || {};
                window.wrconsent.ccpa = window.wrconsent.ccpa || {};

                //Set personalized ads value 
                //More here: https://developers.google.com/publisher-tag/reference#googletag.privacysettingsconfig
                function setPersonalizedAds(value){
                  var googletag = googletag || {};
                  googletag.cmd = googletag.cmd || [];
                  googletag.cmd.push(function() {
                      // Set privacy settings for CCPA compliance
                      // No need to use 'nonPersonalizedAds', it will be redundant since we already have CMP implemented
                      googletag.pubads().setPrivacySettings({
                        'restrictDataProcessing': !value,       //to comply with CCPA regulations, ensuring that personal data is not used for personalized advertising or other purposes that involve data processing
                      });

                      // Set request for non-personalized ads (0 for personalized, 1 for non-personalized)
                      googletag.pubads().setRequestNonPersonalizedAds(!value ? 1 : 0);
                  });
                }   

                // Make sure that the properties exist on the window.
                window.googlefc = window.googlefc || {};
                window.googlefc.ccpa = window.googlefc.ccpa || {}
                window.googlefc.callbackQueue = window.googlefc.callbackQueue || [];

            
                //Get the user consent            
                var consents = {};
                var legitimateInterests = {};
                var personalizedAdsAccepted = false, nonPersonalizedAdsAccepted = false, limitedAdsAccepted = false;
                //setPersonalizedAds(false);    //Useless in TCF v2: GPT will gather the consent string automatically

                //Set the user consent
                const checkGDPRConsent = (tcData, success) => {   
                  consoleDebug("*** GDPR applies");           
                  consoleDebug('++* tcData', tcData, success);
                  if(success && tcData.gdprApplies &&
                    (tcData.eventStatus === 'useractioncomplete' || tcData.eventStatus === 'tcloaded')) {
                    window.wrconsent.gdpr.gdprApplies = true;
                    // do something with tcData.tcString
                    consents = tcData.purpose.consents;
                    legitimateInterests = tcData.purpose.legitimateInterests;
                    consoleDebug('++ consents', consents);

                    //Set the personalized ads for DFP
                    // More: https://support.google.com/admanager/answer/9805023
                    personalizedAdsAccepted = consents[1] && consents[3] && consents[4]
                                              && ((legitimateInterests[2] || consents[2]) && 
                                                  (legitimateInterests[7] || consents[7]) && 
                                                  (legitimateInterests[9] || consents[9]) && 
                                                  (legitimateInterests[10] || consents[10]));
                    nonPersonalizedAdsAccepted = consents[1]
                                                 && ((legitimateInterests[2] || consents[2]) && 
                                                     (legitimateInterests[7] || consents[7]) && 
                                                     (legitimateInterests[9] || consents[9]) && 
                                                     (legitimateInterests[10] || consents[10]));
                    limitedAdsAccepted = !consents[1] 
                                         && ((legitimateInterests[2] || consents[2]) && 
                                             (legitimateInterests[7] || consents[7]) && 
                                             (legitimateInterests[9] || consents[9]) && 
                                             (legitimateInterests[10] || consents[10]));

                    //Update Google Consent Mode

                    if(personalizedAdsAccepted){
                      consoleDebug('++ Personalized ads accepted by the user.');
                    } else if (nonPersonalizedAdsAccepted){
                      consoleDebug('++ Non personalized ads accepted by the user.');
                    } else if (limitedAdsAccepted) {
                      //consoleDebug('++ Limited ads accepted by the user.');
                    } else {
                      consoleDebug('++ Ads are not accepted by the user.');
                    }

                    consentReady = true;    //Ad requests can start
                    consoleDebug('++* Call startAuction from GDPR section.');
                    googletag.cmd.push(function(){
	                    pbjs.que.push(function() {
                            startAuction();         //Start the auction
                    	});
                    });
                    window.wrconsent.auctionStarted = true;

                    //These variables are used for stats
                    var GDPRnoCookie = true;
                    var GDPRconsent = personalizedAdsAccepted;
                    var GDPRnoConsent = !personalizedAdsAccepted;
                    var GDPRconsentAllAccepted = consents[1] && consents[2] && consents[3] && consents[4] && consents[5] && consents[6] && consents[7] && consents[8] && consents[9] && consents[10];
                    var GDPRconsentAllRejected = !consents[1] && !consents[2] && !consents[3] && !consents[4] && !consents[5] && !consents[6] && !consents[7] && !consents[8] && !consents[9] && !consents[10];
                
                    //Report the euconsent cookie state (only for EU users)
                    if(GDPRconsent)
                        sendGAEvent('GDPR', 'GDPR-consent', 'GDPR-consent-' + GDPRconsent, (GDPRconsent ? '1' : '0'), function() { consoleDebug(":> GDPR: GDPR-consent-"  + GDPRconsent + " -> GA"); });
                    if(GDPRnoConsent)
                        sendGAEvent('GDPR', 'GDPR-noConsent', 'GDPR-noConsent-' + GDPRnoConsent, (GDPRnoConsent ? '1' : '0'), function() { consoleDebug(":> GDPR: GDPR-noConsent-"  + GDPRnoConsent + " -> GA"); });
                    if(GDPRnoCookie)
                        sendGAEvent('GDPR', 'GDPR-noCookie', 'GDPR-noCookie-' + GDPRnoCookie, (GDPRnoCookie ? '1' : '0'), function() { consoleDebug(":> GDPR: GDPR-noCookie-"  + GDPRnoCookie + " -> GA"); });
                    if(GDPRconsentAllAccepted)
                        sendGAEvent('GDPR', 'GDPR-consentAllAccepted', 'GDPR-consentAllAccepted-' + GDPRconsentAllAccepted, (GDPRconsentAllAccepted ? '1' : '0'), function() { consoleDebug(":> GDPR: GDPR-consentAllAccepted-"  + GDPRconsentAllAccepted + " -> GA"); });
                    if(GDPRconsentAllRejected)
                        sendGAEvent('GDPR', 'GDPR-consentAllRejected', 'GDPR-consentAllRejected-' + GDPRconsentAllRejected, (GDPRconsentAllRejected ? '1' : '0'), function() { consoleDebug(":> GDPR: GDPR-consentAllRejected-"  + GDPRconsentAllRejected + " -> GA"); });

                    // remove the event handler to not get called more than once
                    __tcfapi('removeEventListener', 2.2, (success) => {
                      if(success) {
                        // oh good...
                        consoleDebug('++ CMP listener removed.');
                      }
                    }, tcData.listenerId);

                    //If the user did not accept at least purpose 1 and Google, ads won't show up
                    var isGoogleConsented = (tcData.vendor.consents[755] && tcData.vendor.legitimateInterests[755]) || false;
                    var isPurposeOneConsented = consents[1] || false;
                    consoleDebug('** isPurposeOneConsented:', isPurposeOneConsented);
                    consoleDebug('** isGoogleConsented:', isGoogleConsented);

                    //Fill wrconsent.gdpr and decide weather ads are consented or not
                    window.wrconsent.gdpr.consents = consents;
                    window.wrconsent.gdpr.legitimateInterests = legitimateInterests;
                    window.wrconsent.gdpr.isGoogleVendorConsented = isGoogleConsented;
                    window.wrconsent.gdpr.isPurposeOneConsented = isPurposeOneConsented;
                    window.wrconsent.gdpr.personalizedAdsAccepted = personalizedAdsAccepted;
                    window.wrconsent.gdpr.nonPersonalizedAdsAccepted = nonPersonalizedAdsAccepted;
                    window.wrconsent.gdpr.limitedAdsAccepted = limitedAdsAccepted;
                    window.wrconsent.gdpr.adsAllowed = (!window.wrconsent.gdpr.gdprApplies || 
                                                       (isGoogleConsented && personalizedAdsAccepted) || 
                                                       //(limitedAdsAccepted) || 
                                                       (isGoogleConsented && nonPersonalizedAdsAccepted));
                    window.wrconsent.isPremiumUser = false;

                    //Save consent status
                    saveWRConsentStatus();
                  }
                  else if (success && !tcData.gdprApplies){
                      window.wrconsent.gdpr.gdprApplies = false;
                      consoleDebug('++ GDPR does not apply.');
                      noConsentNeeded();
                  }
                }            

                const checkUSPConsent = (uspData, success) => { 
                  //consoleDebug("*** CCPA applies");
                  consoleDebug('++* uspData', uspData);
              
                  //uspConsent parsing
                  var CCPAArray = uspData.uspString.split("");
                  var CCPAApplies = (uspData.uspString !== "1---");
                  var CCPANotice = (CCPAArray[1] === 'Y');
                  var CCPAOptOut = (CCPAArray[2] === 'Y');

                  setPersonalizedAds(!CCPAOptOut);
                  if(CCPAOptOut)
                    consoleDebug('++* Don\'t show personalized ads.');
                  else
                    consoleDebug('++* Show personalized ads.');
              
                  //Report the CCPA consent state (only for US CA users)
                  if(CCPAApplies){
                      sendGAEvent('CCPA', 'CCPA-applicable', 'CCPA-applicable-' + CCPAApplies, (CCPAApplies ? '1' : '0'), function() { consoleDebug(":> CCPA: CCPA-applicable-"  + CCPAApplies + " -> GA"); });
                      sendGAEvent('CCPA', 'CCPA-notice', 'CCPA-notice-' + CCPANotice, (CCPANotice ? '1' : '0'), function() { consoleDebug(":> CCPA: CCPA-Notice-"  + CCPANotice + " -> GA"); });
                      sendGAEvent('CCPA', 'CCPA-OptOut', 'CCPA-OptOut-' + CCPAOptOut, (CCPAOptOut ? '1' : '0'), function() { consoleDebug(":> CCPA: CCPA-OptOut-"  + CCPAOptOut + " -> GA"); });
                  }

                  consentReady = true;    //Ad requests can start
                  consoleDebug('++* Call startAuction from USP section.');
                  googletag.cmd.push(function(){
	                    pbjs.que.push(function() {
                            startAuction();         //Start the auction
                  	    });
                  });
                  window.wrconsent.auctionStarted = true;
                }

                const noConsentNeeded = () => { 
                    //Both ccpa and gdpr should be checked first
                    consoleDebug('++* No consent is needed');
                    if(window.wrconsent.gdprApplies || window.wrconsent.ccpaApplies){      //Set personalized ads in the case of ccpa only
                        consoleDebug('++* Something wrong happened. Don\'t show personalized ads.');
                        if(!window.wrconsent.gdprApplies) {       //In GDPR case, personalized ads is set automatically through TCF
                            consoleDebug('++* Don\'t show personalized ads.');
                            setPersonalizedAds(false);
                        }
                    } else {
                        consoleDebug('++* Show personalized ads.');
                        setPersonalizedAds(true);
                    }
                    consoleDebug('++* Call startAuction from noConsentNeeded');
                    consentReady = true;    //Ad request can start                        
                    googletag.cmd.push(function(){
	                    pbjs.que.push(function() {
                            startAuction();         //Start the auction
                    	});
                    });
                    window.wrconsent.auctionStarted = true;
                }            

                // Queue the callback on the callbackQueue.

                    googlefc.callbackQueue.push({
                        'INITIAL_CCPA_DATA_READY':
                        () => {
                            switch (googlefc.ccpa.getInitialCcpaStatus()) {
                                case googlefc.ccpa.InitialCcpaStatusEnum.UNKNOWN:
                                    // Something failed, in an unknown state.
                                    consoleDebug('++* CCPA something wrong happened.');
                                    window.wrconsent.ccpa.ccpaApplies = false;
                                    window.wrconsent.ccpa.uspString = "1---";
                                    consoleDebug('++* CCPA does not apply.');
                                    noConsentNeeded();
                                    break;
                                case googlefc.ccpa.InitialCcpaStatusEnum.CCPA_DOES_NOT_APPLY:
                                    // Insert handling for cases where the user is not CCPA eligible.
                                    window.wrconsent.ccpa.ccpaApplies = false;
                                    window.wrconsent.ccpa.uspString = "1---";
                                    consoleDebug('++* CCPA does not apply.');
                                    noConsentNeeded();
                                    break;
                                case googlefc.ccpa.InitialCcpaStatusEnum.NOT_OPTED_OUT:
                                    // Insert handling for cases where the user is CCPA eligible and has
                                    // not opted out.
                                    window.wrconsent.ccpa.ccpaApplies = true;
                                    window.wrconsent.ccpa.optedOut = false;
                                    consoleDebug('++* CCPA not opted out.');
                                    __uspapi('getUSPData', 1 , (uspData, success) => {
                                        if(success) {
                                            window.wrconsent.ccpa.uspString = uspData.uspString;
                                            checkUSPConsent(uspData, success);
                                        } else {
                                            //Something wrong happened, try to start the auction with personalized ads set to false
                                            window.wrconsent.ccpa.uspString = "1NNN";
                                            noConsentNeeded();
                                        }
                                    });
                                    break;
                                case googlefc.ccpa.InitialCcpaStatusEnum.OPTED_OUT:
                                    // Insert handling for cases where the user is CCPA eligible and has
                                    // opted out.
                                    window.wrconsent.ccpa.ccpaApplies = true;
                                    window.wrconsent.ccpa.optedOut = true;
                                    consoleDebug('++* CCPA opted out.');
                                    __uspapi('getUSPData', 1 , (uspData, success) => {
                                        if(success) {
                                            checkUSPConsent(uspData, success);
                                            window.wrconsent.ccpa.uspString = uspData.uspString;
                                        } else {
                                            //Something wrong happened, try to start the auction
                                            window.wrconsent.ccpa.uspString = "1NYN";
                                            noConsentNeeded();
                                        }
                                    });
                                    break;
                            }
                        }
                    });
                    window.wrconsent.gdpr.gdprApplies = false;
                                }

            //If inside an iframe, don't check the consent and don't run the Auction (no ads)
            document.addEventListener("DOMContentLoaded", function(event) {
                //Use a timer to reduce the Total Blocking Time (web vitals)
                if (!inIframe())
                    consentExec(); //Show the Ads
            });   
                

        
var sizes300 = [[300, 250]];
var sizes728 = [[728, 90], [970, 90]];
var sizes728forum = [[728, 90],[320, 50],[300, 50]];
var sizes_m320x50 = [[320, 50]];
var sizes_mf320x50 = [[320, 50]];
var sizes_m300x250 = [[300, 250]];
var sizesABtest = [[728, 90],[320, 50]];

//for Amazon
var sizesDisplayforum = [[728, 90],[300, 250]];
var sizesPhoneforum = [[320, 50],[300, 50],[300, 250]];
var sizesABdisplay = [[728, 90]];
var sizesABphone = [[320, 50]];

var sizemap_728A =      [
                            { dim: [770, 0],    adsize: [[728, 90]] },
                            { dim: [0,0],       adsize: [] }
                        ];
var sizemap_300AB =     [
                            { dim: [768, 0],    adsize: [[300, 250]] },
                            { dim: [0,0],       adsize: [] }
                        ];
var sizemap_728F_All =  [
                            { dim: [800, 200],  adsize: [[728, 90]] },
                            { dim: [0,0],       adsize: [[320, 50], [320, 100]] }
                        ]
var sizemap_abtest =    [
                            { dim: [800, 200],  adsize: [[728, 90]] },
                            { dim: [0,0],       adsize: [[320, 50]] }
                        ];


//This one is used in the forums to check if 728F_mid should be displayed or not.
var iShow728F_mid = iShow728F_mid || false;

var devicew = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var deviceh = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);

var slots = [];

 //Find the sizes to use in forums
var forumAdSize;
if(devicew >= 800){
    forumAdSize = sizesDisplayforum;
} else {
    forumAdSize = sizesPhoneforum;
}


        slots.push({
            id: 'topSupp',
            path: '/1005951/Forum_728_Top_US',
            tid: generateUUID(),
            sizes: sizes728forum,
            sizeMap: sizemap_728F_All,
            bids: [
								{ bidder: 'ix', labelAny: ["display"], params: { siteId: '313107', size: [728, 90] } },
								{ bidder: 'openx', labelAny: ["display"], params: { delDomain: 'wordreference-d.openx.net', unit: '540412029' } },
								{ bidder: 'appnexus', labelAny: ["display"], params: { placementId: '14260556' } },
								{ bidder: 'rubicon', labelAny: ["display"], params: { accountId: '19572', siteId: '222190', zoneId: '1097120' } },
								{ bidder: 'sovrn', labelAny: ["display"], params: { tagid: '615342' } },
								{ bidder: '33across', labelAny: ["display"], params: { siteId: 'aYAswE-_ar6yoTaKkGJozW', productId: 'siab' } },
								{ bidder: 'medianet', labelAny: ["display"], params: { cid: '8CUP2H835', crid: '326383183' } },
								{ bidder: 'onetag', labelAny: ["display"], params: { pubId: '72056d0354bd858', ext: { placement_name: '728F_top_US' } } },
								{ bidder: 'oftmedia', labelAny: ["display"], params: { placementId: '22307374' } },
								{ bidder: 'pubmatic', labelAny: ["display"], params: { publisherId: '161158', adSlot: 'Forum_728_Top_US' } },
								{ bidder: 'appnexus', labelAny: ["phone"], params: { placementId: '14372127' } },
								{ bidder: 'rubicon', labelAny: ["phone"], params: { accountId: '19572', siteId: '222190', zoneId: '1110418' } },
								{ bidder: 'openx', labelAny: ["phone"], params: { delDomain: 'wordreference-d.openx.net', unit: '540452688' } },
								{ bidder: 'ix', labelAny: ["phone"], params: { siteId: '319019', size: [320, 50] } },
								{ bidder: 'sovrn', labelAny: ["phone"], params: { tagid: '966453' } }
								],
            prebid: {
                enabled: true
            },
            a9: {
                enabled: false,
                sizes: forumAdSize      //Overrides the default size for A9
            }
        });
    
        if(iShow728F_mid){
            slots.push({
                id: '728F_mid',
                path: '/1005951/Forum_728_Mid_US',
                tid: generateUUID(),
                sizes: sizes728forum,
                sizeMap: sizemap_728F_All,
                bids: [
								{ bidder: 'ix', labelAny: ["display"], params: { siteId: '313127', size: [728, 90] } },
								{ bidder: 'openx', labelAny: ["display"], params: { delDomain: 'wordreference-d.openx.net', unit: '540412036' } },
								{ bidder: 'appnexus', labelAny: ["display"], params: { placementId: '14261494' } },
								{ bidder: 'rubicon', labelAny: ["display"], params: { accountId: '19572', siteId: '222190', zoneId: '1097140' } },
								{ bidder: 'sovrn', labelAny: ["display"], params: { tagid: '615349' } },
								{ bidder: '33across', labelAny: ["display"], params: { siteId: 'dS82ZA-_ar6ykcaKkv7mNO', productId: 'siab' } },
								{ bidder: 'medianet', labelAny: ["display"], params: { cid: '8CUP2H835', crid: '334156881' } },
								{ bidder: 'onetag', labelAny: ["display"], params: { pubId: '72056d0354bd858', ext: { placement_name: '728F_mid_US' } } },
								{ bidder: 'oftmedia', labelAny: ["display"], params: { placementId: '22307366' } },
								{ bidder: 'pubmatic', labelAny: ["display"], params: { publisherId: '161158', adSlot: 'Forum_728_Mid_US' } },
								{ bidder: 'appnexus', labelAny: ["phone"], params: { placementId: '14372134' } },
								{ bidder: 'rubicon', labelAny: ["phone"], params: { accountId: '19572', siteId: '222190', zoneId: '1110432' } },
								{ bidder: 'openx', labelAny: ["phone"], params: { delDomain: 'wordreference-d.openx.net', unit: '540452680' } },
								{ bidder: 'ix', labelAny: ["phone"], params: { siteId: '319012', size: [320, 50] } },
								{ bidder: 'sovrn', labelAny: ["phone"], params: { tagid: '966446' } }
								],
                prebid: {
                    enabled: true
                },
                a9: {
                    enabled: false,
                    sizes: forumAdSize      //Overrides the default size for A9
                }
            });
        }
    
        slots.push({
            id: 'botSupp',
            path: '/1005951/Forum_728_Bot_US',
            tid: generateUUID(),
            sizes: sizes728forum,
            sizeMap: sizemap_728F_All,
            bids: [
								{ bidder: 'ix', labelAny: ["display"], params: { siteId: '313135', size: [728, 90] } },
								{ bidder: 'openx', labelAny: ["display"], params: { delDomain: 'wordreference-d.openx.net', unit: '540412043' } },
								{ bidder: 'appnexus', labelAny: ["display"], params: { placementId: '14261537' } },
								{ bidder: 'rubicon', labelAny: ["display"], params: { accountId: '19572', siteId: '222190', zoneId: '1097162' } },
								{ bidder: 'sovrn', labelAny: ["display"], params: { tagid: '615356' } },
								{ bidder: '33across', labelAny: ["display"], params: { siteId: 'bo6iRo-_er6yofaKlId8sQ', productId: 'siab' } },
								{ bidder: 'medianet', labelAny: ["display"], params: { cid: '8CUP2H835', crid: '297614460' } },
								{ bidder: 'onetag', labelAny: ["display"], params: { pubId: '72056d0354bd858', ext: { placement_name: '728F_bot_US' } } },
								{ bidder: 'oftmedia', labelAny: ["display"], params: { placementId: '22307359' } },
								{ bidder: 'pubmatic', labelAny: ["display"], params: { publisherId: '161158', adSlot: 'Forum_728_Bot_US' } },
								{ bidder: 'openx', labelAny: ["phone"], params: { delDomain: 'wordreference-d.openx.net', unit: '540452670' } },
								{ bidder: 'appnexus', labelAny: ["phone"], params: { placementId: '14372143' } },
								{ bidder: 'rubicon', labelAny: ["phone"], params: { accountId: '19572', siteId: '222190', zoneId: '1110456' } },
								{ bidder: 'ix', labelAny: ["phone"], params: { siteId: '319004', size: [320, 50] } },
								{ bidder: 'sovrn', labelAny: ["phone"], params: { tagid: '966439' } }
								],
            prebid: {
                enabled: true
            },
            a9: {
                enabled: false,
                sizes: forumAdSize      //Overrides the default size for A9
            }
        });
    var adUnits = slots
    .filter(slot => slot.prebid && slot.prebid.enabled)
    .map((slot) => ({
        code: slot.id,
        labelAny: slot.labelAny ? slot.labelAny : undefined,
        mediaTypes: {
            banner: {
                sizes: (slot.prebid.sizes ? slot.prebid.sizes : slot.sizes),    //If there is a custom size use it, if not use the default size.
            },
        },
        ortb2Imp: {
            ext: {
                tid: slot.tid
            }
        },
        bids: slot.bids
    }));


function generateUUID() {
    if(crypto && crypto.randomUUID)
        return crypto.randomUUID();

    var d = new Date().getTime();//Timestamp
    var d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now()*1000)) || 0;//Time in microseconds since page-load or 0 if unsupported
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        var r = Math.random() * 16;//random number between 0 and 16
        if(d > 0){//Use timestamp until depleted
            r = (d + r)%16 | 0;
            d = Math.floor(d/16);
        } else {//Use microseconds since page-load if supported
            r = (d2 + r)%16 | 0;
            d2 = Math.floor(d2/16);
        }
        return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
    });
}

                googletag.cmd.push(function() {
                    var headerMap = googletag.sizeMapping().
                        addSize([800, 200], [[728, 90]]).
                        addSize([0,0], [[320, 50], [320, 100]]).
                        build();
                    googletag.defineSlot('/1005951/Forum_728_Top_US', sizes728forum, 'topSupp')
                        .defineSizeMapping(headerMap)
                        .addService(googletag.pubads());
                    //googletag.pubads().enableSingleRequest();
                    //googletag.enableServices();
                });
                
                if(iShow728F_mid){
                    googletag.cmd.push(function() {
                            var headerMap = googletag.sizeMapping().
                                addSize([800, 200], [[728, 90]]).
                                addSize([0,0], [[320, 50], [320, 100]]).
                                build();
                            googletag.defineSlot('/1005951/Forum_728_Mid_US', sizes728forum, '728F_mid')
                                .defineSizeMapping(headerMap)
                                .addService(googletag.pubads());
                            //googletag.pubads().enableSingleRequest();
                            //googletag.enableServices();
                        });
                }
                
                googletag.cmd.push(function() {
                    var headerMap = googletag.sizeMapping().
                        addSize([800, 200], [[728, 90]]).
                        addSize([0,0], [[320, 50], [320, 100]]).
                        build();
                    googletag.defineSlot('/1005951/Forum_728_Bot_US', sizes728forum, 'botSupp')
                        .defineSizeMapping(headerMap)
                        .addService(googletag.pubads());
                    //googletag.pubads().enableSingleRequest();
                    //googletag.enableServices();
                });
                
                googletag.cmd.push(function() {
                    googletag.pubads().enableSingleRequest();
                    googletag.pubads().setTargeting('dict', 'enen');   // Page-level targeting.
                    googletag.enableServices();
                });

                // Polling function
                function poll(fn, timeout, interval) {
                    var endTime = Number(new Date()) + (timeout || 2000);
                    interval = interval || 100;

                    var checkCondition = function(resolve, reject) {
                        // If the condition is met, we're done!
                        var result = fn();
                        if(result) {
                            resolve(result);
                        }
                        // If the condition isn't met but the timeout hasn't elapsed, go again
                        else if (Number(new Date()) < endTime) {
                            setTimeout(checkCondition, interval, resolve, reject);
                        }
                        // Didn't match and too much time, reject!
                        else {
                            reject(new Error('timed out for ' + fn + ': ' + arguments));
                        }
                    };

                    return new Promise(checkCondition);
                }
            
            

        

        var PREBID_TIMEOUT   = 3000;
        var FAILSAFE_TIMEOUT = 3500;
        
        var iShow728F_mid = iShow728F_mid || false;
    

		// ======== DO NOT EDIT BELOW THIS LINE =========== //
            var hideMobileAd = false;               //This is used to exclude the definition of mobileAd_holder slot when the content is small
            var googletag = googletag || {};
            googletag.cmd = googletag.cmd || [];
            googletag.cmd.push(function() {
                googletag.pubads().disableInitialLoad();
            
                //Remove mobileAd_holder from the adUnits if it does not exist
                if(!document.getElementById('mobileAd_holder')) {
                    if(typeof adUnits === 'object'){
                        adUnits = adUnits.filter(function(element, index, array){
                            return element.code != 'mobileAd_holder';
                        });
                    }
                    if(typeof apstagSlots === 'object'){
                        apstagSlots = apstagSlots.filter(function(element, index, array){
                            return element.slotID != 'mobileAd_holder';
                        });
                    }
                }
                
                //Remove mobileAd_holder2 from the adUnits if it does not exist
                if(!document.getElementById('mobileAd_holder2')) {
                    if(typeof adUnits === 'object'){
                        adUnits = adUnits.filter(function(element, index, array){
                            return element.code != 'mobileAd_holder2';
                        });
                    }
                    if(typeof apstagSlots === 'object'){
                        apstagSlots = apstagSlots.filter(function(element, index, array){
                            return element.slotID != 'mobileAd_holder2';
                        });
                    }
                }
            });
        googletag.nAdsShown = 0;        //This is the number of rendered slots
        googletag.nAdsRequested = 0;    //This is the number of requested slots

        //This is the polling timeout in milliseconds for DFP, SlotRendering and consentReady check
        var SlotRenderingTimeout = 5000;

        //This will send an event to GA
        var sendGAEvent = sendGAEvent || function (category, action, label, value, callback){
            gtag('event', action, {
                'event_category': category,
                'event_label': label,
                'value': value,
                'non_interaction': true,
                'event_callback': function() {
                        callback();
                    }
            });
        };

        //Used to detect scrolling position
        let lastKnownScrollPosition = 0;

        //Ads viewability event
        googletag.cmd.push(function() {
            //This event will fire if an ad was rendered
            googletag.pubads().addEventListener('slotRenderEnded', function(e) {
                if (!e.isEmpty) {	// If the ad isn't empty
                    googletag.nAdsShown++;
                    consoleDebug(">> Slot rendered: ", e.slot.getSlotElementId(), e);
                } else {
                    console.warn(">> Slot is empty: ", e.slot.getSlotElementId(), e);
                }
            });

            //This event will fire whenever a slot is requested
            googletag.pubads().addEventListener('slotRequested', function(e) {
                googletag.nAdsRequested++;
                consoleDebug('>> Slot has been requested:', e.slot.getSlotElementId());
            });
        });
    
    

        const wrPriceGranularity = {
            'buckets': [
                { 'precision': 2, 'min': 0, 'max': 4,  'increment': 0.01 },
                { 'precision': 2, 'min': 4, 'max': 10, 'increment': 0.10 },
                { 'precision': 2, 'min':10, 'max': 30, 'increment': 0.50 }
            ]
        };

        var pbjs = pbjs || {};
        pbjs.que = pbjs.que || [];

        pbjs.que.push(function() {
            pbjs.addAdUnits(adUnits);
            var prebidCommonConfig = {
                enableSendAllBids: true,  //Send all bids into DFP
                deviceAccess: true,       //Enable reading or writing cookies or HTML localstorage
                priceGranularity: wrPriceGranularity,
                userSync: {
                    syncEnabled: true,  // for 33across
                    filterSettings: {
                        iframe: {
                            bidders: '*',   // '*' means all bidders (for 33across)
                            filter: 'include'
                        }
                    }
                }
            };
            pbjs.setConfig(prebidCommonConfig);
    
            var prebidSizeConfig = {
                sizeConfig: [{
                    mediaQuery: '(min-width: 800px)',
                    sizesSupported: [[728,90],[300,250]],
                    labels: ["display"]
                }, {
                    mediaQuery: '(min-width: 0px) and (max-width: 799px)',
                    sizesSupported: [[320,50],[300,50],[300,250]],
                    labels: ["phone"]
                }]
            }
                    pbjs.setConfig(prebidSizeConfig);

            var CMP_TIMEOUT = 8000;
            var consentManagement = {
                gdpr: {
                    cmpApi: 'iab',
                    defaultGdprScope: true,            //TCF v2 only
                    timeout: CMP_TIMEOUT,                      //Length of time (in milliseconds) to allow the CMP to obtain the GDPR consent string. Default is 10000.
                    rules: [{
                        // Purpose 1: Store and/or access information on a device
                        // Enforcing both the purpose and vendors ensures that user consent is required for storing 
                        // and accessing information on the user's device, which is crucial for transparency and compliance.
                        purpose: "storage",
                        enforcePurpose: true,
                        enforceVendor: true
                    },{
                        // Purpose 2:  Select basic ads
                        // Allowing users to object to vendors for basic ads while still enforcing the purpose ensures that 
                        // users have some control over their ad experience without completely disabling header bidding, 
                        // which can help maintain revenue streams.
                        purpose: "basicAds",
                        enforcePurpose: false,
                        enforceVendor: true
                    },{
                        // Purpose 4: Select Personalized Ads.
                        // Enforcing both the purpose and vendors for personalized ads aligns with GDPR principles, 
                        // ensuring that user consent is obtained for the processing of personal data for ad personalization.
                        purpose: "personalizedAds",
                        enforcePurpose: true,
                        enforceVendor: true
                    },{
                        // Purpose 7: Measure ad performance
                        // Enforcing both the purpose and vendors for ad performance measurement is essential for 
                        // transparency and accountability in advertising practices while providing an exception 
                        // for "generic" analytics adapters, which can help streamline data processing for non-invasive 
                        // analytics.
                        purpose: "measurement",
                        enforcePurpose: true,
                        enforceVendor: true,
                        softVendorExceptions: ["generic"]           //Vendor consent is not required: https://docs.prebid.org/dev-docs/modules/genericAnalyticsAdapter.html
                    },{
                        // Special Feature 1: Transmit precise geo
                        // Enforcing both the purpose and vendors for transmitting precise geolocation data ensures that user 
                        // consent is obtained for the processing of sensitive location information, promoting user trust 
                        // and compliance with privacy regulations.
                        purpose: "transmitPreciseGeo",
                        enforcePurpose: true,
                        enforceVendor: true
                    }
                    ]
                },
                usp: {
                    cmpApi: 'iab',
                    timeout: CMP_TIMEOUT
                }
            }


                //When not in the EEA, the page sets consentManagement config with defaultGdprScope=false so that if the CMP is slow to respond then enforcement is off.
                consentManagement.gdpr.defaultGdprScope = false;
                //delete consentManagement.gdpr;
            
            if(consentManagement)
                pbjs.setConfig({consentManagement});

            var prebidPreauctionConfig = {
                gptPreAuction: {
                    enabled: true, // enabled by default
                    customPreAuction: function(adUnit, adServerAdSlot) {
		                // get adunit object
		                au=pbjs.adUnits.filter(au => au.code==adUnit.code);
		                if (au.length==0) {
                            consoleDebug("++ gptPreAuction: code not found. Exit.", adUnit, adServerAdSlot);
		                    return;
		                }

                        // use gpid if supplied
		                if (au[0].ort2bImp && au[0].ort2bImp.ext && au[0].ort2bImp.ext.gpid) {
                            consoleDebug("++ gptPreAuction: gpid supplied. Exit.", adUnit, adServerAdSlot);
		                    return au[0].ort2bImp.ext.gpid;
		                }

		                // use pbadslot if supplied
		                if (au[0].ort2bImp && au[0].ort2bImp.ext && au[0].ort2bImp.ext.data && au[0].ort2bImp.ext.data.pbadslot) {
                            consoleDebug("++ gptPreAuction: pbadslot supplied. Exit.", adUnit, adServerAdSlot);
		                    return au[0].ort2bImp.ext.data.pbadslot;
		                }

		                // confirm that GPT is set up
		                if (!(googletag && googletag.apiReady)) {
		                    return;
		                }
		                // find all GPT slots with this name
		                var gptSlots = googletag.pubads().getSlots().filter(function(gpt) {
		                    return gpt.getAdUnitPath() == adServerAdSlot;
		                });
		                if (gptSlots.length==0) {
                            consoleDebug("++ gptPreAuction: gpt slot not found.", adUnit, adServerAdSlot);
                            if(adUnit.code == 'mf320x50') {
                                var foundSlot = '/1005951/mf320x50_US';
                                consoleDebug("++ gptPreAuction: searching for gpt slot.", adUnit, foundSlot);
                                return foundSlot;
                            }
		                    return;  // should never happen
		                }
		                if (gptSlots.length==1) {
                            consoleDebug("++ gptPreAuction: one gpt slot found.", adUnit, adServerAdSlot);
		                    return adServerAdSlot;
		                }
		                // else the adunit code must be div id. append it.
                        consoleDebug("++ gptPreAuction: more than one gpt slot found.", adUnit, adServerAdSlot, adServerAdSlot+"#"+adUnit.code);
		                return adServerAdSlot+"#"+adUnit.code;
	                }
                }
            }
            pbjs.setConfig(prebidPreauctionConfig);

            //opt-in to the inclusion of TIDs in the bid stream.
            pbjs.setConfig({enableTIDs: true});
    

            pbjs.enableAnalytics([{
                provider: 'generic',
                options: {
                    sampling: 1,
                    handler(data) {
                        // `data` is an array of length `batchSize`. If `events` is provided, the elements are the values returned
                        // by the format functions defined therein; otherwise, they have the format {eventType, args}.
                        var _category = 'Prebid.js Bids';
                        data.forEach((event) => {
                            var bid = event.args;
                            if (bid && bid.bidderCode)
                            {
                                switch(event.eventType)
                                {
                                    case "bidRequested":
                                        //console.log("### bidRequested sent");
                                        gtag('event', 'Requests', { event_category: _category, event_label: bid.bidderCode, value: 1, non_interaction: true });
                                        break;
                                    case "bidResponse":
                                        //console.log("### bidResponse sent");
                                        var cpmCents = convertToCents(bid.cpm)
                                        if (bid.cpm > 0) {
                                            gtag('event', 'Bids', { event_category: _category, event_label: bid.bidderCode, value: cpmCents, non_interaction: true });
                                            gtag('event', 'Bid Load Time', { event_category: _category, event_label: bid.bidderCode, value: bid.timeToRespond, non_interaction: true });
                                        }
                                        break;
                                    case "bidTimeout":
                                        //console.log("### bidTimeout sent");
                                        gtag('event', 'Timeouts', { event_category: _category, event_label: bid.bidderCode, value: bid.timeToRespond, non_interaction: true });
                                        break;
                                    case "bidWon":
                                        //console.log("### bidWon sent");
                                        var cpmCents = convertToCents(bid.cpm);
                                        gtag('event', 'Wins', { event_category: _category, event_label: bid.bidderCode, value: cpmCents, non_interaction: true });
                                        break;
                                }
                            }
                            //console.log("## event", event);
                        });
                    }
                }
            }]);
            function convertToCents(dollars) {
                if (dollars) {
                    return Math.floor(dollars * 100);
                }
                
                return 0;
            }
            pbjs.bidderSettings = {
                standard: {
                    storageAllowed: true
                },
                oftmedia: {
                    bidCpmAdjustment : function(bidCpm, bid){
                        // adjust the bid in real time before the auction takes place
                        // console.log('Bidder is: ' + bid.bidderCode);
                        return bidCpm * .95;
                    }
                }
            };
            pbjs.setBidderConfig({
                bidders: ['oftmedia'],  
                config: {
                    schain: {
                        validation: "relaxed",
                        config: {
                            ver:"1.0",
                            complete: 1,
                            nodes: [
                                {
                                    "asi":"152media.info",
                                    "sid":"152M32",
                                    "hp":1
                                }
                            ]
                        }
                    }
                }
            });

            /* Log when Prebid wins the ad server auction since it does not happen by the analytics adapter */
            pbjs.onEvent('bidWon', function(bid) {
                var cpmCents = convertToCents(bid.cpm);
                gtag('event', 'Wins', { event_category: 'Prebid.js Bids', event_label: bid.bidderCode, value: cpmCents, non_interaction: true });
                
            });
        });
    

        consoleDebug(">> Prebid activated.")
        //This function will start the auction
        function startAuction(){
            consoleDebug('*** start the auction from Prebid');
            pbjs.que.push(function() {
                    pbjs.requestBids({
                        bidsBackHandler: function() {
                            //Bidders has responded
                            if (!pbjs.initAdserverSet) pbjs.bidderBack = true;
                            initAdserver();
                        },
                        timeout: PREBID_TIMEOUT
                    });

                    // in case PBJS doesn't load
                    setTimeout(function() {
                        if(!pbjs.initAdserverSet){
                            consoleDebug('>> Ads Failsafe timeout');
                        }
                        initAdserver();
                        if(!googletag.pubadsReady)
                        {
                            //All the ads failed to render
                            consoleDebug('>> All Ads failed. Probably because of an ad blocker.');
                            sendGAEvent('AdRendering', 'GPTNotReady', 'GPTNotReady', 
                                googletag.nAdsShown, function() {
                                    consoleDebug(">> AdRendering: Failed (GPTNotReady) -> GA");
                                });
                        }
                    }, FAILSAFE_TIMEOUT);
            });
        }

        function initAdserver() {
            if (pbjs.initAdserverSet) return;

            googletag.cmd.push(function() {
                pbjs.que.push(function() {
                    pbjs.setTargetingForGPTAsync();
                    consoleDebug('*** Refreshing ads from Prebid');
                    googletag.pubads().refresh();

                    //Polling for ads rendering
                    poll(function() {
                        //consoleDebug('>> nAdsShown:', googletag.nAdsShown, 'nAdsRequested:', googletag.nAdsRequested);
                        return (googletag.nAdsRequested > 0 && googletag.nAdsShown == googletag.nAdsRequested);
                    }, SlotRenderingTimeout, 150).then(function() {
                        // Polling done.
                        //Check slot rendering status
                        areSlotsRendered();
                    }).catch(function() {
                        // Polling timed out. We need to send to GA
                        //Check slot rendering status
                        areSlotsRendered();
                    });
                });
            });

            pbjs.initAdserverSet = true;
        }

        //This function checks if any slots were requested and send a report to GA
        function areSlotsRequested(){
            if(googletag.nAdsRequested > 0){
                //Reports about slots requests
                sendGAEvent('WR_Header_Bidding', 'Slots-Requested', 'SReq-Yes', googletag.nAdsRequested, function() {
                    consoleDebug(":> Slots-Requested: SReq-Yes -> GA");
                });
            } else {
                consoleDebug('>> No slots were requested.');
                sendGAEvent('WR_Header_Bidding', 'Slots-Requested', 'SReq-No', googletag.nAdsRequested, function() {
                    consoleDebug(":> Slots-Requested: SReq-No -> GA");
                });
            }
        }

        //This function will check if slots were rendered and send a report to GA
        function areSlotsRendered(){
            if(googletag.nAdsRequested > 0){
                if(googletag.nAdsShown >= googletag.nAdsRequested){
                    consoleDebug('>> All the Ads were shown.');
                } else if(googletag.nAdsShown == 0) {
                    //All the ads failed to render
                    consoleDebug('>> All Ads failed.');
                    sendGAEvent('AdRendering', 'AdTotalFailure', 'Failed', 
                        googletag.nAdsShown, function() {
                            consoleDebug(">> AdRendering: Failed -> GA");
                        });
                } else {
                    //Some ads failed to render
                    consoleDebug('>> Some Ads failed ' + googletag.nAdsShown + '/' + googletag.nAdsRequested + '.');
                    sendGAEvent('AdRendering', 'AdPartialFailure', googletag.nAdsShown + '/' + googletag.nAdsRequested, 
                        googletag.nAdsShown, function() {
                            consoleDebug(">> AdRendering: PartialFailure " + googletag.nAdsShown + '/' + googletag.nAdsRequested + " -> GA");
                        });
                }
            }
        }

        //This function will sent a GA event if prebid did not get a response soon enough before displaying the ads
        function isPrebidBackInTime(){
            if(googletag.nAdsRequested == 0)        //No ads were requested
                return;

            if(!pbjs.bidderBack){
                consoleDebug('>> Prebid response was too slow');
                sendGAEvent('WR_Header_Bidding', 'Prebid-Response', 'PR-Failure', '0', function() {
                    consoleDebug(":> Prebid-Response: PR-Failure -> GA");
                });
            } else {
                consoleDebug('>> Prebid responded in time.');
                sendGAEvent('WR_Header_Bidding', 'Prebid-Response', 'PR-Success', '1', function() {
                    consoleDebug(":> Prebid-Response: PR-Success -> GA");
                });
            }
        }

        //This function will send the status of DFP to GA
        function isDFPReady(){
            if(googletag.pubadsReady){
                consoleDebug('>> DFP success');
                sendGAEvent('WR_Header_Bidding', 'DFP-loading', 'DFP-Success', '1', function() {
                    consoleDebug(":> DFP-loading: DFP-Success -> GA");
                });
            } else {
                consoleDebug('>> DFP failed to load');
                sendGAEvent('WR_Header_Bidding', 'DFP-loading', 'DFP-Failure', '0', function() {
                    consoleDebug(":> DFP-loading: DFP-Failure -> GA");
                });
            }
        }
    
        



    console.log(">> WR custom code inserted.")



