
(function () {
    var revDiv = document.querySelector('script[id="rc_196"]').parentNode;
    var usPrivacy, ccpaDone = false;
    var gdpr, gdprConsent, gdprDone = false;
    var gpp, gppSid, gppDone = false;


        //IAB's CCPA function
        if (typeof __uspapi === 'function') {
            __uspapi('getUSPData', 1, function(uspData, success) {
                if(success) {
                    usPrivacy = uspData.uspString;
                }
                ccpaDone = true;
            });
        } else {
            ccpaDone = true;
        }


        //IAB's GDPR function
        var gdpr, gdprConsent, gdprDone = false;
        if (typeof __tcfapi === 'function') {
            __tcfapi('getTCData', 2, function(tcData, success) {
                if (success) {
                    gdpr = tcData.gdprApplies === true ? 1 : 0;
                    gdprConsent = tcData.tcString;
                }
                gdprDone = true;
            }, [203,164,185,277,32,128,344,52,165,14,81,341,599,76,58,333,45,82,109,849,259,10,910,1514,]);
        } else if (typeof __cmp === 'function') {
            __cmp('getConsentData', null, function(vendorConsentData, success) {
                if (success) {
                    gdpr = vendorConsentData.gdprApplies === true  ? 1 : 0;
                    gdprConsent = vendorConsentData.consentData;
                }
                gdprDone = true;
            });
        } else {
            gdprDone = true;
        }


        //IAB's GPP function
        if (typeof __gpp === 'function') {
			var data = __gpp('getGPPData');
            if (data != null && data.applicableSections !== -1 && data.gppString != null && data.gppString.length > 0) {
				if (Array.isArray(data.applicableSections)) {
					gpp = data.gppString;
                    gppSid = data.applicableSections.join(',');
				} else {
					gpp = data.gppString;
                    gppSid = data.applicableSections; 
				}
			}
            gppDone = true;
        } else {
            gppDone = true;
        }

    var appendRcel = function(url) {
        var rcel = document.createElement("script");
        rcel.id = 'rc_' + Math.floor(Math.random() * 1000);
        rcel.type = 'text/javascript';
        rcel.src = url;
        rcel.async = true;
        revDiv.appendChild(rcel);
    }

    var callRev_rc_196 = function() {
        var url = '//trends.revcontent.com/serve.js.php?c=1620646331541&k=COVID-19%2CFox+News+Channel%2CRon+Johnson%2CSunday+Morning+Futures%2Cvaccines&t=rc_196&w=86249&width=1600';
        if(gdpr != null) url += '&gdpr=' + gdpr;
        if(gdprConsent != null) url += '&gdpr_consent=' + gdprConsent;
        if(usPrivacy != null) url += '&us_privacy=' + usPrivacy;
		if(gpp != null && gpp != '') url += '&gpp=' + gpp;
		if(gppSid != null && gppSid != '') url += '&gpp_sid=' + gppSid;

        var siteUrl = '';
        if (window && window.location) {
            siteUrl = window.location.href;
        }
        url += '&site_url=' + encodeURIComponent(siteUrl.substr(0,700));
        url += '&referer=' + encodeURIComponent(document.referrer.substr(0,700));
        url += '&skip_iab=true';

        // fetch dsp user id from local storage
        var list = ['3', '115', '118', '112', '149', '109', '2', '150', '136', '151', '153', '154', '155', '156', '157', '158', '159', '160', '161', '163', '166', '167', '169', '171', '176', '178', '179', '180', '181', '186', '187', '188', '190', ];
        for (let i = 0; i < list.length; i++) {
            try {
                var duid = localStorage.getItem('d'+list[i]);
                if (duid) {
                    url += '&duid=' + duid;
                }
            } catch(e) {}
        }

        // localStorage can be missing
        try {
            var rtus_id = localStorage.getItem('rev_criteo_rtus_id');
            if (rtus_id) {
                url += '&criteo_rtus=' + rtus_id;
            }
        } catch(e) {}

        try {
            var rcxhr = new XMLHttpRequest();
            rcxhr.onreadystatechange = function() {
                if (rcxhr.readyState == 4) {
                    var rcel = document.createElement("script");
                    rcel.type = 'text/javascript';
                    rcel.text = rcxhr.responseText;
                    rcel.async = true;
                    revDiv.appendChild(rcel);
                }
            }
            rcxhr.open("POST", url, true);
            rcxhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			
            rcxhr.send();

            rcxhr.onerror = function() {
                appendRcel(url);
            }
        } catch(e) {
            appendRcel(url);
        }
    };

        //50ms interval check if IAB CCPA/GDPR finished
        var gdprCcpaIntervalCheck = setInterval(function() {
            if(ccpaDone && gdprDone) {
                clearTimeout(gdprCcpaTimeoutCheck);
                clearInterval(gdprCcpaIntervalCheck);
                callRev_rc_196();
            }
        }, 30);

        //200ms timeout for IAB CCPA/GDPR functions to finish
        var gdprCcpaTimeoutCheck = setTimeout(function() {
            clearInterval(gdprCcpaIntervalCheck);
            callRev_rc_196();
        }, 200);

})();
