/** -------------------------------- * begin execution * my_ep_js2.php uses DOM script loading, rather than document.write. * it calls /eScripts/epopv2/main2.js, which also uses script loading. * for elements/scripts that need to be added later from within mad_class_v2.php * , a hidden container: div id=epopHolderDiv is added. **/ var adset_id='1171'; /* explicit adset_id (affects constructEpUrl) */ /* set a global debug var from url param.(used in function _epDebug) */ if(GetParmEP('epop_debug') == "Y") { window['debugIsOn'] = true; } if(!varIsDefined('exitPop')) { /* create var exitPop if it doesn't already exist. */ /* NOTE: exitPop must be true if not previously defined, otherwise why include this exitpop script? */ var exitPop=true; } /* check for a cookie opsubm - meaning orderpage submitted (on this domainname) */ if(get_cookie('opsubm') == "Y") { exitPop=false; /* if orderpage submitted, block pops */ } else { /* alert('no cookie opsubm'); */ } /* get the np var, maintain as cookie */ if(!varIsDefined('np')) { var np='N'; } /* create a temp var for use in tests below */ if(!varIsDefined('temp')) { var temp; } temp = GetParmEP('np'); if(temp == 'Y') { np = 'Y'; SetCookie("np",np); } else { temp = get_cookie('np'); if(temp == 'Y') { np = 'Y'; } } /* np var is set */ /* settle value of var current_affiliate: if any possible params have non-blank value set to the best one. otherwise leave previously set current_affiliate if no args. */ if(!varIsDefined('current_aff')) { var current_aff = ""; } temp = GetParmEP('b'); if(temp != "") { /* noop */ } else { temp = GetParmEP('af'); } if(temp != "") { /* noop */ } else { temp = GetParmEP('affiliate'); } if(temp != "") { current_aff = temp; } if( current_aff == "" ){ current_aff = get_cookie('affiliate'); } /* current_aff is now set. */ document.write(''); /* calls to marketing engine */ setTimeout(epopAfterJsCp,2000); /* end execution */ /* functions below */ function epopAfterJsCp() { _epDebug('start epopAfterJsCp()'); var cp_script = "/krtrk/SHOW_JS_CP.php?t=" + escape(Math.random()); loadScript(cp_script,function () { cpScriptOnload(); }); }; function cpScriptOnload() { var d = new Date(); var now = d.getTime(); if(!window['epopStarttime']) window['epopStarttime'] = now; var starttime = window['epopStarttime']; _epDebug('cpScriptOnload fired. starttime=' + starttime + ', now=' + now); if(window['epopTO']) { try { clearTimeout(window['epopTO']); } catch(e) { _epDebug('error clearing epopTO'); _epDebug(e); } } if(!window["MNME_CL_ID"] && (now - starttime < 2000)) { _epDebug('no var found. reload in 500ms'); window['epopTO'] = setTimeout('epopAfterJsCp()',500); } else { _epDebug('var found. MNME_CL_ID=' + window["MNME_CL_ID"] + ',MNME_CP=' + window["MNME_CP"] + '... run epop'); loadScript('/eScripts/epopv2/main2.js',false); } }; function loadScript(url, callback) { _epDebug('loadScript: ' + url + ', ' + callback); var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = url; if(callback) { script.onreadystatechange = callback; script.onload = callback; } head.appendChild(script); }; // debug via console.log function _epDebug(txt) { if(!window['debugIsOn']) { return false; } try { console.log(txt); } catch(e) { } } /** * function get_cookie * return the cookie value of cookie Name or "" if not ext. * *used below **/ function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { // if the cookie exists offset += search.length end = document.cookie.indexOf(";", offset); // set the index of beginning value if (end == -1) // set the index of the end of cookie value end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } /** * function GetParmEP * return the url param's value or "" if none * *used below **/ function GetParmEP(name) { SCH = document.location.search; SCH = "?&" + SCH.substring(1,SCH.length); // alert('SCH = ' + SCH); var start = SCH.indexOf("&" + name+"="); var len = start+name.length+2; if ((!start) && (name != SCH.substring(0,name.length))) return(""); if (start == -1) return ""; var end = SCH.indexOf("&",len); if (end == -1) end = SCH.length; // alert('finished getting parm ' + name); return unescape(SCH.substring(len,end)); } /** * function SetCookie (name, value) * set a cookie. NOTE: this can be overloaded with args 3-5 as well * *used below **/ function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var delay = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires)) + ((path == null) ? "" : ("; path=" + path)) + ((delay == null) ? "" : ("; delay=" + delay)) + ((secure == true) ? "; secure" : ""); } /** * function varIsDefined * return true/false for whether a var has been defined * in the global (window) context * *used below **/ function varIsDefined(variable) { return (typeof(window[variable]) == "undefined") ? false: true; } /* end functions */