window.onload = function () { var mem_sess = document.getElementById('member_session').value; if(mem_sess != ''){ var cd_sec = 600; var ss = new ScreenSaver(600000,cd_sec); timer_countdown(cd_sec); } } var ScreenSaver = function (waitTime,c_sec) { this.lastActivity = new Date().getTime(); this.waitTime = waitTime; var $this = this; this._timer = setInterval(function () { $this._checkTime.call($this) }, 1000); document.onmousemove = function () {$this._mouseHandler.call($this), clear_timer(), timer_countdown(c_sec)}; }; ScreenSaver.prototype = { _timer: null, lastActivity: 0, started: false, waitTime: 0, dispose: function () { if (this._timer) clearInterval(this._timer); document.onmousemove = null; }, _checkTime: function () { if (!this.started && new Date().getTime() - this.lastActivity >= this.waitTime) { this.started = true; } }, _mouseHandler: function () { this.lastActivity = new Date().getTime(); if (this.started) { sessChecking(); this.lastActivity = new Date().getTime(); this.started = false; } } }; var clear_timer = function(i){ clearTimeout(t); return; } var timer_countdown = function(i){ // write out count if (i == 0) { return; // stop } t=setTimeout(function() { // repeat timer_countdown(i - 1); }, 1000 ); } function close_bmsg(val){ document.getElementById('browser_msg').style.display = 'none'; if(val == 1){ var myRequest = new Request({method: 'get', url: 'http://www.cni.com.sg/login/dialog/m_xbd'}); myRequest.send(''); } } function sessChecking(){ var myRequest = new Request({ method: 'get', url: 'http://www.cni.com.sg/login/dialog/m_sess', onSuccess: function(responseText){ if(responseText == 0){ alert('Sorry, your session has expired.\n\nPlease login again. Thank you.'); window.location = "http://www.cni.com.sg"; } } }); myRequest.send(''); }