function ir(max,pagina,uidExcluido){
//alert("hola");
tx_ilztodoterrenovisor_pi1getPagina(max,pagina,uidExcluido);
}


 function pestana(que,num){
    ver(que,num);
    aleta('a'+que,num);
  }
  function aleta(que,num){
    var nomb = nombId(que,num);
    ok=true;
    i=1;
    while(ok){
      var tmp = nombId(que,i);
      try{
        document.getElementById(tmp).className="cajaPaso";
      }catch(e){
        ok=false;
      }
      i++;
    }
    document.getElementById(nomb).className="cajaPasoOpen";
  }
  function ver(que,num){
    var nomb = nombId(que,num);
    ok=true;
    i=1;
    while(ok){
      var tmp = nombId(que,i);
      try{
        document.getElementById(tmp).style.display="none";
      }catch(e){
        ok=false;
      }
      i++;
    }
    document.getElementById(nomb).style.display="block";
  }
  function nombId(id,num){
    if (num < 10)
    return (id+"0"+num);
    else
      return (id+num);
  }

function getpage(page){
window.location = page;
return;
}

   function paginar(){
	 //Verifico si el servidor concluyo una solicitud.
	  if (ajax.readyState == 4) {
	   //Informa el código de estatus del Servidor. "200" = OK
	   if(ajax.status == 200){
	     //valor guarda la respuesta del servidor, que nesescite el XML generado en el archivo listagem.php
		 var valor = ajax.responseXML;

	     var pagAtual = valor.getElementsByTagName("pagAtual")[0].firstChild.nodeValue;//pagAtual = página atual
	     var totalReg = valor.getElementsByTagName("totalReg")[0].firstChild.nodeValue;//totalReg = total de registro del SQL
	     var numPag   = Math.ceil(valor.getElementsByTagName("numPag")[0].firstChild.nodeValue);// numPag =numero de páginas

	     if (totalReg == 0){
		   //caso entre aqui é pq não existe registro o banco, com isso eu "desabilito" os dois select,
		   //exibo a mensagem "Nenhum registro encontrado" e
		   //apago todo o conteúdo da tabela que exibi os registros.
	      // document.getElementById('ordenacao').disabled = true;
		   document.getElementById('registros').disabled = true;
		   //divCarregando = document.getElementById("carregando");
	      // substituirTexto(divCarregando, "Nenhum registro encontrado");
		   if(document.getElementById('tablaPrincipal').rows.length>1){
		     document.getElementById('tablaPrincipal').deleteRow(0);
		     document.getElementById('tablaPrincipal').deleteRow(0);
		   }
	     }else{
           //caso entre aqui é pq existe registro o banco, com isso eu "habilito" os dois select.
		   document.getElementById('ordenacao').disabled = false;
		   document.getElementById('registros').disabled = false;
		   //dataArray = guarda uma matriz com todas informações do xml que pertencer a tag <estado></estado>
		   var dataArray   = valor.getElementsByTagName("cidade");
	       //Utilizado para Limpar a tabela que será usada para mostrar os resgistros
	       while(document.getElementById('tabelaPrincipal').rows.length>0){
		     document.getElementById('tabelaPrincipal').deleteRow(0);
	       }

		   //definição do tamanho das tabelas:
		   //  "tabelaPrincipal" que é usada para mostrar os resgistros
		   //  "tabelaPaginas" que usada para paginar.
	       document.getElementById("tabelaPaginas").width="320";
	       document.getElementById("tabelaPrincipal").width="320";

	       //Inicio da escrita da tebela com o resultado

		   //isso gera uma linha com duas colunas e com conteúdo ID e NOME respectivamente
	       var x=document.getElementById('tabelaPrincipal').insertRow(0);
           var y=x.insertCell(0);
           var z=x.insertCell(1);
           substituirTexto(y, 'ID');
	       substituirTexto(z, 'NOME');

           //Início do processo da paginação propriamente dita
           //quarda a página anterior
		   var anterior = (pagAtual - 1);
		   //guarda a página posterior
	       var proximo  = (Number(pagAtual) + 1);

	       if ((totalReg % dataArray.length!=0)){
		     while(totalReg % dataArray.length!=0){
		       totalReg++;
		     }
	       }

	       if (pagAtual > 1) {
		     //Exibi o texto com o link Primeiro e Anterior, caso a pagina atual seja > 1
			 document.getElementById("pri").style.display = 'block';
		     document.getElementById("ant").style.display = 'block';
		     document.getElementById("pri").href="javascript:listar(1)";
		     document.getElementById("ant").href="javascript:listar("+anterior+")";
	       } else {
		     //Esconde o texto com o link Primeiro e Anterior, caso a página atual seja < 1
			 document.getElementById("pri").style.display = 'none';
		     document.getElementById("ant").style.display = 'none';
		     document.getElementById("pri").href="javascript:listar(1)";
		     document.getElementById("ant").href="javascript:listar("+anterior+")";
	       }

	       if (pagAtual < numPag) {
		     //Exibi o texto com o link Proximo e Ultimo, caso a pagina atual seja < qtd total de páginas
			 document.getElementById("pro").style.display = 'block';
		     document.getElementById("ult").style.display = 'block';
		     document.getElementById("pro").href="javascript:listar("+proximo+")";
		     document.getElementById("ult").href="javascript:listar("+numPag+")";
	       } else {
		     //Esconde o texto com o link Proximo e Ultimo, caso a pagina atual seja >= qtd total de páginas
			 document.getElementById("pro").style.display = 'none';
		     document.getElementById("ult").style.display = 'none';
		     document.getElementById("pro").href="javascript:listar("+proximo+")";
		     document.getElementById("ult").href="javascript:listar("+numPag+")";
	       }
           //Laço para ir exibindo os resgistro linha a linha
	       for(var i = 0 ; i < dataArray.length ; i++) {
             var item = dataArray[i];
		     //contéudo dos campos no arquivo XML
		     var id   =  item.getElementsByTagName("id")[0].firstChild.nodeValue;
		     var nome =  item.getElementsByTagName("nome")[0].firstChild.nodeValue;

			 //será exibido sempre no fim da tabela
			 var posicaoFimTabela = document.getElementById('tabelaPrincipal').rows.length;
	         var x=document.getElementById('tabelaPrincipal').insertRow(posicaoFimTabela)
             var y=x.insertCell(0);
             var z=x.insertCell(1);
             y.width = 30;
			 y.align = 'center';
			 substituirTexto(y, id);
			 z.width = 290;
		     substituirTexto(z, nome);
	       }
		   // Fim do processo da paginação propriamente dita

		   //LimparTexto = função usado para limpar o texto e usada tb para a função substituirTexto
	       var divCarregando = document.getElementById("carregando");
	       divCarregando.style.display = 'none';
	     }
	   }
	 }
   }

