<!--

//----------------------------------------------------------------------------------
/*	FUNÇÕES JAVASCRIPT

01. esconde()
02. mostra()
03. limita(campo)
04. contacampo(campo, tamtxt)
05. initArray( len )
06. initArrayWithValues()
07. isNumeric( valor )
08. rTrim( str ) / lTrim( str ) / Trim( str )
09. right( str , len )
10. strZero( str , len )
11. mid( str , pos , len ) 
12. replace( str , chSrc , chDst )
13. verCgc( CGC )
14. verCpf( CPF )
15. formataCGC (Campo,teclapres)
16. formataCPF (Campo,teclapres)
17. formataTelefone(Campo,teclapres)
18. formataCelular (Campo,teclapres)
19. formataCEP (Campo,teclapres)
20. filtraNR(nr)
21. validaSenha()
22. printPage()
23. formataDado(campo,tammax,pos,teclapres)
24. formataValor(campo,tammax,teclapres)
25. FormataValorAzimute(campo,tammax,teclapres)
26. FormataValorAlt_ERP(campo,tammax,teclapres)
27. FormataValorErpMax(campo,tammax,teclapres)
28. formataVirgula(campo,tammax,pos,teclapres)
29. SaltaCampo (campo,prox,tammax,teclapres)
30. formataData(Campo,teclapres)
31. VerificaJava()
32. mostraLegenda()
33. AbrirJanela(URL, WIDTH, HEIGHT)
34. menuOn(menu, className)
35. menuOff(menu)
36. FormataCNPJ(campo,teclapres)
37. CalculoDvCNPJ(numero)
38. CriticaCNPJ(campo,obrigatorio)
39. ValidaForm(frmCadastro)
40. MascaraCEP()
41. MascaraData()
42. MostrarPlusMinus(nome,imagem)
43. ValidaData()
44. popjanela()
45. FormataValorDecimal(campo,tammax,teclapres,A,D)	// A: Casas antes da vírgula, D:casas deposis da virgula
46. mostraDiv('objeto','s/h')
47. preencheZeros62(campo,casasA,casasD) //Preenche com zeros (6,2)
48. ValidaCPF(obj)
49. ValidaCNPJ(obj,habilita) 
50. ValidaCNPJSemMascara(obj,habilita)
51. checaK(obj)
52. checaPSI(obj)
53. checaAz(obj)
54. checaS(obj)
55. checaM(obj)
56. checaMedAzimAlinhDipolos(obj)
57. checaMedAzimMaxIrradiacao(obj)
58. checaLatitudeGG(obj)
59. checaLatitudeMM(obj)
60. checaLatitudeSS(obj)
61. checaLongitudeGG(obj)
62. checaLongitudeMM(obj)
63. checaLongitudeSS(obj)
64. checaCodAID(obj)
*/

//----------------------------------------------------------------------------------
//Bloco de código para esconder e mostra form

var Ver4 = parseInt(navigator.appVersion) >= 4
var IE4 = ((navigator.userAgent.indexOf("MSIE") != -1) && Ver4)
var block = "all";


function esconde() { document.all.style.visibility = "hidden" }
function mostra() { document.all.style.visibility = "visible" }
//Bloco de código para esconder e mostra all



//----------------------------------------------------------------------------------
// -- Contador para objeto TextArea.

function limita(campo){
	var tamanho = document.all[campo].value.length;
	var tex=document.all[campo].value;
	if (tamanho>=1199) {
		document.all[campo].value=tex.substring(0,1199); 
	}
	return true;
}


//----------------------------------------------------------------------------------
//

function contacampo(campo, tamtxt) {
document.all[tamtxt].value =  1200-document.all[campo].value.length;
}
// --



//----------------------------------------------------------------------------------
//

function initArray( len )
{
	this.length = len;
	for( var i = 0 ; i < len ; i++ )
		this[ i ] = " ";
}


//----------------------------------------------------------------------------------
//

function initArrayWithValues()
{
	this.length = initArrayWithValues.arguments.length;
	for( var i = 0 ; i < this ; i++ )
		this[ i ] = initArrayWithValues.arguments[ i ];
}


//----------------------------------------------------------------------------------
//

function isNumeric( valor )
{
	for( var i = 0 ; i < valor.length ; i++ )
		if( (valor.charAt( i ) < "0") || (valor.charAt( i ) > "9") )
			return false;
	return true;
}


//----------------------------------------------------------------------------------	
//

function rTrim( str )
{
	//Removendo brandos da direita... percorrendo a string inversamente
	for( var i = str.length - 1 ; i >= 0 ; i-- )
		if( str.charAt( i ) != " " )
		{
			return str.substring( 0 , i + 1 );
		}
}	
	
	
//----------------------------------------------------------------------------------	
//

function lTrim( str )
{
	//Removendo brandos da direita... percorrendo a string inversamente
	for( var i = 0 ; i < str.length ; i++ )
		if( str.charAt( i ) != " " )
			return str.substring( i , str.length );
}	



//----------------------------------------------------------------------------------
//

function trim( str )
{
	if( (str == null) || (str == "") )
		return "";
	else
		return rTrim( lTrim( str ) );
}
	


//----------------------------------------------------------------------------------
//

function right( str , len )
{
	//Obtendo a última posição endereçável
	var last = str.length - 1;
	
	//Obtendo a primeira posição desejada
	var first = last - len;
	
	return str.substring( first , last );
}



//----------------------------------------------------------------------------------
//

function strZero( str , len )
{
	//Preparando uma string com a quantidade de zeros desejada
	var zeros = "";
	for( var i = 1 ; i <= len ; i++ )
		zeros = zeros + "0";
		
	//Preparando uma string com os zeros à esquerda
	var ret = zeros + str;	
		
	//Retornando a string com os zeros à esquerda	
	return right( ret , len );
}



//----------------------------------------------------------------------------------
//

function mid( str , pos , len )
{
	return str.substring( pos , pos + len );
}



//----------------------------------------------------------------------------------
//

function replace( str , chSrc , chDst )
{
	//Preparar a variável para retorno
	var ret = "";

	//Percorrer a string toda rocando chSrc por chDst
	for( var i = 0 ; i < str.length ; i++ )
		if( str.charAt( i ) == chSrc )
			ret = ret + chDst;
		else
			ret = ret + str.charAt( i );
			
	return ret;
}


//----------------------------------------------------------------------------------
//Função para validar o CGC

