Tagging = function(context) {
  this.site = 'ng';
  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 = (\'${gemius_trackid}\' != \'\') ? \'${gemius_trackid}\' : \'d12Qck9gv4SOQi_IoQvsz.U57KSFcVB5poQr59bMjCT.O7\';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 type=\\"text/javascript\\" src=\\"http://ad-blacklist.p24.hu/adx_blacklist.js\\"></script><script type=\\"text/javascript\\">    var noADX = false;    if (        typeof blckAdx != \'undefined\' &&        typeof blckAdx[window.location.hostname] != \'undefined\' &&        blckAdx[window.location.hostname].indexOf(location.pathname) >= 0    ) {        noADX = true;    }</script>\"}]';
  this.positions_weighted['head'] = 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\": \"ADAPT\", \"weight\": null, \"source\": \"<script src=\\"http://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-TH7ML6\\"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-TH7ML6\');</script>\"}]';
  this.positions_weighted['body-start'] = false;
  
  this.positions['body-end-adv'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3:  --><div id=\\"zone\\" class=\\"goAdverticum\\"></div>\"}]';
  this.positions_weighted['body-end-adv'] = false;
  
  this.positions['top'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": 100, \"source\": \"<!-- Goa3: 1652201 --><div id=\\"zone1652201\\" class=\\"goAdverticum\\"></div>\"}, {\"service_name\": \"ADAPT\", \"weight\": 0, \"source\": \"<script type=\\"text/javascript\\">document.write(\'<scr\'+\'ipt type=\\"text/javascript\\" src=\\"http://ad.360yield.com/adj?p=515547&w=970&h=90&tz=\'+(new Date().getTimezoneOffset())+\'\\"><\\/scr\'+\'ipt>\');</script>\"}]';
  this.positions_weighted['top'] = true;
  
  this.positions['right010'] = '[{\"service_name\": \"Adverticum AdServer\", \"weight\": null, \"source\": \"<!-- Goa3: 1652176 --><div id=\\"zone1652176\\" class=\\"goAdverticum\\"></div>\"}]';
  this.positions_weighted['right010'] = false;
  
  this.positions['content-bottom'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div class=\\"ctsGadx\\" style=\\"margin-bottom: 10px;\\"><div style=\\"width: 920px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div><script type=\\"text/javascript\\">    if (typeof noADX == \'undefined\' || noADX === false) {        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 = \'8105101400/3535225040\';        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 = \'8105101400/3535225040\';        gaAdxSlotIdentifier = \'5491763120/\' + gaAdxSlotIdentifier;            google_ad_client = \\"ca-pub-1984646123858990\\";        google_ad_slot = gaAdxSlotIdentifier;        google_ad_width = parseInt(920);        google_ad_height = parseInt(120);        google_max_num_ads = parseInt(1);    } 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['content-bottom'] = false;
  
  this.positions['content010'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div class=\\"ctsGadx\\" style=\\"margin-bottom: 10px;\\"><div style=\\"width: 565px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div><script type=\\"text/javascript\\">    if (typeof noADX == \'undefined\' || noADX === false) {        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 = \'9442056560/1918764440\';        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 = \'9442056560/1918764440\';        gaAdxSlotIdentifier = \'5491763120/\' + gaAdxSlotIdentifier;            google_ad_client = \\"ca-pub-1984646123858990\\";        google_ad_slot = gaAdxSlotIdentifier;        google_ad_width = parseInt(565);        google_ad_height = parseInt(110);        google_max_num_ads = parseInt(1);    } 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['content010'] = false;
  
  this.positions['content020'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div class=\\"ctsGadx\\" style=\\"margin-bottom: 15px;\\"><div style=\\"width: 437px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div><script type=\\"text/javascript\\">    if (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 : \'${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 = \'1201392200/4015055240\';        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(437);        google_ad_height = parseInt(130);        google_max_num_ads = parseInt(1);    } 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['content020'] = false;
  
  this.positions['right020'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div class=\\"ctsGadx\\" style=\\"margin-bottom: 10px;\\"><div style=\\"width: 300px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div><script type=\\"text/javascript\\">    if (typeof noADX == \'undefined\' || noADX === false) {        var gaAdxSlots = [            {                source : \'(direct)\',                slots: [                    {   slot : \'3316291640/4792999520\'   }                ]            },            {                source : \'hirkereso.hu\',                slots: [                    {   slot : \'3316291640/8943617720\'   }                ]            },            {                source : \'hirstart.hu\',                slots: [                    {   slot : \'3316291640/2897033480\'   }                ]            },            {                source : \'kapu.hu\',                slots: [                    {   slot : \'3316291640/7327157120\'   }                ]            },            {                source : \'startlap\',                slots: [                    {   slot : \'3316291640/2757280760\'   }                ]            },            {                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 : \'3316291640/7606662560\'   },                    {   slot : \'3316291640/7606662560\'   }                ]            },            {                source : \'google\',                slots: [                    {   slot : \'3316291640/4513494080\'   },                    {   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 = \'3316291640/6269707400\';        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 = \'3316291640/6269707400\';        gaAdxSlotIdentifier = \'5491763120/\' + gaAdxSlotIdentifier;            google_ad_client = \\"ca-pub-1984646123858990\\";        google_ad_slot = gaAdxSlotIdentifier;        google_ad_width = parseInt(300);        google_ad_height = parseInt(350);        google_max_num_ads = parseInt(3);    } 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['right020'] = false;
  
  this.positions['mobile-content020'] = '[{\"service_name\": \"Google Adverts\", \"weight\": null, \"source\": \"<div class=\\"ctsGadx\\" style=\\"margin-bottom: 10px;\\"><div style=\\"width: 300px; text-align: right; font-size: 8px; color: #C6C6C6;\\">HIRDET&#xC9;S</div><script type=\\"text/javascript\\">    if (typeof noADX == \'undefined\' || noADX === false) {        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 = \'6968471000/8445178880\';        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 = \'6968471000/8445178880\';        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);    } 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['mobile-content020'] = 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;
}



