//--------------------------------------------------------------------------------------------------------------------------
// funcion que inicia una comunicacion AJAX
// parametros: nombre del objecto XMLHttpRequest, archivo a consultar, funcion de exito, funcion de espera, datos para POST)
//--------------------------------------------------------------------------------------------------------------------------
function request(xmlhttp, url, onSuccess, onWait, sender) {
	// Moz supports XMLHttpRequest. IE uses ActiveX.
	// browser detction is bad. object detection works for any browser
	try {		
		xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e) {
		// browser doesn't support ajax. handle however you want
		alert('no-ajax');
	}
	// the xmlhttp object triggers an event everytime the status changes
	// triggered() function handles the events
	xmlhttp.onreadystatechange = function() {
		if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)) {
			onSuccess(xmlhttp.responseText);
		} else {
			onWait();
		}
	}
	// open takes in the HTTP method and url.
	xmlhttp.open("POST", url, true);
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=ISO-8859-15');
	// send the request. if this is a POST request we would have
	// sent post variables:	send("name=aleem&gender=male)
	// Moz is fine with just send(); but
	// IE expects a value here, hence we do send(null);
	xmlhttp.send(sender);
}