function verCgc( CGC )
{
	var i, Peso, nDigitOne, nDigitTwo;

	if( !isNumeric( CGC ) )
		return false;

	Peso = new initArrayWithValues( 6 , 5 , 4 , 3 , 2 , 9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 );
	nDigitOne = 0;
	nDigitTwo = 0;

	for( var i = 0 ; i < 12 ; i++ )
		nDigitOne = nDigitOne + parseFloat( CGC.charAt( i ) ) * Peso[ i ];

	if( nDigitOne % 11 < 2 )
		nDigitOne = 0;
	else
		nDigitOne = 11 - ( nDigitOne % 11 );

	for( var i = 0 ; i < 12 ; i++ )
		nDigitTwo = nDigitTwo + parseFloat( CGC.charAt( i ) ) * Peso[ i - 1 ];

	nDigitTwo = nDigitTwo + nDigitOne * 2
	
	if( nDigitTwo % 11 < 2 )
		nDigitTwo = 0;
	else
		nDigitTwo = 11 - ( nDigitTwo % 11 );

	return( ( nDigitOne = parseFloat( CGC.charAt( 12 ) ) ) && (nDigitTwo = parseFloat( CGC.charAt( 13 ) ) ) );

}



//----------------------------------------------------------------------------------
//Função para validar o CPF

function verCpf( CPF )
{
	var mx1, mx2, mx3, mx4, mx5, mx6, mx7, mx8, mr, mc1, mc2, mSoma1, mSoma2, mDv1, mDv2;

	if( !isNumeric( CPF ) )
		return false;
   
	//Alterado por Marcio Esteves em 15/07
	if( CPF.length != 11 )
		return false;
	 
	mx1 = parseFloat( CPF.charAt(  0 ) );
	mx2 = parseFloat( CPF.charAt(  1 ) );
	mx3 = parseFloat( CPF.charAt(  2 ) );
	mx4 = parseFloat( CPF.charAt(  3 ) );
	mx5 = parseFloat( CPF.charAt(  4 ) );
	mx6 = parseFloat( CPF.charAt(  5 ) );
	mx7 = parseFloat( CPF.charAt(  6 ) );
	mx8 = parseFloat( CPF.charAt(  7 ) );
	mr  = parseFloat( CPF.charAt(  8 ) );
	mc1 = parseFloat( CPF.charAt(  9 ) );
	mc2 = parseFloat( CPF.charAt( 10 ) );

	mSoma1 = mr * 2 + mx8 * 3 + mx7 * 4 + mx6 * 5 + mx5 * 6 + mx4 * 7 + mx3 * 8 + mx2 * 9 + mx1 * 10;
         
	mDv1 = 11 - ( mSoma1 - ( parseInt( mSoma1 / 11 ) * 11 ) )

	if( mDv1 > 9 )
	   mDv1 = 0;

	if( mc1 != mDv1 )
		return false;

	mSoma2 = mc1 * 2 + mr * 3 + mx8 * 4 + mx7 * 5 + mx6 * 6 + mx5 * 7 + mx4 * 8 + mx3 * 9 + mx2 * 10 + mx1 * 11;
         
	mDv2 = 11 - ( mSoma2 - ( parseInt( mSoma2 / 11 ) * 11 ) );
      
	if( mDv2 > 9 )
  	mDv2 = 0;

	if( mc2 != mDv2 )
		return false;

	return true;

}



//----------------------------------------------------------------------------------
// Função para formatar CGC ( Ex.: 99.999.999/9999-99 )

function formataCGC (Campo,teclapres){
	 var tecla = teclapres.keyCode; 
	 vr = document.all[Campo].value; 
	 vr = vr.replace( ".", "" ); 
  	 vr = vr.replace( ".", "" ); 
	 vr = vr.replace( "-", "" ); 
	 vr = vr.replace( "/", "" ); 
 	 vr = vr.replace( "/", "" ); 

	 tam = vr.length + 1; 
 
	 if ( tecla != 9 && tecla != 8 ){  
	 	if ( tam > 2 && tam < 5) 
	 		document.all[Campo].value = vr.substr( 0, tam - 2  ) + '.' + vr.substr( tam - 3, tam ); 
	 	if ( tam >= 5 && tam <= 14) 
	 		document.all[Campo].value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr(5, 3 )+ '/' + vr.substr(8, 4 )+ '-' + vr.substr(12, 2 ); } 
} 



//----------------------------------------------------------------------------------
// Função para formatar CPF ( Ex.: 999.999.999-9 )

function formataCPF (Campo,teclapres){
	 var tecla = teclapres.keyCode; 
	 vr = document.all[Campo].value; 
	 vr = vr.replace( ".", "" ); 
  	 vr = vr.replace( ".", "" ); 
	 vr = vr.replace( "-", "" ); 
	 vr = vr.replace( "/", "" ); 
 	 vr = vr.replace( "/", "" ); 

	 tam = vr.length + 1; 
 
	 if ( tecla != 9 && tecla != 8 ){  
	 	if ( tam > 2 && tam < 5) 
	 		document.all[Campo].value = vr.substr( 0, tam - 3  ) + '.' + vr.substr( tam - 3, tam ); 
	 	if ( tam >= 5 && tam <= 10) 
	 		document.all[Campo].value = vr.substr( 0, 3 ) + '.' + vr.substr( 3, 3 ) + '.' + vr.substr(6, 3 )+ '-' + vr.substr(9, 2 ); } 
} 


//----------------------------------------------------------------------------------
// Função para frmCadastroatar CPF frmCadastro Parceiro ( Ex.: 999.999.999-9 )

function formataCPF(Campo,teclapres){
	 var tecla = teclapres.keyCode; 
	 vr = document.all[Campo].value; 
	 vr = vr.replace( ".", "" ); 
  	 vr = vr.replace( ".", "" ); 
	 vr = vr.replace( "-", "" ); 
	 vr = vr.replace( "/", "" ); 
 	 vr = vr.replace( "/", "" ); 

	 tam = vr.length + 1; 
 
	 if ( tecla != 9 && tecla != 8 ){  
	 	if ( tam > 2 && tam < 5) 
	 		document.all[Campo].value = vr.substr( 0, tam - 3  ) + '.' + vr.substr( tam - 3, tam ); 
	 	if ( tam >= 5 && tam <= 10) 
	 		document.all[Campo].value = vr.substr( 0, 3 ) + '.' + vr.substr( 3, 3 ) + '.' + vr.substr(6, 3 )+ '-' + vr.substr(9, 2 ); } 
} 


//----------------------------------------------------------------------------------
// Função para frmCadastroatar Telefone ( Ex.: 999-9999 )

function formataTelefone(Campo,teclapres){
	 var tecla = teclapres.keyCode; 
	 vr = document.all[Campo].value; 
	 vr = vr.replace( ".", "" ); 
  	 vr = vr.replace( ".", "" ); 
	 vr = vr.replace( "-", "" ); 
	 vr = vr.replace( "/", "" ); 
 	 vr = vr.replace( "/", "" ); 

	 tam = vr.length + 1; 
 
	 if ( tecla != 9 && tecla != 8 ){  
	 	if ( tam > 2 && tam < 3) 
	 		document.frmCadastro[Campo].value = vr.substr( 0, tam - 3  ) + '-' + vr.substr( tam - 3, tam ); 
	 	if ( tam >= 3 && tam <= 8) 
	 		document.frmCadastro[Campo].value = vr.substr( 0, 3 ) + '-' + vr.substr( 3, 4 ); } 
} 



