function iniciaAjax()
{
    Ajax = false;
    if ( window.XMLHttpRequest )
        Ajax = new XMLHttpRequest();
    else if ( window.ActiveXObject )
    {
        try {
            Ajax = new ActiveXObject("Msxm12.XMLHTTP");
        } catch (e) {
            try {
            Ajax = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    else
        alert("Não foi possivel iniciar o Ajax!")
}

function buscaLoginAcesso(form)
{
	var login = form.f_login.value;
	var senha = form.f_senha.value;
	iniciaAjax();
	
	if ( !Ajax )
	{
		alert('Não foi possivel iniciar o Ajax!');
		return;
	}

	Ajax.onreadystatechange = function() {resultadoLoginAcesso(form)};
	Ajax.open('GET','./xml/xml_login_acesso.php?login='+login+'&senha='+senha,true);
	Ajax.send(null);
}

function resultadoLoginAcesso(form)
{
	if ( Ajax.readyState == 4 )
	{
		if ( Ajax.status == 200 )
		{
			var xml_login = Ajax.responseXML;
			
			if ( xml_login.hasChildNodes() )
			{
				var login = xml_login.getElementsByTagName('login');
				var login2= login[0].childNodes;
				
				if ( login2[0].nodeValue == 'false' )
					document.getElementById('erro_login').innerHTML = 'Usuário ou senha inválidos!';
				else
				{
					form.submit();
				}
			}
			else
				alert(xml_login.hasChildNodes());
		}
	}
}