function twoDigit(num) { if(num >= 10) { return num.toString(); } else { return "0" + num.toString(); } } var now = new Date(); // name - name of the cookie // value - value of the cookie // [expires] - expiration date of the cookie (defaults to end of current session) // [path] - path for which the cookie is valid (defaults to path of calling document) // [domain] - domain for which the cookie is valid (defaults to domain of calling document) // [secure] - Boolean value indicating if the cookie transmission requires a secure transmission // * an argument defaults when it is assigned null as a placeholder // * a null placeholder is not required for trailing omitted arguments function putCookie(name, value, expires, path, domain, secure) { var curCookie = name + "=" + (value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; } if(webtrackSwitch == "ON") { var refFlag = false; var ref = ""; var uuidSetNow = false; if(document.referrer) { ref = document.referrer; } uuid = getCookie(uuidCookieName); if((uuid == null || uuid == "") || (ref == "" || (ref.indexOf(".vendio.com") == -1 && ref.indexOf(".andale.com") == -1 && ref.indexOf(".honesty.com") == -1 && ref.indexOf(".andalay.com") == -1))) { var today = new Date(); var timeStamp = Date.parse(today); if(uuid == null || uuid == "") { uuidSetNow = true; var randomNumber = 1000000 + Math.floor(Math.random() * (9999999 - 1000000 + 1)); var value = randomNumber.toString() + timeStamp.toString(); year = today.getFullYear(); month = today.getMonth()+1; // Jan returns 0... date = today.getDate(); hour = today.getHours(); today.setFullYear(year+30); value = year.toString() + twoDigit(month) + twoDigit(date) + twoDigit(hour) + "-" + value; putCookie(uuidCookieName, value, today, cookieDefaultPath, cookieDefaultDomain, ""); } var refCookieValue = getCookie(refTrackCookieName); if(uuidSetNow || (!uuidSetNow && (refCookieValue == null || refCookieValue == "" || (refCookieValue == noValue && ref != "")))) { now = new Date(); now.setTime(timeStamp + (defaultExpiryTime * 1000)); if(ref == "") { putCookie(refTrackCookieName, noValue, now, cookieDefaultPath, cookieDefaultDomain, ""); } else { var match = false; for(var ctr = 0; ctr