//----------------------------------------------------------------------------------
// Função para formatar Celular ( Ex.: 9999-9999 )

function formataCelular (Campo,teclapres){
	 var tecla = teclapres.keyCode; 
	 vr = document.all[Campo].value; 
	 vr = vr.replace( ".", "" ); 
  	 vr = vr.replace( ".", "" ); 
	 vr = vr.replace( "-", "" ); 
	 vr = vr.replace( "/", "" ); 
 	 vr = vr.replace( "/", "" ); 

	 tam = vr.length + 1; 
 
	 if ( tecla != 9 && tecla != 8 ){  
	 	if ( tam > 2 && tam < 3) 
	 		document.all[Campo].value = vr.substr( 0, tam - 4  ) + '-' + vr.substr( tam - 4, tam ); 
	 	if ( tam >= 3 && tam <= 8) 
	 		document.all[Campo].value = vr.substr( 0, 4 ) + '-' + vr.substr( 4, 4 ); } 
} 



//----------------------------------------------------------------------------------
// Função para formatar CEP ( Ex.: 99.999-999 )

function formataCEP (Campo,teclapres){
	 var tecla = teclapres.keyCode; 
	 vr = document.all[Campo].value; 
	 vr = vr.replace( ".", "" ); 
  	 vr = vr.replace( ".", "" ); 
	 vr = vr.replace( "-", "" ); 
	 vr = vr.replace( "/", "" ); 
 	 vr = vr.replace( "/", "" ); 

	 tam = vr.length + 1; 
 
	 if ( tecla != 9 && tecla != 8 ){  
	 	if ( tam > 2 && tam < 3) 
	 		document.all[Campo].value = vr.substr( 0, tam - 2  ) + '.' + vr.substr( tam - 3, tam ); 
	 	if ( tam >= 3 && tam <= 8) 
	 		document.all[Campo].value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 )+ '-' + vr.substr( 5, 3 ); } 
} 




//----------------------------------------------------------------------------------
//

function filtraNr(nr)
{
	//Retirar os caracteres inválidos
	nr = replace( nr , "." , "" );
	nr = replace( nr , "," , "" );
	nr = replace( nr , "-" , "" );
	nr = replace( nr , "/" , "" );

	//Retornar o número sem os caracteres inválidos	
	return nr;
}




//----------------------------------------------------------------------------------
//

function validaSenha()
{
	//Obtendo a senha
	var senha = document.all.senha.value;
	
	//Senha com tamanho inválido
	if( (senha.length != 8) || (!isNumeric( senha )) )
  {
	  alert( "Senha inválida! InfrmCadastroe a senha com 8 dígitos numéricos denominada senha BB Office Bank." );
		return false;
	}
	return true;
}




//----------------------------------------------------------------------------------
//

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1); 

function printPage()
{
  if (pr) // NS4, IE5
    window.print()
  else if (da && !mac) // IE4 (Windows)
    vbPrintPage()
  else // other browsers
    alert("Desculpe seu browser não suporta esta função. Por favor utilize a barra de trabalho para imprimir a página.");
  return false;
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}




//----------------------------------------------------------------------------------
//

function formataDado(campo,tammax,pos,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.all[campo].value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length ;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){ tam = tam - 1 ; }
			
	if ( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){
	 		document.all[campo].value = vr ;}
		if ( tam > pos && tam <= tammax ){
			document.all[campo].value = vr.substr( 0, tam - pos ) + '-' + vr.substr( tam - pos, tam );}
	}
}



//----------------------------------------------------------------------------------
//

function formataValor(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.all[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;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){ 
	 		document.all[campo].value = vr ; }
	 	if ( (tam > 2) && (tam <= 5) ){
	 		document.all[campo].value = vr.substr( 0, tam - 2 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 6) && (tam <= 8) ){
	 		document.all[campo].value = vr.substr( 0, tam - 5 ) + '.' + vr.substr( tam - 5, 3 ) + ',' + vr.substr( tam - 2, tam ) ; }
	 	if ( (tam >= 9) && (tam <= 11) ){
	 		document.all[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) ){
	 		document.all[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) ){
	 		document.all[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 ) ;}
	}		
	
}


//----------------------------------------------------------------------------------
// Valores para Azimute(potência) - Sistema SRD - ex.: 999.9

function FormataValorAzimute(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.all[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;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 3 ){ 
	 		document.all[campo].value = vr ; }
	 	if ( (tam > 3) && (tam <= 6) ){
	 		document.all[campo].value = vr.substr( 0, tam - 1 ) + '.' + vr.substr( tam - 1, tam - 3 ) ; }

	}		
	
}



//----------------------------------------------------------------------------------
// Valores para Altura e ERP - Sistema SRD - ex.: 999.99

function FormataValorAlt(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.all[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;

	if (tam < tammax && tecla != 8){ tam = vr.length + 2 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 4 ){ 
	 		document.all[campo].value = vr ; }

	 	if ( (tam > 4) && (tam <= 5) ){
	 		document.all[campo].value = vr.substr( 0, tam - 1 ) + '.' + vr.substr( tam - 1, tam - 3 ) ; }

	}		
	
}


function FormataValorERP(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.all[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;

	if (tam < tammax && tecla != 8){ tam = vr.length + 2 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 3 ){ 
	 		document.all[campo].value = vr ; }

	 	if ( (tam > 3) && (tam <= 4) ){
	 		document.all[campo].value = vr.substr( 0, tam - 1 ) + '.' + vr.substr( tam - 1, tam - 3 ) ; }

	}		
	
}

//----------------------------------------------------------------------------------
// Valores para Potência ERP Máxima - Sistema SRD - ex.: 9999.99999 está 999,99

function FormataValorErpMax(campo,tammax,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.all[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;
	
	
		
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 4 ){ 
	 		document.all[campo].value = vr ; }

	 	if ( (tam > 4) && (tam <= 5) )
	 	{
	 		document.all[campo].value = vr.substr( 0, tam - 1 ) + '.' + vr.substr( tam - 1, tam - 4 ) ; 
	 	}

	}		
	
}


//----------------------------------------------------------------------------------
//

function formataVirgula(campo,tammax,pos,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.all[campo].value;
	vr = vr.replace( "-", "" );
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( ",", "" );
	tam = vr.length ;

	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){ tam = tam - 1 ; }
			
	if ( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= 2 ){
	 		document.all[campo].value = vr ;}
		if ( tam > pos && tam <= tammax ){
			document.all[campo].value = vr.substr( 0, tam - pos ) + ',' + vr.substr( tam - pos, tam );}
	}
}


