function Enodo_SetCookie(sName, sValue)
{
  date = new Date();
  date.setTime(date.getTime() + (365 * 24 * 3600 * 1000));
  document.cookie = sName + "=" + escape(sValue) + "; path=/; expires=" + date.toGMTString();
}

function CtcIDInRequest()
{
	var url = document.URL.toLowerCase();
	var start = url.indexOf('ctcid=');
	if (start == -1)
		return(null);	
	start += 6;
	var end = url.indexOf('&',start);
	if (end == -1) end = url.length;
	var valctcid = url.substring(start,end);
	return( valctcid);
}

function Enodo_GetCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function SaveTracking()
{
	// Should be changed accordingly
	CustomerCode = 'AZ_Incirculation';

   	var CtcID = 	CtcIDInRequest();
   	var r =			document.referrer;
   	if (CtcID == null)
   		CtcID = Enodo_GetCookie('ctcid_cookie');
   	else		
   		Enodo_SetCookie('ctcid_cookie',CtcID);
   	if (CtcID != null)	
	document.write('<IMG WIDTH="1" HEIGHT="1" SRC="http://www.enodo.eu.com/Customers/save.asp?CustomerCode=' + CustomerCode + '&CtcID=' + CtcID + '&p=' + document.URL + '&Referer=' + r + '">');
}