var images = new Array()
function preload() {
	for (i = 0; i < preload.arguments.length; i++) {
		images[i] = new Image()
		images[i].src = preload.arguments[i]
	}
}
var xmlHttp = getNewHTTPObject();
function getNewHTTPObject()
{
        var xmlhttp;

        if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
        {
            try
            {
                xmlhttp = new XMLHttpRequest();
            }
            catch (e)
            {
                xmlhttp = false;
            }
        }

        return xmlhttp;
}
function checkLogin()
{
	if (document.getElementById('login').value == '')
	{
		document.getElementById('logerr').innerHTML = 'Please enter your username';
		return false;
	}
	if (document.getElementById('password').value == '')
	{
		document.getElementById('logerr').innerHTML = 'Please enter your password';
		return false;
	}
	Dialog.info("<center><font style='font-size:15px;color:#808080'><b>Checking login details</b></font><div style='height:8px'><!-- --></div><img width=170 height=15 src=/images/loading.gif>", {className: "alphacube", width:220, height:60});
	var url = "/ajax/login.php?user="+document.getElementById('login').value+"&pass="+document.getElementById('password').value;
	xmlHttp.open('GET', url, true);
	xmlHttp.onreadystatechange = callbackLogin;
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send(null);
}
function callbackLogin()
{
	if (xmlHttp.readyState != 4)
		return;

	var results = eval( "(" + xmlHttp.responseText + ")" );
	if (results['status'] == 'FAILED')
	{
		alert('Login failed: Wrong username/password');
		Dialog.closeInfo();
		return false;
	}
	if (results['status'] == 'SUCCESS')
	{
		location.reload();
	}
}

