// Change the next variable to fit your needings
var gloading_text = 'Cargando... por favor espera';

// Call this function when you need to start callbacks
function gload_content(url, div_id) {
	// Create the xml object for every request
	var o_xml = false;
	if (window.XMLHttpRequest) { // It works for mozilla, safari, etc.
		o_xml = new XMLHttpRequest();
	} else if (window.ActiveXObject){ // Let's figure it out on IExplorer
		try {
			o_xml = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {  // Older versions
				o_xml = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e){ alert(e); }
		}
	}
	if(o_xml === false) {
		return false;	// Browser doesn't support ajax or we didn't implement the right method
	}
	if(gloading_text != '') {
		document.getElementById(div_id).innerHTML = gloading_text;
	}
	o_xml.onreadystatechange=function(){
		gload_response(o_xml, div_id);
	}
	o_xml.open('GET', url, true) // asignamos los métodos open y send
	o_xml.send(null)
}

function gload_response(o_xml, div_id) {
	if (o_xml.readyState == 4) {	// Process completed
		if(o_xml.status >= 200 ||  o_xml.status <= 300) {	// 200 to 300 are right values
			document.getElementById(div_id).innerHTML = o_xml.responseText;
		} else {
			document.getElementById(div_id).innerHTML = 'Error #' + o_xml.status + '; please try again';
		}
	}
}

