// JavaScript Document
var quantasEspecificacoes = 0;
var itensInclusos = 0;
var localServ = '';
//verificarIP();
//localServ = 'localhost/memotec/'; //Local .
localServ = 'www.memotec.com.br/'; //Servidor.

var imgExcluir = 'images/icones/excluir.gif';
imgExcluir = retiraEspacos(imgExcluir);
var imgEditar = 'images/icones/editar.gif';
imgEditar = retiraEspacos(imgEditar);
var imgVisualizar = 'images/icones/visualizar.gif';
imgVisualizar = retiraEspacos(imgVisualizar);
var imgIndex = 'images/icones/bol_novo.gif';
imgIndex = retiraEspacos(imgIndex);
var imgListIndx = 'images/icones/justificar.gif';
imgListIndx = retiraEspacos(imgListIndx);
var imgImg = 'images/icones/comentario.gif';
imgImg = retiraEspacos(imgImg);
var imgLoad = 'images/icones/load.gif';
imgLoad = retiraEspacos(imgLoad);
var imgLoadCli = 'vector/images/icones/load.gif';
imgLoadCli = retiraEspacos(imgLoadCli);
var igual = 'igual';
var menos = 'menos';
var mais = 'mais';
var delta = 20; //define de quanto em quanto a busca traz.
function verificarLogin()
{
    try{                 
	conexao = xmlhttpInit();       
	var postData='met=28&senha=' + $('senha').value + '&user=' + $('user').value;		
	postData = retiraEspacos(postData);	          
    var url = 'http://'+localServ+'/TrataMemotec';        	        	
	url = retiraEspacos(url);	 		
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");												 
						mostraDados(response, 2);						
					}
					else
					{
						alert(' E aqui Existe um problema com o Request.' + conexao.status);
					}
				}
	}

}catch(e){
alert('dentro do catch => ' + e);
}

}

function verificarPermissao(p){    
	var url = 'http://'+localServ+'TrataMemotec?met=2&se='+p;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{                
                        
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');							
							mostraDados(context, 1);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );
		
		delete xmlhttp;

    }
}

function emprestimoSolDescDoc(numDoc){    
	var codSol = document.getElementById('codSol').value;
	alert('numero solicitacao => ' + codSol);
	alert('Numero do documento => ' + numDoc);
}


function verificarProximoCodigo(){
	var url = 'http://'+localServ+'TrataMemotec?met=87';
	url = retiraEspacos(url);
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 19);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );
		
		delete xmlhttp;

    }
}

//Função para excluir empresa
function excluirEmpresa(codEmpresa){
	var url = 'http://'+localServ+'TrataMemotec?met=29&codEmp='+codEmpresa;	
	url = retiraEspacos(url);
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');
							mostraDados(context, 3);
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );
		
		delete xmlhttp;

    }
}

//Função para serviços solicitação
function excluirServSolicitacao(codServEmp, codSol){
	var url = 'http://'+localServ+'TrataMemotec?met=151&codServEmp='+codServEmp+'&codSol='+codSol;	
	url = retiraEspacos(url);
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');
							mostraDados(context, 54);
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );
		
		delete xmlhttp;

    }
}

//Função para excluir contrato;
function excluirContrato(codContrato){
	var url = 'http://'+localServ+'TrataMemotec?met=35&codCont='+codContrato;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{					
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 5);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );
		
		delete xmlhttp;

    }
}

function apagarImg(numDoc){
var url = 'http://'+localServ+'TrataMemotec?met=133&numDoc='+numDoc;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 44);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );
		
		delete xmlhttp;
    }	
}

//Função para excluir contato;
function excluirContato(codContato){
	var url = 'http://'+localServ+'TrataMemotec?met=47&codCont='+codContato;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');							
							mostraDados(context, 7);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

//Função para excluir colaborador;
function excluirColaborador(login){
	var url = 'http://'+localServ+'TrataMemotec?met=54&log='+login;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{						
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 8);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}


//Função para excluir caixa;
function excluirCaixa(codCaixa, codEmp){
	var url = 'http://'+localServ+'TrataMemotec?met=74&codCaixa='+codCaixa+'&codEmp='+codEmp;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{				
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');				
							mostraDados(context, 13);				
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function excluirColeta(codPedColeta, status, dataInicial, dataFinal){	
	if(dataInicial == 0){
		dataInicial = '000';
	}
	if(dataFinal == 0){
	   dataFinal = '000';	
	}    
	var url = 'http://'+localServ+'TrataMemotec?met=81&codPedColeta='+codPedColeta+'&status='+status+'&dataInicial='+dataInicial+'&dataFinal='+dataFinal;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{						
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 16);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

//Função para excluir colaborador;
function excluirServicos(codigo, tipo){
	var url = 'http://'+localServ+'TrataMemotec?met=101&cod='+codigo+'&tipo='+tipo;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{				
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 29);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

//Função para listar os contratos cadastrados
function listarContrato(f){	
	var url = 'http://'+localServ+'TrataMemotec?met=33&codEmp='+f;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
	        document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';	
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');							
							document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 4);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
  }

function listarCaixa(){	        
	var url = 'http://'+localServ+'TrataMemotec?met=58&codEmp='+document.getElementById('empresa').value+'&numCaixa='+document.getElementById('numCaixa').value;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{				
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 9);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};

			xmlhttp.send( null );		
		delete xmlhttp;
    }
  }

function exibirCxRelatorio(){	
	var url = 'http://'+localServ+'TrataMemotec?met=116';
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{				
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');				
							mostraDados(context, 39);				
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
  }
  
function enviarContato(nome, emp, ddd, telefone, email, mensagem){
    nome = replaceAll(nome , " " , "+");
	emp = replaceAll(emp , " " , "+");
	ddd = replaceAll(ddd , " " , "+");
	telefone = replaceAll(telefone , " " , "+");
	email = replaceAll(email , " " , "+");
	mensagem = replaceAll(mensagem , " " , "+");	
	var url = 'http://'+localServ+'TrataMemotec?met=135&nome='+nome+'&emp='+emp+'&ddd='+ddd+'&telefone='+telefone+'&email='+email+'&mensagem='+mensagem;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 45);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function listarContatoSelect(f){	
	var url = 'http://'+localServ+'TrataMemotec?met=43&codEmp='+f;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');							
							document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 47);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}
  
function listarContato(f){	
	var url = 'http://'+localServ+'TrataMemotec?met=43&codEmp='+f;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 6);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function listarItensCliente(f){	
	var url = 'http://'+localServ+'TrataMemotec?met=137&item='+f;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)	{
			
			xmlhttp.open( "GET", url, true );
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');													
							mostraDados(context, 48);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}




function verificaExisteDoc(area, ga, it, descritor){
    var url = 'http://'+localServ+'TrataMemotec?met=127&area='+area+'&ga='+ga+'&it='+it+'&descritor='+descritor;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							data = response[0].getElementsByTagName('resposta');
			                                resp = data.item(0).firstChild.data;	
                                                        return false;		
							//alert('passou pelo  mostraDados(context, 4);');
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function listarPedidoColeta(st, dtIni, dtFin){
     if(st == '' && dtIni == '' && dtFin == ''){	    
	    var status = document.getElementById('status').value; 
	    var diain = document.getElementById('diain').value;
	    var mesin = document.getElementById('mesin').value;
	    var anoin = document.getElementById('anoin').value;
	    var diafim = document.getElementById('diafim').value;
	    var mesfim = document.getElementById('mesfim').value;
	    var anofim = document.getElementById('anofim').value;
	    var dataInicio = anoin + mesin + diain;
	    var dataFim = anofim + mesfim + diafim;
	 }else{
	    var status = st;
		var dataInicio = dtIni;
		if(dataInicio == '0'){ 
		   dataInicio = '000';
		}
		var dataFim = dtFin;
		if(dataFim == '0'){ 
		   dataFim = '000';
		}	
	 } 
	var url = 'http://'+localServ+'TrataMemotec?met=75&status='+status+'&dtInicial='+dataInicio+'&dtFim='+dataFim;
	url = retiraEspacos(url);			
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 14);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function listarGrupoAssunto(f){    
	var url = 'http://'+localServ+'TrataMemotec?met=60&codArea='+f;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 10);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function listarItem(f){    
	var url = 'http://'+localServ+'TrataMemotec?met=61&codGrupoAssunto='+f;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 11);						
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}
function listarSubitem(f){    
	var url = 'http://'+localServ+'TrataMemotec?met=62&codItem='+f;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 12);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function listarHistorico(){    
    var tipo = document.getElementById('tipo').value;
	var diain = document.getElementById('diain').value;
    var mesin = document.getElementById('mesin').value;
    var anoin = document.getElementById('anoin').value;
    var diafim = document.getElementById('diafim').value;
    var mesfim = document.getElementById('mesfim').value;
    var anofim = document.getElementById('anofim').value;	
	var dataInicial = anoin + mesin + diain;
	var dataFinal = anofim + mesfim + diafim;
    var url = 'http://'+localServ+'TrataMemotec?met=109&tipo='+tipo+'&dtInicial='+dataInicial+'&dtFim='+dataFinal;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');							
							mostraDados(context, 36);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }	
}

function listarHistoricoADM(){    
    var tipo = document.getElementById('tipo').value;
	var diain = document.getElementById('diain').value;
    var mesin = document.getElementById('mesin').value;
    var anoin = document.getElementById('anoin').value;
    var diafim = document.getElementById('diafim').value;
    var mesfim = document.getElementById('mesfim').value;
    var anofim = document.getElementById('anofim').value;
	var empresa = document.getElementById('emp').value;	
	var dataInicial = anoin + mesin + diain;
	var dataFinal = anofim + mesfim + diafim;
    var url = 'http://'+localServ+'TrataMemotec?met=111&tipo='+tipo+'&dtInicial='+dataInicial+'&dtFim='+dataFinal+'&emp='+empresa;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 37);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }	
}

function listarTransDoc(){    
	var diain = document.getElementById('diain').value;
    var mesin = document.getElementById('mesin').value;
    var anoin = document.getElementById('anoin').value;
    var diafim = document.getElementById('diafim').value;
    var mesfim = document.getElementById('mesfim').value;
    var anofim = document.getElementById('anofim').value;
	var empresa = document.getElementById('emp').value;
	var tipo = document.getElementById('tipo').value;	
	var dataInicial = anoin + mesin + diain;
	var dataFinal = anofim + mesfim + diafim;
    var url = 'http://'+localServ+'TrataMemotec?met=113&dtInicial='+dataInicial+'&dtFim='+dataFinal+'&emp='+empresa+'&tipo='+tipo;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 38);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }	
}

function inserirDocumentoPedido(nCaixa, itemDoc, descDoc, codPedCol){
	var url = 'http://'+localServ+'TrataMemotec?met=78&nCaixa='+nCaixa+'&itemDoc='+itemDoc+'&descDoc='+descDoc+'&codPedCol='+codPedCol;
	url = retiraEspacos(url);	
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 15);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function inserirDocumentoLote(caminho){
	var url = 'http://'+localServ+'TrataMemotec?met=88&caminho='+caminho
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');							
							mostraDados(context, 20);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}
function consultarDocumento(op){	
   var empresa = document.getElementById('empresa').value;   
   var area = document.getElementById('area').value;
   var item = document.getElementById('item').value;
   var complemento = document.getElementById('complemento').value;   
   var anoin = document.getElementById('anoin').value;   
   var anofim = document.getElementById('anofim').value;
   var descritor = document.getElementById('descritor').value;   
   if(op == 'igual'){
   	of = 0;	
   }else if(op == 'mais'){
   	of = of + delta;	
   }else if(op == 'menos'){
   	of = of - delta;
	if(of < 0){
		of = 0; 
	}	
   }      
   var dataInicio = anoin + "01" + "01";
   var dataFim = anofim + "01" + "01";  
   if(anoin.length ==0 || anoin.length >=4 || anofim.length ==0 && anofim.length >=4 ){
	var url = 'http://'+localServ+'TrataMemotec';	
	conexao = xmlhttpInit();
	var postData='met=83&emp='+escape(empresa)+'&area='+escape(area)+'&item='+escape(item)+'&complemento='+escape(complemento)+'&dataInicio='+escape(dataInicio)+'&dataFim='+escape(dataFim)+'&descritor='+escape(descritor)+'&of='+escape(of);    
	var url = 'http://'+localServ+'TrataMemotec';
	url = retiraEspacos(url);
	
	document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';    
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");						
						document.getElementById( "msg" ).innerHTML = '';
						mostraDados(response, 17);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
	}
	}else{
		alert('A data de inicio e a data de fim devem conter quatro digitos');
	}		    
}

function exportar(){   
   var empresa = document.getElementById('empresa').value;   
   var area = document.getElementById('area').value;
   var item = document.getElementById('item').value;
   var complemento = document.getElementById('complemento').value;   
   var anoin = document.getElementById('anoin').value;   
   var anofim = document.getElementById('anofim').value;
   var descritor = document.getElementById('descritor').value;   
   var dataInicio = anoin + "01" + "01";
   var dataFim = anofim + "01" + "01";  
   if(anoin.length ==0 || anoin.length >=4 || anofim.length ==0 && anofim.length >=4 ){
	var url = 'http://'+localServ+'TrataMemotec';	
	conexao = xmlhttpInit();
	var postData='met=136&emp='+escape(empresa)+'&area='+escape(area)+'&item='+escape(item)+'&complemento='+escape(complemento)+'&dataInicio='+escape(dataInicio)+'&dataFim='+escape(dataFim)+'&descritor='+escape(descritor);    
	var url = 'http://'+localServ+'TrataMemotec';
	url = retiraEspacos(url);
	document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';    
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");												
						mostraDados(response, 46);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
	}
	}else{
		alert('A data de inicio e a data de fim devem conter quatro digitos');
	}		    
}

function tabelaTemporalidade(emp){
var url = 'http://'+localServ+'TrataMemotec?met=129&emp='+emp;
    url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 43);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function delTemporalidade(codigo, emp){    
	var url = 'http://'+localServ+'TrataMemotec?met=132&emp='+emp+'&cod='+codigo;
    url = retiraEspacos(url);			
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 43);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}


function buscaItensTemporalidade(codArea){
var codEmp = document.getElementById('empresa').value;   
var url = 'http://'+localServ+'TrataMemotec?met=142&emp='+codEmp+'&codArea='+codArea;
    url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			//document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );
			//xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			//xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							//document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 50);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function buscaAreasTemporalidade(f){
var url = 'http://'+localServ+'TrataMemotec?met=141&emp='+f;
    url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			//document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );
			//xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			//xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							//document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 51);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function buscaAreasTemporalidadeSelect(f){
var url = 'http://'+localServ+'TrataMemotec?met=141&emp='+f;
    url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			//document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );
			//xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			//xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							//document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 49);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function buscaTemporalidade(f){
var url = 'http://'+localServ+'TrataMemotec?met=130&emp='+f;
    url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );
			//xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			//xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 43);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}	
function validaTemporalidade(emp){   
   if(emp == 0){
   	 alert('Selecione uma empresa!');
	 return false;
   }else{   
     return true;
   }   
}	
function cadTemporalidade(){   
    var empresa = document.getElementById('emp').value;   
    var area = document.getElementById('area').value;
    var ga = document.getElementById('ga').value;
    var it = document.getElementById('item').value; 
    var ano = document.getElementById('ano').value;
    var permanente = document.getElementById('permanente').checked;    
    var refLegal = document.getElementById('ref').value;
    var resp = validaTemporalidade(empresa);
    refLegal = replaceAll(refLegal , " " , "+");    
    if(resp == false){        
        return;	
    }  
    var validou = validaTemporalidadeVazia(permanente, ano);       
    if(!validou){
       return;
    }
    
    var url = 'http://'+localServ+'TrataMemotec?met=131&emp='+empresa+'&area='+area+'&ga='+ga+'&it='+it+'&ano='+ano+'&permanente='+permanente+'&ref='+refLegal;
    url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							document.getElementById( "msg" ).innerHTML = '';
							mostraDados(context, 43);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function consultarDocumentoResumida(op){   
   var empresa = document.getElementById('empresa').value;
   var descritor = document.getElementById('descritor').value;
   var area = document.getElementById('area').value;
   var item = document.getElementById('item').value;
   var complemento = document.getElementById('complemento').value;   
   var anoin = document.getElementById('anoin').value;   
   var anofim = document.getElementById('anofim').value;   
   if(op == 'igual'){
   	of = 0;	
   }else if(op == 'mais'){
   	of = of + delta;
   }else if(op == 'menos'){
   	of = of - delta;
	if(of < 0){
		of = 0; 
	}
   }   
   var dataInicio = anoin + "01" + "01";
   var dataFim = anofim + "01" + "01";  
   if(anoin.length ==0 || anoin.length >=4 || anofim.length ==0 && anofim.length >=4 ){
	var url = 'http://'+localServ+'TrataMemotec';	
	conexao = xmlhttpInit();
	var postData='met=83&emp='+escape(empresa)+'&descritor='+escape(descritor)+'&area='+escape(area)+'&item='+escape(item)+'&complemento='+escape(complemento)+'&dataInicio='+escape(dataInicio)+'&dataFim='+escape(dataFim)+'&of='+of;    
	var url = 'http://'+localServ+'TrataMemotec';
	url = retiraEspacos(url);
    document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						document.getElementById( "msg" ).innerHTML = '';
						mostraDados(response, 42);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
	}
	}else{
		alert('A data de inicio e a data de fim devem conter quatro digitos');
	}		    
}

function consultarDocumentoEmprestimo(op){   
   var empresa = document.getElementById('empresa').value;
   var descritor = document.getElementById('descritor').value;
   var area = document.getElementById('area').value;
   var item = document.getElementById('item').value;
   var complemento = document.getElementById('complemento').value;   
   var anoin = document.getElementById('anoin').value;   
   var anofim = document.getElementById('anofim').value;   
   if(op == 'igual'){
   	of = 0;	
   }else if(op == 'mais'){
   	of = of + delta;
   }else if(op == 'menos'){
   	of = of - delta;
	if(of < 0){
		of = 0; 
	}
   }   
   var dataInicio = anoin + "01" + "01";
   var dataFim = anofim + "01" + "01";  
   if(anoin.length ==0 || anoin.length >=4 || anofim.length ==0 && anofim.length >=4 ){
	var url = 'http://'+localServ+'TrataMemotec';	
	conexao = xmlhttpInit();
	var postData='met=83&emp='+escape(empresa)+'&descritor='+escape(descritor)+'&area='+escape(area)+'&item='+escape(item)+'&complemento='+escape(complemento)+'&dataInicio='+escape(dataInicio)+'&dataFim='+escape(dataFim)+'&of='+of;    
	var url = 'http://'+localServ+'TrataMemotec';
	url = retiraEspacos(url);
    document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" width="16" height="16" border="0" />';
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						document.getElementById( "msg" ).innerHTML = '';
						mostraDados(response, 55);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
	}
	}else{
		alert('A data de inicio e a data de fim devem conter quatro digitos');
	}		    
}


