// Copyright (c) Gate17 System www.gate17.net by Marc Krisnanto. All rights reserved.

var App = {};

App.logout = function ()
{
	try
	{
		Server.get ('/command?a=qLogout');
	}
	catch (err)
	{
	}
	var g = document.getElementById ("logout");
	if (g)
		g.style.display = "none";
	try
	{
		if (thisUser.auth)
			document.location.reload ();
	}
	catch (err)
	{
	}
};


App.setLogout = function ()
{
	var l = thisUser ? thisUser.auth : 0;
	var g = document.getElementById ("logout");
	if (g)
		g.style.display = "none";
	try
	{
		getThisUser ();
		if (thisUser.auth)
		{
			g.innerHTML = 'Logout: ' + thisUser.ids;
			g.style.display = "inline";
		}
	}
	catch (err)
	{
	}
	if (l == 0 && thisUser.auth)
	{
		try
		{
			document.location.reload ();
		}
		catch (err)
		{
		}
	}
};


App.toggle = function (x)
{
	var t = document.getElementById (x + 'T');
	var c = document.getElementById (x + 'C');
	if (c.style.display == 'none')
	{
		t.className = 'ItemTitleOn';
		c.style.display = 'block';
	}
	else
	{
		t.className = 'ItemTitleOff';
		c.style.display = 'none';
	}
}


App.init = function ()
{
	delete window.onfocus;
	App.setLogout ();
	window.cmdAppClose = App.logout;
};

