// JavaScript Document

function inst_exp(xmlhttp)
{   
   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();   
          }   
//alert(xmlhttp);
return xmlhttp;
}


function cargarContenido(pagina,destino)
{   
   //alert(pagina+" - "+destino);
   var contenedor;   
   var ajax;      
   contenedor = document.getElementById(destino);
   ajax = inst_exp(ajax);   
   ajax.open("GET", pagina, true);   
   ajax.onreadystatechange=function() 
   {
	   if (ajax.readyState==4) 
	   {
		   contenedor.innerHTML = ajax.responseText;      
		}   
   }
   ajax.send(null);
}


function CargarContenido(url,combo,text,ope,destino) { 
    var ajax; 									//declaro mi variable 
	ajax = inst_exp(ajax);  	
  
    var contenedor =  document.getElementById(destino); //contenedor de destino
	
    var cmb = document.getElementById(combo) //el combo list 
    var x = cmb.value 
	  
	var valor = document.getElementById(text) //el texto de codigo
    var p = valor.value 
	
	var codo = document.getElementById(ope) //recibo el id del hiden operacion
    var b = codo.value 
	
   if (x=='N')
	   { 
          if(b==3) { u = "php/edo_deuda/edodeudap.php"; }
		  if(b==39){ u = "php/edo_deuda/edodeudak.php"; }
		  if(b==1) { u = "php/edo_deuda/edodeudai.php"; }
		  
	   var t_url = u+'?codigo='+p;  //armo mi url final para pasar parametros
	   openpag(t_url)
	   }
	else 
	{
		//alert(url);
 	    var t_url = url+'?Id='+x+'&Cod='+p+'&Ope='+b;  //armo mi url final para pasar parametros
	    ajax.open("GET", t_url, true);   
   		ajax.onreadystatechange=function() 
       {
   	 		if (ajax.readyState==4) 
	        {
 	   			contenedor.innerHTML = ajax.responseText;      
		//contenedor.innerHTML = ajax.pagina;      
			}   
       }   
  		ajax.send(null);
		delete ajax;
	}
} 

function CargarContenido2(url,combo,text,ope,destino) { 
    var ajax; 									//declaro mi variable 
	ajax = inst_exp(ajax);  	
   
    var contenedor =  document.getElementById(destino); //contenedor de destino
	
    var cmb = document.getElementById(combo) //el combo list 
    var x = cmb.value 
	
	var valor = document.getElementById(text) //el texto de codigo
    var p = valor.value 
	
	var codo = document.getElementById(ope) //recibo el id del hiden operacion
    var b = codo.value 
	
   if (x=='N')
	   { 
          if(b==3) { u = "php/edo_deuda/consulpa.php"; }
		  if(b==39){ u = "php/edo_deuda/edodeudak.php"; }
		  if(b==1) { u = "php/edo_deuda/edodeudai.php"; }
		  
	   var t_url = u+'?codigo='+p;  //armo mi url final para pasar parametros
	   openpag(t_url)
	   }
	else 
	{
 	    var t_url = url+'?Id='+x+'&Cod='+p+'&Ope='+b;  //armo mi url final para pasar parametros
	    ajax.open("GET", t_url, true);   
   		ajax.onreadystatechange=function() 
       {
   	 		if (ajax.readyState==4) 
	        {
 	   			contenedor.innerHTML = ajax.responseText;      
		//contenedor.innerHTML = ajax.pagina;      
			}   
       }   
  		ajax.send(null);
		delete ajax;
	}
} 

function recargar(pagina,destino)
{ 

var contenedor;   
var ajax;      
var num = Math.random(); 
    pagina = pagina + '&n=' + num;

//alert(pagina);
contenedor = document.getElementById(destino);
ajax = inst_exp(ajax);   
ajax.open("GET", pagina, true);   
ajax.onreadystatechange=function() 
  {
	if (ajax.readyState==4) 
	    {
		
		contenedor.innerHTML = ajax.responseText;      
		}   
  }   

ajax.send(null);
	
} 


function cargarCombo(cod_par,cod_ud,cod_ub,id,opt,x)
{   
//alert (cod_par+"-"+cod_ud+"-"+cod_ub+"-"+id+"-"+opt+"-"+x);


switch (opt) 
  {
   case 1: //cargar ciudades
        //alert('edo:'+cod_edo+'cda:'+cod_cda+'mun:'+cod_mun);
        ul="php/solicitud/sql_combo.php?cod_par=" + cod_par + "&cod_ud=" + cod_ud + "&cod_ub=" + cod_ub + "&opt=" + opt + "&sta=" + x;
		break;
   case 2: //cargar municios
        ul="php/solicitud/sql_combo.php?cod_par=" + cod_par + "&cod_ud=" + cod_ud + "&cod_ub=" + cod_ub + "&opt=" + opt + "&sta=" + x;

		break;
 }
 // alert(ul);
  //document.getElementById('denomin').value = ul;
  cargarContenido(ul,id) 
 
}


function cargarCombo2(cod_uno,cod_dos,cod_tres,id,opt)
{   
//alert (cod_uno+"-"+cod_dos+"-"+cod_tres+"-"+id+"-"+opt);

var x = aleatorio(1,9999);


switch (opt) 
  {
   case 4: //cargar ciudades
        ul="php/solicitud/sql_combo.php?cod_uno=" + cod_uno + "&opt=" + opt + "&sta=" + x;
		break;
 }
  //alert(ul);
  //document.getElementById('nom_con').value = ul;
  cargarContenido(ul,id) 
 
}

function doPrint()
{
 
  document.all.item("noprint").style.visibility='hidden' 
  window.print()
  document.all.item("noprint").style.visibility='visible'
  
}
function windows(pagina)
{
	var url=pagina;
window.open(url,null);
}


function valida_clave(clave1,clave2)
{
  var v1 =  document.getElementById(clave1).value;		  
  var v2 =  document.getElementById(clave2).value;		  
  if (v1!= v2)
   {
    alert("Las contraseñas no son Iguales Verifique");
    document.getElementById(clave1).value = "";		    
    document.getElementById(clave2).value = "";		    
    document.getElementById(clave1).focus();		    
   }	
}
function recup_usu()
{
  var url='php/declaracion/regi_usuario.php?opt=6'; 
  //alert (url);
  armar_url2(men_usua,url);
}

function recup_clav()
{
  var url='php/declaracion/regi_usuario.php?opt=7'; 
  armar_url2(men_recup,url);
}


function rutas(op,v,formul)//op = la ruta de armado  y la v= si verifica los datos o no   - y formul =nombre del formulario
{
 if (v==1) 
 {
	verifica(formul);
 }
   var num = Math.random(); 
 
   switch (op)
   {
     case 1://Registro solicitud
	   	var ul="php/solicitud/mant_sol.php?"; 
		var rut="php/solicitud/frm/frm_registro.php";
		var div="contenedor";
        break;
     case 2://registro actividades    
		var ul="php/solicitud/mant_actividades.php?"; 
		var rut="php/solicitud/frm/frm_actividades.php?" + "&n=" + num;;
		var div="frm_tab";
        break;
     case 3://mantenimiento accionista	    
		var ul="php/provee/mant_accionistas.php?"; 
        var rut="php/provee/formul/grp_accionistas.php?" + "&n=" + num;
		var div="formul";
        break;
	  case 4://mantenimiento de socios    
		var ul="php/solicitud/mant_socios.php?"; 
		var rut="php/solicitud/frm/grp_socios.php?" + "&n=" + num;;
		var div="frm_tab";
        break;
	  case 5://registro de empresas sin licencia
		var ul="php/agentes/mant_sinlicencia.php?"; 
		var rut="php/agentes/frm_sinlicencia.php?opt=1&i=1&f=50" + "&n=" + num;
		var div="contenedor";
        break;	
	 case 6://registro de empresas sin licencia
		var ul="php/agentes/mant_foraneos.php?"; 
		var rut="php/agentes/frm_foraneos.php?" + "&n=" + num;
		var div="contenedor";
        break;


   }
   	armar_url3(mostrar_datos,ul,rut,div);
}

function buscar() 
{
  var nro_rep = document.getElementById('nro_rep').value;
  if(typeof nro_rep =='undefined'){ nro_rep = ""; }
  
  
  if (nro_rep != "")
  {
     var num = aleatorio(1,999999);
     var url ='php/solicitud/mant_sol.php?opt=4&nro_rep='+nro_rep+'&r='+num;
	 //document.getElementById('denomin').value=url;
     ObtenerPorGETDatosHTML_2(mostrar_datos,url);
  }
}


function valida_pat() 
{
  var patente = document.getElementById('patente').value;
  if(typeof patente =='undefined'){ patente = ""; }
  
  if (patente != "")
  {
     var opt = eval(document.getElementById('opt').value);
	 blanquear_form();
     var num = aleatorio(1,9999);
     var url ='php/declaracion/sql.php?opt=7&patente='+patente+'&opt2='+opt+'&r='+num;
	 //alert(url);
     obtenerdatos(url,1,'conte');
	 switch (opt)
	 {
        case 4:
            deshabilita();
			break;
		case 5:
            deshabilita();
			break;
        case 6:
         	deshabilita();	
     		break;
 	 }
	 	 
  }

}


