
	if ( !qFlux )
		var qFlux = {};
	qFlux.account = {};
	qFlux.account.text = {};
	
	//####################################################################################################

	qFlux.account.enterDown = function() 
		{ qFlux.account.sendLogin(); }

	//####################################################################################################

	qFlux.account.sendLogin = function()
		{
			document.getElementById('account_status').innerHTML = '';
			document.getElementById('account_status').style.display = 'none';
			var name = document.getElementById('account_name').value;
			if ( !name || name.replace(/ /g,'').length < 3 || name.length > 16 )
				{
					qFlux.account.showStatus('name');
					return;
				}
			var password = document.getElementById('account_password').value;
			if ( !password || password.search(/ /) != -1 || password.length < 6 || password.length > 16 )
				{
					qFlux.account.showStatus('password');
					return;
				}
			if ( !qFlux.account.seed )
				{
					qFlux.xmlHttpRequest('login.php', 'task=seed', 'qFlux.account.receiveSeed');
					return;
				}
			document.getElementById('account_password').value = '';
			qFlux.xmlHttpRequest('login.php', 'task=login&name=' + name + '&hash=' + hex_md5(hex_md5(password) + qFlux.account.seed), 'qFlux.account.receiveLogin');
			qFlux.account.seed = false;
		}
	
	//####################################################################################################

	qFlux.account.sendRegister = function()
		{
			document.getElementById('account_status').innerHTML = '';
			document.getElementById('account_status').style.display = 'none';
			var name = document.getElementById('account_name').value;
			if ( !name || name.replace(/ /g,'').length < 3 || name.length > 16 )
				{
					qFlux.account.showStatus('name');
					return;
				}
			var mail = document.getElementById('account_mail').value;
			if ( !mail || !qFlux.validateMail(mail) )
				{
					qFlux.account.showStatus('mail');
					return;
				}
			qFlux.xmlHttpRequest('login.php', 'task=register&name=' + name + '&mail=' + mail, 'qFlux.account.receiveRegister');
		}
	
	//####################################################################################################

	qFlux.account.receiveRegister = function() 
		{ 
			if ( xmlHttp.readyState != 4 && xmlHttp.readyState != 'complete' )
				{ return; }
			qFlux.account.showStatus(xmlHttp.responseText);
			qFlux.xmlHttpSend();
		}

	//####################################################################################################

	qFlux.account.receiveSeed = function() 
		{ 
			if ( xmlHttp.readyState != 4 && xmlHttp.readyState != 'complete' )
				{ return; }
			if ( xmlHttp.responseText.length != 32 )
				{
					qFlux.account.showStatus(xmlHttp.responseText);
					return;
				}
			qFlux.account.seed = xmlHttp.responseText;
			qFlux.account.sendLogin();
			qFlux.xmlHttpSend();
		}

	//####################################################################################################

	qFlux.account.receiveLogin = function() 
		{ 
			if ( xmlHttp.readyState != 4 && xmlHttp.readyState != 'complete' )
				{ return; }
			if ( xmlHttp.responseText == 'success' )
				{ window.location.href = 'account'; }
			else if ( Number(xmlHttp.responseText) > 0 && Number(xmlHttp.responseText) <= 30 )
				{ qFlux.account.showStatus('block'); }
			else
				{ qFlux.account.showStatus(xmlHttp.responseText); }
			qFlux.xmlHttpSend();
		}
	
	//####################################################################################################

	qFlux.account.logout = function() 
		{ qFlux.xmlHttpRequest('login.php', 'task=logout', 'qFlux.account.receiveLogout'); }
	
	//####################################################################################################

	qFlux.account.receiveLogout = function() 
		{
			if ( xmlHttp.readyState != 4 && xmlHttp.readyState != 'complete' )
				{ return; }
			window.location.href = 'start';
			qFlux.xmlHttpSend();
		}
	
	//####################################################################################################

	qFlux.account.retreivePassword = function() 
		{
			var name = document.getElementById('account_name').value;
			if ( !name || name.length < 3 )
				{ return; }
			qFlux.xmlHttpRequest('login.php', 'task=password&name=' + name, 'qFlux.account.receiveRetreive');
		}
	
	//####################################################################################################
	
	qFlux.account.receiveRetreive = function() 
		{
			if ( xmlHttp.readyState != 4 && xmlHttp.readyState != 'complete' )
				{ return; }
			qFlux.account.showStatus(xmlHttp.responseText);
			qFlux.xmlHttpSend();
		}
	
	//####################################################################################################

	qFlux.account.showStatus = function(status) 
		{
			document.getElementById('account_status').style.backgroundColor = 'rgb(255,170,150)';
			document.getElementById('account_status').style.borderColor = 'rgb(200,0,0)';
			document.getElementById('account_status').style.color = 'rgb(200,0,0)';
			var text;
			if ( status == 'block' )
				{
					text = qFlux.account.text.block_1 + xmlHttp.responseText + qFlux.account.text.block_2;
					window.setTimeout("document.getElementById('account_status').style.display = 'none'", 30000);
				}
			else if ( status == 'password_send' )
				{
					document.getElementById('register_action').style.display = 'none';
					document.getElementById('account_status').style.backgroundColor = 'rgb(160,230,160)';
					document.getElementById('account_status').style.borderColor = 'rgb(0,230,0)';
					document.getElementById('account_status').style.color = 'rgb(0,230,0)';
					text = qFlux.account.text.password_send;
					window.setTimeout("window.location.href = 'start'", 7000);
				}
			else
				{
					if ( qFlux.account.text[status] )
						{ text = qFlux.account.text[status]; }
					else
						{ text = qFlux.account.text.unknown; }
					window.setTimeout("document.getElementById('account_status').style.display = 'none'", 10000);
				}
			document.getElementById('account_status').innerHTML = text;
			document.getElementById('account_status').style.display = 'block';
		}