//----------------------------------------------------------------------------------
//Função para após ter ocorrido a formatacao do campo, pular para o próximo

function SaltaCampo (campo,prox,tammax,teclapres){
	var tecla = teclapres.keyCode;
	vr = document.all[campo].value;
	if( tecla == 109 || tecla == 188 || tecla == 110 || tecla == 111 || tecla == 223 || tecla == 108 ){
		document.all[campo].value = vr.substr( 0, vr.length - 1 ); }
	else{
	 	vr = vr.replace( "-", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( "/", "" );
	 	vr = vr.replace( ",", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	vr = vr.replace( ".", "" );
	 	tam = vr.length;	


		
	 	if (tecla != 0 && tecla != 9 && tecla != 16 )
			if ( tam == tammax )	
				document.all[prox].focus() ;	}
}



//----------------------------------------------------------------------------------
//formata Data ( Ex.: 99/99/9999 )

function formataData(Campo,teclapres) {
	var tecla = teclapres.keyCode;
	vr = document.all[Campo].value;
	vr = vr.replace( ".", "" );
	vr = vr.replace( "/", "" );
	vr = vr.replace( "/", "" );
	tam = vr.length + 1;

	if ( tecla != 9 && tecla != 8 ){
		if ( tam > 2 && tam < 5 )
			document.all[Campo].value = vr.substr( 0, tam - 2  ) + '/' + vr.substr( tam - 2, tam );
		if ( tam >= 5 && tam <= 10 )
			document.all[Campo].value = vr.substr( 0, 2 ) + '/' + vr.substr( 2, 2 ) + '/' + vr.substr( 4, 4 ); }
}



//----------------------------------------------------------------------------------
//

 function VerificaJava()
 	{
	if (navigator.javaEnabled())
		document.all.javas.value="sim"
	}



//----------------------------------------------------------------------------------
//Mostra Legenda

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function mostraLegenda() { //v3.0
  var i,p,v,obj,iTam,iAlt,args=mostraLegenda.arguments;
  for (i=0; i<(args.length-2); i+=3)
	if ((obj=MM_findObj(args[i]))!=null) 
		{ 
		v=args[i+2];
		if (obj.style) 
			{
			obj=obj.style;
			if(document.all)
				{
				iTam=parseInt(obj.width);
				iAlt=parseInt(obj.height);
				obj.pixelLeft = event.clientX + document.body.scrollLeft;
				if(obj.pixelLeft>360) obj.pixelLeft-=iTam;
				obj.pixelTop=event.clientY + document.body.scrollTop - iAlt;
				}
			else
				{
				document.captureEvents(Event.MOUSEMOVE);
				document.onmousemove=newPos;
				}
			 v=(v=='show')?'visible':(v='hide')?'hidden':v; 
			}
		obj.visibility=v; 
		}
}



//----------------------------------------------------------------------------------
//

function AbrirJanela(URL, WIDTH, HEIGHT, scrollbars) {
  windowprops = "left=5,top=5,width=" + WIDTH + ",height=" + HEIGHT+", scrollbars="+ scrollbars+",toolbar=0,location=0,directories=0,status=1,menubar=0,resizable=1";
  preview = window.open(URL, "preview", windowprops);  
}



//----------------------------------------------------------------------------------
//

function menuOn(menu, className)
{
	if (!menu.isMenuSelected)
	{
		menu.oldClassName = menu.className;
		menu.className = className;
	}
}


//----------------------------------------------------------------------------------
//

function menuOff(menu)
{
	if (!menu.isMenuSelected)
	{
		menu.className = menu.oldClassName;
	}
}


//----------------------------------------------------------------------------------
//Mascara e validação do CNPJ

function FormataCNPJ(campo,teclapres) {
  var tecla = teclapres.keyCode;
  vr = document.frmCadastro[campo].value;
  if ("0123456789".search(vr.substr(vr.length-1,1)) == -1) {
      vr = vr.substr(0, vr.length-1);
      document.frmCadastro[campo].value = vr;
  }
  else {   
    vr = vr.replace( ".", "" );
    vr = vr.replace( ".", "" );
    vr = vr.replace( "/", "" );
    vr = vr.replace( "-", "" );
    tam = vr.length;
    if ( tecla != 9 && tecla != 8 ) {
      if ( tam > 1 && tam < 4 ) {
        document.frmCadastro[campo].value = vr.substr( 0, 2 ) + '.' + vr.substr( 2 );
      }
      if ( tam > 4 && tam < 7 ) {
        document.frmCadastro[campo].value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5 );
      } 
      if ( tam > 7 && tam < 11 ) {
        document.frmCadastro[campo].value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '/' + vr.substr( 8 );
      }
      if ( tam > 11 && tam <= 14 ) {
        document.frmCadastro[campo].value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '/' + vr.substr( 8, 4 ) + "-" + vr.substr( 12 );
      }
    }
  }
}


//----------------------------------------------------------------------------------
//

function CalculoDvCNPJ(numero) {
  var ind = "6543298765432";
  var i = 0;
  var soma = 0;
  var dig1 = 0;
  var dig2 = 0;
  temerro = false;

  for (i=0; i < 12; i++) {
    soma += numero.substr(i,1) * ind.substr(i+1,1);
  }

  dig1 = 11 - (soma % 11);
  if (dig1 == 10 || dig1 == 11) {
    dig1 = 0;
  }
  if (numero.substr(12,1) != dig1) {
      temerro = true;
  }
  else {  
    soma = 0;
    for (i=0; i < 13; i++) {
      soma += numero.substr(i,1) * ind.substr(i,1);
    } 
    dig2 = 11 - (soma % 11);
    if (dig2 == 10 || dig2 == 11) {
       dig2 = 0;
    }
    if (numero.substr(13,1) != dig2) {
      temerro = true;
    }
  }
  return(temerro);
}



//----------------------------------------------------------------------------------
//

function CriticaCNPJ(campo,obrigatorio) {
  temerro=false;
  dv=0;
  vr = document.frmCadastro[campo].value;  
  if (obrigatorio == "1") {
    if (document.frmCadastro[campo].value.length == 0) {
      //setColor(document.frmCadastro[campo], "#FFCC66");
      temerro=true;
      //document.frmCadastro[campo].select();
      //document.frmCadastro[campo].focus();
     
    
   }
  }
   
  if (!temerro && document.frmCadastro[campo].value.length > 0) {  
    vr = vr.replace( ".", "" );
    vr = vr.replace( ".", "" );
    vr = vr.replace( "/", "" );
    vr = vr.replace( "-", "" );
    if (CalculoDvCNPJ(vr)) {
      
      temerro=true;
     // document.frmCadastro[campo].select();
      //document.frmCadastro[campo].focus();
      
      
    }
  }

  if (!temerro) {
     
  }
  return(temerro);
}



//----------------------------------------------------------------------------------
//

function ValidaForm(frmCadastro)
{
	
		if(CriticaCNPJ('CNPJ',1)==false) 
		{
			return true;
		
		}
		else
		{
			alert('CNPJ Inválido');
			document.frmCadastro.CNPJ.value="";
			
			return false; 
		}
	
}


//----------------------------------------------------------------------------------
// mascara CEP

function MascaraCEP()
{
if(document.frmCadastro.CEPSede.value.length == 5)
	{
	document.frmCadastro.CEPSede.value= document.frmCadastro.CEPSede.value + "-";
	}
}



//----------------------------------------------------------------------------------
//

function MascaraData()
{
if(document.frmCadastro.CEPSede.value.length == 2)
	{
		document.frmCadastro.CEPSede.value= document.frmCadastro.CEPSede.value + "/";
		if(document.frmCadastro.CEPSede.value.length == 5)
		{
		document.frmCadastro.CEPSede.value= document.frmCadastro.CEPSede.value + "/";
		}
	}
}



//----------------------------------------------------------------------------------
//mostrar formulário
function MostrarPlusMinus(nome,imagem)
{ 
	var det = document.all(nome);
	var gif = document.all(imagem);

	if(null != gif)
	{ 
		if(null != det)
	   {
			if (det.style.display == "")
			{
				det.style.display = "none";
				gif.src = "/srd/images/Mais.gif";
			}
			else
			{
				det.style.display = "";
				gif.src = "/srd/images/Menos.gif";
			}
		}  
	}
	else
	{
		if (det.style.display == "")
		{
			det.style.display = "none";
		}
		else
		{
			det.style.display = "";
		}
	}
}



//----------------------------------------------------------------------------------
//Valida data
function validadata(data)
{
	var v_dia, v_mes, v_ano, v_data;
	
	data = data.replace( ".", "" ); 
  	data = data.replace( ".", "" ); 
	data = data.replace( "-", "" );
	data = data.replace( "-", "" );  
	data = data.replace( "/", "" ); 
 	data = data.replace( "/", "" ); 
	
	v_data = data;
	
	
	v_dia = v_data.substring(0,2);
	v_mes = v_data.substring(2,4);
	v_ano = v_data.substring(4,12);
	
					
	if (((v_ano < 1900) || (v_ano > 2020)) && (v_ano.length != 0))
	{
		alert('Data inválida');
		statusData = false;
		return statusData;
	}

	if (v_dia > 31)
	{
		alert('Data inválida');
		statusData = false;
		return statusData;
	}
			
	if (v_mes > 12)
	{
		alert('Data inválida');
		statusData = false;
		return statusData;
	}
			


	if (v_dia == 31)
	{
		if ((v_mes == 04) || (v_mes == 06) || (v_mes == 09) || (v_mes == 11))
		{
			alert('Data inválida');
			statusData = false;
			return statusData;
		}
	}
		

	if (v_mes == 02)
	{
		if (!(v_ano%4)) 
		{
			if (v_dia > 29)
			{
			alert('Data inválida');
			statusData = false;
			return statusData;
			}
		}
		else if (v_dia > 28)
		{
			alert('Data inválida');
			statusData = false;
			return statusData;
		}
	}
			
	//o -if- abaixo testa se algum campo foi preenchido e outro deixado em branco deixando a data incompleta

	if (((v_dia != "") || (v_mes != "") || (v_ano != "")) && ((v_dia == "") || (v_mes == "") || (v_ano == "")))
	{
		statusData = false;
		return statusData;
	}
	
	
	//Verifica se digitou o dia anterior ao atual
	//if(v_data < data_Atual){
	//	alert('Data inválida');
	//	statusData = false;
	//	return statusData;
	//}
	
	
	
	statusData = true;
	return statusData;		
}


//----------------------------------------------------------------------------------
//Abre janela por cima
function popjanela(a,b,x,y) { window.open(a,b,'width=' + x + ',height=' + y + ',resizable=0,status=0,menubar=0,scrollbars=1'); }


//----------------------------------------------------------------------------------
// Formatação - Recebe parametros de quantidades antes(A) e depois(D) da vírgura

function FormataValorDecimal(campo,tammax,teclapres, A,D) {
	
	var tecla = teclapres.keyCode;
	//vr = document.all[campo].value;
	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;
	
			
	if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

	if (tecla == 8 ){	tam = tam - 1 ; }
		
	if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ){
		if ( tam <= A ){ 
	 		campo.value = vr ; }

	 	if ( (tam > A) && (tam <= (A+1)) ){
	 		campo.value = vr.substr( 0, tam - 1 ) + '.' + vr.substr( tam - 1, tam - 3 ) ; }
	}		
}

