var xmlHttpObj;
function catchEvent(eventObj, event, eventHandler) {
	if (eventObj.addEventListener) {
		eventObj.addEventListener(event, eventHandler, false);
	} else if (eventObj.attachEvent){
		event = "on" + event;
		eventObj.attachEvent(event, eventHandler);
	}
}
catchEvent(window,"load", function() {
	document.getElementById("botao").onclick=retorno;
	//catchEvent(getElementById("botao"), "submit", retorno);
	//alert(document.getElementById("botao").value);
});
// cria objeto XHR - aqui está a mudança em relação ao exemplo java84.htm
function getXmlHttp() {
	var xmlhttp = null;
	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	} else {
		try
		{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				return xmlhttp;
			}
		}
	}
	return xmlhttp;
}
// prepara e envia a solicitação XHR
function retorno() {
	var nome = document.getElementById("jogador").nome.value;
	var URL = 'player.php?nome=' + nome;
	// se xmlHttpObj não estiver configurado
	if (!xmlHttpObj)
	xmlHttpObj = getXmlHttp();
	if (!xmlHttpObj) return;
	xmlHttpObj.open('GET', URL, true);
	xmlHttpObj.onreadystatechange = continua;
	xmlHttpObj.send(null);
}
// processa o retorno
function continua() {
	if (xmlHttpObj.readyState == 4 && xmlHttpObj.status == 200) {
		document.getElementById("retorno").innerHTML = xmlHttpObj.responseText;
	} else if (xmlHttpObj.readyState == 4 && xmlHttpObj.status != 200) {
		document.getElementById("retorno").innerHTML = 'Error: preSearch Failed!';
	}
}
