// JavaScript Document
function creaAjax()
{
	var objetoAjax=false;
	try
	{
		/*Para navegadores distintos a internet explorer*/
		objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e) 
	{
		try
		{
			/*Para explorer*/
			objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (E)
		{
			objetoAjax = false;
		}
	}		
	if (!objetoAjax && typeof XMLHttpRequest!='undefined')
	{
		objetoAjax = new XMLHttpRequest();
	}
	return objetoAjax;
}
// funciones 

function getproyectos()
{
	var ajax=creaAjax();
	
	document.getElementById('cargar').style.display = "block"; // mensaje de cargando
	
	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("empresa="+document.actpro.empresa.value);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('proyecto').innerHTML="Cargando ...";			
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{				
				document.getElementById('cargar').style.display = "none";
				document.getElementById('proyecto').innerHTML=ajax.responseText;
				getproyecto()
				document.actpro.nombre.value="";
				document.actpro.fecha.value="";
				document.actpro.descripcion.value="";
				document.actpro.envio.value="";
				document.actpro.vigente.value="";
			}
		}
	}	
}
function getmcpro(cod)
{
	var ajax=creaAjax();

	//document.getElementById('cargar').style.display = "block"; // mensaje de cargando
	document.getElementById(cod).style.display = "block";
	ajax.open ('POST', 'panel/lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("miproyecto="+cod);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('nombre').innerHTML="Cargando ...";
			//document.getElementById('cargar').style.display = "block";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				//document.getElementById('nombre').innerHTML=ajax.responseText;	
				document.getElementById(cod).innerHTML=ajax.responseText;
			}
		}
	}
}
function getpro(cod)
{
	var ajax=creaAjax();

	//document.getElementById('cargar').style.display = "block"; // mensaje de cargando
	document.getElementById(cod).style.display = "block";
	ajax.open ('POST', 'panel/lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("proyecto="+cod);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('nombre').innerHTML="Cargando ...";
			//document.getElementById('cargar').style.display = "block";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				//document.getElementById('nombre').innerHTML=ajax.responseText;	
				document.getElementById(cod).innerHTML=ajax.responseText;
			}
		}
	}
}
function geteve(cod)
{
	var ajax=creaAjax();

	//document.getElementById('cargar').style.display = "block"; // mensaje de cargando
	
	ajax.open ('POST', 'panel/lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("evento="+cod);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('nombre').innerHTML="Cargando ...";
			//document.getElementById('cargar').style.display = "block";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				//document.getElementById('nombre').innerHTML=ajax.responseText;	
				document.getElementById(cod).innerHTML=ajax.responseText;
			}
		}
	}
}