function armar_url(pagina,modo,destino,llamado) 
{
var e = '?';


  
  // 1.- Obtiene los datos del formulario, y los estructura en array GET/POST
  // 2.- Recorre todo los formularios y sus campos
  for (var a=0; a < document.forms.length; a++) 
  {
  for (var i=0; i < document.forms[a].length; i++) 
   {
    if (document.forms[a].elements[i].type !== "button") 
	  {
      if (document.forms[a].elements[i].type == "checkbox" ) 
	     {
         // 3.- Anexa cada par campo-valor del formulario si es un checkbo
          e = e + '&' + document.forms[a].elements[i].name + '=';
          e = e + document.forms[a].elements[i].checked;
		  }
      else
	      {
          // 4.- Anexa cada par campo-valor del formulario
		  if (document.forms[a].elements[i].name == 'denomin')
		     {
              e = e + '&' + document.forms[a].elements[i].name + '=';
			  var cadena = document.forms[a].elements[i].value;
			      cadena = cadena.replace('&','§');
              e = e + cadena;
			 }
		  else
		     {
		      e = e + '&' + document.forms[a].elements[i].name + '=';
              e = e + document.forms[a].elements[i].value;
			 }
		  }

       }
     }
   }

  var num = Math.random(); 
  url = pagina + e + '&n=' + num;
 // alert(url);
  switch (llamado) 
   {
   case 0://llamado a una archivo en new pagina
        openpag(url);
		break;
   case 1: //llamado a una funcion
        
        //document.getElementById('placa').value = url;
		ObtenerPorGETDatosHTML_2(mostrar_datos,url) 
		
		break;
   }
	
}

function armar_url2(funcion,pagina) 
{
var e = '';
  for (var a=0; a < document.forms.length; a++) 
  {
  for (var i=0; i < document.forms[a].length; i++) 
   {
    if (document.forms[a].elements[i].type !== "button") 
	  {
      if (document.forms[a].elements[i].type == "checkbox" ) 
	     {
          e = e + '&' + document.forms[a].elements[i].name + '=';
          e = e + document.forms[a].elements[i].checked;
		  }
      else
	      {
          e = e + '&' + document.forms[a].elements[i].name + '=';
          e = e + document.forms[a].elements[i].value;
          }
       }
     }
   }

  var num = Math.random(); 
  url = pagina + e + '&n=' + num;
  //document.getElementById('placa').value=url;
  ObtenerPorGETDatosHTML_2(funcion,url) 
}


function armar_url3(funcion,pagina,recarga,div) 
{
var e = '';
  for (var a=0; a < document.forms.length; a++) 
  {
  for (var i=0; i < document.forms[a].length; i++) 
   {
    if (document.forms[a].elements[i].type !== "button") 
	  {
      if (document.forms[a].elements[i].type == "checkbox" ) 
	     {
          e = e + '&' + document.forms[a].elements[i].name + '=';
          e = e + document.forms[a].elements[i].checked;
		  }
      else
	      {
		  var linea = document.forms[a].elements[i].value;
          //linea = linea.toUpperCase();     //convierte en mayustula
          linea = linea.replace(/&/g, "~"); //remplaza los ampersan por ~
          linea = linea.replace(/#/g, "^"); //remplaza los ampersan por ~
          e = e + '&' + document.forms[a].elements[i].name + '='+linea;
          }
       }
     }
   }

  var num = Math.random(); 
  url = pagina + e + '&n=' + num;

  //document.getElementById('denomin').value=url;
  //alert(url);
  ObtenerDatos2(funcion,url,recarga,div) 

  
}



function obtenerdatos(url,modo,destino){
var contenedor;   
var ajax;     


//alert(url);
contenedor = document.getElementById(destino);
ajax = inst_exp(ajax); 
ajax.open("GET",url,true);

ajax.onreadystatechange = function() 
  {
	if (ajax.readyState==4) 
	    {
			
		 if (modo == false )//es para un DIV	
		      {
				contenedor.innerHTML = ajax.responseText;
			   }
	     else //llama una funcion
		      {
                var datos = ajax.responseText;
				mostrar_datos(datos);
			  }
		}   
  }   
ajax.send(null);
}


function ObtenerDatos2(retorno,urlDatos,recarga,div) 
{
	var XMLHttpRequestObject = false;
	if (window.XMLHttpRequest) 
	{
	    XMLHttpRequestObject = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) 
	{
	    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
	}

	if (XMLHttpRequestObject) 
	{
		XMLHttpRequestObject.open("GET", urlDatos);
		XMLHttpRequestObject.onreadystatechange = function() 
		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
			{
				var respGetHTML = XMLHttpRequestObject.responseText;
				retorno(respGetHTML,recarga,div);
				delete XMLHttpRequestObject;
				XMLHttpRequestObject = null;
				//alert(respGetHTML);
			}
		}
		XMLHttpRequestObject.send(null);
	}
}

function men_usua(datos) 
{

  a = car(datos);
  b = isNaN(a); //devuelve verdadero si es strin
  if (isNaN(a)==false)
   {
     a = eval(a); 
     msj_error(a);
	}
  else
     mostrar_datos(a)	
}



function mostrar_datos(datos,recarga,div) 
{
  //alert(datos+"-"+recarga+"-"+div);
  //document.getElementById('denomin').value=datos;
  
  a = car(datos);

  b = isNaN(a);
  if (b == false){ a = eval(a); }
  //alert(recarga);
  switch (a) 
  {
   case 0: 
		msj_error(0);
		break;
   case 1: 
  	    msj_error(1);
		if (recarga != null )
		 { 
		   if (recarga != "" )
		   {
			 cargarContenido(recarga,div); 
		   }
		 }
		reporte()
		//activar();activa la declaracion
  	    blanquear_form();
		foco('patente');
		break;
   case 2: 
        msj_error(2);
		break;
   case 3: 
        msj_error(3);
		break;
   case 4: 
        msj_error(1);
		if (recarga != null )
		  { cargarContenido(recarga,div); }
		break;		
	case 5: 
        msj_error(5);
		if (recarga != null )
		  { cargarContenido(recarga,div); }
		break;	
   case 6: 
		msj_error(4);
		break;	
   case 7: 
		msj_error(5);
   case 8: 
		msj_error(6);		
		break;	
   case 9: 
		msj_error(7);		
		break;	
   case 10: 
		msj_error(8);		
		break;	
   case 11: 
		msj_error(9);		
		break;	
   case 12: 
		msj_error(10);		
		break;	
   case 13: 
		msj_error(11);		
		break;
   case 14: 
		msj_error(12);		
		break;	
   case 15: 
		msj_error(13);		
		break;	
   case 16: 
		msj_error(14);		
		break;
   case 17: 
		msj_error(15);		
		break;
   case 18: 
		msj_error(16);		
		break;
   case 20: 
		msj_error(6);		
		break;		
   case 30:
        alert("paso");
  	    msj_error(30);
		if (recarga != null )
		  { cargarContenido(recarga,div); }
		break;
   default: 
  	    var vec = datos.split('|');
	    a=vec.length;	
	    for (i=1;i < a; i++)
	    {
		 var vec2 = vec[i].split('=');
		 var elemento = document.getElementById(vec2[0]);
		 
		 switch (vec2[0]) 
        {
            case 'ud_loc':
		      	 var ud_loc =  vec2[1];
			     break;
	        case 'ub_loc':
		         var ub_loc =  vec2[1];
			     break;			
		}
		 if (elemento != null)
		  {
			elemento.value = vec2[1];
		  }
	    }
		
		var element = document.getElementById('par_loc')
        if(element != null)
		{
		var par_loc = element.value
		//alert('par:'+par_loc+'ud:'+ud_loc+'ub:'+ub_loc);
		cargarCombo(par_loc,ud_loc,ub_loc,'div_ud',1,1)
		cargarCombo(par_loc,ud_loc,ub_loc,'div_ub',2,1)
		//cargarCombo(cod_edo,cod_cda,cod_mun,'div_par',3,cod_par)
		}

		
		
  }//end swt
  
}//end fuction

function car(cadena) 
{
 var texto="";	
  for (var i=0; i < cadena.length; i++) 
  {
   if (cadena.charAt(i)!="\n")
   {
     texto = texto + cadena.charAt(i);
   }
  }
  return texto;
}



function blanquear_form() 
{
  for (var a=0; a < document.forms.length; a++) 
  {
  for (var i=0; i < document.forms[a].length; i++) 
   {
    if (document.forms[a].elements[i].type !== "button") 
	  {
      if (document.forms[a].elements[i].name != "opt" ) 
	     {  
		   document.forms[a].elements[i].value="";     
		 }
      }
   }
 }
}


