var curtime = "October, 17, 2017 07:44:00"; var curdate = new Date(curtime); var timeExpire = readCookie("cxt") * 1000; var timeExpireClock = new Date(timeExpire); var akttValue = readCookie("aktt"); var theClock = ""; function checkCookieTime() { curdate.setSeconds(curdate.getSeconds() + 1); if (akttValue != null && timeExpireClock.valueOf() > 0 && timeExpireClock.valueOf() - curdate.valueOf() <= 0) { window.clearInterval(theClock); alert("Sorry, you've run out of time to complete this sale."); if (window.location.pathname == "/sale/purchase.php") { window.location.href = window.location.pathname + '?sid=' + readCookie("sid"); } } } window.onload = function() { theClock = window.setInterval("checkCookieTime()", 1000); }