function CounterSetCookie(strName, strValue, strExpires, strPath, strDomain, strSecure) 
{
  document.cookie = strName + "=" + escape(strValue) +
    ( (strExpires) ? ";expires=" + strExpires.toGMTString() : "") +
    ( (strPath)    ? ";path="    + strPath                  : "") + 
    ( (strDomain)  ? ";domain="  + strDomain                : "") +
    ( (strSecure)  ? ";secure"                              : "");
}

function CounterGetCookie(strName) 
{
  var iStart = document.cookie.indexOf(strName + "=");
  var iLen   = iStart + strName.length + 1;
  if ((!iStart) && (strName != document.cookie.substring(0, strName.length))) { return null; }
  if (iStart == -1) { return null; }
  var iEnd = document.cookie.indexOf(";", iLen);
  if (iEnd == -1) { iEnd = document.cookie.length; }
  return(unescape(document.cookie.substring(iLen, iEnd)));
}



function WriteCounterCode(strCustomerGUID, strAccountGUID, strCounterBase, strStyle)
{

	var fRandVal1 = Math.random();
	var fRandVal2 = Math.random();
	var strCookieName = 'lcCouCookie' + strCustomerGUID + strAccountGUID;
	
	var strCookieSecret = '';
	var strOldCookie = CounterGetCookie(strCookieName);
	
	if(strOldCookie == null)
	{
		strCookieSecret = fRandVal1 + 'hIFH3737iisjf77frq' + fRandVal2 + 'jskiof37sjfjsfjafj8HFI37DHFAKFafsdbjsfüqopuqpfrq' + '99mvnS7frqfafF5g';
	}
	else
	{
		strCookieSecret = 'hIFH3737iisjf7rq' + fRandVal2 + 'jskiof37sjfjsafj8HFI37DHFAKFafsdbjqopuqpfrq' + '9mvnS7frqF5g' + fRandVal1;
	}
	CounterSetCookie(strCookieName, strCookieSecret);
	
	document.writeln('<img align="absmiddle" src="' + strCounterBase + 'lccmsCounter.php?customerguid=' + strCustomerGUID + '&accountguid=' + strAccountGUID + '&cookieval='+ strCookieSecret + '&counterstyle=' + strStyle + '" border="0">');
}

