/* Script Document */

function ShowAuth()
{
	var Auth = document.getElementById ('Auth');
	if (Auth)
	{
		var display = Auth.style.display;
		if (display == 'none' || !display)
		{
			Auth.style.display = 'block';
			var Login = document.getElementById ('Username');
			if (Login) Login.focus();
			keep = true;
			Auth.onclick = Keep;
			document.onclick = CloseAuth;
		}
		else
		{
			Auth.style.display = 'none';
		}
		return false;
	}
	else return true;	
}

function TestAuthForm()
{
	var UsernameField = document.getElementById ('Username');
	var PasswordField = document.getElementById ('Password');
	var AuthSubmit = document.getElementById ('AuthSubmit');
	if (!UsernameField || !PasswordField || !AuthSubmit) return;

	AuthSubmit.disabled = !UsernameField.value || !PasswordField.value; 
}

function Keep()
{
	keep = true;
}

function CloseAuth()
{
	if (keep)
	{
		keep = false;
		return;
	}

	var Auth = document.getElementById ('Auth');	

	if (!Auth) return;

	Auth.style.display = 'none';

	document.onclick = null;
	document.onkeydown = null;
}