/*
**********************************************************************************
 Criada por: Augusto (setembro/2008)
 Desabilita página e coloca a mensagem ("Processando...")
**********************************************************************************
*/
function msgSubmit(){
  Ext.MessageBox.show({
      msg: 'Aguarde um momento...',
      progressText: 'Processando...',
      width:300,
      wait:true,
      waitConfig: {interval:200},
      icon:'ext-mb-download'
  });
}

/*
**********************************************************************************
 Criada por: Cleverson (março/2007)
 Desabilita botao e coloca mensagem
no mesmo ("Aguarde...")
 Sintax:
     showWait(obj) //obj =
objeto do botao
**********************************************************************************
*/

  function showWait(obj) {
    obj.value = 'Aguarde...';
    obj.disabled = true;
  }

/*
**********************************************************************************
 Criada por: Augusto (fevereiro/2006)
 Tratamento de espaços em branco na 'string' utilizando Expressão Regular
 Sintax:
        texto = texto.trim();     //retira espaços em branco do início e fim
	 texto = texto.rtrim();    //retira espaços em branco da direita
	 texto = texto.ltrim();    //retira espaços em branco da esquerda
	 texto = texto.ntrim();    //corrige o espaçamento da string
	 texto = texto.alltrim();  //retira todos os espaços em branco
**********************************************************************************
*/

String.prototype.rtrim = function() {
  return this.replace(/\s*$/g, "");
}

String.prototype.ltrim = function() {
  return this.replace(/^\s*/g, "");
}

String.prototype.trim = function() {
  return this.replace(/^\s*|\s*$/g, "");
}

String.prototype.alltrim = function() {
  return this.replace(/\s/g, "");
}

String.prototype.ntrim = function() {
  return this.replace(/\s{2,}/g,' ').trim();
}

/*
**********************************************************************************
// formata valor numerico
// Exemplo: 1.333.444,00 
// Colocar no OnKeyPress() juntamente com Somente_Numero;
// Sintax: OnKeyPress="FormataValor(this,16,event); return Somente_Numero(event);" 
// Atualizada em: 22/09/2005 (IE/Firefox)
**********************************************************************************
*/


