var uniAjax_Waiting = '<table border="0" align="center" cellpadding="4" cellspacing="0"><tr><td align="center" class="bold">leyendo datos<br /><img src="/images/PleaseWait.gif" width="35" height="35" /></td></tr></table>';

function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
       try {
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (e) {
          try {
             xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
          } catch (E) { xmlhttp = false; }
       }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
       try {
          xmlhttp = new XMLHttpRequest();
       } catch (e) { xmlhttp = false; }
    }
    return xmlhttp;
}


/* 
class uniAjax: el AJAX de Unitec (sincronica)

necesita en caso de querer debuguear que está ocurriendo, un tag <SPAN id='debugArea'></SPAN> en algún lugar del documento.
Este tag debe estar definido previo a la creación del objeto del tipo uniAjax, ejemplo:

<SPAN id='debugArea'></SPAN>
<script type="text/javascript">
	var ajax = new uniAjax();
</script>

tiene 1 metodo público que es leer(URL) que devuelve el resultado de haber procesado un requerimiento a esa URL
*/
function uniAjax() {
	this._http = getHTTPObject(); 		// Creamos el objeto XMLHttpRequest
    this.isWorking = false; 			// lo usamos para ver si hay un proceso activo
	this._debugAjax('objeto ajax creado');
}

uniAjax.prototype.isWorking;

uniAjax.prototype._debugAjax = function(str){
	try{
		window.document.getElementById('debugArea').innerHTML = str;
	} catch(e){};
}
uniAjax.prototype._isWorking = function() {
	this._debugAjax('entre a _isWorking');
    return this.isWorking;
}

uniAjax.prototype.leer = function(url){ // procesa un requerimiento HTTP y obtiene el resultado en HTML
	this._debugAjax('entre a leer');
	var results='';
	if (!this.isWorking && this._http) {
		this.isWorking = true;
		this._debugAjax('url a llamar: '+url);
		this._http.open("GET", url, false);
		this._http.send(null);
		
		if (this._http.status == 200) { 
			results = this._http.responseText.toString(); 
		} else {
			alert("ERROR AJAX\nStatus: "+this._http.status+'\nURL: '+url);
		} // EOF
    }
	this.isWorking = false;
	return results;
}
// fin de uniAjax class

