");
}
}

if (responsiveDesign == 1) {
//Page is responsive design, check if it is an article page
if ($("[data-widget-def='UX3articleContent']").length != 0) {
//Its an article page, disable the sticky sidebar
disableStickySidebar = 1;
}
}
if (disableStickySidebar == 0) {
//Check for disableStickySidebar in Querystring
disableStickySidebar = gpt_GetQuerystring('disableStickySidebar', 0);
}

if (disableStickySidebar != 0) {
//Disable the sticky leaderbard
//Check for page flag, if it does not exist, create it.
if ($('#disableStickySidebar').length == 0) {
$("body").append("");
}
}

//Load common stylesheet for all sites except Cell & Responsive Design
if ($('.cell-site-header').length == 0 && responsiveDesign == 0) {
$("body").append('');
}

googletag.cmd.push(function () {
var gptAdSlots = [];

//***********************************************
//Start Define Size mapping based on client Viewport
//***********************************************
var gptLeaderboardSizeMapping = googletag.sizeMapping().
addSize([768, 0], [[728, 90]]). // Leaderboard
addSize([0, 0], [[320, 50], [300, 50]]). // Mobile Leaderboard
build();

if ($("#jbs-fixed-hdr").length != 0) {
//Download Bar Exists
var gptSideBarSizeMapping = googletag.sizeMapping().
addSize([1140, 330], [[336, 280], [300, 250]]). // Desktop BoomBox
addSize([0, 0], []). // Phone-Tablet
build();
}
else {
//Download Bar does not exist
var gptSideBarSizeMapping = googletag.sizeMapping().
addSize([1140, 280], [[336, 280], [300, 250]]). // Desktop
addSize([0, 0], []). // Phone-Tablet
build();
}

var gptSideBarNotStickySizeMapping = googletag.sizeMapping().
addSize([1140, 160], [[336, 280], [300, 250]]). // Desktop
addSize([0, 0], []). // Phone-Tablet
build();

var gptBoomBoxSizeMapping = googletag.sizeMapping().
addSize([1140, 0], [[336, 280], [300, 250]]). // Desktop
addSize([0, 0], []). // Phone-Tablet
build();

var gptSkyscraperNotResponsiveSizeMapping = googletag.sizeMapping().
addSize([1140, 800], [[160, 600], [120, 600]]). // SkyScraper - Desktop (Require min 800 vertical)
addSize([0, 0], []). // Phone-Tablet
build();

//***********************************************
//End Define Size mapping based on client Viewport
//***********************************************

//***********************************************
//Start detection for ad slots on page
//***********************************************
$(".gpt-ad").each(function (index) {
var gptSite = GPT_CheckForNULL($('#gptSite').val());
var gptPage = '';
var adSizeMapping = '';
var adId;
var gptPOS;
var gptMasterPage = GPT_CheckForNULL($('#gptPage').val());

if (gptSite == null) {
gptSite = GPT_CheckForNULL($('#gptAltSite').val());
if (gptSite == null) {
gptSite = GPT_CheckForNULL($(this).data('site'));
}
}
if (gptSite == null) {
gptSite = GPT_CheckForNULL($('#gptDefaultSite').val());
}
if (gptSite != null) {
adId = 'gpt-ad-' + index + 1;

gptPOS = parseInt($(this).data('pos')) || -1;
if (gptPOS == -1) {
gptPOS = index + 1;
}

if (gptMasterPage != null) {
gptPage = '/' + gptMasterPage;
}
else {
gptPage = GPT_CheckForNULL($(this).data('page'));
if (gptPage != null) {
gptPage = '/' + gptPage;
}
else {
gptPage = '';
}
}

//Determine sizemapping based on data-adsize
switch ($(this).data('adsize')) {
case 'cell-leaderboard':
adSizeMapping = gptLeaderboardSizeMapping;
if (gptPOS == 1) {
$(this).addClass('GPT-Leaderboard-Cell');
}
break;
case 'leaderboard':
adSizeMapping = gptLeaderboardSizeMapping;
$(this).addClass('GPT-Leaderboard');
break;
case 'boombox':
adSizeMapping = gptBoomBoxSizeMapping;
break;
case 'skyscraper':
if ($(this).hasClass("disableStickySidebar")) {
adSizeMapping = gptSideBarNotStickySizeMapping;
}
else {
$(this).addClass('GPT-StickySideBar');
adSizeMapping = gptSideBarSizeMapping;
}
break;
case 'skyscrapernotresponsive':
adSizeMapping = gptSkyscraperNotResponsiveSizeMapping;
break;
}
}

//Ignore any invalid adsizes that could be on the page
if (adSizeMapping != '') {
$(this).addClass('gpt-ad-defined');
$(this).attr('id', adId);
gptAdSlots[index] = googletag.defineSlot('/6053/els.' + gptSite + gptPage, [], adId).defineSizeMapping(adSizeMapping).addService(googletag.pubads()).setTargeting("pos", gptPOS);
}
else {
$(this).remove();
}
});
//***********************************************
//End detection for ad slots on page
//***********************************************

//***********************************************
//Start page level targeting
//***********************************************
gpt_Target("LoggedIn");
gpt_Target("PII");

//Check for DFP Test
gpt_GetDFPTestId();

//Check for Additional Targeting
gpt_GetAdditionalTargeting()

//***********************************************
//End page level targeting
//***********************************************

//Enable google dfp services
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs();
googletag.enableServices();

//Add Listener for Leaderboard
googletag.pubads().addEventListener('slotRenderEnded', function (event) {
if (!event.isEmpty) {
$('#' + event.slot.getSlotElementId()).closest(".GPT-ad-placeholder").css("display", "block");

//Sticky LeaderBoard JBS
if ($('#' + event.slot.getSlotElementId()).hasClass("GPT-Leaderboard")) {
if ($('#disableStickyLeaderboard').length == 0) {
$('body').addClass("hasLeaderboard");

// INJECT SOME CSS FOR STICKY LEADERBOARD
// THIS INCLUDES CHANGING THE TOP OF THE STICKY HEADER #jbs-fixed-hdr
$("body").append("");

setTimeout(handleStickyLeaderboard, 8000);
}
}

//Sticky LeaderBoard Cell
if ($('#' + event.slot.getSlotElementId()).hasClass("GPT-Leaderboard-Cell")) {
if ($('#disableStickyLeaderboard').length == 0) {
$("body").append('');
$("div.cell-top-head").attr("style", "display:block !important;"); $("body").append("");
var tmp;
tmp = $(".article.enhanced .tab-nav").attr("style");
tmp = "top:110px;" + tmp;
$(".article.enhanced .tab-nav").removeAttr("style");
$(".article.enhanced .tab-nav").attr("style", tmp);
tmp = $(".article.enhanced #fixedPane").attr("style");
tmp = "top:148px;" + tmp;
$(".article.enhanced #fixedPane").removeAttr("style");
$(".article.enhanced #fixedPane").attr("style", tmp);
setTimeout(handleStickyLeaderboard_CELL, 8000);
}

// THE FOLLOWING MAKES SURE THAT THE FIGURES PANE POPULATES
// (there might be a bug on the live site)
$("li.showFullText a").click();
}

//Sticky SideBar
if ($('#' + event.slot.getSlotElementId()).hasClass("GPT-StickySideBar")) {
if ($('#disableStickySidebar').length == 0) {
enableStickySideBar();
}
}
}
});

//Populate Defined Ad Slots
$(".gpt-ad-defined").each(function (index) {
var adId = $(this).attr('id');
googletag.cmd.push(function () { googletag.display(adId); });
});

});
}



Source link