(function() {
    var name = '';
    var inventory = "S:PD9IH5KxoChW9HVNjcrawy0rBwch-ThfwhmRfN_fKIW6yk2XA97XpoLsLyEVxJlJ6VLB7e1y_yoZZetWMC2cqHsQrNQQ53BhdlMqqCYNXrJgqk3K22KMOtey0BnepBPRMWjjBwmlNgjxiXDh1hfBatag1ATvScNOHeZk";
    var logSampleRatePercent = -1;
    var logSampling = Math.random() * 100 <= logSampleRatePercent;
    var isIE = (function() {
        var ver = navigator.userAgent.match(/MSIE ([0-9]{1,}[\\.0-9]{0,})|Trident\/.*rv:([0-9]{1,}[\\.0-9]{0,})/);
        if (!ver) {
            return false;
        }
        ver.shift();
        return ver.filter(function(str) { return str != undefined; }).pop();
    });
    var logEvent = function (event) {
        if (!logSampling) {
            logger('log sampling disabled, event: ' + event);
            return;
        }
        var eventURL = new URL("https:\/\/ads.counciladvertising.net\/event\/log");
        eventURL.searchParams.set('inventory', inventory);
        eventURL.searchParams.set('event', event);
        var xhr = new XMLHttpRequest();
        xhr.open('GET', eventURL.toString());
        logger('sending audit event: ' + event);
        xhr.send();
    };
    var logger = function () {
        if (window.localStorage && window.localStorage.getItem('can_debug') == 'true') {
            if (window._canStore && !window._canStore.debugLogsPrinted) {
                window._canStore.debugLogsPrinted = true;

                if (isIE()) {
                    console.debug(
                        "[CAN] If you can see this, CAN debug logs are turned ON"
                    );
                } else {
                    console.debug(
                        "%c[CAN] %cIf you can see this, CAN debug logs are turned ON",
                        "font-size: 3em; color: #267cae; font-weight: bolder; font",
                        "font-size: 3em; color: #f47401; font-weight: bold"
                    );
                }
            }
            for (var msgKey in arguments) {
                var msg = arguments[msgKey];
                console.debug("[can] [" + name + "]: "+msg);
            }
        }
    };
    logEvent('script_load');
    (function () {
    var gdpr_stub = function (quantcastAccountId) {
    if (window.__cmp || window.__tcfapi) {
        return;
    }

    (function() {
        var host = window.location.hostname;
        var element = document.createElement('script');
        var firstScript = document.getElementsByTagName('script')[0];
        var milliseconds = new Date().getTime();
        var url = 'https://quantcast.mgr.consensu.org'
            .concat('/choice/', quantcastAccountId, '/', host, '/choice.js')
            .concat('?timestamp=', milliseconds);
        var uspTries = 0;
        var uspTriesLimit = 3;
        element.async = true;
        element.type = 'text/javascript';
        element.src = url;

        firstScript.parentNode.insertBefore(element, firstScript);

        function makeStub() {
            var TCF_LOCATOR_NAME = '__tcfapiLocator';
            var queue = [];
            var win = window;
            var cmpFrame;

            function addFrame() {
                var doc = win.document;
                var otherCMP = !!(win.frames[TCF_LOCATOR_NAME]);

                if (!otherCMP) {
                    if (doc.body) {
                        var iframe = doc.createElement('iframe');

                        iframe.style.cssText = 'display:none';
                        iframe.name = TCF_LOCATOR_NAME;
                        doc.body.appendChild(iframe);
                    } else {
                        setTimeout(addFrame, 5);
                    }
                }
                return !otherCMP;
            }

            function tcfAPIHandler() {
                var gdprApplies;
                var args = arguments;

                if (!args.length) {
                    return queue;
                } else if (args[0] === 'setGdprApplies') {
                    if (
                        args.length > 3 &&
                        args[2] === 2 &&
                        typeof args[3] === 'boolean'
                    ) {
                        gdprApplies = args[3];
                        if (typeof args[2] === 'function') {
                            args[2]('set', true);
                        }
                    }
                } else if (args[0] === 'ping') {
                    var retr = {
                        gdprApplies: gdprApplies,
                        cmpLoaded: false,
                        cmpStatus: 'stub'
                    };

                    if (typeof args[2] === 'function') {
                        args[2](retr);
                    }
                } else {
                    queue.push(args);
                }
            }

            function postMessageEventHandler(event) {
                var msgIsString = typeof event.data === 'string';
                var json = {};

                try {
                    if (msgIsString) {
                        json = JSON.parse(event.data);
                    } else {
                        json = event.data;
                    }
                } catch (ignore) {}

                var payload = json.__tcfapiCall;

                if (payload) {
                    window.__tcfapi(
                        payload.command,
                        payload.version,
                        function(retValue, success) {
                            var returnMsg = {
                                __tcfapiReturn: {
                                    returnValue: retValue,
                                    success: success,
                                    callId: payload.callId
                                }
                            };
                            if (msgIsString) {
                                returnMsg = JSON.stringify(returnMsg);
                            }
                            event.source.postMessage(returnMsg, '*');
                        },
                        payload.parameter
                    );
                }
            }

            while (win) {
                try {
                    if (win.frames[TCF_LOCATOR_NAME]) {
                        cmpFrame = win;
                        break;
                    }
                } catch (ignore) {}

                if (win === window.top) {
                    break;
                }
                win = win.parent;
            }
            if (!cmpFrame) {
                addFrame();
                win.__tcfapi = tcfAPIHandler;
                win.addEventListener('message', postMessageEventHandler, false);
            }
        };

        // edited the original quantcast wrapper
        // remove the module.exports check and use
        // as we have our own below
        makeStub();

        var uspStubFunction = function() {
            var arg = arguments;
            if (typeof window.__uspapi !== uspStubFunction) {
                setTimeout(function() {
                    if (typeof window.__uspapi !== 'undefined') {
                        window.__uspapi.apply(window.__uspapi, arg);
                    }
                }, 500);
            }
        };

        var checkIfUspIsReady = function() {
            uspTries++;
            if (window.__uspapi === uspStubFunction && uspTries < uspTriesLimit) {
                console.warn('USP is not accessible');
            } else {
                clearInterval(uspInterval);
            }
        };

        if (typeof window.__uspapi === 'undefined') {
            window.__uspapi = uspStubFunction;
            var uspInterval = setInterval(checkIfUspIsReady, 6000);
        }
    })();
};

if (typeof module !== "undefined") {
    module.exports = gdpr_stub;
}

    gdpr_stub("mjq2rgU4Jj7VF");
    var css = "";
    var style = document.createElement("style");
    document.head.appendChild(style);
    style.type = 'text/css';
    style.appendChild(document.createTextNode(css));
})();

(function(currentScript) {
    if (!window._canStore) {
        window._canStore = {};
    }
    name = "div-gpt-ad-tamesidec-ibar";
    var isRTBEnabled = false;
    var consentDecisionMade = false;
    var consentManagement = true;

    if (consentManagement) {
        logger('waiting for IAB CMP to provide consent info');
        var locatorFrame = null;

        var checkConsent = function (tcData, success) {
                        if (!success || consentDecisionMade) {
                return;
            }

            var shouldCheckConsent = tcData.gdprApplies !== false;

            var requiredPurposes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
            var purposesWithoutConsent = requiredPurposes
                .filter(function (key) {
                    return tcData.purpose.consents[key] !== true
                        && tcData.purpose.legitimateInterests[key] !== true;
                });

            var vendorsWithConsent = Object
                .keys(tcData.vendor.consents)
                .map(function (key) { return parseInt(key); })
                .filter(function (key) {
                    return tcData.vendor.consents[key] === true;
                });

            var consentGranted = !shouldCheckConsent ||
                (
                    vendorsWithConsent.length > 0
                    && purposesWithoutConsent.length === 0
                    && tcData.isServiceSpecific
                );

            if (consentGranted) {
                consentDecisionMade = true;
                logEvent('consent_granted');
                logger('consent granted; continuing');
                if (locatorFrame) {
                    locatorFrame.postMessage(
                        {
                            __tcfapiCall: {
                                command: 'removeEventListener',
                                version: 2,
                                callId: Math.random()+'',
                                parameter: tcData.listenerId
                            }
                        },
                        '*'
                    );
                    window.removeEventListener('message', readPostMessage);
                } else {
                    window.__tcfapi('removeEventListener', 2, function () {}, tcData.listenerId);
                }
                beginInit();
            } else {
                logEvent('consent_denied');
                logger('consent not granted; exiting');
                window._canStore.consent = {
                    vendorsWithConsent: vendorsWithConsent,
                    purposesWithoutConsent: purposesWithoutConsent,
                };
            }
        }

        var getTCFLocatorFrame = function() {
            let frame = window;
            let cmpFrame = null;

            while(frame) {
                try {
                    if (frame.frames['__tcfapiLocator']) {
                        cmpFrame = frame;
                        break;
                    }
                } catch(ignore) {}

                if (frame === window.top) {
                    break;
                }
                frame = frame.parent;
            }

            return cmpFrame;
        }

        var readPostMessage = function (event) {
            var payload = event.data;
            try {
                if (typeof payload === 'string') {
                    payload = JSON.parse(payload);
                }
            } catch (ignore) { }
            if (!payload || !payload.__tcfapiReturn) {
                return;
            }

            checkConsent(payload.__tcfapiReturn.returnValue, payload.__tcfapiReturn.success);
        };

        var checkForCMP = function (delay) {
            if (window.__tcfapi) {
                logger('found TCF API via current window');
                window.__tcfapi('addEventListener', 2, checkConsent);
                return;
            }
            var cmpFrame = getTCFLocatorFrame();
            if (cmpFrame) {
                locatorFrame = cmpFrame;
                logger('found TCF API via locator frame');
                window.addEventListener(
                    'message',
                    readPostMessage,
                    false
                );
                cmpFrame.postMessage(
                    {
                        __tcfapiCall: {
                            command: 'addEventListener',
                            version: 2,
                            callId: Math.random()+'',
                        }
                    },
                    '*'
                );
                return;
            }

            var nextDelay = delay + 100;
            setTimeout(checkForCMP, nextDelay, nextDelay);
            return;
        };
        setTimeout(checkForCMP, 0, 0);
    } else {
        setTimeout(function () { beginInit() }, 0);
    }

    var validateRTBResponse = function (xhr) {
        if (xhr.status != 200) {
            logger('RTB is disabled: a failure occurred resolving the RTB check for ' + window.location.href, xhr.status, xhr.statusText, xhr.responseText);
            return false;
        }
        var responseJson;
        try {
            responseJson = JSON.parse(xhr.responseText);
        } catch (err) {
            logger('RTB is disabled: a failure occurred parsing the RTB response', err);
            return false;
        }

        if (responseJson.blocked) {
            logger('RTB is disabled: endpoint blocked');
            return false;
        }

        logger('RTB is enabled');
        return true;
    };

    var beginInit = function () {
        logger('checking RTB state');

        var windowURL = window.location.hostname + window.location.pathname;
        var xhr = new XMLHttpRequest();
        xhr.open('GET', "https:\/\/ads.counciladvertising.net\/tag\/rtb\/check" + "?url=" + encodeURIComponent(windowURL));
        xhr.setRequestHeader('Accept', 'application/json');

        xhr.onload = function() {
            isRTBEnabled = validateRTBResponse(xhr);
            start();
        };
        xhr.onerror = function() {
            logger('a failure occurred resolving the RTB check for ' + window.location.href);
            start();
        };

        xhr.send();
    };
    var start = function() {
        var blacklist = ["@","%2540","%40","user=","email=","emailaddress=","password=","pw=","un=","username="];

var shouldAbortDueToPII = function () {
    var url = (window.location.search || window.location.href).toLowerCase();
    for (var i = 0; i < blacklist.length; i++) {
        var word = blacklist[i];
        if (url.indexOf(word) !== -1 || decodeURIComponent(url).indexOf(word) !== -1) {
            logger("aborted load after finding "+word);
            return true;
        };
    };

    return false;
}

if (shouldAbortDueToPII()) {
    return;
}

var gdpr = null;
var addScript = function(url) {
    var script = document.createElement("script");

    script.type = "text/javascript";
    script.src = url;

    var head = document.body || document.getElementsByTagName('body')[0];
    head.appendChild(script);
    return script;
};
var gpt_slot = null;

var load = function () {
    var div = document.createElement('div');
    div.id = "div-gpt-ad-tamesidec-ibar";
    document.body.appendChild(div);

    if (!window.googletag) {
        addScript('https://www.googletagservices.com/tag/js/gpt.js');
    }
    window.googletag = window.googletag || {};
    window.googletag.cmd = window.googletag.cmd || [];

    window.googletag.cmd.push(function () {
        gpt_slot = window.googletag.defineOutOfPageSlot('/31781941/can_tamesidec', "div-gpt-ad-tamesidec-ibar").setTargeting('category', ["disabled","automotive","motab","parents","sme"]).addService(window.googletag.pubads());
        window.googletag.pubads().enableAsyncRendering();
        window.googletag.pubads().enableSingleRequest();
        window.googletag.pubads().disableInitialLoad();
        window.googletag.enableServices();
    });

    window.googletag.cmd.push(function () {
        window.googletag.display("div-gpt-ad-tamesidec-ibar");
        window.googletag.pubads().refresh([gpt_slot]);
    });
};

if (gdpr == null) {
    load();
} else {
    window._canStore = window._canStore || {};
    if (!window._canStore['gdpr']) {
        addScript(gdpr);
        window._canStore['gdpr'] = true;
    };
    window.addEventListener('canGdprConsent', function (e) {
        if (e.consent) {
            load();
        }
    });
}
    };
})(document.currentScript);
})();