function consultarDocumentoCliente(op){   
   var area = document.getElementById('area').value;
   var item = document.getElementById('item').value;
   var complemento = document.getElementById('complemen').value;   
   var anoin = document.getElementById('anoin').value;      
   var anofim = document.getElementById('anofim').value;
   if(op == 'igual'){
   	of = 0;	
   }else if(op == 'mais'){
   	of = of + delta;	
   }else if(op == 'menos'){
   	of = of - delta;
	if(of < 0){
		of = 0; 
	}	
   }   
   var dataInicio = anoin + "01" + "01";
   var dataFim = anofim + "01" + "01";      
	var url = 'http://'+localServ+'TrataMemotec';	
	conexao = xmlhttpInit();
	var postData='met=86&area='+escape(area)+'&item='+escape(item)+'&complemento='+escape(complemento)+'&dataInicio='+escape(dataInicio)+'&dataFim='+escape(dataFim);	    
	var url = 'http://'+localServ+'TrataMemotec';
    url = retiraEspacos(url);	
    document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoadCli+'" width="16" height="16" border="0" />';
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						document.getElementById( "msg" ).innerHTML = '';
						mostraDados(response, 18);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
     }
			    
}

function consultarDocumentoAvancadoCliente(op){   
 try{
   var area = document.getElementById('area').value;
   var item = document.getElementById('item').value;
   var complemento = document.getElementById('comple').value;   
   var anoin = document.getElementById('anoin').value;   
   var anofim = document.getElementById('anofim').value;
   var descritor = document.getElementById('descritor').value;
   var situacao = document.getElementById('situacao').value;
   var nCaixa = document.getElementById('numerocaixa').value;
   var digitalizado = document.getElementById('digitalizado').checked;   
   var nDocumento = document.getElementById('numerodocumento').value;
   if(op == 'igual'){
   	of = 0;	
   }else if(op == 'mais'){
   	of = of + delta;	
   }else if(op == 'menos'){
   	of = of - delta;
	if(of < 0){
		of = 0; 
	}	
   }
   var dataInicio = anoin + "01" + "01";
   var dataFim = anofim + "01" + "01";       
   var url = 'http://'+localServ+'TrataMemotec';	
	conexao = xmlhttpInit();
	var postData='met=89&area='+escape(area)+'&item='+escape(item)+'&complemento='+escape(complemento)+'&dataInicio='+escape(dataInicio)+'&dataFim='+escape(dataFim)+
	'&descritor='+escape(descritor)+'&situacao='+escape(situacao)+'&ncaixa='+escape(nCaixa)+'&dig='+escape(digitalizado)+'&ndocumento='+escape(nDocumento);    
	var url = 'http://'+localServ+'TrataMemotec';
    url = retiraEspacos(url);	
    document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoadCli+'" width="16" height="16" border="0" />';
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						document.getElementById( "msg" ).innerHTML = '';
						mostraDados(response, 18);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
     }
	 }catch(e){
	 	consultarDocumentoCliente(op);
	 }	    
}

function consultarDocumentoAvancado(op){   
   try{
   var emp = document.getElementById('empresa').value;
   var us = document.getElementById('us').value;   
   var area = document.getElementById('area').value;
   var item = document.getElementById('item').value;
   var complemento = document.getElementById('complemento').value;  
   var anoin = document.getElementById('anoin').value;  
   var anofim = document.getElementById('anofim').value;
   var descritor = document.getElementById('descritor').value;   
   var temporalidade = document.getElementById('temp').value;
   var permanente = document.getElementById('permanente').checked;  
   var situacao = document.getElementById('situacao').value;
   var nCaixa = document.getElementById('ncaixa').value;
   var digitalizado = document.getElementById('dig').checked;
   var nDocumento = document.getElementById('ndocumento').value;   
   var anoDoc = document.getElementById('anodoc').value;
   anoDoc = anoDoc + "01" + "01";   
   if(permanente == true){
      temporalidade = 'Permanente';
   }else{
   	  temporalidade = temporalidade + "01" + "01";
   }
   if(op == 'igual'){
   	of = 0;	
   }else if(op == 'mais'){
   	of = of + delta;	
   }else if(op == 'menos'){
   	of = of - delta;
	if(of < 0){
		of = 0; 
	}	
   }     
   var dataInicio = anoin + "01" + "01";
   var dataFim = anofim + "01" + "01";  
   if(anoin.length ==0 || anoin.length >=4 || anofim.length ==0 && anofim.length >=4 ){        
	var url = 'http://'+localServ+'TrataMemotec';
	url = retiraEspacos(url);	
	conexao = xmlhttpInit();
	var postData='met=84&emp='+escape(emp)+'&area='+escape(area)+'&item='+escape(item)+'&complemento='+escape(complemento)+'&dataInicio='+escape(dataInicio)+'&dataFim='+escape(dataFim)+
	'&descritor='+escape(descritor)+'&temp='+escape(temporalidade)+'&situacao='+escape(situacao)+'&ncaixa='+escape(nCaixa)+'&dig='+escape(digitalizado)+'&ndocumento='+escape(nDocumento)+'&anodoc='+escape(anoDoc)+'&of='+escape(of)+'&us='+escape(us); 	
	
    document.getElementById( "msg" ).innerHTML = '<img src="'+imgLoad+'" alt="Editar o Evento" width="16" height="16" border="0" />';
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						document.getElementById( "msg" ).innerHTML = '';
						mostraDados(response, 17);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
	}
	}else{
		alert('A data de inicio e a data de fim devem conter quatro digitos');
	}
	}catch(e){
		consultarDocumento(op);
	}			    
}

function pedidoEmprestimo(desc, formatDoc, envBusca, 
	dataPedido, horario, rua, bairro, numero, cep, complemento, cidade, uf, docNum){    
	var compUrl = '';	  
        for(i=0; i<docNum.length; i++){
           if(docNum[i] == undefined){    
              docNum[i] = null;
           }          
		  if(docNum[i] != 0 && docNum[i] != null){
             compUrl += '&docchek'+i+'='+ docNum[i];
		   }           
        }		
	var url = 'http://'+localServ+'TrataMemotec';	
	conexao = xmlhttpInit();
	var postData='met=91&desc='+escape(desc)+'&formatDoc='+escape(formatDoc)+'&envBusca='+envBusca+
	'&dataPed='+dataPedido+'&horario='+horario+'&rua='+escape(rua)+'&bairro='+escape(bairro)+'&numero='+numero+'&cep='+cep+'&comp='+escape(complemento)+'&cidade='+escape(cidade)+'&uf='+uf+'&tamdoc='+docNum.length+compUrl;    
	var url = 'http://'+localServ+'TrataMemotec';        
	url = retiraEspacos(url);    
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						mostraDados(response, 22);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
	}	
}

function pedidoDescritivo(){
   try{    
	var desc = document.getElementById('desc').value;	
	var envBusca = document.getElementById('menu1').value;	   
	if(envBusca == '2'){
	   var diaBusca = document.getElementById('dia').value;
       var mesBusca = document.getElementById('mes').value;
       var anoBusca = document.getElementById('ano').value;       
       var horarioBusca = document.getElementById('horario').value;       
       var rua = document.getElementById('rua').value;
	   var bairro = document.getElementById('bairro').value;
	   var numero = document.getElementById('numero').value;            
	   var cidade = document.getElementById('cidade').value;		  
       var uf = document.getElementById('uf').value;	
       var comp = document.getElementById('comp').value;
       var cep = document.getElementById('cep').value;
       var dataPedido = anoBusca + mesBusca + diaBusca;      
	}
	var postData = '';
	if(envBusca == '2'){		
		postData='met=146&desc='+desc+'&envBusca='+envBusca+'&dataPed='+dataPedido+'&horario='+horarioBusca+'&rua='+rua+'&bairro='+bairro+'&numero='+numero+'&cep='+cep+'&comp='+comp+'&cidade='+cidade+'&uf='+uf;		
	}else{
	    postData='met=146&desc='+desc+'&envBusca='+envBusca;		
	} 
	conexao = xmlhttpInit();	   
	var url = 'http://'+localServ+'TrataMemotec';	
	url = retiraEspacos(url);	
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						mostraDados(response, 52);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
	}
	}catch(e){
	   alert(e);
	}	
	
}

function listarPedidoDesc(){
   try{    
	var emp = document.getElementById('emp').value;	
	var status = document.getElementById('tipo').value;
	postData='met=147&emp='+emp+'&status='+status;	 
	conexao = xmlhttpInit();	   
	var url = 'http://'+localServ+'TrataMemotec';	
	url = retiraEspacos(url);	
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						mostraDados(response, 53);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
	}
	}catch(e){
	   alert(e);
	}	
	
}


function pedidoSolicitacao(desc, formatDoc, envBusca, 
	dataPedido, horario, rua, bairro, numero, cep, complemento, cidade, uf, docNum){	
	var compUrl = '';	  
        for(i=0; i<docNum.length; i++){
           if(docNum[i] == undefined){    
              docNum[i] = null;
           }           
		  if(docNum[i] != 0 && docNum[i] != null){
             compUrl += '&docchek'+i+'='+ docNum[i];
		   }           
        }		
	var url = 'http://'+localServ+'TrataMemotec';	
	conexao = xmlhttpInit();	
	var postData='met=103&desc='+desc+'&formatDoc='+formatDoc+'&envBusca='+envBusca+
	'&dataPed='+dataPedido+'&horario='+horario+'&rua='+rua+'&bairro='+bairro+'&numero='+numero+'&cep='+cep+'&comp='+complemento+'&cidade='+cidade+'&uf='+uf+'&tamdoc='+docNum.length+compUrl;    
	var url = 'http://'+localServ+'TrataMemotec';	
	url = retiraEspacos(url);
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						mostraDados(response, 31);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
	}	
	
}

function confirmarDescarte(numDoc){
    var url = 'http://'+localServ+'TrataMemotec?met=107&nDoc='+numDoc;
    url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 34);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function descartarDoc(numDoc){  
   var url = 'http://'+localServ+'TrataMemotec?met=108&nDoc='+numDoc;
   url = retiraEspacos(url);   		
   var xmlhttp = xmlhttpInit();
   if(xmlhttp)
      {
             xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{						
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 35);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }	
}

function emprestarDocumento(codEmp,acao,ndoc){    
	var url = 'http://'+localServ+'TrataMemotec?met=93&codEmp='+codEmp+'&acao='+acao+'&ndoc='+ndoc;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');							
							mostraDados(context, 24);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}
function atenderSolicitacao(codSolicitacao, nDocumento, tipoSol){    
	var url = 'http://'+localServ+'TrataMemotec?met=105&codSol='+codSolicitacao+'&nDoc='+nDocumento+'&tipoSol='+tipoSol;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{
							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');							
							mostraDados(context, 24);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}
// este e o pedido atual da solicitação descritiva
function cadastrarServicoPedido(){
	var quantidade = document.getElementById('quant').value; 
	var serv = document.getElementById('serv').value;
	var codSol = document.getElementById('codPedDesc').value;
	conexao = xmlhttpInit();
	var postData='met=150&quant='+quantidade+'&serv='+serv+'&codSol='+codSol;
	var url = 'http://'+localServ+'TrataMemotec';
	url = retiraEspacos(url);
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						mostraDados(response, 54);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
     }

}

function cadastrarServicos(){ 
    var tipo = document.getElementById('tipo').value;  
	var descricao = document.getElementById('desc').value;
	var valorServico = document.getElementById('valorservico').value;
	var valorBuscaEntrega = document.getElementById('valorbuscaentrega').value;		
	conexao = xmlhttpInit();
	var postData='met=97&tipo='+tipo+'&desc='+descricao+'&valorservico='+valorServico+'&valorbuscaentrega='+valorBuscaEntrega;
	var url = 'http://'+localServ+'TrataMemotec';
	url = retiraEspacos(url);
	conexao.open("POST",url, true);	
	conexao.setRequestHeader('encoding','ISO-8859-1');
	conexao.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');	
	conexao.send(postData);
	conexao.onreadystatechange=function()
	{
				if(conexao.readyState==4)
				{
					if (conexao.status == 200) {						
						response = conexao.responseXML.getElementsByTagName("memotec");
						mostraDados(response, 27);
					}
					else
					{
						alert('Existe um problema com o Request.' + conexao.status);
					}
				}
     }     
}

function listarServicos(){ 
    var tipo = document.getElementById('tipo').value;	
	var url = 'http://'+localServ+'TrataMemotec?met=98&tipo='+tipo;	
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 28);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function baixaDocumento(nDocumento){   
	var url = 'http://'+localServ+'TrataMemotec?met=94&nDoc='+nDocumento;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 25);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function avisoDescarteDoc(nDocumento){   
	var url = 'http://'+localServ+'TrataMemotec?met=106&nDoc='+nDocumento;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 33);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function dadosCompleto(dadosNDocumento){
	var url = 'http://'+localServ+'TrataMemotec?met=90&codDoc='+dadosNDocumento
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 21);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function carregaTelaEmprestimo(){  
   var url = 'http://'+localServ+'TrataMemotec?met=102';
   url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 30);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
	
}

function mostraDadosEmprestimo(dadosNDocumento){	
        var url = 'http://'+localServ+'TrataMemotec?met=92&codDoc='+dadosNDocumento
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 23);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

function mostraDadosSolicitacao(dadosNDocumento){
	var url = 'http://'+localServ+'TrataMemotec?met=104&codDoc='+dadosNDocumento
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 32);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

// Chama 'url' e insere em 'destino' com a chave como id.
function include(url,destino,chave){        
		var xmlhttp = xmlhttpInit();
		if(xmlhttp){
		xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{
							document.getElementById(destino).innerHTML = xmlhttp.responseText;
							if(chave.length > 0){
		                       document.getElementById('idDoc').value = chave;	
		                    }						        						
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}else{
					// Por ser o erro mais comum generalizei como sendo o status=404 que é o famoso Not found
					document.getElementById(destino).innerHTML = '<p align=\"center\"><img src=\"vector/include/img/alerta.gif\" alt=\"Erro\" /></p>';
				}
			 }else{
				document.getElementById(destino).innerHTML = '<p align=\"center\"><img src=\"img/load.gif\" alt=\"Carregando...\" /></p>';
			}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }	
}

function validaNumCaixa(){
var num = document.getElementById('ncaixa').value;
var url = 'http://'+localServ+'TrataMemotec?met=124&num='+num
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 40);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }	
}

function mudarStatusPedido(codPedido, statusPedido){    
	var url = 'http://'+localServ+'TrataMemotec?met=95&codPed='+codPedido+'&status='+statusPedido;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 26);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
  }

function direcionarIndex(ses){
	var url = "";
	if(ses == 1){
		url = "http://"+localServ+"vector/index.jsp";
		url = retiraEspacos(url);
		location.href=url;
	}if(ses == 2){		
		url = "http://"+localServ+"acesso.jsp";
		url = retiraEspacos(url);
		location.href=url;		
	}
}

function direcionaClienteLogado(){
	var url = "";
	//verificarIP();
	url = "http://"+localServ+"inicial_cliente.jsp";
	url = retiraEspacos(url);
	location.href=url;
}

function verificarSenha(){	
	var login = document.getElementById('log').value;
	var url = 'http://'+localServ+'TrataMemotec?met=125&log='+login;
	url = retiraEspacos(url);		
	var xmlhttp = xmlhttpInit();
	if(xmlhttp)
	{
			xmlhttp.open( "GET", url, true );
			xmlhttp.setRequestHeader('encoding','ISO-8859-1');
			xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{							
							var context = xmlhttp.responseXML.getElementsByTagName('memotec');						
							mostraDados(context, 41);							
						}
						catch(e)
						{                                                  
                                alert('Erro:\n' + xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
						}
					}
					else alert('Erro:\n'+xmlhttp.statusText + ' ' + xmlhttp.status + ' ' + xmlhttp.responseText);
				}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
    }
}

/*function verificarIP(){  
	var xmlhttp = xmlhttpInit();
	var url = 'testeip.jsp';
	if(xmlhttp){
		xmlhttp.open( "GET", url, true );			
			xmlhttp.onreadystatechange = function()
			{
				if( xmlhttp.readyState == 4 )
				{
					if (xmlhttp.status == 200)
					{
						try
						{
							localServ = xmlhttp.responseText;     
							alert('Dentro do verificar ip o que tem em localserv ' + localServ);                       							
						}
						catch(e)
						{                                                                                  
								window.location.assign('index.jsp');
						}					
			 }else{
				//alert('Erro no status do ajax');
			}
			}
			};
			xmlhttp.send( null );		
		delete xmlhttp;
   }
 }*/
 