//------------------------------------------------------------------------------------
// Mostra Div

//Script para controlar DIV
var isIE=document.all?true:false;
var isDOM=document.getElementById?true:false;
var isNS4=document.layers?true:false;

/* _w : which ID (1) or (2) */
/* _h : (h)ide or (s)how */
function mostraDiv(_w,_h) {
  if (isDOM){
    if (_h=='s') document.getElementById(_w).style.display='';
    if (_h=='h') document.getElementById(_w).style.display='none';
	}
  
  else if (isIE){
    if (_h=='s') eval("document.all."+_w+".style.visibility='visible';");
    if (_h=='h') eval("document.all."+_w+".style.visibility='hidden';");
	}
  
  else if(isNS4){
    if (_h=='s') eval("document.layers['"+_w+"'].visibility='show';");
    if (_h=='h') eval("document.layers['"+_w+"'].visibility='hide';");
	}
}


//------------------------------------------------------------------------------------
//Preenche com Zeros 6,2 (S)
function preencheZeros62(campo,casasA,casasD){

//Campo: Campo do form para deixar formatado
//CasasA: Relativo a qtd de casas ANTES da vírgula.
//CasasD: Relativo a qtd de casas APÓS a vírgula.
	
	campoAux = campo.name;
	campoVal = campo.value;
	tam		 = campo.value.length;
	campoVal = campoVal.replace( ".", "" ); 
			
	if((tam != '') && (tam < 6) && (campo.value != '000000')){
		
		if(casasA == '6'){zerosA = '000';}
		if(casasD == '2'){zerosD = '.00';}
	
		if (tam == 1){
			campo.value = (zerosA + campoVal + zerosD);
			}
			
		if (tam == 2){
			campo.value = ('00' + campoVal + zerosD);
			}	
			
		if (tam == 3){
			campo.value = ('0' + campoVal + zerosD);
			}
			
		if (tam == 4){
			campo.value = (campoVal);
			}
			
		if (tam == 5){
			campo.value = (campoVal + '00');
			}							
	}	
		
}


