var warningAfter = 15; //minutes var remainingTime = 5; //minutes var counter; if (navigator.appName.indexOf('netscape') > -1) { window.onload = monitorTimeOut(); } else { monitorTimeOut(); } function monitorTimeOut(){ if (false){ window.setTimeout('warnUser()', (warningAfter * 60 * 1000)); } } function warnUser(){ remainingTimeSeconds = remainingTime * 60; document.getElementById('timeOutWarning').style.width = (getWidth() * 0.5) + 'px'; //document.getElementById('timeOutWarning').style.height = (getHeight() * 0.5) + 'px'; document.getElementById('timeOutWarning').style.left = ((getWidth() - (getWidth() * 0.5)) / 2) + 'px'; document.getElementById('timeOutWarning').style.top = (((((getHeight()) - (getHeight() * 0.5)) / 2) - 50) + document.documentElement.scrollTop) + 'px'; countDown(); document.getElementById('timeOutWarning').style.display = 'block'; counter = window.setInterval('countDown()', 1000); } function countDown(){ var o = document.getElementById('countDown'); var secs = (remainingTimeSeconds % 60); if (secs < 10) secs = '0' + secs; o.innerHTML = Math.floor(remainingTimeSeconds / 60) + ':' + secs; document.getElementById('completed').style.width = Math.round(100 - (100/(remainingTime * 60)) * remainingTimeSeconds) + '%'; if (remainingTimeSeconds <= 0) { window.clearInterval(counter); var x = new Image(); x.src = '/kill.asp'; alert('Due to inactivity, this booking has been abandoned.\nIf you wish to book, please start again.'); window.location.reload(); } remainingTimeSeconds--; } function refreshSession() { //Refresh the session by calling an image. var x = new Image(); x.src = '/images/mozilla_blu.gif'; document.getElementById('timeOutWarning').style.display = 'none'; window.clearInterval(counter); window.setTimeout('warnUser()', (warningAfter * 60 * 1000)); } function getWidth(){ if (navigator.appName.indexOf('Netscape') > -1) { return window.innerWidth; } else if (navigator.appName.indexOf('Microsoft') > -1) { return document.documentElement.offsetWidth; } } function getHeight(){ if (navigator.appName.indexOf('Netscape') > -1) { return window.innerHeight; } else if (navigator.appName.indexOf('Microsoft') > -1) { return document.documentElement.offsetHeight; } }