function mostraDados(response, qualXML){
	var data;
	var conteudo;
	if(response.length >= 1)
	{
		if(qualXML == 1) //Verifica permissão do usuário		
		{			
			data = response[0].getElementsByTagName('permissao');
			conteudo = data.item(0).firstChild.data;			
			if(conteudo == 'OK'){
				data = response[0].getElementsByTagName('sessao');
				conteudo1 = data.item(0).firstChild.data;							
				if(conteudo1 == 1){
				   url = 'http://'+localServ+'vector/area.jsp';   
				   url = retiraEspacos(url);				                   
                   window.location.assign(url);
                }
				else if(conteudo1 == 2){
				   url = 'http://'+localServ+'vector/cadastro.jsp';	
				   url = retiraEspacos(url);					
				   window.location.assign(url);
                }
				else if(conteudo1 == 3){
				   url = 'http://'+localServ+'vector/indexar.jsp';	
				   url = retiraEspacos(url);
				   window.location.assign(url);	
				}
				else if(conteudo1 == 4){
				   url = 'http://'+localServ+'vector/consultar.jsp';	 
				   url = retiraEspacos(url);	
				   window.location.assign(url);	
				}
				else if(conteudo1 == 5){
				   url = 'http://'+localServ+'vector/solicitacao.jsp';	
				   url = retiraEspacos(url);	
				   window.location.assign(url);	
				}
				else if(conteudo1 == 6){
				   url = 'http://'+localServ+'vector/relatorio.jsp';	
				   url = retiraEspacos(url);	
				   window.location.assign(url);	
				}
				else if(conteudo1 == 7){
				   url = 'http://'+localServ+'vector/historico.jsp';	
				   url = retiraEspacos(url);	
				   window.location.assign(url);	
				}                
			}else if(conteudo == 'NEGADO'){
				alert('Usuario não possui permissão para está sessão !');
            }
		}
		else if(qualXML == 2) // Login
		{							
			data = response[0].getElementsByTagName('login');
			conteudo = data.item(0).firstChild.data;

			if(conteudo == 0)
			{
				$('senha').value = '';
				alert('Login ou senha incorreto');
			}			
			if(conteudo == 1){			       	
				   var url = 'http://'+localServ+'vector/administrativo.jsp'
				   url = retiraEspacos(url);				   			    	
				   window.location.assign(url);				
			}else if(conteudo == 2){
                   data = response[0].getElementsByTagName('status');
			       conteudo = data.item(0).firstChild.data;				   								
				   if(conteudo == 't'){
				   	  url = 'http://'+localServ+'vector/administrativo.jsp';
					  url = retiraEspacos(url);
				      window.location.assign(url);
				   }else{
				   	alert('Este login esta inativo entre em contato com o administrador do sistema! ');					
					$('senha').value = '';
				   }				
			}else if(conteudo == 3){
				data = response[0].getElementsByTagName('status');
			    conteudo = data.item(0).firstChild.data;				   								
				if(conteudo == 't'){
				   url = 'http://'+localServ+'inicial_cliente.jsp';
				   url = retiraEspacos(url);
				   window.location.assign(url);				
			    }else{
				   	alert('Este login esta inativo entre em contato com o administrador do sistema! ');					
					$('senha').value = '';
				}
		    }
		}
		else if(qualXML == 3){ // excluir empresa			
			data = response[0].getElementsByTagName('respDelEmpresa');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == "V"){
				url = 'http://'+localServ+'TrataMemotec?met=24';
				url = retiraEspacos(url);
				window.location.assign(url);
			}
			if(conteudo == "F"){
				alert("Não foi possivel excluir esta empresa ! ");
			}			
			if(conteudo == "K"){
				alert("Os contratos e contatos referentes a esta empresa devem ser apagados previamente! ");
			}		
		}
		else if(qualXML == 4){ // listar contrato			
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
                  htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhum contrato encontrado para esta empresa.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table><br/>';
			 document.getElementById("tabela").innerHTML = htmlText;	  
			}else{				
			   data = response[0].getElementsByTagName('contrato');			   
			   htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
			   htmlText +='<th width="123" align="center" valign="middle"><div align="center">OP&Ccedil;&Otilde;ES</div></th>';
               htmlText +='<th width="382" align="center" valign="middle">CLIENTE</th>';
               htmlText += '</tr>';			   
			   for(i=0; i < data.length; i++){
				  var dtcodigo = data[i].getElementsByTagName('codContrato');
				  codigo = dtcodigo.item(0).firstChild.data;				  
                  htmlText += '<td align="center" valign="middle"><a href="javascript:excluirContrato('+codigo+')" onclick="return deleta()"><img src="'+imgExcluir+'" alt="Remover o Evento" width="16" height="16" border="0" /></a>&nbsp; <a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=38&codCont='+codigo+'')+'"><img src="'+imgEditar+'" alt="Editar o Evento" width="16" height="16" border="0" /></a>&nbsp;<a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=34&codCont='+codigo+'')+'"><img src="'+imgVisualizar+'" alt="Visualizar o Evento" width="16" height="16" border="0" /></a></td>';
                  var dtnome = data[i].getElementsByTagName('nomeCliente');
				  nome = dtnome.item(0).firstChild.data;                  
				  htmlText += '<td>'+nome+'</td>';                  
                  htmlText += '</tr>'			      
			   }
			   			   
			   htmlText += '</table><br/>';
			document.getElementById("tabela").innerHTML = htmlText;   
			}			
		}else if(qualXML == 5){ // excluir contrato			
			data = response[0].getElementsByTagName('respDelContrato');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo){		   
			   listarContrato(document.getElementById('empresa').value);			   
			}else{				
			   alert("O correu um problema na exclusão");   
			}			
		}else if(qualXML == 6){ // excluir Verificar se usuario existe.					
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
                  htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhum usuário encontrado para esta empresa.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table><br/>';
			 document.getElementById("tabela").innerHTML = htmlText;	  
			}else{				
			   data = response[0].getElementsByTagName('contato');			   
			   htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
			   htmlText +='<th width="123" align="center" valign="middle"><div align="center">OP&Ccedil;&Otilde;ES</div></th>';
               htmlText +='<th width="382" align="center" valign="middle">CLIENTE</th>';
               htmlText += '</tr>';			   
			   for(i=0; i < data.length; i++){
				  var dtcodigo = data[i].getElementsByTagName('codContato');
				  codigo = dtcodigo.item(0).firstChild.data;				  
                  htmlText += '<td align="center" valign="middle"><a href="javascript:excluirContato('+codigo+')" onclick="return deleta()"><img src="'+imgExcluir+'" alt="Remover o Evento" width="16" height="16" border="0" /></a>&nbsp; <a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=45&codCont='+codigo+'')+'"><img src="'+imgEditar+'" alt="Editar o Evento" width="16" height="16" border="0" /></a></td>';
                  // &nbsp;<a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=44&codCont='+codigo+'')+'"><img src="'+imgVisualizar+'" alt="Visualizar o Evento" width="16" height="16" border="0" /></a>
                  var dtnome = data[i].getElementsByTagName('nome');
				  nome = dtnome.item(0).firstChild.data;                  
				  htmlText += '<td>'+nome+'</td>';                  
                  htmlText += '</tr>'			      
			   }
			   			   
			   htmlText += '</table><br/>';
			document.getElementById("tabela").innerHTML = htmlText;		
			}	
		}else if(qualXML == 7){ // excluir contrato			
			data = response[0].getElementsByTagName('respDelContato');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo){		   
			   listarContato(document.getElementById('empresa').value);			   
			}else{				
			   alert("O correu um problema na exclusão");   
			}			
       }else if(qualXML == 8){ // excluir colaborador          		
			data = response[0].getElementsByTagName('respDelColaborador');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo){		   
			   window.location.assign('http://'+localServ+'TrataMemotec?met=50');							   
			}else{				
			   alert("O correu um problema na exclusão");   
			}			
       }else if(qualXML == 9){ // listar caixa			
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
                  htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhuma caixa encontrado para esta empresa.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table><br/>';
			 document.getElementById("tabela").innerHTML = htmlText;	  
			}else{				
			   data = response[0].getElementsByTagName('caixa');			   
			   htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
			   htmlText +='<th width="175" align="center" valign="middle"><div align="center">OP&Ccedil;&Otilde;ES</div></th>';
               htmlText +='<th width="80" align="center" valign="middle">CAIXA</th>';
			   htmlText +='<th align="center" valign="middle">ESTADO</th>';
               htmlText += '</tr>';	
			   var prefCx = 'CX_';		   
			   for(i=0; i < data.length; i++){                 
				  var dtcodigo = data[i].getElementsByTagName('codCaixa');
				  codigo = dtcodigo.item(0).firstChild.data;
				  var dCodEmp = data[i].getElementsByTagName('codEmp');
				  codEmp = dCodEmp.item(0).firstChild.data;
				  var numCaixa = data[i].getElementsByTagName('numCaixa');
				  nCaixa = numCaixa.item(0).firstChild.data;							  
                  htmlText += '<td align="center" valign="middle"><a href="javascript:excluirCaixa('+codigo+','+codEmp+')" onclick="return deleta()"><img src="'+imgExcluir+'" alt="Remover o Evento" width="16" height="16" border="0" /></a>&nbsp; <a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=66&codCaixa='+codigo+'')+'"><img src="'+imgEditar+'" alt="Editar o Evento" width="16" height="16" border="0" /></a>&nbsp;<a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=65&codCaixa='+codigo+'')+'"><img src="'+imgVisualizar+'" alt="Visualizar o Evento" width="16" height="16" border="0" /></a>&nbsp; <a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=59&codCaixa='+codigo+'')+'"><img src="'+imgIndex+'" alt="Indexar Documento" width="16" height="16" border="0" /></a>&nbsp; <a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=68&codCaixa='+codigo+'')+'"><img src="'+imgListIndx+'" alt="Listar Documentos" width="16" height="16" border="0" /></a></td>';                  
				  htmlText += '<td>'+prefCx + nCaixa+'</td>'; 
				  var dtestado = data[i].getElementsByTagName('estado');
				  estado = dtestado.item(0).firstChild.data;	
				  			  				  
				  if(estado == 1){                             
                     htmlText += '<td style="padding-left:25px;">C</td>';
				  }else if(estado == 2){                             
                     htmlText += '<td style="padding-left:25px;">V</td>';
				  }else if(estado == 3){                             
                     htmlText += '<td style="padding-left:25px;">E</td>';
				  }        
				  htmlText += '</tr>'			      
			   }
			   			   
			   htmlText += '</table><br/>';
			document.getElementById("tabela").innerHTML = htmlText;   
			}			
		}else if(qualXML == 10){ // listar Grupo Assunto				
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){				
			   htmlText += '<select name="ga" id="ga">';
               htmlText += '<option value="0">Grupo de assunto</option>';                          
               htmlText += '</select>';
			   document.getElementById("dga").innerHTML = htmlText;			 	  
			}else{				
			   data = response[0].getElementsByTagName('GrupoAssunto');			   
			   htmlText += '<select name="ga" id="ga" onchange="javascript:listarItem(this.value);">';
               htmlText += '<option value="0">Grupo de assunto</option>';
			   for(i=0; i < data.length; i++){                 
				  var dtcodigo = data[i].getElementsByTagName('codGrupoAssunto');
				  var codigoGrupoAssunto = dtcodigo.item(0).firstChild.data;				  
                  var dtdescricao = data[i].getElementsByTagName('descricao');
				  var descricao = dtdescricao.item(0).firstChild.data;
				  htmlText += '<option value="'+codigoGrupoAssunto+'"'+codigoGrupoAssunto+'>'
                  htmlText += descricao+'</option>'
			   } 			   
			   htmlText += '</select>';
			   document.getElementById("dga").innerHTML = htmlText;   
			}			
		}else if(qualXML == 11){ // listar Item				
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){              			
			   htmlText += '<select name="item" id="item">';
               htmlText += '<option value="0">Item</option>';                          
               htmlText += '</select>';
			   document.getElementById("ditem").innerHTML = htmlText;			 	  
			}else{				
			   data = response[0].getElementsByTagName('Item');
			   // onchange do select abaixo cara queira que exita o subitem (onchange="javascript:listarSubitem(this.value);")			   
			   htmlText += '<select name="item" id="item">';
               htmlText += '<option value="0">Item</option>';
			   for(i=0; i < data.length; i++){                 
				  var dtcodigo = data[i].getElementsByTagName('codItem');
				  var codigoItem = dtcodigo.item(0).firstChild.data;				  
                  var dtdescricao = data[i].getElementsByTagName('descricao');
				  var descricao = dtdescricao.item(0).firstChild.data;
				  htmlText += '<option value="'+codigoItem+'"'+codigoItem+'>'
                  htmlText += descricao+'</option>'
			   } 			   
			   htmlText += '</select>';
			   document.getElementById("ditem").innerHTML = htmlText;   
			}			
		}else if(qualXML == 12){ // listar Subitem				
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){              			
			   htmlText += '<select name="subitem" id="subitem">';
               htmlText += '<option value="0">Subitem</option>';                          
               htmlText += '</select>';
			   document.getElementById("dsubitem").innerHTML = htmlText;			 	  
			}else{				
			   data = response[0].getElementsByTagName('Subitem');			   
			   htmlText += '<select name="subitem" id="subitem">';
               htmlText += '<option value="0">Subitem</option>';
			   for(i=0; i < data.length; i++){                 
				  var dtcodigo = data[i].getElementsByTagName('codSubitem');
				  var codigoSubitem = dtcodigo.item(0).firstChild.data;
				  var dtdescricao = data[i].getElementsByTagName('descricao');
				  var descricao = dtdescricao.item(0).firstChild.data;
				  htmlText += '<option value="'+codigoSubitem+'"'+codigoSubitem+'>'
                  htmlText += descricao+'</option>'
			   } 			   
			   htmlText += '</select>';
			   document.getElementById("dsubitem").innerHTML = htmlText;   
			}			
		}else if(qualXML == 13){ // Excluir caixa				
			data = response[0].getElementsByTagName('respDelCx');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo == "V"){
				data = response[0].getElementsByTagName('codEmp');
				conteudo = data.item(0).firstChild.data;								
				listarCaixa(conteudo);
			}
			if(conteudo == "F"){
				alert("Não foi possivel excluir esta caixa ! ");
			}			
			if(conteudo == "K"){
				alert("Os documentos referentes a esta caixa devem ser apagados previamente! ");
			}						
		}else if(qualXML == 14){ // listar Pedido coleta												
		  var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
                  htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhuma pedido de coleta encontrado.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table><br/>';
			 document.getElementById("tabela2").innerHTML = htmlText;	  
			}else{	
			try{		   
			   data = response[0].getElementsByTagName('status');			
			   statusPed = data.item(0).firstChild.data;			   
			   data = response[0].getElementsByTagName('dataInicial');			
			   dataInicial = data.item(0).firstChild.data;			   
			   data = response[0].getElementsByTagName('dataFinal');			
			   dataFinal = data.item(0).firstChild.data;			   			   								
			   data = response[0].getElementsByTagName('PedCol');			   
			   htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
			   htmlText +='<th width="200" align="center" valign="middle"><div align="center">OP&Ccedil;&Otilde;ES</div></th>';
               htmlText +='<th width="28" align="center" valign="middle"><center>PEDIDO</center></th>';
			   htmlText +='<th width="53" align="center" valign="middle"><center>EMPRESA</center></th>';
			   htmlText +='<th width="38" align="center" valign="middle"><center>CONTATO</center></th>';
			   htmlText +='<th width="108" align="center" valign="middle"><center>DATA</center></th>';
			   htmlText +='<th width="58" align="center" valign="middle"><center>HORÁRIO</center></th>';
			   htmlText +='<th width="29" align="center" valign="middle"><center>FICHA</center></th>';			   
               htmlText += '</tr>';	
			   var pref = 'COD_';			   	   
			   for(i=0; i < data.length; i++){
				  var codigo1 = data[i].getElementsByTagName('codPedido');
				  codigoPedido = codigo1.item(0).firstChild.data;				  
				  var codigo2 = data[i].getElementsByTagName('data');
				  dataPedido = codigo2.item(0).firstChild.data;				  
				  var codigo3 = data[i].getElementsByTagName('horario');
				  horario = codigo3.item(0).firstChild.data;				  		
				  var codigo4 = data[i].getElementsByTagName('empresa');
				  empresa = codigo4.item(0).firstChild.data;				  	
				  var codigo5 = data[i].getElementsByTagName('contato');
				  contato = codigo5.item(0).firstChild.data;				  				  	
				  var codigo6 = data[i].getElementsByTagName('fichaDetalhada');
				  ficha = codigo6.item(0).firstChild.data;				  				  									  
                  var mostra;
				  if(ficha == 'null' || ficha == "vazio"){
				  	mostra = '&nbsp;';					
				  }else{				  					  	 
				  	mostra = '<a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=79&codPed='+codigoPedido+'')+'&ficha='+ficha+'" target="_blank"><img src="'+imgImg+'" alt="'+ficha+'" width="16" height="16" border="0"/>';					
				  }				  
				  htmlText += '<td align="center" valign="middle"><a href="javascript:excluirPedidoColeta('+codigoPedido+', '+statusPed+', '+dataInicial+', '+dataFinal+')" onclick="return deleta()"><img src="'+imgExcluir+'" alt="Remover o Evento" width="16" height="16" border="0" /></a><a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=76&codPedCol='+codigoPedido+'&status='+statusPed+'&dataInicial='+dataInicial+'&dataFinal='+dataFinal+'')+'"><img src="'+imgVisualizar+'" alt="Visualizar o Evento" width="16" height="16" border="0" /></a><a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=80&codPed='+codigoPedido+'')+'"><img src="'+imgListIndx+'" alt="Listar Documentos" width="16" height="16" border="0" /></a></td>';                  
				  htmlText += '<td>'+pref + codigoPedido+'</td>'; 
				  htmlText += '<td> <center>'+empresa+'</center></td>';
				  htmlText += '<td> <center>'+contato+'</center></td>';
				  htmlText += '<td> <center>'+dataPedido+'</center></td>';
				  htmlText += '<td>'+horario+'</td>';
				  htmlText += '<td> <center>'+mostra+'</center></td>';
				  htmlText += '</tr>'			      
			   }
			   htmlText += '</table><br/>';
			document.getElementById("tabela2").innerHTML = htmlText;
			}catch(e){
				alert('Esta dando um erro'+ e); 
			}   
			}			
		}else if(qualXML == 15){ // inserirPedido		    
		    var htmlText = '<HR />';			
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo != 0){			
				data = response[0].getElementsByTagName('DocPedCol');								
				for(i=0; i < data.length; i++){
				   var codigo1 = data[i].getElementsByTagName('nCaixa');
				   nCaixa = codigo1.item(0).firstChild.data;				   	 
				   if(nCaixa == 'vazio'){ nCaixa = "";}  	  
				   var codigo2 = data[i].getElementsByTagName('itDoc');
				   itDoc = codigo2.item(0).firstChild.data;				   		
				   if(itDoc == 'vazio'){ itDoc = "";}		   		  
				   var codigo3 = data[i].getElementsByTagName('descDoc');
				   descDoc = codigo3.item(0).firstChild.data;				   
                   if(descDoc == 'vazio'){ descDoc = "";}        				   				   
			       htmlText += '<div style=\"margin-left:185px;font-family:Verdana;font-size:10px;text-align:left;\"><B>Nº Caixa Cliente:</B>'+nCaixa+'<BR /><B>Item Doc.:</B>'+itDoc+'<BR /><B>Descrição:</B>'+descDoc+'</div><HR />';				   			       	  
	            }
				document.getElementById('n_caixa').value = '';
				document.getElementById('item_doc').value = '';
				document.getElementById('desc').value = '';
				document.getElementById('n_caixa').focus();
				document.getElementById("listaDocumentos").innerHTML = htmlText;		
			}						
		}else if(qualXML == 16){ // excluirPedido		    
		   data = response[0].getElementsByTagName('respDelPed');			
		   conteudo = data.item(0).firstChild.data;			
		   if(conteudo){
		      data = response[0].getElementsByTagName('status');			
		      status = data.item(0).firstChild.data;			  		
		      data = response[0].getElementsByTagName('dataInicial');			
		      dataInicial = data.item(0).firstChild.data;			  			
		      data = response[0].getElementsByTagName('dataFinal');			
		      dataFinal = data.item(0).firstChild.data;			  	  				   
		      listarPedidoColeta(status, dataInicial, dataFinal);							   
		   }else{				
			   alert("O correu um problema na exclusão");   
		   }
	  }else if(qualXML == 17){ // consultas Adm	   	    
		  var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			 htmlText += '<tr>';
             htmlText += '<br>';
             htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhum documento encontrado.</th>';
             htmlText += '<tr>';
			 htmlText += '</table>';
			 document.getElementById("consultaAdm").innerHTML = htmlText;	  
			}else{				   	   			   								
			   data = response[0].getElementsByTagName('consultaAdimim');
			   var pref = 'Doc_';
			   var prefCaixa = 'Cx_';
			   var espaco = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			   for(i=0; i < data.length; i++){                 
			      var codigo1 = data[i].getElementsByTagName('dadosncaixa');
				  dadosNuncaixa = codigo1.item(0).firstChild.data;
                                  var codigo1 = data[i].getElementsByTagName('dadosArea');
				  dadosArea = codigo1.item(0).firstChild.data;
				  var codigo2 = data[i].getElementsByTagName('dadositem');
				  dadosItemDoc = codigo2.item(0).firstChild.data;				  				  
				  var codigo3 = data[i].getElementsByTagName('dadoscomplemento');
				  dadosComplemento = codigo3.item(0).firstChild.data;
				  var codigo4 = data[i].getElementsByTagName('dadosdescritor');
				  dadosDescritor = codigo4.item(0).firstChild.data;				  	
				  var codigo5 = data[i].getElementsByTagName('dadosndocumento');
				  dadosNDocumento = codigo5.item(0).firstChild.data;				  		  				  	
				  var codigo6 = data[i].getElementsByTagName('dadosNCaixa');
				  dadosNCaixa = codigo6.item(0).firstChild.data;
				  var codigo6 = data[i].getElementsByTagName('dadossituacao');
				  dadosSituacao = codigo6.item(0).firstChild.data;
				  var codigo7 = data[i].getElementsByTagName('dadosavisodescarte');
				  dadosAvisoDescarte = codigo7.item(0).firstChild.data;
                  var codigo8 = data[i].getElementsByTagName('dadoslocalarmazenamento');
				  dadosLocalArmazenamento = codigo8.item(0).firstChild.data;                                  
				  htmlText +='<table width="525" border="0" cellspacing="1" cellpadding="1" class="tabela" id="tabela1">';
			      htmlText +='<tr>';
			      htmlText +='<th>Área</th>';
			      htmlText +='<td colspan="3">'+dadosArea+'</td>';
			      htmlText +='</tr>';
			      htmlText +='<tr>';			   
                  htmlText += '<th>Item Documental</th>';
			      htmlText += '<td colspan="3">'+dadosItemDoc+'</td>';
			      htmlText += '</tr>';
			      htmlText += '<tr>';
			      htmlText += '<th>Complemento</th>';
			      htmlText += '<td colspan="3">'+dadosComplemento+'</td>';
			      htmlText += '</tr>';
			      htmlText += '<tr>';
			      htmlText += '<th style="width:25px;">Descritor</th>';                                  
				  if(dadosDescritor == 'vazio'){
			         htmlText += '<td style="width:500px;" colspan="3">.</td>';
				  }else{
				  	 htmlText += '<td colspan="3">'+dadosDescritor+'</td>';
				  }
			      htmlText += '</tr>';
			      htmlText += '<tr>';
			      htmlText += '<th>Situação</th>';
			      htmlText += '<td colspan="3">'+dadosSituacao+'</td>';
			      htmlText += '</tr>';
                  htmlText += '<tr>';
			      htmlText += '<th>Local Armazenamento</th>';
			      htmlText += '<td colspan="3">'+dadosLocalArmazenamento+'</td>';
			      htmlText += '</tr>';
			      htmlText += '<tr>';
			      htmlText += '<th>N&ordm; Documento</th>';
			      htmlText += '<td width="17%">'+ pref + dadosNDocumento +'</td>';
			      htmlText += '<th width="15%">Nº Caixa</th>';
			      htmlText += '<td width="40%">'+ prefCaixa +dadosNuncaixa+espaco+espaco+espaco+'<input name="TodosDados" type="submit" class="botao1" value=">>>" onclick= "mostraDadosComplemConsAvancAdm('+dadosNDocumento+');"/></td>';				  
			      htmlText += '</tr>';	
				  if(dadosSituacao == 'Descarte confirmado'){
				  	dadosAvisoDescarte = 'vazio';				  	 					 
					 htmlText += '<tr>';
				     htmlText += '<th>Descarte</th>';
				     htmlText += '<td colspan="3"><input name="descartar" type="submit" class="botao1" value="Descartar" onclick= "descartarDoc('+dadosNDocumento+');"/></td>';
				     htmlText += '</tr>';
				  }			  	
				  if(dadosSituacao != 'Descartado'){  
				     if(dadosSituacao != "Aviso descarte"){   				  		  			  
				        if(dadosAvisoDescarte == 'avisoDescarte'){				       	        
					       htmlText += '<tr>';
			               htmlText += '<th>Descarte</th>';
			               htmlText += '<td colspan="3"><input name="AvisarDescarte" type="submit" class="botao1" value="Avisar Descarte" onclick= "avisoDescarteDoc('+dadosNDocumento+');"/></td>';
				        }
					 }
				  }
				  if(dadosSituacao == 'Emprestado' || dadosSituacao == 'Reservado'){
				     htmlText += '<tr>';
				     htmlText += '<th>Emprestimo</th>';
				     htmlText += '<td colspan="3"><input name="Visualisar" type="submit" class="botao1" value="Verificar" onclick= "mostraEmprestimoAdm('+dadosNDocumento+');"/></td>';
				     htmlText += '</tr>'; 
			      }			  
				  if(dadosSituacao == 'reservado'){				  	
				  	 dadosSituacao = 'Reservado';					 
					 htmlText += '<tr>';
				     htmlText += '<th>Solicitacao</th>';
				     htmlText += '<td colspan="3"><input name="Verificar" type="submit" class="botao1" value="Verificar" onclick= "mostraSolicitacaoAdm('+dadosNDocumento+');"/></td>';
				     htmlText += '</tr>';
				  }				  
				  htmlText += '</table>';
			      htmlText += '<div id="respostaConsulta'+dadosNDocumento+'" style="width:100%; display:none" ></div>';		  		      
				  htmlText += '<img src="../imagens/transp.gif" height="10" width="10" alt="" />';
				  htmlText += '<div id="dadosCompletos'+dadosNDocumento+'" style="width:100%; display:none" ></div>';
			   }			     
			   htmlText += '<div id="ultlinha" align="center">';
			   htmlText += '<input name="voltar" type="submit" class="botao1" value="<" onclick= "javascript:consultarDocumentoAvancado('+menos+');"/>'+espaco;
			   if(data.length >= 20){ 
			      htmlText += '<input name="ir" type="submit" class="botao1" value=">" onclick= "javascript:consultarDocumentoAvancado('+mais+');"/>';
			   }
			   htmlText += '</div>'; 
			document.getElementById("consultaAdm").innerHTML = htmlText;		
		}	
	  }else if(qualXML == 18){ // consulta Cliente	  	  
		  try{  
		  var htmlText = "";
		  var totaldoc = '';		   	
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;						
			if(conteudo == 0){
			   htmlText += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
			   htmlText += '<tr>';                  
                           htmlText +=  '<td bgcolor="#066F9B"><p style="color:#FFFFFF"><b><center>Nenhum Documento encontrado!</center></b></p></td>';
                           htmlText += '<tr>';
			   htmlText += '</table>';			   
			   document.getElementById("consultaCliente").innerHTML = htmlText;	  
			}else{					   	   			   								
			   data = response[0].getElementsByTagName('consultaCli');			   			   
			   var color = '';
			   var espaco = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
               totaldoc = data.length;		
               htmlText += '<table width="100%" border="0" cellspacing="1" cellpadding="1">';               
               htmlText +='<tr>';
			   htmlText +='<td width="10%" class="txt" align="center"><b>&Aacute;rea:</b></td>';
			   htmlText +='<td width="15%" class="txt" align="center"><b>&Iacute;tem:</b></td>';
			   htmlText +='<td width="15%" class="txt" align="center"><b>Complemento:</b></td>';
			   htmlText +='<td width="10%" class="txt" align="center"><b>Descritor:</b></td>';
			   htmlText +='<td  width="3%" class="txt" align="center"><b>N&ordm; Doc:</b></td>';
			   htmlText +='<td width="3%" class="txt" align="center"><b>Data Doc:</b></td>';
			   htmlText +='</tr>';
               
			   for(i=0; i < data.length; i++){				  
				  var codigo1 = data[i].getElementsByTagName('dadosncaixa');
				  dadosNuncaixa = codigo1.item(0).firstChild.data;
				  var codigo1 = data[i].getElementsByTagName('dadosArea');
				  DadosArea = codigo1.item(0).firstChild.data;
				  var codigo2 = data[i].getElementsByTagName('dadositem');
				  dadosItemDoc = codigo2.item(0).firstChild.data;				  
				  var codigo3 = data[i].getElementsByTagName('dadoscomplemento');
				  DadosComplemento = codigo3.item(0).firstChild.data;				  		
				  var codigo4 = data[i].getElementsByTagName('dadosdescritor');
				  DadosDescritor = codigo4.item(0).firstChild.data;				  	
				  var codigo5 = data[i].getElementsByTagName('dadosndocumento');
				  DadosNDocumento = codigo5.item(0).firstChild.data;                                                                
				  var codigo6 = data[i].getElementsByTagName('dadosdataDoc');
				  DadosDataDoc = codigo6.item(0).firstChild.data;
				  var codigo6 = data[i].getElementsByTagName('dadossituacao');
				  DadosSituacao = codigo6.item(0).firstChild.data;
				  var codigo7 = data[i].getElementsByTagName('dadosnomedocdig');
				  DadosDocDig = codigo7.item(0).firstChild.data;				  
				  if(i % 2 == 0){
					  color = "#F4F4F9";					  
				  }else{
					  color = "#FFFFFF";
				  }
			      			     
                  htmlText +='<tr>';
			      //htmlText +='<td width="22%" class="txt"><b>&nbsp;&Aacute;rea:</b></td>';
			      //htmlText +='<td colspan="3" bgcolor="#F4F4F4"><p>'+DadosArea+'</p></td>';
                  htmlText +='<td bgcolor="'+color+'"><p>'+DadosArea+'</p></td>';
			      //htmlText +='</tr>';
			      //htmlText +='<tr>';			   
                  //htmlText += '<td class="txt"><b>&nbsp;&Iacute;tem Documental:</b></td>';
			      htmlText += '<td bgcolor="'+color+'"><p>'+dadosItemDoc+'</p></td>';
			      //htmlText += '</tr>';
			      //htmlText += '<tr>';
			      //htmlText += '<td class="txt"><b>&nbsp;Complemento:</b></td>';
			      htmlText += '<td bgcolor="'+color+'"><p>'+DadosComplemento+'</p></td>';
			      //htmlText += '</tr>';
			      //htmlText += '<tr>';
			      //htmlText += '<td class="txt"><b>&nbsp;Descritor:</b></td>';
				  if(DadosDescritor == 'vazio'){
			         htmlText += '<td bgcolor="'+color+'"><p></p></td>';
				  }else{
				  	 htmlText += '<td bgcolor="'+color+'"><p>'+DadosDescritor+'</p></td>';
				  }
			      //htmlText += '</tr>';
			      //htmlText += '<tr>';
			      //htmlText += '<td class="txt"><b>&nbsp;Situa&ccedil;&atilde;o:</b></td>';
				  /*if(DadosSituacao == 'reservado'){
				     DadosSituacao = 'Reservado';
				     htmlText += '<td colspan="3" bgcolor="#F4F4F4"><p>'+DadosSituacao+'</p></td>';	
				  }else{
				  	htmlText += '<td colspan="3" bgcolor="#F4F4F4"><p>'+DadosSituacao+'</p></td>';
				  }
				  if(DadosDocDig != 'vazio'){
				  	if(DadosDocDig == 'null'){
						DadosDocDig = '&nbsp';
					}
				  	htmlText += '<tr>';
					htmlText += '<td class="txt"><b>&nbsp;Imagem</b></td>';
					htmlText += '<td colspan="3" bgcolor="#F4F4F4"><p><a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=72&numDoc='+DadosNDocumento+'')+'&nomeArq='+DadosDocDig+'"target="_blank">'+DadosDocDig+'</a></p></td>';
					htmlText += '</tr>';
				  }*/	      
			      
			      //htmlText += '<tr>';
			      //htmlText += '<td class="txt"><b>&nbsp;N&ordm; Documento:</b></td>';
			      htmlText += '<td bgcolor="'+color+'"><p>'+DadosNDocumento +'</p></td>';
			      //htmlText += '<td width="21%" class="txt"><b>&nbsp;Data Documento:</b></td>';
			      htmlText += '<td bgcolor="'+color+'"><p>'+DadosDataDoc+'</p></td>';
			      //htmlText += '</tr>';
			      /*if(DadosSituacao == 'Normal'){
			         htmlText += '<tr>';
				      htmlText += '<td class="txt"><b>Solicitação</b></td>';
				      //htmlText += '<td colspan="3" bgcolor="#F4F4F4"><a href="javascript:;" onclick ="mostraEmprestimo('+DadosNDocumento+');"><img src="imagens/bt_realizar.gif" alt="" border="0"/></a></td>';
				      if(i == 0){
					     htmlText += '<td colspan="3" bgcolor="#F4F4F4"> <input type="checkbox" name= "nomedocchek'+i+'" id="docchek'+i+'" value="'+DadosNDocumento+'"  onclick="verificaPosZero()"/> </td>';
				      }else{
					  	 htmlText += '<td colspan="3" bgcolor="#F4F4F4"> <input type="checkbox" name= "nomedocchek'+i+'" id="docchek'+i+'" value="'+DadosNDocumento+'" /> </td>';
					  }
					  htmlText += '</tr>';
				 }else{
                       htmlText += '<input type="hidden"  name= "nomedocchek'+i+'" id="docchek'+i+'" value="'+DadosNDocumento+'"/>';
                 }		
				 if(DadosSituacao == 'Aviso descarte'){
				    htmlText += '<tr>';
				    htmlText += '<td class="txt"><b>Descartar</b></td>';
				    htmlText += '<td colspan="3" bgcolor="#F4F4F4"><a href="javascript:;" onclick ="confirmarDescarte('+DadosNDocumento+');"><img src="imagens/bt_confirmar.gif" alt="" border="0"/></a><a href="javascript:; "onclick ="alert('+DadosNDocumento+');"><img src="imagens/bt_renovar.gif" alt="" border="0"/></a></td>';
				    htmlText += '</tr>';
				 }*/	
			      //htmlText +='</tr>';
			      //   htmlText += '</table>';                     
			      //   htmlText += '<div id="respostaConsulta'+DadosNDocumento+'" style="width:100%; display:none" ></div>';		  		      
			      //   htmlText += '<img src="imagens/transp.gif" height="10" width="10" alt="" />';				  
			   }//fim do for
			   htmlText += '</table>';
			   htmlText += '<input name="todoc" type="hidden" id="todoc" value="'+totaldoc+'" />';
			   
			   htmlText += '<div id="tpcte"></div>';
			   
			   htmlText += '<div id="ultlinha" align="center">';
			   //htmlText += '<input name="voltar" type="image" src="imagens/bt_voltar.gif" onclick= "javascript:consultarDocumentoAvancadoCliente('+menos+');"/>'+espaco;
			   if(totaldoc >= 50){ 
			     //htmlText += '<input name="ir" type="image" src="imagens/bt_ir.gif" onclick= "javascript:consultarDocumentoAvancadoCliente('+mais+');"/>';
			   }
			   htmlText += '</div>';
			   
			  // carregaTelaEmprestimo();			   
			document.getElementById("consultaCliente").innerHTML = htmlText;
		  }   
		}catch(e){
			alert(e);
		}
		}else if(qualXML == 19){ // Proximo doc indexação		    
		   data = response[0].getElementsByTagName('proximo');			
		   conteudo = data.item(0).firstChild.data;			
		   if(conteudo == 0){
		      alert('Houve um ERRO na consulta.')							   
		   }else{				
			   alert("O código para inserção em lote é : " + conteudo);   
		   }
	    }else if (qualXML == 20){		
		try{		
			var htmlText = "";	
			var pref = " Doc_";
			data = response[0].getElementsByTagName('resultado');
			htmlText += '<table width="525" border="0" cellpadding="0" cellspacing="0" class="tabela">';	
			for(i=0; i < data.length; i++){                 
			   var dtcodigo = data[i].getElementsByTagName('codDocIndx');
			   var codDocIndx = dtcodigo.item(0).firstChild.data;			   
			   var dtResp = data[i].getElementsByTagName('resposta');
			   var resposta = dtResp.item(0).firstChild.data;			   
			   htmlText +='<tr><td><B>Nº Documento :</B>'+ pref + codDocIndx+'</td><td><B>Status inserção:</B>'+ " " + resposta+'</td></tr>';			   			   
			}
			htmlText += '</table>';			   
			document.getElementById('caminho').value = '';
			document.getElementById("resultadoLote").innerHTML = htmlText;			
		 }catch(e){
		    alert('Esta dando um erro'+ e); 
	     }    
			
		}else if (qualXML == 21){		
		try{					
			var htmlText = "";
			var Ndoc = response[0].getElementsByTagName('dadosndoc');			
		    var ndocumento = Ndoc.item(0).firstChild.data;						
			var dtUsuario = response[0].getElementsByTagName('dadosusuario');
			var usuario = dtUsuario.item(0).firstChild.data;				
			var dtvia = response[0].getElementsByTagName('dadosvia');
			var via = dtvia.item(0).firstChild.data;			   
			var dtTguarda = response[0].getElementsByTagName('dadostipoGuarda');
			var tGuarda = dtTguarda.item(0).firstChild.data;
			var dataQuant = response[0].getElementsByTagName('dadosquant');
			var quan = dataQuant.item(0).firstChild.data;
			var dtDataIndx = response[0].getElementsByTagName('dadosdataIndex');
			var dataIndex = dtDataIndx.item(0).firstChild.data;
			var dtDataDoc = response[0].getElementsByTagName('dadosdataDoc');
			var dataDoc = dtDataDoc.item(0).firstChild.data;
			var dtDocDig = response[0].getElementsByTagName('dadosdocDig');
			var docDig = dtDocDig.item(0).firstChild.data;
			var dtTemp = response[0].getElementsByTagName('dadostemp');
			var temporalidade = dtTemp.item(0).firstChild.data;
																	  			   			   
			htmlText += '<table width="100%" border="0" cellspacing="1" cellpadding="1" class="tabela" id="tabela1">';
			htmlText += '<tr>';
	        htmlText += '<th colspan="4"><center>Dados Complementares</center></th>';
	        htmlText += '</tr>';					   
		 	htmlText += '<tr>';
			htmlText += '<th width="18%">Usuario:</th>';
            htmlText += '<td >&nbsp;'+usuario+'</td>';		
			htmlText += '<th >Via:</th>';
			htmlText += '<td >&nbsp;'+via+'</td>';
			htmlText += '</tr>';			   
			htmlText += '<tr>';
			htmlText += '<th>Tipo Guarda:</th>';
			htmlText += '<td width="27%">&nbsp;'+tGuarda+'</td>';			   
			htmlText += '<th width="15%">Quantidade:</th>';
			if(quan == 'vazio'){
				htmlText += '<td width="40%">&nbsp;</td>';
			}else{
				htmlText += '<td width="40%">&nbsp;'+quan+'</td>';
			}
			
			htmlText += '</tr>';			   
			htmlText += '<tr>';
			htmlText += '<th>Data Indexação:</th>';						   
			htmlText += '<td width="27%">&nbsp;'+dataIndex+'</td>';
			htmlText += '<th width="15%">Data Documento:</th>';
			htmlText += '<td width="40%">&nbsp;'+dataDoc+'</td>';
			htmlText += '</tr>';
			htmlText += '<th>Documento Digitalizado:</th>';
			if(docDig == 'vazio'){
			   htmlText += '<td width="27%">&nbsp;</td>';
			}else{
			   htmlText += '<td width="27%">&nbsp;'+docDig+'</td>';	
			}
			var ano = "";	
			if(temporalidade != 'Permanente'){
			  ano = " ano(s)";
			}		
			htmlText += '<th width="15%">Temporalidade:</th>';
			htmlText += '<td width="40%">&nbsp;'+ temporalidade + ano +'</td>';
			htmlText += '</tr>';			
			htmlText += '</table>';
			htmlText += '<br>';			
			document.getElementById('dadosCompletos'+ndocumento).innerHTML = htmlText;
		 }catch(e){
		    alert('Esta dando um erro => ' + e); 
	     }    
			
	   }else if (qualXML == 22){		
		try{		
			var inserido = '';
            var ninserido = '';
			var resp;
			var ndoc;
            data = response[0].getElementsByTagName('lps');			
            for(i=0; i < data.length; i++){                   
                      var codigo1 = data[i].getElementsByTagName('ndoc');
		      ndoc = codigo1.item(0).firstChild.data;				  			                       
                      var codigo2 = data[i].getElementsByTagName('resp');	
		      resp = codigo2.item(0).firstChild.data;
			  if(resp){
		        inserido += ndoc + ' - ';
	          }else{
	            ninserido += ndoc + ' - ';
	          }		   			  
		    }
            if(ninserido.length == 0){
            	alert('O pedido foi realizado com sucesso!');
            }else{
				alert('Houve um erro no pedido, nos documentos ' + ninseridos);				
			}
			consultarDocumentoAvancadoCliente();
		 }catch(e){
		    consultarDocumentoCliente(); 
	     }    
	   }else if (qualXML == 23){             
		try{		
		    var pref = " Doc_";			
			var htmlText = "";
			var dCodEmp = response[0].getElementsByTagName('dcodemp');			
		    var codEmp = dCodEmp.item(0).firstChild.data;
			var dNome = response[0].getElementsByTagName('dnome');			
		    var nome = dNome.item(0).firstChild.data;			
			var dLogin = response[0].getElementsByTagName('dlogin');
			var login = dLogin.item(0).firstChild.data;				
			var dNumDoc = response[0].getElementsByTagName('dnumdoc');
			var numDoc = dNumDoc.item(0).firstChild.data;			   
			var dAreaTrabalho = response[0].getElementsByTagName('dareatrabalho');
			var aTrabalho = dAreaTrabalho.item(0).firstChild.data;
			var dataPed = response[0].getElementsByTagName('ddatapedido');
			var dataPedido = dataPed.item(0).firstChild.data;
			var dHoraPedido = response[0].getElementsByTagName('dhorapedido');
			var horaPedido = dHoraPedido.item(0).firstChild.data;
			var dNomeEmpresa = response[0].getElementsByTagName('dnomeempresa');
			var NomEmp = dNomeEmpresa.item(0).firstChild.data;
			var dstatus = response[0].getElementsByTagName('dstatus');
			var dStatus = dstatus.item(0).firstChild.data;			
			var dDataConf = response[0].getElementsByTagName('ddataconf');
			var dataConf = dDataConf.item(0).firstChild.data;
			var dDatadev = response[0].getElementsByTagName('ddatadev');
			var dataDev = dDatadev.item(0).firstChild.data;
			var denvApanha = response[0].getElementsByTagName('denvapanha');
			var denvAp = denvApanha.item(0).firstChild.data;
                        var dDescricao = response[0].getElementsByTagName('ddescricao');
			var ddescricao = dDescricao.item(0).firstChild.data;
			if(denvAp == '2'){
				var drua = response[0].getElementsByTagName('drua');
				var dRua = drua.item(0).firstChild.data;
				var dnumero = response[0].getElementsByTagName('dnumero');
				var dNumero = dnumero.item(0).firstChild.data;
				var dbairro = response[0].getElementsByTagName('dbairro');
				var dBairro = dbairro.item(0).firstChild.data;
				var dcomple = response[0].getElementsByTagName('dcomplemento');
				var dComp = dcomple.item(0).firstChild.data;
				var dcep = response[0].getElementsByTagName('dcep');
				var dCep = dcep.item(0).firstChild.data;
				var dcidade = response[0].getElementsByTagName('dcidade');
				var dCidade = dcidade.item(0).firstChild.data;
				var duf = response[0].getElementsByTagName('duf');
				var dUf = duf.item(0).firstChild.data;
                                var ddataenvAp = response[0].getElementsByTagName('ddataenvap');
				var dDataEnvAp = ddataenvAp.item(0).firstChild.data;
				var dhoraenvap = response[0].getElementsByTagName('dhoraenvap');
				var dHoraEnvAp = dhoraenvap.item(0).firstChild.data;
			}													  			   			   
			htmlText += '<table width="100%" border="0" cellspacing="1" cellpadding="1" class="tabela" id="tabela1">';			   
		 	htmlText += '<tr>';
			htmlText += '<th colspan="4"><center>Dados Empréstimo</center></th>';
			htmlText += '</tr>';
			htmlText += '<tr>';			
			htmlText += '<th width="18%">Nome:</th>';
            htmlText += '<td >&nbsp;'+nome+'</td>';		
			htmlText += '<th >Login:</th>';
			htmlText += '<td >&nbsp;'+login+'</td>';
			htmlText += '</tr>';			   
			htmlText += '<tr>';
			htmlText += '<th>Nº Doc:</th>';
			htmlText += '<td width="27%">&nbsp;'+pref+numDoc+'</td>';			   
			htmlText += '<th width="15%">Área de Trabalho:</th>';
			htmlText += '<td width="40%">&nbsp;'+aTrabalho+'</td>';			
			htmlText += '</tr>';			   
			htmlText += '<tr>';
			htmlText += '<th>Data Pedido:</th>';						   
			htmlText += '<td width="27%">&nbsp;'+dataPedido+'</td>';
			htmlText += '<th width="15%">Hora Pedido:</th>';
			htmlText += '<td width="40%">&nbsp;'+horaPedido+'</td>';
			htmlText += '</tr>';
			htmlText += '<tr>';
			htmlText += '<th>Nome Empresa:</th>';		
			htmlText += '<td width="27%">&nbsp;'+NomEmp+'</td>';						
			htmlText += '<th width="15%">Status:</th>';
			htmlText += '<td width="40%">&nbsp;'+dStatus+'</td>';
			htmlText += '</tr>';			
                        htmlText += '<tr>';
                        htmlText += '<th>Descrição:</th>';                        
                        if(ddescricao == 'vazio'){
			   htmlText += '<td width="40%" colspan="4">&nbsp;</td>';
			}else{
			   htmlText += '<td width="40%" colspan="4">&nbsp;'+ddescricao+'</td>';
			}                        
                        htmlText += '</tr>';			
			if(denvAp == '2'){
				htmlText += '<tr>';
				htmlText += '<th colspan="4"><center>Endereço</center></th>';
				htmlText += '</tr>';
				htmlText += '<tr>';
				htmlText += '<th width="15%">Rua:</th>';
				htmlText += '<td colspan="4">&nbsp;'+dRua+'</td>';
				htmlText += '</tr>';
				htmlText += '<tr>';
				htmlText += '<th width="15%">Bairro:</th>';
				htmlText += '<td width="40%">&nbsp;'+dBairro+'</td>';
				htmlText += '<th width="15%">Nº:</th>';
				htmlText += '<td width="40%">&nbsp;'+dNumero+'</td>';
				htmlText += '</tr>';
				htmlText += '<tr>';				
				htmlText += '<th width="15%">Complemento:</th>';
				if(dComp == 'vazio'){
					htmlText += '<td width="40%">&nbsp;</td>';
				}else{
				    htmlText += '<td width="40%">&nbsp;'+dComp+'</td>';
				}
				htmlText += '<th width="15%">CEP:</th>';
				htmlText += '<td width="40%">&nbsp;'+dCep+'</td>';
				htmlText += '</tr>';
				htmlText += '<tr>';
				htmlText += '<th width="15%">Cidade:</th>';
				htmlText += '<td width="40%">&nbsp;'+dCidade+'</td>';
				htmlText += '<th width="15%">UF:</th>';
				htmlText += '<td width="40%">&nbsp;'+dUf+'</td>';
				htmlText += '</tr>';                                
                                htmlText += '<tr>';
				htmlText += '<th width="15%">Na Data:</th>';
				htmlText += '<td width="40%">&nbsp;'+dDataEnvAp+'</td>';
				htmlText += '<th width="15%">No Horário:</th>';
				htmlText += '<td width="40%">&nbsp;'+dHoraEnvAp+'</td>';
				htmlText += '</tr>';
			}		
			if(dataConf != 'vazio' && dataDev != 'vazio'){
			   htmlText += '<tr>';
			   htmlText += '<th>Data Confirmação:</th>';	
			   if(dataConf == 'vazio'){	
			      htmlText += '<td width="27%">&nbsp;</td>';
			   }else{
			      htmlText += '<td width="27%">&nbsp;'+dataConf+'</td>';	
			   }						
			   htmlText += '<th width="15%">Data Devolução:</th>';
			   if(dataDev == 'vazio'){
			      htmlText += '<td width="40%">&nbsp;</td>';	
			   }else{
			      htmlText += '<td width="40%">&nbsp;'+dataDev+'</td>';	
			   }			   			
			   htmlText += '</tr>';			   		   
			   htmlText += '<tr><td>&nbsp;</td><td><input name="Renovar" type="submit" class="botao1" value="Renovar" onclick="emprestarDocumento('+codEmp+','+1+','+numDoc+');"/></td>';
			   htmlText += '<td>&nbsp;</td><td><input name="Baixa" type="submit" class="botao1" value="Baixa" onclick="baixaDocumento('+numDoc+');"/></tr></td>';
			}else{				
				htmlText += '<tr><td>&nbsp;</td><td><input name="Emprestar" type="submit" class="botao1" value="Emprestar" onclick= "emprestarDocumento('+codEmp+','+2+','+numDoc+');"/></td><td>&nbsp;</td><td>&nbsp;</td><tr>';
			}
			
			htmlText += '</table>';
			htmlText += '<br>';							
			document.getElementById('respostaConsulta'+numDoc).innerHTML = htmlText;
		 }catch(e){
		    alert('Esta dando um erro'+ e); 
	     }    
	   }  
	   else if (qualXML == 24){		
		try{				
			data = response[0].getElementsByTagName('resp');	
			var resp = data.item(0).firstChild.data;
			dataAcao = response[0].getElementsByTagName('acao');	
			var acao = dataAcao.item(0).firstChild.data;
			if(acao == 2){				   
               if(resp){
			      alert('O emprestimo foi realizado com sucesso.');
			   }else{
			      alert('Houve um erro na realização do emprestimo.');
			   }			   
			}else if(acao == 1){
			    if(resp){					
				   alert('A renovação foi realizado com sucesso.');
			   }else{			   	   
			      alert('Houve um erro na realização da renovação.');
			   }			   
			}
			consultarDocumentoAvancado();			
		 }catch(e){
		 	consultarDocumento();		     
	     }    
	   }else if (qualXML == 25){		
		try{				
			data = response[0].getElementsByTagName('resp');	
			var resp = data.item(0).firstChild.data;	
			if(resp){			   
			   alert('A baixa do arquivo foi realizada com sucesso.');
			}else{			   
			   alert('Houve um erro na realização da baixa do arquivo.');
			}
		 consultarDocumentoAvancado();						
		 }catch(e){
		    consultarDocumento(); 
	     }    
	   }else if (qualXML == 26){		
		try{				
			data = response[0].getElementsByTagName('resp');	
			var resp = data.item(0).firstChild.data;	
			if(resp){
			   var url = 'http://'+localServ+'vector/list_pedido_coleta.jsp'
			   url = retiraEspacos(url);			   
			   window.location.assign(url);
			}else{			   
			   alert('Houve um erro.');
			}		 						
		 }catch(e){
		 	alert(e);		     
	     }    
	   }else if (qualXML == 27){		
		try{				
			data = response[0].getElementsByTagName('resp');	
			var resp = data.item(0).firstChild.data;
			data = response[0].getElementsByTagName('tipo');	
			var tipo = data.item(0).firstChild.data;		
			if(tipo == '1'){		
			   if(resp == 'true'){			   
			      alert('Solicitação foi cadastrada com sucesso.');				  
			   }else{			   
			      alert('Houve um erro no cadastro da solicitação.');
			   }		 		
			}				
			if(tipo == '2'){		
			   if(resp == 'true'){			   
			      alert('Valor coleta cadastrada com sucesso.');
			   }else{			   
			      alert('Houve um erro no cadastro do valor da coleta.');
			   }		 		
			}
			if(tipo == '3'){		
			   if(resp == 'true'){			   
			      alert('Valor do empréstimo cadastrado com sucesso');
			   }else{			   
			      alert('Houve um erro no cadastro do valor do empréstimo.');
			   }		 		
			}
			if(tipo == '1'){
			   document.getElementById('desc').value = '';
			}
	        document.getElementById('valorservico').value = '';
	        document.getElementById('valorbuscaentrega').value = '';			
		 }catch(e){
		 	alert(e);		     
	     }    
	   }else if (qualXML == 28){	   
		try{				
		  var htmlText = "";
		  var cor = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;						
			if(conteudo == 0){
			   htmlText += '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tabela">';
			   htmlText += '<tr>';                  
               htmlText += '<th align="center" valign="middle" colspan="2">Nenhum Serviço encontrado!</th>';  
			   			  
               htmlText += '<tr>';
			   htmlText += '</table>';			   
			   document.getElementById("servicos").innerHTML = htmlText;	  
			}else{					   	   			   								
			   data = response[0].getElementsByTagName('consultaSol');			   		   	
			   htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
			   htmlText +='<th width="123" align="center" valign="middle"><div align="center">OP&Ccedil;&Otilde;ES</div></th>';
               htmlText +='<th width="142" align="center" valign="middle"><center>DESCRIÇÃO</center></th>';
			   htmlText +='<th width="60" align="center" valign="middle"><center>VALOR</center></th>';
			   htmlText +='<th width="60" align="center" valign="middle"><center>VALOR ENTREGA</center></th>';			   			   
			   htmlText +='<th width="70" align="center" valign="middle"><center>LOGIN</center></th>';
			   htmlText +='<th width="70" align="center" valign="middle"><center>DATA</center></th>';
               htmlText += '</tr>';			   	   
			   for(i=0; i < data.length; i++){                  		         
				  var codigo1 = data[i].getElementsByTagName('dcodigo');
				  dCodigo = codigo1.item(0).firstChild.data;				  
				  var codigo2 = data[i].getElementsByTagName('ddescricao');
				  dDescricao = codigo2.item(0).firstChild.data;				   				  
				  var codigo3 = data[i].getElementsByTagName('dvalor');
				  dValor = codigo3.item(0).firstChild.data;
				  var codigo4 = data[i].getElementsByTagName('dvalorbuscaapanha');
				  dValorBuscaApanha = codigo4.item(0).firstChild.data;
				  var codigo5 = data[i].getElementsByTagName('dlogin');
				  dLogin = codigo5.item(0).firstChild.data;
				  var codigo6 = data[i].getElementsByTagName('ddata');
				  dData = codigo6.item(0).firstChild.data;
				  var tipo = document.getElementById('tipo').value;				  				  		  				  
				  /*if(dDescricao == 'Empréstimo' || dDescricao == 'Pedido Coleta'){
				     htmlText += '<td align="center" valign="middle"><a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=100&cod='+dCodigo+'&tipo='+tipo+'')+'"><img src="'+imgEditar+'" alt="Editar o Evento" width="16" height="16" border="0"/></a></td>';
				  }else{*/                  
				     htmlText += '<td align="center" valign="middle"><a href="javascript:excluirServicos('+dCodigo+','+tipo+')" onclick="return deleta()"><img src="'+imgExcluir+'" alt="Remover o Evento" width="16" height="16" border="0" /></a>&nbsp;<a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=100&cod='+dCodigo+'&tipo='+tipo+'')+'"><img src="'+imgEditar+'" alt="Editar o Evento" width="16" height="16" border="0"/></a></td>';
				  //}				  
				  htmlText += '<td><center>'+dDescricao+'</center></td>'; 
				  htmlText += '<td> <center>'+dValor+'</center></td>';				  
				  htmlText += '<td> <center>'+dValorBuscaApanha+'</center></td>';				  
				  htmlText += '<td> <center>'+dLogin+'</center></td>';
				  htmlText += '<td> <center>'+dData+'</center></td>';
				  htmlText += '</tr>'	   
			   }   
			   htmlText += '</table><br/>';
			 document.getElementById("servicos").innerHTML = htmlText;
			}		
		 }catch(e){
		 	alert(e);		     
	     }    
	   }else if (qualXML == 29){
	   	   data = response[0].getElementsByTagName('delserv');			
		   conteudo = data.item(0).firstChild.data;			
		   if(conteudo){
		   	data = response[0].getElementsByTagName('dtipo');			
		    var tipo = data.item(0).firstChild.data;	
			listarServicos(tipo);	      							   
		   }else{				
			   alert("O correu um problema na exclusão");   
		   }
	   }else if (qualXML == 30){	   		      
		  data = response[0].getElementsByTagName('consultaSol');		
		  var htmlText = '';		
		  htmlText += '<table width="370" border="0" cellspacing="1" cellpadding="0">';	
		  htmlText += '<tr>';
		  htmlText += '<td><div id="txtForm" style="text-align:right;">Descrição Doc.:</div></td>';
		  htmlText += '<td colspan="2"><input name="descricaoDoc" id="descricaoDoc" type="text" class="campo" size="42" maxlength="65" /></td>';
		  htmlText += '</tr>';
		  htmlText += '<tr>';
		  htmlText += '<td><div id="txtForm" style="text-align:right;">Formato Doc.:</div></td>';
		  htmlText += '<td colspan="2">';
		  htmlText += '<select name="formatoDoc" id="formatoDoc" class="campo">';		  		  
		  for(i=0; i < data.length; i++){                  		         		    
			 var codigo2 = data[i].getElementsByTagName('ddescricao');
      		 dDescricao = codigo2.item(0).firstChild.data;				   				  
			 htmlText += '<option value="'+dDescricao+'">'+dDescricao+'</option>';
  	      }		  
		  htmlText += '</select>';
		  htmlText += '</td>';
		  htmlText += '</tr>';
		  htmlText += '<tr>';
		  htmlText += '<td width="100"><div id="txtForm" style="text-align:right;">Selecione:</div></td>';
		  htmlText += '<td>';
		  htmlText += '<select name="menu1" id="menu1" class="campo" onchange="exibe(this.value)">';
		  htmlText += '<option value="1" selected="selected">Busca</option>';
		  htmlText += '<option value="2">Entrega</option>';
		  htmlText += '</select></td>';
		  htmlText += '<td>&nbsp;</td>';
		  htmlText += '</tr>';
		  htmlText += '</table>';
		  htmlText += '<div id="entrega" style="display:none;">';
		  htmlText += '<table width="370" border="0" cellspacing="0" cellpadding="1" style="margin-top:20px;">';
		  htmlText += '<tr>';
		  htmlText += '<td width="100"><div id="txtForm" style="text-align:right;">Data:</div></td>';
		  htmlText += '<td>';
		  htmlText += '<table border="0" cellspacing="0" cellpadding="0">';
		  htmlText += '<tr>';
		  htmlText += '<td><input name="dia" type="text" class="campo" id="dia" onKeyPress="return formata(this, \'##\', event)" style="margin-right:3px;" size="3" /></td>';
		  htmlText += '<td><input name="mes" type="text" class="campo" id="mes" onKeyPress="return formata(this, \'##\', event)" style="margin-right:3px;" size="3" /></td>';
		  htmlText += '<td><input name="ano" type="text" class="campo" id="ano" onKeyPress="return formata(this, \'####\', event)" style="margin-right:3px;" size="3" /></td>';
		  htmlText += '<td><div id="txtForm">Horário: </div></td>';
		  htmlText += '<td><input name="horario" type="text" class="campo" id="horario" onKeyPress="return formata(this, \'##:##\', event)" size="16" /></td>';
		  htmlText += '</tr>';
		  htmlText += '</table>';
		  htmlText += '</td>';
		  htmlText += '</tr>';
		  htmlText += '<tr>';
		  htmlText += '<td><div id="txtForm" style="text-align:right;">Rua/Av.</div></td>';
		  htmlText += '<td><input name="rua" type="text" class="campo" id="rua" size="42" /></td>';
		  htmlText += '</tr>';
		  htmlText += '<tr>';
		  htmlText += '<td><div id="txtForm" style="text-align:right;">Bairro:</div></td>';
		  htmlText += '<td>';
		  htmlText += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		  htmlText += '<tr>';
		  htmlText += '<td width="5%"><input name="bairro" type="text" class="campo" id="bairro" style="margin-right:3px;" size="15" /></td>';
		  htmlText += '<td width="5%"><div id="txtForm">Nº:</div></td>';
		  htmlText += '<td width="5%"><input name="numero" type="text" class="campo" id="numero" style="margin-right:3px;" size="3" /></td>';
		  htmlText += '<td width="5%"><div id="txtForm">Cep:</div></td>';
		  htmlText += '<td width="80%"><input name="cep" type="text" class="campo" id="cep" onKeyPress="return formata(this, \'#####-###\', event)" style="width:97%; _width:100%;"/></td>';
		  htmlText += '</tr>';
		  htmlText += '</table>';
		  htmlText += '</td>';
		  htmlText += '</tr>';
		  htmlText += '<tr>';
		  htmlText += '<td><div id="txtForm" style="text-align:right;">Complemento:</div></td>';
		  htmlText += '<td><input name="cpl" type="text" class="campo" id="cpl" size="42" /></td>';
		  htmlText += '</tr>';
		  htmlText += '<tr>';
		  htmlText += '<td><div id="txtForm" style="text-align:right;">Cidade:</div></td>';
		  htmlText += '<td>';
		  htmlText += '<table border="0" cellspacing="0" cellpadding="0">';
		  htmlText += '<tr>';
		  htmlText += '<td width="5%"><input name="cidade" type="text" class="campo" id="cidade" style="margin-right:5px;" size="32" /></td>';
		  htmlText += '<td width="5%"><div id="txtForm">UF:</div></td>';
		  htmlText += '<td width="90%"><input name="uf" type="text" class="campo" id="uf" style="width:95%; _width:100%;" /></td>';
		  htmlText += '</tr>';
		  htmlText += '</table>';
		  htmlText += '</td>';
		  htmlText += '</tr>';
		  htmlText += '</table>';
		  htmlText += '</div>';
		  htmlText += '<table width="370" border="0" cellspacing="1" cellpadding="0">';
		  htmlText += '<tr>';
		  htmlText += '<td width="100">&nbsp;</td>';	
		  htmlText += '<td><div style="margin-top:5px;"><input name="btn" id="btn" type="image" src="imagens/bt_ok.gif" style="display:block;" onclick="javascript:validaEmprestimo();"/></div></td>';
		  htmlText += '</tr>';
		  htmlText += '</table>';
		  htmlText += '</center>';
                  
		  document.getElementById("tpcte").innerHTML = htmlText;
	   }else if (qualXML == 31){             
		try{	
            var inserido = '';
            var ninserido = '';
			var resp;
			var ndoc;
            data = response[0].getElementsByTagName('lps');			
            for(i=0; i < data.length; i++){                   
                      var codigo1 = data[i].getElementsByTagName('ndoc');
		      ndoc = codigo1.item(0).firstChild.data;				  			                       
                      var codigo2 = data[i].getElementsByTagName('resp');	
		      resp = codigo2.item(0).firstChild.data;
			  if(resp){
		        inserido += ndoc + ' - ';
	          }else{
	            ninserido += ndoc + ' - ';
	          }		   			  
		    }
            if(ninserido.length == 0){
            	alert('O pedido foi realizado com sucesso!');
            }else{
				alert('Houve um erro no pedido, nos documentos ' + ninseridos);				
			}
			consultarDocumentoAvancadoCliente();
		 }catch(e){
                    //alert('Dentro do catch => ' + e);
		    consultarDocumentoCliente(); 
	     }    
	   }else if (qualXML == 32){		
		try{		
		    var pref = " Doc_";			
			var htmlText = "";
			var dNome = response[0].getElementsByTagName('dnome');			
		    var nome = dNome.item(0).firstChild.data;			
			var dLogin = response[0].getElementsByTagName('dlogin');
			var login = dLogin.item(0).firstChild.data;				
			var dNumDoc = response[0].getElementsByTagName('dnumdoc');
			var numDoc = dNumDoc.item(0).firstChild.data;			   
			var dAreaTrabalho = response[0].getElementsByTagName('dareatrabalho');
			var aTrabalho = dAreaTrabalho.item(0).firstChild.data;
			var dataSol = response[0].getElementsByTagName('ddatasolicitacao');
			var dataSolicit = dataSol.item(0).firstChild.data;
			var dHoraSol = response[0].getElementsByTagName('dhorasolicitacao');
			var horaSolicit = dHoraSol.item(0).firstChild.data;
			var dNomeEmpresa = response[0].getElementsByTagName('dnomeempresa');
			var NomEmp = dNomeEmpresa.item(0).firstChild.data;
			var dTipoSol = response[0].getElementsByTagName('dtiposol');
			var dTipoSolicitacao = dTipoSol.item(0).firstChild.data;
			var dDataAtend = response[0].getElementsByTagName('ddataatendimento');
			var dataAtend = dDataAtend.item(0).firstChild.data;
			var dcodSol = response[0].getElementsByTagName('dcodsol');
			var dcodSolicitacao = dcodSol.item(0).firstChild.data;
			var dbusAp = response[0].getElementsByTagName('dbuscaApanha');
			var dBuscAp = dbusAp.item(0).firstChild.data;
                        var ddesc = response[0].getElementsByTagName('ddescricao');
			var dDescricao = ddesc.item(0).firstChild.data;
			if(dBuscAp == '2'){
				var drua = response[0].getElementsByTagName('drua');
				var dRua = drua.item(0).firstChild.data;
				var dbairro = response[0].getElementsByTagName('dbairro');
				var dBairro = dbairro.item(0).firstChild.data;
				var dnumero = response[0].getElementsByTagName('dnumero');
				var dNumero = dnumero.item(0).firstChild.data;
				var dcomp = response[0].getElementsByTagName('dcomplemento');
				var dComp = dcomp.item(0).firstChild.data;
				var dcep = response[0].getElementsByTagName('dcep');
				var dCep = dcep.item(0).firstChild.data;
				var dcidade = response[0].getElementsByTagName('dcidade');
				var dCidade = dcidade.item(0).firstChild.data;
				var duf = response[0].getElementsByTagName('duf');
				var dUf = duf.item(0).firstChild.data;
                                var ddataba = response[0].getElementsByTagName('ddataba');
				var dDataBa = ddataba.item(0).firstChild.data;
				var dhoraba = response[0].getElementsByTagName('dhoraba');
				var dHoraBa = dhoraba.item(0).firstChild.data;
			}
			//htmlText += '<br/>';											  			   			   
			htmlText += '<table width="100%" border="0" cellspacing="1" cellpadding="1" class="tabela" id="tabela1">';			   
		 	htmlText += '<tr>';
			htmlText += '<th colspan="4"><center>Solicitacao Documento</center></th>';
			htmlText += '</tr>';
			htmlText += '<tr>';			
			htmlText += '<th width="18%">Nome:</th>';
            htmlText += '<td >&nbsp;'+nome+'</td>';		
			htmlText += '<th >Login:</th>';
			htmlText += '<td >&nbsp;'+login+'</td>';
			htmlText += '</tr>';			   
			htmlText += '<tr>';
			htmlText += '<th>Nº Doc:</th>';
			htmlText += '<td width="27%">&nbsp;'+pref+numDoc+'</td>';			   
			htmlText += '<th width="15%">Área de Trabalho:</th>';
			htmlText += '<td width="40%">&nbsp;'+aTrabalho+'</td>';			
			htmlText += '</tr>';			   
			htmlText += '<tr>';
			htmlText += '<th>Data Pedido:</th>';						   
			htmlText += '<td width="27%">&nbsp;'+dataSolicit+'</td>';
			htmlText += '<th width="15%">Hora Pedido:</th>';
			htmlText += '<td width="40%">&nbsp;'+horaSolicit+'</td>';
			htmlText += '</tr>';
			htmlText += '<tr>';
			htmlText += '<th>Nome Empresa:</th>';		
			htmlText += '<td width="27%">&nbsp;'+NomEmp+'</td>';						
			htmlText += '<th width="15%">Tipo Solicitacao:</th>';
			htmlText += '<td width="40%">&nbsp;'+dTipoSolicitacao+'</td>';
			htmlText += '</tr>';
	                htmlText += '<tr>';
                        htmlText += '<th>Descrição:</th>';                        	
                        if(dDescricao == 'vazio'){
                           htmlText += '<td width="27%" colspan="4">.</td>';						
                        }else if(dDescricao.length < 1){
                           htmlText += '<td width="27%" colspan="4">.</td>';						
                        }else{
                           htmlText += '<td width="27%" colspan="4">&nbsp;'+dDescricao+'</td>';						
                        }
                        htmlText += '</tr>';
            if(dBuscAp == '2'){
				htmlText += '<tr>';
				htmlText += '<th colspan="4"><center>Endereço</center></th>';
				htmlText += '</tr>';
				htmlText += '<tr>';
				htmlText += '<th>Rua:</th>';						   
				htmlText += '<td colspan="4">&nbsp;'+dRua+'</td>';				
				htmlText += '</tr>';
				htmlText += '<tr>';
				htmlText += '<th>Bairro:</th>';		
				htmlText += '<td width="27%">&nbsp;'+dBairro+'</td>';						
				htmlText += '<th width="15%">Nº:</th>';
				htmlText += '<td width="40%">&nbsp;'+dNumero+'</td>';
				htmlText += '</tr>';
				htmlText += '<tr>';
				htmlText += '<th>Complemento:</th>';
				if(dComp == 'vazio'){
					htmlText += '<td width="27%">&nbsp;</td>';
				}else{
					htmlText += '<td width="27%">&nbsp;'+dComp+'</td>';
				}										
				htmlText += '<th width="15%">CEP:</th>';
				htmlText += '<td width="40%">&nbsp;'+dCep+'</td>';
				htmlText += '</tr>';
				htmlText += '<tr>';
				htmlText += '<th>Cidade:</th>';		
				htmlText += '<td width="27%">&nbsp;'+dCidade+'</td>';						
				htmlText += '<th width="15%">UF:</th>';
				htmlText += '<td width="40%">&nbsp;'+dUf+'</td>';
				htmlText += '</tr>';
                                htmlText += '<tr>';
				htmlText += '<th>Na Data:</th>';		
				htmlText += '<td width="27%">&nbsp;'+dDataBa+'</td>';						
				htmlText += '<th width="15%">No Horario:</th>';
				htmlText += '<td width="40%">&nbsp;'+dHoraBa+'</td>';
				htmlText += '</tr>';
			} 					
			if(dataAtend != 'vazio'){
				alert('Problema na linha qualXML32');			   
			}else{				
				htmlText += '<tr><td>&nbsp;</td><td><input name="Atender" type="button" class="botao1" value="Atender" onclick= "atenderSolicitacao('+dcodSolicitacao+', '+numDoc+', \''+dTipoSolicitacao+'\');"/></td><td>&nbsp;</td><td>&nbsp;</td><tr>';
			}
			htmlText += '</table>';
			htmlText += '<br>';							
			document.getElementById('respostaConsulta'+numDoc).innerHTML = htmlText;
		 }catch(e){
		    alert('Esta dando um erro'+ e); 
	     }    
	   }else if (qualXML == 33){		
		try{					
			data = response[0].getElementsByTagName('respdesc');	
			var resp = data.item(0).firstChild.data;				   
            if(resp){
			   alert('O aviso de descarte foi realizado com sucesso.');
			}else{
			   alert('Houve um erro na realização do aviso de descarte.');
			}		
			consultarDocumentoAvancado();
		 }catch(e){
		    consultarDocumento(); 
	     }   
	   }else if (qualXML == 34){		
		try{					
			data = response[0].getElementsByTagName('resp');	
			var resp = data.item(0).firstChild.data;				   
            if(resp){
			   alert('A confirmação do descarte foi realizada com sucesso.');
			}else{
			   alert('Houve um erro na realização da confirmação.');
			}		
			consultarDocumentoAvancadoCliente();			
		 }catch(e){
		    consultarDocumentoCliente();			 
	     }   
	   }else if (qualXML == 35){		
		try{					
			data = response[0].getElementsByTagName('respdesc');	
			var resp = data.item(0).firstChild.data;				   
            if(resp){
			   alert('Descarte realizada com sucesso.');
			}else{
			   alert('Houve um erro na realização do Descarte.');
			}		
			consultarDocumentoAvancado();
		 }catch(e){
		    consultarDocumento(); 
	     }   
	   }else if (qualXML == 36){		
		try{					
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			data = response[0].getElementsByTagName('tipo');			
			tipo = data.item(0).firstChild.data;
			if(conteudo == 0){
			   htmlText += '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
			   htmlText += '<tr>';                  
               htmlText +=  '<td bgcolor="#066F9B"><p style="color:#FFFFFF"><b><center>Nenhum Documento encontrado!</center></b></p></td>';
               htmlText += '<tr>';
			   htmlText += '</table>';			   

			 document.getElementById("resconsulta").innerHTML = htmlText;	  
			}else{				
			   data = response[0].getElementsByTagName('historico');			   		                  	
			   var pref = 'Doc_';	
			   htmlText += '<table width="100%" border="0" cellspacing="1" cellpadding="1">';
	           htmlText += '<tr>';
			   htmlText +='<td width="15%" class="txt"><b>&nbsp;N&ordm; Doc :</b></td>';
               if(tipo == '0'){
			     htmlText +='<td width="15%" class="txt"><b>&nbsp;N&ordm; Caixa:</b></td>';
			   }
			   htmlText +='<td width="30%" class="txt"><b>&nbsp;A&ccedil;&atilde;o:</b></td>';
			   htmlText +='<td width="20%" class="txt"><b>&nbsp;Login:</b></td>';
			   htmlText +='<td width="20%" class="txt"><b>&nbsp;Data:</b></td>';
			   if(tipo == '0'){
				 htmlText +='<td class="txt"><b>&nbsp;Tipo-solicita&ccedil;&atilde;o:</b></td>';
			   }
			   htmlText +='</tr>';			   	   
			   for(i=0; i < data.length; i++){			                    
				  var dtNumCaixa = data[i].getElementsByTagName('znumcaixa');
				  numCaixa = dtNumCaixa.item(0).firstChild.data;
				  var dtNumDoc = data[i].getElementsByTagName('znumdoc');
				  numDoc = dtNumDoc.item(0).firstChild.data;
				  var dtData = data[i].getElementsByTagName('zdata');
				  dataOc = dtData.item(0).firstChild.data;
				  var dtLogin = data[i].getElementsByTagName('zlogin');
				  login = dtLogin.item(0).firstChild.data;
				  var dtTipoSol = data[i].getElementsByTagName('ztiposol');
				  tipoSol = dtTipoSol.item(0).firstChild.data;				    
                  var dtAcao = data[i].getElementsByTagName('zacao');
				  acao = dtAcao.item(0).firstChild.data;				
                  switch (acao) {
	                 case "1":
		                acao = 'Indexação';
		                break
	                 case "2":
		                acao = 'Pedido Emprestimo';
		                break
	                 case "3":
		                acao = 'Emprestimo';
		                break
					 case "4":
		                acao = 'Renovação';
		                break
					 case "5":
		                acao = 'Devolução';
		                break
					 case "6":
		                acao = 'Aviso Descarte';
		                break
					 case "7":
		                acao = 'Confirmação Descarte';
		                break
					 case "8":
		                acao = 'Descarte';
		                break
					 case "9":
		                acao = 'Pedido Solicitação';
		                break
					 case "10":
		                acao = 'Atendimento Solicitação';
		                break
					 case "11":
		                acao = 'Emprestimo';
		                break
					 case "12":
		                acao = 'Emprestimo';
		                break
					 case "13":
		                acao = 'Emprestimo';
		                break
					 case "14":
		                acao = 'Emprestimo';
		                break
					 case "100":
		                acao = 'Pedido Coleta';
		                break
					 case "101":
		                acao = 'Processando';
		                break
				     case "102":
		                acao = 'Atendido';
		                break		
					 case "103":
		                acao = 'Devolvido p/ verificação';
		                break
	                 default:
		                acao = "Não foi encontrado correspondecia para esta ação.";			  
				  }
				  
				  htmlText += '<tr>';
				  htmlText +='<td bgcolor="#F4F4F4"><p>'+numDoc+'</p></td>';
				  if(tipo == '0'){
				    htmlText +='<td bgcolor="#F4F4F4"><p>'+numCaixa+'</p></td>';
				  }
				  htmlText +='<td bgcolor="#F4F4F4"><p>'+acao+'</p></td>';
				  htmlText +='<td bgcolor="#F4F4F4"><p>'+login+'</p></td>';
				  htmlText +='<td bgcolor="#F4F4F4"><p>'+dataOc+'</p></td>';
				  if(tipo == '0'){
				  	if(tipoSol == 'vazio'){
				      htmlText +='<td bgcolor="#F4F4F4"><p>&nbsp;</p></td>';
					}else{
					  htmlText +='<td bgcolor="#F4F4F4"><p>'+tipoSol+'</p></td>';	
					}
				  }
				  htmlText +='</tr>';				  			      
			   }
               htmlText += '<tr>';			   			   
			   htmlText += '<td colspan="2"><img src="imagens/transp.gif" alt="" height="10" width="10" /></td>';
			   htmlText += '</tr>';
			   htmlText += '</table>';
			document.getElementById("resconsulta").innerHTML = htmlText;   
			}
			}catch(e){
		    alert('ERRO : '+ e.print); 
	     }   
	   }else if (qualXML == 37){		
		try{					
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			data = response[0].getElementsByTagName('tipo');			
			tipo = data.item(0).firstChild.data;			
			if(conteudo == 0){
			   htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			  htmlText += '<tr>';
               htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhum documento encontrado.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table>';
			 document.getElementById("resconsulta").innerHTML = htmlText;	  
			}else{
				htmlText += '<table width="525" border="0" cellspacing="1" cellpadding="1" class="tabela">';
				  htmlText += '<tr>';
				  if(tipo == '1'){
				  	htmlText +='<th align="center">Cod Pedido :</th>';
				  }else{
			        htmlText +='<th align="center">N&ordm; Doc :</th>';
					htmlText +='<th align="center">N&ordm; Caixa :</th>';
				  }                  
				  htmlText +='<th align="center">A&ccedil;&atilde;o:</th>';
				  htmlText +='<th align="center">Login:</th>';
				  htmlText +='<th align="center">Data:</th>';
				  if(tipo == '0'){
				    htmlText +='<th align="center">solicita&ccedil;&atilde;o:</th>';
				  }
				  htmlText += '</tr>';				
			   data = response[0].getElementsByTagName('historico');			   		                  	
			   var pref = 'Doc_';		   
			   for(i=0; i < data.length; i++){			                 
			      var dtNumCaixa = data[i].getElementsByTagName('znumcaixa');
				  numCaixa = dtNumCaixa.item(0).firstChild.data;   
				  var dtNumDoc = data[i].getElementsByTagName('znumdoc');
				  numDoc = dtNumDoc.item(0).firstChild.data;
				  var dtData = data[i].getElementsByTagName('zdata');
				  dataOc = dtData.item(0).firstChild.data;
				  var dtLogin = data[i].getElementsByTagName('zlogin');
				  login = dtLogin.item(0).firstChild.data;
				  var dtTipoSol = data[i].getElementsByTagName('ztiposol');
				  tipoSol = dtTipoSol.item(0).firstChild.data;				    
                  var dtAcao = data[i].getElementsByTagName('zacao');
				  acao = dtAcao.item(0).firstChild.data;				
                  switch (acao) {
	                 case "1":
		                acao = 'Indexação';
		                break
	                 case "2":
		                acao = 'Pedido Emprestimo';
		                break
	                 case "3":
		                acao = 'Emprestimo';
		                break
					 case "4":
		                acao = 'Renovação';
		                break
					 case "5":
		                acao = 'Devolução';
		                break
					 case "6":
		                acao = 'Aviso Descarte';
		                break
		                break
					 case "8":
		                acao = 'Descarte';
		                break
					 case "9":
		                acao = 'Pedido Solicitação';
		                break
					 case "10":
		                acao = 'Atendimento Solicitação';
		                break
					 case "11":
		                acao = 'Emprestimo';
		                break
					 case "12":
		                acao = 'Emprestimo';
		                break
					 case "13":
		                acao = 'Emprestimo';
		                break
					 case "14":
		                acao = 'Emprestimo';
		                break
					 case "100":
		                acao = 'Pedido Coleta';
		                break
					 case "101":
		                acao = 'Processando';
		                break
				     case "102":
		                acao = 'Atendido';
		                break		
					 case "103":
		                acao = 'Devolvido p/ verificação';
		                break
	                 default:
		                acao = "Não foi encontrado correspondecia para esta ação.";			  
				  }
				  
				  htmlText += '<tr>';
				  htmlText +='<td align="center" width="25px">'+numDoc+'</td>';
                  if(tipo == '0'){
				  htmlText +='<td align="center" width="50px">'+numCaixa+'</td>';
				  }
                  htmlText +='<td align="center" width="150px">'+acao+'</td>';			      
                  htmlText +='<td align="center" width="100px">'+login+'</td>';
                  htmlText +='<td align="center" width="100px">'+dataOc+'</td>';			      
				  if(tipo == '0'){
				    if(tipoSol != 'vazio'){			  						
                       htmlText +='<td align="center" width="100px">'+tipoSol+'</td>';			         
				    }else{
				  	   htmlText +='<td align="center" width="100px">&nbsp;</td>';
				    }				  
				  }			      
			   }
			   htmlText += '</tr>';
               //htmlText += '<tr>';			   			   
			   //htmlText += '<td colspan="2"><img src="imagens/transp.gif" alt="" height="10" width="10" /></td>';
			   //htmlText += '</tr>';
			   htmlText += '</table><br/>';
			document.getElementById("resconsulta").innerHTML = htmlText;   
			}
			}catch(e){
		    alert('ERRO : '+ e.print); 
	     }   
	   }else if(qualXML == 38){ // listar transações.	   		
			var htmlText = "";			
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
                  htmlText += '<br>';
                      htmlText +='<th align="center" valign="middle" colspan="2">Nenhum serviço encontrado.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table><br/>';
			 document.getElementById("tabela2").innerHTML = htmlText;	  
			}else{				
			 try{  
			   data = response[0].getElementsByTagName('servpedcol');	   	
			   var prefCx = 'CX_';
			   //htmlText +='<br/>';
			   htmlText +='<table width="525" border="0" cellspacing="1" cellpadding="1" class="tabela">';
			      htmlText +='<tr>';
			      htmlText +='<th style="width:25px;" align="center">Cód.</th>';
                              htmlText +='<th style="width:75px;" align="center">Solicitante</th>';
				  htmlText +='<th style="width:75px;" align="center">Atendimento</th>';
				  htmlText += '<th style="width:75px;" align="center">Cliente</th>';
				  htmlText += '<th style="width:75px;" align="center">Serviço</th>';
				  htmlText += '<th style="width:75px;" align="center">Valor</th>';
				  htmlText += '<th style="width:75px;" align="center">Valor Apanha</th>';			      
			      htmlText +='</tr>';				   	   
			   for(i=0; i < data.length; i++){                 
			      var dcod = data[i].getElementsByTagName('wcod');
				  cod = dcod.item(0).firstChild.data;
				  var dDataAtend = data[i].getElementsByTagName('wdataatend');
				  dtAtend = dDataAtend.item(0).firstChild.data;
				  var dCliente = data[i].getElementsByTagName('wcliente');
				  cliente = dCliente.item(0).firstChild.data;							  
				  var dTipoServ = data[i].getElementsByTagName('wtiposerv');
				  tipoServ = dTipoServ.item(0).firstChild.data;
				  var dValor = data[i].getElementsByTagName('wvalor');
				  valor = dValor.item(0).firstChild.data;
				  var dValorApanha = data[i].getElementsByTagName('wvalorapanha');
				  valorApanha = dValorApanha.item(0).firstChild.data;
                                  var dNome = data[i].getElementsByTagName('wnome');
				  nome = dNome.item(0).firstChild.data;
				  htmlText +='<tr>';
				  htmlText +='<td align="center">'+cod+'</td>';
                              htmlText +='<td align="center">'+nome+'</td>';			     
			      htmlText +='<td align="center">'+dtAtend+'</td>';
			      htmlText += '<td align="center">'+cliente+'</td>';
			      htmlText += '<td align="center">'+tipoServ+'</td>';
			      htmlText += '<td align="center">'+valor+'</td>';
				  if(valorApanha != 'vazio'){			       
			        htmlText += '<td align="center">'+valorApanha+'</td>';			        	
				  }
			      htmlText += '</tr>';
			      				  
			         
			}		
			htmlText += '</table><br/>';
			document.getElementById("tabela2").innerHTML = htmlText;	
		}catch(e){
		alert('Erro catch ' + e);	
		}		
		}		
	}else if (qualXML == 39){		
		try{		
		    var pref = " Cx_";			
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;	
			if(conteudo == 0){
				htmlText +='<table width="100%" border="0" cellspacing="1" cellpadding="1">';
			    htmlText +='<tr>';
			    htmlText +='<td width="22%" class="txt"><b>&nbsp;&Aacute;rea:</b></td>';
			    htmlText +='<td colspan="3" bgcolor="#F4F4F4"><p>'+DadosArea+'</p></td>';
			    htmlText +='</tr>';
				htmlText += '</table><br/>';
			 document.getElementById("cx").innerHTML = htmlText;	  
			}else{				
			   data = response[0].getElementsByTagName('listaexcx');
			   htmlText +='<table width="100%" border="0" cellspacing="1" cellpadding="1">';
			   i = 0;
			   while(i < data.length){ 
			      htmlText +='<tr>';
				  j = 0;
				  while(j < 4){
				  	if(i < data.length){
					   var ncx = data[i].getElementsByTagName('ncx');
				       num = ncx.item(0).firstChild.data;
					   var ncx = data[i].getElementsByTagName('codcx');
				       cod = ncx.item(0).firstChild.data;
					   var url = localServ+'TrataMemotec?met=117&cx='+cod+'" target="_blank">'+pref+num+'</a>';					   
	                   url = retiraEspacos(url);				   
					   htmlText +='<td bgcolor="#F4F4F4"><p><a href="http://'+url+'</p></td>';					   
					   i++;
					   j++;
					}else{
						break;
					}
				  }  
				  htmlText +='</tr>';     
			   }		      
			document.getElementById("cx").innerHTML = htmlText;
			}
			}catch(e){
		    alert('Esta dando um erro'+ e); 
	     }
	    }else if (qualXML == 40){		
		try{                        	
			data = response[0].getElementsByTagName('resp');	
			var resp = data.item(0).firstChild.data;				
			if(resp == 'true'){	
                           document.getElementById('ncaixa').value = '';  		   	                           
			   alert('Já existe uma caixa com este numero!')                           		   
			}	 						
		 }catch(e){
		 	alert(e);		     
	     }    
	   }else if (qualXML == 41){			   
		try{				
			data = response[0].getElementsByTagName('msg');	
			var msge = data.item(0).firstChild.data;							
			if(msge == '0'){   	   
			   alert('e-mail enviado com sucesso.'); 
			}else{
				alert('não foi encontrado no cadastro este usuário.')
			}	 						
		 }catch(e){
		 	alert(e);		     
	     }    
	   }else if (qualXML == 42){			   
		var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			  htmlText += '<tr>';
               htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhum documento encontrado.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table>';
			 document.getElementById("consultaAdm").innerHTML = htmlText;	  
			}else{				   	   			   								
			   data = response[0].getElementsByTagName('consultaAdimim');
			   var pref = 'Doc_';
			   var prefCaixa = 'Cx_';
			   var espaco = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			   htmlText +='<table width="525" border="0" cellspacing="1" cellpadding="1" class="tabela" id="tabela1">';
			   htmlText +='<tr>';
			   htmlText +='<th width="150"><b>Ítem Documental</b></th>';
			   htmlText += '<th width="125"><b>Complemento</b></th>';
			   htmlText += '<th width="125"><b>Descritor</b></th>';
			   htmlText += '<th width="65" align="center"><b>N&ordm; Doc.</b></th>';
			   htmlText += '<th width="60" align="center"><b>N&ordm; Cx.</b></th>';
			   htmlText +='</tr>';
			   for(i=0; i < data.length; i++){
				  var codigo2 = data[i].getElementsByTagName('dadositem');
				  dadosItemDoc = codigo2.item(0).firstChild.data;				  				  
				  var codigo3 = data[i].getElementsByTagName('dadoscomplemento');
				  dadosComplemento = codigo3.item(0).firstChild.data;
				  var codigo4 = data[i].getElementsByTagName('dadosdescritor');
				  dadosDescritor = codigo4.item(0).firstChild.data;				  	
				  var codigo5 = data[i].getElementsByTagName('dadosndocumento');
				  dadosNDocumento = codigo5.item(0).firstChild.data;	
				  var codigo6 = data[i].getElementsByTagName('dadosncaixa');
				  dadosCx = codigo6.item(0).firstChild.data;
				                           
			      htmlText +='<tr>';                 
			      htmlText += '<td>'+dadosItemDoc+'</td>';
				  htmlText += '<td>'+dadosComplemento+'</td>';
				  if(dadosDescritor == 'vazio'){
			         htmlText += '<td>.</td>';
				  }else{
				  	 htmlText += '<td>'+dadosDescritor+'</td>';
				  }	      
				  htmlText += '<td>'+ pref + dadosNDocumento +'</td>';				  
			      htmlText += '<td>'+ prefCaixa + dadosCx+'</td>';
				  htmlText += '</tr>';
			}   
			htmlText += '</table>';
			htmlText += '<div id="ultlinha" align="center">';
			   htmlText += '<input name="voltar" type="submit" class="botao1" value="<" onclick= "javascript:consultarDocumentoResumida('+menos+');"/>'+espaco;
			   if(data.length >= 20){ 
			      htmlText += '<input name="ir" type="submit" class="botao1" value=">" onclick= "javascript:consultarDocumentoResumida('+mais+');"/>';
			   }
			   htmlText += '</div>';
		   document.getElementById("consultaAdm").innerHTML = htmlText;		
		}    
	   }else if (qualXML == 43){			   
	        var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo == 0){
			  htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			  htmlText += '<tr>';
               htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhum documento encontrado.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table>';
			 document.getElementById("temporalidade").innerHTML = htmlText;	  
			}else{				   	   			   								
			   data = response[0].getElementsByTagName('consultaTemporalidade');
			   htmlText +='<table width="525" border="0" cellspacing="1" cellpadding="1" class="tabela" id="tabela1">';
			   htmlText +='<tr>';
			   htmlText +='<th style="border-bottom:solid 1px #FFF;" width="75" valign="middle"><center><b>opções</b></center></th>';
			   htmlText +='<th style="border-bottom:solid 1px #FFF;" width="150" valign="middle"><center><b>Área</b></center></th>';
			   htmlText += '<th style="border-bottom:solid 1px #FFF;" width="150" valign="middle"><center><b>Grupo de Assunto</b></center></th>';
			   htmlText += '<th style="border-bottom:solid 1px #FFF;" width="150" valign="middle"><center><b>Item</b></center></th>';			   
                           htmlText += '<th style="border-bottom:solid 1px #FFF;" width="150" valign="middle"><center><b>Temp</b></center></th>';
			   htmlText +='</tr>';
			   for(i=0; i < data.length; i++){
				  var codigo2 = data[i].getElementsByTagName('tarea');
				  dadosArea = codigo2.item(0).firstChild.data;				  				  
				  var codigo3 = data[i].getElementsByTagName('tga');
				  dadosGa = codigo3.item(0).firstChild.data;
				  var codigo4 = data[i].getElementsByTagName('titem');
				  dadosItem = codigo4.item(0).firstChild.data;
				  var codigo5 = data[i].getElementsByTagName('tcod');
				  dadosCod = codigo5.item(0).firstChild.data;
				  var codigo6 = data[i].getElementsByTagName('temp');
				  dadosEmp = codigo6.item(0).firstChild.data;						  
                  var codigo7 = data[i].getElementsByTagName('ttemporalidade');
				  dadosTemporalidade = codigo7.item(0).firstChild.data;
			      htmlText +='<tr>';     
				  dadosAreaPar = "\'"+dadosArea+"\'";
				  dadosGaPar = "\'"+dadosGa+"\'";
				  dadosItemPar = "\'"+dadosItem+"\'";                              
				  htmlText += '<td align="center" valign="middle"><a href="javascript:delTemporalidade('+dadosCod+','+dadosEmp+');" onclick="return deletaTemporalidade()"><img src="'+imgExcluir+'" alt="Remover o Evento" width="16" height="16" border="0" /></a>&nbsp;<a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=139&codTemp='+dadosCod+'')+'"><img src="'+imgEditar+'" alt="Editar o Evento" width="16" height="16" border="0" /></a></td>';
				                                                    
			      htmlText += '<td align="center">'+dadosArea+'</td>';
				  htmlText += '<td align="center">'+dadosGa+'</td>';                                  
				  htmlText += '<td align="center">'+dadosItem +'</td>';
                  htmlText += '<td align="center">'+dadosTemporalidade +'</td>';
				  htmlText += '</tr>';	
			}   
			htmlText += '</table>';        
                        document.getElementById('ano').value = '';                 
                        document.getElementById('ref').value = '';
                        document.getElementById('permanente').disabled = false;
			document.getElementById("temporalidade").innerHTML = htmlText;		
		}    

		}else if (qualXML == 44){			   
	        var htmlText = "";
			data = response[0].getElementsByTagName('resp');			
			resp = data.item(0).firstChild.data;				
			document.getElementById("apg").innerHTML = htmlText;
		}else if (qualXML == 45){			
			data = response[0].getElementsByTagName('resposta');			
			resp = data.item(0).firstChild.data;
			
			if(resp =='1'){
			  alert('Contato enviado com sucesso.');	
			}				
		document.getElementById('nome').value = "";
        document.getElementById('emp').value = "";
        document.getElementById('ddd').value = "";
        document.getElementById('telefone').value = "";
        document.getElementById('email').value = "";   
        document.getElementById('mensagem').value = "";
		}else if (qualXML == 46){			
			data = response[0].getElementsByTagName('resposta');			
			resp = data.item(0).firstChild.data;	
			document.getElementById( "msg" ).innerHTML = '';		
			if(resp =='true'){
			  alert('Arquivo Gravado com sucesso');			  
			  var url = 'http://'+localServ+'vector/exportacao/dadosexportados.xls';			  
			  url = retiraEspacos(url);			   
			  //window.location.assign(url);
			  var html = "<div align=\"left\"><a href=exportacao/dadosexportados.xls target=\"_blank\">Visualizar</a>";
			  document.getElementById("exportacao").innerHTML = html;
			}else{
			  document.getElementById("exportacao").innerHTML = "";
			  alert('Houve um erro na gravação do arquivo ou a consulta não pode encontrar resultados.');			  	
			}
		}else if (qualXML == 47){			
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){
			 htmlText += '<select name="us" id="us" tabindex="1" style="margin-top:2px;margin-bottom:2px;margin-left:4px;">';
			 htmlText += '<option value="0"></option>';
             htmlText += '</select>';                      
			 document.getElementById("log").innerHTML = htmlText;	  
			}else{				
			   data = response[0].getElementsByTagName('contato');			   
			   htmlText += '<select name="us" id="us" tabindex="1" style="margin-top:2px;margin-bottom:2px;margin-left:4px;">';
			   htmlText += '<option value="0"></option>';			   			   
			   for(i=0; i < data.length; i++){
				  var dtcodigo = data[i].getElementsByTagName('codContato');
				  codigo = dtcodigo.item(0).firstChild.data;				  
                  var dtnome = data[i].getElementsByTagName('nome');
				  nome = dtnome.item(0).firstChild.data;                  
				  htmlText += '<option value="'+codigo+'">'+nome+'</option>';
			   }			   			   
			   htmlText += '</select>';
			document.getElementById("log").innerHTML = htmlText;		
			}
		}else if(qualXML == 48){ // listar Item	Cliente                        
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;                        
			if(conteudo == 0){              			
			   htmlText += '<select name="item" id="item">';
                           htmlText += '<option value="0"></option>';                          
                           htmlText += '</select>';
			   document.getElementById("itar").innerHTML = htmlText;			 	  
			}else{                         				
			   data = response[0].getElementsByTagName('Item');			   
			   htmlText += '<select name="item" class="campo" id="item">';
                           htmlText += '<option value="0"></option>';
			   for(i=0; i < data.length; i++){                                   
				  var dtcodigo = data[i].getElementsByTagName('codItem');
				  var codigoItem = dtcodigo.item(0).firstChild.data;				  
                                  var dtdescricao = data[i].getElementsByTagName('descricao');
				  var descricao = dtdescricao.item(0).firstChild.data;
				  htmlText += '<option value="'+codigoItem+'">'
                                  htmlText += descricao+'</option>'
			   } 			   
			   htmlText += '</select>';                           
			   document.getElementById("itar").innerHTML = htmlText;   
			}			
		}else if(qualXML == 49){  // listar areas temporalidade
                   var htmlText = "";                    
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;                        
			if(conteudo == 0){              						                                                      
			   document.getElementById("areaTemp").innerHTML = ".";			 	  
			}else{                         				
			   data = response[0].getElementsByTagName('areaTemp');			   			   
			   for(i=0; i < data.length; i++){                                   
				  var dtcodigo = data[i].getElementsByTagName('codArea');
				  var codigoArea = dtcodigo.item(0).firstChild.data;				  
                                  var dtdescricao = data[i].getElementsByTagName('descricao');
				  var descricao = dtdescricao.item(0).firstChild.data;				 
                                  htmlText += '<label style="width:180px; height:20px; float:left;"><input type="checkbox" name= "'+descricao+'" id="'+descricao+'" value="'+codigoArea+'" />'+descricao+'</label>';
			   } 			   			                              
			   document.getElementById("areaTemp").innerHTML = htmlText;   
			}
                }else if(qualXML == 50){  // listar areas temporalidade
                   var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){              			
			   htmlText += '<select name="item" id="item">';
                           htmlText += '<option value="0"></option>';                          
                           htmlText += '</select>';
			   document.getElementById("ditem").innerHTML = htmlText;			 	  
			}else{				
			   data = response[0].getElementsByTagName('Item');			   			   
                           htmlText += '<select name="item" id="item">';
                           htmlText += '<option value="0"></option>';                           
			   for(i=0; i < data.length; i++){                 
				  var dtcodigo = data[i].getElementsByTagName('codItem');
				  var codigoItem = dtcodigo.item(0).firstChild.data;				  
                                  var dtdescricao = data[i].getElementsByTagName('descricao');
				  var descricao = dtdescricao.item(0).firstChild.data;
				  htmlText += '<option value="'+codigoItem+'"'+codigoItem+'>'
                                  htmlText += descricao+'</option>'
			   } 			   
			   htmlText += '</select>';
			   document.getElementById("ditem").innerHTML = htmlText;   
			}
                }else if(qualXML == 51){ // listar Item				
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){              			
			   htmlText += '<select name="area" id="area">';
                           htmlText += '<option value="0"></option>';                          
                           htmlText += '</select>';
			   document.getElementById("areaTemp").innerHTML = htmlText;			 	  
			}else{				
			   data = response[0].getElementsByTagName('areaTemp');			   
			   htmlText += '<select name="area" id="area" tabindex="1" onchange="javascript:buscaItensTemporalidade(this.value);" style="margin-left:4px;margin-top:2px;margin-bottom:2px;">';                           
                           htmlText += '<option value="0"></option>';                           
			   for(i=0; i < data.length; i++){                 
				  var dtcodigo = data[i].getElementsByTagName('codArea');
				  var codigoArea = dtcodigo.item(0).firstChild.data;				  
                                  var dtdescricao = data[i].getElementsByTagName('descricao');
				  var descricao = dtdescricao.item(0).firstChild.data;
				  htmlText += '<option value="'+codigoArea+'"'+codigoArea+'>'
                                  htmlText += descricao+'</option>'
			   } 			   
			   htmlText += '</select>';
			   document.getElementById("areaTemp").innerHTML = htmlText;   
			}			
		}else if(qualXML == 52){ // pedido Descritivo			
			var htmlText = "";
			data = response[0].getElementsByTagName('codSol');			
			codSol = data.item(0).firstChild.data;
			if(codSol == 0){              			
			   htmlText += '<h3>Houve um erro no pedido, entre em contato com a Memotec.</h3>';                           
			   document.getElementById("conteudoInterno").innerHTML = htmlText;			 	  
			}else{				
			   htmlText += '<br/><br/><br/><h3>Pedido realizado com sucesso. Guarde o numero do pedido: '+codSol+'</h3>';
			   document.getElementById("conteudoInterno").innerHTML = htmlText;   
			}			
		}else if(qualXML == 53){ // lista pedido Descritivo			
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
                  htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhuma pedido encontrado.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table><br/>';
			 document.getElementById("listSol").innerHTML = htmlText;	  
			}else{				
			   data = response[0].getElementsByTagName('solDesc');			   
			   htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="1" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
			   htmlText +='<th width="80" align="center" valign="middle"><div align="center">OP&Ccedil;&Otilde;ES</div></th>';
               htmlText +='<th><div align="center">COD</div></th>';
               htmlText +='<th><div align="center">LOGIN</div></th>';
			   htmlText +='<th><div align="center">EMPRESA</div></th>';
			   htmlText +='<th><div align="center">STATUS</div></th>';
			   htmlText +='<th><div align="center">DATA PEDIDO</div></th>';
               htmlText += '</tr>';			   	   
			   for(i=0; i < data.length; i++){                 
				  var dtcodigo = data[i].getElementsByTagName('codPedDesc');
				  codigo = dtcodigo.item(0).firstChild.data;
				  var dLogin = data[i].getElementsByTagName('login');
				  login = dLogin.item(0).firstChild.data;
				  var dNomeEmp = data[i].getElementsByTagName('nomeEmp');
				  nomeEmp = dNomeEmp.item(0).firstChild.data;
				  var dStatus = data[i].getElementsByTagName('status');
				  var status = dStatus.item(0).firstChild.data;
				  var dDataped = data[i].getElementsByTagName('dataPed');
				  dataPedido = dDataped.item(0).firstChild.data;											  
                  htmlText += '<td align="center" valign="middle"><a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=148&codPedDesc='+codigo+'')+'"><img src="'+imgVisualizar+'" alt="Visualizar o Evento" width="16" height="16" border="0" /></a>&nbsp; <a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=59&codCaixa='+codigo+'')+'"><img src="'+imgIndex+'" alt="Indexar Documento" width="16" height="16" border="0" /></a>&nbsp; <a href="'+retiraEspacos('http://'+localServ+'TrataMemotec?met=68&codCaixa='+codigo+'')+'"><img src="'+imgListIndx+'" alt="Listar Documentos" width="16" height="16" border="0" /></a></td>';                  
				  htmlText += '<td align="center">'+codigo+'</td>';	
				  htmlText += '<td align="center">'+login+'</td>';
				  htmlText += '<td align="center">'+nomeEmp+'</td>';				  			  			  				  
				  if(status == 1){                             
                     htmlText += '<td align="center">Não Atendido</td>';
				  }else if(status == 2){                             
                     htmlText += '<td align="center">Atendido</td>';
				  }else if(status == 3){                             
                     htmlText += '<td align="center">Processamento</td>';
				  }
				  htmlText += '<td align="center" >'+dataPedido+'</td>';        
				  htmlText += '</tr>'			      
			   }			   			   
			   htmlText += '</table><br/>';
			document.getElementById("listSol").innerHTML = htmlText;   
			}			
		}else if(qualXML == 54){ // cadastrar serviço ao pedido descritivo.		
			var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
                  htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhuma serviço cadastrado.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table><br/>';
			 document.getElementById("listServSol").innerHTML = htmlText;	  
			}else{				
			   data = response[0].getElementsByTagName('solDescServ');			   
			   htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="1" class="tabela" id="tabela1">';
			   htmlText += '<tr>';
			   htmlText +='<th width="80" align="center" valign="middle"><div align="center">OP&Ccedil;&Otilde;ES</div></th>';
               htmlText +='<th><div align="center">DESC SERVIÇO</div></th>';
               htmlText +='<th><div align="center">QUANTIDADE</div></th>';			   
               htmlText += '</tr>';			   	   
			   for(i=0; i < data.length; i++){                 
				  var dtDescServ = data[i].getElementsByTagName('descricao');
				  var descServ = dtDescServ.item(0).firstChild.data;
				  var dQuant = data[i].getElementsByTagName('quantidade');
				  var quantidade = dQuant.item(0).firstChild.data;
				  var dCodServEmp = data[i].getElementsByTagName('codServEmp');
				  var codServEmp = dCodServEmp.item(0).firstChild.data;
				  var dCodSol = data[i].getElementsByTagName('codSol');
				  var codSol = dCodSol.item(0).firstChild.data;							  									  
                  htmlText += '<td align="center" valign="middle"><a href="javascript:excluirServSolicitacao('+codServEmp+','+codSol+')" onclick="return deleta()"><img src="'+imgExcluir+'" alt="Remover o Evento" width="16" height="16" border="0" /></a></td>';               
				  htmlText += '<td align="center">'+descServ+'</td>';	
				  htmlText += '<td align="center">'+quantidade+'</td>';				        
				  htmlText += '</tr>'			      
			   }			   			   
			   htmlText += '</table><br/>';
			   document.getElementById("listServSol").innerHTML = htmlText;   
			}			
		}else if (qualXML == 55){			   
		var htmlText = "";
			data = response[0].getElementsByTagName('vazio');			
			conteudo = data.item(0).firstChild.data;			
			if(conteudo == 0){
			 htmlText += '<table width="525" border="0" cellpadding="5" cellspacing="0" class="tabela" id="tabela1">';
			  htmlText += '<tr>';
               htmlText += '<br>';
                      htmlText +=  '<th align="center" valign="middle" colspan="2">Nenhum documento encontrado.</th>';
                  htmlText += '<tr>';
			 htmlText += '</table>';
			 document.getElementById("consultaAdm").innerHTML = htmlText;	  
			}else{				   	   			   								
			   data = response[0].getElementsByTagName('consultaAdimim');
			   var pref = 'Doc_';
			   var prefCaixa = 'Cx_';
			   var espaco = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			   htmlText +='<table width="525" border="0" cellspacing="1" cellpadding="1" class="tabela" id="tabela1">';
			   htmlText +='<tr>';
			   htmlText +='<th width="20" align="center" valign="middle"><div align="center">OP&Ccedil;&Otilde;ES</div></th>';
			   htmlText +='<th width="150"><b>Ítem Documental</b></th>';
			   htmlText += '<th width="125"><b>Complemento</b></th>';
			   htmlText += '<th width="105"><b>Descritor</b></th>';
			   htmlText += '<th width="65" align="center"><b>N&ordm; Doc.</b></th>';
			   htmlText += '<th width="60" align="center"><b>N&ordm; Cx.</b></th>';
			   htmlText +='</tr>';
			   for(i=0; i < data.length; i++){
				  var codigo2 = data[i].getElementsByTagName('dadositem');
				  dadosItemDoc = codigo2.item(0).firstChild.data;				  				  
				  var codigo3 = data[i].getElementsByTagName('dadoscomplemento');
				  dadosComplemento = codigo3.item(0).firstChild.data;
				  var codigo4 = data[i].getElementsByTagName('dadosdescritor');
				  dadosDescritor = codigo4.item(0).firstChild.data;				  	
				  var codigo5 = data[i].getElementsByTagName('dadosndocumento');
				  dadosNDocumento = codigo5.item(0).firstChild.data;	
				  var codigo6 = data[i].getElementsByTagName('dadosncaixa');
				  dadosCx = codigo6.item(0).firstChild.data;
				                           
			      htmlText +='<tr>';   
			      htmlText += '<td align="center" valign="middle"><a href="javascript:emprestimoSolDescDoc('+dadosNDocumento+')"><img src="'+imgIndex+'" alt="Emprestar Documento" width="16" height="16" border="0" /></a></td>';              
			      htmlText += '<td>'+dadosItemDoc+'</td>';
				  htmlText += '<td>'+dadosComplemento+'</td>';
				  if(dadosDescritor == 'vazio'){
			         htmlText += '<td>.</td>';
				  }else{
				  	 htmlText += '<td>'+dadosDescritor+'</td>';
				  }	      
				  htmlText += '<td>'+ pref + dadosNDocumento +'</td>';				  
			      htmlText += '<td>'+ prefCaixa + dadosCx+'</td>';
				  htmlText += '</tr>';
			}   
			htmlText += '</table>';
			htmlText += '<div id="ultlinha" align="center">';
			   htmlText += '<input name="voltar" type="submit" class="botao1" value="<" onclick= "javascript:consultarDocumentoEmprestimo('+menos+');"/>'+espaco;
			   if(data.length >= 20){ 
			      htmlText += '<input name="ir" type="submit" class="botao1" value=">" onclick= "javascript:consultarDocumentoEmprestimo('+mais+');"/>';
			   }
			   htmlText += '</div>';
		   document.getElementById("consultaAdm").innerHTML = htmlText;		
		}    
	   }
      }else{
      alert('alert pq o tamnho da reposta e menor que zero!');
 	alert('Fechou a sessão!');
    }
}		