function cambia_msj(id,destino)
{   
var val = document.getElementById(id);
var i   = val.value

var contenedor;   
var ajax;      
contenedor = document.getElementById(destino);
ajax = inst_exp(ajax);   
switch (i) 
  {
case 'C': 
		var  msj = "Ejemplo: 15520874";
		break;
case 'N': 
		var  msj = "Ejemplo: 2007-1515 ó 2007-K11"
		break;
case 'R': 
		var  msj = "Ejemplo: J-31157169-0  ó V-15520874"
		break;
case 'M': 
		var  msj = "Ejemplo: COOP,INV,BUHO. No Necesita Escribir el Nombre Completo."
		break;
default: 
       var  msj = ""
  }
  //MANDA LA RESPUESTA
  contenedor.innerHTML = msj
}

function msj_error(valor)
{
  var opt = document.getElementById('opt').value;
  switch (opt) 
  {
   case '1':
           switch (valor) 
           {
              case 0:
			        alert ("NO se pudo Guardar su Informacion");
					break;
			  case 1:
			        alert ("Su Informacion se Guardo Correctamente");
					break;
			  case 2:
			        alert ("Datos ya Existen o ya Declaro.");
					break;
			  case 3:
			        alert ("Patente no Valida, Revise.");
					break;
			  case 5:
			        alert ("Se Elimino Correctamente");
					break;	
			  case 6:
			        alert ("NO se puede, hay Datos incompletos");
					break;
			  case 30:
			        alert ("Su Informacion se Guardo Correctamente");
					break;		
			  default: 
                    alert ("Patente no Valida, Revise....");
	                break;
		   }
		   break; 
    case '2': 
	      switch (valor) 
           {
              case 0:
			        alert ("Hubo un Error al Tratar de Modificar, Revise.");
					break;
			  case 1:
			        alert ("Los Cambios Fueron Guardados");
					break;
			  case 2:
			        alert ("Patente Activa No se Puede Modificar.");
					break;
			  case 3:
			        alert ("Patente no ha Declarado");
					break;
			  case 4:
			        alert ("Patente no Pertenece al Usuario");
					break;
			  case 6:
			         alert ("NO se puede, hay Datos incompletos");
					break;			
			  default: 
                   alert ("Patente no Valida, Revise....");
	                break;
		   }
		   break;
	case '3': 
	      switch (valor) 
           {
              case 0:
			        alert ("Hubo un Error al Eliminar, Revise.");
					break;
			  case 1:
			        alert ("Se Eliminaron los Registros");
					break;
			  case 2:
			        alert ("Patente Activa No se Puede Eliminar.");
					break;
			  case 3:
			        alert ("Patente no ha Declarado");
					break;
			  default: 
                    alert ("Patente no Valida, Revise....");
	                break;
		   }
		  break; 
	case '4': 
	      switch (valor) 
           {
              case 0:
			        alert ("Hubo un Error al Buscar su Declaracion.");
					break;
			  case 1:
			        alert ("Ya Declaro");
					break;
			  case 3:
			        alert ("No se Encontraron Datos");
					break;
			  default: 
                    alert ("Patente no Valida, Revise....");
	                break;
		   }
		   break; 
	case '5': // Herrores de la opcion ACTIVAR DECLARACIONES
	      switch (valor) 
           {
              case 0:
			        alert ("Hubo un Error al Tratar de Activar, Revise.");
					break;
			  case 1:
			        alert ("Se Activo la Declaracion");
					break;
			  case 2:
			        alert ("Patente ya esta Activa.");
					break;
			  case 3:
			        alert ("Patente no ha Declarado");
					break;
			  case 4:
			        alert ("Hubo un error al actualizar el Status de la Declaración");
					break;					
			  case 5:
			        alert ("Hubo un error al generar el Nro de recibo");
					break;	
			  case 6:
			        alert ("Hubo un error al Asociar el Recibo a la Patente");
					break;		
			  case 7:
			        alert ("Hubo un error al Insertar el Recibo");
					break;	
			  case 8:
			        alert ("Hubo un error al generar el Nro de Multa");
					break;	
			  case 9:
			        alert ("Hubo un error al Insertar la Multa");
					break;
			  case 10:
			        alert ("Hubo un error al Insertar el Detalle de Multa en el Recibo");
					break;
			  case 11:
			        alert ("Hubo un error al generar el Nro Impuesto Complementario ");
					break;	
			  case 12:
			        alert ("Hubo un error al Guardar el Impuesto Complementario ");
					break;
			  case 13:
			        alert ("Hubo un error al Guardar el Detalle del Impuesto Complementario ");
					break;	
			  case 14:
			        alert ("Hubo un error al actualizar el Saldo en el Recibo");
					break;	
			  case 15:
			        alert ("Hubo un error al actualizar el Saldo en la Patente");
					break;	
			  case 16:
			        alert ("Patente Insolvente");
					break;					
			  default: 
                    alert ("Patente no Valida, Revise....");
	                break;
		   }
		   break; 
	case '6': 
	      switch (valor) 
           {
              case 0:
			        alert ("Hubo un Error al Tratar de Reversar, Revise.");
					break;
			  case 1:
			        alert ("Se Reverso la Declaracion");
					break;
			  case 2:
			        alert ("Patente No esta Activa");
					break;
			  case 3:
			        alert ("Patente no ha Declarado");
					break;
              case 4:
			        alert ("los Datos datos suministrados son incorrectos");
					break;
              case 5:
			        alert ("Usuario no existe, Debe Registrarse");
					break;					
			  default: 
                    alert ("Patente no Valida, Revise....");
	                break;
					
		   }
		  break;  
	default: 
       alert ("Valor nulo o Inconsitentes.");
	   break;
  }
  //foco('patente');
}

function deshabilita(){ 
   	document.getElementById('g1a').readOnly = true;
   	document.getElementById('g1b').readOnly = true;
   	document.getElementById('g2aa').readOnly = true;
   	document.getElementById('g2ab').readOnly = true;
    document.getElementById('g2ba').readOnly = true;
	document.getElementById('g2bb').readOnly = true;
	document.getElementById('g3a').readOnly = true;
	document.getElementById('g3b').readOnly = true;
 	document.getElementById('g4').readOnly = true;
	document.getElementById('observacion').readOnly = true;
   } 

   function habilita(){ 
   	document.getElementById('g1a').readOnly = false;
   	document.getElementById('g1b').readOnly = false;
   	document.getElementById('g2aa').readOnly = false; 
   	document.getElementById('g2ab').readOnly= false;
    document.getElementById('g2ba').readOnly = false;
	document.getElementById('g2bb').readOnly= false;
	document.getElementById('g3a').readOnly = false;
	document.getElementById('g3b').readOnly = false;
 	document.getElementById('g4').readOnly = false;
	document.getElementById('observacion').readOnly = false;
   } 







function openw(pagina)
{
	var url=pagina;
window.open(url,null,"height=250,width=350,status=yes,toolbar=no,menubar=no,location=no,left=200,top=300");
}

function openpag(pagina)
{
var url=pagina;
window.open(url,null,"width=770,height=600,top=100,left=100,resizable=no,scrollbars=yes,menubar=no,toolbar=no,status=no,location=no");
}


function set_menu(val,id)
{

 var element = document.getElementById(id);
 var opt = document.getElementById('opt');
 opt.value = (val);
 foco('patente');
}


function A(e,t)
{
var k=null;
(e.keyCode) ? k=e.keyCode : k=e.which;
if(k==13) (!t) ? B() : t.focus();
}

function B()
{
document.forms[0].submit();
return true;
}

function foco(id)
{
var element = document.getElementById(id);
    element.focus();
}

function enter(e,id)
{
var k=null;
(e.keyCode) ? k=e.keyCode : k=e.which;
if(k==13)
  {
	   //  var element = document.getElementById(id);
	   foco(id);
	  //    element.focus();  //AQUI
  }
}

function mayus(id)
{ 
  var element = document.getElementById(id).value;
  var m = toUpperCase(element);
  element.value=m;
}


function dos_dec(numero)
{
  var num = numero.toFixed(2);
  return num;
}

function mnu_set(val,id,id2)
{
var element = document.getElementById(id);
    element.value=val;
var element = document.getElementById(id2);
    element.focus();
}


