 <!--
 function FocoInicial(){
 	document.form.matricula.focus();
 }
 function FocoAdesao(){
 	document.form.endereco.focus();
 }
 
 function Matricula(){
 if (document.form.matricula.value == ""){
 alert("Informe o Sua Matricula!");
 document.form.matricula.focus();
 return false;
 }
 var matricula=document.form.matricula.value
 matricula = matricula.replace("-", "");    
 if (matricula.length < 3) {
 alert('Matrícula Incorreta!');
 document.form.matricula.focus();
 return false;
 }
 var base = "54329876543298765432";
 var dv = 0;
 for (var i = (21 - matricula.length); i < 20; i++) {
 dv += base.substr(i, 1) * matricula.substr(i - 21 + matricula.length, 1);
 }
 var dv1 = dv % 11;
 
 if (dv1 == 0) {
 dv = 1;
 } else if (dv1 == 1) {
 dv = 0;
 } else {
 dv = 11 - dv1;
 }
 if (dv != matricula.substr(matricula.length - 1, 1)){
 alert('Matrícula Incorreta!');
 document.form.matricula.focus();
 return false;
 }
 return true;
}




function trim(inputString) {
   // Removes espçoes finais e inicias da string passada. Também remove
   // espaços consecutivos e substitue-os com um espaço with one espaço. se alguma coisa após a string
   // for passada (null, custom object, etc.) ent~ao retornar a entrada.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // chca por espaçoes no início da string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Checa por spaces no fim da string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note que existem dois espaços na string - procure por espaçoes múltiplos dentro da string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1,retValue.length); // De novo, existem dois espaços em cada uma das strings
   }
   return retValue; // Retorna a string trimnada de volta ao usuário
} // Fim da function


function formatMatricula()
{
	var newMatricula = document.form.matricula.value;	
	while(newMatricula.length < 11)
	     newMatricula="0"+newMatricula;	
	document.form.matricula.value = newMatricula;
	return true;
}

function SubmitForm()
{
 //trim nos campos
 document.form.matricula.value=trim(document.form.matricula.value);
  
 //testando campos
 if(!TestaFormSenha()){
 	return false;
 }
 else{
 	if(formatMatricula())
 		document.form.submit();
 }		

}
  

function SubmitTermo()   
{	
	if(document.form.endereco.value.length == 0){
		alert("O Campo Endereço deve ser preenchido");
		document.form.endereco.focus();          
		return;	              
	}     
	else{	
		if(document.form.aceite.checked == false){
			alert("Você deve marcar ESTOU CIENTE para continuar")
			document.form.aceite.focus(); 
			return;
		}
		else{
			alert("Imprima o termo, assine e leve ao RH do seu órgão ou entidade."); 
			document.form.submit();  
		}
	} 		
}  




function testLogin()
{
 //trim nos campos
 document.form.matricula.value=trim(document.form.matricula.value);
  
 //testando campos
 if(!TestaFormSenha()){
 	return false;
 }
 else{
 	if(formatMatricula())
 		return true;
 }		

}



function TestaFormSenha()
{

 var erro=-1;
 var msg = new Array(3); //atençao AQUI... alterar se acrescentar mensagens
 
 msg[0]="Preencha o campo MATRICULA"; 
 msg[1]="Preencha o campo SENHA"; 
 msg[2]="A senha deve conter 8 caracteres"; 

  


 if(document.form.matricula.value=="") 		   {erro=0; document.form.matricula.focus();} 	else 
 if(document.form.senha.value=="") 		       {erro=1; document.form.senha.focus();} 	else 
 if(document.form.senha.value.length!=8)	   {erro=2; document.form.senha.focus();}	


 if(erro>-1)
 {
  alert(msg[erro]);
  return false;  
 }

 return Matricula();     

}


function foco_matricula_para_senha()
{
 if(document.form.matricula.value.length == 11)
  document.form.senha.focus();
}

function yesClose()
	{	  
				
		if (typeof(top.opener)==typeof(window) && 
			typeof(top.opener.top)==typeof(window) && 
			!top.opener.top.closed &&
			typeof(top.opener.length)==typeof(self.length))
		{
		if(navigator.appName.indexOf("Microsoft") != -1)
			top.close();		
		}			
	}
	
function enter(e) 
{	
	// ve quando e o netscape ou IE
	k = (navigator.appName.substring(0,9) == "Microsoft") ? window.event.keyCode : e.which;
	if (k == 13) { // preciona tecla enter							
		SubmitForm();			
	} 	
}

function doOnload() {
	document.form.matricula.select();
	document.form.matricula.focus();
}

function link(URL) {
	window.location.href = URL;
}

 //-->