//------------------------------------------------------------------------------------
function ValidaCPF(obj)
{
	var str
	str=obj.value
  
	if (str != "")
	{
	   var MaskNumber = "";
	   var Lpad = "00000000000";
	   for (var i = 0; i < str.length; i++)
	   {
	      var chr = str.substring(i, i + 1);
	      if (chr >= "0" && chr <= "9")
	      {
	         MaskNumber += chr;
	      }
	   }
	   MaskNumber = Lpad.substring(0, 11 - MaskNumber.length) + MaskNumber;
	   MaskNumber = MaskNumber.substring((MaskNumber.length - 11), MaskNumber.length);
	   SumBlock1 = 0,
	   RemBlock1 = 0;
	   SumBlock2 = 0;
	   RemBlock2 = 0;

	   for (var i = 0; i < (MaskNumber.length - 2); i++)
	   {
	      var chr = MaskNumber.substring(i, i + 1);
	      SumBlock1 += eval(chr * (10 - i));
	   }
	   RemBlock1 = eval(SumBlock1 - (parseInt(SumBlock1 / 11) * 11));
	   if (RemBlock1 == 0 || RemBlock1 == 1)
	   {
	      RemBlock1 = 0;
	   }
	   else
	   {
	      RemBlock1 = eval(11 - RemBlock1);
	   }
	   for (var i = 0; i < (MaskNumber.length - 1); i++)
	   {
	      var chr = MaskNumber.substring(i, i + 1);
	      SumBlock2 += eval(chr * (11 - i));
	   }
	   RemBlock2 = eval(SumBlock2 - (parseInt(SumBlock2 / 11) * 11));
	   if (RemBlock2 == 0 || RemBlock2 == 1)
	   {
	      RemBlock2 = 0;
	   }
	   else
	   {
	      RemBlock2 = eval(11 - RemBlock2);
	   }
	   var result = "";
		if (RemBlock1 == parseInt(MaskNumber.substring(09,10)) && RemBlock2 == parseInt(MaskNumber.substring(10,11)))
		{
			if(MaskNumber != '00000000000' && MaskNumber != '11111111111' && MaskNumber != '22222222222' && MaskNumber != '33333333333' && MaskNumber != '44444444444' && MaskNumber != '55555555555' && MaskNumber != '66666666666' && MaskNumber != '77777777777' && MaskNumber != '88888888888' && MaskNumber != '99999999999') 
			{
				if (str.length<14)
				{
					obj.value=''
					for (var i = 0; i < str.length; i++)
					{
						obj.value = obj.value + str.substr(i,1)
						mascarar(obj,'###.###.###-##')
					}
				}
				return true;
			}else
			{
				alert("CPF Inválido!")
				obj.value = "";
				return false;
			}
		}else
		{
			alert("CPF Inválido!")
			obj.value = "";
			return false;
		} 
	}
}

//------------------------------------------------------------------------------------
function ValidaCNPJ(obj,habilita) 
{
	var str
	str=obj.value
	 
	if(habilita=="Sim")
	{
		if (str != "")
		{
			var MaskNumber = "";
			var Lpad = "00000000000000";
			for (var i = 0; i < str.length; i++)
			{
			   var chr = str.substring(i, i + 1);
			   if (chr >= "0" && chr <= "9")
			   {
			      MaskNumber += chr;
			   }
			}
	      MaskNumber = Lpad.substring(0, 14 - MaskNumber.length) + MaskNumber;
	      MaskNumber = MaskNumber.substring((MaskNumber.length - 14), MaskNumber.length);
	      SumBlock1 = 0,
	      RemBlock1 = 0;
	      SumBlock2 = 0;
	      RemBlock2 = 0;
			for (var i = 0; i < (MaskNumber.length - 2); i++)
			{
			   var chr = MaskNumber.substring(i, i + 1);
			   if (i <= 3)
			   {
			      SumBlock1 += eval(chr * (5 - i));
			   }
			   else
			   {
			      SumBlock1 += eval(chr * (13 - i));
			   }
			}
	      RemBlock1 = eval(SumBlock1 - (parseInt(SumBlock1 / 11) * 11));
	      if (RemBlock1 <= 1)
	      {
	         RemBlock1 = 0;
	      }
	      else
	      {
	         RemBlock1 = eval(11 - RemBlock1);
	      }
			for (var i = 0; i < (MaskNumber.length - 2); i++)
			{
			   var chr = MaskNumber.substring(i, i + 1);
			   if (i <= 4)
			   {
			      SumBlock2 += eval(chr * (6 - i));
			   }
			   else
			   {
			      SumBlock2 += eval(chr * (14 - i));
			   }
			}
			SumBlock2 += eval(2 * RemBlock1);
			RemBlock2 = eval(SumBlock2 - (parseInt(SumBlock2 / 11) * 11));
			if (RemBlock2 <= 1)
			{
			   RemBlock2 = 0;
			}
			else
			{
			   RemBlock2 = eval(11 - RemBlock2);
			}
			var result = "";
			if ((RemBlock1 == MaskNumber.substring(12,13)) && (RemBlock2 == MaskNumber.substring(13,14)))
			{
	 			if (str.length<18)
	 			{
	 				obj.value=''
	 				for (var i = 0; i < str.length; i++)
	 				{
	 					obj.value = obj.value + str.substr(i,1)
	 					mascarar(obj,'##.###.###/####-##')
	 				}
	 			}
	 			return true;
			}
			else
			{
				alert("CNPJ Inválido!")
				obj.value = "";
				return false;
			} 
		}
	} 
}

//------------------------------------------------------------------------------------
function ValidaCNPJSemMascara(obj,habilita) 
{
	var str
	str=obj.value
	
	if(habilita=="Sim")
	{
		if (str != "")
		{
			var MaskNumber = "";
			var Lpad = "00000000000000";
			for (var i = 0; i < str.length; i++)
			{
			   var chr = str.substring(i, i + 1);
			   if (chr >= "0" && chr <= "9")
			   {
			      MaskNumber += chr;
			   }
			}
	      MaskNumber = Lpad.substring(0, 14 - MaskNumber.length) + MaskNumber;
	      MaskNumber = MaskNumber.substring((MaskNumber.length - 14), MaskNumber.length);
	      SumBlock1 = 0,
	      RemBlock1 = 0;
	      SumBlock2 = 0;
	      RemBlock2 = 0;
			for (var i = 0; i < (MaskNumber.length - 2); i++)
			{
			   var chr = MaskNumber.substring(i, i + 1);
			   if (i <= 3)
			   {
			      SumBlock1 += eval(chr * (5 - i));
			   }
			   else
			   {
			      SumBlock1 += eval(chr * (13 - i));
			   }
			}
	      RemBlock1 = eval(SumBlock1 - (parseInt(SumBlock1 / 11) * 11));
	      if (RemBlock1 <= 1)
	      {
	         RemBlock1 = 0;
	      }
	      else
	      {
	         RemBlock1 = eval(11 - RemBlock1);
	      }
			for (var i = 0; i < (MaskNumber.length - 2); i++)
			{
			   var chr = MaskNumber.substring(i, i + 1);
			   if (i <= 4)
			   {
			      SumBlock2 += eval(chr * (6 - i));
			   }
			   else
			   {
			      SumBlock2 += eval(chr * (14 - i));
			   }
			}
			SumBlock2 += eval(2 * RemBlock1);
			RemBlock2 = eval(SumBlock2 - (parseInt(SumBlock2 / 11) * 11));
			if (RemBlock2 <= 1)
			{
			   RemBlock2 = 0;
			}
			else
			{
			   RemBlock2 = eval(11 - RemBlock2);
			}
			var result = "";
			if ((RemBlock1 == MaskNumber.substring(12,13)) && (RemBlock2 == MaskNumber.substring(13,14)))
			{
	 			if (str.length<18)
	 			{
	 				obj.value=''
	 				for (var i = 0; i < str.length; i++)
	 				{
	 					obj.value = obj.value + str.substr(i,1)
	 				}
	 			}
	 			return true;
			}
			else
			{
				alert("CNPJ Inválido!")
				obj.value = "";
				return false;
			} 
		}
	} 
}