function calcula(id,des,alicuota,ut)
{
	
var opt = document.getElementById('opt').value;

if (opt != 4)
{	
	
valida_num(id);

var bruto   = eval(document.getElementById(id).value);
var destino = document.getElementById(des);
if (bruto == null){ bruto=0; }
var tot_imp =(bruto * alicuota);
var uni_tri = 55;
var mto_min =(ut * uni_tri);
if ((tot_imp < mto_min)&&(tot_imp != 0))
    {  
     tot_imp = mto_min;   
    }

destino.value=dos_dec(tot_imp);

var imp_05  = 0;
var i1a     = eval(document.getElementById('i1a').value);
var i1b     = eval(document.getElementById('i1b').value);
var i2aa    = eval(document.getElementById('i2aa').value);  
var i2ab    = eval(document.getElementById('i2ab').value);
var i2ba    = eval(document.getElementById('i2ba').value);
var i2bb    = eval(document.getElementById('i2bb').value);
var i3a     = eval(document.getElementById('i3a').value);  
var i3b     = eval(document.getElementById('i3b').value);
var i4      = eval(document.getElementById('i4').value);
var imp_anti= eval(document.getElementById('imp_anti').value);  
var imp_05  = eval(document.getElementById('imp_05').value);  
var suma    = 0;
var imp_06  = 0;
var imp_men = 0;



if (i1a  == null){ i1a  = 0; }
if (i1b  == null){ i1b  = 0; }
if (i2aa == null){ i2aa = 0; }
if (i2ab == null){ i2ab = 0; }
if (i2ba == null){ i2ba = 0; }
if (i2bb == null){ i2bb = 0; }
if (i3a  == null){ i3a  = 0; }
if (i3b  == null){ i3b  = 0; }
if (i4   == null){ i4   = 0; }
if (imp_05  == null){ imp_05  = 0; }
if (imp_anti== null){ imp_anti= 0; }


suma     = i1a+i1b+i2aa+i2ab+i2ba+i2bb+i3a+i3b+i4;
imp_06   = dos_dec(suma);
imp_men  = imp_06/12;
imp_men  = dos_dec(imp_men);
imp_comp = (imp_06 - imp_05);
imp_comp = dos_dec(imp_comp);

//if (imp_comp < 0){ imp_comp = 0; }
  
document.getElementById('imp_06').value  =imp_06;
//document.getElementById('imp_05').value  =imp_05;
document.getElementById('imp_comp').value=imp_comp;  
document.getElementById('imp_men').value =imp_men;
 }
}

function calcula2(ut)
{
var imp_anti= eval(document.getElementById('imp_anti').value);  
var imp_05  = eval(document.getElementById('imp_05').value);  
if (imp_05  == null){ imp_05  = 0; }
if (imp_anti== null){ imp_anti= 0; }

var uni_tri = 55;
var tot_imp = (ut * uni_tri);

var imp_06  = dos_dec(tot_imp);
var imp_men = imp_06/12;
    imp_men = dos_dec(imp_men);
var imp_comp = (imp_06 - imp_05);
    imp_comp = dos_dec(imp_comp);
	
//if (imp_comp < 0){ imp_comp = 0; }
  
document.getElementById('imp_06').value  =imp_06;
document.getElementById('imp_05').value  =imp_05;
document.getElementById('imp_comp').value=imp_comp;  
document.getElementById('imp_men').value =imp_men;

}

function valida_num(id) 
{

  var element = document.getElementById(id);
  var checkOK = "0123456789.";
  var checkStr = element.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0; i < checkStr.length; i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0; j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length) 
	{
      allValid = false;
      break;
    }
    allNum += ch;
  }
  
  if (!allValid) 
  {
	var b="El Valor Invalido:"+checkStr;
    alert(b);
    element.value="";
	element.focus();
  }
}

function very_recibo(id) //verifica si el recibo existe
{
  var recibo = id.value;
  if (recibo == null)
   {
	 //mostrar_rec(0);
     //var url='php/declaracion/regi_usuario.php?opt=4&nro_fac='+recibo;
     //ObtenerPorGETDatosHTML_2(mostrar_rec,url);
   }
}

function mostrar_rec(resp)
{
  var div = document.getElementById('very_rec');
	if (resp==0)//no lo dejo pasar
	{
        div.innerHTML = "Recibo de Pago no Existe";
	    foco('nro_fac');
    }
    else
    {
	   div.innerHTML = ""; 
    }
}

function very_pat(id) //verifica si la patente existe
{
  var patente = id.value;
  if (patente=="")//no lo dejo pasar
	{
		 //mostrar_pat(0);
         //var url='php/declaracion/regi_usuario.php?opt=2&patente='+patente;
         //ObtenerPorGETDatosHTML_2(mostrar_pat,url);
	}
}

function mostrar_pat(resp)
{
  var div = document.getElementById('very_pat');
	if (resp==0)//no lo dejo pasar
	{
        div.innerHTML = "Patente no Existe";
	    foco('patente');
    }
    else
    {
	   div.innerHTML = ""; 
    }
}


function registrar()
{
  var url='php/declaracion/regi_usuario.php?opt=5';
  armar_url2(very_reg,url);
}

function very_reg(resp)
{
    var x =eval(resp);
    switch (x) 
           {
              case 0:
			        alert ("Sus datos no pueden ser Registrados,\n verifique su recibo y patente");
					break;
			  case 1:
			        alert ("Su Registro Fue Satisfactorio");
					break;
			  case 2:
			        alert ("No se Puede Registrar, Patente ya fue Registrada");
					break;
   			  case 3:
			        alert ("Recibo no Pertenece a la Patente, Verifique sus Datos");
					break;	
			  case 4:
			        alert ("Se Actualizaron sus Datos");
					break;			
		   }
}

function men_recup(resp)
{
    var x =eval(resp);
    switch (x) 
           {
              case 0:
			        alert ("Revise sus Datos, Son Incorrectos");
					break;
			  case 1:
			        alert ("Usuario no Registrado");
					break;
			  case 2:
			        alert ("Transacción Fallida");
					break;
			  case 3:
			        alert ("Cambio de Clave Satisfactorio");
					break;					
		   }
}





function validar_form() 
{
		
  var opt = document.getElementById('opt').value;
  var patente = document.getElementById('patente').value;
  var denomin = document.getElementById('denomin').value;
  var loc_obs = document.getElementById('loc_obs').value;
  var email = document.getElementById('email').value;
  var rif = document.getElementById('rif').value;  

  if(typeof patente =='undefined'){ patente = ""; }  
  if(typeof denomin =='undefined'){ denomin = ""; }
  if(typeof loc_obs =='undefined'){ loc_obs = ""; }
  if(typeof email =='undefined'){ email = ""; }
  if(typeof rif =='undefined'){ rif = ""; }  

if (!validarEmail(email))
{
   alert("Formato Email es Incorrecto, Por Favor Verifique.")
   return;
}

  if ((patente == "" )|| (denomin == "") || (loc_obs == "")|| (email == "")|| (rif == ""))
  {
   alert("Datos Inconsistente Por Favor Verifique.") 
  } 
  else
  {		
	  if (opt != 4)
   	  {	
	  	var imp_men = eval(document.getElementById('imp_men').value);
		  if(typeof imp_men =='undefined'){ imp_men = 0; }  
		  if (imp_men == 0)
		  {
		    alert("No Declaro por Ningun Grupo se Aplicara el Minimo")
			calcula2(10);
		  }  
		  if (confirm('¿Estas seguro de Realizar esta Transaccion?'))
		  {
			armar_url('php/declaracion/sql.php',1,'conten',1)//(url,modo,destino,llamado)
			//blanquear_form();//blanquea el formulario
			//foco('patente');
	      }
	   }
   }  
}



function activar() 
{
		
  var opt = document.getElementById('opt').value;
  var patente = document.getElementById('patente').value;

  if(typeof patente =='undefined'){ patente = ""; }  
  if(typeof denomin =='undefined'){ denomin = ""; }

  if (patente == "")
  {
   alert("Datos Inconsistente Por Favor Verifique.") 
  } 
 else
  {
    if (confirm('¿Desea Activar esta Declaracion'))
	   {
		url ='php/declaracion/sql.php?'+'patente='+patente+'&opt='+opt;
        obtenerdatos(url,1,'conte');
	   }
  }
}


function very_user(user) 
{
  if(typeof user =='undefined'){ user = ""; }
  if(user !="")
  {
	 url ='php/declaracion/regi_usuario.php?opt=1&srUsuario='+user;
     //obtenerdatos(url,0,'very_user');
     ObtenerPorGETDatosHTML_2(mostrar,url);
  }
}

function mostrar(resp) 
{
  var div = document.getElementById('very_user');	
  if (resp == 0)
  {
	div.innerHTML = "Usuario ya Existe";
	//alert("Usuario ya Existe");
	foco('login');
  }
  else
  {
	div.innerHTML = ""; 
  }

}

function very_pass(valor,id,des) 
{
  var element = document.getElementById(id).value;
  var contenedor = document.getElementById(des);
  if(typeof valor =='undefined'){ valor = ""; }
  if(typeof element =='undefined'){ element = ""; }
  if(valor !="")
  {
	 alert(element);
	 alert(valor);
	 if (element == valor)
	 {
		contenedor.innerHTML = "";
	 }
	 {
		var msj = "Las Contraseñas no Coinciden";
		contenedor.innerHTML = msj;
		foco(id);
	 }
  }
}

function limpiar(cadena) 
{
 var texto="";	
  for (var i=0; i < cadena.length; i++) 
  {
   if (cadena.charAt(i)!=" ")
   {
     texto = texto + cadena.charAt(i);
   }
  }
  return texto;
}






