//Script que desabilita o menu contextual do navegador
//Implementada em 20/10/2006 - Marcos Gil
/*function desabilitar(){
    alert ("Esta função está desabilitada.")
    return false
}
*/
document.oncontextmenu=desabilitar 

function callback(pResponseText){
			document.getElementById("txtHint").innerHTML=pResponseText 
}
function FrontPage_Form1_Validator(theForm)
{

  if (theForm.PalChave.value == "")
  {
    alert("Entre com um valor para o campo \"testess\".");
    theForm.PalChave.focus();
    return (false);
  }

  if (theForm.PalChave.value.length < 3)
  {
    alert("Digite pelo menos 3 caracteres no campo \"testess\".");
    theForm.PalChave.focus();
    return (false);
  }

  if (theForm.PalChave.value.length > 200)
  {
    alert("O limite do campo é de 200 caracteres \"testess\".");
    theForm.PalChave.focus();
    return (false);
  }
  return (true);
}


function validaForm1(){  //Form1
   if (document.form1.TXT_NUMERO.value == "" && document.form1.TXT_NANT.value == ""){
      alert ("Preencha o número do processo ou seu respectivo número anterior.")
	  document.form1.TXT_NUMERO.focus()
	  return false;
   }
   //alert(document.form1.TXT_NUMERO.value.length);
   if (!document.form1.TXT_NUMERO.value == "" && document.form1.TXT_NUMERO.value.length < 16){
      alert ("Preencha o campo número com os 13 digitos do processo.");
  	  document.form1.TXT_NUMERO.focus()
	  return false;   
   }
}
function validaForm2(){ //Form2
   if (document.form2.TXT_NOMEPARTE.value == ""){
      alert ("Preencha o nome da parte para realizar a consulta.")
	  return false;
   }			 
	if (document.getElementById("opt_inicia").checked)	{
        if (document.form2.TXT_NOMEPARTE.value.indexOf(" ") <= 0){
   		   alert("Informe pelo menos nome e sobrenome!")
   		   document.form2.TXT_NOMEPARTE.focus()
		   return false
		}  
 	 	if(document.form2.TXT_NOMEPARTE.value.length<15){
		   alert("Nome muito pequeno para realizar a pesquisa!\nTente especificar melhor o nome da parte ou \nutiliza a opção 'Exatamente igual'.")
   		   document.form2.TXT_NOMEPARTE.focus()
   		   return false
   		}

	}
}
function mask(str,textbox,loc,delim){
var locs = loc.split(',');
var naopassou = true;
for (var i = 0; i <= locs.length; i++){
	for (var k = 0; k <= str.length; k++){
	 if (k == locs[i]){
	  if (locs[i] ==  14) delim = "-";
	  if (str.substring(k, k+1) != delim){
	     str = str.substring(0,k) + delim + str.substring(k,str.length);
	  }
	 }
	}
 }
textbox.value = str
}
function seleciona(opt){
   switch (parseInt(opt)) { 
      case 1:  //por nÃºmero de processo
	     document.getElementById("numeroProcesso").style.display="block";
		 document.getElementById("nomeParte").style.display="none";
	     document.getElementById("crime1instancia").style.display="none";		
	     document.getElementById("JECC").style.display="none";
		 break;
	  case 2:  //por nome da parte
	     document.getElementById("numeroProcesso").style.display="none";
		 document.getElementById("nomeParte").style.display="block";
	     document.getElementById("crime1instancia").style.display="none";		 
	     document.getElementById("JECC").style.display="none";		 
		 break;	  	
	  case 3:  //Processos de 1a InstÃ¢ncia - Crime
	     document.getElementById("numeroProcesso").style.display="none";
		 document.getElementById("nomeParte").style.display="none";
	     document.getElementById("crime1instancia").style.display="block";		 
	     document.getElementById("JECC").style.display="none";		 
		 break;	  			  
	  case 4:  //Juizados Especiais CÃ­veis e Criminais
	     document.getElementById("numeroProcesso").style.display="none";
		 document.getElementById("nomeParte").style.display="none";
	     document.getElementById("crime1instancia").style.display="none";		 
	     document.getElementById("JECC").style.display="block";		 
		 break;	  			  		 
	  default:	//por nÃºmero de processo
	     document.getElementById("numeroProcesso").style.display="block";
		 document.getElementById("nomeParte").style.display="none";
	     document.getElementById("crime1instancia").style.display="none";	
	     document.getElementById("JECC").style.display="none";		 	 
		 break;	 
   }
}
function limpaSeletor(){
    document.form1.seletor.value="";
	document.getElementById("txtHint").innerHTML="";
	seleciona(1);
}
function chamaModal(){
   window.open("consulta_or_julg_simples.asp?Acesso=2","Consulta OrgÃ£o","width=400,height=200")
}
function colocaDados(obj){
        //alert(obj.selectedIndex);
	//num = obj.length; // Quantidade de itens da lista
	//for(i = 0 ; i < num ; i++)
	//	{
	//	if (obj.options(obj.selectedIndex).value){
		   document.getElementById("TXT_NOMEORI").value = obj.options[obj.selectedIndex].text;	
		   document.form2.TXT_CODORI.value = obj.options[obj.selectedIndex].value;
		   //alert(document.form2.TXT_CODORI.value);
		   document.getElementById("txtHint").innerHTML="";
	//	}
	//}
   //document.getElementById("TXT_NOMEORI").value = cod;
}
