-
Notifications
You must be signed in to change notification settings - Fork 2
/
headerTagWrapper.js
2 lines (2 loc) · 42.4 KB
/
headerTagWrapper.js
1
2
window.cygnus_index_args={name:"cygnus",embedMode:1,siteID:2,slots:[{siteID:2,width:300,height:250,id:"1"},{siteID:2,width:300,height:600,id:"2"},{siteID:2,width:320,height:50,id:"4"}],gpt_divs:{1:["5b21496d-f88d-c097-064c-4170d8e75d3c"],2:["d087513f-4233-054f-9355-ffb4266f6ad5"],4:["824b3a73-b1fd-1a50-481a-d2497c7b486a"]},targetMode:2},window.headertag.sizeRetargeting={},function(){"use strict";function e(){}function t(e,t){return function(){e.apply(t,arguments)}}function r(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],d(e,this)}function n(e,t){for(;3===e._state;)e=e._value;if(0===e._state)return void e._deferreds.push(t);e._handled=!0;var r=1===e._state?t.onFulfilled:t.onRejected;if(null===r)return void(1===e._state?o:i)(t.promise,e._value);var n;try{n=r(e._value)}catch(e){return void i(t.promise,e)}o(t.promise,n)}function o(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var o=n.then;if(n instanceof r)return e._state=3,e._value=n,void a(e);if("function"==typeof o)return void d(t(o,n),e)}e._state=1,e._value=n,a(e)}catch(t){i(e,t)}}function i(e,t){e._state=2,e._value=t,a(e)}function a(e){2===e._state&&0===e._deferreds.length&&(e._handled||r._unhandledRejectionFn(e._value));for(var t=0,o=e._deferreds.length;t<o;t++)n(e,e._deferreds[t]);e._deferreds=null}function s(e,t,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=r}function d(e,t){var r=!1;try{e(function(e){r||(r=!0,o(t,e))},function(e){r||(r=!0,i(t,e))})}catch(e){if(r)return;r=!0,i(t,e)}}r.prototype.catch=function(e){return this.then(null,e)},r.prototype.then=function(t,r){var o=new this.constructor(e);return n(this,new s(t,r,o)),o},r.all=function(e){var t=Array.prototype.slice.call(e);return new r(function(e,r){function n(i,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(e){n(i,e)},r)}t[i]=a,0===--o&&e(t)}catch(e){r(e)}}if(0===t.length)return e([]);for(var o=t.length,i=0;i<t.length;i++)n(i,t[i])})},r.resolve=function(e){return e&&"object"==typeof e&&e.constructor===r?e:new r(function(t){t(e)})},r.reject=function(e){return new r(function(t,r){r(e)})},r._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console},r.defer=function(){var e={};return e.promise=new r(function(t,r){e.resolve=t,e.reject=r}),e},window.headertag.Promise=r}(),function(){"use strict";function e(){function e(e,t){return e===t}function t(e){return"[object Object]"===Object.prototype.toString.call(e)}function r(e){return"[object Array]"===Object.prototype.toString.call(e)}function n(e){return"number"==typeof e}function o(e){return n(e)&&e%1===0}function i(e){return"string"==typeof e}function a(e){return"boolean"==typeof e}function s(e){return"function"==typeof e}function d(e){if(i(e)){if(""!==e)return!1}else if(t(e)){for(var n in e)if(e.hasOwnProperty(n))return!1}else if(r(e)&&e.length)return!1;return!0}function l(e,t,r){return!("number"==typeof t&&e<t)&&!("number"==typeof r&&e>r)}function c(t,r,n){n||(n=e);for(var o=0;o<t.length;o++){for(var i=!1,a=0;a<r.length&&!(i=n(t[o],r[a]));a++);if(!i)return!1}return!0}function u(e,t){return!!(t&&!e||e&&"string"==typeof e)}function p(e,t){return!!(t&&!e||e&&"function"==typeof e)}function g(e,t){return!!(t&&!e||e&&r(e)&&e.length)}function f(e,t){return!!(t&&!e||e&&"object"==typeof e&&!d(e))}function h(e,t,r,n){return!!(n&&"number"!=typeof e||"number"==typeof e&&o(e)&&("number"!=typeof t||e>=t)&&("number"!=typeof r||e<=r))}function m(e,t){return!!(t&&"boolean"!=typeof e||"boolean"==typeof e)}function y(){return window.googletag&&window.googletag.apiReady?googletag.pubads().getSlots().slice():null}function v(e){for(var t=y(),r=0,n=t.length;r<n;r++)if(t[r].getSlotElementId()===e)return t[r];return null}function S(e){e||(e=y());for(var t={},r=0,n=e.length;r<n;r++)t[e[r].getSlotElementId()]=e[r];return t}function w(e){e||(e=y());for(var t=[],r=0,n=e.length;r<n;r++)t.push(e[r].getSlotElementId());return t}function T(){return(new Date).getTime()}function I(){return navigator.userAgent.indexOf("Mobi")!==-1?"mobile":"desktop"}function b(){var e="CSS1Compat"===window.top.document.compatMode?window.top.document.documentElement:window.top.document.body;return e.clientWidth}function D(){var e="CSS1Compat"===window.top.document.compatMode?window.top.document.documentElement:window.top.document.body;return e.clientHeight}function x(e,t){return e=e||"http:",t=t||"https:","https:"===document.location.protocol?t:e}function E(){try{return window.top.location.href}catch(e){return window.location.href}}function R(e,t,r){var n=document.createElement("script");n.type="text/javascript",n.async=t,n.src=("https:"===document.location.protocol?"https:":"http:")+e,n.onload=r,n.readyState&&(n.onreadystatechange=function(){"loaded"!==n.readyState&&"complete"!==n.readyState||(n.onreadystatechange=null,r())});var o=document.getElementsByTagName("script")[0];return o.parentNode.insertBefore(n,o),n}function P(e){var t="?";for(var r in e)e.hasOwnProperty(r)&&(t+=r+"="+e[r]+"&");return t.slice(0,-1)}function O(){return"_"+String((new Date).getTime()%2592e6)+String(Math.floor(16384*Math.random()))}function _(e){return e.length?e.splice(Math.floor(Math.random()*e.length),1)[0]:null}return{isObject:t,isArray:r,isNumber:n,isInteger:o,isString:i,isBoolean:a,isFunction:s,isEmpty:d,isInRange:l,isArraySubset:c,validateNonEmptyString:u,validateFunction:p,validateNonEmptyArray:g,validateNonEmptyObject:f,validateInteger:h,validateBoolean:m,getGSlots:y,getSlots:y,divIdToGSlot:v,divIdToSlot:v,getDivIdToGSlotMap:S,getDivIdToSlotMap:S,getGSlotDivIds:w,getDivIds:w,now:T,getDeviceTypeByUserAgent:I,getViewportWidth:b,getViewportHeight:D,getProtocol:x,getPageUrl:E,addScriptTag:R,objToQueryString:P,generateCorrelator:O,randomSplice:_}}var t=e();window.headertag.Utilities=t,window.headertag.Utils=t}(),function(){"use strict";function e(e){function r(e){for(var t=["floor","inputCentsMultiplier","outputCentsDivisor","outputPrecision","roundingType"],r=0;r<t.length;r++){var n=t[r],o=s[n];"undefined"==typeof e[n]?a[n]=o:a[n]=e[n]}}function n(e){var t=a.floor;a.buckets=[];for(var r=0;r<e.length;r++){var n={};n.max=e[r].max,0!==a.roundingType&&(n.step=e[r].step),t=n.max,a.buckets.push(n)}}function o(e){return a.roundingType===d.FLOOR?Math.floor(e):a.roundingType===d.ROUND?Math.round(e):a.roundingType===d.CEIL?Math.ceil(e):e}function i(e){var r,n,i,s=a.floor,d=e;if(t.isEmpty(a))return e;if(d=Number(e),!t.isNumber(d)||Number.isNaN(d))throw new Error("INVALID_TYPE: `rawBid` must be a number");if(d<0)throw new Error("INVALID_VALUE: `rawBid` must be >= 0");if(d*=a.inputCentsMultiplier,i=a.buckets.length,d<a.floor)d=0;else if(d>=a.buckets[i-1].max)d=a.buckets[i-1].max;else{for(r=0;r<i&&(n=a.buckets[r],!(d<=n.max));r++)s=n.max;0!==a.roundingType&&(d-=s,d/=n.step,d=o(d),d*=n.step,d+=s)}return d/=a.outputCentsDivisor,d=a.outputPrecision<0?d.toString():d.toFixed(a.outputPrecision)}var a={},s={floor:0,inputCentsMultiplier:1,outputCentsDivisor:1,outputPrecision:-1,roundingType:0,buckets:[{max:1/0}]},d={NO_OP:0,FLOOR:1,ROUND:2,CEIL:3};return function(){return"undefined"==typeof e&&(e={}),t.isEmpty(e)?void(a={}):(r(e),void("undefined"==typeof e.roundingType&&"undefined"==typeof e.buckets?(a.roundingType=s.roundingType,a.buckets=s.buckets):n(e.buckets)))}(),{__type__:"BidRoundingTransformer",transformBid:i}}var t=window.headertag.Utilities;window.headertag.BidRoundingTransformer=e}(),function(){"use strict";function e(){function e(){return a}function r(e){var r="";for(var n in e)if(e.hasOwnProperty(n))if(t.isArray(e[n]))for(var o=0;o<e[n].length;o++)r+=n+"[]="+encodeURIComponent(e[n][o])+"&";else r+=n+"="+encodeURIComponent(e[n])+"&";return r.slice(0,-1)}function n(e,t,r){return"/"!==e[e.length-1]&&t&&(e+="/"),t=t||[],r=r?"?"+r:"",e+t.join("/")+r}function o(e){var o=null,i=document.createElement("script");i.type="text/javascript";var a=!0;e.hasOwnProperty("async")&&(a=e.async),i.async=a;var s=e.url;if(e.data){var d;d=t.validateNonEmptyString(e.data)?e.data:r(e.data),s=n(e.url,null,d)}i.src=s;var l,c=!1;if(e.timeout&&(l=setTimeout(function(){try{c=!0,e.onTimeout&&e.onTimeout()}catch(e){}},e.timeout)),e.onSuccess){var u=function(){try{if(c){if(!e.continueAfterTimeout)return}else clearTimeout(l);e.onSuccess(null,t.now(),c),i.parentNode.removeChild(i)}catch(e){}};null===i.onload?i.onload=u:i.onreadystatechange=function(){"loaded"!==i.readyState&&"complete"!==i.readyState||(i.onreadystatechange=null,u())}}var p=document.getElementsByTagName("script")[0];return o=t.now(),p.parentNode.insertBefore(i,p),o}function i(i){if(!e()){if(i.jsonp)return o(i);throw new Error("INTERNAL_ERROR: XHR is not supported in this browser.")}var a=null,s=new XMLHttpRequest,d=i.url,l=null;if(i.data)if("GET"===i.method){var c;c=t.validateNonEmptyString(i.data)?i.data:r(i.data),d=n(i.url,null,c)}else"POST"===i.method&&(l=t.validateNonEmptyString(i.data)?i.data:JSON.stringify(i.data));var u=!0;i.hasOwnProperty("async")&&(u=i.async),s.open(i.method,d,u);var p="application/x-www-form-urlencoded; charset=UTF-8";if("undefined"!=typeof i.contentType&&(p=i.contentType),p&&s.setRequestHeader("Content-Type",p),i.headers){i.headers.hasOwnProperty("X-Request-With")||s.setRequestHeader("X-Request-With","XMLHttpRequest");for(var g in i.headers)i.headers.hasOwnProperty(g)&&s.setRequestHeader(g,i.headers[g])}i.withCredentials&&(s.withCredentials=!0);var f,h=!1;return i.continueAfterTimeout?i.timeout&&(f=setTimeout(function(){try{h=!0,i.onTimeout&&i.onTimeout()}catch(e){}},i.timeout)):(i.timeout&&(s.timeout=i.timeout),i.onTimeout&&(s.ontimeout=function(){try{i.onTimeout()}catch(e){}})),(i.onSuccess||i.onFailure)&&(s.onreadystatechange=function(){if(4===s.readyState)if(h||clearTimeout(f),200===s.status){if(i.onSuccess)try{i.onSuccess(s.responseText,t.now(),h)}catch(e){}}else if(i.onFailure)try{i.onFailure(s.status)}catch(e){}}),a=t.now(),s.send(l),a}var a;return function(){a=window.XMLHttpRequest&&"string"==typeof(new XMLHttpRequest).responseType}(),{__type__:"Network",ajax:i,jsonp:o,buildUrl:n,objToQueryString:r,isXhrSupported:e}}var t=window.headertag.Utilities;window.headertag.Network=e()}(),function(){"use strict";function e(e){function n(e){l[e]=l[e]||{},l[e].startTime=r.now()}function o(e){l.hasOwnProperty(e)&&(l[e].stopTime=r.now())}function i(e,t,n){l[e].partners=l[e].partners||{},l[e].partners[t]=l[e].partners[t]||{},l[e].partners[t].timeout=n,l[e].partners[t].startTime=r.now()}function a(e,t){l.hasOwnProperty(e)&&(l[e].partners[t].stopTime=r.now())}function s(e,t,r,n){l.hasOwnProperty(e)&&(l[e].partners[t].targetingType=r,l[e].partners[t].returnedDemand=n)}function d(n){if(l.hasOwnProperty(n)){var o={};o.s=e,o.u=encodeURIComponent(document.location.href),o.type="RT",o.r=n.replace("_",""),o.t0=l[n].startTime,o.t1=l[n].stopTime||-1;var i=l[n].partners;for(var a in i)if(i.hasOwnProperty(a)){var s=-1,d=1;i[a].startTime&&i[a].stopTime&&(s=i[a].stopTime-i[a].startTime,d=0),o[a+".t"]=s,o[a+".to"]=d,o[a+".ts"]=i[a].timeout||-1;var c=null;if(i[a].hasOwnProperty("returnedDemand"))if("page"===i[a].targetingType)for(c in i[a].returnedDemand.page.demand)i[a].returnedDemand.page.demand.hasOwnProperty(c)&&(o[a+".p.pl."+c]=i[a].returnedDemand.page.demand[c].toString()||"");else for(var u in i[a].returnedDemand.slot)if(i[a].returnedDemand.slot.hasOwnProperty(u))for(c in i[a].returnedDemand.slot[u].demand)i[a].returnedDemand.slot[u].demand.hasOwnProperty(c)&&(o[a+".p."+u+"."+c]=i[a].returnedDemand.slot[u].demand[c].toString()||"")}t.ajax({async:!0,data:o,jsonp:!0,method:"GET",url:r.getProtocol("http://as","https://as-sec")+".casalemedia.com/headerstats"}),delete l[n]}}var l={};this.startSessionTimer=n,this.stopSessionTimer=o,this.startPartnerTimer=i,this.stopPartnerTimer=a,this.recordReturnedDemand=s,this.sendReport=d}var t=window.headertag.Network,r=window.headertag.Utilities;window.headertag.HeaderStats=e}(),function(){"use strict";function e(e,t){function r(e,t){return Number(e)-Number(t)}function n(){return g}function o(){return f}function i(e,t){var n,o,i,a,s=[];n=Object.keys(y).sort(r);for(var d=n.length-1;d>=0;d--)if(i=n[d],!(Number(i)>e)){o=Object.keys(y[i]).sort(r);for(var l=o.length-1;l>=0;l--)if(a=o[l],!(Number(a)>t)){s=y[i][a];break}if(s.length>0)break}return s}function a(){return v}function s(){return S}function d(){return w}function l(){return T}function c(){return h}function u(){return m}function p(e){I=e}var g,f,h,m,y,v,S,w,T,I;return function(){g=e,t.hasOwnProperty("divId")&&(f=t.divId);var r,n,o,i=/^(\d+)x(\d+)$/;y={};for(var a in t.sizeMapping)t.sizeMapping.hasOwnProperty(a)&&(r=i.exec(a),n=r[1],o=r[2],y.hasOwnProperty(n)||(y[n]={}),y[n][o]=t.sizeMapping[a]);t.hasOwnProperty("targeting")&&(v=t.targeting),t.hasOwnProperty("deviceType")&&(S=t.deviceType),t.hasOwnProperty("adUnitPath")&&(w=t.adUnitPath),t.hasOwnProperty("adUnitPathRegEx")&&(T=new RegExp(t.adUnitPathRegEx)),t.hasOwnProperty("divIdRegEx")&&(h=new RegExp(t.divIdRegEx)),t.hasOwnProperty("divIdRegExBySize")&&(m=new RegExp(t.divIdRegExBySize))}(),{getId:n,getSlotElementId:n,getDivId:o,getSizes:i,getTargeting:a,getDeviceType:s,getAdUnitPath:d,getDivIdRegEx:c,getDivIdRegExBySize:u,getAdUnitPathRegEx:l,setGSlotRef:p}}var t=window.headertag.Utilities;e.__isObjectSubset=function(e,r){for(var n in e)if(e.hasOwnProperty(n)){if("!"===n[0]){var o=n.substring(1);if(r.hasOwnProperty(o)){if(1===e[n].length&&"*"===e[n][0])return!1;for(var i=0;i<e[n].length;i++){var a=[e[n][i]];if(t.isArraySubset(a,r[o]))return!1}continue}}if(!r.hasOwnProperty(n))return!1;if((1!==e[n].length||"*"!==e[n][0])&&!t.isArraySubset(e[n],r[n]))return!1}return!0},e.__matcher=function(e,t){return e[0]===t[0]&&e[1]===t[1]},e.__getGSlotSizes=function(e,t,r){var n=[],o=e.getSizes(t,r);if(!o)return[];for(var i=0;i<o.length;i++)"fluid"!==o[i]&&n.push([o[i].getWidth(),o[i].getHeight()]);return n},e.__getGSlotTargeting=function(e){for(var t={},r=e.getTargetingKeys(),n=0;n<r.length;n++)t[r[n]]=e.getTargeting(r[n]);return t},e.selectByStaticDivId=function(e,t){for(var r={selectedHtSlots:[],htSlotToGSlotMap:{}},n=t.length-1;n>=0;n--)for(var o=t[n],i=e.length-1;i>=0;i--){var a=e[i];if(a.getDivId()&&a.getDivId()===o.getSlotElementId()){t.splice(n,1),e.splice(i,1),r.selectedHtSlots.push(a),r.htSlotToGSlotMap[a.getSlotElementId()]=o.getSlotElementId();break}}return r},e.selectByDivIdRegExBySize=function(r,n){for(var o={selectedHtSlots:[],htSlotToGSlotMap:{}},i=t.getViewportWidth(),a=t.getViewportHeight(),s=n.length-1;s>=0;s--){for(var d=n[s],l={selectedHtSlot:null,selectedHtSlotIndex:0,sizeMatchScore:0},c=r.length-1;c>=0;c--){var u=r[c];if(u.getDivIdRegExBySize()&&u.getDivIdRegExBySize().test(d.getSlotElementId())){var p=u.getSizes(i,a);if(p){var g=e.__getGSlotSizes(d,i,a);if(t.isArraySubset(p,g,e.__matcher)){var f=p.length/g.length;f>=l.sizeMatchScore&&(l.sizeMatchScore=f,l.selectedHtSlot=u,l.selectedHtSlotIndex=c)}}}}l.selectedHtSlot&&(n.splice(s,1),r.splice(l.selectedHtSlotIndex,1),o.selectedHtSlots.push(l.selectedHtSlot),o.htSlotToGSlotMap[l.selectedHtSlot.getSlotElementId()]=d.getSlotElementId())}return o},e.selectByDivIdRegEx=function(e,t){for(var r={selectedHtSlots:[],htSlotToGSlotMap:{}},n=t.length-1;n>=0;n--)for(var o=t[n],i=e.length-1;i>=0;i--){var a=e[i];if(a.getDivIdRegEx()&&a.getDivIdRegEx().test(o.getSlotElementId())){t.splice(n,1),e.splice(i,1),r.selectedHtSlots.push(a),r.htSlotToGSlotMap[a.getSlotElementId()]=o.getSlotElementId();break}}return r},e.selectByCustomKeyValue=function(r,n){for(var o={selectedHtSlots:[],htSlotToGSlotMap:{}},i=t.getViewportWidth(),a=t.getViewportHeight(),s=n.length-1;s>=0;s--){for(var d=n[s],l={selectedHtSlot:null,selectedHtSlotIndex:0,sizeMatchScore:0,targetingMatchScore:0},c=0;c<r.length;c++){var u=r[c],p=u.getSizes(i,a);if(p){var g=e.__getGSlotSizes(d,i,a);if(t.isArraySubset(p,g,e.__matcher)){var f=p.length/g.length;if(!(f<l.sizeMatchScore)){var h=u.getTargeting();if(h){for(var m=e.__getGSlotTargeting(d),y=!1,v=0,S=0;S<h.length;S++)if(h[S])if(t.validateNonEmptyObject(h[S])){if(e.__isObjectSubset(h[S],m)){var w=0;for(var T in h[S])h[S].hasOwnProperty(T)&&(w+=h[S][T].length);v=Math.max(v,w)}}else y=!0;if(y||0!==v)if(f>l.sizeMatchScore)l.sizeMatchScore=f,l.targetingMatchScore=v,l.selectedHtSlot=u,l.selectedHtSlotIndex=c;else if(f===l.sizeMatchScore){if(v<=l.targetingMatchScore)continue;l.sizeMatchScore=f,l.targetingMatchScore=v,l.selectedHtSlot=u,l.selectedHtSlotIndex=c}}}}}}l.selectedHtSlot&&(n.splice(s,1),r.splice(l.selectedHtSlotIndex,1),o.selectedHtSlots.push(l.selectedHtSlot),o.htSlotToGSlotMap[l.selectedHtSlot.getSlotElementId()]=d.getSlotElementId())}return o},e.selectByAdUnitPath=function(r,n){for(var o={selectedHtSlots:[],htSlotToGSlotMap:{}},i=t.getViewportWidth(),a=t.getViewportHeight(),s=n.length-1;s>=0;s--)for(var d=n[s],l=r.length-1;l>=0;l--){var c=r[l],u=c.getAdUnitPath();if(u&&d.getAdUnitPath()===u){var p=c.getSizes(i,a);if(p){var g=e.__getGSlotSizes(d,i,a);if(t.isArraySubset(p,g,e.__matcher)){n.splice(s,1),r.splice(l,1),o.selectedHtSlots.push(c),o.htSlotToGSlotMap[c.getSlotElementId()]=d.getSlotElementId();break}}}}return o},e.selectByAdUnitPathRegEx=function(r,n){for(var o={selectedHtSlots:[],htSlotToGSlotMap:{}},i=t.getViewportWidth(),a=t.getViewportHeight(),s=n.length-1;s>=0;s--)for(var d=n[s],l=r.length-1;l>=0;l--){var c=r[l],u=c.getAdUnitPathRegEx();if(u&&u.test(d.getAdUnitPath())){var p=c.getSizes(i,a);if(p){var g=e.__getGSlotSizes(d,i,a);if(t.isArraySubset(p,g,e.__matcher)){n.splice(s,1),r.splice(l,1),o.selectedHtSlots.push(c),o.htSlotToGSlotMap[c.getSlotElementId()]=d.getSlotElementId();break}}}}return o},window.headertag.HeaderTagSlot=e}(),window.headertag.partnerScopes.push(function(){"use strict";function validateTargetingType(e){return"string"==typeof e&&SUPPORTED_TARGETING_TYPES[e]}function getKeys(e){var t=[];for(var r in e)e.hasOwnProperty(r)&&t.push(r);return t}function arrayCompare(e,t){var r,n,o={matched:0,success:!1};if(!e||!t)return o;for(r=e.length,n=0;n<r;n++){if(t.indexOf(e[n])===-1)return o;o.matched++}return o.success=!0,o}function retrieveIndexSlot(e,t,r){var n,o,i,a,s,d,l,c={};for(s in t)if(!r[s]){a=t[s],n=0,i=0,o=0;for(d in a)n++,l=arrayCompare(a[d],e[d]),l.success&&(o++,i+=l.matched);n===o&&(c.indexId||(c={matched:i,indexId:s}),i>c.matched&&(c.matched=i,c.indexId=s))}return c.indexId}function mapSlots(e){var t,r,n,o=headerTagArgs.gptDivs,i=e.length,a={};if(o)for(n=0;n<i;n++){r=e[n].getSlotElementId();for(t in o)o[t].indexOf(r)!==-1&&(a[t]||(a[t]=[]),a[t].push(r))}return a}function convertSlotDemandObject(e,t){if("slot"===targetingType)return e;var r,n,o={page:{slotIds:[],gCorrelator:t,demand:{}}};for(r in e.slot){o.page.slotIds.push(r),o.page.timestamp?o.page.timestamp=Math.min(o.page.timestamp,e.slot[r].timestamp):o.page.timestamp=e.slot[r].timestamp;for(n in e.slot[r].demand)o.page.demand[n]=o.page.demand[n]||[],o.page.demand[n]=o.page.demand[n].concat(e.slot[r].demand[n])}return o}function getAdSize(e){if(headerTagArgs&&headerTagArgs.slots)for(var t=0;t<headerTagArgs.slots.length;t++){var r=headerTagArgs.slots[t];if(r.id&&r.id===e&&r.width&&r.height)return r.width+"x"+r.height}return""}function parseResults(e,t,r){var n,o,i,a,s,d,l=[],c={slot:{}};if(t){prefetch.demand=JSON.parse(JSON.stringify(indexDemandList)),prefetch.state=prefetchState.READY,prefetch.analyticsCallback(prefetch.correlator);for(var u=0,p=prefetch.callbacks.length;u<p;u++)setTimeout(prefetch.callbacks[u],0);return void(prefetch.timestamp=Utils.now())}if(r?(n=prefetch.correlator,a=prefetch.demand,d=mapSlots(r)):(n=correlatorTracker[e],a=indexDemandList,d=ixSlots[n]),(r||dSlots[n]).map(function(e){for(i=e.getSlotElementId(),adId++,o=0;o<a.length;o++)if(s=a[o].split("_"),"undefined"!=typeof d[s[1]]&&d[s[1]].indexOf(i)!==-1)if(r&&l.push(prefetch.demand[o]),c.slot[i]||(c.slot[i]={timestamp:prefetch.timestamp||Utils.now(),demand:{}}),c.slot[i].demand[s[0]]||(c.slot[i].demand[s[0]]=[]),targetingMode===TARGETING_MODE.STANDARD||targetingMode===TARGETING_MODE.ADVANCED){var t=s[0],n=s[1],u=s[2],p="",g=i+"_"+adId,f=getAdSize(n),h=s.slice(1).join("_");c.slot[i].demand[t].push(f+"_"+u),t===headerTagPrivateKey&&(p=s.slice(3).join("_"),c.slot[i].demand[headerTagPrivateIdKey]||(c.slot[i].demand[headerTagPrivateIdKey]=[]),c.slot[i].demand[headerTagPrivateIdKey].push(f+"_"+p)),c.slot[i].demand[headerTagIdKey]||(c.slot[i].demand[headerTagIdKey]=[g]),targetIDMap[g]||(targetIDMap[g]={}),targetIDMap[g][f]=h}else c.slot[i].demand[s[0]].push(s[1]+"_"+s[2])}),r){var g;for(var f in d)if(d.hasOwnProperty(f)&&prefetch.slotIds.indexOf(f)!==-1){for(o=0;o<d[f].length;o++)c.slot[d[f][o]]||(c.slot[d[f][o]]={timestamp:prefetch.timestamp,demand:{}});g=prefetch.slotIds.indexOf(f),g!==-1&&prefetch.slotIds.splice(g,1)}for(demandStore=c,o=prefetch.demand.length-1;o>=0;o--)l.indexOf(prefetch.demand[o])!==-1&&prefetch.demand.splice(o,1)}else"function"==typeof cb[n]&&(cb[n](null,c),delete cb[n]),delete correlatorTracker[e],delete ixSlots[n],delete dSlots[n]}function escapeCharacter(e){var t=META[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}function quote(e){return ESCAPABLE.lastIndex=0,ESCAPABLE.test(e)?e.replace(ESCAPABLE,escapeCharacter):e}function OpenRTBRequest(e,t){if("number"!=typeof e||e%1!==0||e<0)throw"Invalid Site ID";this.siteID=e,this.impressions=[],top===self?(this.sitePage=location.href,this.topframe=1):(this.sitePage=document.referrer,this.topframe=0),"undefined"==typeof indexRequestData.requestCounter?indexRequestData.requestCounter=Math.floor(256*Math.random()):indexRequestData.requestCounter=(indexRequestData.requestCounter+1)%256,this.requestID=String((new Date).getTime()%2592e3*256+indexRequestData.requestCounter+256),correlatorTracker[this.requestID]=t}function cygnus_index_judge(e){indexDemandList=[];var t,r={},n="^(?:"+headerTagPublicKey+"|"+headerTagPrivateKey+")_(?:T([0-9])_)?(.*)_.*$",o=new RegExp(n),i=[];for(t=0;t<e.length;t++)if(e[t].split("_")[0]!==headerTagPrivateKey){var a=o.exec(e[t]);if("undefined"!=typeof a&&null!==a){var s,d;if(s=a[1],d=a[2],"undefined"!=typeof s&&null!==s||(s=0),r[d]=r[d]||{},"undefined"==typeof r[d].tier||r[d].tier<s){r[d].tier=s;var l=e[t];if(s>0){var c=e[t].split("_"),u=c.shift(),p=c.join("_");c.shift();var g=c.join("_");l=u+"_"+g,indexRequestData.targetIDToBid[g]=indexRequestData.targetIDToBid[p]}r[d].target=l}}}else i.push(e[t]);var f,h=[];for(f in r)r.hasOwnProperty(f)&&h.push(r[f].target);return h.concat(i)}function Partner(e){function t(e,t){if(Utils.isEmpty(e))return t;if(Utils.isEmpty(t))return e;var r,n;for(r in t.slot)if("undefined"==typeof e.slot[r])e.slot[r]=t.slot[r];else{e.slot[r].timestamp=Math.min(e.slot[r].timestamp,t.slot[r].timestamp);for(n in t.slot[r].demand){switch(typeof e.slot[r].demand[n]){case"undefined":e.slot[r].demand[n]=[];break;case"string":e.slot[r].demand[n]=[e.slot[r].demand[n]]}e.slot[r].demand[n]=e.slot[r].demand[n].concat(t.slot[r].demand[n])}}return e}function r(e,t){var r,n,o,i;try{if("undefined"==typeof headerTagArgs||"undefined"==typeof headerTagArgs.siteID||"undefined"==typeof headerTagArgs.slots)return;for("undefined"==typeof indexRequestData&&(indexRequestData={},indexRequestData.impIDToSlotID={},indexRequestData.reqOptions={}),o=new OpenRTBRequest(headerTagArgs.siteID,e),headerTagArgs.url&&"string"==typeof headerTagArgs.url&&o.setPageOverride(headerTagArgs.url),indexRequestData.impIDToSlotID[o.requestID]={},indexRequestData.reqOptions[o.requestID]={},r=0;r<headerTagArgs.slots.length;r++)i=headerTagArgs.slots[r],t.indexOf(i.id.toString())!==-1&&(n=o.addImpression(i.width,i.height,i.bidfloor,i.bidfloorcur,i.id,i.siteID),n&&(indexRequestData.impIDToSlotID[o.requestID][n]=String(i.id)));return"number"==typeof headerTagArgs.targetMode&&(indexRequestData.reqOptions[o.requestID].targetMode=headerTagArgs.targetMode),"function"==typeof headerTagArgs.callback&&(indexRequestData.reqOptions[o.requestID].callback=headerTagArgs.callback),o.sendRequestAsync(e,e===prefetch.correlator)}catch(e){}}function n(e){var t=[],r=e.divIds;for(var n in headerTagArgs.gptDivs)headerTagArgs.gptDivs.hasOwnProperty(n)&&(1!==headerTagArgs.gptDivs[n].length,r.indexOf(headerTagArgs.gptDivs[n][0])!==-1&&t.push(n));return t}var o=this,i=e.usermatch||!1;if(i){var a=document.createElement("iframe");a.src=("https:"==document.location.protocol?"https://ssum-sec":"http://ssum")+".casalemedia.com/usermatch?s=184674&cb=https%3A%2F%2Fjs-sec.indexww.com%2Fht%2Fhtw-pixel.gif%3F",a.style.display="none";var s=function(){document.body.appendChild(a)};window.addEventListener?window.addEventListener("load",s):window.attachEvent("onload",s)}targetingType=e.targetingType||"slot",targetingMode=e.targetingMode||TARGETING_MODE.LEGACY,headerTagArgs={gptDivs:cygnus_index_args.gpt_divs,siteID:cygnus_index_args.siteID,slots:cygnus_index_args.slots,url:cygnus_index_args.url,targetMode:cygnus_index_args.targetMode,callback:cygnus_index_args.callback},targetIDMap={},adId=0,cygnus_index_args=void 0;var d=e.targetingType,l=SUPPORTED_ANALYTICS,c=SUPPORTED_OPTIONS,u=SUPPORTED_OPTIONS.demandExpiry?SUPPORTED_OPTIONS.demandExpiry:-1;this.publicKey=e.publicKey||"IOM",this.privateKey=e.privateKey||"IPM",this.privateIdKey=e.privateIdKey||"IPMID",this.idKey=e.idKey||"ix_id",headerTagPrivateKey=this.privateKey,headerTagPublicKey=this.publicKey,headerTagPrivateIdKey=this.privateIdKey,headerTagIdKey=this.idKey,this.getPartnerTargetingType=function(){return d},this.getSupportedAnalytics=function(){return l},this.getSupportedOptions=function(){return c},this.getPartnerDemandExpiry=function(){return u},this.setPartnerTargetingType=function(e){return!!validateTargetingType(e)&&(d=e,targetingType=d,!0)},this.prefetchDemand=function(t,o,i){prefetch.state=prefetchState.IN_PROGRESS,prefetch.correlator=t,e.prefetch?("page"===targetingType&&(prefetch.gCorrelator=o),this.prefetchIndexSlotIds=e.prefetch.info[window.headertag.pagetype].requiredIndexSlots):"page"===targetingType?(prefetch.gCorrelator=o.gCorrelator,this.prefetchIndexSlotIds=n(o.htSlots)):this.prefetchIndexSlotIds=n(o),prefetch.slotIds=this.prefetchIndexSlotIds.slice(),prefetch.slotIdsInPrefetch=this.prefetchIndexSlotIds.slice(),prefetch.analyticsCallback=i,r(t,this.prefetchIndexSlotIds)},this.getDemand=function e(n,i,a){var s;if("page"===targetingType&&(i.htSlots?(s=i.gCorrelator,i=i.htSlots):(s=i,i=Utils.getSlots())),prefetch.state===prefetchState.IN_PROGRESS){for(var d=getKeys(mapSlots(i)),l=!1,u=0,p=d.length;u<p;u++){var g=prefetch.slotIdsInPrefetch.indexOf(d[u]);g!==-1&&(prefetch.slotIdsInPrefetch.splice(g,1),l=!0)}if(l)return void prefetch.callbacks.push(e.bind(o,n,i,a))}var f={};if(prefetch.state===prefetchState.READY&&(prefetch.demand&&prefetch.demand.length>0&&prefetch.slotIds.length&&parseResults(null,!1,i),demandStore.slot)){f.slot=f.slot||{};for(var h=i.length-1;h>=0;h--){var m=i[h].getSlotElementId();if(demandStore.slot.hasOwnProperty(m)){if((c.demandExpiry<0||Utils.now()-demandStore.slot[m].timestamp<=c.demandExpiry)&&(f.slot[m]=demandStore.slot[m],i.splice(h,1)),"page"===targetingType&&s===prefetch.gCorrelator)continue;delete demandStore.slot[m]}}if(prefetch.timestamp&&Utils.now()-prefetch.timestamp>c.demandExpiry&&(prefetch.slotIds=[],prefetch.demand=[],delete prefetch.timestamp),Utils.validateNonEmptyObject(demandStore.slot)||prefetch.slotIds.length||(prefetch.state=prefetchState.USED,delete prefetch.timestamp),!i.length)return void a(null,convertSlotDemandObject(f,s))}cb[n]=function(e,r){return e?void a(e):void a(null,convertSlotDemandObject(t(f,r),s))},dSlots[n]=i,ixSlots[n]=mapSlots(i);var y=getKeys(ixSlots[n]);return y.length?void r(n,y):a(null,convertSlotDemandObject(f))}}function init(e,t){var r=[];return Utils=window.headertag.Utils,e.hasOwnProperty("targetingType")&&!validateTargetingType(e.targetingType)&&(r.push("targetingType either not set or invalid. Defaulting to using slot level targeting."),e.targetingType="slot"),e.hasOwnProperty("publicKey")&&!Utils.validateNonEmptyString(e.publicKey)&&(r.push("Private key is not a string. Defaulting value to IOM"),e.publicKey="IOM"),e.hasOwnProperty("privateKey")&&!Utils.validateNonEmptyString(e.privateKey)&&(r.push("Private key is not a string. Defaulting value to IPM"),e.privateKey="IPM"),e.hasOwnProperty("privateIdKey")&&!Utils.validateNonEmptyString(e.privateIdKey)&&r.push("Private ID key is not a string"),e.hasOwnProperty("idKey")&&!Utils.validateNonEmptyString(e.idKey)&&r.push("ID key is not a string"),e.hasOwnProperty("targetingMode")&&(Utils.validateNonEmptyString(e.targetingMode)?e.targetingMode!==TARGETING_MODE.LEGACY&&e.targetingMode!==TARGETING_MODE.STANDARD&&e.targetingMode!==TARGETING_MODE.ADVANCED&&r.push("Targeting Mode is not a supported value"):r.push("Targeting Mode is not a string")),e.hasOwnProperty("usermatch")&&(Utils.isBoolean(e.usermatch)||r.push("Usermatch is not a valid boolean")),r.length?t(r,new Partner(e)):void t(null,new Partner(e))}var PARTNER_ID="INDX",SUPPORTED_TARGETING_TYPES={page:!0,slot:!0},SUPPORTED_ANALYTICS={time:!0,demand:!0},SUPPORTED_OPTIONS={prefetch:!0,demandExpiry:5e4},prefetchState={NEW:1,IN_PROGRESS:2,READY:3,USED:4},TARGETING_MODE={LEGACY:"legacy",STANDARD:"standard",ADVANCED:"advanced"},prefetch={state:prefetchState.NEW,demand:null,correlator:null,slotIds:[],callbacks:[]},Network=window.headertag.Network,demandStore={},headerTagArgs,indexDemandList,headerTagPublicKey,headerTagPrivateKey,headerTagPrivateIdKey,headerTagIdKey,targetingMode,targetIDMap,adId,cb={},correlatorTracker={},ESCAPABLE=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,META={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},indexRequestData,dSlots={},ixSlots={},targetingType,Utils,demandExpiry=15e3;OpenRTBRequest.prototype.serialize=function(){var e,t,r,n='{"id":'+this.requestID+',"site":{"page":"'+quote(this.sitePage)+'"';for("string"==typeof document.referrer&&(n+=',"ref":"'+quote(document.referrer)+'"'),n+='},"imp":[',r=0;r<this.impressions.length;r++)e=this.impressions[r],t=[],n+='{"id":"'+e.id+'", "banner":{"w":'+e.w+',"h":'+e.h+',"topframe":'+String(this.topframe)+"}","number"==typeof e.bidfloor&&(n+=',"bidfloor":'+e.bidfloor,"string"==typeof e.bidfloorcur&&(n+=',"bidfloorcur":"'+quote(e.bidfloorcur)+'"')),"string"!=typeof e.slotID||e.slotID.match(/^\s*$/)||t.push('"sid":"'+quote(e.slotID)+'"'),"number"==typeof e.siteID&&t.push('"siteID":'+e.siteID),t.length>0&&(n+=',"ext": {'+t.join()+"}"),n+=r+1==this.impressions.length?"}":"},";return n+="]}"},OpenRTBRequest.prototype.addImpression=function(e,t,r,n,o,i){var a={id:String(this.impressions.length+1)};if("number"!=typeof e||e<=1)return null;if("number"!=typeof t||t<=1)return null;
if(("string"==typeof o||"number"==typeof o)&&String(o).length<=50&&(a.slotID=String(o)),a.w=e,a.h=t,void 0!==r&&"number"!=typeof r)return null;if("number"==typeof r){if(r<0)return null;if(a.bidfloor=r,void 0!==n&&"string"!=typeof n)return null;a.bidfloorcur=n}if("undefined"!=typeof i){if(!("number"==typeof i&&i%1===0&&i>=0))return null;a.siteID=i}return this.impressions.push(a),a.id},OpenRTBRequest.prototype.sendRequestAsync=function(correlator,isPrefetch){if(0===this.impressions.length)return void(cb.hasOwnProperty(correlator)&&(cb[correlator](null,{}),delete cb[correlator]));var jsonURI=encodeURIComponent(this.serialize()),scriptSrc="https:"===window.location.protocol?"https://as-sec.casalemedia.com":"http://sandbox.ht.indexexchange.com";scriptSrc+="/cygnus?v=7&fn=headertag_parse&s="+this.siteID+"&r="+jsonURI,Network.ajax({url:scriptSrc,method:"GET",partnerId:"INDX",jsonp:!0,withCredentials:!0,onSuccess:function(responseText){responseText&&eval(responseText)},onFailure:function(){cb.hasOwnProperty(correlator)&&(cb[correlator](["Unable to get demand from cygnus"]),delete cb[correlator])}})},window.headertag_parse=function(e){function t(e,t){indexDemandList.push(e+t),void 0===indexRequestData.targetIDToBid[t]?(indexRequestData.targetIDToBid[t]=[i.adm],indexRequestData.correlator[t]=[r]):(indexRequestData.targetIDToBid[t].push(i.adm),indexRequestData.correlator[t].push(r)),l={},l.impressionID=i.impid,"undefined"!=typeof i.ext.dealid&&(l.dealID=i.ext.dealid),l.bid=i.price,l.slotID=a,l.priceLevel=i.ext.pricelevel,l.target=e+t,p.push(l)}var r;try{if(indexDemandList=[],e){if("object"!=typeof indexRequestData||"object"!=typeof indexRequestData.impIDToSlotID||"undefined"==typeof indexRequestData.impIDToSlotID[e.id])return;var n,o=0;"object"==typeof indexRequestData.reqOptions&&"object"==typeof indexRequestData.reqOptions[e.id]&&("function"==typeof indexRequestData.reqOptions[e.id].callback&&(n=indexRequestData.reqOptions[e.id].callback),"number"==typeof indexRequestData.reqOptions[e.id].targetMode&&(o=indexRequestData.reqOptions[e.id].targetMode)),indexRequestData.lastRequestID=e.id,r=correlatorTracker[e.id];var i,a,s,d,l,c,u,p=[],g="undefined"==typeof e.seatbid?0:e.seatbid.length;for(c=0;c<g;c++)for(u=0;u<e.seatbid[c].bid.length;u++)i=e.seatbid[c].bid[u],"object"==typeof i.ext&&"string"==typeof i.ext.pricelevel&&"undefined"!=typeof indexRequestData.impIDToSlotID[e.id][i.impid]&&(a=indexRequestData.impIDToSlotID[e.id][i.impid],"undefined"==typeof indexDemandList&&(indexDemandList=[]),"undefined"==typeof indexRequestData.targetIDToBid&&(indexRequestData.targetIDToBid={}),"undefined"==typeof indexRequestData.correlator&&(indexRequestData.correlator={}),"string"==typeof i.ext.dealid?(d=headerTagPrivateKey+"_",targetingMode===TARGETING_MODE.STANDARD||targetingMode===TARGETING_MODE.ADVANCED?(s=a+i.ext.pricelevel+"_"+i.ext.dealid,t(d,s)):1===o?(s=a+i.ext.pricelevel,t(d,s)):2===o?(s=a+i.ext.pricelevel,t(d,s),s=a+"_"+i.ext.dealid,t(d,s)):(s=a+"_"+i.ext.dealid,t(d,s))):(d=headerTagPublicKey+"_",s=a+i.ext.pricelevel,t(d,s)));"function"==typeof n&&(0===p.length?n(e.id):n(e.id,p)),indexDemandList=cygnus_index_judge(indexDemandList.slice(0))}}catch(e){}"undefined"==typeof indexDemandList&&(indexDemandList=[]),parseResults(e.id,correlatorTracker[e.id]===prefetch.correlator)},window.index_render=function(e,t){var r,n,o,i,a,s,d;"undefined"==typeof index_demand&&(window.index_demand={}),d=t.split("_"),r=d[0];try{if(n=indexRequestData.targetIDToBid[t].shift(),"undefined"!=typeof n&&null!==n)e.write(n),index_demand[r]=1,delete index_no_demand[r];else{for(o={},j=0;j<headerTagArgs.slots.length;j++)if(headerTagArgs.slot[j].id===r){o.s=headerTagArgs.slot[j].siteID;break}o.hasOwnProperty("s")||(o.s=0),o.u=encodeURIComponent(location.href),o.type="RT",o.r=correlator,o.blank="["+t+"]",i=Utils.objToQueryString(o),a=("https:"===location.protocol?"https://as-sec.":"http://as.")+"casalemedia.com/headerstats"+i,s=new XMLHttpRequest,s.open("GET",a,!0),s.send()}}catch(e){}},window.headertag_render=function(e,t,r){var n,o,i=r,a=t.split(",");for(n=0;n<a.length;n++)if(o=a[n].split("_"),o[0]==i)return void window.index_render(e,a[n])},window.headertag.IxModule=window.headertag.IxModule||{},window.headertag.IxModule.render=function(e,t,r,n){if(e&&t&&r&&n)try{var o=t[headerTagIdKey],i=targetIDMap[o][r+"x"+n];window.index_render(e,i),e.close(),targetingMode===TARGETING_MODE.ADVANCED&&e.defaultView&&e.defaultView.frameElement&&(e.defaultView.frameElement.width=r,e.defaultView.frameElement.height=n)}catch(e){}},window.headertag.registerPartner(PARTNER_ID,init)}),function(){"use strict";function e(e){function i(e){e=e.slice();for(var t=e.length-1;t>=0;t--){var n;if(n=r.isString(e[t])?e[t]:e[t].getSlotElementId(),H.hasOwnProperty(n)){var o=H[n];o.getDeviceType()&&o.getDeviceType()!==C()&&e.splice(t,1)}}return e}function a(e,t){if(e&&!r.isEmpty(e))for(var n=r.getDivIdToGSlotMap(t),o=0;o<e.length;o++){var i=e[o];if(i.page)for(var a in i.page)i.page.hasOwnProperty(a)&&(window.googletag.pubads().setTargeting(a,i.page[a]),O.page[a]=!0);else for(var s in i.slot)if(i.slot.hasOwnProperty(s)&&n.hasOwnProperty(s)){var d=i.slot[s].demand;for(var l in d)d.hasOwnProperty(l)&&(n[s].setTargeting(l,d[l]),O.slot[s]=O.slot[s]||{},O.slot[s][l]=!0)}}}function s(e){for(var t in O.page)O.page.hasOwnProperty(t)&&(window.googletag.pubads().clearTargeting(t),delete O.page[t]);for(var r=0;r<e.length;r++){var n=e[r].getSlotElementId();if(O.slot.hasOwnProperty(n)){for(var o in O.slot[n])O.slot[n].hasOwnProperty(o)&&e[r].setTargeting(o,"");delete O.slot[n]}}}function d(e,n,o){var i=t.defer();o=o.slice();var a=null,s=!1,d=E[n].getPartnerTargetingType(),l=function(t,o){return b[e]!==D.DONE&&!s&&(clearTimeout(a),E[n].getSupportedAnalytics().time&&I.stopPartnerTimer(e,n),t?(i.resolve(),!0):r.isEmpty(o)?(i.resolve(),!0):(E[n].getSupportedAnalytics().demand&&I.recordReturnedDemand(e,n,d,o),i.resolve(o),!0))};P[n]&&(a=setTimeout(function(){s=!0,i.resolve()},P[n])),E[n].getSupportedAnalytics().time&&I.startPartnerTimer(e,n,P[n]);try{"page"===d?E[n].getDemand(e,K,l):E[n].getDemand(e,o,l)}catch(e){}return i}function l(e,t){for(var r={selectedHtSlots:[],htSlotToGSlotMap:{}},n=0;n<B.length;n++){var i=B[n],a=o[i](e,t);r.selectedHtSlots=r.selectedHtSlots.concat(a.selectedHtSlots);for(var s in a.htSlotToGSlotMap)a.htSlotToGSlotMap.hasOwnProperty(s)&&(r.htSlotToGSlotMap[s]=a.htSlotToGSlotMap[s])}return r}function c(e,n){var o=t.defer();b[e]=D.IN_PROGRESS;var a=[],s=[];n=n.slice();var c=i(k),u=l(c,n);if(!u.selectedHtSlots.length)return o.resolve(),o.promise;I.startSessionTimer(e);for(var p=Object.keys(E);p.length;){var g=r.randomSplice(p);if(!R[g]){var f=d(e,g,u.selectedHtSlots);a.push(f),s.push(f.promise)}}var h=null,m=!1;return x&&(h=setTimeout(function(){m=!0;for(var e=0;e<a.length;e++)a[e].resolve()},x)),t.all(s).then(function(t){m||clearTimeout(h),b[e]=D.DONE,I.stopSessionTimer(e);var r=[];t.map(function(e){if(e)if(e.page)r.push(e);else{var t=e.slot,n={slot:{}};for(var o in t)if(t.hasOwnProperty(o)){var i=u.htSlotToGSlotMap[o];n.slot[i]=t[o]}r.push(n)}}),o.resolve(r)}),o.promise}function u(e){N?N(e):window.googletag.display(e)}function p(e,t){U?U(e,t):window.googletag.pubads().refresh(e,t)}function g(e){j?j(e):window.googletag.destroySlots(e)}function f(t,n){function o(n,o){if((!n||o)&&(E[t]=o,R[t]=e.partners[t].disabled,P[t]=e.partners[t].timeout,!R[t]&&!_&&e.prefetch&&e.prefetch.enabled)){var s=[],d=window.headertag.pagetype;if(d&&e.prefetch.pageTypeMapping.hasOwnProperty(d)?s=e.prefetch.pageTypeMapping[d]:e.prefetch.defaultSet&&(s=e.prefetch.defaultSet),s=i(s),s&&s.length){var l=o.getSupportedOptions();if(l.prefetch&&a.prefetchEnabled){var c=r.generateCorrelator();I.startSessionTimer(c),I.startPartnerTimer(c,t,P[t]);var u=function(){I.stopPartnerTimer(c,t),I.stopSessionTimer(c),I.sendReport(c)},p={divIds:s};"page"===o.getPartnerTargetingType()?o.prefetchDemand(c,K,u):o.prefetchDemand(c,p,u)}}}}var a=e.partners[t];if(e.partners.hasOwnProperty(t))try{n(a,o)}catch(e){}}function h(e){try{if(!M){if(q.hasOwnProperty(e))return;return q[e]=!0,u(e)}if(_=!0,!document.getElementById(e)||!r.divIdToGSlot(e))return u(e);var t;if(A){t=r.getSlots();for(var n=t.length-1;n>=0;n--)q.hasOwnProperty(t[n].getSlotElementId())&&t.splice(n,1)}else{var o=r.divIdToSlot(e);t=o?[o]:[]}for(var i=t.length-1;i>=0;i--)document.getElementById(t[i].getSlotElementId())||t.splice(i,1);if(!t.length)return;if(q.hasOwnProperty(e))return;for(var d=0;d<t.length;d++)q[t[d].getSlotElementId()]=!0;var l=r.generateCorrelator();c(l,t).then(function(r){s(t),a(r,t),u(e)}).then(function(){I.sendReport(l)}).catch(function(e){})}catch(t){u(e)}}function m(e,t,r,n){try{var o=googletag.defineSlot(e,t,r).addService(googletag.pubads());n&&o.setClickUrl(n),h(r)}catch(o){G(e,t,r,n)}}function y(e,t){try{M||(_=!0),e||(e=r.getSlots());for(var n=e.slice(),o=e.length-1;o>=0;o--)r.isObject(e[o])&&e[o].getSlotElementId&&document.getElementById(e[o].getSlotElementId())||e.splice(o,1);if(K=window.googletag.pubads().getCorrelator(),!e.length)return p(n,t);var i=r.generateCorrelator();c(i,e).then(function(r){s(e),a(r,e),p(n,t)}).then(function(){I.sendReport(i)}).catch(function(e){})}catch(r){p(e,t)}}function v(){return{display:m.bind(w),refresh:y.bind(w)}}function S(e){try{e||(e=r.getSlots());for(var t=0;t<e.length;t++){var n=e[t].getSlotElementId();delete q[n]}g(e)}catch(t){g(e)}}var w,T,I,b,D,x,E,R,P,O,_,M,A,q,N,G,U,j,C,k,H,B,K;!function(){if(e.hasOwnProperty("siteId")?r.isInteger(e.siteId)&&r.isInRange(e.siteId,0)||(e.siteId=0):e.siteId=0,e.hasOwnProperty("timeout")?r.isInteger(e.timeout)&&r.isInRange(e.timeout,1)||(e.timeout=1e3):e.timeout=1e3,e.hasOwnProperty("disableInitialLoad")?r.isBoolean(e.disableInitialLoad)||(e.disableInitialLoad=!1):e.disableInitialLoad=!1,e.hasOwnProperty("enableSingleRequest")?r.isBoolean(e.enableSingleRequest)||(e.enableSingleRequest=!0):e.enableSingleRequest=!0,e.hasOwnProperty("deviceTypeRef")?r.isString(e.deviceTypeRef)||r.isFunction(e.deviceTypeRef)||(e.deviceTypeRef=r.getDeviceTypeByUserAgent):e.deviceTypeRef=r.getDeviceTypeByUserAgent,!r.isObject(e.partners))throw new Error("Invalid `config.partners`, must be an object");if(!e.partners.hasOwnProperty("INDX"))throw new Error("Invalid `config.partners`, must include INDX");for(var t in e.partners)if(e.partners.hasOwnProperty(t)){var i=e.partners[t];i.hasOwnProperty("disabled")?r.isBoolean(i.disabled)||(i.disabled=!0):i.disabled=!1,i.hasOwnProperty("timeout")?r.isInteger(i.timeout)&&r.isInRange(i.timeout,0)||(i.timeout=0):i.timeout=0,i.hasOwnProperty("prefetchEnabled")?r.isBoolean(i.prefetchEnabled)||(i.prefetchEnabled=!1):i.prefetchEnabled=!1}w=this,T=e.siteId,I=new n(T),b={},D={IN_PROGRESS:0,DONE:1},x=e.timeout,E={},R={},P={},O={page:{},slot:{}},_=!1,M=!e.disableInitialLoad,A=e.enableSingleRequest,q={};var a=function(){window.googletag.cmd.push(function(){e.overrideGoogletag&&(N=window.googletag.display,G=window.googletag.pubads().display.bind(window.googletag.pubads()),U=window.googletag.pubads().refresh.bind(window.googletag.pubads()),j=window.googletag.destroySlots,window.googletag.display=h,window.googletag.pubads().display=m,window.googletag.pubads().refresh=y,window.googletag.destroySlots=S)})};r.isArray(window.googletag.cmd)?window.googletag.cmd.unshift(a):window.googletag.cmd.push(a),k=[],H={};for(var s in e.htSlots)if(e.htSlots.hasOwnProperty(s)){var d=e.htSlots[s];for(var l in d)if(d.hasOwnProperty(l)){var c=e.htSlots[s][l];c.deviceType=s;var u=o(l,c);k.push(u),H[l]=u}}B=e.slotMappingTypes,C=e.deviceTypeRef,r.isString(e.deviceTypeRef)&&(C=function(){return e.deviceTypeRef}),K=0}(),this.apiReady=!0,this.version="1.5.11",this.registerPartner=f,this.display=h,this.pubads=v,this.destroySlots=S}var t=window.headertag.Promise,r=window.headertag.Utilities,n=window.headertag.HeaderStats,o=window.headertag.HeaderTagSlot;window.googletag=window.googletag||{},window.googletag.cmd=window.googletag.cmd||[];try{var i=new e(window.headertagconfig);for(var a in window.headertag)window.headertag.hasOwnProperty(a)&&"display"!==a&&"pubads"!==a&&(i[a]=window.headertag[a]);window.headertag=i;for(var s=0;s<window.headertag.partnerScopes.length;s++)try{window.headertag.partnerScopes[s]()}catch(e){}}catch(e){window.googletag=window.googletag||{},window.googletag.cmd=window.googletag.cmd||[],window.headertag=window.googletag}}();