//<!-- -->
// Dá TAB automaticamente quando a digitação atinge o tamanho máximo do campo  
VerifiqueTAB=true;
function Mostra(quem, tammax) {
	if ( (quem.value.length == tammax) && (VerifiqueTAB) ) {
		var i=0,j=0, indice=-1;
		for (i=0; i<document.forms.length; i++) {
			for (j=0; j<document.forms[i].elements.length; j++) {
				if (document.forms[i].elements[j].name == quem.name) {
					indice=i;
					break;
				}
			}
			if (indice != -1)
		         break;
		}
		for (i=0; i<=document.forms[indice].elements.length; i++) {
			if (document.forms[indice].elements[i].name == quem.name) {
				while ( (document.forms[indice].elements[(i+1)].type == "hidden") &&
						(i < document.forms[indice].elements.length) ) {
							i++;
				}
				document.forms[indice].elements[(i+1)].focus();
				VerifiqueTAB=false;
				break;
			}
		}
	}
}

//<!-- -->

function PararTAB(quem) 
{
   VerifiqueTAB=false; 
} 

//<!-- -->

function ChecarTAB() 
{
   VerifiqueTAB=true; 
} 

//<!-- -->

var posicSelec = 99;
function RadioSelecionado(radio)
{
 	var selecionado = "";
	for(i=0;i<radio.length;i++)
	{
		if(radio[i].checked)
		{
			selecionado = radio[i];
			posicSelec  = i;
		}
	}
	return selecionado;
}


function isNumber(n) {
     for(i=0; i < n.length; i++) {
        c = n.charAt(i);
        if (( c < "0") || (c > "9")) {
           return false;
        }
     }
     return true;
  }


function SoEspaco(texto) {
	var i
	for (i = 0; i < texto.length; i++) {
		if (texto.substring(i, i+1) != ' ')
			return false
	}
	return true
}

function ZeroEsq(num, tam) {
	var i;
	var numTrab = num;
	for (i = 0; i < (tam - num.length); i++) {
		numTrab = '0' + numTrab;
	}
	return numTrab;
}

function substitui(texto, caract1, caract2) {

	var aux = "";
	for (i = 0; i < texto.length; i++) {
		if (texto.substring(i, i + caract1.length) == caract1) {
			aux += caract2;
			i+= caract1.length - 1;
		}
		else
			aux += texto.substring(i, i + 1);
	}
	return aux;
}

function arredonda(numero, casas) {

	var i, fator, valor, texto, casasAtual;
	fator = 1;
	for (i = 1; i <= casas; i++)
		fator *= 10;

	valor = Math.round(numero * fator) / fator;
	
	texto = "" + valor + "";
	texto = substitui(texto, ".", ",");

	if (casas == 0)
		return texto;
	else {
		if (texto.indexOf(",") == -1)
			texto += ",";
		casasAtual = texto.length - texto.indexOf(",") - 1;
		for (i = casasAtual; i < casas; i++)
			texto += "0";
	}
	return texto;
}

//Função para Calcular Modulo 11

function CalculaDigitoMod11(Dado, NumDig, LimMult)
 {
  var Mult, Soma, i, n, digito;

//digito para conferencia  
  digito = Dado.substr(Dado.length - 1);

//sem o digito    
  Dado= Dado.substring(0,Dado.length-1);
    
  for(n=1; n<=NumDig; n++)
    {
    Soma = 0;
    Mult = 2;
    for(i=Dado.length-1; i>=0; i--)
      {
      Soma += (Mult * parseInt(Dado.charAt(i)));
      if(++Mult > LimMult) 
	  		Mult = 2;
      }
    Dado += ((Soma * 10) % 11) % 10;
    }

	DigCalculado = Dado.substr(Dado.length - NumDig, NumDig);
		
	if (digito != DigCalculado)
	{
		return true
	}
	
	return false
 	      
  } 