function reporte() 
{
		
  var opt = eval(document.getElementById('opt').value);
  var patente = document.getElementById('patente').value;
  if(typeof patente =='undefined'){ patente = ""; }  

  if ((opt == 1)||(opt == 2))
     {
       armar_url('php/declaracion/reportes/planilla_declara.php',1,'conten',0)//(url,modo,destino,llamado)
     }

}

function DelS()
{
  Cookie ('user');
  Cookie ('nvl');
  Cookie ('lic');
}

function Cookie (name) 
{
	var value = "";
	document.cookie=name+'=""'
	//document.cookie = name + "=" + escape(value) + "; expires=Fri, 31 Dec 2099 23:59:59 GMT;";
	//JavaScript : alert(document.cookie);
}


function aleatorio(inferior,superior){ 
numPosibilidades = superior - inferior 
aleat = Math.random() * numPosibilidades 
aleat = Math.round(aleat) 
return parseInt(inferior) + aleat 
} 


function Clear(id,tip)
{
//tip: tipo de elemtento false para div el resto para elementos
//id es el id del elemento
element = document.getElementById(id);
var ajax;     
var valor = " ";
ajax = inst_exp(ajax); 
var N = Que_Navegador();

  if (N == true)
	{ //internet Explorer
	   if (tip == true)
		{
		   element.value = "";
		}
	   else
		{
		   element.innerHTML = "";
		}
	}
  else
   {// Nescape o firefox
   	   if (tip == true)
		{
		   element.value = null;
		}
	   else
		{
		   element.innerHTML = null;
		}
   }
}

function Que_Navegador()
{
var navegador = navigator.appName
if (navegador == "Microsoft Internet Explorer")
	{
    	var navi=1;
	}
else
	{
	   var navi=0;
	}
	return navi;
}


function valor(cant) {
   	var res ="";
          	var coma = ".";
           	var punto = ".";
	var n = 1;
	var y = 0;

	y = cant.length;
        	y = y -1;

	for (i = y; i >= 0; i--) {
	   if (cant.charAt(i) == coma.charAt(0)) { 
                  coma = ",";
                  res = coma + res;
           	   } else if (coma.charAt(0) == punto.charAt(0))
                     res = cant.charAt(i) + res;
                           else if (n == 3) {
                    		if(i != 0) 
                    		    res = "." + cant.charAt(i) + res;
			else 
                    		    res = cant.charAt(i) + res;
	                n = 1;
                   } else {
            	   n = n + 1;
                    	   res = cant.charAt(i) + res;
	          }
	    }
	   document.write(res);
}


//MENSAJE EN LA BARRA DE ESTADO
var Nav = Que_Navegador();

if (Nav == true)
{//internet explorer

var speed = 100 
var pause = 3000
var timerID = null
var bannerRunning = false
var ar = new Array()
ar[0] = ">>>> Almacaroni - Servicios al Contribuyente <<<<"
ar[1] = " Consultas tus Estados de Deudas, ....."
ar[2] = "..... Imprime Lo que necesitas saber para obtener tu Licencia y Patente, ....."
ar[3] = "..... No olvides de visitar http://www.almacaroni.gob.ve, ....."
ar[4] = "..... Pronto Declaracion de Impuestos En-Linea, ....."
ar[5] = "..... Hacienda - Convirtiendo tus impuestos en Obras y Recursos ....."
ar[6] = "..... Servicios al Contribuyente la forma mas facil de conocer tus impuesto ....."
var currentMessage = 0
var offset = 0

function stopBanner() 
{
	if (bannerRunning)
		clearTimeout(timerID)
		bannerRunning = false
}

function startBanner() 
{
	stopBanner()
	showBanner()
}


function showBanner() 
{
	var text = ar[currentMessage]

 if (offset < text.length) 
  {
	if (text.charAt(offset) == " ")
	offset++ 
	var partialMessage = text.substring(0, offset + 1) 
	window.status = partialMessage
	offset++ // IE sometimes has trouble with "++offset"
	timerID = setTimeout("showBanner()", speed)
	bannerRunning = true
  } 
 else 
  {
	offset = 0
	currentMessage++
	if (currentMessage == ar.length)
		currentMessage = 0
		timerID = setTimeout("showBanner()", pause)
		bannerRunning = true
  }
}
startBanner();

}

else
{//FIREFOX y nescape
   
	window.status='Almacaroni...';
	//return true;
}

function cancelar(cual)
{
    document.getElementById(cual).className = "invisible";
}





//*************************************funcion valida fecha********************************
function esDigito(sChr){
var sCod = sChr.charCodeAt(0);
return ((sCod > 47) && (sCod < 58));
}

function valSep(oTxt){
var bOk = false;
bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));
bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
return bOk;
}

function finMes(oTxt){
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
var nRes = 0;
switch (nMes){
case 1: nRes = 31; break;
case 2: nRes = 29; break;
case 3: nRes = 31; break;
case 4: nRes = 30; break;
case 5: nRes = 31; break;
case 6: nRes = 30; break;
case 7: nRes = 31; break;
case 8: nRes = 31; break;
case 9: nRes = 30; break;
case 10: nRes = 31; break;
case 11: nRes = 30; break;
case 12: nRes = 31; break;
}
return nRes;
}

function valDia(oTxt){
var bOk = false;
var nDia = parseInt(oTxt.value.substr(0, 2), 10);
bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
return bOk;
}

function valMes(oTxt){
var bOk = false;
var nMes = parseInt(oTxt.value.substr(3, 2), 10);
bOk = bOk || ((nMes >= 1) && (nMes <= 12));
return bOk;
}

function valAno(oTxt){
var bOk = true;
var nAno = oTxt.value.substr(6);
bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
if (bOk){
for (var i = 0; i < nAno.length; i++){
bOk = bOk && esDigito(nAno.charAt(i));
}
}
return bOk;
}

function valFecha(oTxt){
var bOk = true;
if (oTxt.value != ""){
bOk = bOk && (valAno(oTxt));
bOk = bOk && (valMes(oTxt));
bOk = bOk && (valDia(oTxt));
bOk = bOk && (valSep(oTxt));
if (!bOk){
alert("Fecha inválida");
oTxt.value = "";
oTxt.focus();
}
}
}

function ocultar_ayuda(id)
{
 var div =document.getElementById(id);
 div.style["display"] = "none"; 
}

function mostrar_ayuda(id)
{
 var div =document.getElementById(id);
 div.style["display"] = "";
}


function solonumero(evt){
	
    evt = (evt) ? evt : event
	var key = (evt.which) ? evt.which : evt.keyCode;
	if (key > 47 && key < 58 || key == 8 || key == 13 || key == 39 || key == 37 || evt.keyCode == 46) 	{ return true;}
	else 
	{return false;}
	
}

function FechaManual(event,Valor,Fecha){

//Coloca El Slash Automaticamente Por El Usuario, Toma El Valor y el Campo de la Fecha
//Evalua en que posicion se encuantra el valor   y coloca el valor de la fecha automatica

 if(event.keyCode != 46 && event.keyCode != 8){
  
 var ValorFecha = document.getElementById(Fecha).value;
 var arrayDatos = ValorFecha.split('/');
  
   switch (ValorFecha.length){
     case 1:
         	 if(arrayDatos[0] > 3){
		       alert('Valor de Dia Invalido Dias No Reconocido')
		       document.getElementById(Fecha).value = '';
		     }
	 break;  
     case 2:
    	     if(arrayDatos[0] > 31){
		       alert('Valor de Dia Invalido Dias No Reconocido, Los Dias No Pueden Ser Mayor de 31 ')
		       document.getElementById(Fecha).value = '';
	         }else{
		       document.getElementById(Fecha).value = ValorFecha + '/'
		     }
	 break;
	 case 4:
		     if(arrayDatos[1] > 1){
				alert('Valor de Mes Invalido Mes No Reconocido, El Mes No Comienza con ' + arrayDatos[1])
   			   document.getElementById(Fecha).value = arrayDatos[0] + '/'
			 }
	 break;
	 case 5:
		      if(arrayDatos[1] > 12 || arrayDatos[1] < 0){
				alert('Valor de Mes Invalido Mes No Reconocido, El Mes No Puede Ser ' + arrayDatos[1])
				document.getElementById(Fecha).value = arrayDatos[0] + '/'
			  }else{
				document.getElementById(Fecha).value = ValorFecha + '/' 
			  }
	  break;
	}
 }
   
}

//fin funcion valida fecha

//Funcion ajax
function ObtenerPorGETDatosHTML_2(retorno, urlDatos) {
  var XMLHttpRequestObject = false;
  if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  }

  if (XMLHttpRequestObject) {
	  
	    XMLHttpRequestObject.open("GET", urlDatos);
	   XMLHttpRequestObject.onreadystatechange = function() {
      if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
        {
          var respGetHTML = XMLHttpRequestObject.responseText;
          retorno(respGetHTML);
          delete XMLHttpRequestObject;
          XMLHttpRequestObject = null;
        }
    }
    XMLHttpRequestObject.send(null);
  }
}


