// JavaScript Document

var interval = inactivity_interval; //set on main page
var initialtime;
var timer;
var use_timer = (interval) ? true : false;

function refreshTimer(){
	if(use_timer){
		today = new Date();
		initialtime = today.getTime();
		countDown();
		checkTime();
	}
}

function countDown(){
	window.clearTimeout(timer);	
	timer = window.setTimeout("checkTime()", 1000);
}

function checkTime(){
	now = new Date();
	nowtime = now.getTime();
	elapsed = Math.round((nowtime - initialtime) / 1000);
	if (elapsed >= interval){
		window.clearTimeout(timer);	
		self.location.href = '/index.php?action=accesslogout';
		} else {
			countDown();
	}
}
