// Returns an XmlHttpRequestObject, or boolean 'false' on failure
function getXHRObject () {
	var obj = false;
	try {obj = new ActiveXObject("Msxml2.XMLHTTP");}
	catch (e) {
		try {obj = new ActiveXObject("Microsoft.XMLHTTP");}
		catch (e) {
			try {obj = new XMLHttpRequest();}
			catch (e) {return false;}
		}
	} return obj;
}

function sendRequest(nu) {
	// Create the XmlHttpRequest object
	var xhr = getXHRObject();
	// Make sure the object was created successfully
	if (xhr){
		var file = "new.php?id="+nu;
		// Open an asynchronous connection to the server, requesting page "test.php" with "get" method
		xhr.open("get", file, true);
		// Response is received by browser from server
		xhr.onreadystatechange = function () {
			if (xhr.readyState == 1) {
				document.getElementById('frase').innerHTML = "<cite>Attendi</cite>";
			}
			if (xhr.readyState == 4) {
				// Make sure server returned status code 200 (200 = OK, 404 = Page not Found, ...)
				if (xhr.status == 200) {
					// Simply alert what the server returned to us for now
					document.getElementById('frase').innerHTML = xhr.responseText;
				}
			}
		};
		// Send the request
		xhr.send(null);
	}
}

window.onload = function() {document.getElementById('altro').onclick = function() {sendRequest(document.getElementById('number').innerHTML);}}
