window.IS24 = window.IS24 || {};
window.IS24.gpt = (function() {
"use strict";
var adIndex = 0,
adSelector = '[data-gpt-slot]',
adModules = {},
adData = {
"reportGPTLoadError": false,
"gptUrl": "//www.googletagservices.com/tag/js/gpt.js",
"interactiveMediaUrl": "//cdn.interactivemedia.net/live/Immobilienscout24/live/globalAdTag.min.js",
"global": {
"isForecast": false,
"targeting" : {},
"outOfPage" : "banner_top"
},
"slots": {},
"breakpoints": [],
"index": {},
"eventHandler": {
"all": null,
"slotIds": null,
"domIds": null
}
};
window.googletag = window.googletag || {};
window.googletag.cmd = window.googletag.cmd || [];
var $ = window.$;
if (!$ && !!window.jQuery) {
$ = window.jQuery;
}
adModules.calculateStickyOffset = (function () {
function subtractBreakpoint(cssTop, breakPoint) {
if ($(window).scrollTop() > breakPoint) {
cssTop -= breakPoint;
}
return cssTop;
}
function addOffset(cssTop, skyOffset) {
cssTop += skyOffset;
return cssTop;
}
function addPageOffset(cssTop) {
cssTop += window.pageYOffset;
return cssTop;
}
return function (breakPoint, skyOffset) {
var cssTop = 0;
skyOffset = skyOffset || 0;
cssTop = subtractBreakpoint(cssTop, breakPoint);
cssTop = addOffset(cssTop, skyOffset);
cssTop = addPageOffset(cssTop);
return cssTop;
};
}());
adModules.gptAdd = (function () {
var interstitialId = "is24-interstitial",
shouldDisplayOutOfPageSlot = false;
function addBreakPointAd(arrayWidths, slot) {
var arrayWidthsSorted = arrayWidths.sort(function (a, b) {
return a - b;
});
adData.breakpoints.push({
slot: slot,
breaks: arrayWidthsSorted
});
}
function fireEventAdSlotBeingDisplayed(){
var event;
try {
event = new CustomEvent('fetching_ad', {detail: 'details'});
} catch (exception){
event = document.createEvent('CustomEvent');
event.initCustomEvent('fetching_ad', true, false, {detail: 'details'});
}
window.document.dispatchEvent(event);
}
function isNotValid(slotConfig, adElem) {
return (adElem.length === 0 || slotConfig.isAdded || !slotConfig.slot || !slotConfig.sizes);
}
function display(domNodeId, slotConfig) {
if (!slotConfig.showAd || slotConfig.isDisplayed) {
return;
}
googletag.display(domNodeId);
fireEventAdSlotBeingDisplayed(domNodeId, slotConfig);
slotConfig.isDisplayed = true;
}
function addOutOfPageContainer(slotConfig) {
var outOfPageSlot;
$(document.body).append("
");
outOfPageSlot = googletag.defineOutOfPageSlot(slotConfig.slot, interstitialId);
outOfPageSlot.addService(googletag.pubads());
}
function defineSlot(slotConfig, sizes, domNodeId) {
var slot = googletag.defineSlot(slotConfig.slot, sizes, domNodeId);
slot.addService(googletag.pubads());
slot.setTargeting("domNodeId", domNodeId);
return slot;
}
function buildMappings(sizes, sizeList) {
var i, mapping;
mapping = googletag.sizeMapping();
for (i = 0; i < sizes.length; i += 2) {
mapping = mapping.addSize(sizes[i], sizes[i + 1]);
sizeList.push(sizes[i][0]);
}
mapping = mapping.build();
return mapping;
}
function endsWith(subjectString, searchString, position) {
if (!searchString || !subjectString) {
return false;
}
if (position === undefined || position > subjectString.length) {
position = subjectString.length;
}
position -= searchString.length;
var lastIndex = subjectString.indexOf(searchString, position);
return lastIndex !== -1 && lastIndex === position;
}
function addOutOfPageSlot(slotConfig) {
var isOutOfPageSlot = endsWith(slotConfig.slot, !!adData && !!adData.global ? "/" + adData.global.outOfPage : "");
if (isOutOfPageSlot) {
addOutOfPageContainer(slotConfig);
shouldDisplayOutOfPageSlot = true;
}
}
function add(domNodeId, slotConfig) {
var sizeList, sizes, adElem = $("#" + domNodeId), slot;
if (isNotValid(slotConfig, adElem) || slotConfig.isAdded) {
return;
}
slotConfig.isAdded = true;
slotConfig.showAd = true;
addOutOfPageSlot(slotConfig);
if ($.isArray(slotConfig.sizes) && $.isArray(slotConfig.sizes[0])) {
sizes = slotConfig.sizes;
sizeList = [];
slot = defineSlot(slotConfig, sizes[1], domNodeId);
slot.defineSizeMapping(buildMappings(sizes, sizeList));
addBreakPointAd(sizeList, slot);
} else {
slot = defineSlot(slotConfig, slotConfig.sizes, domNodeId);
}
slotConfig.slotObj = slot;
}
function displayOutOfPageSlot() {
if (shouldDisplayOutOfPageSlot) {
googletag.display(interstitialId);
shouldDisplayOutOfPageSlot = false;
}
}
return function () {
googletag.cmd.push(function () {
$.each(adData.slots, add);
// OPENX_START
// OpenX Targeting
try {
//console.log ("setting Ox targeting");
/* jshint -W106, -W117 */
window.OX.dfp_bidder.setOxTargeting();
/* jshint +W106, +W117 */
} catch (e) {
//console.log("exception: OX not found", e);
}
// OPENX_END
googletag.enableServices();
$.each(adData.slots, display);
displayOutOfPageSlot();
});
};
}());
adModules.gptAddHandler = (function () {
var isRegistered = false,
renderedSlotIdsWithAdvertisement = [],
renderedCallbacks = [];
function hasSlotId(slot) {
return adData.eventHandler.slotIds && adData.eventHandler.slotIds[slot.getAdUnitPath()];
}
function hasDomId(slot) {
return adData.eventHandler.domIds && adData.eventHandler.domIds[slot.getSlotId().getName()];
}
function checkTitle(domid, adData) {
var config = adData.slots[domid];
if (config && config.title) {
var d = $('#' + domid);
var align = "center";
if (config.title.indexOf('left') >= 0) {
align = "left";
} else if (config.title.indexOf('right') >= 0) {
align = "right";
}
var anzeigenDiv = $('ANZEIGE
');
anzeigenDiv.css({
'text-align': align,
'color': '#969696',
'font-size': '11px'
});
if (config.title.indexOf('top') >= 0) {
anzeigenDiv.insertBefore(d.children()[0]);
} else {
anzeigenDiv.insertAfter(d.children()[0]);
}
}
}
function checkCallbacks() {
$.each(renderedCallbacks, function (idx, renderedCallback) {
var allSlotsRendered = true;
if (renderedCallback.called) {
return;
}
$.each(renderedCallback.slotIds, function (idx, slotId) {
if (renderedSlotIdsWithAdvertisement.indexOf(slotId) === -1) {
allSlotsRendered = false;
}
});
if (allSlotsRendered) {
renderedCallback.called = true;
renderedCallback.callback();
}
});
}
function init() {
if (!isRegistered) {
isRegistered = true;
googletag.cmd.push(function () {
googletag.pubads().addEventListener('slotRenderEnded', function (event) {
var slot = event.slot,
handledByAllHandler = false,
slotId = slot.getSlotId().getName(),
domId = slot.getSlotId().getDomId();
if (!event.isEmpty) {
renderedSlotIdsWithAdvertisement.push(slotId);
checkCallbacks();
}
if (adData.eventHandler.all) {
handledByAllHandler = adData.eventHandler.all(event);
}
if (!handledByAllHandler) {
if (hasSlotId(slot)) {
adData.eventHandler.slotIds[slot.getAdUnitPath()](event);
} else if (hasDomId(slot)) {
adData.eventHandler.domIds[slotId](event);
}
}
checkTitle(domId, adData);
});
});
}
}
function onSlotsRendered(slotIds, cb) {
var slotIdArray = slotIds;
if (!$.isArray(slotIds)) {
slotIdArray = [slotIds];
}
renderedCallbacks.push({
slotIds: slotIdArray,
callback: cb
});
checkCallbacks();
}
return {
init: init,
onSlotsRendered: onSlotsRendered
};
}());
adModules.gptConfigure = function (data) {
googletag.cmd.push(function () {
googletag.pubads().enableSingleRequest();
googletag.pubads().collapseEmptyDivs(true);
if (data.global) {
if (data.global.targeting) {
$.each(data.global.targeting, function (key, value) {
if (typeof value !== "undefined") {
googletag.pubads().setTargeting(key, value);
}
});
}
if (!!data.global.isForecast) {
googletag.pubads().setTargeting("forecast", "true");
}
}
var adTestName = 'adtest';
if (window.location.search.indexOf(adTestName) >= 0) {
var urlParts = window.location.href.split('?');
if (!!urlParts && urlParts.length > 0) {
var searchParams = urlParts[1].split(/[]/);
$.each(searchParams, function (index, value) {
if (value.indexOf(adTestName + '=') === 0) {
var testAd = value.split('=');
googletag.pubads().setTargeting(adTestName, testAd[1]);
}
});
}
}
});
};
adModules.gptCreateSlotsFromNodes = (function () {
function getConfig(data, id) {
var config = {sizes: [], title: null};
if (!!data) {
var values = data.split(";");
$.each(values, function (key, value) {
var kv = value.split('=');
if (kv[0] === 'sizes') {
try {
config.sizes = JSON.parse(kv[1]);
} catch (e) {
}
} else if (kv[0] === 'title') {
try {
config.title= kv[1];
} catch (e) {
}
}
});
}
if (config.sizes.length === 0) {
adModules.logError("missing size information for id: " + id);
}
return config;
}
function hasSlotAlready(id, data) {
return (data.slots[id]);
}
function filterInvisibleNodes(domNode) {
domNode = domNode.filter(function (index, el) {
var $el = $(el);
return ($el.is(":visible") || $el.hasClass("gptForceLoad"));
});
return domNode;
}
function addUniqueId($el) {
var id = 'gpt-slot-' + adIndex;
adIndex++;
$el.attr("id", id);
return id;
}
return function (domNode, data) {
googletag.cmd.push(function () {
domNode = filterInvisibleNodes(domNode);
domNode.each(function (index, el) {
var $el = $(el),
id = $el.attr("id"),
localConfig = $el.attr("data-gpt-config"),
isIndexed = !!$el.attr("data-gpt-index"),
slotId = $el.attr('data-gpt-slot');
if (hasSlotAlready(id, data)) {
return;
}
if (isIndexed && !!slotId) {
var indexCount = data.index[slotId] !== undefined ? data.index[slotId] : 0;
indexCount++;
$el.attr('data-gpt-slot', slotId + "_" + indexCount);
data.index[slotId] = indexCount;
}
if (!id) {
id = addUniqueId($el);
}
var config = getConfig(localConfig, id);
data.slots[id] = {
"slot": $el.attr("data-gpt-slot"),
"sizes": config.sizes,
"title": config.title
};
});
});
};
}());
adModules.gptSafeframeEnhancement = (function () {
var creativeIdToSlotId = {},
offset = null,
resizeHandler = null,
scrollHandler = null,
skyTopOffset = 120;
function brandDaySuperiorImage(data) {
var is24 = window.IS24;
if (data.brandDaySuperiorImage !== undefined && data.brandDaySuperiorImage !== null) {
if (is24 && is24.homepage && is24.homepage.advertisement && is24.homepage.advertisement.backgroundImage && is24.homepage.advertisement.backgroundImage.setAdImage) {
if (data.brandDaySuperiorImage.length > 0) {
is24.homepage.advertisement.backgroundImage.setAdImage(data.brandDaySuperiorImage);
} else {
is24.homepage.advertisement.backgroundImage.setDefaultImage();
}
}
}
}
function sticky(data, skyOffset, $skyscraper) {
if (data.isSkySticky === undefined || data.isSkySticky === null) {
return;
}
var skyOffsetGiven = skyOffset;
function resetStickySky() {
$skyscraper.css({
"top": skyOffsetGiven + "px",
"left": "auto",
"position": "absolute"
});
}
var resizeHandlerTimeout = null;
window.stillSticky = data.isSkySticky === true;
if (data.isSkySticky) {
window.stillSticky = true;
if (!!resizeHandler && !!scrollHandler) {
resetStickySky();
}
offset = $skyscraper.offset();
if (!scrollHandler) {
scrollHandler = $(window).on("scroll", function () {
if (!window.stillSticky) {
return;
}
var scrollTop = $(window).scrollTop();
if (offset.top > scrollTop) {
resetStickySky();
} else {
$skyscraper.css({
"top": "0px",
"left": offset.left,
"position": "fixed"
});
}
});
}
if (!resizeHandler) {
resizeHandler = $(window).resize("resize", function () {
if (!window.stillSticky) {
return;
}
if (!!resizeHandlerTimeout) {
clearTimeout(resizeHandlerTimeout);
}
resizeHandlerTimeout = setTimeout(function () {
resetStickySky();
setTimeout(function () {
offset = $skyscraper.offset();
$(window).trigger("scroll");
}, 0);
}, 250);
});
}
$(window).trigger("scroll");
$(window.document).on('reload_ad', function (event) {
if (!window.stillSticky) {
return;
}
var slots = event.detail;
$.each(slots, function (index, slot) {
var unitPath = slot.getAdUnitPath();
if (unitPath.indexOf("sky_right") > 0) {
resetStickySky();
$(window).trigger('scroll');
}
});
});
/* Do not need that code anymore hopefully ;) */
//googletag.pubads().addEventListener('slotRenderEnded', function (obj) {
// if (!window.stillSticky) {
// return;
// }
// var unitPath = obj.slot.getAdUnitPath();
// if (unitPath.indexOf("sky_right") > 0) {
// resetStickySky();
// $(window).trigger('scroll');
// }
//});
} else {
window.stillSticky = false;
resetStickySky();
}
}
function wallpaper(data) {
if (data.wallpaperColor) {
$(document.body).css("background-color", data.wallpaperColor);
}
if (data.wallpaperClickUrl) {
$(document).on("click", function (event) {
if (event.target.nodeName.toLowerCase() === "body" || $(event.target).hasClass("viewport")) {
window.open(data.wallpaperClickUrl);
}
});
}
if (data.wallpaperImage) {
$(document.body).css("background-image", "url('" + data.wallpaperImage + "')");
}
}
function setSkyOffset(skyOffset, $skyscraper) {
if (skyOffset !== undefined) {
$skyscraper.css("top", skyOffset + "px");
}
}
function positionBannerTop(data, borderSize) {
if (data.bannerRight) {
$("#is24-banner-top").css("right", (-(data.bannerRight + borderSize)) + "px");
}
}
function setBackgroundColorOfSlot(data) {
var slotId;
if (data.backgroundForCreativeId) {
slotId = creativeIdToSlotId[data.backgroundForCreativeId];
if (slotId) {
$("#" + slotId).addClass("background padding-vertical");
}
}
}
function handleEvent(data){
if (!data.event){
return;
}
var event;
try{
event = new Event(data.event);
} catch(e){
event = document.createEvent('Event');
event.initEvent(data.event, true, false);
}
window.dispatchEvent(event);
}
function handleMessageCommand(data) {
var $skyscraper = $("#is24-sky-right"),
borderSize = 1,
//breakPoint,
skyOffset,
messageCommand,
command = data.command;
if (data.topElementHockeyStick === "banner-top") {
skyOffset = (borderSize * -1);
//breakPoint = data.bannerTopHeight + borderSize;
} else if (data.topElementHockeyStick === "sky") {
skyOffset = ((data.bannerTopHeight + borderSize) * -1);
//breakPoint = 0;
} else if (data.topElementHockeyStick === "none") {
skyOffset = $skyscraper.position().top;
//breakPoint = 0;
}
positionBannerTop(data, borderSize);
setSkyOffset(skyOffset, $skyscraper);
wallpaper(data);
sticky(data, skyOffset, $skyscraper);
brandDaySuperiorImage(data);
setBackgroundColorOfSlot(data);
handleEvent(data);
messageCommand = adModules.messageCommand[command];
if (messageCommand) {
messageCommand(data);
}
}
function isOurMessage(event) {
return (event && $.isPlainObject(event.data) && event.data.id === "is24data");
}
function addMessageListener() {
$(window).on("message", function (event) {
if (isOurMessage(event.originalEvent)) {
handleMessageCommand(event.originalEvent.data.message);
}
});
}
function addSkyListener(){
window.googletag.pubads().addEventListener('slotRenderEnded', function(event){
if (event && event.slot){
var adPath = event.slot.getAdUnitPath();
if (adPath.indexOf('sky_right')>0){
var slotid = event.slot.getSlotId();
var $domid = $("#"+slotid.getDomId());
sticky({isSkySticky: true}, skyTopOffset, $domid );
}
}
});
}
function addSlotRenderEndedListener() {
window.googletag.pubads().addEventListener("slotRenderEnded", function (event) {
if (event.slot.getSlotElementId) {
creativeIdToSlotId[event.creativeId] = event.slot.getSlotElementId();
} else if (event.slot.getSlotId) {
creativeIdToSlotId[event.creativeId] = event.slot.getSlotId();
}
});
}
return function () {
googletag.cmd.push(function () {
addSlotRenderEndedListener();
addMessageListener();
addSkyListener();
});
};
}());
adModules.gptSetResponsiveAdHandler = (function () {
var adFetcherTimeout,
lastTimeWidth;
function isLastElement(b, bb) {
return (b === bb - 1);
}
function isFirstValidElement(b, breaks) {
return (b === 0 && breaks[b] > 0);
}
function deleteContent(elem) {
if (!!elem.getSlotId && !!elem.getSlotId().getDomId) {
$(elem.getSlotId().getDomId()).html('');
}
}
function getSlotsToFetch(breakpoints, currentWidth, lastTimeWidth) {
var slotsToFetch = [], b, bb, slot, breaks, addToFetch;
$.each(breakpoints, function (index, breakpoint) {
slot = breakpoint.slot;
breaks = breakpoint.breaks;
addToFetch = false;
for (b = 0, bb = breaks.length; b < bb && !addToFetch; b++) {
if (isFirstValidElement(b, breaks)) {
addToFetch = ((currentWidth < breaks[b]) && (lastTimeWidth >= breaks[b]));
}
if (!addToFetch) {
if (isLastElement(b, bb)) {
addToFetch = ((currentWidth >= breaks[b]) && (lastTimeWidth < breaks[b]));
} else { //in the middle and also the first element starts with 0 pixels
addToFetch = ((currentWidth >= breaks[b]) && (currentWidth < breaks[b + 1]) && ((lastTimeWidth < breaks[b]) || (lastTimeWidth >= breaks[b + 1])));
}
}
if (addToFetch) {
deleteContent(slot);
slotsToFetch.push(slot);
}
}
});
return slotsToFetch;
}
return function (delayInMillis) {
googletag.cmd.push(function () {
delayInMillis = (delayInMillis !== undefined ? delayInMillis : 500);
lastTimeWidth = $(window).width();
function fireReloadEvent(slotIDs) {
var event;
try {
event = new CustomEvent('reload_ad', {detail: slotIDs});
} catch (exception){
event = document.createEvent('CustomEvent');
event.initCustomEvent('reload_ad', true, false, {detail: slotIDs});
}
window.document.dispatchEvent(event);
}
$(window).on('resize', function () {
var breakpoints = adData.breakpoints;
if (!breakpoints || breakpoints.length === 0) {
return;
}
if (!!adFetcherTimeout) {
window.clearTimeout(adFetcherTimeout);
adFetcherTimeout = null;
}
adFetcherTimeout = window.setTimeout(function () {
var currentWidth = $(window).width(),
slotsToFetch = getSlotsToFetch(breakpoints, currentWidth, lastTimeWidth);
if (slotsToFetch.length > 0) {
//OPENX_SART
// include OpenX in refresh
/* jshint -W106 */
try {
OX.dfp_bidder.refresh(function () {
try {
OX.dfp_bidder.setOxTargeting(slotsToFetch);
} catch (e) {
}
googletag.pubads().refresh(slotsToFetch);
fireReloadEvent(slotsToFetch);
}, slotsToFetch);
} catch (e) {
//OPENX_END
googletag.pubads().refresh(slotsToFetch);
fireReloadEvent(slotsToFetch);
}
/* jshint +W106 */
//OPENX_SART
}
//OPENX_END
lastTimeWidth = currentWidth;
adFetcherTimeout = null;
}, delayInMillis);
});
});
};
}());
adModules.interactiveMedia = (function () {
var isSetUp = false,
isLoading = false,
adCache = [];
function register(advertisement) {
IM.GlobalAdTag.register(advertisement.type, advertisement.id, "asyncJs", "onRegister");
}
function setUp(advertisement) {
if (!isSetUp) {
isSetUp = true;
IM.GlobalAdTag.setZone(advertisement.zone);
IM.GlobalAdTag.setPageType(advertisement.pageType);
}
}
function registerAll() {
$.each(adCache, function (index, advertisement) {
setUp(advertisement);
register(advertisement);
});
adCache = [];
}
function loadScript() {
$.ajax({
dataType: "script",
cache: true,
url: adData.interactiveMediaUrl
}).done(function () {
registerAll();
isLoading = false;
});
}
return function (advertisement) {
adCache.push(advertisement);
if (window.IM && window.IM.GlobalAdTag) {
registerAll();
} else if (!isLoading) {
isLoading = true;
loadScript(advertisement);
}
};
}());
adModules.krux = function () {
var user, segments;
function retrieve(n) {
var cookieData, id = 'kx' + n;
if (window.localStorage) {
return window.localStorage[id] || "";
} else if (navigator.cookieEnabled) {
cookieData = document.cookie.match(id + '=([^;]*)');
return (cookieData && window.unescape(cookieData[1])) || "";
} else {
return '';
}
}
user = retrieve('user');
segments = retrieve('segs') && retrieve('segs').split(',') || [];
if (user) {
adData.global.targeting.kuid = user;
}
if (segments) {
adData.global.targeting.ksg = segments;
}
};
adModules.logError = function (message) {
if (!!window.console && !!window.console.error) {
console.error(message);
}
};
adModules.logInfo = function (message) {
if (!!window.console && !!window.console.log) {
console.log(message);
}
};
adModules.messageCommand = (function () {
function skyExpand() {
var expandableClassDefinition = '';
$(expandableClassDefinition).appendTo("head");
}
function removeAdTitle(data) {
var commandSlot = data.element,
slotDomId;
$.each(adData.slots, function (currentSlotDomId, currentSlot) {
if (currentSlot.slot === commandSlot) {
slotDomId = currentSlotDomId;
}
});
if (slotDomId) {
$(".anzeigentitel:first", "#" + slotDomId).html(" ");
}
}
function interstitial(data) {
var node = $((!!data.mobile ? "#is24-mobile-interstitial" : "#is24-interstitial"));
if (data.iframeCss) {
node.find("iframe").css(data.iframeCss);
}
if (data.containerCss) {
node.css(data.containerCss);
}
}
return {
"skyExpand": skyExpand,
"interstitial": interstitial,
"remove-advertisement-title": removeAdTitle
};
}());
adModules.public = {
getSlots: function () {
return $.extend(true, {}, adData.slots);
},
getAdvertisementDomNodes: function(scanSectionSelector){
return $(adSelector, scanSectionSelector);
},
scanForSlots: function (scanSectionSelector) {
var adContainer = adModules.public.getAdvertisementDomNodes(scanSectionSelector);
if (adContainer.length > 0) {
adModules.gptCreateSlotsFromNodes(adContainer, adData);
adModules.gptAdd();
}
},
reloadAdvertisement: function (domId) {
if (!domId && !adData.slots[domId] && !adData.slots[domId].slotObj){
return null;
}
var slotObj = adData.slots[domId].slotObj;
//OPENX_START
// include OpenX in refresh
/* jshint -W106 */
try{
OX.dfp_bidder.refresh(function() {
try{
OX.dfp_bidder.setOxTargeting([slotObj]);
}catch(e){}
googletag.pubads().refresh([slotObj]);
},[slotObj]);
} catch(e) {
//OPENX_END
googletag.pubads().refresh([slotObj]);
//OPENX_START
}
/* jshint +W106 */
//OPENX_END
},
reloadAllAdvertisements: function(){
//OPENX_SART
/* jshint -W106 */
// include OpenX in refresh
try{
OX.dfp_bidder.refresh(function() {
try{
OX.dfp_bidder.setOxTargeting();
}catch(e){}
googletag.pubads().refresh();
});
} catch(e) {
//OPENX_END
googletag.pubads().refresh();
//OPENX_SART
}
/* jshint +W106 */
//OPENX_END
},
onSlotsRendered: adModules.gptAddHandler.onSlotsRendered,
interactiveMedia: adModules.interactiveMedia
};
function onScriptFail(jqxhr) {
var message, moduleName;
if (!adData.reportGPTLoadError) {
return;
}
message = "could not load google gpt. code: " + jqxhr.status;
moduleName = "information.js gptLoader";
if (window.is24ExceptionLog) {
window.is24ExceptionLog(new Error(message), moduleName);
} else if (window.console && window.console.error) {
window.console.error(message + " - " + moduleName);
}
}
function mergeGlobalConfig(target, source) {
if (source) {
$.extend(true, target, source);
}
}
function objectSize(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
size++;
}
}
return size;
}
function hasAdvertisement(adNodes, adData) {
return (adNodes.length > 0 || objectSize(adData.slots) > 0 || adData.forceload);
}
function loadGptScript() {
if (!window.googletag || !window.googletag.defineSlot) {
$.ajax({
timeout: 6000,
dataType: "script",
cache: true,
url: adData.gptUrl
}).fail(onScriptFail);
}
}
function init() {
var adNodes = $(adSelector);
mergeGlobalConfig(adData, window.IS24.gptConfig);
if (hasAdvertisement(adNodes, adData)) {
adModules.krux();
loadGptScript();
adModules.gptSafeframeEnhancement();
adModules.gptConfigure(adData);
adModules.gptCreateSlotsFromNodes(adNodes, adData);
//OPENX_START
// this will only be called after valid bids are ready
// now do the remaining steps as they were done previously
if (typeof window.oxProcess === "function") {
window.oxProcess(function () {
//OPENX_END
adModules.gptAdd();
adModules.gptSetResponsiveAdHandler();
adModules.gptAddHandler.init();
//OPENX_START
});
} else {
//safety, -> call without OpenX in case something went wrong
adModules.gptAdd();
adModules.gptSetResponsiveAdHandler();
adModules.gptAddHandler.init();
}
//OPENX_END
}
}
init();
adModules.public.version = "1.17.5";
return adModules.public;
}());