Tagging = function(context) {
  this.site = 'hirstart';
  this.zone = 'hirkoteg';
  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['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\": \"Sanoma/Hirstart\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\" src=\\"//stat.p24.hu/CTS/measuring-codes/hirstart/desktop/measuringCode.min.js?t=20190924\\"></script>\"}, {\"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\": \"ADAPT\", \"weight\": 0, \"source\": \"<script src=\\"//stat.p24.hu/switcher.js\\" type=\\"text/javascript\\"></script>\"}]';
  this.positions_weighted['body-end'] = false;
  
  this.positions['body-start'] = '[{\"service_name\": \"Google Tag Manager\", \"weight\": null, \"source\": \"<noscript><iframe src=\\"//www.googletagmanager.com/ns.html?id=GTM-N3KR9Z\\"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-N3KR9Z\');</script>\"}, {\"service_name\": \"Sanoma/Hirstart\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\">  var s = \'<div id=\\"dialog-confirm\\" style=\\"display:none; cursor: default;\\">\';        s += \'<img src=\\"//www.hirstart.hu/site/res/img/adult18plus.png\\" /><br />\';        s += \'<p style=\\"text-align:center; font-family:Arial; font-weight:bold; font-size:13px;color:#dddddd;\\">Az &Ouml;n &aacute;ltal k&eacute;rt lap feln&otilde;tt l&aacute;togat&oacute;knak sz&oacute;l!<br />Biztosan, meg akarja n&eacute;zni?</p>\';        s += \'<div style=\\"margin-top: 50px;\\">\';          s += \'<input type=\\"button\\" style=\\"padding: 7px 15px;color: #555555;font-size: 13px;font-weight: bold;cursor:pointer;\\" id=\\"18layer-yes\\" value=\\"Igen\\" />\';          s += \'<input type=\\"button\\" style=\\"padding: 7px 15px;color: #555555;font-size: 13px;font-weight: bold;cursor:pointer;\\" id=\\"18layer-no\\" value=\\"Nem\\" />\';        s += \'</div>\';      s += \'</div>\';  if (put18PlusDialog) document.write(s);</script>\"}]';
  this.positions_weighted['body-start'] = false;
  
  this.positions['head'] = '[{\"service_name\": \"Sanoma\", \"weight\": null, \"source\": \"<script src=\\"//stat.p24.hu/mobile_detect/mobile_detect.js\\"></script>\"}, {\"service_name\": \"Gemius Traffic\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\">    var properGemId = (\'${gemius_trackid}\' != \'\' ? \'${gemius_trackid}\' : \'ofrrQ.NmAI93l5wW9ZJ55Gazj721ORuyXLDkSdi9Jrv.n7\');        if(typeof _ceDeviceDetect.getDeviceType() !== \'undefined\' && _ceDeviceDetect.getDeviceType() != \'desktop\' && \'ofrlRfNmpZfXzr2CXURimWX1zUW17QNKkhark.sQfO..v7\' != \'\') {        properGemId = \'ofrlRfNmpZfXzr2CXURimWX1zUW17QNKkhark.sQfO..v7\';    }       var pp_gemius_identifier = properGemId;    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 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\": \"jQuery\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\" src=\\"//stat.p24.hu/hirstart/cts/jquery.blockUI.js\\"></script>\"}, {\"service_name\": \"Sanoma/Hirstart\", \"weight\": null, \"source\": \"<script>    var path = window.location.pathname;    var pathElements = path.split(\'/\');    var pathLastElement = pathElements[pathElements.length - 1];    var put18PlusDialog = false;    var is18PlusSearch = false;    var topParam = \'32%\';    if (window.location.host == \'m.hirstart.hu\') topParam = \'10%\';        if (path.indexOf(\'/keres/\') != -1 && path.indexOf(\'/szex/\') != -1) is18PlusSearch = true;        if (pathLastElement == \'szex.php\' || pathLastElement == \'szex\' || is18PlusSearch) {            put18PlusDialog = true;            if($.cookie(\\"firsttime\\") != 1){            jQuery(document).ready(function ($) {                $.blockUI({                    message: $(\'#dialog-confirm\'),                    css: {                        top: topParam,                        border: \'none\',                        backgroundColor: \'#212121\',                        \'-webkit-border-radius\': \'10px\',                        \'-moz-border-radius\': \'10px\',                        opacity: 1,                        color: \'#fff\'                    },                    overlayCSS: {                        backgroundColor: \'#212121\',                        opacity: 1,                        cursor: \'default\'                    }                });                    $(\'#18layer-yes\').click(function (e) {                    setFirstTimeCookie();                    $.unblockUI();                    e.preventDefault();                    e.stopPropagation();                });                $(\'#18layer-no\').click(function () {                    window.location.href = \\"//hirstart.hu/\\";                });                });        }            function setFirstTimeCookie(){            $.cookie(\\"firsttime\\", \\"1\\", { path: \'/\' });        }        }</script>\"}, {\"service_name\": \"Sanoma\", \"weight\": null, \"source\": \"<script type=\\"text/javascript\\" src=\\"//segment.p24.hu/cerment.min.js\\" async></script>\"}, {\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<script>if (typeof _ceDeviceDetect != \'undefined\' && typeof _ceDeviceDetect.getDeviceType == \'function\') {    var _ceDisplayData = _ceDisplayData || {};    _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);    })();        var googletag = googletag || {};    googletag.cmd = googletag.cmd || [];    googletag.cmd.push(function() {        googletag.pubads().enableSingleRequest();        googletag.pubads().collapseEmptyDivs();        googletag.enableServices();    });}</script>\"}]';
  this.positions_weighted['head'] = false;
  
  this.positions['body-end-adv'] = '[]';
  this.positions_weighted['body-end-adv'] = false;
  
  this.positions['left010'] = '[]';
  this.positions_weighted['left010'] = false;
  
  this.positions['left020'] = '[]';
  this.positions_weighted['left020'] = false;
  
  this.positions['left030'] = '[]';
  this.positions_weighted['left030'] = false;
  
  this.positions['list-adx-left020'] = '[]';
  this.positions_weighted['list-adx-left020'] = false;
  
  this.positions['adx-bottom'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<script async src=\\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\"></script><ins class=\\"adsbygoogle\\"    style=\\"display:inline-block;width:980px;height:90px\\"    data-ad-client=\\"ca-pub-8962558862962174\\"    data-ad-slot=\\"9075303264\\"    data-max-num-ads=5></ins><script>    if (typeof noADX == \'undefined\' || noADX === false) {        (adsbygoogle = window.adsbygoogle || []).push({});    }</script>\"}]';
  this.positions_weighted['adx-bottom'] = false;
  
  this.positions['theme-adx-top'] = '[{\"service_name\": \"Google Adverts\", \"weight\": 0, \"source\": \"<div class=\\"ctsGadx\\" style=\\"margin-left: 5px;\\"><script type=\\"text/javascript\\">        if (typeof noADX == \'undefined\' || noADX === false) {            if (\'true\' != \'true\') {                document.write(\'<div style=\\"width: \' + 465 +\'px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div>\');            }            var gaAdxSlots = [                {                    source: \'(direct)\',                    slots: [                        {slot: \'${google_adx_slot_direct}\'}                    ]                },                {                    source: \'hirkereso.hu\',                    slots: [                        {slot: \'${google_adx_slot_hirkereso}\'}                    ]                },                {                    source: \'hirstart.hu\',                    slots: [                        {slot: \'${google_adx_slot_hirstart}\'}                    ]                },                {                    source: \'kapu.hu\',                    slots: [                        {slot: \'${google_adx_slot_kapu}\'}                    ]                },                {                    source: \'startlap\',                    slots: [                        {slot: \'${google_adx_slot_startlap}\'}                    ]                },                {                    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: \'${google_adx_slot_facebook_organic}\'},                        {slot: \'${google_adx_slot_facebook_cpc}\'}                    ]                },                {                    source: \'google\',                    slots: [                        {slot: \'${google_adx_slot_google_organic}\'},                        {slot: \'${google_adx_slot_google_cpc}\'}                    ]                }            ];            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\';            var gaAdxSlotIdentifier = \'3775593841/4833043561\';            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 = \'3775593841/4833043561\';            if (\'true\' == \'true\') {                gaAdxSlotIdentifier = gaAdxSlotIdentifier;            } else {                gaAdxSlotIdentifier = \'1504628240/\' + gaAdxSlotIdentifier;            }            if (\'ca-pub-4337926688528987\' == \'\'){                google_ad_client = \\"ca-pub-1984646123858990\\";            } else {                google_ad_client = \\"ca-pub-4337926688528987\\";            }            google_ad_slot = gaAdxSlotIdentifier;            google_ad_width = parseInt(465);            google_ad_height = parseInt(258);            google_max_num_ads = parseInt(4);        } 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>\"}, {\"service_name\": \"Google Adverts\", \"weight\": 100, \"source\": \"<script async src=\\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\"></script><ins class=\\"adsbygoogle\\"    style=\\"display:inline-block;width:465px;height:258px\\"    data-ad-client=\\"ca-pub-8962558862962174\\"    data-ad-slot=\\"6213668066\\"    data-max-num-ads=4></ins><script>    if (typeof noADX == \'undefined\' || noADX === false) {        (adsbygoogle = window.adsbygoogle || []).push({});    }</script>\"}]';
  this.positions_weighted['theme-adx-top'] = true;
  
  this.positions['theme-adx-bottom'] = '[{\"service_name\": \"Google Adverts\", \"weight\": 0, \"source\": \"<div class=\\"ctsGadx\\" style=\\"margin-left: 5px;\\"><script type=\\"text/javascript\\">        if (typeof noADX == \'undefined\' || noADX === false) {            if (\'true\' != \'true\') {                document.write(\'<div style=\\"width: \' + 465 +\'px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div>\');            }            var gaAdxSlots = [                {                    source: \'(direct)\',                    slots: [                        {slot: \'${google_adx_slot_direct}\'}                    ]                },                {                    source: \'hirkereso.hu\',                    slots: [                        {slot: \'${google_adx_slot_hirkereso}\'}                    ]                },                {                    source: \'hirstart.hu\',                    slots: [                        {slot: \'${google_adx_slot_hirstart}\'}                    ]                },                {                    source: \'kapu.hu\',                    slots: [                        {slot: \'${google_adx_slot_kapu}\'}                    ]                },                {                    source: \'startlap\',                    slots: [                        {slot: \'${google_adx_slot_startlap}\'}                    ]                },                {                    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: \'${google_adx_slot_facebook_organic}\'},                        {slot: \'${google_adx_slot_facebook_cpc}\'}                    ]                },                {                    source: \'google\',                    slots: [                        {slot: \'${google_adx_slot_google_organic}\'},                        {slot: \'${google_adx_slot_google_cpc}\'}                    ]                }            ];            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\';            var gaAdxSlotIdentifier = \'3775593841/3356335681\';            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 = \'3775593841/3356335681\';            if (\'true\' == \'true\') {                gaAdxSlotIdentifier = gaAdxSlotIdentifier;            } else {                gaAdxSlotIdentifier = \'1504628240/\' + gaAdxSlotIdentifier;            }            if (\'ca-pub-4337926688528987\' == \'\'){                google_ad_client = \\"ca-pub-1984646123858990\\";            } else {                google_ad_client = \\"ca-pub-4337926688528987\\";            }            google_ad_slot = gaAdxSlotIdentifier;            google_ad_width = parseInt(465);            google_ad_height = parseInt(258);            google_max_num_ads = parseInt(4);        } 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>\"}, {\"service_name\": \"Google Adverts\", \"weight\": 100, \"source\": \"<script async src=\\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\"></script><ins class=\\"adsbygoogle\\"    style=\\"display:inline-block;width:465px;height:258px\\"    data-ad-client=\\"ca-pub-8962558862962174\\"    data-ad-slot=\\"3899330069\\"    data-max-num-ads=4></ins><script>    if (typeof noADX == \'undefined\' || noADX === false) {        (adsbygoogle = window.adsbygoogle || []).push({});    }</script>\"}]';
  this.positions_weighted['theme-adx-bottom'] = true;
  
  this.positions['category-adx-top'] = '[{\"service_name\": \"Google Adverts\", \"weight\": 0, \"source\": \"<div class=\\"ctsGadx\\" style=\\"${google_adx_style}\\"><script type=\\"text/javascript\\">        if (typeof noADX == \'undefined\' || noADX === false) {            if (\'true\' != \'true\') {                document.write(\'<div style=\\"width: \' + 490 +\'px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div>\');            }            var gaAdxSlots = [                {                    source: \'(direct)\',                    slots: [                        {slot: \'${google_adx_slot_direct}\'}                    ]                },                {                    source: \'hirkereso.hu\',                    slots: [                        {slot: \'${google_adx_slot_hirkereso}\'}                    ]                },                {                    source: \'hirstart.hu\',                    slots: [                        {slot: \'${google_adx_slot_hirstart}\'}                    ]                },                {                    source: \'kapu.hu\',                    slots: [                        {slot: \'${google_adx_slot_kapu}\'}                    ]                },                {                    source: \'startlap\',                    slots: [                        {slot: \'${google_adx_slot_startlap}\'}                    ]                },                {                    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: \'${google_adx_slot_facebook_organic}\'},                        {slot: \'${google_adx_slot_facebook_cpc}\'}                    ]                },                {                    source: \'google\',                    slots: [                        {slot: \'${google_adx_slot_google_organic}\'},                        {slot: \'${google_adx_slot_google_cpc}\'}                    ]                }            ];            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\';            var gaAdxSlotIdentifier = \'3775593841/9682425361\';            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 = \'3775593841/9682425361\';            if (\'true\' == \'true\') {                gaAdxSlotIdentifier = gaAdxSlotIdentifier;            } else {                gaAdxSlotIdentifier = \'1504628240/\' + gaAdxSlotIdentifier;            }            if (\'ca-pub-4337926688528987\' == \'\'){                google_ad_client = \\"ca-pub-1984646123858990\\";            } else {                google_ad_client = \\"ca-pub-4337926688528987\\";            }            google_ad_slot = gaAdxSlotIdentifier;            google_ad_width = parseInt(490);            google_ad_height = parseInt(172);            google_max_num_ads = parseInt(2);        } 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>\"}, {\"service_name\": \"Google Adverts\", \"weight\": 100, \"source\": \"<script async src=\\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\"></script><ins class=\\"adsbygoogle\\"    style=\\"display:inline-block;width:490px;height:172px\\"    data-ad-client=\\"ca-pub-8962558862962174\\"    data-ad-slot=\\"1148410468\\"    data-max-num-ads=2></ins><script>    if (typeof noADX == \'undefined\' || noADX === false) {        (adsbygoogle = window.adsbygoogle || []).push({});    }</script>\"}]';
  this.positions_weighted['category-adx-top'] = true;
  
  this.positions['category-adx-bottom'] = '[{\"service_name\": \"Google Adverts\", \"weight\": 0, \"source\": \"<div class=\\"ctsGadx\\" style=\\"${google_adx_style}\\"><script type=\\"text/javascript\\">        if (typeof noADX == \'undefined\' || noADX === false) {            if (\'true\' != \'true\') {                document.write(\'<div style=\\"width: \' + 490 +\'px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div>\');            }            var gaAdxSlots = [                {                    source: \'(direct)\',                    slots: [                        {slot: \'${google_adx_slot_direct}\'}                    ]                },                {                    source: \'hirkereso.hu\',                    slots: [                        {slot: \'${google_adx_slot_hirkereso}\'}                    ]                },                {                    source: \'hirstart.hu\',                    slots: [                        {slot: \'${google_adx_slot_hirstart}\'}                    ]                },                {                    source: \'kapu.hu\',                    slots: [                        {slot: \'${google_adx_slot_kapu}\'}                    ]                },                {                    source: \'startlap\',                    slots: [                        {slot: \'${google_adx_slot_startlap}\'}                    ]                },                {                    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: \'${google_adx_slot_facebook_organic}\'},                        {slot: \'${google_adx_slot_facebook_cpc}\'}                    ]                },                {                    source: \'google\',                    slots: [                        {slot: \'${google_adx_slot_google_organic}\'},                        {slot: \'${google_adx_slot_google_cpc}\'}                    ]                }            ];            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\';            var gaAdxSlotIdentifier = \'3775593841/8205717481\';            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 = \'3775593841/8205717481\';            if (\'true\' == \'true\') {                gaAdxSlotIdentifier = gaAdxSlotIdentifier;            } else {                gaAdxSlotIdentifier = \'1504628240/\' + gaAdxSlotIdentifier;            }            if (\'ca-pub-4337926688528987\' == \'\'){                google_ad_client = \\"ca-pub-1984646123858990\\";            } else {                google_ad_client = \\"ca-pub-4337926688528987\\";            }            google_ad_slot = gaAdxSlotIdentifier;            google_ad_width = parseInt(490);            google_ad_height = parseInt(172);            google_max_num_ads = parseInt(2);        } 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>\"}, {\"service_name\": \"Google Adverts\", \"weight\": 100, \"source\": \"<script async src=\\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\"></script><ins class=\\"adsbygoogle\\"    style=\\"display:inline-block;width:490px;height:172px\\"    data-ad-client=\\"ca-pub-8962558862962174\\"    data-ad-slot=\\"5439009262\\"    data-max-num-ads=2></ins><script>    if (typeof noADX == \'undefined\' || noADX === false) {        (adsbygoogle = window.adsbygoogle || []).push({});    }</script>\"}]';
  this.positions_weighted['category-adx-bottom'] = true;
  
  this.positions['collector-adx-top'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<script async src=\\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\"></script><ins class=\\"adsbygoogle\\"    style=\\"display:inline-block;width:465px;height:258px\\"    data-ad-client=\\"ca-pub-8962558862962174\\"    data-ad-slot=\\"6213668066\\"    data-max-num-ads=4></ins><script>    if (typeof noADX == \'undefined\' || noADX === false) {        (adsbygoogle = window.adsbygoogle || []).push({});    }</script>\"}]';
  this.positions_weighted['collector-adx-top'] = false;
  
  this.positions['top'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 4895 --><div id=\\"zone4895\\" class=\\"goAdverticum a8a263be\\" data-adsv-name=\\"top\\"></div>\"}]';
  this.positions_weighted['top'] = false;
  
  this.positions['right030'] = '[]';
  this.positions_weighted['right030'] = false;
  
  this.positions['county-adx'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<script async src=\\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\"></script><ins class=\\"adsbygoogle\\"    style=\\"display:inline-block;width:300px;height:250px\\"    data-ad-client=\\"ca-pub-8962558862962174\\"    data-ad-slot=\\"2241080065\\"    data-max-num-ads=1></ins><script>    if (typeof noADX == \'undefined\' || noADX === false) {        (adsbygoogle = window.adsbygoogle || []).push({});    }</script>\"}]';
  this.positions_weighted['county-adx'] = false;
  
  this.positions['left030'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<script async src=\\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\"></script><ins class=\\"adsbygoogle\\"    style=\\"display:inline-block;width:670px;height:79px\\"    data-ad-client=\\"ca-pub-8962558862962174\\"    data-ad-slot=\\"6347343511\\"    data-max-num-ads=1></ins><script>    if (typeof noADX == \'undefined\' || noADX === false) {        (adsbygoogle = window.adsbygoogle || []).push({});    }</script>\"}]';
  this.positions_weighted['left030'] = false;
  
  this.positions['list-left030'] = '[]';
  this.positions_weighted['list-left030'] = false;
  
  this.positions['list-left030'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": 0, \"source\": \"<!-- Goa3: 3369049 --><div id=\\"zone3369049\\" class=\\"goAdverticum\\"></div>\"}, {\"service_name\": \"Google Adverts\", \"weight\": 100, \"source\": \"<script async src=\\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\\"></script><ins class=\\"adsbygoogle\\"    style=\\"display:inline-block;width:300px;height:250px\\"    data-ad-client=\\"ca-pub-8962558862962174\\"    data-ad-slot=\\"9309560532\\"    data-max-num-ads=1></ins><script>    if (typeof noADX == \'undefined\' || noADX === false) {        (adsbygoogle = window.adsbygoogle || []).push({});    }</script>\"}]';
  this.positions_weighted['list-left030'] = true;
}

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;
}