function del_grip(url,grip,div) //url:url a ejecutar,grip:que va a cargar,div:div que va a cargar
{
    var num = Math.random(); 
    var grip=grip + '?n=' + num;
    //document.getElementById('dani').value=url;
     
   if (confirm('¿Deseas Eliminar los Datos?'))
			 {
			 // cargarContenido(grip,div);
			  //alert(url+" "+grip);
			  ObtenerDatos2(mostrar_datos,url,grip,div) 
			  // ObtenerPorGETDatosHTML_2(nula,url);
			    
		     }
   
   
}

function nula(datos) //esto no hace nada solo para que no de error otras funciones
{
   //alert(datos);
}





///Fin Funcion Ajax


// Modificado por Almacaroni

// Variables Globales 
var swOK=0; 
var nEle=0; 
var sError=''; 

// VERIFICA EL FORMULARIO 
//=================================== 
function Verifica() { 
   var nTot=0; 
   var nPas=0; 
   var nTorna=0; 
   sError="Lista de errores: "+"\n"; 
   for (var j=0; j<12; j++) { 
     nEle=j; 

     // AVERIGUA LOS TIPOS 
     var sNom=document.forms['registro'].elements[j].name; 
     var sOne=sNom.substring(0,1); 
     var sTwo=sNom.substring(1,2); 
  

     // CORREO OBLIGATORIO 
     if (sOne=='e' && sTwo=='r') { 
       CaracterNoValid(document.forms['registro'].elements[j].value,'Er'); 
       nTot+=swOK; 
     } 
     else 
       if (sOne=='e' && document.forms['registro'].elements[nEle].value!='') { 
         CaracterNoValid(document.forms['registro'].elements[j].value,'Eo'); 
         nTot+=swOK; 
       } 
  

     // NUMERICO Y OBLIGATORIO else NUMERICO NO OBLIGATORIO PERO INFORMADO 
     if (sOne=='n' && sTwo=='r') { 
       CaracterNoValid(document.forms['registro'].elements[j].value,'Nr'); 
       nTot+=swOK; 
     } 
     else 
       if (sOne=='n' && document.forms['registro'].elements[nEle].value!='') { 
         CaracterNoValid(document.forms['registro'].elements[j].value,'No'); 
         nTot+=swOK; 
       } 

     // CADENA Y OBLIGATORIA 
     if (sOne=='s' && sTwo=='r') { 
       CaracterNoValid(document.forms['registro'].elements[j].value,'Sr'); 
       nTot+=swOK; 
     } 

     // LISTA DE ERRORES 
     if (nPas==0 && nTot>0) { 
       document.forms['registro'].elements[nEle].focus() 
       nPas=1 
     } 
   } 

   if (nTot>0) 
     alert(sError) 
   else 
     registrar();
} 

// ANALIZA CAMPO A CAMPO SI SON NUMERICOS 
//========================================= 
function CaracterNoValid(pCaracter,pType) { 
   swOK=0; 
  // E-MAIL OBLIGATORIO 
  if (pType=='Er') { 
     swOK=2 
     for (var i=0;i<pCaracter.length;i++) {
      var sByte=pCaracter.substring(i,i+1); 
     if (sByte=="@" || sByte==".") { 
         swOK=swOK-1; 
     } 
   } 
   if (swOK>0) 
     sError+="Campo "+document.forms['registro'].elements[nEle].name.substr(2)+" ha de ser valido y es obligatorio" +"\n"; 
   return; 
} 

   // NUMERICO OBLIGATORIO 
   if (pType=='Nr') { 
     swOK=0; 
     if (pCaracter=='') { 
       swOK=1 
       sError+="Campo "+document.forms['registro'].elements[nEle].name.substr(2)+" ha de ser numérico y es obligatorio" +"\n" 
       return 
     } 

     for (var i=0;i<pCaracter.length;i++) {
        var sByte=pCaracter.substring(i,i+1); 
       if (sByte<"0" || sByte>"9") { 
         sError+="Campo "+document.forms['registro'].elements[nEle].name.substr(2)+" ha de ser numérico y es obligatorio" +"\n" 
         swOK=1; 
         return; 
       }  
     } 
   } 

   // NUMERICO INFORMADO 
   if (pType=='No') {  
     swOK=0; 
     if (pCaracter=='') { 
       swOK=1 
       sError+="Campo "+document.forms['registro'].elements[nEle].name.substr(2)+" ha de ser numérico" +"\n" 
       return 
     } 
     for (var i=0;i<pCaracter.length;i++) {
        var sByte=pCaracter.substring(i,i+1); 
       if (sByte<"0" || sByte>"9") { 
         sError+="Campo "+document.forms['registro'].elements[nEle].name.substr(2)+" ha de ser numérico" +"\n" 
         swOK=1; 
         return; 
       }  
     } 
   } 

   // CADENA 
   if (pType=='Sr') {  
     if (pCaracter=='') { 
       sError+="Campo "+document.forms['registro'].elements[nEle].name.substr(2)+" es obligatorio"+"\n" 
       swOK=1; 
       return 
     } 
   } 
} 

