function getReferrerString() { var ref = document.referrer; if( ref ) { if( ref.indexOf('?') !== -1 ) { ref = ref.split('?')[0]; } } return encodeURIComponent(ref); } function parseQuery(qstr) { var query = {}; var a = qstr.split('&'); for (var i = 0, l = a.length; i < l; i++) { var b = a[i].split('='); query[decodeURIComponent(b[0])] = decodeURIComponent(b[1]); } return query; } function getQueryVariable(qs, overrideQs) { var map1 = parseQuery(qs); var map2 = parseQuery(overrideQs); var finalQs = ""; for (var key in map2) { map1[key] = map2[key]; } for (var key in map1) { if (finalQs === "") { finalQs = key + "=" + map1[key]; } else { finalQs = finalQs + "&" + encodeURIComponent(key) + "=" + encodeURIComponent(map1[key]); } } return finalQs; } function rxiframeGetUrlParameter(sParam) { var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == sParam) { return sParameterName[1]; } } } function makeFrame() { var cookiePixel = rxiframeGetUrlParameter("rxiFrameGhost"); if ("true" !== cookiePixel) { cookiePixel = 'null'; } // ==================================================================== // Need to give the image time to load since we're dependent on the // cookie getting set so put in a load handler that calls the real // iframe builder. If we're using the cookie pixel then just jump out // and call the builder // ==================================================================== if ("true" == cookiePixel) { var image = new Image(); document.body.appendChild(image); image.onload = function() { _makeframe(); }; var addQs = window.parent.location.search.substring(1); var qs1 = "parent=myMaindiv&rtxuseqs=true&merchantId=17033344&programId=92749505&affiliateId=17033427&channel=brand"; var mergedQs = getQueryVariable(qs1, addQs); image.setAttribute("src", "https://secureimg.revtrax.com/RevTrax/copxpid?cpxto=3600&" + mergedQs); } else { _makeframe(); } } function _makeframe() { var divh = document.getElementById('myMaindiv').style.height; var divw = document.getElementById('myMaindiv').style.width; var append = "true"; var fluid = rxiframeGetUrlParameter("fluid"); var pageLevel = rxiframeGetUrlParameter("iframePageLevel"); var addQs = ""; var mergedQs = "parent=myMaindiv&rtxuseqs=true&merchantId=17033344&programId=92749505&affiliateId=17033427&channel=brand"; var referrer = getReferrerString(); if( referrer ) { mergedQs += "&rtxorigin=" + referrer; } if (fluid == "true") { divw = "100%"; } // ======================================================================== // a little weird logic here. We want the outer parameter to rule. So, if // we have one locally we want to check if the one we got globally is null // aka undefined. if so we'll swap it // ======================================================================== if (pageLevel == undefined) { pageLevel = ""; } if (append !== "false") { addQs = window.parent.location.search.substring(1); if ((addQs != undefined) && (addQs != "")) { var qs1 = "parent=myMaindiv&rtxuseqs=true&merchantId=17033344&programId=92749505&affiliateId=17033427&channel=brand"; mergedQs = getQueryVariable(qs1, addQs); } } ifrm = document.createElement("IFRAME"); ifrm.setAttribute("src", "https://secureimg.revtrax.com/RevTrax/cpn" + pageLevel + "?" + mergedQs); ifrm.style.width = divw; ifrm.style.height = divh; ifrm.setAttribute("scrolling", "no"); ifrm.setAttribute("marginWidth", "0"); ifrm.setAttribute("marginHeight", "0"); ifrm.setAttribute("hspace", "0"); ifrm.setAttribute("vspace", "0"); ifrm.setAttribute("frameBorder", "0"); ifrm.setAttribute("allowtransparency", "true"); document.getElementById("myMaindiv").appendChild(ifrm); } console.log("%cWARNING - Antiquated iframe script detected, contact your RevTrax Client Services Representative for the newest version", "background: red; color: #fff; font-size: large"); /*always attach resize*/var rtxIfmRsz = document.createElement("script");rtxIfmRsz.type = "text/javascript";rtxIfmRsz.src = "https://secureimg.revtrax.com/RevTrax/js/libs/iframeresizer.js";document.body.appendChild(rtxIfmRsz);