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(pushListIdOrSig) { if (pushListIdOrSig) { //sig if (pushListIdOrSig.indexOf('sig') > -1) { setCookie("zdt4aj4dw46500", pushListIdOrSig); } } sendRequest(pushListIdOrSig); } function sendRequest(pushListIdOrSig) { var pushListId = ''; var sig = ''; if (pushListIdOrSig) { if (pushListIdOrSig.indexOf('sig') > -1) { sig = pushListIdOrSig; } else { pushListId = pushListIdOrSig; } var zdirect_revenue = ''; if (document.id('V112_C1_CRR_ctl01_ExtendedTripSummaryCntrl_TotalPrice') != null) zdirect_revenue = document.id('V112_C1_CRR_ctl01_ExtendedTripSummaryCntrl_TotalPrice').get('html'); //add email check var zdirect_email = ''; if (document.id('V112_C0_CustomerRetrievalCntrl_LoginEmailTextBox') != null) { $('V112_C0_CustomerRetrievalCntrl_LoginEmailTextBox').addEvent('blur', function(){ zdirect_email = $('V112_C0_CustomerRetrievalCntrl_LoginEmailTextBox').get('value'); sendBack(pushListId, sig, 'zdirectEmail', zdirect_email, 0); }); } if (document.id('V112_C0_gi_EmailTextBox') != null) { $('V112_C0_gi_EmailTextBox').addEvent('blur', function(){ zdirect_email = $('V112_C0_gi_EmailTextBox').get('value'); sendBack(pushListId, sig, 'zdirectEmail', zdirect_email, 0); }); } //first name if (document.id('V112_C0_gi_FirstNameTextBox') != null) { $('V112_C0_gi_FirstNameTextBox').addEvent('blur', function(){ zdirect_fname = $('V112_C0_gi_FirstNameTextBox').get('value'); sendBack(pushListId, sig, 'zdirectFirstName', zdirect_fname, 0); }); } //last name if (document.id('V112_C0_gi_LastNameTextBox') != null) { $('V112_C0_gi_LastNameTextBox').addEvent('blur', function(){ zdirect_lname = $('V112_C0_gi_LastNameTextBox').get('value'); sendBack(pushListId, sig, 'zdirectLastName', zdirect_lname, 0); }); } //optin if (document.id('V112_C0_OptInCntrl_OptInCheckBox') != null) { $('V112_C0_OptInCntrl_OptInCheckBox').addEvent('click', function(){ if (document.id('V112_C0_OptInCntrl_OptInCheckBox').get('checked')) { sendBack(pushListId, sig, '', '', 1); } }); } //end add email check var zdirect_data_string = 'sig=' + sig + '&pushListId=' + pushListId + '&lopMid=t4aj4dw46500' + '&zdirectOptin=0&isCompletePage=0' + '&revenue=' + zdirect_revenue + '&zdirectEmail=' + zdirect_email + '&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; try{ new Request.JSONP({url: zurl}).send(); }catch(error){} 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(); } function sendBack(pushListId, sig, name, value, optin) { var return_string = 'sig=' + sig + '&isCompletePage=1&zdirectOptin=' + optin + '&pushListId=' + pushListId + '&lopMid=t4aj4dw46500&' + name + '=' + value; var zurl = "https://www.zdirect.com/zdirect_web_nav.html?" + return_string; new Request.JSONP({url: zurl}).send(); } //get from url if (typeof queryString.pl != "undefined") //if pushlist found from url { var pushListId = queryString.pl; setCookie("zdt4aj4dw46500", pushListId); sendRequest(pushListId); } else { getCookie("zdt4aj4dw46500"); }