function validarEmail(valor) 
{
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor))
  {
     return (true);       //La dirección de email es correcta
  }
  else
  {
     return (false);      //La dirección de email es incorrecta
  }
}


		function cambiar_formulario(opcion)
		{
			if(opcion)
			{
				document.getElementById('info_usuario').innerHTML = 'Contribuyente';
				document.getElementById('info_patente').innerHTML = 'Patente';
				document.getElementById('patente').value = '';
				var patente = document.getElementById('patente');
				patente.removeAttribute('disabled');
			}
			else
			{
				document.getElementById('info_usuario').innerHTML = 'Usuario';
				document.getElementById('info_patente').innerHTML = 'Rif Alcaldia';
				document.getElementById('patente').value = 'G-20000363-4';
				document.getElementById('patente').disabled = 'true';
			}
		}
		function validar_formulario()
		{
			var mensaje = '';
			var login = document.getElementById('login').value;
			var patente = document.getElementById('patente').value;
			var correo = document.getElementById('correo').value;
			var clave1 = document.getElementById('clave1').value;
			var clave2 = document.getElementById('clave2').value;

			var patron_login   = /^([a-z|A-Z]{5,})+$/;
			var patron_correo  = /^([a-zA-Z0-9_\.\-])+\@+[a-z|A-Z]+\.+([a-z|A-Z])+$/;
			var patron_patente = /^((([0-9]{4})+-+(((sl|SL)+[0-9])|[0-9]))|([0-9]))+$/;
			var patron_clave   = /^([a-z|A-Z|0-9]{5,})+$/;

			var sw_clave1 = false;
			if( clave1.search(patron_clave) == 0 )
				sw_clave1 = true;

			var sw_clave2 = false;
			if( clave2.search(patron_clave) == 0 )
				sw_clave2 = true;

			var sw_clave_igual = false;
			if(clave1 == clave2)
				sw_clave_igual = true;

			var sw_login = false;
			if( login.search(patron_login) == 0 )
				sw_login = true;

			var sw_patente = false;
			if( patente.search(patron_patente) == 0 || patente == 'G-20000363-4')
				sw_patente = true;

			var sw_correo = false;
			if( correo.search(patron_correo) == 0 )
				sw_correo = true;

			if( sw_clave1 && sw_clave2 && sw_clave_igual && sw_login && sw_patente && sw_correo )
			{
				valida();
			}
			else
			{
				mensaje += 'Error: Valores no validos. \n\n';

				if( !sw_login )
					mensaje += 'Login no valido: solo caracteres.\n\n';

				if( !sw_patente )
					mensaje += 'Patente no valida.\n\n';

				if( !sw_correo )
					mensaje += 'Correo no valido.\n\n';

				if( !sw_clave1 || !sw_clave2 )
					mensaje += 'Clave no valida: Minimo 5 digitos Numericos o Caracteres.\n\n';

				if( !sw_clave_igual )
					mensaje += 'Las claves deben ser iguales.\n\n';

				alert(mensaje);
			}
		}

		var READY_STATE_COMPLETE = 4;
		var peticion_http = null;
		function inicializa_xhr()
		{
			if(window.XMLHttpRequest) 
			{
				return new XMLHttpRequest();
			}
			else if(window.ActiveXObject) 
			{
				return new ActiveXObject("Microsoft.XMLHTTP");
			}
		}

		function crea_query_string()
		{
			var login   = document.getElementById("login").value;
			var patente = document.getElementById("patente").value;
			var correo  = document.getElementById("correo").value;
			var clave   = document.getElementById("clave1").value;

			return "login="+encodeURIComponent(login)+"&patente="+encodeURIComponent(patente)+"&correo="+encodeURIComponent(correo)+"&clave="+encodeURIComponent(clave)+"&nocache=" + Math.random();
		}

		function valida() 
		{
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				peticion_http.onreadystatechange = procesaRespuesta;
				//peticion_http.open("POST", "http://localhost/prueba_clases/s_recuperar_clave.php", true);
				peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/declaracion/s_recuperar_clave.php", true);
				//peticion_http.open("POST", "http://128.1.12.5/gestion1/s_recuperar_clave.php", true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				var query_string = crea_query_string();
				peticion_http.send(query_string);
			}
		}
		function procesaRespuesta() 
		{
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					//document.getElementById("respuesta").innerHTML = peticion_http.responseText;
					alert(peticion_http.responseText);
				}
			}
		}

		function validar_formulario2()
		{
			var mensaje = '';
			var num_rif = document.getElementById('num_rif').value;
			var patente = document.getElementById('patente').value;
			var correo  = document.getElementById('correo').value;
			var num_rep = document.getElementById('num_rep').value;

			var patron_rif   = /^([a-z|A-Z]{1})+-+([0-9]{8})+-+([0-9]{1})+$/;
			var patron_correo  = /^([a-zA-Z0-9_\.\-])+\@+[a-z|A-Z]+\.+([a-z|A-Z|\.])+$/;
			var patron_patente = /^((([0-9]{4})+-+((([a-z|A-Z]{2})+[0-9])|[0-9]))|([0-9]))+$/;
			var patron_rep   = /^([0-9]{5,})+$/;

			var sw_patron_rif = false;
			if( num_rif.search(patron_rif) == 0 )
				sw_patron_rif = true;

			var sw_patron_rep = false;
			if( num_rep.search(patron_rep) == 0 )
				sw_patron_rep = true;

			var sw_patente = false;
			if( patente.search(patron_patente) == 0 )
				sw_patente = true;

			var sw_correo = false;
			if( correo.search(patron_correo) == 0 )
				sw_correo = true;

			if( sw_patron_rif && sw_patron_rep && sw_patente && sw_correo )
			{
				valida2();
			}
			else
			{
				mensaje += 'Error: Valores no validos. \n\n';

				if( !sw_patron_rif )
					mensaje += 'Rif no valido. \n\n';

				if( !sw_patente )
					mensaje += 'Patente no valida.\n\n';

				if( !sw_correo )
					mensaje += 'Correo no valido.\n\n';

				if( !sw_patron_rep )
					mensaje += 'Cedula Rep Legal no valida.\n\n';

				alert(mensaje);
			}
		}


		function crea_query_string2()
		{
			var num_rif = document.getElementById('num_rif').value;
			var patente = document.getElementById('patente').value;
			var correo  = document.getElementById('correo').value;
			var num_rep = document.getElementById('num_rep').value;

			return "num_rif="+encodeURIComponent(num_rif)+"&patente="+encodeURIComponent(patente)+"&correo="+encodeURIComponent(correo)+"&num_rep="+encodeURIComponent(num_rep)+"&nocache=" + Math.random();
		}

		function valida2()
		{
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				peticion_http.onreadystatechange = procesaRespuesta2;
				//peticion_http.open("POST", "http://localhost/gestion1/s_recuperar_usuario.php", true);
				//peticion_http.open("POST", "http://128.1.12.5/gestion1/s_recuperar_usuario.php", true);
				peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/declaracion/s_recuperar_usuario.php", true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				var query_string = crea_query_string2();
				peticion_http.send(query_string);
			}
		}
		function procesaRespuesta2()
		{
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					alert(peticion_http.responseText);
				}
			}
		}


		function validar_formulario3()
		{
			var mensaje = '';
			var patente = document.getElementById('patente').value;

			var patron_patente = /^((([0-9]{4})+-+((([a-z|A-Z]{2})+[0-9])|[0-9]))|([0-9]))+$/;

			var sw_patente = false;
			if( patente.search(patron_patente) == 0 || patente == 'G-20000363-4')
				sw_patente = true;

			if( sw_patente )
			{
				valida_3();
			}
			else
			{
				mensaje += 'Error: Valores no validos. \n\n';

				if( !sw_patente )
					mensaje += 'Patente no valida.\n\n';

				alert(mensaje);
			}
		}

		function crea_query_string_3()
		{
			var patente = document.getElementById("patente").value;
			return "patente="+encodeURIComponent(patente)+"&nocache=" + Math.random();
		}

		function crea_query_string_patente()
		{
			var patente = document.getElementById("patente").value;
			var estatus_agente = document.getElementById("estatus_agente").value;
			var estatus_retencion = document.getElementById("estatus_retencion").value;

			return "patente="+encodeURIComponent(patente)+"&estatus_agente="+encodeURIComponent(estatus_agente)+"&estatus_retencion="+encodeURIComponent(estatus_retencion)+"&nocache=" + Math.random();
		}

		function valida_3() 
		{
			//crea el objeto ajax
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				peticion_http.onreadystatechange = procesaRespuesta_3;
				peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/declaracion/s_designar_agente.php", true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				var query_string = crea_query_string_3();
				peticion_http.send(query_string);
			}
		}
		function procesaRespuesta_3() 
		{
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					document.getElementById("detalle_patente").innerHTML = peticion_http.responseText;
				}
			}
		}
		function actualizar_agente() 
		{
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				peticion_http.onreadystatechange = procesaRespuesta_patente_3;
				peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/declaracion/s_designar_agente_actualizar.php", true);
				//peticion_http.open("POST", "http://128.1.12.5/gestion1/s_designar_agente_actualizar.php", true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				var query_string = crea_query_string_patente();
				peticion_http.send(query_string);
			}
		}
		function procesaRespuesta_patente_3() 
		{
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					alert(peticion_http.responseText);
				}
			}
		}

		function validar_formulario4()
		{
			if( document.getElementById('codigo').value != '')
			{
				valida_4();
			}
			else
			{
				mensaje += 'Error: Valores no validos. \n\n';
				mensaje += 'Codigo de declaracion no valido.\n\n';
				alert(mensaje);
			}
		}

		function crea_query_string_4()
		{
			var codigo = document.getElementById("codigo").value;
			return "codigo="+encodeURIComponent(codigo)+"&nocache=" + Math.random();
		}

		function valida_4()
		{
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				peticion_http.onreadystatechange = procesaRespuesta_4;
				//peticion_http.open("POST", "http://localhost/prueba_clases/s_recuperar_clave.php", true);
				//peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/declaracion/s_recuperar_clave.php", true);
				peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/declaracion/s_reversar_declaracion.php", true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				var query_string = crea_query_string_4();
				peticion_http.send(query_string);
			}
		}
		function procesaRespuesta_4() 
		{
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					document.getElementById("detalle_declaracion").innerHTML = peticion_http.responseText;
				}
			}
		}
		function crea_query_string_codigo4()
		{
			var codigo = document.getElementById("cod_ret").value;
			var sw = 0;
			if(document.getElementById("cod_ret").checked)
				sw = 1;
			
			return "codigo="+encodeURIComponent(codigo)+"&sw="+sw+"&nocache=" + Math.random();
		}
		function actualizar_retencion()
		{
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				peticion_http.onreadystatechange = procesaRespuesta_codigo_4;
				//peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/declaracion/s_recuperar_clave.php", true);
				peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/declaracion/s_reversar_declaracion_actualizar.php", true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				var query_string = crea_query_string_codigo4();
				peticion_http.send(query_string);
			}
		}
		function procesaRespuesta_codigo_4() 
		{
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					alert(peticion_http.responseText);
					validar_formulario4();
				}
			}
		}
		
//*******opc consultar 

function validar_agente(){
		
	var mensaje='';
	var opc = document.getElementById('catego3').value;
	var catego = document.getElementById('catego').value;
	
	var cedula = document.getElementById('cedula').value;
	var sw_agent=true;
	var cedula_num = /\d{7}/
	
		if(!cedula_num.test(cedula)){
			//alert('Los Datos Ingresados no son correctos');
			sw_agent=false;
		}
		if(sw_agent)
			{
				
				if(opc==1)
				{
					//alert('!!!...OPCION EN MANTENIMIENTO DISCULPEN LAS MOLESTIAS..!!!');
					cargarContenido('php/agentes/iframe1.php?cedula='+cedula+'&catego='+catego,'contenedor');
					
					
				}
				if(opc==2)
				{
					agente_modificar();
					//cargarContenido('php/agentes/iframe2.php?cedula='+cedula,'contenedor');
					//"php/agentes/consultar.php?patente="+patente+"&cedula="+cedula;
				}  
				if(opc==3)
				{
					agente_1();
				}
			}
		else 
			{	
				mensaje += 'Error: Valores no validos. \n\n';
				alert(mensaje);
			}
		
}
function envio_ced()
		{
			//alert("voy por envio");
			var cedula = document.getElementById("cedula").value;
			return "cedula="+encodeURIComponent(cedula)+"&nocache=" + Math.random();
		}