function getparticipante()
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("participante="+document.actpro.participante.value);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			document.getElementById('participante').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				//document.getElementById('nombre').innerHTML=ajax.responseText;				
				var arrayResultado = eval(ajax.responseText); // evaluamos el array que generó el php
				if (arrayResultado.length >= 2)
				{
					document.actpro.rut.value=arrayResultado[0];
					document.actpro.dv.value=arrayResultado[1];
					document.actpro.nombrep.value=arrayResultado[4];
					document.actpro.cargo.value=arrayResultado[5];
					document.actpro.direccion.value=arrayResultado[9];
					document.actpro.mail.value=arrayResultado[6];
					document.actpro.fono.value=arrayResultado[8];
					document.actpro.celular.value=arrayResultado[7];
					document.actpro.password.value=arrayResultado[11];
					document.actpro.status.value=arrayResultado[10];
				}
			}
		}
	}
}
function getdocumentos()
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("documentos="+document.ingdoc.evento.value);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			document.getElementById('documentos').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				document.getElementById('documentos').innerHTML=ajax.responseText;
				getdocumento()
				/*document.actpro.nombre.value="";
				document.actpro.fecha.value="";
				document.actpro.descripcion.value="";
				document.actpro.envio.value="";
				document.actpro.vigente.value="";*/
			}
		}
	}
}
function getdocumento()
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("documento="+document.ingdoc.documentos.value);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('documentos').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				//document.getElementById('documentos').innerHTML=ajax.responseText;
				var arrayResultado = eval(ajax.responseText); // evaluamos el array que generó el php
				if (arrayResultado.length >= 2)
				{
					document.ingdoc.nombre.value=arrayResultado[1];
					document.ingdoc.resumen.value=arrayResultado[5];
					document.ingdoc.clave.value=arrayResultado[6];
					// Para el combo de tipo de ventana en q se abrira el documento
					if( arrayResultado[7]==1 )					
						document.ingdoc.abrir[1].checked=true;
					else
						document.ingdoc.abrir[0].checked=true;
					document.ingdoc.status.value=arrayResultado[3];					
					var fecha = arrayResultado[2].split('-');
					document.ingdoc.mes.value=parseFloat(fecha[1]);
					document.ingdoc.anio.value=fecha[0];
				}				
			}
		}
	}
}
function getdocmsj()
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("docmsj="+document.actpro.docs.value);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('documentos').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				document.getElementById('docus').innerHTML=ajax.responseText;
				/*var arrayResultado = eval(ajax.responseText); // evaluamos el array que generó el php
				if (arrayResultado.length >= 2)
				{
					document.ingdoc.nombre.value=arrayResultado[1];
					document.ingdoc.resumen.value=arrayResultado[5];
					document.ingdoc.clave.value=arrayResultado[6];
					// Para el combo de tipo de ventana en q se abrira el documento
					if( arrayResultado[7]==1 )					
						document.ingdoc.abrir[1].checked=true;
					else
						document.ingdoc.abrir[0].checked=true;
					document.ingdoc.status.value=arrayResultado[3];					
					var fecha = arrayResultado[2].split('-');
					document.ingdoc.mes.value=parseFloat(fecha[1]);
					document.ingdoc.anio.value=fecha[0];
				}*/				
			}
		}
	}
}
function getobjmsj()
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("objmsj="+document.actpro.objs.value);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('documentos').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				document.getElementById('objes').innerHTML=ajax.responseText;
				/*var arrayResultado = eval(ajax.responseText); // evaluamos el array que generó el php
				if (arrayResultado.length >= 2)
				{
					document.ingdoc.nombre.value=arrayResultado[1];
					document.ingdoc.resumen.value=arrayResultado[5];
					document.ingdoc.clave.value=arrayResultado[6];
					// Para el combo de tipo de ventana en q se abrira el documento
					if( arrayResultado[7]==1 )					
						document.ingdoc.abrir[1].checked=true;
					else
						document.ingdoc.abrir[0].checked=true;
					document.ingdoc.status.value=arrayResultado[3];					
					var fecha = arrayResultado[2].split('-');
					document.ingdoc.mes.value=parseFloat(fecha[1]);
					document.ingdoc.anio.value=fecha[0];
				}*/				
			}
		}
	}
}
function getcommsj()
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("commsj="+document.actpro.coms.value);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('documentos').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				document.getElementById('comps').innerHTML=ajax.responseText;
				/*var arrayResultado = eval(ajax.responseText); // evaluamos el array que generó el php
				if (arrayResultado.length >= 2)
				{
					document.ingdoc.nombre.value=arrayResultado[1];
					document.ingdoc.resumen.value=arrayResultado[5];
					document.ingdoc.clave.value=arrayResultado[6];
					// Para el combo de tipo de ventana en q se abrira el documento
					if( arrayResultado[7]==1 )					
						document.ingdoc.abrir[1].checked=true;
					else
						document.ingdoc.abrir[0].checked=true;
					document.ingdoc.status.value=arrayResultado[3];					
					var fecha = arrayResultado[2].split('-');
					document.ingdoc.mes.value=parseFloat(fecha[1]);
					document.ingdoc.anio.value=fecha[0];
				}*/				
			}
		}
	}
}
function getmensajes()
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("mensajes="+document.actpro.evento.value);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('documentos').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				document.getElementById('msj').innerHTML=ajax.responseText;
				/*var arrayResultado = eval(ajax.responseText); // evaluamos el array que generó el php
				if (arrayResultado.length >= 2)
				{
					document.ingdoc.nombre.value=arrayResultado[1];
					document.ingdoc.resumen.value=arrayResultado[5];
					document.ingdoc.clave.value=arrayResultado[6];
					// Para el combo de tipo de ventana en q se abrira el documento
					if( arrayResultado[7]==1 )					
						document.ingdoc.abrir[1].checked=true;
					else
						document.ingdoc.abrir[0].checked=true;
					document.ingdoc.status.value=arrayResultado[3];					
					var fecha = arrayResultado[2].split('-');
					document.ingdoc.mes.value=parseFloat(fecha[1]);
					document.ingdoc.anio.value=fecha[0];
				}*/				
			}
		}
	}
}
function getinfomsj()
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("infomsj="+document.actpro.mensajes.value);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('documentos').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				//document.getElementById('msj').innerHTML=ajax.responseText;
				var arrayResultado = eval(ajax.responseText); // evaluamos el array que generó el php
				if (arrayResultado.length >= 2)
				{
					document.actpro.resumen.value=arrayResultado[2];
					document.actpro.nombre.value=arrayResultado[3];
					document.actpro.plazo.value=arrayResultado[4];
					document.actpro.status.value=arrayResultado[5];					
					var fecha = arrayResultado[6].split(' ');
					document.actpro.fecha.value=fecha[0];					
				}			
			}
		}
	}
}
function getmsj(cod)
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("msj="+cod);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('documentos').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				document.getElementById(cod).style.display = "block";
				document.getElementById(cod).innerHTML=ajax.responseText;
				/*var arrayResultado = eval(ajax.responseText); // evaluamos el array que generó el php
				if (arrayResultado.length >= 2)
				{
					document.ingdoc.nombre.value=arrayResultado[1];
					document.ingdoc.resumen.value=arrayResultado[5];
					document.ingdoc.clave.value=arrayResultado[6];
					// Para el combo de tipo de ventana en q se abrira el documento
					if( arrayResultado[7]==1 )					
						document.ingdoc.abrir[1].checked=true;
					else
						document.ingdoc.abrir[0].checked=true;
					document.ingdoc.status.value=arrayResultado[3];					
					var fecha = arrayResultado[2].split('-');
					document.ingdoc.mes.value=parseFloat(fecha[1]);
					document.ingdoc.anio.value=fecha[0];
				}*/				
			}
		}
	}
}
function outmsj(cod)
{
	document.getElementById(cod).style.display = "none";
}
function cargarMenu(cod)
{
	var ajax=creaAjax();

	ajax.open ('POST', 'lib/combos.php?', true);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax.send("cm="+cod);

	ajax.onreadystatechange = function() 
	{
		if (ajax.readyState==1)
		{
			//document.getElementById('documentos').innerHTML="Cargando ...";
		}
		else if (ajax.readyState==4)
		{
			if(ajax.status==200)
			{
				//document.getElementById(cod).style.display = "block";
				document.getElementById("submenu").innerHTML=ajax.responseText;
				/*var arrayResultado = eval(ajax.responseText); // evaluamos el array que generó el php
				if (arrayResultado.length >= 2)
				{
					document.ingdoc.nombre.value=arrayResultado[1];
					document.ingdoc.resumen.value=arrayResultado[5];
					document.ingdoc.clave.value=arrayResultado[6];
					// Para el combo de tipo de ventana en q se abrira el documento
					if( arrayResultado[7]==1 )					
						document.ingdoc.abrir[1].checked=true;
					else
						document.ingdoc.abrir[0].checked=true;
					document.ingdoc.status.value=arrayResultado[3];					
					var fecha = arrayResultado[2].split('-');
					document.ingdoc.mes.value=parseFloat(fecha[1]);
					document.ingdoc.anio.value=fecha[0];
				}*/				
			}
		}
	}
}