//------------------------------------------------------------------------------------
//ERPmáx
function checaERPmax(obj){
				
	//Checa na 2 posição entrada	
	if (obj.value != ""){
						
		var valor = obj.value;
		var vr = valor.replace( ",", "." ); 				
						
		if (isNaN(vr)){
			alert('Digite apenas número.');
			obj.focus();
			obj.value = '';
			return(false);
			}
				
		else if (vr > 9999.9999){
			alert('Valores permitido apenas entre 0000,0001 e 9999,9999.');
			obj.focus();
			obj.value = '';
			return(false);
			}	
		else if (vr == 0){
			alert('Valores permitido apenas entre 0000,0001 e 9999,9999.');
			obj.focus();
			obj.value = '';
			return(false);
			}	
	}
}

//-------------------------------------------------------------
//MedAzimute
function checaMedAzimute(obj)
{
	//Checa na 2 posição entrada	
	if (obj.value != "")
	{
		var valor = obj.value;
		var vr = valor.replace( ",", "." ); 	
		
		if (isNaN(vr))
		{
			alert('Digite apenas número.');
			obj.focus();
			obj.value = '';
			return(false);
		}
			
		else if (vr < 0)
		{
			alert('Valores permitido apenas entre 0 e 359.');
			obj.focus();
			obj.value = '';
			return(false);
		}
				
		else if (vr > 359)
		{
			alert('Valores permitido apenas entre 0 e 359.');
			obj.focus();
			obj.value = '';
			return(false);
		}	
	}
}

//-------------------------------------------------------------
//MedAltura
function checaMedAltura(obj)
{
	//Checa na 2 posição entrada	
	if (obj.value != "")
	{
		var valor = obj.value;
		var vr = valor.replace( ",", "." ); 	
		//var vr = vr.replace( "-", "" ); 
					
		if (isNaN(vr))
		{
			alert('Digite apenas número.');
			return false;
			obj.focus();
			obj.value = '';
			return(false);
		}
		else if (vr < -1000)
		{
			var vr = valor.replace( "-", "" ); 
			alert('Valores permitido apenas entre -1000 e 2000.');
			obj.focus();
			obj.value = '';
			return(false);
		}
				
		else if (vr > 2000)
		{
			var vr = valor.replace( "-", "" );	
			alert('Valores permitido apenas entre -1000 e 2000.');
			obj.focus();
			obj.value = '';
			return(false);
		}
	}
}


//-------------------------------------------------------------
//MedERP
function checaMedERP(obj)
{
	//Checa na 2 posição entrada	
	if (obj.value != "")
	{
		var valor = obj.value;
		var vr = valor.replace( ",", "." ); 
					
		if (isNaN(vr))
		{
			alert('Digite apenas número.');
			return false;
			obj.focus();
			obj.value = '';
			return(false);
		}
		else if (vr > 500.000)
		{
			alert('Valores permitido apenas entre 0,001 e 500,000.');
			obj.focus();
			obj.value = '';
			return(false);
		}	
		else if (vr < 0)
		{
			alert('Valores permitido apenas entre 0,001 e 500,000.');
			obj.focus();
			obj.value = '';
			return(false);
		}	
	}
}


//-------------------------------------------------------------
//Checa valores de Antena - Ganho Radcom
//Não esquecer de dar o replace no request.form(ASP) do objeto qdo for gravar.
function checaGanhoRadcom(obj){
	

	//Checa na 2 posição entrada	
	if (obj.length != ''){
	
		var valor = obj.value;
		var vr = valor.replace( ",", "." );
				
		if (isNaN(vr)){
			alert('Digite apenas número.');
			obj.value = '';
			obj.focus();
			return(false);
			}
			
		else if (vr > 0){
			alert('Valores permitido apenas entre -40 e 0.');
			obj.value = '';
			obj.focus();
			return(false);
			}
			
		else if (vr < -40){
			alert('Valores permitido apenas entre -40 e 0.');
			obj.value = '';
			obj.focus();
			return(false);
			}		
	}	
}



//-------------------------------------------------------------
//Checa valores de Antena - Ganho
//Não esquecer de dar o replace no request.form(ASP) do objeto qdo for gravar.
function checaGanho(obj){
	

	//Checa na 2 posição entrada	
	if (obj.length != ''){
	
		var valor = obj.value;
		var vr = valor.replace( ",", "." );
				
		if (isNaN(vr)){
			alert('Digite apenas número.');
			obj.value = '';
			obj.focus();
			return(false);
			}
			
		else if (vr > 40){
			alert('Valores permitido apenas entre -40 e 40.');
			obj.value = '';
			obj.focus();
			return(false);
			}
			
		else if (vr < -40){
			alert('Valores permitido apenas entre -40 e 40.');
			obj.value = '';
			obj.focus();
			return(false);
			}		
	}	
}


//-------------------------------------------------------------
//Checa PSI
function checaPSI(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 360.0)
	{
		alert('Valores permitidos entre 0 e 359');
		obj.value = '';
		obj.focus();
		return false;
	}
}

//-------------------------------------------------------------
//Checa K
function checaK(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 9.0)
	{
		alert('Valores permitidos entre 0 e 9');
		obj.value = '';
		obj.focus();
		return false;
	}
}

//-------------------------------------------------------------
//Checa Az
function checaAz(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 360.0)
	{
		alert('Valores permitidos entre 0 e 359');
		obj.value = '';
		obj.focus();
		return false;
	}
}

//-------------------------------------------------------------
//Checa S
function checaS(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 500.0)
	{
		alert('Valores permitidos entre 0 e 500');
		obj.value = '';
		obj.focus();
		return false;
	}
}