/*******************Funciones de checkbox****************/

function infnorecibida(){

	aChk=document.getElementsByTagName('input');
      num=aChk.length;
	var box=new array();
      hay=0;
      for(i=0;i<num;i++){
        if(aChk[i].name.substr(0,4)=='cor_'){
        	if(document.getElementById(aChk[i].name).checked==true){
				box[i]=aChk[i].name;
          		hay++;
          	}
        }
      }


		if(hay != 0){
			if(confirm("Esta seguro que decea informar como no recibidas las correspondencias"))
				tx_ilzcorrespmiscorresp_pi1setnoRecivida(box);
		}else{
			alert("Debe Seleccionar a lo Menos una Correspondencia");
		}

}


function cerrarcorresp(){

	aChk=document.getElementsByTagName('input');
      num=aChk.length;
      cuantos=0;
      hay=0;
      for(i=0;i<num;i++){
        if(aChk[i].name.substr(0,4)=='cor_'){
        	if(document.getElementById(aChk[i].id).checked==true){
        		if(aChk[i].id.substr(0,11)=='cor_Enviada'){
          			cuantos++;
          		}

          		hay++;
          	}
        }
      }

	if(cuantos != 0){
			if(confirm("Esta intentado Cerrar Correspondencias que no han sido revisadas, desea continuar"))
				tx_ilzcorrespmiscorresp_pi1cerrarcorresp(xajax.getFormValues('frmsolicitud'));
	}else{
		if(hay != 0){
			if(confirm("Esta seguro que decea cerrar las correspondencias"))
				tx_ilzcorrespmiscorresp_pi1cerrarcorresp(xajax.getFormValues('frmsolicitud'));
		}else{
			alert("Debe Seleccionar a lo Menos una Correspondencia");
		}
	}


}

function deselect(){

	aChk=document.getElementsByTagName('input');
      num=aChk.length;
      cuantos=0;
      for(i=0;i<num;i++){
        if(aChk[i].name.substr(0,4)=='cor_'){
          cuantos++;
          document.getElementById(aChk[i].id).checked=false;
        }
      }

}


function selectall(){

	aChk=document.getElementsByTagName('input');
      num=aChk.length;
      cuantos=0;
      for(i=0;i<num;i++){
        if(aChk[i].name.substr(0,4)=='cor_'){
          cuantos++;
          document.getElementById(aChk[i].id).checked=true;
        }
      }

}

function invertir(){

	aChk=document.getElementsByTagName('input');
      num=aChk.length;
      cuantos=0;
      for(i=0;i<num;i++){
        if(aChk[i].name.substr(0,4)=='cor_'){
          cuantos++;
          if(document.getElementById(aChk[i].id).checked==true){
          	document.getElementById(aChk[i].id).checked=false;
          }else{
          	document.getElementById(aChk[i].id).checked=true;
        	}
        }

      }

}

function cerrar(){


	if(document.frmsolicitud.codigo.value==""){
		alert("Debe ingresar un comentario para cerrar la correspondencia")
	}else{
		tx_ilzcorrespmiscorresp_pi1cerrando(xajax.getFormValues('frmsolicitud'));
	}

}
