// JavaScript Document
if (window.XMLHttpRequest) {
peticion = new XMLHttpRequest();
} else if (window.ActiveXObject) {
peticion = new ActiveXObject("Microsoft.XMLHTTP");
}

function getHttpObject()
{
	var xmlhttp=false;
	try
	{
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{
	xmlhttp=false;
	}
	if(window.XMLHttpRequest)
	xmlhttp = new XMLHttpRequest();
	return xmlhttp;
}

function get_choice(idTipo, idMostrar, idReem){
var http = getHttpObject();
if(http)
		{
		var idMostrar = idMostrar;
		var url = "/Sistema_Gestion/Sistema/sistema_get_choise.php";
		var params = "idMostrar="+idMostrar+"&idTipo="+idTipo;
		var combo = document.getElementById(idReem);
			http.open("POST",url,true);
			http.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			http.setRequestHeader("Content-length",params.length);
			http.onreadystatechange = function(){	
				if(http.readyState==1)
				{				
				document.getElementById('position_cargando').innerHTML='<span id="cargando">Cargando..</span>';
				}
				if(http.readyState==4 && http.status == 200)
				{
				combo.innerHTML=http.responseText;
				document.getElementById('position_cargando').innerHTML='';
				}
			}
		http.send(params);
	}else{
		document.getElementById('position_cargando').innerHTML='<span id="cargando">Error #400, no se pudo cargar la pagina intentenlo mas tarde.</span>';
	}
}

function generaReporte(tipo,file,id,DivId){
var http = getHttpObject();
if(http){	
			var params = "tipo="+tipo+"&file="+file+"&id="+id;
			var url = "/Sistema_Gestion/Reporte/genera_reporte.php";
			var combo = document.getElementById(DivId);
			http.open("POST",url,true);
			http.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			http.setRequestHeader("Content-length",params.length);
			http.onreadystatechange = function()
				{
					if(http.readyState==4 && http.status == 200)
					{
					combo.innerHTML = http.responseText;
					}
				}
			http.send(params);	
	}else{
		document.getElementById('position_cargando').innerHTML='<span id="cargando">Error #400, no se pudo cargar la pagina intentenlo mas tarde.</span>';
	}
}
