if(typeof ctnetwork == 'undefined') { var ctnet_scripts= document.getElementsByTagName('script'); var ctnet_hostpath= ctnet_scripts[ctnet_scripts.length-1].src.split('/js/')[0]; if (!ctnet_hostpath.match(/ctnetwork\.hu/)){ ctnet_hostpath = "http://av.ctnetwork.hu"; } //console.log(ctnet_hostpath); document.write(''); ctnetwork=function() { return { cnt: 0, seen: '', hostpath: ctnet_hostpath, init: function() { this.adslots = []; if (window.addEventListener) // W3C standard { //console.log('a'); window.addEventListener('load', this.startdisplay.bind(this), false); window.addEventListener('scroll', this.displayads.bind(this), false); } else if (window.attachEvent) // Microsoft { //console.log('b'); window.attachEvent('onload', this.startdisplay); window.attachEvent('onscroll', this.displayads); } return this; }, adslot: function(params) { var adHtml = ''; var imported = document.createElement('script'); imported.type = 'text/javascript'; imported.setAttribute('async', true); imported.src = ctnetwork.hostpath+'/?partner_id='+ctnetwork.partner_id+'&cd='+ctnetwork.cd+'&js=1&html_element_id=ctnet_target_'+ctnetwork.cnt+'&rand='+Math.floor(Math.random()*1000)+urlpars+'&l='+encodeURIComponent(ctnetwork.getAdHostLocation())+'&seen='+encodeURIComponent(ctnetwork.seen)+'&encoding='+encodeURIComponent(document.inputEncoding); var callback = function() { CT_net_jq(imported).unbind('load',callback); adslot.style.display='inline'; //egérmozgás logolás CT_net_jq(adslot).parents('.ctnet_adslot_wrapper').bind('mousemove', function(event){ var offset = CT_net_jq(this).offset(); var mouseX = event.pageX - offset.left; var mouseY = event.pageY - offset.top; if (mouseX && mouseY){ CT_net_jq(this).attr('data-mousePosX', mouseX); CT_net_jq(this).attr('data-mousePosY', mouseY); } }); //Linkcsere var links = CT_net_jq(adslot).find('a'); links.each(function(i, link){ this.setAttribute('onclick','return false;'); CT_net_jq(this).bind('mousedown',function(event){ var mouseX = event.pageX - CT_net_jq(adslot).parents('.ctnet_adslot_wrapper').offset().left; var mouseY = event.pageY - CT_net_jq(adslot).parents('.ctnet_adslot_wrapper').offset().top; if (mouseX && mouseY){ var linkHref = CT_net_jq(this).attr('href'); linkHref = linkHref.replace(/&mdmouse[XY]=\d+/g,''); linkHref+="&mdmouseX="+parseInt(mouseX)+"&mdmouseY="+parseInt(mouseY); CT_net_jq(this).attr('href',linkHref); } var mousePosX = CT_net_jq(adslot).parents('.ctnet_adslot_wrapper').attr('data-mousePosX'); var mousePosY = CT_net_jq(adslot).parents('.ctnet_adslot_wrapper').attr('data-mousePosY'); if (mousePosX && mousePosY){ var linkHref = CT_net_jq(this).attr('href'); linkHref = linkHref.replace(/&momouse[XY]=\d+/g,''); linkHref+="&momouseX="+parseInt(mousePosX)+"&momouseY="+parseInt(mousePosY); CT_net_jq(this).attr('href',linkHref); } var ut = 0; if (!event.which) { ut = 1; } else if ('isTrusted' in event && !event.isTrusted) { ut = 2; } else if (event.originalEvent === undefined) { ut = 3; } var linkHref = CT_net_jq(this).attr('href'); linkHref = linkHref.replace(/&ut=\d+/g,''); linkHref+="&ut="+parseInt(ut); CT_net_jq(this).attr('href',linkHref); }); CT_net_jq(this).bind('click',function(event){ var mouseX = event.pageX - CT_net_jq(adslot).parents('.ctnet_adslot_wrapper').offset().left; var mouseY = event.pageY - CT_net_jq(adslot).parents('.ctnet_adslot_wrapper').offset().top; if (mouseX && mouseY){ var linkHref = CT_net_jq(this).attr('href'); linkHref = linkHref.replace(/&clmouse[XY]=\d+/g,''); linkHref+="&clmouseX="+parseInt(mouseX)+"&clmouseY="+parseInt(mouseY); CT_net_jq(this).attr('href',linkHref); } var mousePosX = CT_net_jq(adslot).parents('.ctnet_adslot_wrapper').attr('data-mousePosX'); var mousePosY = CT_net_jq(adslot).parents('.ctnet_adslot_wrapper').attr('data-mousePosY'); if (mousePosX && mousePosY){ var linkHref = CT_net_jq(this).attr('href'); linkHref = linkHref.replace(/&momouse[XY]=\d+/g,''); linkHref+="&momouseX="+parseInt(mousePosX)+"&momouseY="+parseInt(mousePosY); CT_net_jq(this).attr('href',linkHref); } var ut = 0; if (!event.which) { ut = 1; } else if ('isTrusted' in event && !event.isTrusted) { ut = 2; } else if (event.originalEvent === undefined) { ut = 3; } var linkHref = CT_net_jq(this).attr('href'); linkHref = linkHref.replace(/&ut=\d+/g,''); linkHref+="&ut="+parseInt(ut); CT_net_jq(this).attr('href',linkHref); window.open(CT_net_jq(this).attr('href')); if (event && event.stopPropagation){ event.stopPropagation(); } if (event && event.preventDefault){ event.preventDefault(); } }); }); //Linkcsere vége ctnetwork.showadslot(); }; CT_net_jq(imported).bind('load',callback); document.getElementsByTagName('head')[0].appendChild(imported); } }, startdisplay: function() { var ctnet_jq = document.createElement('script'); ctnet_jq.type = 'text/javascript'; ctnet_jq.setAttribute('async', true); ctnet_jq.src = 'http://av.ctnetwork.hu/min/?f=js/ct_net_jq_1_7_min.js,js/ct_net_jq.js'; document.getElementsByTagName('head')[0].appendChild(ctnet_jq); (delayStart = function(){ if ((typeof CT_net_jq != 'undefined') && CT_net_jq){ ctnetwork.displayads(); }else{ window.setTimeout(function(){ delayStart(); },10); } })(); }, getWindowHeight: function() // viewport, not document { var windowHeight = 0; if (typeof(window.innerHeight) == 'number') { // DOM compliant, IE9+ windowHeight = window.innerHeight; } else { // IE6-8 workaround, Note: document can be smaller than window var ieStrict = document.documentElement.clientHeight; // w/out DTD gives 0 var ieQuirks = document.body.clientHeight; // w/DTD gives document height windowHeight = (ieStrict > 0) ? ieStrict : ieQuirks; } return windowHeight; }, getWindowWidth: function() // viewport, not document { var windowWidth = 0; if (typeof(window.innerWidth) == 'number') { // DOM compliant, IE9+ windowWidth = window.innerWidth; } else { // IE6-8 workaround, Note: document can be smaller than window var ieStrict = document.documentElement.clientWidth; // w/out DTD gives 0 var ieQuirks = document.body.clientWidth; // w/DTD gives document width windowWidth = (ieStrict > 0) ? ieStrict : ieQuirks; } return windowWidth; }, getScrollTop: function() { var scrollTop; if(typeof(window.pageYOffset) == 'number') { // DOM compliant, IE9+ scrollTop = window.pageYOffset; } else { // IE6-8 workaround if(document.body && (typeof(document.body.scrollTop) == 'number')) { // IE quirks mode scrollTop = document.body.scrollTop; } else if(document.documentElement && (typeof(document.documentElement.scrollTop) == 'number')) { // IE6+ standards compliant mode scrollTop = document.documentElement.scrollTop; } } return scrollTop; }, getScrollLeft: function() { var scrollLeft; if(typeof(window.pageXOffset) == 'number') { // DOM compliant, IE9+ scrollLeft = window.pageXOffset; } else { // IE6-8 workaround if(document.body && (typeof(document.body.scrollLeft) == 'number')) { // IE quirks mode scrollLeft = document.body.scrollLeft; } else if(document.documentElement && (typeof(document.documentElement.scrollLeft) == 'number')) { // IE6+ standards compliant mode scrollLeft = document.documentElement.scrollLeft; } } return scrollLeft; }, displayads: function() { var elems = document.getElementsByTagName('span'), i, cnt=0, pars, urlpars, wsizes={x: 0, y: 0, w: ctnetwork.getWindowWidth(), h: ctnetwork.getWindowHeight()}; //console.log('win:', wsizes.x, ' ', wsizes.y, ' ', wsizes.w, ' ', wsizes.h, ' '); //console.log(elems); //ctnetwork.adslots=[]; for (i in elems) { if(elems[i].className=='ctnet_adslot') { var rect = elems[i].parentNode.getBoundingClientRect(); if(wsizes.x<=rect.left && rect.left<=wsizes.x+wsizes.w && wsizes.y<=rect.top && rect.top<=wsizes.y+wsizes.h ) { if(!elems[i].loading) { //console.log(rect.left, rect.top, rect.right, rect.bottom); elems[i].loading=true; ctnetwork.adslots.push(elems[i]); } } } } //console.log(ctnetwork.adslots.length); if (ctnetwork.adslots.length>0){ ctnetwork.delayShowAdslot(); } }, showAdslotDelayed: false, delayShowAdslot: function(){ //console.log(ctnetwork.adslots); if ((typeof CT_net_jq != 'undefined') && CT_net_jq){ //console.log('CT_net_jq OK', 'showing adslots'); ctnetwork.showadslot(); }else{ //console.log('CT_net_jq not present', 'ctnetwork.showadslot delayed'); ctnetwork.showAdslotDelayed = true; window.setTimeout(function(){ //console.log('delay over'); ctnetwork.showAdslotDelayed = false; ctnetwork.delayShowAdslot(); },50); } } }; } ().init(); }