Tagging = function(context) {
  this.site = 'eoldal';
  this.zone = 'zene';
  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\": \"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\": \"Gemius Traffic\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\">    if (document.location.hostname == \'www.eoldal.hu\') {        var pp_gemius_identifier = \'bQcwssdhZ35KZIdlnNYGEPTZXmeFmXsEEAVHJQv.R13.Z7\';        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\": \"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'] = '[]';
  this.positions_weighted['body-start'] = false;
  
  this.positions['body-end'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\" src=\\"//ad.adverticum.net/g3.js\\"></script>\"}, {\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\">    (function(){        var googleCPLink = (\\"${google_cookie_policy_link}\\" != \\"\\") ? \\"${google_cookie_policy_link}\\" : \\"http://centralmediacsoport.hu/Company/Central-Digitalis-Media-Adatkezelesi-tajekoztato\\";        var googleCPRename = (\\"${google_cookie_policy_rename}\\" != \\"\\") ? \\"${google_cookie_policy_rename}\\" : 1;            window.cookieconsent_options = {            \\"message\\"   : \\"A weboldalon cookie-kat haszn&#xE1;lunk, hogy biztons&#xE1;gos b&#xF6;ng&#xE9;sz&#xE9;s mellett a legjobb felhaszn&#xE1;l&#xF3;i &#xE9;lm&#xE9;nyt ny&#xFA;jthassunk.\\",            \\"dismiss\\"   : \\"Rendben!\\",            \\"learnMore\\" : \\"R&#xE9;szletes le&#xED;r&#xE1;s\\",            \\"link\\"      : googleCPLink,            \\"theme\\"     : \\"//stat.p24.hu/CTS/helper-scripts/cookieconsent/styles/custom.css\\",            \\"expiryDays\\": 1095,            \\"renamed\\"   : googleCPRename        };    })();</script><script type=\\"text/javascript\\" src=\\"//stat.p24.hu/CTS/helper-scripts/cookieconsent/cookieconsent.min.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'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 76216 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone76216\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['body-end-adv'] = false;
  
  this.positions['top'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div id=\\"ctsGadxTemp\\" class=\\"ctsGadx\\" ctsStyle=\\"width: 728px;\\" style=\\"display: none;\\"><script type=\\"text/javascript\\">        (function () {            var slotForDevice = \\"2855277799\\";            var gadxErr = false;            var dimensionForDevice = {                width: parseInt(728) || 0,                height: parseInt(90) || 0            };            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed && (typeof noADX == \'undefined\' || noADX === false) && slotForDevice != \'\') {                var advParts = {};                var gadxDiv = document.getElementById(\'ctsGadxTemp\');                gadxDiv.style.width = dimensionForDevice.width + \'px\';                advParts.initScript = document.createElement(\'script\');                advParts.initScript.src = \'//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\';                advParts.initScript.async = \'true\';                advParts.adText = document.createElement(\'div\');                advParts.adText.style = \\"text-align: right; font-size: 8px; color: #C6C6C6; margin: 0 auto;\\";                advParts.adText.innerHTML += \\"HIRDET&#xC9;S\\";                advParts.body = document.createElement(\'ins\');                advParts.body.className = \'adsbygoogle\';                advParts.body.style.display = \'table\';                advParts.body.style.margin = \'0 auto\';                advParts.body.style.width = dimensionForDevice.width + \'px\';                advParts.body.style.height = dimensionForDevice.height + \'px\';                advParts.body.setAttribute(\'data-ad-client\', \'ca-pub-8962558862962174\');                advParts.body.setAttribute(\'data-ad-slot\', slotForDevice);                advParts.body.setAttribute(\'data-max-num-ads\', parseInt(${google_max_num_ads}) || 1);                gadxDiv.appendChild(advParts.adText);                gadxDiv.appendChild(advParts.initScript);                gadxDiv.appendChild(advParts.body);                if (gadxDiv.getAttribute(\\"ctsStyle\\") != null) {                    gadxDiv.style = gadxDiv.getAttribute(\\"ctsStyle\\");                    gadxDiv.removeAttribute(\\"ctsStyle\\");                } else {                    gadxDiv.removeAttribute(\\"style\\");                }                (adsbygoogle = window.adsbygoogle || []).push({});                gadxDiv.removeAttribute(\'id\');            } else {                var adxElement = document.getElementById(\'ctsGadxTemp\');                adxElement.parentNode.removeChild(adxElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['top'] = false;
  
  this.positions['top-hl'] = '[{\"service_name\": \"Google Adverts\", \"weight\": 0, \"source\": \"<div id=\\"ctsGadxTemp\\" ctsStyle=\\"text-align: right; font-size: 8px; color: #C6C6C6; margin: 0 auto;\\"    style=\\"display: none;\\">    HIRDET&#xC9;S    <ins class=\\"adsbygoogle\\"        style=\\"display:inline-block;width:300px;height:250px;${custom_css}\\"        data-ad-client=\\"ca-pub-8962558862962174\\" data-ad-slot=\\"4956456861\\"        data-max-num-ads=${google_max_num_ads}></ins><script type=\\"text/javascript\\">        (function () {            var adxElement = document.getElementById(\'ctsGadxTemp\');            var adsByGoogleScript = document.createElement(\\"script\\");            var isSubscribed = false;            adsByGoogleScript.src = \\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\";            adxElement.removeAttribute(\'id\');            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed && (typeof noADX == \'undefined\' || noADX === false)) {                adxElement.appendChild(adsByGoogleScript);                if (adxElement.getAttribute(\\"ctsStyle\\") != null) {                    adxElement.style = adxElement.getAttribute(\\"ctsStyle\\");                    adxElement.removeAttribute(\\"ctsStyle\\");                } else {                    adxElement.removeAttribute(\\"style\\");                }                (adsbygoogle = window.adsbygoogle || []).push({});            } else {                adxElement.parentNode.removeChild(adxElement);            }        })();    </script></div>\"}, {\"service_name\": \"Adverticum AdServer\", \"weight\": 100, \"source\": \"<!-- Goa3: 2228347 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone2228347\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['top-hl'] = true;
  
  this.positions['top-blog'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 1742457 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone1742457\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['top-blog'] = false;
  
  this.positions['top-other'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 2228345 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone2228345\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['top-other'] = false;
  
  this.positions['right010'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 5080391 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone5080391\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['right010'] = false;
  
  this.positions['right020'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 2228346 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone2228346\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['right020'] = false;
  
  this.positions['sky-hl'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div id=\\"ctsGadxTemp\\" ctsStyle=\\"text-align: right; font-size: 8px; color: #C6C6C6; margin: 0 auto;\\"    style=\\"display: none;\\">    HIRDET&#xC9;S    <ins class=\\"adsbygoogle\\"        style=\\"display:inline-block;width:300px;height:600px;${custom_css}\\"        data-ad-client=\\"ca-pub-8962558862962174\\" data-ad-slot=\\"7430562762\\"        data-max-num-ads=${google_max_num_ads}></ins><script type=\\"text/javascript\\">        (function () {            var adxElement = document.getElementById(\'ctsGadxTemp\');            var adsByGoogleScript = document.createElement(\\"script\\");            var isSubscribed = false;            adsByGoogleScript.src = \\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\";            adxElement.removeAttribute(\'id\');            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed && (typeof noADX == \'undefined\' || noADX === false)) {                adxElement.appendChild(adsByGoogleScript);                if (adxElement.getAttribute(\\"ctsStyle\\") != null) {                    adxElement.style = adxElement.getAttribute(\\"ctsStyle\\");                    adxElement.removeAttribute(\\"ctsStyle\\");                } else {                    adxElement.removeAttribute(\\"style\\");                }                (adsbygoogle = window.adsbygoogle || []).push({});            } else {                adxElement.parentNode.removeChild(adxElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['sky-hl'] = false;
  
  this.positions['sky-user'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 78134 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone78134\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['sky-user'] = false;
  
  this.positions['sky-other'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 2228344 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone2228344\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['sky-other'] = false;
  
  this.positions['header010'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 2081568 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone2081568\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['header010'] = false;
  
  this.positions['header020'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 2081567 --><div id=\\"ctstemp\\" class=\\"goAdverticum\\" style=\\"display: none;\\"><script>        (function () {            var insertedElement = document.getElementById(\\"ctstemp\\");            var isSubscribed = false;            if (typeof _ceSubscriptionDetect != \'undefined\' && _ceSubscriptionDetect.getSubscriptionData() != undefined && _ceSubscriptionDetect.getSubscriptionData().isSubscribed) {                isSubscribed = true;            }            if (!isSubscribed) {                insertedElement.id = \\"zone2081567\\";                if (insertedElement.getAttribute(\\"ctsStyle\\") != null) {                    insertedElement.style = insertedElement.getAttribute(\\"ctsStyle\\");                    insertedElement.removeAttribute(\\"ctsStyle\\");                } else {                    insertedElement.removeAttribute(\\"style\\");                }            } else {                insertedElement.parentNode.removeChild(insertedElement);            }        })();    </script></div>\"}]';
  this.positions_weighted['header020'] = false;
  
  this.positions['bottom'] = '[{\"service_name\": \"Sanoma/Hirstart\", \"weight\": null, \"source\": \"<div id=\'hirstart_rss_partner_box\' class=\\"_ce_measure_widget\\" data-ce-measure-widget=\\"hirstart_rss_partner_box\\" style=\\"display: flex; margin: 0 auto; max-width: 800px;\\"></div><script>    (function () {        var src = \'\',        insertedElement = document.getElementById(\'hirstart_rss_partner_box\');        if (typeof _ceDeviceDetect.getDeviceType() !== \'undefined\') {            switch (_ceDeviceDetect.getDeviceType()) {                case \'desktop\':                    src = \'https://box.hirstart.hu/site/jsembed_news.php?pid=8&id=1502\';                    break;                case \'mobile\':                    src = \'https://box.hirstart.hu/site/jsembed_news.php?pid=8&id=1502\';                    break;                case \'tablet\':                    src = \'https://box.hirstart.hu/site/jsembed_news.php?pid=8&id=1502\';                    break;            }        }        if (src != \'\') {            insertedElement.id = \\"hirstartbox-8-1502\\";            var s = document.createElement(\\"script\\");            s.type = \\"text/javascript\\";            s.async = true;            s.src = src;            document.getElementsByTagName(\\"head\\")[0].appendChild(s);        } else {            insertedElement.parentNode.removeChild(insertedElement);        }    })();</script>\"}]';
  this.positions_weighted['bottom'] = false;
  
  this.positions['content-bottom'] = '[{\"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: \'5168150069\',                mobile: \'8566575955\',                tablet: \'8566575955\'            },                recommDiv = document.getElementById(\'cts_content_recomm\'),                slot = \'\',                parameter = \'\',                googleUniqueParameters = {                    desktop: \'${google_recomm_unique_parameters}\',                    mobile: \'{\\"data-matched-content-rows-num\\": \\"12,6\\", \\"data-matched-content-columns-num\\": \\"1,2\\", \\"data-matched-content-ui-type\\": \\"image_sidebyside,image_sidebyside\\"}\',                    tablet: \'{\\"data-matched-content-rows-num\\": \\"12,6\\", \\"data-matched-content-columns-num\\": \\"1,2\\", \\"data-matched-content-ui-type\\": \\"image_sidebyside,image_sidebyside\\"}\'                };            var 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;                        parameter = googleUniqueParameters.desktop;                        break;                    case \'mobile\':                        slot = slotForDevice.mobile;                        parameter = googleUniqueParameters.mobile;                        if (slot == \'\') {                            slot = slotForDevice.desktop;                        }                        break;                    case \'tablet\':                        slot = slotForDevice.mobile;                        parameter = googleUniqueParameters.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);                try {                    parameter = JSON.parse(parameter);                    for (var key in parameter) {                        if (parameter.hasOwnProperty(key)) {                            advParts.body.setAttribute(key, parameter[key]);                        }                    }                } catch (e) {                }                if (recommDiv.getAttribute(\\"ctsStyle\\") != null) {                    recommDiv.style = recommDiv.getAttribute(\\"ctsStyle\\");                    recommDiv.removeAttribute(\\"ctsStyle\\");                } else {                    recommDiv.removeAttribute(\\"style\\");                }                recommDiv.appendChild(advParts.initScript);                recommDiv.appendChild(advParts.body);                (adsbygoogle = window.adsbygoogle || []).push({});                recommDiv.removeAttribute(\'id\');            } else {                recommDiv.parentNode.removeChild(recommDiv);            }        })();    </script></div>\"}]';
  this.positions_weighted['content-bottom'] = 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;
}



