<!--
function testabrowser() {
	if (navigator.appName == "Microsoft Internet Explorer" && 	navigator.appVersion.substring(0,1) < 4) {
		alert("Voce está utilizando uma versão de Browser que pode apresentar problemas ao submeter esta consulta. Caso isto ocorra, aperte a tecla ENTER do seu teclado ao invés do botão CONSULTA. Sugerimos que, quando possível voce atualize seu Browser para a versão mais atual. Obrigado.");
	}
}



function Mascara(objeto, evt, mask) {
	var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
	var Letras  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	var Numeros = '0123456789';
	var Fixos  = '().-:/ '; 
	var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";
	
	evt = (evt) ? evt : (window.event) ? window.event : "";
	var value = objeto.value;
	if (evt) {
		 var ntecla = (evt.which) ? evt.which : evt.keyCode;
		 tecla = Charset.substr(ntecla - 32, 1);
		 if (ntecla < 32) return true;
		
		 var tamanho = value.length;
		 if (tamanho >= mask.length) return false;
		
		 var pos = mask.substr(tamanho,1); 
		 while (Fixos.indexOf(pos) != -1) {
			  value += pos;
			  tamanho = value.length;
			  if (tamanho >= mask.length) return false;
			  pos = mask.substr(tamanho,1);
		 }
		
		 switch (pos) {
			case '#' : if (Numeros.indexOf(tecla) == -1) return false; break;
			case 'A' : if (LetrasU.indexOf(tecla) == -1) return false; break;
			case 'a' : if (LetrasL.indexOf(tecla) == -1) return false; break;
			case 'Z' : if (Letras.indexOf(tecla) == -1) return false; break;
			case '*' : objeto.value = value; return true; break;
			default : return false; break;
		 }
	}
	objeto.value = value; 
	return true;
}

function MaskCPF(objeto, evt) { 
return Mascara(objeto, evt, '###.###.###-##');
}


function validaCPF(elemento, myForm) {
	cpf = document.getElementById(elemento).value;
	//alert (cpf);
	cpf = cpf.replace("-" , "");
	cpf = cpf.replace("." , "");
	cpf = cpf.replace("." , "");
	//alert(cpf);
	erro = new String;
	if (cpf.length < 11) erro += "S%E3o necessarios 11 digitos para verifica%E7%E3o do CPF! \n\n"; 
	var nonNumbers = /\D/;
	if (nonNumbers.test(cpf)) erro += "A verifica%E7%E3o de CPF suporta apenas n%FAmeros! \n\n"; 
	if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
		erro += "N%FAmero de CPF inv%E1lido!"
	}
	var a = [];
	var b = new Number;
	var c = 11;
	for (i=0; i<11; i++){
		   a[i] = cpf.charAt(i);
		   if (i < 9) b += (a[i] * --c);
	}
	if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
	b = 0;
	c = 11;
	for (y=0; y<10; y++) b += (a[y] * c--); 
	if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
	if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
		   erro +="CPF Inv%E1lido!";
	}
	if (erro.length > 0){
		   alert(unescape(erro));
		   return false;
	}
	myForm.target = '_blank';
	//return true;
}

function SubmeterGuia(elemento)
{
	validaCPF(elemento);	
	if (erro.length > 0){
		document.getElementById('txtCPFGuia').focus();
		return false;
	}
	document.getElementById('txtDocPrincipal').value = cpf;
	document.getElementById('oculto').value = "C";
	var frm = document.getElementById('frmServico');
	//alert (frm);	
	frm.action = 'http://www.detrannet.sc.gov.br/habilitacao/ConsultaCpf.asp';
	frm.submit();
}
	
function SubmeterAndamentoProcesso(elemento)
{
	validaCPF(elemento);
	if (erro.length > 0){
		document.getElementById('txtCPFAndamentoProcesso').focus();
		return false;
	}
	
	var renach = document.getElementById('txtNuRenach').value;
	if (renach.length != 9) 
	{
		alert(unescape('N%FAmero do Renach inv%E1lido.'));
		document.getElementById('txtNuRenach').focus();
		return false;
	}
		
	document.getElementById('txtDocPrincipal').value = cpf;
	document.getElementById('NumeroRenach').value = renach;
	document.getElementById('oculto').value = "AvancarC";
	
	var frm =	document.getElementById('frmServico');
	frm.action = 'http://www.detrannet.sc.gov.br/habilitacao/ConsultaProcesso.asp';
	frm.submit();
	
}

function SubmeterPontuacaoCNH(elemento)
{
	validaCPF(elemento);
	if (erro.length > 0){
		document.getElementById('txtCPFCNH').focus();
		return false;
	}
	
	var docCNH = document.getElementById('txtNuRegistroCNH').value;

	if (docCNH == "") 
	{
		alert(unescape('N%FAmero do Registro inv%E1lido.'));
		document.getElementById('txtNuRegistroCNH').focus();
		return false;
	}
		
	document.getElementById('txtDocPrincipal').value = cpf;
	document.getElementById('txtDocCNH').value = docCNH;
	document.getElementById('oculto').value = "C";
	
	var frm =	document.getElementById('frmServico');
	frm.action = 'http://www.detrannet.sc.gov.br/servicos/ConsultaPontuacaocondutor.asp';
	frm.submit();

}