function FormataValor(campo,tammax,e) { 
	
	var tecla;
		
	if(window.event){
	   tecla = e.keyCode;
	}
	if(e.which){
	   tecla = e.which;
   	}
 
      vr = campo.value;
	  vr = vr.replace( "/", "" );
	  vr = vr.replace( "/", "" );
	  vr = vr.replace( ",", "" );
	  vr = vr.replace( ".", "" );
	  vr = vr.replace( ".", "" );
	  vr = vr.replace( ".", "" );
	  vr = vr.replace( ".", "" );
	  tam = vr.length;
	
      // valores das teclas => 8(backspace) - 9(tab) - 48 a 57 / 96 a 105 (numeros)

	  if (tecla == 9) {return;}

//	  if (tam < tammax && (tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )){ tam = vr.length + 1 ; }
      if (tam < tammax && (tecla >= 48 && tecla <= 57)){ tam = vr.length + 1 ; }


  	  if (tecla == 8 || tecla == 110){ tam = tam - 1 ; }
		
//    if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
	  if ( tecla == 8 || tecla >= 48 && tecla <= 57 ){
		 
          if ( tam <= 2 ){ campo.value = vr ; }
		  if ( (tam > 2) && (tam <= 5) ){
		  	  campo.value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
		  if ( (tam >= 6) && (tam <= 8) ){
			  campo.value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
		  if ( (tam >= 9) && (tam <= 11) ){
			  campo.value = vr.substr( 0, tam - 8 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
		  if ( (tam >= 12) && (tam <= 14) ){
			  campo.value = vr.substr( 0, tam - 11 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
		  if ( (tam >= 15) && (tam <= 17) ){
			  campo.value = vr.substr( 0, tam - 14 ) + '.' + vr.substr( tam - 14, 3 ) + '.' + vr.substr( tam - 11, 3 ) + '.' + vr.substr( tam - 8, 3 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ;}
	  }
}


/*
**************************************************************
 Criada por: Augusto (Dezembro/2006)
 Permite apenas caractere alfa válido (evento)
 ==> colocar no onKeyPress
 Sintax: OnKeyPress="return SomenteTexto(event);"
***************************************************************
*/

function SomenteTexto(e)
 {
    var key;
    var keychar;
    var reg;
 
 if(window.event) {
  // for IE, e.keyCode or window.event.keyCode podem ser usados
  key = e.keyCode;
 }
 else if(e.which) {
    // Firefox e Netscape
  key = e.which;
 }
 else {
  return true;
 }
   
  if((key >= 33 && key <= 64) || (key >= 91 && key <= 96) || (key >= 123 && key <= 125))
  {
    return false;
  }
  else
  {
    return true;
  }
 
}




/*
**************************************
* String.isCPF                       *
* Autor: Carlos R. L. Rodrigues      *
**************************************
*/

String.prototype.isCPF = function(){
	var c = this;
	if((c = c.replace(/[^\d]/g,"").split("")).length != 11) return false;
	if(new RegExp("^" + c[0] + "{11}$").test(c.join(""))) return false;
	for(var s = 10, n = 0, i = 0; s >= 2; n += c[i++] * s--);
	if(c[9] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
	for(var s = 11, n = 0, i = 0; s >= 2; n += c[i++] * s--);
	if(c[10] != (((n %= 11) < 2) ? 0 : 11 - n)) return false;
	return true;
}


/*
***************************************************** 
* Função checarCPF()                                *
* Autor: Augusto (03/04/2006)                       *
* Faz referência à função isCPF()                   *  
* e já formata o campo para o padrão xxx.xxx.xxx-xx *
*****************************************************
*/

function checarCPF(e)
{
 if(e.value!='')
 { 
   if(e.value.isCPF())
   { 
     var eCPF = '';
     x = e.value.length;
     for (var i=0;i<x; i++) { 
       temp = e.value.substring(i,i+1),10;
       if(parseInt(temp) == temp) {
          eCPF += temp;
       }
     }

     if (eCPF.length != 11) {return "";}
     p1 = eCPF.substring(0,3);
     p2 = eCPF.substring(3,6);
     p3 = eCPF.substring(6,9);
     p4 = eCPF.substring(9,11);
     with(document.forms[0])
     { 
       e.value=p1+"."+p2+"."+p3+"-"+p4;
     }
   }
   else
   { 
     alert('CPF inválido');
     with(document.forms[0])
     { 
      e.value='';
      e.focus();
     }
   }
 }
}


/*
**************************************************************
 Criada por: Augusto (agosto/2005)
 Impede que o usuário digite caracteres não numéricos (evento)
 ==> colocar no onKeyPress
 Sintax: OnKeyPress="return Somente_Numero(event);"
***************************************************************
*/

function Somente_Numero(e)
 {
    var key;
	var keychar;
	var reg;
	
	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode podem ser usados
		key = e.keyCode; 
	}
	else if(e.which) {
	   // Firefox e Netscape
		key = e.which; 
	}
	else {
		return true;
	}
    keychar = String.fromCharCode(key); 
	reg = /\d/;  // checa se contem caracteres alfa
	
	if (key != 8) // No Firefox ignora a tecla BACKSPACE
	return reg.test(keychar);   // retorna somente numericos
}


/*
***************************************************** 
* Função MascaraDATA(e,objeto)                      *
* Autor: Augusto (20/04/2006)                       *
*                                                   *
* Formata o campo data para o padrão dd/MM/yyyy     *  
* na medida em que a data é digitada                *    
*                                                   *  
* Sintax: OnKeyPress="MascaraDATA(e,objeto);"       *
*****************************************************
*/

function MascaraDATA(e,objeto)
{

  var tecla;

  if(window.event)  { tecla = e.keyCode; }     // Captura a tecla digitada no IE
  if(e.which)  { tecla = e.which; }            // Captura a tecla digitada no Firefox   
  
  campo = eval (objeto);

  caracteres = '01234567890';   // Define os caracteres válidos para o campo

  if ((caracteres.search(String.fromCharCode(tecla))!=-1) && campo.value.length < 10)
  { 
    if (campo.value.length == 2) campo.value = campo.value + '/' ;
    if (campo.value.length == 5) campo.value = campo.value + '/' ;
  }
  
  else { event.returnValue = false; }

}


/*
***************************************************** 
* Função validaDATA(objeto)                         *
* Autor: Augusto (25/04/2006)                       *
*                                                   *
* Valida a data, digitada no padrão dd/MM/yyyy,     *  
* utilizando-se de EXPRESSAO REGULAR.               *    
*                                                   *  
* Sintax: OnBlur="validaDATA(objeto);"              *
*****************************************************
*/

function validaDATA(data)
{
    // Definição da Expressão Regular (Márcio d'Ávila)
    // * Os dias 1 a 29 ((0?[1-9]|[12]\d)) são aceitos em todos os meses (1 a 12): (0?[1-9]|1[0-2])
    // * Dia 30 é válido em todos os meses, exceto fevereiro (02): (0?[13-9]|1[0-2])
    // * Dia 31 é permitido em janeiro (01), março (03), maio (05), julho (07), agosto (08), outubro (10) e dezembro (12): (0?[13578]|1[02])

    var reDate = /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/[12][0-9]{3}$/;
	
    dt    = data.value; 
    mData = dt.toLocaleString(); 
    mDia  = mData.substring(0,2);
    mMes  = mData.substring(3,5);
    mAno  = mData.substring(6); 
	
    if (reDate.test(dt))  // Testa a Data com base na Expressão Regular Definida
    {  
       if ( (mMes == '02') && (parseInt(mDia) > 28) && ( (parseInt(mAno) % 4) != 0) )  // Verifica se o ano é bissexto
 	{
    	     alert(dt + " NÃO é uma data válida."); 
	     data.value = "";
  	     data.focus()
	     return false;
	}

    } 
	 
    else if (dt != null && dt != "")  // Teste negativo ....
    {
       alert(dt + " NÃO é uma data válida.");
       data.value = "";
	data.focus()
    }
} 


/*
***************************************************** 
* Função MascaraHORA(e,objeto)                      *
* Autor: Augusto (11/05/2006)                       *
*                                                   *
* Formata o campo hora para o padrão HH:MM          *  
* na medida em que a data é digitada                *    
*                                                   *  
* Sintax: OnKeyPress="MascaraHORA(e,objeto);"       *
*****************************************************
*/

function MascaraHORA(e,objeto)
{

  var tecla;

  if(window.event)  { tecla = e.keyCode; }     // Captura a tecla digitada no IE
  if(e.which)  { tecla = e.which; }            // Captura a tecla digitada no Firefox   
  
  campo = eval (objeto);

  caracteres = '0123456789';   // Define os caracteres válidos para o campo

  if ((caracteres.search(String.fromCharCode(tecla))!=-1) && campo.value.length < 5)
  { 
    if (campo.value.length == 2) campo.value = campo.value + ':' ;
  }
  
  else { event.returnValue = false; }

}


/*
***************************************************** 
* Função validaHORA(objeto)                         *
* Autor: Augusto (11/05/2006)                       *
*                                                   *
* Valida a hora, digitada no padrão HH:MM,          *  
* utilizando-se de EXPRESSAO REGULAR.               *    
*                                                   *  
* Sintax: OnBlur="validaHORA(objeto);"              *
*****************************************************
*/

function validaHORA(hora)
{
    //  Valida a hora no padrão 24 hs

    var reTime  = /^([0-1]\d|2[0-3]):[0-5]\d$/;
	
    hr = hora.value; 
	 
    if (reTime.test(hr))  // Testa a Data com base na Expressão Regular Definida
    { return; }
    else if (hr != null && hr != "")  // Teste negativo ....
    {
       alert(hr + " NÃO é uma hora válida.");
       hora.value = "";
	   hora.focus()
    }
} 



//Função que esconde os "divs".
function hide(id) {
   if (document.layers) {
        document.layers[id].visibility = 'hidden';
    }
   else if (document.getElementById) {
         document.getElementById(id).style.visibility = 'hidden';
    }
}

//Função que exibe os "divs".
function show(id) {
   if (document.layers) {
        document.layers[id].visibility = 'visible';
    }
    else if(document.getElementById){
         document.getElementById(id).style.visibility = 'visible';
    }

 }

// no click do botao direito nao mostrar "apenas no IE"
function identify () {
  if (navigator.appName == "Microsoft Internet Explorer"){
     if (event.button==2) 
	    alert('Tribunal de Justiça do Estado de Sergipe.');
  }
}

// bloqueia a tecla ENTER "apenas no IE"
function noenter() {
  if (navigator.appName == "Microsoft Internet Explorer"){
    if (window.event && window.event.keyCode == 13) {
        window.event.keyCode=0; 
	}
  }
}


/*
**********************************************************************************
 Função para realizar a mudança dos cursores
 Sintax:
     cursor(<elemento_hierárquico>,<tag_utilizada>,<tipo_cursor>);
	 - <elemento_hierárquico> = document, window, self ...
	 - <tag_utilizada> = body, forms, input ...
	 - <tipo_cursor> = wait, defult, hand ...
 Ex.: <input type="button" name="btEnviar" value="Enviar" onClinck="cursor(document,'body','wait');"
**********************************************************************************
*/
function cursor(element,local,tipo){
  element.getElementsByTagName(local).item(0).style.cursor=tipo;
}




//Função para limitar o campo textarea
function countTextarea(txtarea,tam) {
  frm=document.formulario;
  if(txtarea.value.length>tam) {
    alert("O Texto deve conter no máximo "+tam+" caracteres.");
    txtarea.value = txtarea.value.substring(0,tam);
  }
}


// Impede que o usuário digite caracteres não numéricos
function apenasnumero(entry) {
  var str = entry.value;
  for (var i = 0; i < str.length; i++) {
    var ch = str.substring(i, i + 1);
//    if ((ch < "0" || "9" < ch) && ch != '.' && ch != ',') {
    if (ch < "0" || "9" < ch) {
      alert("Digite apenas números");
      i=str.length;
      entry.value="";
	  entry.focus();
    }
  }
}


// Imprime conteúdo do frame "main"

function imprimir() {
  if (navigator.appName == "Microsoft Internet Explorer"){
     parent.main.focus();
	 window.print();
  }   
  else{
	 parent.frames[1].print();	
  }
}

function Dia(Data_DDMMYYYY)
{
string_data = Data_DDMMYYYY.toString();
posicao_barra = string_data.indexOf("/");
if (posicao_barra!= -1)
{
dia = string_data.substring(0,posicao_barra);
return dia;
}
else
{
return false;
}
}

function Mes(Data_DDMMYYYY)
{
string_data = Data_DDMMYYYY.toString();
posicao_barra = string_data.indexOf("/");
if (posicao_barra!= -1)
{
dia = string_data.substring(0,posicao_barra);
string_mes = string_data.substring(posicao_barra+1,string_data.length);
posicao_barra = string_mes.indexOf("/");
if (posicao_barra!= -1)
{
mes = string_mes.substring(0,posicao_barra);
mes = Math.floor(mes);
return mes;
}
else
{
return false;
}

}
else
{
return false;
}
}

function Ano(Data_DDMMYYYY)
{
string_data = Data_DDMMYYYY.toString();
posicao_barra = string_data.indexOf("/");
if (posicao_barra!= -1)
{
dia = string_data.substring(0,posicao_barra);
string_mes = string_data.substring(posicao_barra+1,string_data.length);
posicao_barra = string_mes.indexOf("/");
if (posicao_barra!= -1)
{
mes = string_mes.substring(0,posicao_barra);
mes = Math.floor(mes);
ano = string_mes.substring(posicao_barra+1,string_mes.length);
return ano;
}
else
{
return false;
}

}
else
{
return false;
}
}

function Calcula_Data(data_DDMMYYYY,dias,adicao){

Var_Dia=Dia(data_DDMMYYYY);
Var_Mes=Mes(data_DDMMYYYY);
Var_Mes=Math.floor(Var_Mes)-1;
Var_Ano=Ano(data_DDMMYYYY);

var data = new Date(Var_Ano,Var_Mes,Var_Dia);

if (adicao == true)
{
operacao = '+'
var diferenca = data.getTime() + (dias * 1000 * 60 * 60 * 24);
}
else
{
operacao = '-'
var diferenca = data.getTime() - (dias * 1000 * 60 * 60 * 24);
}
var diferenca = new Date(diferenca);
alert(string_data+operacao+dias+' dias = '+diferenca.getDate()+'/'+(parseInt(diferenca.getMonth())+1)+'/'+diferenca.getYear());

}

function Calcula_Dias(data1_DDMMYYYY,data2_DDMMYYYY){

Var_Dia1=Dia(data1_DDMMYYYY);
Var_Mes1=Mes(data1_DDMMYYYY);
Var_Mes1=Math.floor(Var_Mes1)-1;
Var_Ano1=Ano(data1_DDMMYYYY);
var data1 = new Date(Var_Ano1,Var_Mes1,Var_Dia1);

Var_Dia2=Dia(data2_DDMMYYYY);
Var_Mes2=Mes(data2_DDMMYYYY);
Var_Mes2=Math.floor(Var_Mes2)-1;
Var_Ano2=Ano(data2_DDMMYYYY);
var data2 = new Date(Var_Ano2,Var_Mes2,Var_Dia2);

var diferenca = data1.getTime() - data2.getTime();
var diferenca = Math.floor(diferenca / (1000 * 60 * 60 * 24));
return diferenca;
}

//
function ComboOficio(ofi1,ofi2){

 if (ofi1=='S' && ofi2 == 'S') {
  dw('<select name="TMP_OFICIO"><option value="T" selected>Todos</OPTION><option value="1">1º ofício</OPTION><option value="2">2º ofício</OPTION></select>');  
  return;
  } 
 if (ofi1=='S') {
  dw('<select name="TMP_OFICIO" disabled><option value="1">1º ofício</OPTION></select>');  
  return;
  } 
 if (ofi2 == 'S') {
  dw('<select name="TMP_OFICIO" disabled><option value="2">2º ofício</OPTION></select>');
  return;
  } 

 dw('<select name="TMP_OFICIO" disabled><option value="T">único</OPTION></select>');

}

//
function ComboAcao(acao){

 if (acao==1 || acao==3){  
  dw('<select name="TMP_ACAO" disabled><option value="1">Civel</OPTION></select>');
 }

 if (acao==2){  
  dw('<select name="TMP_ACAO" disabled><option value="2">Criminal</OPTION></select>');
 }
 
 if (acao==5){   
  dw('<select name="TMP_ACAO"><option value="0" selected>Selecione...</OPTION><option value="1">Civel</OPTION><option value="2">Criminal</OPTION></select>');
 }

}

//
function ValidaSessao(usuario) {

 //alert('\n\n - 24/02/2006 - ATENÇÃO - Os sistemas entrarão em manutenção a partir das 12:00 hs, com previsão de retorno às 13:00 hs. \n\n Quaisquer dúvidas entrar em contato com o callcenter, ramais : 3393, 3394 e 3381. \n\n Agradecemos a compreensão.'); 

 if (usuario=='') {
   alert('Sessão expirada.  Seu browser será fechado.');
   //window.top.opener.top.opener.top.location.reload();
   window.top.opener.top.opener.top.close();
   window.top.opener.close();
   window.top.close()
 }
}

//
function janela(tipo){
 var frm=document.formulario;
 acao=frm.TMP_ACAO.value;
 local=frm.TMP_LOCAL.value;
 // Todas as petições exceto carta precatória
 if (tipo==1){
  nome=frm.TMP_NPARTE.value;
  frm.TMP_TPESQ.value=1;
  pesq=frm.TMP_TPESQ.value;
  if (nome==""){
    alert("Sr. usuário, digite o nome da parte a ser pesquisada.");
    frm.TMP_NPARTE.focus();
    return;
   } 
   wiOpen('/scp/cadastros/cadparte.wsp?TMP.NPARTE='+nome+'&TMP.TPESQ='+pesq+'&TMP.ACAO='+acao+'&TMP.LOCAL='+local,'_blank','width=700,height=450,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
   return;
 }
 // Somente para carta precatória
 if (tipo==2){
  nome=frm.TMP_NDEPRE.value;
  frm.TMP_TPESQ.value=1;
  pesq=frm.TMP_TPESQ.value;
  carta='T1';
  if (nome==""){
    alert("Sr. usuário, digite o nome da parte a ser pesquisada.");
    frm.TMP_NPARTE.focus();
    return;
   } 
   wiOpen('/scp/cadastros/cadparte.wsp?TMP.NPARTE='+nome+'&TMP.TPESQ='+pesq+'&TMP.CARTA='+carta+'&TMP.ACAO='+acao+'&TMP.LOCAL='+local,'_blank','width=700,height=450,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
   return;
 }
 // Somente para advogados
 if (tipo==3){
   nome=frm.TMP_NOMEADV.value;
   frm.TMP_TPESQ.value=1;
   pesq=frm.TMP_TPESQ.value;
   if (nome==""){
    alert("Sr. usuário, digite o nome do advogado a ser pesquisado.");
    frm.TMP_NOMEADV.focus();
    return;
    } 
   wiOpen('/scp/cadastros/cadadvogado.wsp?TMP.NOMEADV='+nome+'&TMP.TPESQ='+pesq+'&TMP.ACAO='+acao+'&TMP.LOCAL='+local,'_blank','width=700,height=450,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');  
 }
}


//
function verificaBrowser(url) { 
  if (url=="undefined") url = "index.wsp";
  navName = navigator.appName;
  navVersion = navigator.appVersion;
  navAgent = navigator.userAgent;
  compatibleNav = false;
  opera = (navAgent.indexOf('Opera') != -1);

  	if (opera)
	{
		navVersion = parseFloat(navAgent.slice(navAgent.indexOf('Opera') + 6))
    	compatibleNav = (navVersion >= 7.11);
		if (!compatibleNav)
		{
			alert('Para acessar o sistema, você precisa ter o Opera 7.11 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
			return;
		}
	}

	netscape = mozilla = Konqueror = iexplore = !opera;

	if (!opera)
	{

		netscape = (navAgent.indexOf('Netscape') != -1);
		if (netscape)
		{
			navVersion = parseFloat(navAgent.slice(navAgent.lastIndexOf('/') + 1));
			compatibleNav = (navVersion >= 7.0);
			if (!compatibleNav)
			{
				alert('Para acessar o sistema, você precisa ter o Netscape 7.0 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
				return;
			}
		}
		
		mozilla = (!netscape && (navAgent.indexOf('rv:') != -1));
		if (mozilla)
		{
			navVersion = parseFloat(navAgent.slice(navAgent.indexOf('rv:') + 3))
			compatibleNav = (navVersion >= 1.0);
			if (!compatibleNav)
			{
				alert('Para acessar o sistema, você precisa ter o Mozilla Firefox 1.0 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
				return;
			}
		}
		
		Konqueror = (navAgent.indexOf('Konqueror') != -1);
		if (Konqueror)
		{
			navVersion = parseFloat(navAgent.slice(navAgent.indexOf('Konqueror') + 10))
			compatibleNav = (navVersion >= 3.1);
			if (!compatibleNav)
			{
				alert('Para acessar o sistema, você precisa ter o Konqueror 3.1 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
				return;
			}
		}
		
		iexplore = (navAgent.indexOf('MSIE') != -1);
		if (iexplore)
		{
			navVersion = parseFloat(navAgent.slice(navAgent.indexOf('MSIE') + 5))
			compatibleNav = (navVersion >= 5.5);
			if (!compatibleNav)
			{
				alert('Para acessar o sistema, você precisa ter o Internet Explorer 5.5 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
				return;
			}
		}
	}
}

// tratamento padrão de erros
function myFunc(a,b,c) {
   alert("Informar ao CPD.\r\nOcorreu um erro: "+a+" \r\n(Página: "+b+"  -   Linha: "+c+")"); 
   return true;
}
window.onerror= myFunc;

// funcao que valida se a data tem o tamanho correto
function tamdata(nome,valor){
 if (valor.length<8 && valor!=''){
  alert('Sr. usuário, data inválida');
  nome.focus();
  nome.value="";
 }
}
//
function irparasistema(caminho,sistema,idusuario,cmpt){
 var h = screen.height-56; 
 var w = screen.width-10;  
 //wiOpen(caminho+'&idsistema='+sistema+'&idusuario='+idusuario+'&cmpt='+cmpt,'_blank','top=0,width=800,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes'); 
//wiOpen(caminho+'&idsistema='+sistema+'&idusuario='+idusuario+'&cmpt='+cmpt,'_blank','width='+w+',height='+h+','top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,copyhistory=no,resizable');
wiOpen(caminho+'&idsistema='+sistema+'&idusuario='+idusuario+'&cmpt='+cmpt,'_blank','top=0,left=0,width=800,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes'); 

}

// Retira strings
function RetiraChar(entrada)  { 
  var result = "";
  var temp;
  for (var i=0;i<entrada.length; i++) {
    temp = entrada.substring(i,i+1),10;
    if ( parseInt(temp) == temp ) {
      result += temp;
    }
  }
  return result;
}


//Exibe o cabeçalho nas páginas de resposta de relatórios, estatísticas e consultas
function cabecalho(){
 document.write('<table border="0" width="100%" cellspacing="0" cellpadding="0"><tr><td width="20%">&nbsp;</td><td width="60%" align="center"><img border="0" src="/scp/imagens/logotrib2.jpg" align="center" hspace="15"><br><font><b>Tribunal de Justiça do Estado de Sergipe</b></font></td>');
 document.write('<td width="20%" align="right"><font class="fontsmall">Gerada em <br>'+data+'<br>'+hora+'</font></td></tr></table>');
}
//
function janelaadv(codadv,acao,local){
 codadv=Piece(codadv,"#",1)+"%23"+Piece(codadv,"#",2)+"%23"+Piece(codadv,"#",3);
 wiOpen('/scp/cadastros/respcadadv.wsp?TMP_ACAO='+acao+'&TMP_LOCAL='+local+'&TMP_CODOAB='+codadv,'_blank','width=700,height=450,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
}

/*****************************************
*  Função padrão para alteração de partes.
*  Ela abre uma janela com o formulário
*  de alteração de partes.
*  Ao terminar este procedimento é chamada
*  uma outra função (fechar() - que se 
*  encontra na página respcadparte.wsp)
*  que irá fechar a janela e retornar para
*  a página que a chamou os dados necessários.
******************************************/
function janelaparte(codpar,acao,local){
 if (local=="S") {
   wiOpen('/scp/cadastros/respcadparte.wsp?TMP_CODPARTE='+codpar+'&TMP_ACAO='+acao+'&TMP_LOCAL='+local,'_blank','width=700,height=450,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
 } else {
   wiOpen('/vec/cadastro/cadParte.wsp?TMP.CODPARTE='+codpar+'&TMP.ACAO='+acao+'&TMP.LOCAL='+local,'_blank','width=700,height=550,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
 }
}
function janelaparte(codpar,acao,local,npro){
 if (local=="S") {
   wiOpen('/scp/cadastros/respcadparte.wsp?TMP_CODPARTE='+codpar+'&TMP_ACAO='+acao+'&TMP_LOCAL='+local+'&TMP_NPRO='+npro,'_blank','width=700,height=450,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
 } else {
   wiOpen('/vec/cadastro/cadParte.wsp?TMP.CODPARTE='+codpar+'&TMP.ACAO='+acao+'&TMP.LOCAL='+local+'&TMP.NPRO='+npro,'_blank','width=700,height=550,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
 }
}

/******************************************
*  Semelhante a função anterior, sendo que
*  será usada na página da guia.
******************************************/
function janelaparte2(codpar,acao,local,tipo){
 if (local=="S") {
   wiOpen('/scp/cadastros/respcadparte.wsp?TMP_CODPARTE='+codpar+'&TMP_ACAO='+acao+'&TMP_LOCAL='+local+'&TMP_TPPAGINA='+tipo,'_blank','width=700,height=450,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
 } else {
   wiOpen('/vec/cadastro/cadParte.wsp?TMP.CODPARTE='+codpar+'&TMP.ACAO='+acao+'&TMP.LOCAL='+local+'&TMP.TPPAGINA='+tipo,'_blank','width=700,height=550,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
 }
}

// 
function janelaproc(codproc,acao,local){
 janelaproc(codproc,acao,local,'');
}

//
function janelaproc(codproc,acao,local,qtde){
 wiOpen('/scp/consultas/cartorio/respnumproc.wsp?TMP_NPRO='+codproc+'&TMP_ACAO='+acao+'&TMP_QTDE='+qtde,'_blank','width=700,height=450,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
}

//
function janelaproc2(codproc){
 janelaproc2(codproc,'');
}

//
function janelaproc2(codproc,qtde){
 wiOpen('/tjnet/consultas/internet/respnumproc2.wsp?TMP.CODCOMPETENCIA=1&TMP_NPRO='+codproc+'&TMP_QTDE='+qtde,'_blank','width=700,height=450,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
}


//
function Piece(str,delim,ind) {
   var aux = str.split(delim);
   if (ind <= aux.length) {
     return aux[ind-1];
   }
}   

//
function formataTEL(origem,destino) {
var telefone="";
var numeros="0123456789";
for (i=0;i<origem.value.length;i++) {
  var num = new String(origem.value.charAt(i));
  if (numeros.indexOf(num)>-1) { telefone=telefone+num; }
}


if (telefone.length!=0 && telefone.length<9)
{alert("Número de telefone inválido, coloque o DDD e o número do telefone,Ex: 792312234 ou 7923112234");
 destino.value="";
 }
if (telefone.length==9) {
  destino.value ="("+telefone.substr(0,2)+")"+telefone.substr(2,3)+"-"+telefone.substr(5,4);
}
if ((telefone.length==10)&&(telefone.indexOf("-")!=3)) {
  destino.value ="("+telefone.substr(0,2)+")"+telefone.substr(2,4)+"-"+telefone.substr(6,4);
}
}

//
function formatanewCEP(origem,destino) {
var cep="";
var numeros="0123456789";
for (i=0;i<origem.value.length;i++) {
  var num = new String(origem.value.charAt(i));
  if (numeros.indexOf(num)>-1) { cep=cep+num; }
}


if (cep.length!=0 && cep.length<8) {
  alert("Número de CEP inválido");
  destino.value="";
  destino.focus();
}
if (cep.length==8) {

destino.value = cep.substr(0,2)+"."+cep.substr(2,3)+"-"+cep.substr(5,6);
}
if ((cep.length==10)&&(cep.indexOf(".")!=3)) {
  destino.value = cep.substr(0,2)+"."+cep.substr(2,3)+"-"+cep.substr(5,6);
}
}

//
function checkdate(objName) {
var datefield = objName;
if (datefield.value == "") return;
if (datefield.value == " ") return;
if (datefield.value == "  ") return;
if (datefield.value == "    ") return;
if (datefield.value == "     ") return;
if (chkdate(objName) == false) {
datefield.select();
alert("Sr. usuário, esta data é inválida.");
datefield.value="";
datefield.focus();
return false;
}
else {
return true;
   }
}

//
function chkdate(objName) {
//var strDatestyle = "US"; //United States date style
var strDatestyle = "EU";  //European date style
var strDate;
var strDateArray;
var strDay;
var strMonth;
var strYear;
var intday;
var intMonth;
var intYear;
var booFound = false;
var datefield = objName;
var strSeparatorArray = new Array("-"," ","/",".");
var intElementNr;
var err = 0;
var strMonthArray = new Array(12);
strMonthArray[0] = "/01/";
strMonthArray[1] = "/02/";
strMonthArray[2] = "/03/";
strMonthArray[3] = "/04/";
strMonthArray[4] = "/05/";
strMonthArray[5] = "/06/";
strMonthArray[6] = "/07/";
strMonthArray[7] = "/08/";
strMonthArray[8] = "/09/";
strMonthArray[9] = "/10/";
strMonthArray[10] = "/11/";
strMonthArray[11] = "/12/";
strDate = datefield.value;
if (strDate.length < 1) {
return true;
}
for (intElementNr = 0; intElementNr < strSeparatorArray.length; 
intElementNr++) {
if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
strDateArray = strDate.split(strSeparatorArray[intElementNr]);
if (strDateArray.length != 3) {
err = 1;
return false;
}
else {
strDay = strDateArray[0];
strMonth = strDateArray[1];
strYear = strDateArray[2];
}
booFound = true;
   }
}
if (booFound == false) {
  if (strDate.length>5) {
    strDay = strDate.substr(0, 2);
    strMonth = strDate.substr(2, 2);
    strYear = strDate.substr(4);
  }
}
if (strYear != undefined){
  if (strYear.length != 4) {
  //strYear = '20' + strYear;
  alert("O ano deve ter 04 dígitos");
  return false;
  }
}else{
  alert("Data imcompleta.");
  return false;
}

// US style
if (strDatestyle == "US") {
strTemp = strDay;
strDay = strMonth;
strMonth = strTemp;
}
intday = strDay;
if (isNaN(intday)) {
err = 2;
return false;
}
intMonth = parseInt(strMonth, 10);
if (isNaN(intMonth)) {
for (i = 0;i<12;i++) {
if (strMonth.toUpperCase() == strMonthArray[i].toUpperCase()) {
intMonth = i+1;
strMonth = strMonthArray[i];
i = 12;
   }
}
if (isNaN(intMonth)) {
err = 3;
return false;
   }
}
intYear = parseInt(strYear, 10);
if (isNaN(intYear)) {
err = 4;
return false;
}
if (intMonth>12 || intMonth<1) {
err = 5;
return false;
}
if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || 
intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 
1)) {
err = 6;
return false;
}
if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && 
(intday > 30 || intday < 1)) {
err = 7;
return false;
}
if (intMonth == 2) {
if (intday < 1) {
err = 8;
return false;
}
if (LeapYear(intYear) == true) {
if (intday > 29) {
err = 9;
return false;
}
}
else {
if (intday > 28) {
err = 10;
return false;
}
}
}
if (strDatestyle == "US") {
datefield.value = strMonthArray[intMonth-1] + " " + intday+" " + strYear;
}
else {
datefield.value = intday + strMonthArray[intMonth-1] + strYear;
}
return true;
}
function LeapYear(intYear) {
if (intYear % 100 == 0) {
if (intYear % 400 == 0) { return true; }
}
else {
if ((intYear % 4) == 0) { return true; }
}
return false;
}

//
function Limpar(valor, validos) {
// retira caracteres invalidos da string
  var result = "";
  var aux;
  for (var i=0; i < valor.length; i++) {
    aux = validos.indexOf(valor.substring(i, i+1));
      if (aux>=0) {
        result += aux;
      }
  }
  return result;
}

//
function YMDtoDMY (data) {
  if (data.length!=8) return "";
  return data.substr(6,2)+"/"+data.substr(4,2)+"/"+data.substr(0,4);
}

//
function dw(texto) {
  document.write(texto);
}	

// 
function RetiraChar(entrada)  { 
  var result = "";
  var temp;
  for (var i=0;i<entrada.length; i++) {
    temp = entrada.substring(i,i+1),10;
    if ( parseInt(temp) == temp ) {
      result += temp;
    }
  }
  return result;
}

//
function CPFdv(CPF) {
  CPF = RetiraChar(CPF);
  if (CPF.length != 9) { return ""; }
  var soma = 0;
  var checar = CPF.substring(9);
  CPF = CPF.substring(0,9);
  for (var i=0; i<9; i++) { 
    soma = soma + CPF.substring(i,i+1)*(10-i);
  }
  var cpfdv = 11 - (soma % 11);
  if ( cpfdv >= 10 ) { 
    cpfdv = 0;
  }
  soma = 0;
  for (var i=0; i<9; i++) {
    soma = soma + CPF.substring(i,i+1)*(11-i);
  }
  soma = soma + cpfdv * 2;
  var cpfdv2 = 11 - (soma%11);
  if ( cpfdv2 >= 10 ) { 
    cpfdv2 = 0;
  }
  cpfdv += ""+cpfdv2;
  return cpfdv;
}

//
function ValidaCPF(CPF) {
  CPF = RetiraChar(CPF);
  if (CPF.length == 0) {return "";}
  if (CPF.length != 11) { 
   alert("\n- O campo 'CPF' é inválido.");
   return "";
  }
  if (CPF.length != 11) { return "" }
  if (CPFdv(CPF.substring(0,9)) == CPF.substring(9)) {
    return CPF;
  }
  else {
    alert("\n- O campo 'CPF' é inválido.");
    return "";
  }
}

//
function FormataCPF(CPF) {
  CPF = RetiraChar(CPF);
  if (CPF.length != 11) {return "";}
  var parte1 = CPF.substring(0,3);
  var parte2 = CPF.substring(3,6);
  var parte3 = CPF.substring(6,9);
  var parte4 = CPF.substring(9,11);
  document.formulario.TMP_NUM.value=parte1 + "." + parte2 + "." + parte3 + "-" + parte4;
}

//
function formatahora(origem,destino) {
var hora="";
var numeros="0123456789:h";
var msg="";
for (i=0;i<origem.value.length;i++) {
  var num = new String(origem.value.charAt(i));
  if (numeros.indexOf(num)>-1) { hora=hora+num; }
} 
if ((hora.length<4)&&(hora.length>0)) {msg="Sr. usuário o horário deve ter 4 digitos";}
if (hora.substr(0,2)>24) {msg="Sr. usuário a hora não pode exceder a 24.";}
if (hora.substr(3,2)>59) {msg="Sr. usuário o minuto não pode exceder a 59.";}
if ((hora.length==5)) {destino.value = hora.substr(0,2)+":"+hora.substr(3,2)+":00";}
if (msg!="") {
  alert(msg);
  destino.focus();
  destino.value = "";
  return;
  }
if ((hora.length==4)&&(hora.indexOf(":")!=3)) {destino.value = hora.substr(0,2)+":"+hora.substr(2,3)+":00";}
}

function isNumber() {
 var text = document.formulario.TMP_NUM.value;
 if (text=="") return;
 for (var i = 0; i <= text.length-1; i++) {
    if (isNaN(parseInt(text.substring(i,i+1)))) {
     alert("\n Sr. usuário, apenas números são permitidos neste campo.")
     document.formulario.TMP_NUM.value=""
     document.formulario.TMP_NUM.focus();
     return; 
    }
  }
  validacnpj();
  return;
}

function validacnpj(){
    var CPFCGC = document.formulario.TMP_NUM.value;
    var CPFCGCvalido = 0;
    somacgc = 0;
    for (var i = 0; i<4; i++) {
      somacgc = somacgc + CPFCGC.substring(i,i+1)*(5-i) 
      }
    for (var i = 4; i<12; i++) { 
      somacgc = somacgc + CPFCGC.substring(i,i+1)*(13-i) 
     }
    cgcdv = 11 - (somacgc % 11)
    if (cgcdv == 10) cgcdv = 0
    somacgc = 0;
    for (var i = 0; i<5; i++) { 
      somacgc = somacgc + CPFCGC.substring(i,i+1)*(6-i) 
      }
    for (var i = 5; i<12; i++) { 
      somacgc = somacgc + CPFCGC.substring(i,i+1)*(14-i) 
      }
    somacgc = somacgc + cgcdv * 2;
    cgcdv2 = 11 - (somacgc%11)
    if (cgcdv2 == 10) cgcdv2 = 0
    cgcdv = ( cgcdv * 10 ) + cgcdv2
    if (CPFCGC.substring(12,14) == cgcdv) CPFCGCvalido = 1
    if (CPFCGCvalido == 0) {
    alert("CNPJ inválido");
    document.formulario.TMP_NUM.value=""
    document.formulario.TMP_NUM.focus();
    }
        
} 

// função para substituir o window.open e window.location que não aceita segurança ativa
//@list
function wiOpen(url, target, props) {
   if (target) {
      if (target.toLowerCase()=="_blank") {
         target = Date.parse(new Date())+new Date().getMilliseconds();
      }
   } else target = "_self";
   var frm = document.createElement("FORM");
   frm.action = url;
   frm.target = target;
   frm.method = "POST";
   document.body.appendChild(frm);
   if (target!="")  {
      window.open('',target,props);
   }
   frm.submit();
   document.body.removeChild(frm);
}


function Zeros(val, qtde)
{
        if (qtde==undefined) qtde=10;
	val = RetiraChar(val);
	if (val == "")
		return "";
	var tam = qtde - val.length;
	for (var i = 0; i < tam; ++i)
		val = "0" + val;
	return val;
}


function ValidaDataMesExtenso(campodia,campomes,campoano) {
// funcao que tem os parametros dia, mes, ano
// se for uma data valida, retorna a data no formato: "YYYY-MM-DD"
// senao retorna 0
// Exemplo: ValidaDataMesExtenso(12,"agosto",2003)
  var dia= campodia.value;
  var mes= campomes.value;
  var ano= campoano.value;

  if ( dia == "" || dia >31 || dia <1) {
    alert("Sr Usuário, o dia deve ser entre 1 e 31.");
    campodia.value="";
    campodia.focus();
    return 0;
  }

  var mes_aux = mes.toUpperCase();
  var Nmes = 15;
  var data;

 
  if (mes_aux == "JANEIRO") {
    Nmes = 01;}
  if (mes_aux == "FEVEREIRO") {
    Nmes = 02;}
  if (mes_aux == "MARÇO") {
    Nmes = 03;}
  if (mes_aux == "ABRIL") {
    Nmes = 04;}
  if (mes_aux == "MAIO") {
    Nmes = 05;}
  if (mes_aux == "JUNHO") {
    Nmes = 06;}
  if (mes_aux == "JULHO") {
    Nmes = 07;}
  if (mes_aux == "AGOSTO") {
    Nmes = 08;}
  if (mes_aux == "SETEMBRO") {
    Nmes = 09;}
  if (mes_aux == "OUTUBRO") {
    Nmes = 10;}
  if (mes_aux == "NOVEMBRO") {
    Nmes = 11;}
  if (mes_aux == "DEZEMBRO") {
    Nmes = 12;}

     
  if (Nmes == 15) {
    alert("Sr. Usuário, este mês é inválido.")
    campomes.value="";
    campomes.focus();
    return 0;
    
}

 if ((Nmes==04 || Nmes==06 || Nmes==09 || Nmes==11) && dia==31)  {
   alert("Sr. Usuário, " + mes + " não tem 31 dias!")
   return 0;
 }
 if (Nmes == 02)  {
   var bissexto = (ano % 4 == 0 && (ano % 100 != 0 || ano % 400 == 0));
   if (dia>29 || (dia==29 && !bissexto)) {
     alert("Sr. Usuário, Fevereiro não tem "+dia+" dias.");
     return 0;
   }
 }

 var cont=0;
 for (var i=0;i<ano.length;i++){
    cont++;
 }

 if ( ano == "" || cont != 4 ) {
   alert("Sr. Usuário, este ano é inválido.");
    campoano.value="";
    campoano.focus();   
   return 0;
 }


if (dia<10 && Nmes>=10){
  data= ano + "-" + Nmes + "-" + dia;
}

if (Nmes<10 && dia>=10){
 data= ano + "-0" + Nmes + "-" + dia;
}

if ((Nmes<10) && (dia<10)){
  data= ano + "-0"+ Nmes + "-" + dia;
}

if (Nmes>=10 && dia>=10){
 data= ano + "-" + Nmes + "-" + dia;
}

 return data;

}


// Validação do Navegador ******

function verificaBrowser2(url) {
  if (url=="undefined") url = "http://www.tj.se.gov.br/";

  navName = navigator.appName;
  navVersion = navigator.appVersion;
  navAgent = navigator.userAgent;
  compatibleNav = false;
  opera = (navAgent.indexOf('Opera') != -1);

  if (url=="undefined") url = "http://www.tj.se.gov.br/";

  	if (opera)
	{
		navVersion = parseFloat(navAgent.slice(navAgent.indexOf('Opera') + 6))
    	compatibleNav = (navVersion >= 7.11);
		if (!compatibleNav)
		{
			alert('Para acessar o sistema, você precisa ter o Opera 7.11 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
			return;
		}
	}

	netscape = mozilla = Konqueror = iexplore = !opera;

	if (!opera)
	{

		netscape = (navAgent.indexOf('Netscape') != -1);
		if (netscape)
		{
			navVersion = parseFloat(navAgent.slice(navAgent.lastIndexOf('/') + 1));
			compatibleNav = (navVersion >= 7.0);
			if (!compatibleNav)
			{
				alert('Para acessar o sistema, você precisa ter o Netscape 7.0 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
				return;
			}
		}
		
		mozilla = (!netscape && (navAgent.indexOf('rv:') != -1));
		if (mozilla)
		{
			navVersion = parseFloat(navAgent.slice(navAgent.indexOf('rv:') + 3))
			compatibleNav = (navVersion >= 1.0);
			if (!compatibleNav)
			{
				alert('Para acessar o sistema, você precisa ter o Mozilla Firefox 1.0 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
				return;
			}
		}
		
		Konqueror = (navAgent.indexOf('Konqueror') != -1);
		if (Konqueror)
		{
			navVersion = parseFloat(navAgent.slice(navAgent.indexOf('Konqueror') + 10))
			compatibleNav = (navVersion >= 3.1);
			if (!compatibleNav)
			{
				alert('Para acessar o sistema, você precisa ter o Konqueror 3.1 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
				return;
			}
		}
		
		iexplore = (navAgent.indexOf('MSIE') != -1);
		if (iexplore)
		{
			navVersion = parseFloat(navAgent.slice(navAgent.indexOf('MSIE') + 5))
			compatibleNav = (navVersion >= 5.5);
			if (!compatibleNav)
			{
				alert('Para acessar o sistema, você precisa ter o Internet Explorer 5.5 ou superior.\nCaso não tenha, solicite ao seu suporte técnico para instalá-lo.');
				return;
			}
		}
	}
}


// Impede que o usuário digite caracteres não numéricos (evento) ==> colocar no onKeyPress
// Sintax: OnKeyPress="return Somente_Numero(event);"
function Somente_Numero(e)
 {
    var key;
	var keychar;
	var reg;
	
	if(window.event) {
		// for IE, e.keyCode or window.event.keyCode podem ser usados
		key = e.keyCode; 
	}
	else if(e.which) {
	   // Firefox e Netscape
		key = e.which; 
	
	}
	else {
		return true;
	}
    keychar = String.fromCharCode(key); 
	reg = /\d/;  // checa se contem caracteres alfa
	
	if (key != 8) // No Firefox ignora a tecla BACKSPACE
	
	return reg.test(keychar);   // retorna somente numericos

}

/****************************************************
* Feita por: Marcus V.R.Santos
*            -> Função addNome() - utilizada para 
*           adicionar dados na combo;
****************************************************/
 function addNome(objectSelect,texto,valor){
   frm=document.formulario;

   // Adiciona no Select
   if(valor != '') opt = valor
   else opt = objectSelect.length;
   
   objectSelect.options[objectSelect.length] = new Option(texto, opt);
 }

/****************************************************
* Feita por: Marcus V.R.Santos
*            -> Função remNome() - utilizada para 
*           remover dados da combo pelo índice;
****************************************************/
 function remNome(objectSelect,index){

   if(index == -1) return;
   // Remove do Select
   objectSelect.remove(index);
 }
 
/* Feita por: Marcus V.R.Santos
 * Descrição: Função para verificar se a data passada como parâmetro
 *            é ou não maior/menor que a data seguinte(também passada 
 *            como parâmetro) a depender do tipo informado:
 *            1: menor; 2: maior.
 *            A data (obj) é passada como parâmetro da seguinte forma:
 *            'document.forms[0].[VARIAVEL]' para, através da refe-
 *            rência, buscar o valor do objeto.
 *            E, por último, vem a data atual(dtHoje).
 */
 function dtAtual(obj,dt,tipo){
   dtFato=obj.value;
   dtHoje=dt.value;
   if(dtFato==''||dt=='')return;
   if(dtFato.indexOf('/')!=-1) dtFato=Piece(dtFato,"/",3)+Piece(dtFato,"/",2)+Piece(dtFato,"/",1);
   dtFato=parseInt(dtFato);
   dtHoje=parseInt(dtHoje);
   if(tipo==1){
     if(dtFato<dtHoje){
       alert("Sr. usuário, a data informada não pode ser inferior à Data Atual!");
       obj.focus();
       obj.select();
       return false;
     }
   }else if(tipo==2){
     if(dtFato>dtHoje){
       alert("Sr. usuário, a data informada não pode ser superior à Data Atual!");
       obj.focus();
       obj.select();
       return false;
     }
   }else alert("Parâmetro inválido: não existe esse tipo informado!");
   return true;
 }
 
 /* 
 * Descrição: Função para inserir valores em regiões (DIV's).
 *            'div' é a label da div utilizada e 'txt' é o valor
 *            a ser inserido.
 */
 function innerTexto(div,txt){
   with(document){
     getElementById(div).innerHTML=txt;
   }
 }

/*
 * Descrição: Função para realizar uma prévia de Cálculo de Fim de Prazo.
 *            Ela utilizará label's (div/span) contendo um campo para a
 *            data, utilizada como base de cálculo (data do movimento ou
 *            a possível data da publicação), e um espaço para mostrar 
 *            a possível data  de Final de Prazo.
 */
function getDtPrazo(tpprazo,qtdprazo,dtRef,EXP){
  evt=new WIEvent();
  if(dtRef==''){
     alert("Sr. usuário, a data de referência de cálculo está vazia.");
     return;
  }
  if(tpprazo!=''&&(qtdprazo==''||qtdprazo==0)){
     alert("Sr. usuário, a quantidade para o Final de Prazo não pode \n\rser vazia ou igual a zero.");
     return;
  }
  if(tpprazo==1) tpprazo="hh";
  else if(tpprazo==2) tpprazo="dd";
  else if(tpprazo==3) tpprazo="mm";
  else if(tpprazo==4) tpprazo="yy";
  else tpprazo="";
  if(qtdprazo!=''&&tpprazo==''){
     alert("Sr. usuário, escolha o tipo para o Final de Prazo.");
     return;
  }
  evt.writeobj("TMP.TPPRAZO",tpprazo);
  evt.writeobj("TMP.QTDPRAZO",qtdprazo);
  evt.writeobj("TMP.DTREF",dtRef);
  evt.writeobj("TMP.EXP",EXP);
  //evt.debug=true;
  evt.selectdb("evtDtPrazo");
  sizeEvent=evt.rowcount();
  evt.next();
  return evt.column("PRDTPRAZO");
}

function cutBubble() {
 if(event.srcElement.tagName!='INPUT' && event.srcElement.tagName!='IMG'){
 window.event.returnValue=false
 }
}

function janelaadv(codadv,acao,local,oabpagina){
 codadv=Piece(codadv,"#",1)+"%23"+Piece(codadv,"#",2)+"%23"+Piece(codadv,"#",3);
 wiOpen('/scp/cadastros/respcadadv.wsp?TMP_ACAO='+acao+'&TMP_LOCAL='+local+'&TMP_CODOAB='+codadv+'&TMP_OABPAGINA='+oabpagina,'_blank','width=700,height=450,top=10,left=60,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no');
}

