var autologout_win;
var autologout_timer;
var autologout_response = true;

function autologout_set(minutes)
{
	if (autologout_timer)
		window.clearTimeout(autologout_timer);
	autologout_timer = window.setTimeout('autologout_display()',minutes*60*1000);
}

function autologout_clear()
{
	if (autologout_win && !autologout_win.closed)
	{
		autologout_win.close();
		autologout_win = null;
	}
}

function autologout_display()
{
	autologout_win = window.open("autologout.php","_blank","width=200,height=150");
	if (autologout_win == null) {
		// open failed so log them out.  we are in the desired window at this point.
		autologout_logout();
	}
}

function autologout_logout()
{
	window.location.href="index.php?s=5&dologout=yes";
}

function autologout_popup_start()
{
	window.setTimeout('autologout_response=false;window.close()',15000);
}

function autologout_popup_end(minutes)
{
	if (!window.opener || window.opener.closed)
		return;

	if (autologout_response)
		window.opener.autologout_set(minutes);
	else
		window.opener.autologout_logout();
}
