var New_Cookie_Value;var Orig_Cookie_Value;var Cookie_Name;var Referrer;var FoundReferrer ;var msg = " ";Cookie_Name     ="Initial_Referrer";Referrer        ="NotSet";Orig_Cookie_Value="NotSet";New_Cookie_Value="NotSet";if (document.referrer != ""){  Referrer= document.referrer;   Referrer= Referrer.toLowerCase();  FoundReferrer="True";}else {  Referrer        ="-None-";  New_Cookie_Value="-None-";  FoundReferrer="False";}Orig_Cookie_Value=getCookie(Cookie_Name);// If the cookie is not set, then set it. if (Orig_Cookie_Value == "") {    // not found (or cookie is null?)  New_Cookie_Value=Referrer;  setCookie(Cookie_Name,New_Cookie_Value); }else { // found a referrer so Referrer variable has a valid value  // if the referrer is YourShops, then override the Initial_Referrer with the current referrer  var YourShops1="http://www.intactearnings.com";  var YourShops2="https://www.intactearnings.com";  var YourShops3="http://www.yourshops.ca";  var YourShops4="https://www.yourshops.ca";  var YourShops5="http://192.168.1.3";  offset1= Referrer.indexOf(YourShops1);  offset2= Referrer.indexOf(YourShops2);  offset3= Referrer.indexOf(YourShops3);  offset4= Referrer.indexOf(YourShops4);  offset5= Referrer.indexOf(YourShops5);  if (   offset1 != -1       || offset2 != -1       || offset3 != -1       || offset4 != -1       || offset5 != -1      )   {                // then this is a referral from yourShops, so override the cookie    New_Cookie_Value=Referrer;    setCookie(Cookie_Name,New_Cookie_Value);   }  else { //Do not override the existing cookie  }}// ---- Functionsfunction setCookie(name, value) { // use: setCookie("name", value);  var expiry = new Date(2035, 00, 01, 00, 00, 00); // Far in the future  if (value != null && value != ""){    cookie_string = name + "=" + escape(value) + "; expires=" + expiry.toGMTString() + "; path=/; domain=.interwood.com" ;    //document.write("<br> Setting "+cookie_string);    document.cookie = cookie_string;  }}  function setShortCookie(name, value) { // use: setCookie("name", value);  var expiry = new Date(); // set cookie to expire in 12 hours  expiry = (new Date(expiry.getTime() + 12*3600000))  if (value != null && value != ""){    cookie_string = name + "=" + escape(value) + "; expires=" + expiry.toGMTString() + "; path=/; domain=.interwood.com" ;    //document.write("<br> Setting "+cookie_string);    document.cookie = cookie_string;  }}  function getCookie(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) {end = document.cookie.length;} // set the index of the end of cookie value      returnvalue=unescape(document.cookie.substring(offset, end)) ;    }  }  return(returnvalue);}function deleteCookie(name) { // use: deleteCookie("name");  var today = new Date();  var expired = new Date(today.getTime() - 28 * 24 * 60 * 60 * 1000); // less 28 days  document.cookie=name + "=null; expires=" + expired.toGMTString(); // delete cookie}function em( name, server, clicktext1, clicktext2 ) {  emailAddress=(name + '@' + server) ;  emailText= clicktext1 + clicktext2 ;  document.write('<A href="mailto:' + emailAddress + '">' + emailText + '</a>') ;}