//-------------------------------------------------------------
//checa M
function checaM(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 999.9)
	{
		alert('Valores permitidos entre 0 e 999');
		obj.value = '';
		obj.focus();
		return false;
	}
}


//-------------------------------------------------------------
//Checagem parte de ANTENAS em OC - Módulo 2
function checaComprimento(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 999.99)
	{
		alert('Valores permitidos entre 0 e 999.99');
		obj.value = '';
		obj.focus();
		return false;
	}
}


//-------------------------------------------------------------
//Checagem Impedância e Atenuação
function checaImpedanciaAtenuacao(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 999.99)
	{
		alert('Valores permitidos entre 0 e 999.99');
		obj.value = '';
		obj.focus();
		return false;
	}
}



//-------------------------------------------------------------
function checaSeparacao(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 999.99)
	{
		alert('Valores permitidos entre 0 e 999.99');
		obj.value = '';
		obj.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checaAlturaMax(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 99.99)
	{
		alert('Valores permitidos entre 0 e 99.99');
		obj.value = '';
		obj.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checaAzimuteMax(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 360)
	{
		alert('Valores permitidos entre 0 e 360');
		obj.value = '';
		obj.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checaDefasagem(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 999.99)
	{
		alert('Valores permitidos entre 0 e 999.99');
		obj.value = '';
		obj.focus();
		return false;
	}
}

//-------------------------------------------------------------
function checaMedAzimAlinhDipolos(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 999.99)
	{
		alert('Valores permitidos entre 0 e 999.99');
		obj.value = '';
		obj.focus();
		return false;
	}

}

//-------------------------------------------------------------
function checaMedAzimMaxIrradiacao(obj)
{
	valor = obj.value;
	
	valor = valor.replace( ",", "." ); 
		
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}


	if (valor > 999.99)
	{
		alert('Valores permitidos entre 0 e 999.99');
		obj.value = '';
		obj.focus();
		return false;
	}

}


//Checa Latitude GG
function checaLatitudeGG(obj)
{
	valor = obj.value;
	if ((valor.length) > 0)
	{
		if ((valor.length) == 1)
		{
			obj.value = 0+ obj.value;
			valor = obj.value;
		}
		
	
		if (isNaN(valor))
		{
			alert('Digite apenas número.');
			obj.value = '';
			obj.focus();
			return false;
		}
	
		else if (valor > 33)
		{
			alert('Valores permitido apenas entre 0 e 33.');
			obj.value = '';
			obj.focus();
			return false;
		}
	}
}


//-------------------------------------------------------------
//Checa Latitude MM
function checaLatitudeMM(obj)
{
	valor = obj.value;
	
	if ((valor.length) > 0)
	{
		if ((valor.length) == 1)
		{
			obj.value = 0 + obj.value;
		}
	}	
	
	
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}
	
	else if (valor > 59)
	{
		alert('Valores permitido apenas entre 0 e 59.');
		obj.value = '';
		obj.focus();
		return false;
	}
	
}


//-------------------------------------------------------------
//Checa Latitude SS
function checaLatitudeSS(obj)
{
	valor = obj.value;
	
	if ((valor.length) > 0)
	{
		if ((valor.length) == 1)
		{
			obj.value = 0 + obj.value;
		}
	}	
	
	
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}
	
	else if (valor > 59)
	{
		alert('Valores permitido apenas entre 0 e 59.');
		obj.value = '';
		obj.focus();
		return false;
	}
}

//-------------------------------------------------------------
//Checa Longitude GG
function checaLongitudeGG(obj)
{
	valor = obj.value;
	
	if ((valor.length) > 0)
	{
		if ((valor.length) == 1)
		{
			obj.value = 0 + obj.value;
		}
		
	
		if (isNaN(valor))
		{
			alert('Digite apenas número.');
			obj.value = '';
			obj.focus();
			return false;
		}
	
		else if (valor > 73)
		{
			alert('Valores permitido apenas entre 34 e 73.');
			obj.value = '';
			obj.focus();
			return false;
		}
	
		else if (valor < 34)
		{
			alert('Valores permitido apenas entre 34 e 73.');
			obj.value = '';
			obj.focus();
			return false;
		}
	}		
}

//-------------------------------------------------------------
//Checa Longitude MM
function checaLongitudeMM(obj)
{
	valor = obj.value;
	
	if ((valor.length) > 0)
	{
		if ((valor.length) == 1)
		{
			obj.value = 0 + obj.value;
		}
	}	
	
	
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}
	
	else if (valor > 59)
	{
		alert('Valores permitido apenas entre 00 e 59.');
		obj.value = '';
		obj.focus();
		return false;
	}
	
}


//-------------------------------------------------------------
//Checa Longitude SS
function checaLongitudeSS(obj)
{
	valor = obj.value;
	
	if ((valor.length) > 0)
	{
		if ((valor.length) == 1)
		{
			obj.value = 0 + obj.value;
		}
	}	
	
	
	if (isNaN(valor))
	{
		alert('Digite apenas número.');
		obj.value = '';
		obj.focus();
		return false;
	}
	
	else if (valor > 59)
	{
		alert('Valores permitido apenas entre 0 e 59.');
		obj.value = '';
		obj.focus();
		return false;
	}
	
}



//-------------------------------------------------------------
//Verifica CodAID
function checaCodAID(obj)
{
	if (obj.value.length != '')
	{
		nomeCampo = obj.name;
		CodAIDAux  = obj.value.toUpperCase();
		var vStatusAID
		vStatusAID = true;
		
		//Checar Qtd. entrada.
		if (obj.value.length == 4)
		{
			for(i=0;i<4;i++){
				//Verifica casas
				CodAIDAux = obj.value.toUpperCase().substr( i,1 );
				if (CodAIDAux != 'A' && CodAIDAux != 'B' && CodAIDAux != 'C' && CodAIDAux != 'D' && CodAIDAux != 'E' && CodAIDAux != 'F' && CodAIDAux != '0' && CodAIDAux != 1 && CodAIDAux != 2 && CodAIDAux != 3 && CodAIDAux != 4 && CodAIDAux != 5 && CodAIDAux != 6 && CodAIDAux != 7 && CodAIDAux != 8 && CodAIDAux != 9 ){	
					vStatusAID = false;
				}
			}
					
			if (vStatusAID == false){
				alert('Valores inválidos!\n\nOs dígitos devem ser: A a F ou 0 a 9 !');
				document.all[nomeCampo].value = '';
				document.all[nomeCampo].focus();			
				return false;
			}
		}
		else
		{
			alert('Seqüência não finalizada de 4 dígitos!\n\nOs dígitos devem ser: A a F ou 0 a 9 !');
			document.all[nomeCampo].value = '';
			document.all[nomeCampo].focus();
			return false;
		}
		document.all[nomeCampo].value = obj.value.toUpperCase()
		
	}
}


//-------------------------------------------------------------

-->