var DfpSlotManagerMixin = DfpSlotManagerMixin || (function() { var DfpSlotManager = function() { this.dfpSlots = {}; this.initialize = function() { $(document).on('dfpSlotManager::updateSlot', function(e, data) { this.updateSlot(data); }.bind(this)); $(document).on('adsRefresher::beforeDfpRefresh', function() { this.beforeSlotRefresh(); }.bind(this)); }; this.getSlots = function() { return this.dfpSlots; }.bind(this); this.updateSlot = function(payload) { payload = typeof payload === 'object' ? payload : {}; if (!this.dfpSlots[payload.id]) { this.dfpSlots[payload.id] = payload; } else if (!$('#' + payload.id).hasClass('permanent_hide')) { $.extend(this.dfpSlots[payload.id], payload); } }.bind(this); this.handleSlotStacking = function(slot) { var direction = slot.refreshWhenNodeHasContent; var refreshable = true; if (!direction || direction === 'None') { return refreshable; } var slotNode = $('#' + slot.id)[0]; var $slotParent = $(slotNode.parentElement); var nodesToCheck = []; var $firstNodeToCheck = {}; var $secondNodeToCheck = {}; if (direction === 'Next') { $firstNodeToCheck = $slotParent.next(); $secondNodeToCheck = $firstNodeToCheck.next(); } else { $firstNodeToCheck = $slotParent.prev(); $secondNodeToCheck = $firstNodeToCheck.prev(); } nodesToCheck.push($firstNodeToCheck); nodesToCheck.push($secondNodeToCheck); var allChildrenEmpty = true; var nodesOk = false; nodesToCheck.forEach(function($nodeToCheck) { $nodeToCheck.children().each(function() { if ($(this).children().length || !!$.trim($(this).html())) { allChildrenEmpty = false; } return allChildrenEmpty; }); var isDfpSlot = $nodeToCheck.hasClass('ads_dfpslot') || $nodeToCheck.hasClass('v2_ads_dfpslot'); var nodeHasChildren = !!$nodeToCheck.children().length; var nodeHasText = $.trim($nodeToCheck.text()) !== ''; var nodeHasMarkup = $.trim($nodeToCheck.html()) !== ''; if (!isDfpSlot && ((!allChildrenEmpty && nodeHasText) || nodeHasChildren || nodeHasMarkup)) { nodesOk = true; } return nodesOk; }); if (!nodesOk) { slot.refresh = false; $('#' + slot.id).hide(); $('#' + slot.id).addClass('permanent_hide'); // Don't apply ad stacking logic if slot explicitly set { hidden: true }, // if hidden === true, slot is unaffiliated with ad stacking } else if (!slot.hidden) { slot.refresh = true; $('#' + slot.id).show(); } refreshable = slot.refresh; return refreshable; }; this.beforeSlotRefresh = function() { for (var key in this.dfpSlots) { this.handleSlotStacking(this.dfpSlots[key]); } }.bind(this); }; var dfpSlotManager = new DfpSlotManager(); dfpSlotManager.initialize(); var exposedManagerMethods = { getSlots: dfpSlotManager.getSlots, updateSlot: dfpSlotManager.updateSlot, beforeSlotRefresh: dfpSlotManager.beforeSlotRefresh }; return exposedManagerMethods; })(); var PageDepthManager = PageDepthManager || (function() { var pageDepth = 0; var prevHref; var attributes = { pageDepthVariableName: 'guteref' }; function initialize(options) { $.extend(attributes, options); function sameDomain() { return document.domain === sessionStorage.prevDomain; }; function uniqueReferal() { var uniq = document.referrer !== sessionStorage.prevReferrer; return !!document.referrer && uniq; }; if (sameDomain() && uniqueReferal()) { pageDepth = Number(sessionStorage.pageDepth); } sessionStorage.prevDomain = document.domain || ''; sessionStorage.prevReferrer = document.referrer || ''; initialize = function() { return this; } return this; } function emitDepth() { try { googletag.cmd.push(function() { googletag.pubads().setTargeting(attributes.pageDepthVariableName, String(pageDepth)); }); } catch(e) { // window.googletag || googletag.cmd undefined } return this; }; function incrementDepth() { var pageChange = prevHref !== location.href; if (pageChange) { pageDepth += 1; sessionStorage.pageDepth = pageDepth; } prevHref = location.href; return this; }; function getDepth() { return pageDepth; }; return { initialize: initialize, emitDepth: emitDepth, incrementDepth: incrementDepth, getDepth: getDepth }; })(); var AppContentData = AppContentData || (function() { var moduleName = 'js_app_contentdata-0'; var ContentDataController = function() { var pageData = __page_data__ || {}; var data = pageData[moduleName]; var actionHandlers = function() { return { 'contentData::getCategories': this.getCategories, 'contentData::getTitle': this.getTitle }; }.bind(this); var bindActionHandlers = function() { actionHandlers = actionHandlers(); var keys = Object.keys(actionHandlers); for (var i = 0; i < keys.length; i++) { var action = keys[i]; var handler = actionHandlers[keys[i]]; $(document).on(action, handler); } }; this.initialize = function() { bindActionHandlers(); }; this.getCategories = function(event, payload) { payload = payload || {}; if (!data.categories) { return undefined; } var categories = { category: data.categories.category, subcategory: data.categories.subcategory }; if (!!payload.done) { payload.done.call(payload.done, categories); } return categories; }.bind(this); this.getTitle = function(event, payload) { payload = payload || {}; if (!data.title) { return undefined; } if (!!payload.done) { payload.done.call(payload.done, data.title); } return data.title; }.bind(this); }; var controller = new ContentDataController() controller.initialize() return { getCategories: function(payload) { return controller.getCategories(null, payload); }, getTitle: function(payload) { return controller.getTitle(null, payload); } }; })(); /* global initAdserver googletagData */ var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; var PrebidManager = PrebidManager || (function() { var adUnits = []; var slotNum = 0; var indexID = 0; // Used for indexExchange until they fix their bidder function initialize(timeout) { pbjs.isEnabled = true; pbjs.timeout = timeout; // Next block is used to load the Prebid.js CDN whenever we don't use a prebuilt one. // Keep for now until we work out kinks // (function() { // var pbjsEl = document.createElement('script'); // pbjsEl.type = 'text/javascript'; // pbjsEl.async = true; // pbjsEl.src = '//acdn.adnxs.com/prebid/static/0.6.0/prebid.js'; // var pbjsTargetEl = document.getElementsByTagName('head')[0]; // pbjsTargetEl.insertBefore(pbjsEl, pbjsTargetEl.firstChild); // })(); // add sovrn beacon if (googletagData.sovrn_bidder) { (function() { var sovrnBeacon = document.createElement('script'); sovrnBeacon.type = 'text/javascript'; sovrnBeacon.id = 'sBeacon'; sovrnBeacon.src = '//ap.lijit.com/www/sovrn_beacon_standalone/sovrn_standalone_beacon.js?iid=12106015&uid=answers'; var sovrnBeaconTargetEl = document.getElementsByTagName('head')[0]; sovrnBeaconTargetEl.insertBefore(sovrnBeacon, sovrnBeaconTargetEl.firstChild); })(); } pbjs.que.push(function() { // 1-cent increments up to $20 pbjs.setPriceGranularity('high'); }); return this; } function registerSlot(slot, sizes) { var slotConfig = { code: slot.container_id, sizes: sizes, bids: buildBidderParams(slot) }; adUnits.push(slotConfig); return this; } function buildBidderParams(slot) { var params = []; var explodedTag = slot.ad_unit.split('/'); var adUnit = explodedTag[explodedTag.length - 1]; var sizeRegEx = /[0-9]{2,3}x[0-9]{2,3}_.*/; var placement = (sizeRegEx.test(adUnit)) ? sizeRegEx.exec(adUnit)[0] : '300x250_' + ++slotNum; if (googletagData.sovrn_bidder && slot.enable_sovrn_bidding !== 'off') { var sovrnParams = generateSovrnParams(placement); params.push(sovrnParams); } if (googletagData.new_aol_bidder && slot.enable_aol_bidding !== 'off') { var AOLParams = generateAOLParams(placement, adUnit); params.push(AOLParams); } if (googletagData.new_indexexchange_bidder && slot.enable_indexexchange_bidding !== 'off') { var indexParams = generateIndexParams(placement); params.push(indexParams); } if (googletagData.appnexus_bidder && slot.enable_appnexus_bidding !== 'off') { var appNexusParams = generateAppNexusParams(placement); params.push(appNexusParams); } if (googletagData.districtm_bidder && slot.enable_districtm_bidding !== 'off') { var districtMParams = generateDistrictMParams(placement); params.push(districtMParams); } return params; } function generateSovrnParams(placement) { // Ugly mapping ahead var map = { ANSWG_160x600_1_header: 349915, ANSWG_300x250_1_header: 349891, ANSWG_300x250_2_header: 349897, ANSWG_300x250_3_header: 349903, ANSWG_300x250_4_header: 349909, ANSWG_728x90_1_header: 349852, ANSWG_728x90_2_header: 349861, ANSWG_728x90_3_header: 349867, ANSWG_728x90_4_header: 349873, ANSWG_728x90_5_header: 349879, AT_160x600_1_header: 349918, AT_300x250_1_header: 349894, AT_300x250_2_header: 349900, AT_300x250_3_header: 349906, AT_300x250_4_header: 349912, AT_728x90_1_header: 349858, AT_728x90_2_header: 349864, AT_728x90_3_header: 349870, AT_728x90_4_header: 349876, AT_728x90_5_header: 349884, BRO_160x600_1_header: 349919, BRO_300x250_1_header: 349895, BRO_300x250_2_header: 349901, BRO_300x250_3_header: 349907, BRO_300x250_4_header: 349913, BRO_728x90_1_header: 349859, BRO_728x90_2_header: 349865, BRO_728x90_3_header: 349871, BRO_728x90_4_header: 349877, BRO_728x90_5_header: 349886, CS_160x600_1_header: 349920, CS_300x250_1_header: 349896, CS_300x250_2_header: 349902, CS_300x250_3_header: 349908, CS_300x250_4_header: 349914, CS_728x90_1_header: 349860, CS_728x90_2_header: 349866, CS_728x90_3_header: 349872, CS_728x90_4_header: 349878, CS_728x90_5_header: 349890, MH_160x600_1_header: 349917, MH_300x250_1_header: 349893, MH_300x250_2_header: 349899, MH_300x250_3_header: 349905, MH_300x250_4_header: 349911, MH_728x90_1_header: 349857, MH_728x90_2_header: 349863, MH_728x90_3_header: 349869, MH_728x90_4_header: 349875, MH_728x90_5_header: 349881, ROA_160x600_1_header: 349916, ROA_300x250_1_header: 349892, ROA_300x250_2_header: 349898, ROA_300x250_3_header: 349904, ROA_300x250_4_header: 349910, ROA_728x90_1_header: 349856, ROA_728x90_2_header: 349862, ROA_728x90_3_header: 349868, ROA_728x90_4_header: 349874, ROA_728x90_5_header: 349880 }; return { bidder: 'sovrn', params: { tagid: map[googletagData.site_code + '_' + placement + '_header'] } }; } function generateAOLParams(placement, adUnit) { // Note: in Prebid.js documentation 'placement' is needed for AOL // 'placement' and 'alias' map 1:1, so only one or the other is needed per a conversation with AOL var alias = googletagData.site_code + '_' + placement + '_header'; if (adUnit.indexOf('gut_') === 0) { alias += '_mobile'; } return { bidder: 'aol', params: { network: '9424.1', alias: alias } }; } function generateIndexParams(placement) { var map = { ANSWG_160x600_1_header: 172832, ANSWG_300x250_1_header: 172833, ANSWG_300x250_2_header: 172834, ANSWG_300x250_3_header: 172835, ANSWG_300x250_4_header: 172837, ANSWG_728x90_1_header: 175090, ANSWG_728x90_2_header: 172828, ANSWG_728x90_3_header: 172829, ANSWG_728x90_4_header: 172830, ANSWG_728x90_5_header: 172831, BLE_728x90_1_header: 174945, BLE_728x90_2_header: 174946, BLE_728x90_3_header: 174947, BLE_728x90_4_header: 174948, BLE_728x90_5_header: 174949, BLE_300x250_1_header: 174950, BLE_300x250_2_header: 174951, BLE_300x250_3_header: 174952, BLE_300x250_4_header: 174953, BLE_160x600_1_header: 174954, ELS_728x90_1_header: 175039, ELS_728x90_2_header: 175040, ELS_728x90_3_header: 175041, ELS_728x90_4_header: 175042, ELS_728x90_5_header: 175043, ELS_300x250_1_header: 175044, ELS_300x250_2_header: 175045, ELS_300x250_3_header: 175046, ELS_300x250_4_header: 175047, ELS_160x600_1_header: 175048, NEW_728x90_1_header: 175049, NEW_728x90_2_header: 175050, NEW_728x90_3_header: 175051, NEW_728x90_4_header: 175052, NEW_728x90_5_header: 175053, NEW_300x250_1_header: 175054, NEW_300x250_2_header: 175055, NEW_300x250_3_header: 175056, NEW_300x250_4_header: 175057, NEW_160x600_1_header: 175058, PRE_728x90_1_header: 175059, PRE_728x90_2_header: 175060, PRE_728x90_3_header: 175061, PRE_728x90_4_header: 175062, PRE_728x90_5_header: 175063, PRE_300x250_1_header: 175064, PRE_300x250_2_header: 175065, PRE_300x250_3_header: 175066, PRE_300x250_4_header: 175067, PRE_160x600_1_header: 175068, ROA_728x90_1_header: 175069, ROA_728x90_2_header: 175070, ROA_728x90_3_header: 175071, ROA_728x90_4_header: 175072, ROA_728x90_5_header: 175073, ROA_300x250_1_header: 175074, ROA_300x250_2_header: 175075, ROA_300x250_3_header: 175076, ROA_300x250_4_header: 175077, ROA_160x600_1_header: 175078, SPL_728x90_1_header: 175079, SPL_728x90_2_header: 175081, SPL_728x90_3_header: 175082, SPL_728x90_4_header: 175083, SPL_728x90_5_header: 175084, SPL_300x250_1_header: 175085, SPL_300x250_2_header: 175086, SPL_300x250_3_header: 175087, SPL_300x250_4_header: 175088, SPL_160x600_1_header: 175089 }; return { bidder: 'indexExchange', params: { id: ++indexID, siteID: map[googletagData.site_code + '_' + placement + '_header'] } }; } function generateAppNexusParams(placement) { return { bidder: 'appnexus', params: { invCode: googletagData.site_code + '_' + placement + '_header', member: 3768 } }; } function generateDistrictMParams(placement) { return { bidder: 'districtm', params: { placementId: 9342237 } }; } function populateAdUnits() { pbjs.que.push(function() { if (googletagData.districtm_bidder) { pbjs.aliasBidder('appnexus', 'districtm'); } pbjs.addAdUnits(adUnits); pbjs.bidderSettings = { aol: { bidCpmAdjustment: function(bidCpm) { // 90% rev share with AOL return bidCpm * 0.90; } } }; }); return this; } function requestBids() { pbjs.que.push(function() { pbjs.requestBids({ bidsBackHandler: function() { window.initAdServer(); } }); }); return this; } function sendBids() { pbjs.que.push(function() { pbjs.setTargetingForGPTAsync(); }); } function refresh(name) { pbjs.que.push(function() { pbjs.requestBids({ timeout: pbjs.timeout, bidsBackHandler: function() { pbjs.setTargetingForGPTAsync(); $(document).trigger('received_partner_bid-' + name); } }); }); } return { initialize: initialize, registerSlot: registerSlot, lockInAdUnits: populateAdUnits, requestBids: requestBids, setTargeting: sendBids, refresh: refresh }; })(); var googletagData = __page_data__['ads_dfpheader2-0'] || {}; var load_group = []; var interstitial_group = []; var custom_1_group = []; var custom_2_group = []; var custom_3_group = []; var PREBID_TIMEOUT = googletagData.header_bidding_timeout; if (!googletagData.openx_bidder) { var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; } if (googletagData.rubicon_bidder) { var rubicontag = rubicontag || {}; rubicontag.cmd = rubicontag.cmd || []; } if (googletagData.indexexchange_bidder) { window.headertag_ready = window.headertag_ready || false; } if (googletagData.new_aol_bidder || googletagData.new_indexexchange_bidder || googletagData.sovrn_bidder || googletagData.appnexus_bidder || googletagData.districtm_bidder) { PrebidManager.initialize(PREBID_TIMEOUT); } var gptLoaded = false; function initAdServer() { if (!gptLoaded) { (function() { var gads = document.createElement('script'); gads.async = true; gads.type = 'text/javascript'; var useSSL = 'https:' == document.location.protocol; gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js'; var node = document.getElementsByTagName('script')[0]; node.parentNode.insertBefore(gads, node); })(); gptLoaded = true; } } var numExpectedRequests = googletagData.rubicon_bidder + googletagData.indexexchange_bidder; var numReceivedRequests = 0; $(document).on('receivedPrepingBid', function() { numReceivedRequests++; if (numReceivedRequests === numExpectedRequests) { initAdServer(); } }); if (window.headertag_ready) { numReceivedRequests++; } // backup timer to allow for prebidding if (googletagData.rubicon_bidder || (googletagData.indexexchange_bidder && !window.headertag_ready) || pbjs.isEnabled) { setTimeout(initAdServer, PREBID_TIMEOUT); } else { initAdServer(); } var filterObject = function(obj, predicate) { var key; var result = []; for (key in obj) { if (obj.hasOwnProperty(key) && predicate(obj[key])) { result.push(obj[key]); } } return result; }; var dfpheader2 = dfpheader2 || (function() { var isArrayLike = function(variable) { var isObject = typeof variable === 'object'; var hasLength = typeof variable.length === 'number'; return isObject && hasLength; }; var Model = function(model) { // strip unnecessary 'dfp_' prefix from ads/dfpslot configs function normalizeSlotKeys() { var i = 0; while (model.dfpSlots[i]) { var slot = model.dfpSlots[i]; var keys = Object.keys(slot); for (var index = 0; index < keys.length; index++) { var key = keys[index]; if (key.match('dfp_')) { var normalKey = key.replace('dfp_', ''); if (normalKey === 'div_id') { normalKey = 'container_id'; } slot[normalKey] = slot[key]; delete slot[key]; } } model.dfpSlots[i] = slot; i++; } } this.each = function(key, callback) { var value = model[key]; var i, len; if (typeof value === 'object' && !!value.push) { for (i = 0, len = value.length; i < len; i++) { callback.call(model, value[i]); } } else if (typeof value === 'object') { var keys = Object.keys(value); for (i = 0, len = keys.length; i < len; i++) { callback.call(model, value[keys[i]]); } } }; this.get = function(key) { return typeof model[key] === 'undefined' ? {} : model[key]; }; (function initialize() { if (model.dfpSlots) { normalizeSlotKeys(); } })(); }; // if ads/dfpheader2 config 'load_on_carousel_ready' set to 'on' // && have dfpslot objects && carousel has images // then load make initial call for dfpslots var handleCarouselCoupledSlotInitialization = function() { var initializeSlots = function() { DfpSlotManagerMixin.beforeSlotRefresh(); var slotsToInit = filterObject(DfpSlotManagerMixin.getSlots(), function(slot) { return slot.refresh === true; }); slotsToInit = $.map(slotsToInit, function(slot) { return slot.object; }); // Func '..refresh()' is a misnomer in this case // because disableInitialLoad called, slots have yet to initialize googletag.pubads().refresh(slotsToInit); } var checkReady = function() { var slots = DfpSlotManagerMixin.getSlots(); var hasSlots = Object.keys(slots).length > 0; if (hasSlots) { var imageWrapper = document.getElementsByClassName('carousel_ui_img-0')[0]; var sectionWrapper = document.getElementsByClassName('subject_section')[0]; var image; var embed; if (!!imageWrapper) { image = imageWrapper.getElementsByTagName('img')[0]; embed = imageWrapper.getElementsByClassName('embed')[0]; if (!!image || !!embed) { window.clearInterval(check); initializeSlots(); } } else if (!!sectionWrapper) { section = sectionWrapper.getElementsByClassName('section')[0]; if (!!section) { window.clearInterval(check); setTimeout(function() { initializeSlots(); }, 50); } } else { return false; } } } var check = window.setInterval(checkReady, 50); }; var sandboxDfpslots = function() { var whitelist = filterObject(DfpSlotManagerMixin.getSlots(), function(slot) { return slot.sandboxWhitelist; }); Node.prototype.appendChild_ = Node.prototype.appendChild; Node.prototype.appendChild = function(el) { if (el.nodeName === 'IFRAME') { var shouldFilter = true; // never sandbox FB ad iframes if ( this.nodeName === 'FB:AD' || (this.closest && this.closest('fb\\:ad')) || (this.closest && this.closest('.fb-ad')) || (this.closest && this.closest('.fb_iframe_widget')) || (this.closest && this.closest('.fb-page')) || (this.closest && this.closest('.fb-banner')) || (window.jQuery && jQuery(this).closest('fb\\:ad').length) || (window.jQuery && jQuery(this).closest('.fb-page').length) || (window.jQuery && jQuery(this).closest('.fb-ad').length) || (window.jQuery && jQuery(this).closest('.fb_iframe_widget').length) || (window.jQuery && jQuery(this).closest('.fb-banner').length) || (el.src && el.src.search('facebook.com') !== -1 && el.src.search('plugins/ad.php') !== -1) ) { shouldFilter = false; } if (shouldFilter && whitelist.length > 0) { for (var i = 0, len = whitelist.length; i < len; i++) { if (whitelist[i].ad_unit && el.id.search(whitelist[i].ad_unit) !== -1) { shouldFilter = false; } } } if (shouldFilter) { el.sandbox = 'allow-forms allow-popups allow-scripts allow-same-origin'; } } Node.prototype.appendChild_.apply(this, arguments); return el; } var documentWriteFilter = function(html) { try { var shouldFilter = false; // never sandbox FB ad iframes if (html && !(html.search('facebook.com') !== -1 && html.search('plugins/ad.php') !== -1)) { shouldFilter = true; if (whitelist.length > 0) { for (var i = 0, len = whitelist.length; i < len; i++) { // could generate false positives, if becomes an issue make more specific if (whitelist[i].id && html.search(whitelist[i].id) !== -1) { shouldFilter = false; } } } } if (shouldFilter) { html = html.replace(/