function nuevoAjax()
{ 
	var xmlhttp=false;
	try
	{
		// Creacion del objeto AJAX para navegadores no IE
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e)
	{
		try
		{
			// Creacion del objet AJAX para IE
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E)
		{
			if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new XMLHttpRequest();
		}
	}
	return xmlhttp; 
}

function ajax_operador(leyen)
{
	var selectOrigen=document.getElementById("campo");
	// Cual opcion el usuario selecciono
	var opcionSeleccionada=selectOrigen.options[selectOrigen.selectedIndex].value;
	if(opcionSeleccionada==0)
	{
		var x=posicionSelectDestino, selectActual=null;
	}
	   	var division=document.getElementById("divoperador");
		var ajax=nuevoAjax();
	    var ajax1=nuevoAjax();

		var param1="select=operador&opcion="+escape(opcionSeleccionada)+"&lov="+escape(jlov[selectOrigen.selectedIndex - 1]);
		param1=escape(param1);
		ajax1.open("GET", "/funciones/gral2.php?p1="+param1, true);
				ajax1.onreadystatechange=function() 
		{ 
			if (ajax1.readyState==1)
			{
				// Esto es para el tiempo mientras se carga- saca la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
				var nuevaOpcion=document.createElement("pepe"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
			}
		if (ajax1.readyState==4)
			{
			
			
				ajax.open("GET", "proper.php?select=operador&opcion="+escape(opcionSeleccionada)+"&lov="+escape(jlov[selectOrigen.selectedIndex - 1]), true);
		ajax.onreadystatechange=function() 
		{ 
			if (ajax.readyState==1)
			{
				// Esto es para el tiempo mientras se carga- saca la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
				var nuevaOpcion=document.createElement("option"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
			}
			if (ajax.readyState==4)
			{
		division.innerHTML='<label class="labelchi">'+leyen+'</label>'+ajax.responseText;
		division.style.visibility  = "visible";
			} 
		}
		ajax.send(null);

		
		
			} 	
		}
		ajax1.send(null);
		return;
}
function ajax_lov(leyen,texto)
{
	var resul;
    	var division0=document.getElementById("divlov0");
	   	var divbus0=document.getElementById("divbus");
	   	var division=document.getElementById("divlov");
	   	var bus1=document.getElementById("buspepe");
	   	var boton=document.getElementById("botbuscar");

		var ajax=nuevoAjax();
	    var ajax1=nuevoAjax();

		var param1="param="+leyen+"&busca="+escape(texto);
		param1=escape(param1);
		ajax1.open("GET", "/funciones/gral2.php?p1="+param1, true);
				ajax1.onreadystatechange=function() 
		{ 
			if (ajax1.readyState==1)
			{
				// Esto es para el tiempo mientras se carga- saca la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
				var nuevaOpcion=document.createElement("pepe"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
			}
		if (ajax1.readyState==4)
			{

		ajax.open("GET", "gentablaleg.php?param="+leyen+"&busca="+escape(texto), true);
   ajax.onreadystatechange = function() {
           if (ajax.readyState==1) {
            division.innerHTML="Cargando.......";
			division0.style.visibility  = "visible";
			divbus0.style.visibility  = "visible";
			 bus1.style.visibility  = "visible";
			 boton.style.visibility  = "visible";

                   }
                   else if (ajax.readyState==4){
                       if(ajax.status==200){
					  
                                   division.innerHTML=ajax.responseText;
			                       division0.style.visibility  = "visible";
			divbus0.style.visibility  = "visible";
			 boton.style.visibility  = "visible";
			 bus1.style.visibility  = "visible";

                                         }
                        else if(ajax.status==404)
                               {
                            division.innerHTML = "La direccion no existe";
                                }
                                else
                                    {
                            division.innerHTML = "Error: ".ajax.status;
                                    }
                                              }
                                          }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send(null);
		 		
			} 	
		}
		ajax1.send(null);
         return
} 
function ajax_lovsimple(leyen,texto)
{
	var resul;
    	var division0=document.getElementById("divlov0");
	   	var division=document.getElementById("divlov");
	   	var bus1=document.getElementById("buspepe");
	   	var boton=document.getElementById("botbuscar");

		var ajax=nuevoAjax();
	    var ajax1=nuevoAjax();

		var param1="param="+leyen+"&busca="+escape(texto);
		param1=escape(param1);
		ajax1.open("GET", "/funciones/gral2.php?p1="+param1, true);
				ajax1.onreadystatechange=function() 
		{ 
			if (ajax1.readyState==1)
			{
				// Esto es para el tiempo mientras se carga- saca la opcion "Selecciona Opcion..." y pongo una que dice "Cargando..."
				var nuevaOpcion=document.createElement("pepe"); nuevaOpcion.value=0; nuevaOpcion.innerHTML="Cargando...";
			}
		if (ajax1.readyState==4)
			{
		
		ajax.open("GET", "gentablaleg.php?param="+leyen+"&busca="+escape(texto), true);
   ajax.onreadystatechange = function() {
           if (ajax.readyState==1) {
            division.innerHTML="Cargando.......";
			division0.style.visibility  = "visible";
		//	 bus1.style.visibility  = "visible";
		//	 boton.style.visibility  = "visible";

                   }
                   else if (ajax.readyState==4){
                       if(ajax.status==200){
					  
                                   division.innerHTML=ajax.responseText;
			                       division0.style.visibility  = "visible";
			// boton.style.visibility  = "visible";
                                         }
                        else if(ajax.status==404)
                               {
                            division.innerHTML = "La direccion no existe";
                                }
                                else
                                    {
                            division.innerHTML = "Error: ".ajax.status;
                                    }
                                              }
                                          }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send(null);
		 		
			} 	
		}
		ajax1.send(null);
         return
} 
