try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

var ajaxLastResult;
var ajaxLine = new Array;
var ajaxReady = true;
var ajax = new Object();

function ajaxGet(URL, func)
	{
		var texto;

		ajaxReady = false;

    	xmlhttp.open("GET", URL, true);
		xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState==4)
					{
						texto = xmlhttp.responseText;
						texto = texto.replace(/\+/g," ");
						texto = unescape(texto);
						
						ajaxLastResult = texto;
												
						setTimeout(func, 1);

						ajaxReady = true;
					}
			}
    	xmlhttp.send(null);
	}



/* LOADHTML */
function loadHTML(uri, id) {
		
	if(!ajaxReady)
		return;
	
	getE(id).innerHTML = '&nbsp;';
	
	ajaxGet(uri, function () {						   
		getE(id).innerHTML = ajaxLastResult;
	} );
}


/* AJAX OBJECT */
function Ajax () {
	this.onload = null;
	this.embed_js = false;
}
Ajax.prototype.get = function (uri) {
	
	var response = '';
	var onload = this.onload;
	var embed_js = this.embed_js;
	
	if(!ajaxReady) {
		setTimeout( function () { this.get(uri); } , 1000);
		return;
	}
	
	ajaxReady = false;
	
	xmlhttp.open("GET", uri, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4) {
			
			if(embed_js === true) { // js embutido
				response = xmlhttp.responseText;
				response = response.replace(/\+/g," ");
				response = unescape(response);
				response = response.split('<!-- ENDJS -->');
	
				if(response.length == 2) {
					ajaxLastResult = response[1];
					eval(response[0]);
				} else {
					ajaxLastResult = response[0];
				}			
			} else { // normal
				response = xmlhttp.responseText;
				response = response.replace(/\+/g," ");
				response = unescape(response);
				
				ajaxLastResult = response;
			}
			
			try {
				onload(ajaxLastResult);
			} catch (err) { }
			
			ajaxReady = true;
		}
	}
    xmlhttp.send(null);
}