Advertisement
Guest User

http://s.zkcdn.net/ados.js

a guest
Sep 21st, 2015
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function() {
  2.     var JSON;
  3.     if (!JSON) {
  4.         JSON = {}
  5.     }(function() {
  6.         'use strict';
  7.  
  8.         function f(n) {
  9.             return n < 10 ? '0' + n : n
  10.         }
  11.         if (typeof Date.prototype.toJSON !== 'function') {
  12.             Date.prototype.toJSON = function(key) {
  13.                 return isFinite(this.valueOf()) ? this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z' : null
  14.             };
  15.             String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function(key) {
  16.                 return this.valueOf()
  17.             }
  18.         }
  19.         var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  20.             escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
  21.             gap, indent, meta = {
  22.                 '\b': '\\b',
  23.                 '\t': '\\t',
  24.                 '\n': '\\n',
  25.                 '\f': '\\f',
  26.                 '\r': '\\r',
  27.                 '"': '\\"',
  28.                 '\\': '\\\\'
  29.             },
  30.             rep;
  31.  
  32.         function quote(string) {
  33.             escapable.lastIndex = 0;
  34.             return escapable.test(string) ? '"' + string.replace(escapable, function(a) {
  35.                 var c = meta[a];
  36.                 return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4)
  37.             }) + '"' : '"' + string + '"'
  38.         }
  39.  
  40.         function str(key, holder) {
  41.             var i, k, v, length, mind = gap,
  42.                 partial, value = holder[key];
  43.             if (value && typeof value === 'object' && typeof value.toJSON === 'function') {
  44.                 value = value.toJSON(key)
  45.             }
  46.             if (typeof rep === 'function') {
  47.                 value = rep.call(holder, key, value)
  48.             }
  49.             switch (typeof value) {
  50.                 case 'string':
  51.                     return quote(value);
  52.                 case 'number':
  53.                     return isFinite(value) ? String(value) : 'null';
  54.                 case 'boolean':
  55.                 case 'null':
  56.                     return String(value);
  57.                 case 'object':
  58.                     if (!value) {
  59.                         return 'null'
  60.                     }
  61.                     gap += indent;
  62.                     partial = [];
  63.                     if (Object.prototype.toString.apply(value) === '[object Array]') {
  64.                         length = value.length;
  65.                         for (i = 0; i < length; i += 1) {
  66.                             partial[i] = str(i, value) || 'null'
  67.                         }
  68.                         v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']';
  69.                         gap = mind;
  70.                         return v
  71.                     }
  72.                     if (rep && typeof rep === 'object') {
  73.                         length = rep.length;
  74.                         for (i = 0; i < length; i += 1) {
  75.                             if (typeof rep[i] === 'string') {
  76.                                 k = rep[i];
  77.                                 v = str(k, value);
  78.                                 if (v) {
  79.                                     partial.push(quote(k) + (gap ? ': ' : ':') + v)
  80.                                 }
  81.                             }
  82.                         }
  83.                     } else {
  84.                         for (k in value) {
  85.                             if (Object.prototype.hasOwnProperty.call(value, k)) {
  86.                                 v = str(k, value);
  87.                                 if (v) {
  88.                                     partial.push(quote(k) + (gap ? ': ' : ':') + v)
  89.                                 }
  90.                             }
  91.                         }
  92.                     }
  93.                     v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}';
  94.                     gap = mind;
  95.                     return v
  96.             }
  97.         }
  98.         if (typeof JSON.stringify !== 'function') {
  99.             JSON.stringify = function(value, replacer, space) {
  100.                 var i;
  101.                 gap = '';
  102.                 indent = '';
  103.                 if (typeof space === 'number') {
  104.                     for (i = 0; i < space; i += 1) {
  105.                         indent += ' '
  106.                     }
  107.                 } else if (typeof space === 'string') {
  108.                     indent = space
  109.                 }
  110.                 rep = replacer;
  111.                 if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) {
  112.                     throw new Error('JSON.stringify')
  113.                 }
  114.                 return str('', {
  115.                     '': value
  116.                 })
  117.             }
  118.         }
  119.         if (typeof JSON.parse !== 'function') {
  120.             JSON.parse = function(text, reviver) {
  121.                 var j;
  122.  
  123.                 function walk(holder, key) {
  124.                     var k, v, value = holder[key];
  125.                     if (value && typeof value === 'object') {
  126.                         for (k in value) {
  127.                             if (Object.prototype.hasOwnProperty.call(value, k)) {
  128.                                 v = walk(value, k);
  129.                                 if (v !== undefined) {
  130.                                     value[k] = v
  131.                                 } else {
  132.                                     delete value[k]
  133.                                 }
  134.                             }
  135.                         }
  136.                     }
  137.                     return reviver.call(holder, key, value)
  138.                 }
  139.                 text = String(text);
  140.                 cx.lastIndex = 0;
  141.                 if (cx.test(text)) {
  142.                     text = text.replace(cx, function(a) {
  143.                         return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4)
  144.                     })
  145.                 }
  146.                 if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
  147.                     j = eval('(' + text + ')');
  148.                     return typeof reviver === 'function' ? walk({
  149.                         '': j
  150.                     }, '') : j
  151.                 }
  152.                 throw new SyntaxError('JSON.parse')
  153.             }
  154.         }
  155.     }());;
  156.     var P, Req, e, impressionData, logData, passbackData, passbackLoadData, passbackNextData, passbackTimeoutData, placementData, requestData, root, zerkEvent, __slice = [].slice,
  157.         __hasProp = {}.hasOwnProperty;
  158.     root = typeof exports !== "undefined" && exports !== null ? exports : this;
  159.     root.zerk_base64 = {
  160.         _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",
  161.         decode: function(e) {
  162.             var a, f, i, n, o, r, s, t, u;
  163.             t = "";
  164.             n = void 0;
  165.             r = void 0;
  166.             i = void 0;
  167.             s = void 0;
  168.             o = void 0;
  169.             u = void 0;
  170.             a = void 0;
  171.             f = 0;
  172.             e = e.replace(/[^A-Za-z0-9\-_\=]/g, "");
  173.             while (f < e.length) {
  174.                 s = this._keyStr.indexOf(e.charAt(f++));
  175.                 o = this._keyStr.indexOf(e.charAt(f++));
  176.                 u = this._keyStr.indexOf(e.charAt(f++));
  177.                 a = this._keyStr.indexOf(e.charAt(f++));
  178.                 n = s << 2 | o >> 4;
  179.                 r = (o & 15) << 4 | u >> 2;
  180.                 i = (u & 3) << 6 | a;
  181.                 t = t + String.fromCharCode(n);
  182.                 if (u !== 64) {
  183.                     t = t + String.fromCharCode(r);
  184.                 }
  185.                 if (a !== 64) {
  186.                     t = t + String.fromCharCode(i);
  187.                 }
  188.             }
  189.             t = zerk_base64._utf8_decode(t);
  190.             return t.replace(/\0/g, '');
  191.         },
  192.         _utf8_decode: function(e) {
  193.             var c1, c2, c3, n, r, t;
  194.             t = "";
  195.             n = 0;
  196.             r = c1 = c2 = 0;
  197.             while (n < e.length) {
  198.                 r = e.charCodeAt(n);
  199.                 if (r < 128) {
  200.                     t += String.fromCharCode(r);
  201.                     n++;
  202.                 } else if (r > 191 && r < 224) {
  203.                     c2 = e.charCodeAt(n + 1);
  204.                     t += String.fromCharCode((r & 31) << 6 | c2 & 63);
  205.                     n += 2;
  206.                 } else {
  207.                     c2 = e.charCodeAt(n + 1);
  208.                     c3 = e.charCodeAt(n + 2);
  209.                     t += String.fromCharCode((r & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
  210.                     n += 3;
  211.                 }
  212.             }
  213.             return t;
  214.         }
  215.     };
  216.     root.zerk_generateUUID = function() {
  217.         var d, uuid;
  218.         d = new Date().getTime();
  219.         uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
  220.             var r;
  221.             r = (d + Math.random() * 16) % 16 | 0;
  222.             d = Math.floor(d / 16);
  223.             return (c === "x" ? r : r & 0x3 | 0x8).toString(16);
  224.         });
  225.         return uuid;
  226.     };
  227.     root.zerk_getQueryVariable = function(url, variable) {
  228.         var i, pair, query, vars;
  229.         query = url.split("?")[1];
  230.         vars = query.split("&");
  231.         i = 0;
  232.         while (i < vars.length) {
  233.             pair = vars[i].split("=");
  234.             if (pair[0] === variable) {
  235.                 return pair[1];
  236.             }
  237.             i++;
  238.         }
  239.         return false;
  240.     };
  241.     root.adosRun = function() {
  242.         while (window.ados.run !== void 0 && window.ados.run.length > 0) {
  243.             window.ados.run[0].call();
  244.             ados.run.splice(0, 1);
  245.         }
  246.         return window.ados.run.push = function(code) {
  247.             return code.call();
  248.         };
  249.     };
  250.     root.cssLoad = function(css) {
  251.         var s, stylenode;
  252.         s = document.createElement("style");
  253.         document.getElementsByTagName("head")[0].appendChild(s);
  254.         if (!!window.ActiveXObject) {
  255.             return document.styleSheets[document.styleSheets.length - 1].cssText = css;
  256.         } else {
  257.             stylenode = document.createTextNode(css);
  258.             return s.appendChild(stylenode);
  259.         }
  260.     };
  261.     root.cssLinkLoad = function(url) {
  262.         var tag;
  263.         tag = document.createElement('link');
  264.         tag.rel = 'stylesheet';
  265.         tag.href = url;
  266.         return document.getElementsByTagName('head')[0].appendChild(tag);
  267.     };
  268.     root.azHtmlLoad = function(div, content) {
  269.         var adzerkDiv;
  270.         adzerkDiv = document.getElementById(div);
  271.         return adzerkDiv.innerHTML = content;
  272.     };
  273.     root.azScriptSRCLoad = function(div, script) {
  274.         var adzerkDiv, newScript;
  275.         newScript = document.createElement("script");
  276.         newScript.type = "text/javascript";
  277.         newScript.src = script;
  278.         adzerkDiv = document.getElementById(div);
  279.         return adzerkDiv.appendChild(newScript);
  280.     };
  281.     root.azScriptExtensionLoad = function(url) {
  282.         var head, newScript;
  283.         newScript = document.createElement('script');
  284.         newScript.type = 'text/javascript';
  285.         newScript.src = url;
  286.         head = document.getElementsByTagName('head')[0];
  287.         return head.appendChild(newScript);
  288.     };
  289.     root.azRegisterExtension = function(name, func) {
  290.         var args, _i, _len, _ref;
  291.         if (root.ados.extensions == null) {
  292.             root.ados.extensions = {};
  293.         }
  294.         root.ados.extensions[name] = func;
  295.         if ((root.ados.extensionCalls != null) && (root.ados.extensionCalls[name] != null)) {
  296.             _ref = root.ados.extensionCalls[name];
  297.             for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  298.                 args = _ref[_i];
  299.                 func.apply(root, args);
  300.             }
  301.             return delete root.ados.extensionCalls[name];
  302.         }
  303.     };
  304.     root.azInitExtension = function() {
  305.         var args, name;
  306.         name = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
  307.         if ((root.ados.extensions != null) && (root.ados.extensions[name] != null)) {
  308.             return root.ados.extensions[name].apply(root, args);
  309.         } else {
  310.             if (root.ados.extensionCalls == null) {
  311.                 root.ados.extensionCalls = {};
  312.             }
  313.             if (root.ados.extensionCalls[name] == null) {
  314.                 root.ados.extensionCalls[name] = [];
  315.             }
  316.             return root.ados.extensionCalls[name].push(args);
  317.         }
  318.     };
  319.     root.ados_async_load = function(src) {
  320.         var s, z;
  321.         z = document.createElement("script");
  322.         z.type = "text/javascript";
  323.         z.async = true;
  324.         z.src = src;
  325.         s = document.getElementsByTagName("script")[0];
  326.         return s.parentNode.insertBefore(z, s);
  327.     };
  328.     root.azScriptInlineLoad = function(div, script, interval) {
  329.         var adzerkDiv, newScript;
  330.         newScript = document.createElement("script");
  331.         newScript.type = "text/javascript";
  332.         if (/msie/.test(navigator.userAgent.toLowerCase())) {
  333.             newScript.text = script;
  334.         } else {
  335.             newScript.innerHTML = script;
  336.         }
  337.         adzerkDiv = document.getElementById(div);
  338.         return adzerkDiv.appendChild(newScript);
  339.     };
  340.     root.azLoad = function(div, code) {
  341.         var adzerkDiv;
  342.         adzerkDiv = document.getElementById(div);
  343.         if (adzerkDiv) {
  344.             return code();
  345.         } else {
  346.             return setTimeout((function() {
  347.                 return azLoad(div, code);
  348.             }), 100);
  349.         }
  350.     };
  351.     root.zshow = function(div) {
  352.         if (zItems[div]) {
  353.             return document.write(zItems[div]);
  354.         }
  355.     };
  356.     root.ados_addInlinePlacement = function(accountId, siteId, size) {
  357.         var chars, i, ran, randomName;
  358.         chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZ";
  359.         randomName = "";
  360.         i = 0;
  361.         while (i < 12) {
  362.             ran = Math.floor(Math.random() * chars.length);
  363.             randomName += chars.substring(ran, ran + 1);
  364.             i++;
  365.         }
  366.         return ados_addPlacement(accountId, siteId, randomName, size);
  367.     };
  368.     root.ados_add_placement = function(accountId, siteId, name, size) {
  369.         return ados_addPlacement(accountId, siteId, name, size);
  370.     };
  371.     root.ados_addPlacement = function(accountId, siteId, name, size) {
  372.         var placement;
  373.         placement = new P();
  374.         placement.A = accountId;
  375.         placement.S = siteId;
  376.         placement.D = name;
  377.         if (!isNaN(size)) {
  378.             placement.AT = size;
  379.         } else {
  380.             placement.ATA = size;
  381.         }
  382.         ados_addPlacementObject(placement);
  383.         return placement;
  384.     };
  385.     root.ados_loadDiv = function(name) {
  386.         if (!window.ados.isAsync) {
  387.             return zshow(name);
  388.         }
  389.     };
  390.     root.ados_setKeywords = function(keywords) {
  391.         var keywordCookie;
  392.         keywordCookie = (' ' + document.cookie).match(new RegExp('[; ]ados_keyword_cookie=([^\\s;]*)'));
  393.         if (!!keywordCookie) {
  394.             return window.ados.keywords = unescape(keywordCookie[1]) + ',' + keywords;
  395.         } else {
  396.             return window.ados.keywords = keywords;
  397.         }
  398.     };
  399.     root.ados_setKeywordCookie = function(keywords) {
  400.         var domain, expires;
  401.         expires = new Date();
  402.         domain = window.ados.domain || ".adzerk.net";
  403.         expires.setTime(new Date().getTime() + 3600000 * 24 * 30);
  404.         return document.cookie = 'ados_keyword_cookie=' + escape(keywords) + ';expires=' + expires.toGMTString() + 'domain=' + domain + ';path=\/;';
  405.     };
  406.     root.ados_setNoTrack = function() {
  407.         return window.ados.isNoTrack = true;
  408.     };
  409.     root.ados_setDomain = function(domain) {
  410.         return window.ados.domain = domain;
  411.     };
  412.     root.ados_setWriteResults = function() {
  413.         return window.ados.writeResults = true;
  414.     };
  415.     root.ados_setPassbackTimeout = function(timeout) {
  416.         ados_log('setting timeout' + timeout);
  417.         return window.ados.passbackTimeout = timeout;
  418.     };
  419.     root.ados_log = function(text) {
  420.         window.ados.fire('log', new logData(text));
  421.         if (window.console) {
  422.             return console.info(new Date().getTime() + ': ' + text);
  423.         }
  424.     };
  425.     root.ados_addPlacementObject = function(placement) {
  426.         if (!window.ados.placements) {
  427.             window.ados.placements = new Array();
  428.         }
  429.         return window.ados.placements.push(placement);
  430.     };
  431.     root.ados_refresh = function(placement, seconds, again) {
  432.         var div;
  433.         ados_log('triggering refresh of:' + placement.D);
  434.         ados.fire('refresh', null);
  435.         div = document.getElementById(placement.D);
  436.         while (div.hasChildNodes()) {
  437.             div.removeChild(div.lastChild);
  438.         }
  439.         ados_addPlacementObject(placement);
  440.         ados_load();
  441.         if (again) {
  442.             return setTimeout((function() {
  443.                 return ados_refresh(placement, seconds, true);
  444.             }), seconds * 1000);
  445.         }
  446.     };
  447.     root.ados_loadResults = function(results) {
  448.         var i, len, _results;
  449.         len = results.length;
  450.         i = 0;
  451.         _results = [];
  452.         while (i < len) {
  453.             adosResults[results[i].divName] = results[i];
  454.             eval(results[i].adCode);
  455.             _results.push(i++);
  456.         }
  457.         return _results;
  458.     };
  459.     Req = function() {
  460.         this.Placements = window.ados.placements;
  461.         window.ados.placements = new Array();
  462.         this.Keywords = encodeURIComponent(ados.keywords);
  463.         this.Referrer = encodeURIComponent(document.referrer);
  464.         this.IsAsync = window.ados.isAsync;
  465.         this.IsNoTrack = window.ados.isNoTrack;
  466.         this.WriteInline = window.ados.writeInline;
  467.         this.WriteResults = window.ados.writeResults;
  468.         return this;
  469.     };
  470.     placementData = function(placement) {
  471.         var a, _i, _len, _ref;
  472.         this.accountId = placement.A;
  473.         this.siteId = placement.S;
  474.         this.name = placement.D;
  475.         if (placement.Z) {
  476.             this.zoneId = placement.Z;
  477.         }
  478.         if (placement.CampaignId) {
  479.             this.campaignId = placement.CampaignId;
  480.         }
  481.         if (placement.FlightId) {
  482.             this.flightId = placement.FlightId;
  483.         }
  484.         if (placement.FlightCreativeId) {
  485.             this.adId = placement.FlightCreativeId;
  486.         }
  487.         if (placement.properties) {
  488.             this.properties = placement.properties;
  489.         }
  490.         this.sizes = [];
  491.         if (placement.AT) {
  492.             this.sizes.push(placement.AT);
  493.         }
  494.         if (placement.ATA) {
  495.             _ref = placement.ATA;
  496.             for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  497.                 a = _ref[_i];
  498.                 this.sizes.push(a);
  499.             }
  500.         }
  501.         return this;
  502.     };
  503.     requestData = function(req) {
  504.         var p, _i, _len, _ref;
  505.         this.placements = [];
  506.         _ref = req.Placements;
  507.         for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  508.             p = _ref[_i];
  509.             this.placements.push(new placementData(p));
  510.         }
  511.         if (req.Keywords) {
  512.             this.keywords = req.Keywords;
  513.         }
  514.         if (req.Referrer) {
  515.             this.referrer = req.Referrer;
  516.         }
  517.         return this;
  518.     };
  519.     logData = function(message) {
  520.         this.message = message;
  521.         return this;
  522.     };
  523.     passbackData = function(div, passback) {
  524.         this.flightId = passback.FlightId;
  525.         this.veriPixel = passback.VeriPixel;
  526.         this.script = passback.Script;
  527.         this.div = div;
  528.         return this;
  529.     };
  530.     passbackLoadData = function(div, passbacks) {
  531.         var p, _i, _len;
  532.         this.passbacks = [];
  533.         for (_i = 0, _len = passbacks.length; _i < _len; _i++) {
  534.             p = passbacks[_i];
  535.             this.passbacks.push(new passbackData(div, p));
  536.         }
  537.         return this;
  538.     };
  539.     passbackNextData = function(div, flightId, nextFlightId) {
  540.         this.div = div;
  541.         this.flightId = flightId;
  542.         this.nextFlightId = nextFlightId;
  543.         return this;
  544.     };
  545.     passbackTimeoutData = function(div, flightId) {
  546.         this.div = div;
  547.         return this.flightId = flightId;
  548.     };
  549.     impressionData = function(div, url) {
  550.         var shim;
  551.         this.div = div;
  552.         this.veriPixel = url;
  553.         shim = zerk_getQueryVariable(url, "e");
  554.         this.e = shim;
  555.         this.shim = JSON.parse(zerk_base64.decode(shim));
  556.         return this;
  557.     };
  558.     zerkEvent = function(e, args) {
  559.         this.name = e;
  560.         this.sessionId = window.ados.sessionId;
  561.         if (args) {
  562.             this.data = args;
  563.         }
  564.         return this;
  565.     };
  566.     P = function() {
  567.         return {
  568.             setZone: function(zoneid) {
  569.                 this.Z = zoneid;
  570.                 return this;
  571.             },
  572.             setClickUrl: function(clickurl) {
  573.                 this.ClickUrl = encodeURIComponent(clickurl);
  574.                 return this;
  575.             },
  576.             setRedirectUrl: function(redirectUrl) {
  577.                 this.RedirectUrl = encodeURIComponent(redirectUrl);
  578.                 return this;
  579.             },
  580.             setCampaignId: function(campaignId) {
  581.                 this.CampaignId = campaignId;
  582.                 return this;
  583.             },
  584.             setFlightId: function(flightId) {
  585.                 this.FlightId = flightId;
  586.                 return this;
  587.             },
  588.             setFlightCreativeId: function(flightCreativeId) {
  589.                 this.FlightCreativeId = flightCreativeId;
  590.                 return this;
  591.             },
  592.             setProperty: function(key, value) {
  593.                 if (this.Properties == null) {
  594.                     this.Properties = {};
  595.                 }
  596.                 this.Properties[key] = value;
  597.                 return this;
  598.             },
  599.             setProperties: function(dict) {
  600.                 var key, value;
  601.                 if (this.Properties == null) {
  602.                     this.Properties = {};
  603.                 }
  604.                 for (key in dict) {
  605.                     if (!__hasProp.call(dict, key)) continue;
  606.                     value = dict[key];
  607.                     this.Properties[key] = value;
  608.                 }
  609.                 return this;
  610.             },
  611.             setContentKeys: function(dict) {
  612.                 var key, value;
  613.                 if (this.ContentKeys == null) {
  614.                     this.ContentKeys = {};
  615.                 }
  616.                 for (key in dict) {
  617.                     if (!__hasProp.call(dict, key)) continue;
  618.                     value = dict[key];
  619.                     this.ContentKeys[key] = value;
  620.                 }
  621.                 return this;
  622.             },
  623.             enableDynamicSiteSelection: function() {
  624.                 this.DynamicSiteOverride = document.domain.replace(/^www\./, '');
  625.                 return this;
  626.             },
  627.             setRefresh: function(seconds) {
  628.                 var placement;
  629.                 placement = this;
  630.                 setTimeout((function() {
  631.                     return ados_refresh(placement, seconds, true);
  632.                 }), seconds * 1000);
  633.                 return this;
  634.             },
  635.             loadInline: function() {
  636.                 ados.isAsync = false;
  637.                 ados.writeInline = true;
  638.                 window.divName = this.D;
  639.                 ados_load(this.D);
  640.                 return this;
  641.             }
  642.         };
  643.     };
  644.     root.ados_load = function(loadDiv) {
  645.         var data, domain, keywordCookie, proto, prototype_toJSON, req, src;
  646.         domain = window.ados.domain || "engine.adzerk.net";
  647.         if (ados.isAsync !== false) {
  648.             window.ados.isAsync = true;
  649.         }
  650.         keywordCookie = (' ' + document.cookie).match(new RegExp('[; ]ados_keyword_cookie=([^\\s;]*)'));
  651.         if (!!keywordCookie) {
  652.             window.ados.keywords = unescape(keywordCookie[1]);
  653.         }
  654.         proto = "http";
  655.         if (document.location.protocol === "https:") {
  656.             proto = "https";
  657.         }
  658.         src = proto + "://" + domain + "/ados?t=" + new Date().getTime() + "&request=";
  659.         req = new Req();
  660.         data = new requestData(req);
  661.         ados.fire('requestStart', data);
  662.         prototype_toJSON = (window.Prototype ? Array.prototype.toJSON : null);
  663.         if (prototype_toJSON) {
  664.             delete Array.prototype.toJSON;
  665.         }
  666.         if (req.Placements.length !== 0) {
  667.             if (!window.ados.isAsync) {
  668.                 document.write("<script type=\"text/javascript\" src=\"" + src + encodeURI(JSON.stringify(req)) + "\"></script>");
  669.             } else {
  670.                 ados_async_load(src + JSON.stringify(req));
  671.             }
  672.         }
  673.         if (prototype_toJSON) {
  674.             return Array.prototype.toJSON = prototype_toJSON;
  675.         }
  676.     };
  677.     root.ados_loadInline = function(accountId, siteId, adtype) {
  678.         var chars, i, ran, randomName;
  679.         chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZ";
  680.         randomName = "";
  681.         i = 0;
  682.         while (i < 12) {
  683.             ran = Math.floor(Math.random() * chars.length);
  684.             randomName += chars.substring(ran, ran + 1);
  685.             i++;
  686.         }
  687.         document.write("<div id=\"" + randomName + "\"></div>");
  688.         return ados_add_placement(accountId, siteId, randomName, adtype);
  689.     };
  690.     root.ados_loadPassback = function(div, passbacks) {
  691.         if (!window.ados.passbacks) {
  692.             window.ados.passbacks = {};
  693.         }
  694.         if (!window.ados.currentPassback) {
  695.             window.ados.currentPassback = {};
  696.         }
  697.         if (!window.ados.counted) {
  698.             window.ados.counted = {};
  699.         }
  700.         window.ados.fire('passbackLoad', new passbackLoadData(div, passbacks));
  701.         window.ados.passbacks[div] = passbacks;
  702.         window.ados.counted[div] = false;
  703.         return ados_execPassback(div, passbacks[0]);
  704.     };
  705.     root.ados_passback_next = function(div, id) {
  706.         var chain, flight, idx, next, _i, _ref;
  707.         chain = window.ados.passbacks[div];
  708.         for (idx = _i = _ref = chain.length - 1; _ref <= 0 ? _i <= 0 : _i >= 0; idx = _ref <= 0 ? ++_i : --_i) {
  709.             flight = chain[idx];
  710.             if (flight.FlightId === id) {
  711.                 next = idx + 1;
  712.                 if (next === window.ados.passbacks[div].length) {
  713.                     return null;
  714.                 }
  715.                 window.ados.fire('passbackNext', new passbackNextData(div, id, window.ados.passbacks[div][next]));
  716.                 return window.ados.passbacks[div][next];
  717.             }
  718.         }
  719.         throw new Error("Flight not found - make sure the network is returning the correct passback");
  720.     };
  721.     root.ados_passback_last = function(div, ids) {
  722.         var chain, flight, id, idx, next, potentialFlights, _i, _j, _len, _ref;
  723.         chain = window.ados.passbacks[div];
  724.         potentialFlights = [];
  725.         for (_i = 0, _len = ids.length; _i < _len; _i++) {
  726.             id = ids[_i];
  727.             for (idx = _j = _ref = chain.length - 1; _ref <= 0 ? _j <= 0 : _j >= 0; idx = _ref <= 0 ? ++_j : --_j) {
  728.                 flight = chain[idx];
  729.                 if (flight.FlightId === id) {
  730.                     next = idx + 1;
  731.                     if (next < window.ados.passbacks[div].length) {
  732.                         potentialFlights.push(next);
  733.                     }
  734.                 }
  735.             }
  736.         }
  737.         if (potentialFlights.length === 0) {
  738.             throw new Error("No eligible flight found to passback to");
  739.         }
  740.         window.ados.fire('passbackNext', new passbackNextData(div, id, next));
  741.         return window.ados.passbacks[div][Math.max.apply(Math, potentialFlights)];
  742.     };
  743.     root.ados_findPassback = function(div, id) {
  744.         var chain, flight, idx, _i, _ref;
  745.         chain = window.ados.passbacks[div];
  746.         for (idx = _i = _ref = chain.length - 1; _ref <= 0 ? _i <= 0 : _i >= 0; idx = _ref <= 0 ? ++_i : --_i) {
  747.             flight = chain[idx];
  748.             if (flight.FlightId === id) {
  749.                 return flight;
  750.             }
  751.         }
  752.         throw new Error("Flight not found - make sure the network is returning the correct passback");
  753.     };
  754.     root.azk_clearframe = function(div, flightId) {
  755.         var ifrm;
  756.         ifrm = document.getElementById("ados_frame_" + div + "_" + flightId);
  757.         if (ifrm !== null) {
  758.             return ifrm.parentNode.removeChild(ifrm);
  759.         }
  760.     };
  761.     root.ados_passback = function(div, flightId) {
  762.         var next;
  763.         ados_log('received passback for div:' + div + ' and flightId:' + flightId);
  764.         next = ados_passback_next(div, flightId);
  765.         ados_execPassback(div, next);
  766.         return azk_clearframe(div, flightId);
  767.     };
  768.     root.azk_passback = function(div, flightIds) {
  769.         var last;
  770.         ados_log('received passback for div:' + div + ' and flightIds:' + flightIds);
  771.         last = ados_passback_last(div, flightIds);
  772.         ados_execPassback(div, last);
  773.         return azk_clearframe(div, last);
  774.     };
  775.     root.ados_execPassback = function(div, passback) {
  776.         var timeoutScript;
  777.         ados_log('loading flight:' + passback.FlightId);
  778.         window.ados.currentPassback[div] = passback.FlightId;
  779.         window.ados.fire('passbackExec', new passbackData(div, passback));
  780.         timeoutScript = '';
  781.         if (!window.ados.isAsync) {
  782.             timeoutScript = 'setTimeout(function() { ados_timeoutExpired("' + div + '", ' + passback.FlightId + ') }, 2500)';
  783.         }
  784.         return eval(passback.Script + timeoutScript);
  785.     };
  786.     root.ados_timeoutExpired = function(div, flightId) {
  787.         if (window.ados.currentPassback && window.ados.currentPassback[div] === flightId && window.ados.counted[div] === false) {
  788.             window.ados.fire('passbackTimeout', new passbackTimeoutData(div, flightId));
  789.             ados_log('time to passback expired for div:' + div + ' and flightid:' + flightId);
  790.             return ados_passbackFilled(div, flightId);
  791.         }
  792.     };
  793.     root.ados_frameLoaded = function(div, flightId) {
  794.         var ifrm, timeout;
  795.         ifrm = document.getElementById("ados_frame_" + div + "_" + flightId);
  796.         if (ifrm !== null && ifrm.readyState !== "complete" && ifrm.readyState !== void 0) {
  797.             return setTimeout((function() {
  798.                 return ados_frameLoaded(div, flightId);
  799.             }), 100);
  800.         } else if (window.ados.currentPassback && window.ados.currentPassback[div] === flightId) {
  801.             timeout = window.ados.passbackTimeout || 400;
  802.             return setTimeout((function() {
  803.                 return ados_passbackFilled(div, flightId);
  804.             }), timeout);
  805.         } else if (window.ados.currentPassback && window.ados.currentPassback[div]) {
  806.             return azk_clearframe(div, flightId);
  807.         }
  808.     };
  809.     root.ados_passbackFilled = function(div, flightId) {
  810.         var flight;
  811.         if (window.ados.currentPassback && window.ados.currentPassback[div] === flightId) {
  812.             ados_log('flight is loaded for div: ' + div + ' and flightId:' + flightId);
  813.             flight = ados_findPassback(div, flightId);
  814.             if (flight.counted === void 0 && window.ados.counted[div] === false) {
  815.                 flight.counted = window.ados.counted[div] = true;
  816.                 return ados_passbackWritePixel(div, flight.VeriPixel, flightId);
  817.             }
  818.         } else {
  819.             return azk_clearframe(div, flightId);
  820.         }
  821.     };
  822.     root.ados_passbackWritePixel = function(div, url, flightId) {
  823.         var adzerkDiv, pixel;
  824.         adzerkDiv = document.getElementById(div);
  825.         if (adzerkDiv !== null) {
  826.             ados_log('writing pixel for div: ' + div + ' and flightId:' + flightId);
  827.             pixel = document.createElement('img');
  828.             pixel.setAttribute("height", "0px");
  829.             pixel.setAttribute("width", "0px");
  830.             pixel.setAttribute("border", "0");
  831.             pixel.setAttribute("style", "position:absolute;");
  832.             pixel.setAttribute("src", url);
  833.             adzerkDiv.appendChild(pixel);
  834.             return ados.fire('ImpressionCounted', new impressionData(div, url));
  835.         }
  836.     };
  837.     root.ados_writePixel = function(div, url) {
  838.         var adzerkDiv, pixel;
  839.         adzerkDiv = document.getElementById(div);
  840.         if (adzerkDiv !== null) {
  841.             pixel = document.createElement('img');
  842.             pixel.setAttribute("height", "0px");
  843.             pixel.setAttribute("width", "0px");
  844.             pixel.setAttribute("border", "0");
  845.             pixel.setAttribute("style", "position:absolute;");
  846.             pixel.setAttribute("src", url);
  847.             adzerkDiv.appendChild(pixel);
  848.             return ados.fire('ImpressionCounted', new impressionData(div, url));
  849.         }
  850.     };
  851.     root.ados_writeGenericPixel = function(div, url) {
  852.         var adzerkDiv, pixel;
  853.         adzerkDiv = document.getElementById(div);
  854.         if (adzerkDiv !== null) {
  855.             pixel = document.createElement('img');
  856.             pixel.setAttribute("height", "0px");
  857.             pixel.setAttribute("width", "0px");
  858.             pixel.setAttribute("border", "0");
  859.             pixel.setAttribute("style", "position:absolute;");
  860.             pixel.setAttribute("src", url);
  861.             return adzerkDiv.appendChild(pixel);
  862.         }
  863.     };
  864.     root.ados_loadFIframe = function(div, content, flightid, height, width) {
  865.         var adzerkDiv, doc, ifrm;
  866.         adzerkDiv = document.getElementById(div);
  867.         ifrm = document.createElement("iframe");
  868.         ifrm.id = "ados_frame_" + div + "_" + flightid;
  869.         ifrm.frameBorder = 0;
  870.         ifrm.scrolling = "no";
  871.         ifrm.noresize = "noresize";
  872.         ifrm.marginheight = 0;
  873.         ifrm.marginwidth = 0;
  874.         if (height !== 0) {
  875.             ifrm.height = height;
  876.         }
  877.         if (width !== 0) {
  878.             ifrm.width = width;
  879.         }
  880.         adzerkDiv.appendChild(ifrm);
  881.         if (ifrm.attachEvent) {
  882.             ifrm.attachEvent('onload', function() {
  883.                 return ados_frameLoaded(div, flightid);
  884.             });
  885.         } else {
  886.             ifrm.onload = function() {
  887.                 return ados_frameLoaded(div, flightid);
  888.             };
  889.         }
  890.         content = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><html><head><style>div,iframe { top: 0; position:absolute; }</style></head><body style=\"margin:0px;padding:0px;\"><script type=\"text/javascript\">var divName = \"" + div + "\";var inFIF=true;var inDapIF = true;</script>" + content + "</body></html>";
  891.         if (/msie/.test(navigator.userAgent.toLowerCase()) || window.opera) {
  892.             ifrm.contentWindow.contents = content;
  893.             return ifrm.src = "javascript:window[\"contents\"]";
  894.         } else {
  895.             doc = ifrm.contentDocument;
  896.             doc.open();
  897.             doc.write(content);
  898.             doc.close();
  899.             return ifrm;
  900.         }
  901.     };
  902.     root.ados_passback_receiveMessage = function(evt) {
  903.         var adosWindow, flightId;
  904.         flightId = evt.data.flightId;
  905.         adosWindow = evt.source.parent;
  906.         while (!adosWindow.divName) {
  907.             if (adosWindow === adosWindow.parent) {
  908.                 break;
  909.             }
  910.             adosWindow = adosWindow.parent;
  911.         }
  912.         if (adosWindow.divName === void 0 || evt.data.flightId === void 0) {
  913.             return;
  914.         }
  915.         ados_log('passback recieved through postMessage for Div:' + adosWindow.divName + ' FlightId:' + evt.data.flightId);
  916.         return ados_passback(adosWindow.divName, evt.data.flightId);
  917.     };
  918.     window.ados = window.ados || {};
  919.     window.ados.events = window.ados.events || {};
  920.     window.ados.run = window.ados.run || [];
  921.     window.zItems = window.zItems || [];
  922.     window.adosResults = window.adosResults || {};
  923.     window.ados.sessionId = zerk_generateUUID();
  924.     window.ados.on = function(e, fn) {
  925.         window.ados.events[e] = window.ados.events[e] || [];
  926.         return window.ados.events[e].push(fn);
  927.     };
  928.     window.ados.fire = function(e, args) {
  929.         var zevent, _i, _len, _ref, _results;
  930.         if (window.ados.events[e] != null) {
  931.             zevent = new zerkEvent(e, args);
  932.             _ref = window.ados.events[e];
  933.             _results = [];
  934.             for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  935.                 e = _ref[_i];
  936.                 _results.push(e.call(null, zevent));
  937.             }
  938.             return _results;
  939.         }
  940.     };
  941.     try {
  942.         if (window.top.attachEvent) {
  943.             window.top.attachEvent("message", ados_passback_receiveMessage, false);
  944.         } else if (window.top.addEventListener) {
  945.             window.top.addEventListener("message", ados_passback_receiveMessage, false);
  946.         }
  947.     } catch (_error) {
  948.         e = _error;
  949.     }
  950.     root.adosRun();
  951.     setTimeout((function() {
  952.         return root.adosRun();
  953.     }), 1000);
  954.     window.ados.fire('load', null);
  955. }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement