var queryString = function () { // This function is anonymous, is executed immediately and/ // the return value is assigned to queryString! var query_string = {}; var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0; i < vars.length; i++) { var pair = vars[i].split("="); // If first entry with this name if (typeof query_string[pair[0]] === "undefined") { query_string[pair[0]] = pair[1]; // If second entry with this name } else if (typeof query_string[pair[0]] === "string") { var arr = [ query_string[pair[0]], pair[1] ]; query_string[pair[0]] = arr; // If third or later entry with this name } else { query_string[pair[0]].push(pair[1]); } } return query_string; } (); //leave for jsonp function foo(o) { sendRequest(o); } function sendRequest(pushListId) { if (pushListId) { var zdirect_revenue = ''; if (document.id('V83_C4_TotalPrice') != null) zdirect_revenue = document.id('V83_C4_TotalPrice').get('html'); var zdirect_data_string = 'pushListId=' + pushListId + '&lopMid=l37u32d00' + '&isCompletePage=0' + '&revenue=' + zdirect_revenue + '&pageUrl=' + window.location + "&time=" + new Date().getTime(); var zurl = "https://www.zdirect.com/zdirect_web_nav.html?" + zdirect_data_string; new Request.JSONP({url: zurl}).send(); } } function setCookie(name, value) { var zurl = "https://www.zdirect.com/zdirect/set_cookie.php?name=" + name + "&value=" + value; new Request.JSONP({url: zurl}).send(); Cookie.write(name, value); } function getCookie(cname) { var myRequest = new Request.JSONP({ url: 'https://www.zdirect.com/zdirect/get_cookie.php', callbackKey: 'foo', data: { name: cname }, onComplete: function(responseText){ } }).send(); } //get from url if (typeof queryString.pl != "undefined") //if pushlist found from url { var pushListId = queryString.pl; setCookie("zdl37u32d00", pushListId); sendRequest(pushListId); } else{ getCookie("zdl37u32d00"); }