function setActivityCookie(cname,cvalue,exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires=" + d.toGMTString(); document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; } function getActivityCookie(cname) { var name = cname + "="; var decodedCookie = decodeURIComponent(document.cookie); var ca = decodedCookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } function setActivityURL(getEmail, getURL){ /* $.get("//api.ip.sb/geoip", function() {}, "jsonp").always(function(resp) { var ip = (resp && resp.ip) ? resp.ip : ""; var city = (resp && resp.city) ? resp.city : ""; var region = (resp && resp.region) ? resp.region : ""; var country = (resp && resp.country) ? resp.country : ""; var country_code = (resp && resp.country_code) ? resp.country_code : ""; }); */ $.ajax({ type: "POST", url: location.protocol + "//nhtagent.com/WebActivity/", data: {actionId : "SetActivity", ActivityEmail : getEmail, ActivityURL : encodeURI(getURL)} }); } function CPTActivity(ClientEmail){ var ActivityEmail = getActivityCookie("ActivityEmail"); var ActivityURL = window.location; if(ActivityEmail != "" && ActivityEmail != null && ((ClientEmail != "" && ClientEmail != null && ActivityEmail == ClientEmail) || (ClientEmail == null || ClientEmail == ""))){ setActivityURL(ActivityEmail, ActivityURL); } else { if(ClientEmail != "" && ClientEmail != null){ setActivityCookie("ActivityEmail", ClientEmail, 365); setActivityURL(ClientEmail, ActivityURL); } } }