xmlhttp = new XMLHttpRequest();

function validar()
{
	var login, password;
	login = document.getElementById('campo_login').value;
	password = document.getElementById('campo_password').value;
	
	xmlhttp.open("POST", "http://avap2.pepe/ajax/contesta.php", true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = evalua_xmlhttprequest;
	xmlhttp.send("login="+login+"&password="+password);
}

/**
 * Espera a la respuesta del servidor y la procesa
 * @return
 */
function evalua_xmlhttprequest()
{
	if(xmlhttp.readyState == 4)
	{
		document.alert("Ya");
	}
}

/**
 * La función habilitar_boton activa el botón en caso de que los campos reque-
 * ridos estén cumplimentados
 * @return void
 */
function habilitar_boton(login, password)
{
	objetoBoton = document.getElementById('botonFormulario');
	
	if( (login != '') && (password !='') )
	{
		objetoBoton.disabled = false;
	}
	
	else
	{
		objetoBoton.disabled = true;
	}
}

function comprueba_entradas()
{
	var login, password, notificacion;
	login = document.getElementById('campo_username').value;
	password = document.getElementById('campo_password').value;
	
	notificacion = document.getElementById('notificacion');
	
	/* Habilitación, o no, del botón si procede */
	habilitar_boton(login, password);
	
	if(notificacion.firstChild)
	{
		if( (login != '') && (password !='') )
		{
			notificacion.firstChild.nodeValue = 'Press the Enter button to log in';
		}
		
		else
		{
			notificacion.firstChild.nodeValue = 'Please specify username and password to log in';
		}
	}
	//esto se ejecuta primero...
	//si no existe el nodo aún, lo creamos
	else
	{
		if( (login != '') && (password !='') )
		{
			//creamos el nodo para representar el texto
			texto_aviso = document.createTextNode('Press the Enter button to log in');
		}
		else
		{
			//creamos el nodo para representar el texto
			texto_aviso = document.createTextNode('Please specify username and password to log in');
		}
		
		notificacion.appendChild(texto_aviso);		
	}
}
