Tagging = function(context) {
  this.site = '50plusz';
  this.zone = 'default';
  this.protocol = window.location.protocol;
  this.autodetect_url = this.protocol + '//cts.p24.hu/service/detect/';
  this.context = context;
  this.positions = {};
  this.positions_weighted = {};

  this.positions['head'] = '[{\"service_name\": \"Gemius Traffic\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\">var pp_gemius_identifier = (\'\'+eval(\'dataLayer[0].gemiusID\')+\'\' != \'\') ? \'\'+eval(\'dataLayer[0].gemiusID\')+\'\' : \'B8NF.WrhYUDsZof8bYFwVYZRP31F77s7YgfrnqW3_nD.R7\';function gemius_pending(i) { window[i] = window[i] || function() {var x = window[i+\'_pdata\'] = window[i+\'_pdata\'] || []; x[x.length]=arguments;};};gemius_pending(\'gemius_hit\'); gemius_pending(\'gemius_event\'); gemius_pending(\'pp_gemius_hit\'); gemius_pending(\'pp_gemius_event\');(function(d,t) {try {var gt=d.createElement(t),s=d.getElementsByTagName(t)[0],l=\'http\'+((location.protocol==\'https:\')?\'s\':\'\'); gt.setAttribute(\'async\',\'async\');gt.setAttribute(\'defer\',\'defer\'); gt.src=l+\'://gahu.hit.gemius.pl/xgemius.js\'; s.parentNode.insertBefore(gt,s);} catch (e) {}})(document,\'script\');</script>\"}, {\"service_name\": \"Sanoma\", \"weight\": null, \"source\": \"<script src=\\"//stat.p24.hu/mobile_detect/mobile_detect.js\\"></script>\"}, {\"service_name\": \"Sanoma\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\" src=\\"//ad-blacklist.p24.hu/adx_blacklist.js\\"></script><script type=\\"text/javascript\\" src=\\"//ad-blacklist.p24.hu/rubicon_blacklist.js\\"></script><script type=\\"text/javascript\\">    (function(){        var blacklistsToCheck = [\'ADX\', \'RUBICON\'];        for (var i=0; i<blacklistsToCheck.length; i++) {            var typeName = blacklistsToCheck[i].charAt(0) + blacklistsToCheck[i].substr(1).toLowerCase();            window[\'no\' + blacklistsToCheck[i]] = false;            if (                typeof window[\'blck\' + typeName] != \'undefined\' &&                typeof window[\'blck\' + typeName][window.location.hostname] != \'undefined\' &&                window[\'blck\' + typeName][window.location.hostname].indexOf(location.pathname) >= 0            ) {                window[\'no\' + blacklistsToCheck[i]] = true;            }        }    })();</script>\"}, {\"service_name\": \"Sanoma\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\" src=\\"//segment.p24.hu/cerment.min.js\\" async></script>\"}, {\"service_name\": \"CMP\", \"weight\": null, \"source\": \"<!-- Quantcast Choice. Consent Manager Tag v2.0 (for TCF 2.0) --><script type=\\"text/javascript\\" async=true>(function() {  var host = window.location.hostname;  var element = document.createElement(\'script\');  var firstScript = document.getElementsByTagName(\'script\')[0];  var url = \'https://quantcast.mgr.consensu.org\'.concat(\'/choice/\', \'ZWemmHq85Y1fR\', \'/\', host, \'/choice.js\');  var uspTries = 0;  var uspTriesLimit = 3;  element.async = true;  element.type = \'text/javascript\';  element.src = url;  firstScript.parentNode.insertBefore(element, firstScript);  function makeStub() {    var TCF_LOCATOR_NAME = \'__tcfapiLocator\';    var queue = [];    var win = window;    var cmpFrame;    function addFrame() {      var doc = win.document;      var otherCMP = !!(win.frames[TCF_LOCATOR_NAME]);      if (!otherCMP) {        if (doc.body) {          var iframe = doc.createElement(\'iframe\');          iframe.style.cssText = \'display:none\';          iframe.name = TCF_LOCATOR_NAME;          doc.body.appendChild(iframe);        } else {          setTimeout(addFrame, 5);        }      }      return !otherCMP;    }    function tcfAPIHandler() {      var gdprApplies;      var args = arguments;      if (!args.length) {        return queue;      } else if (args[0] === \'setGdprApplies\') {        if (          args.length > 3 &&          args[2] === 2 &&          typeof args[3] === \'boolean\'        ) {          gdprApplies = args[3];          if (typeof args[2] === \'function\') {            args[2](\'set\', true);          }        }      } else if (args[0] === \'ping\') {        var retr = {          gdprApplies: gdprApplies,          cmpLoaded: false,          cmpStatus: \'stub\'        };        if (typeof args[2] === \'function\') {          args[2](retr);        }      } else {        queue.push(args);      }    }    function postMessageEventHandler(event) {      var msgIsString = typeof event.data === \'string\';      var json = {};      try {        if (msgIsString) {          json = JSON.parse(event.data);        } else {          json = event.data;        }      } catch (ignore) {}      var payload = json.__tcfapiCall;      if (payload) {        window.__tcfapi(          payload.command,          payload.version,          function(retValue, success) {            var returnMsg = {              __tcfapiReturn: {                returnValue: retValue,                success: success,                callId: payload.callId              }            };            if (msgIsString) {              returnMsg = JSON.stringify(returnMsg);            }            event.source.postMessage(returnMsg, \'*\');          },          payload.parameter        );      }    }    while (win) {      try {        if (win.frames[TCF_LOCATOR_NAME]) {          cmpFrame = win;          break;        }      } catch (ignore) {}      if (win === window.top) {        break;      }      win = win.parent;    }    if (!cmpFrame) {      addFrame();      win.__tcfapi = tcfAPIHandler;      win.addEventListener(\'message\', postMessageEventHandler, false);    }  };  makeStub();  var uspStubFunction = function() {    var arg = arguments;    if (typeof window.__uspapi !== uspStubFunction) {      setTimeout(function() {        if (typeof window.__uspapi !== \'undefined\') {          window.__uspapi.apply(window.__uspapi, arg);        }      }, 500);    }  };  var checkIfUspIsReady = function() {    uspTries++;    if (window.__uspapi === uspStubFunction && uspTries < uspTriesLimit) {      console.warn(\'USP is not accessible\');    } else {      clearInterval(uspInterval);    }  };  if (typeof window.__uspapi === \'undefined\') {    window.__uspapi = uspStubFunction;    var uspInterval = setInterval(checkIfUspIsReady, 6000);  }})();</script><!-- End Quantcast Choice. Consent Manager Tag v2.0 (for TCF 2.0) -->\"}, {\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<script>    if (typeof _ceDeviceDetect != \'undefined\' && typeof _ceDeviceDetect.getDeviceType == \'function\') {        var _ceDisplayData = _ceDisplayData || {},            googletag,            loader = function (multipleAds) {                _ceDisplayData.gpt = _ceDisplayData.gpt || { items: [], defContName: \'div-gpt-ad\' };                (function () {                    var scriptInserter = document.createElement(\'script\');                    scriptInserter.src = \'https://www.googletagservices.com/tag/js/gpt.js\';                    scriptInserter.async = true;                    /*document.head.appendChild(scriptInserter);*/                    document.head.insertBefore(scriptInserter, document.head.firstChild);                })();                if (multipleAds) {                    googletag = {};                    googletag.cmd = [];                } else {                    googletag = googletag || {};                    googletag.cmd = googletag.cmd || [];                }                googletag.cmd.push(function () {                    googletag.pubads().enableSingleRequest();                    googletag.pubads().collapseEmptyDivs();                    googletag.enableServices();                });            };        loader();        window.addEventListener(\'_ceDisplayDataLoadHeader\', loader);    }</script>\"}, {\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<script>    (function () {        if (window.Element && !Element.prototype.closest) {            Element.prototype.closest = function (s) {                var matches = (this.document || this.ownerDocument).querySelectorAll(s),                    i,                    el = this;                do {                    i = matches.length;                    while (--i >= 0 && matches.item(i) !== el) { };                } while ((i < 0) && (el = el.parentElement));                return el;            };        }        window.googletag = window.googletag || { cmd: [] };        googletag.cmd.push(function () {            window.googletag.pubads().addEventListener(\'slotRenderEnded\', function (event) {                if (event.isEmpty) {                    var slotEl = document.getElementById(event.slot.getSlotId().getDomId());                    try {                        var advEl = slotEl.closest(\\".goAdverticum\\");                        if (advEl != undefined && advEl != null && advEl.contains(slotEl)) {                            slotEl = advEl;                        }                    } catch (e) { }                    slotEl.style.display = \'none\';                }            });        });    })();</script>\"}, {\"service_name\": \"Gemius\", \"weight\": null, \"source\": \"<script src=\\"//spl.hit.gemius.pl/gplayer.js\\" type=\\"text/javascript\\"></script>\"}]';
  this.positions_weighted['head'] = false;
  
  this.positions['body-start'] = '[{\"service_name\": \"Google Tag Manager\", \"weight\": null, \"source\": \"<noscript><iframe src=\\"//www.googletagmanager.com/ns.html?id=GTM-WQ7LZB\\"height=\\"0\\" width=\\"0\\" style=\\"display:none;visibility:hidden\\"></iframe></noscript><script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({\'gtm.start\':new Date().getTime(),event:\'gtm.js\'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!=\'dataLayer\'?\'&l=\'+l:\'\';j.async=true;j.src=\'//www.googletagmanager.com/gtm.js?id=\'+i+dl;f.parentNode.insertBefore(j,f);})(window,document,\'script\',\'dataLayer\',\'GTM-WQ7LZB\');</script>\"}]';
  this.positions_weighted['body-start'] = false;
  
  this.positions['body-end'] = '[{\"service_name\": \"Social\", \"weight\": null, \"source\": \"<script>function dataLayerPush(eventNetwork, eventAction, targetUrl) {    dataLayer.push({        \'event\'        : \'socialEvent\',        \'socialNetwork\': eventNetwork,        \'socialAction\' : eventAction,        \'socialTarget\' : targetUrl,        \'eventValue\'   : 1    });}try {    FB.Event.subscribe(\'edge.create\', function(targetUrl) {        dataLayerPush(\'facebook\', \'like\', targetUrl);    });    FB.Event.subscribe(\'edge.remove\', function(targetUrl) {        dataLayerPush(\'facebook\', \'unlike\', targetUrl);    });    FB.Event.subscribe(\'message.send\', function(targetUrl) {        dataLayerPush(\'facebook\', \'send\', targetUrl);    });} catch(err) {}</script>\"}, {\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\" src=\\"//ad.adverticum.net/g3.js\\"></script>\"}, {\"service_name\": \"Gemius\", \"weight\": null, \"source\": \"<script src=\\"//stat.p24.hu/CTS/measuring-codes/gem_stream.min.js?t=202010121\\" type=\\"text/javascript\\"></script>\"}]';
  this.positions_weighted['body-end'] = false;
  
  this.positions['body-end-adv'] = '[]';
  this.positions_weighted['body-end-adv'] = false;
  
  this.positions['content010'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div id=\\"ctsGadxTemp\\" ctsStyle=\\"${google_adx_style}\\" style=\\"display: none;\\"><ins class=\\"adsbygoogle\\" style=\\"display:inline-block;width:463px;height:150px;\\"        data-ad-client=\\"ca-pub-8962558862962174\\" data-ad-slot=\\"8455911264\\"        data-max-num-ads=1></ins><script type=\\"text/javascript\\">\t\t(function () {\t\t\tvar adxElement = document.getElementById(\'ctsGadxTemp\');\t\t\tvar adsByGoogleScript = document.createElement(\\"script\\");\t\t\tvar isSubscribed = false;\t\t\tadsByGoogleScript.src = \\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\";\t\t\tadxElement.removeAttribute(\'id\');\t\t\tif (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {\t\t\t\tisSubscribed = true;\t\t\t}\t\t\tif (!isSubscribed && (typeof noADX == \'undefined\' || noADX === false)) {\t\t\t\tif (adxElement.getAttribute(\\"ctsStyle\\") != null) {\t\t\t\t\tadxElement.style = adxElement.getAttribute(\\"ctsStyle\\");\t\t\t\t\tadxElement.removeAttribute(\\"ctsStyle\\");\t\t\t\t} else {\t\t\t\t\tadxElement.removeAttribute(\\"style\\");\t\t\t\t}\t\t\t\tadxElement.appendChild(adsByGoogleScript);\t\t\t\t(adsbygoogle = window.adsbygoogle || []).push({});\t\t\t} else {\t\t\t\tadxElement.parentNode.removeChild(adxElement);\t\t\t}\t\t})();\t</script></div>\"}, {\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div id=\\"cts_content_recomm\\" class=\\"ctsGadx\\" ctsStyle=\\"display:block;margin-top:30px;margin-bottom:30px;${custom_css}\\"    style=\\"display: none;\\"><script type=\\"text/javascript\\">        (function () {            var slotForDevice = {                desktop: \'1526024066\',                mobile: \'${google_adsense_content_recommendation_mobile}\',                tablet: \'${google_adsense_content_recommendation_mobile}\'            },                recommDiv = document.getElementById(\'cts_content_recomm\'),                slot = \'\',                isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (typeof _ceDeviceDetect.getDeviceType() !== \'undefined\') {                switch (_ceDeviceDetect.getDeviceType()) {                    case \'desktop\':                        slot = slotForDevice.desktop;                        break;                    case \'mobile\':                        slot = slotForDevice.mobile;                        if (slot == \'\') {                            slot = slotForDevice.desktop;                        }                        break;                    case \'tablet\':                        slot = slotForDevice.mobile;                        if (slot == \'\') {                            slot = slotForDevice.desktop;                        }                        break;                }            }            if (!isSubscribed && (typeof noADX == \'undefined\' || noADX === false) && slot != \'\') {                var advParts = {};                advParts.initScript = document.createElement(\'script\');                advParts.initScript.src = \'//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\';                advParts.initScript.async = \'true\';                advParts.body = document.createElement(\'ins\');                advParts.body.className = \'adsbygoogle\';                advParts.body.style.display = \'block\';                advParts.body.setAttribute(\'data-ad-format\', \'autorelaxed\');                advParts.body.setAttribute(\'data-ad-client\', \'ca-pub-8962558862962174\');                advParts.body.setAttribute(\'data-ad-slot\', slot);                recommDiv.appendChild(advParts.initScript);                recommDiv.appendChild(advParts.body);                if (recommDiv.getAttribute(\\"ctsStyle\\") != null) {                    recommDiv.style = recommDiv.getAttribute(\\"ctsStyle\\");                    recommDiv.removeAttribute(\\"ctsStyle\\");                } else {                    recommDiv.removeAttribute(\\"style\\");                }                (adsbygoogle = window.adsbygoogle || []).push({});                recommDiv.removeAttribute(\'id\');            } else {                recommDiv.parentNode.removeChild(recommDiv);            }        })();    </script></div>\"}]';
  this.positions_weighted['content010'] = false;
  
  this.positions['right030'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div class=\\"ctsGadx\\" id=\\"ctsGadx\\" ctsStyle=\\"${google_adx_style}\\" style=\\"display: none;\\"><div style=\\"width: 160px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div><script type=\\"text/javascript\\">        var ctsTplEl = document.getElementById(\\"ctsGadx\\");        var isSubscribed = false;        if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {            isSubscribed = true;        }        if (!isSubscribed && (typeof noADX == \'undefined\' || noADX === false)) {            var gaAdxSlots = [                {                    source: \'(direct)\',                    slots: [                        { slot: \'7746415280/1699831040\' }                    ]                },                {                    source: \'hirkereso.hu\',                    slots: [                        { slot: \'7746415280/7466909840\' }                    ]                },                {                    source: \'hirstart.hu\',                    slots: [                        { slot: \'7746415280/4373741360\' }                    ]                },                {                    source: \'kapu.hu\',                    slots: [                        { slot: \'7746415280/8803865000\' }                    ]                },                {                    source: \'startlap\',                    slots: [                        { slot: \'7746415280/4233988640\' }                    ]                },                {                    source: \'adbox\',                    slots: [                        { slot: \'${google_adx_slot_adbox}\' }                    ]                },                {                    source: \'hirek.oldal.info\',                    slots: [                        { slot: \'${google_adx_slot_hirekoldalinfo}\' }                    ]                },                {                    source: \'newsletter\',                    slots: [                        { slot: \'${google_adx_slot_newsletter}\' }                    ]                },                {                    source: \'tombola.hu\',                    slots: [                        { slot: \'${google_adx_slot_tombola}\' }                    ]                },                {                    source: \'facebook\',                    slots: [                        { slot: \'7746415280/9083370440\' },                        { slot: \'7746415280/9083370440\' }                    ]                },                {                    source: \'google\',                    slots: [                        { slot: \'7746415280/3036786200\' },                        { slot: \'7746415280/3036786200\' }                    ]                }            ];            var gaAdxSlotIdentifier = \'7746415280/9223123160\';            if (typeof ga == \'function\') {                var gaReferrer = ga.getAll()[0].get(\'referrer\');                if (typeof gaReferrer != \'undefined\' && gaReferrer != undefined) {                    for (var x = 0; x < gaAdxSlots.length; x++) {                        if (gaReferrer.indexOf(gaAdxSlots[x].source) != -1) {                            switch (gaAdxSlots[x].source) {                                default:                                    gaAdxSlotIdentifier = gaAdxSlots[x].slots[0].slot;                                    break;                            }                            break;                        }                    }                }            } else {                function readAsCookie(cname) {                    var name = cname + \\"=\\";                    var ca = document.cookie.split(\';\');                    for (var i = 0; i < ca.length; i++) {                        var c = ca[i].trim();                        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);                    }                    return \\"\\";                }                var utmz = readAsCookie(\'__utmz\');                var utmzVals = (function () {                    var pairs = utmz.split(\'.\').slice(4).join(\'.\').split(\'|\');                    var ga = {};                    for (var i = 0; i < pairs.length; i++) {                        var temp = pairs[i].split(\'=\');                        ga[temp[0]] = temp[1];                    }                    return ga;                })();                if (typeof utmzVals.utmccn == \'undefined\') utmzVals.utmccn = \'undefined\';                if (typeof utmzVals.utmcsr == \'undefined\') utmzVals.utmcsr = \'undefined\';                if (typeof utmzVals.utmcmd == \'undefined\') utmzVals.utmcmd = \'undefined\';                for (var x = 0; x < gaAdxSlots.length; x++) {                    if (utmzVals.utmccn.indexOf(gaAdxSlots[x].source) != -1 || utmzVals.utmcsr.indexOf(gaAdxSlots[x].source) != -1) {                        switch (gaAdxSlots[x].source) {                            case \'google\':                            case \'facebook\':                                if (utmzVals.utmcmd == \'cpc\') {                                    gaAdxSlotIdentifier = gaAdxSlots[x].slots[1].slot;                                } else if (utmzVals.utmcmd == \'organic\') {                                    gaAdxSlotIdentifier = gaAdxSlots[x].slots[0].slot;                                }                                break;                            default:                                gaAdxSlotIdentifier = gaAdxSlots[x].slots[0].slot;                                break;                        }                        break;                    }                }            }            if (gaAdxSlotIdentifier == \'\') gaAdxSlotIdentifier = \'7746415280/9223123160\';            gaAdxSlotIdentifier = \'5491763120/\' + gaAdxSlotIdentifier;            google_ad_client = \\"ca-pub-1984646123858990\\";            google_ad_slot = gaAdxSlotIdentifier;            google_ad_width = parseInt(160);            google_ad_height = parseInt(200);            google_max_num_ads = parseInt(1);            if (ctsTplEl.getAttribute(\\"ctsStyle\\") != null) {                ctsTplEl.style = ctsTplEl.getAttribute(\\"ctsStyle\\");                ctsTplEl.removeAttribute(\\"ctsStyle\\");            } else {                ctsTplEl.removeAttribute(\\"style\\");            }        } else {            var elements = document.getElementsByClassName(\\"ctsGadx\\");            while (elements.length > 0) {                elements[0].parentNode.removeChild(elements[0]);            }        }    </script><script type=\\"text/javascript\\" src=\\"//pagead2.googlesyndication.com/pagead/show_ads.js\\"></script></div>\"}]';
  this.positions_weighted['right030'] = false;
  
  this.positions['content030'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div class=\\"ctsGadx\\" id=\\"ctsGadx\\" ctsStyle=\\"${google_adx_style}\\" style=\\"display: none;\\"><div style=\\"width: 300px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div><script type=\\"text/javascript\\">        var ctsTplEl = document.getElementById(\\"ctsGadx\\");        var isSubscribed = false;        if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {            isSubscribed = true;        }        if (!isSubscribed && (typeof noADX == \'undefined\' || noADX === false)) {            var gaAdxSlots = [                {                    source: \'(direct)\',                    slots: [                        { slot: \'1201392200/2678100080\' }                    ]                },                {                    source: \'hirkereso.hu\',                    slots: [                        { slot: \'1201392200/7108223720\' }                    ]                },                {                    source: \'hirstart.hu\',                    slots: [                        { slot: \'1201392200/8584931600\' }                    ]                },                {                    source: \'kapu.hu\',                    slots: [                        { slot: \'1201392200/1061639480\' }                    ]                },                {                    source: \'startlap\',                    slots: [                        { slot: \'1201392200/2538347360\' }                    ]                },                {                    source: \'adbox\',                    slots: [                        { slot: \'${google_adx_slot_adbox}\' }                    ]                },                {                    source: \'hirek.oldal.info\',                    slots: [                        { slot: \'${google_adx_slot_hirekoldalinfo}\' }                    ]                },                {                    source: \'newsletter\',                    slots: [                        { slot: \'${google_adx_slot_newsletter}\' }                    ]                },                {                    source: \'tombola.hu\',                    slots: [                        { slot: \'${google_adx_slot_tombola}\' }                    ]                },                {                    source: \'facebook\',                    slots: [                        { slot: \'1201392200/4154807960\' },                        { slot: \'1201392200/4154807960\' }                    ]                },                {                    source: \'google\',                    slots: [                        { slot: \'1201392200/5631515840\' },                        { slot: \'1201392200/5631515840\' }                    ]                }            ];            var gaAdxSlotIdentifier = \'1201392200/4015055240\';            if (typeof ga == \'function\') {                var gaReferrer = ga.getAll()[0].get(\'referrer\');                if (typeof gaReferrer != \'undefined\' && gaReferrer != undefined) {                    for (var x = 0; x < gaAdxSlots.length; x++) {                        if (gaReferrer.indexOf(gaAdxSlots[x].source) != -1) {                            switch (gaAdxSlots[x].source) {                                default:                                    gaAdxSlotIdentifier = gaAdxSlots[x].slots[0].slot;                                    break;                            }                            break;                        }                    }                }            } else {                function readAsCookie(cname) {                    var name = cname + \\"=\\";                    var ca = document.cookie.split(\';\');                    for (var i = 0; i < ca.length; i++) {                        var c = ca[i].trim();                        if (c.indexOf(name) == 0) return c.substring(name.length, c.length);                    }                    return \\"\\";                }                var utmz = readAsCookie(\'__utmz\');                var utmzVals = (function () {                    var pairs = utmz.split(\'.\').slice(4).join(\'.\').split(\'|\');                    var ga = {};                    for (var i = 0; i < pairs.length; i++) {                        var temp = pairs[i].split(\'=\');                        ga[temp[0]] = temp[1];                    }                    return ga;                })();                if (typeof utmzVals.utmccn == \'undefined\') utmzVals.utmccn = \'undefined\';                if (typeof utmzVals.utmcsr == \'undefined\') utmzVals.utmcsr = \'undefined\';                if (typeof utmzVals.utmcmd == \'undefined\') utmzVals.utmcmd = \'undefined\';                for (var x = 0; x < gaAdxSlots.length; x++) {                    if (utmzVals.utmccn.indexOf(gaAdxSlots[x].source) != -1 || utmzVals.utmcsr.indexOf(gaAdxSlots[x].source) != -1) {                        switch (gaAdxSlots[x].source) {                            case \'google\':                            case \'facebook\':                                if (utmzVals.utmcmd == \'cpc\') {                                    gaAdxSlotIdentifier = gaAdxSlots[x].slots[1].slot;                                } else if (utmzVals.utmcmd == \'organic\') {                                    gaAdxSlotIdentifier = gaAdxSlots[x].slots[0].slot;                                }                                break;                            default:                                gaAdxSlotIdentifier = gaAdxSlots[x].slots[0].slot;                                break;                        }                        break;                    }                }            }            if (gaAdxSlotIdentifier == \'\') gaAdxSlotIdentifier = \'1201392200/4015055240\';            gaAdxSlotIdentifier = \'5491763120/\' + gaAdxSlotIdentifier;            google_ad_client = \\"ca-pub-1984646123858990\\";            google_ad_slot = gaAdxSlotIdentifier;            google_ad_width = parseInt(300);            google_ad_height = parseInt(250);            google_max_num_ads = parseInt(1);            if (ctsTplEl.getAttribute(\\"ctsStyle\\") != null) {                ctsTplEl.style = ctsTplEl.getAttribute(\\"ctsStyle\\");                ctsTplEl.removeAttribute(\\"ctsStyle\\");            } else {                ctsTplEl.removeAttribute(\\"style\\");            }        } else {            var elements = document.getElementsByClassName(\\"ctsGadx\\");            while (elements.length > 0) {                elements[0].parentNode.removeChild(elements[0]);            }        }    </script><script type=\\"text/javascript\\" src=\\"//pagead2.googlesyndication.com/pagead/show_ads.js\\"></script></div>\"}]';
  this.positions_weighted['content030'] = false;
}

Tagging.prototype.get_json = function(text) {
  return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(text.replace(/"(\\.|[^"\\])*"/g, '')))
         && eval('(' + text + ')');
}

Tagging.prototype.random_tag = function(position) {
  var tags = [];
  var weighted_tags = [];

  for (index in position) {
    tag = position[index];
    tags[index] = tag.source;

    for (var i = 0; i < tag.weight; i++) {
      weighted_tags.push(index);
    }
  }

  // Pick a random tag from array based on weight
  var random_index = weighted_tags[Math.floor((Math.random() * weighted_tags.length))];
  return tags[random_index];
}

Tagging.prototype.all_tags = function(position) {
  var tags = [], index, tag;
  for (index in position) {
    tag = position[index];
    tags[index] = tag.source;
  }
  return tags.join("\n");
}

Tagging.prototype.render = function(slug, context) {
    document.write(this.get_source(slug, context));
}

Tagging.prototype.get_source = function(slug, context) {
  if (typeof this.positions[slug] == 'undefined') {
    // This position doesn't exist, call the autodetect
    this._detect(slug);
  } else {
    var position = this.get_json(this.positions[slug]);
    var tag_source = "";

    if (this.positions_weighted[slug]) {
      tag_source = this.random_tag(position)
    } else {
      tag_source = this.all_tags(position);
    }

    // Replace variables
    var variables = {};
    for (variable in this.context) {
      variables[variable] = this.context[variable];
    }
    for (variable in context) {
      variables[variable] = context[variable];
    }
    tag_source = this._replace_variables(tag_source, variables);

    // Remove unset variables and return result
    return tag_source.replace(/\$\w+/g, "").replace(/\${\w+}/g, "");
  }
  return '';
}

Tagging.prototype.log = function(err) {
  //this._load(error_endpoint);
}

Tagging.prototype._load = function(url) {
  var head = document.getElementsByTagName('head')[0] || document.documentElement,
      script = document.createElement('script');

  script.type = 'text/javascript';
  script.src = url;
  head.appendChild(script);
}

Tagging.prototype._detect = function(position) {
  this._load(this.autodetect_url + this.site +'/'+ this.zone +'/' + position + '/');
}

Tagging.prototype._replace_variables = function(content, variables) {
  var RE_VALID_IDENT = /^[a-zA-Z_]\w*$/;
  for (variable in variables) {
    if (RE_VALID_IDENT.test(variable)) {
      var regexes = [new RegExp('\\$' + variable, 'g'), new RegExp('\\${' + variable + '}', 'g')];

      for (re in regexes) {
        content = content.replace(regexes[re], variables[variable]);
      }
    } else {
      throw "'" + variable + "' is not a valid identifier.";
    }
  }
  return content;
}



