function objetoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}


function RefreshData(FileName, DivId){
	//donde se mostrará los registros
	divContenido = document.getElementById(DivId);
	if(divContenido){
		ajax=objetoAjax();
		ajax.open("GET", FileName, true);
		divContenido.innerHTML= '<center style="font-family: Verdana; font-size: 10px; color: #CCCCCC">Cargando...<br><img src="manager/sources/scripts/wajax/anim.gif"/></center>';
		ajax.onreadystatechange=function() {
			if (ajax.readyState==4) {
				//mostrar resultados en esta capa
				//divContenido.innerHTML = ajax.responseText
				SetContainerHTML(DivId, ajax.responseText, true);
				//RefreshDataSide('manager/Blank.php', 'Anuncios');
			}
		}
		ajax.send(null);
	}else{
		return false;
	}
}


//lo mismo que la anterior pero para el modulo de admon por la ruta de acceso a la imagen
function RefreshDataManager(FileName, DivId){
	//donde se mostrará los registros
	divContenido = document.getElementById(DivId);
	ajax=objetoAjax();
	ajax.open("GET", FileName, true);
	divContenido.innerHTML= '<br><br><br><center style="font-family: Verdana; font-size: 10px; color: #CCCCCC">Cargando Datos...<br><img src="http://www.grupoinmobiliario.com.sv/manager/sources/scripts/wajax/anim.gif"></center>';
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4){
			//mostrar resultados en esta capa
			//divContenido.innerHTML = ajax.responseText
			SetContainerHTML(DivId, ajax.responseText, true);
		}
	}
	ajax.send(null);
}


function SetContainerHTML(id,html,processScripts)
{
	mydiv = document.getElementById(id);
	mydiv.innerHTML = html;
	if(processScripts!=false)
	{
		var elementos = mydiv.getElementsByTagName('script');
		for(ii=0;ii<elementos.length;ii++) 
		{
			var elemento = elementos[ii];
			nuevoScript = document.createElement('script');
			nuevoScript.text = elemento.innerHTML;
			nuevoScript.type = 'text/javascript';
			if(elemento.src!=null && elemento.src.length>0)
			{nuevoScript.src = elemento.src;}
			elemento.parentNode.replaceChild(nuevoScript,elemento);
		}
	}
} 
 
