var dataToSend = [], prebid;
prebid = {"colossusssp": {"enabled": true, "placements": {"poster_scroll": {"placement_id": 21038}, "poster": {"placement_id": 21037}, "high_impact": {"placement_id": 21036}, "leaderboard_btf": {"placement_id": 21039}, "poster_front": {"placement_id": 21037}}}, "all_bids_cutoff": 4, "openX": {"domain": "gannett-d.openx.net", "enabled": true, "multisize": true, "placements": [{"life": 538809219, "money": 538809222, "travel": 538809226, "sports": 538809208, "opinion": 538809230, "home": 538809201, "news": 538809203, "ros": 538809232, "size": "300x250"}, {"life": 538809224, "money": 538809220, "travel": 538809227, "sports": 538809207, "opinion": 538809231, "home": 538809202, "news": 538809204, "ros": 538809234, "size": "300x600"}, {"home": 538809200, "ros": 538809235, "size": "970x250"}, {"ros": 540401032, "size": "728x90"}]}, "pubMatic": {"enabled": true, "account": "57752", "group": "2", "slots": ["ATF@728x90", "BTF@728x90", "ATF@300x250", "BTF@300x250", "ATF@300x600", "ROS@970x250", "ROS@300x1050"]}, "index": {"enabled": false, "placements": {"poster_scroll": {"siteid": 196732, "id": 8}, "poster_gallery": {"siteid": 196730, "id": 6}, "poster_front": {"siteid": 196729, "id": 5}, "poster": {"siteid": 196728, "id": 4}, "leaderboard_atf": {"siteid": 196726, "id": 2}, "high_impact": {"siteid": 196725, "id": 1}, "poster_gallery_companion": {"siteid": 196731, "id": 7}, "leaderboard_btf": {"siteid": 196727, "id": 3}}}, "targeting": {"keys": ["pb", "adid", "deal"], "generic": false}, "rubicon": {"zones": {"atf": {"life": 156952, "money": 156956, "travel": 156966, "sports": 156960, "weather": 159204, "tech": 156962, "opinion": 217164, "home": 156954, "news": 156958, "ros": 164392}, "btf": {"life": 159192, "money": 159196, "travel": 159202, "sports": 156964, "weather": 159206, "tech": 159200, "opinion": 217166, "home": 159194, "news": 159198, "ros": 164392}}, "enabled": true, "account": "11324", "siteId": "37664", "zoneId": "164392"}, "criteo": {"enabled": true, "multisize": true, "placements": [{"id": 580850, "size": "728x90"}, {"id": 580848, "size": "300x250"}, {"id": 580849, "size": "300x600"}, {"id": 580856, "size": "970x250"}]}, "config": {"syncsPerBidder": 50, "iframeSync": "*", "syncDelay": 7000, "timeoutBuffer": 400, "maxRequestsPerOrigin": 1}, "appNexus": {"enabled": true, "multisize": true, "placements": [{"ros": 15674410, "size": "728x90"}, {"life": 10670398, "money": 10670402, "travel": 10670428, "sports": 10670419, "tech": 10670424, "home": 10670395, "opinion": 10670410, "news": 10670406, "ros": 10670414, "size": "970x250"}, {"life": 10670399, "money": 10670403, "travel": 10670430, "sports": 10670420, "tech": 10670425, "home": 10670396, "opinion": 10670411, "news": 10670407, "ros": 10670415, "size": "300x250"}, {"home": 10670397, "ros": 10670416, "size": "300x600"}, {"life": 10670400, "money": 10670404, "travel": 10670431, "sports": 10670422, "tech": 10670426, "opinion": 10670412, "news": 10670408, "ros": 10670417, "size": "300x1050"}, {"life": 10670401, "money": 10670405, "travel": 10670432, "sports": 10670423, "tech": 10670427, "opinion": 10670413, "news": 10670409, "ros": 10670418, "size": "preroll"}]}, "staq": {"url": "headerbidding.staqdata.com", "enabled": false, "connId": "6872"}, "symbol": "pbjs", "aol": {"bidkey": "aolbid", "network": "10315.1", "enabled": true, "multisize": false, "server": "adserver.adtechus.com", "placements": [{"id": 4113915, "size": "728x90"}, {"id": 4113916, "size": "300x250"}, {"id": 4113917, "size": "300x600"}], "bidfloor": "0.0"}, "triplelift": {"enabled": true, "multisize": false, "placements": [{"id": "USCP_300x600_desktop", "size": "300x600"}, {"id": "USCP_970x250_desktop", "size": "970x250"}]}, "scriptUrl": "
function getbids(divId, adUnit, adSizes) {
var adSize, adSizeStr, bids = [], section = 'ros',
location = (adUnit.indexOf('_btf') !== -1) ? 'btf' : 'atf';
adSize = getMaxSize(adSizes, prebid.sizes);
if(!adSize) return bids;
adSizeStr = adSize[0] + 'x' + adSize[1];
// Sonobi settings
if (prebid.sonobi.enabled) {
bids.push({
bidder: 'sonobi',
params: {
ad_unit: adUnit
}
});
}
// A9 settings
if (prebid.a9.enabled) {
a9Bid = setupA9(prebid.a9, adSizes);
if(a9Bid) bids.push(a9Bid);
}
// Criteo settings
if (prebid.criteo.enabled) {
// Moved aol to it's own function, as we needed to determine the largest size available for aol placements
criteoBid = _setupCriteo(prebid.criteo, adSizes);
if(criteoBid) bids.push(criteoBid);
}
// Rubicon settings
if (prebid.rubicon.enabled) {
bids.push({
bidder: 'rubicon',
params: {
accountId: prebid.rubicon.account,
siteId: prebid.rubicon.siteId,
zoneId: prebid.rubicon.zoneId,
inventory: {
domain: document.location.hostname,
section: section
}
}
});
}
// AppNexus settings
if (prebid.appNexus.enabled) {
appNexusBid = setupAppNexus(prebid.appNexus, adSizes, section);
if(appNexusBid) bids.push(appNexusBid);
}
// OpenX settings
if (prebid.openX.enabled) {
// Moved aol to it's own function, as we needed to determine the largest size available for aol placements
openXBid = setupOpenX(prebid.openX, adSizes, section);
if(openXBid) bids.push(openXBid);
}
// IndexExchange settings
if (prebid.index.enabled) {
// Moved aol to it's own function, as we needed to determine the largest size available for aol placements
indexBids = setupIndex(prebid.index, adUnit, adSizes);
if(indexBids) {
indexBids.forEach(function (indexBid) {
bids.push(indexBid);
});
}
}
// Yieldbot settings
if (prebid.yieldbot.enabled) {
ybBid = setupYieldbox(prebid.yieldbot, adUnit, adSizes);
if(ybBid) bids.push(ybBid);
}
// Pubmatic settings
if (prebid.pubMatic.enabled) {
var slot = location.toUpperCase() + '@' + adSizeStr,
rosSlot = 'ROS@' + adSizeStr,
adSlot = (prebid.pubMatic.slots.indexOf(slot) > -1) ? slot : (prebid.pubMatic.slots.indexOf(rosSlot) > -1) ? rosSlot : null;
if (adSlot) {
bids.push({
bidder: 'pubmatic',
params: {
publisherId: prebid.pubMatic.account,
adSlot: adSlot
}
});
}
}
// Aol settings
if (prebid.aol.enabled) {
// Moved aol to it's own function, as we needed to determine the largest size available for aol placements
aolBid = setupAol(prebid.aol, adUnit, adSizes);
if(aolBid) bids.push(aolBid);
}
return bids;
}
function setupA9(config, sizes) {
var placement,
sizeStr = getLargestPlacementSize(config.placements, sizes);
// Match up the largest available size with the placement
placement = config.placements.find(function(placement) {
return placement.size === sizeStr;
});
if(placement) {
return {
bidder: 'amazon',
params: {
amazonId: config.account,
size: placement.id,
height: placement.height,
width: placement.width
}
};
}
}
function setupAol(config, adUnit, sizes) {
var placement,
sizeStr = getLargestPlacementSize(config.placements, sizes);
// Match up the largest available size with the placement
placement = config.placements.find(function(placement) {
return placement.size === sizeStr;
});
if(placement) {
return {
bidder: 'aol',
params: {
placement: placement.id,
network: config.network,
alias: adUnit,
server: config.server,
sizeId: placement.size,
bidFloor: config.bidfloor,
}
};
}
}
function setupYieldbox(config, adUnit, sizes) {
var placement,
sizeStr = getLargestPlacementSize(config.placements, sizes);
// Match up the largest available size with the placement
placement = config.placements.find(function(placement) {
return placement.size === sizeStr;
});
if(placement) {
return {
bidder: 'yieldbot',
params: {
psn: placement.id,
slot: placement.slot
}
};
}
}
function _setupCriteo(config, sizes) {
var placement,
sizeStr = getLargestPlacementSize(config.placements, sizes);
// Match up the largest available size with the placement
placement = config.placements.find(function(placement) {
return placement.size === sizeStr;
});
if(placement) {
return {
bidder: 'criteo',
params: {
zoneId: placement.id
}
};
}
}
function setupAppNexus(config, sizes, section) {
var placements, placementId,
sizeStr = getLargestPlacementSize(config.placements, sizes);
// Match up the largest available size with the placement
placements = config.placements.find(function(placement) {
return placement.size === sizeStr;
});
if(placements) {
// Get the section/ROS placement id based on this size
placementId = placements[section] || placements.ros;
if(placementId) {
return {
bidder: 'appnexusAst',
params: {
placementId: placementId
}
};
}
}
}
function setupOpenX(config, sizes, section) {
var placements, placementId,
sizeStr = getLargestPlacementSize(config.placements, sizes);
// Match up the largest available size with the placement
placements = config.placements.find(function(placement) {
return placement.size === sizeStr;
});
if(placements) {
// Get the section/ROS placement id based on this size
placementId = placements[section] || placements.ros;
if(placementId) {
return {
bidder: 'openx',
params: {
unit: placementId,
delDomain: config.domain
}
};
}
}
}
function setupIndex(config, adUnit, sizes) {
var placement,
key = adUnit.split('/')[2],
bids = [];
if(!key) return;
// Use key to get placement
placement = config.placements[key];
if(placement) {
sizes.forEach(function (size) {
bids.push({
bidder: 'indexExchange',
params: {
siteId: placement.siteid,
size: [size[0], size[1]]
}
});
});
}
return bids;
}
function getLargestPlacementSize(placements, sizes) {
var thePlacement = null;
placements.reduce(function(memo, placement) {
var total, match,
size = placement.size.split('x');
// Change the sizes string values to integers
size = size.map(function(str) {
return parseInt(str, 10);
});
// Find a match in the ad slots sizes array
match = sizes.find(function(slotSize) {
return slotSize[0] === size[0] && slotSize[1] === size[1] ;
});
if(!match) return memo;
total = match[0] + match[1];
if (total > memo) {
thePlacement = placement;
return total;
}
return memo;
}, 0);
return (thePlacement) ? thePlacement.size : false;
}
function getMaxSize(sizes) {
var adSize;
if(sizes.length > 1) {
// if larger size
sizes.reduce(function(memo, size) {
var total = size[0] + size[1];
if (total > memo) {
adSize = size;
return total;
}
return memo;
}, 0);
} else {
// If single size return it
adSize = sizes[0];
}
return adSize;
}
function cobrandCallForAd(divId, adUnit, adSizes, customTargeting) {
adSizes= adSizes || [[300,250], [300,600]];
dataToSend.push ({
code: divId,
mediaTypes: {
banner: {
sizes: adSizes
}
},
bids: getbids(divId, adUnit, adSizes) || []
});
customTargeting= customTargeting || {};
window.googletag.cmd.push(function() {
var slotRef= window.googletag.defineSlot(adUnit, adSizes, divId).addService(window.googletag.pubads());
for (var name in customTargeting) {
if (customTargeting.hasOwnProperty(name)) {
slotRef.setTargeting(name, customTargeting[name]);
}
}
window.googletag.display(divId);
});
}