function agente_1() 
		{
			//crea el objeto ajax
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				//alert("voy por agente_1");
				peticion_http.onreadystatechange = procesarAgente;
				peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/agentes/consulta_patente.php", true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				var query_string = envio_ced();
				peticion_http.send(query_string);
			}
		}
		
function procesarAgente() 
		{
			
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					document.getElementById("consulta").innerHTML = peticion_http.responseText;
					//alert(peticion_http.responseText);
				}
			}
		}

function seleccionar(patente,cedula){
	
	//alert(patente);
	//alert(cedula);
    var pagina = "php/agentes/consultar.php?patente="+patente+"&cedula="+cedula;
    window.open(pagina,"ventana1","width=650,height=600,scrollbars=yes,");
	
	
  }
  
  
//**************************************************opc incluir		



function agente_incluir(){
	
	
}
	




// ********************************opc modificar	


function envio_ced2()
		{
			//alert("voy por envio");
			var cedula = document.getElementById("cedula").value;
			//alert(cedula);
			return "cedula="+encodeURIComponent(cedula)+"&nocache=" + Math.random();
		}
		
			
function agente_modificar(){
	
		//alert('!!!...OPCION EN MANTENIMIENTO DISCULPEN LAS MOLESTIAS..!!!');
		//crea el objeto ajax
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				//alert("voy por agente_1");
				peticion_http.onreadystatechange = procesarAgenteM;
				peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/agentes/consulta_modificar.php", true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				var query_string = envio_ced2();
				peticion_http.send(query_string);
			}

	}
	
function procesarAgenteM() 
		{
			//alert("voy por procesar");
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					document.getElementById("modifi").innerHTML = peticion_http.responseText;
					//alert(peticion_http.responseText);
				}
			}
		}

function seleccionar2(patente,cedula){
	
	cargarContenido('php/agentes/iframe2.php?cedula='+cedula+'&patente='+patente,'contenedor');
  } 

/* providencia*/
function validar_providencia(){
		
	var mensaje='';
	var opt = document.getElementById('contenido').value;
	//alert(opt);
	var patente = document.getElementById('patente').value;
	var num_liq = document.getElementById('num_liq').value;
	
	if(opt==1)
	{
		//alert("entro a opt1");
		cargarContenido('php/agentes/iframe4.php?opt=2&patente='+patente+'&num_liq='+num_liq,'contenedor');
	}
	if(opt==2)
	{
		consultar_providencia();
	}
	if (opt==3)
	{
		anula_provi();
	}
   }
   
   function envio_liquidacion()
		{
			//alert("voy por envio_liquidacion");
			
			//alert(patente);
			var patente = 0;
			if(document.getElementById("patente").value != '')
			{
			    patente = document.getElementById("patente").value;
			}
			var num_liq = 0;
			if(document.getElementById("num_liq").value != '')
			{	
				num_liq = document.getElementById("num_liq").value;
			}	
			return "num_liq="+encodeURIComponent(num_liq)+"&patente="+encodeURIComponent(patente);
		}

    function consultar_providencia() 
		{
			//crea el objeto ajax
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				//alert("voy por consultar_providencia");
				peticion_http.onreadystatechange = procesarProvidencia;
				peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/agentes/consulta_provi.php", true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				var query_string = envio_liquidacion();
				peticion_http.send(query_string);
			}
		}
		
	function procesarProvidencia() 
		{
			
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					document.getElementById("consulta").innerHTML = peticion_http.responseText;
					//alert(peticion_http.responseText);
				}
			}
		}

	function envio_anulacion_providencia()
	{
		//alert("voy por envio_providencia");
		
		var patente = 0;
		if(document.getElementById("patente").value != '')
		{
		    patente = document.getElementById("patente").value;
		}
		var num_liq = 0;
		if(document.getElementById("num_liq").value != '')
		{	
			num_liq = document.getElementById("num_liq").value;
		}
		//alert(patente);
		//alert(num_liq);	
		//alert("num_liq="+encodeURIComponent(num_liq)+"&patente="+encodeURIComponent(patente)+"&nocache=" + Math.random());
		return "num_liq="+encodeURIComponent(num_liq)+"&patente="+encodeURIComponent(patente)+"&nocache=" + Math.random();
	}

       function anula_provi() 
	{
		peticion_http = inicializa_xhr();
		if(peticion_http) 
		{
		  //alert("voy por anula_provi");
		  peticion_http.onreadystatechange = procesarProvidencia2;
		  peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/agentes/anular_providencia.php", true);
		  peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		  var query_string = envio_anulacion_providencia();
		  peticion_http.send(query_string);
		}
	}
	
	function procesarProvidencia2() 
		{
			
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					document.getElementById("anula").innerHTML = peticion_http.responseText;
					//alert(peticion_http.responseText);
				}
			}
		}

	function abrir(direccion,pantallacompleta,herramientas,direcciones,estado,barramenu,barrascroll,cambiatamano,ancho,alto,izquierda,arriba,sustituir){
    var opciones="fullscreen=" + pantallacompleta +
	         ",toolbar=" + herramientas +
			 ",location=" + direcciones +
			 ",status=" + estado +
			 ",menubar=" + barramenu +
			 ",scrollbars=" + barrascroll +
			 ",resizable=" + cambiatamano +
			 ",width=" + ancho +
			 ",height=" + alto +
			 ",left=" + izquierda +
			 ",top=" + arriba;
		var ventana = window.open(direccion,"venta",opciones,sustituir);
  }
  function abrir2(direccion,pantallacompleta,herramientas,direcciones,estado,barramenu,barrascroll,cambiatamano,ancho,alto,izquierda,arriba,sustituir){
    var opciones="fullscreen=" + pantallacompleta +
	         ",toolbar=" + herramientas +
			 ",location=" + direcciones +
			 ",status=" + estado +
			 ",menubar=" + barramenu +
			 ",scrollbars=" + barrascroll +
			 ",resizable=" + cambiatamano +
			 ",width=" + ancho +
			 ",height=" + alto +
			 ",left=" + izquierda +
			 ",top=" + arriba;
		var ventanas = window.open(direccion,"ventana",opciones,sustituir);
  }


	function eliminar_providencia(num_liq, estado) 
	{
		peticion_http = inicializa_xhr();
		if(peticion_http) 
		{
		  //alert("voy por consultar_retencion");
		  peticion_http.onreadystatechange = procesarEliminarPro;
		  peticion_http.open("POST", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/agentes/anular_providencia2.php", true);
		  peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		  var query_string = envio_eliminar_providencia(num_liq, estado);
		  peticion_http.send(query_string);
		}
	}
	
	function procesarEliminarPro() 
	{
		if(peticion_http.readyState == READY_STATE_COMPLETE) 
		{
			if(peticion_http.status == 200) 
			{
				document.getElementById("anula2").innerHTML = peticion_http.responseText;
				//alert(peticion_http.responseText);
			}
		}
	}
	
	function prueba(num_liq, estado)
	{
	 	//alert(num_liq);
	 	//alert(estado);
		return "num_liq="+encodeURIComponent(num_liq)+"&estado="+encodeURIComponent(estado)+"&nocache=" + Math.random();
	}
	function envio_eliminar_providencia(num_liq, estado)
	{
		//alert(estado);
		//alert(num_liq);	
		return "num_liq="+encodeURIComponent(num_liq)+"&estado="+encodeURIComponent(estado)+"&nocache=" + Math.random();
	}	

	function mensaje8()
	{alert('Registro anulado Exitosamente');
        //  blanquear_form();
	}
	function mensaje9()
	{alert('Error al anular los datos');
	}
/* fin providencia*/
/*eliminar foraneas*/


		function valida_del_foranea(nro_rif) 
		{
			peticion_http = inicializa_xhr();
			if(peticion_http) 
			{
				peticion_http.onreadystatechange = procesaRespuesta_del_foranea;
				peticion_http.open("GET", "http://intranet.alsobocaroni.gob.ve/alcaldia/php/agentes/mant_foraneos.php?opt=3&nro_rif="+nro_rif, true);
				peticion_http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				//var query_string = crea_query_string_del_foranea();
				peticion_http.send();
			}
		}
		function procesaRespuesta_del_foranea() 
		{
			if(peticion_http.readyState == READY_STATE_COMPLETE) 
			{
				if(peticion_http.status == 200) 
				{
					alert(peticion_http.responseText);
					cargarContenido('php/agentes/frm_foraneos.php?opt=1','contenedor');
				}
			}
		}

/* enviar formulario agentes de retencion*/
function enviar_form_agentes_sin_declarar()
{
	var ruta_original = document.getElementById('form_agentes_sin_declarar').action;
	var url = '?year='+document.getElementById('year').value+'&mes='+document.getElementById('mes').value;
	document.getElementById('form_agentes_sin_declarar').action='php/agentes/agentes_sin_declarar_excel.php'+url;
	document.getElementById('form_agentes_sin_declarar').submit();	
	document.getElementById('form_agentes_sin_declarar').action = ruta_original;
}

function prueba(num_liq, estado)
{
	alert(num_liq);
	alert(estado);
}