document.onmousedown=verfonte ;
tempo() ;

//-- Função da Internet
var sele;

function maskNumberS ()
{
    sele = true;
}

function maskNumber(obj, casas)
{
    var valor;
    var acao = 0;
    valor = obj.value;
    if (sele == true)
        valor = '';

    if ((((event.keyCode >= 96) && (event.keyCode <= 105)) || ((event.keyCode >= 48) && (event.keyCode <= 57))) && (valor.length<17))  {
        if (event.keyCode < 96)      
           valor = valor + String(event.keyCode - 48);  else
           valor = valor + String(event.keyCode - 96);

        obj.value = formata(valor, casas);
        acao = 1;
    }


    if (event.keyCode == 8)   {
        valor = valor.substr(0, valor.length - 1);
        obj.value = formata(valor, casas);
        acao = 2;
    }
    if ((event.keyCode == 9) || (event.keyCode == 46))   acao = 3;   

    if (((event.keyCode==109) || (event.keyCode==189)) && (acao==0))  {
       if (valor.indexOf('-') < 0)
         valor = '-'+valor;  else
         valor = valor.substring(1,valor.length)
       obj.value = formata(valor, casas);
       acao = 1;
    }

    if (acao < 3)     event.keyCode = 35;  
    sele = false;
}

function insere(original, novo, onde)
{
  return original.substring(0, onde) + novo + original.substring(onde, original.length);
}

function apaga(a, x)
{
  if (x==0)
    return a.substring(1); else
    return a.substr(0, x) + a.substring(x+1);
}

function formata(texto, casas)
{
  var menos=0;
  texto = String(texto);

  if (texto.indexOf('-') >= 0)  {
    texto = texto.substring(1,texto.length); 
    menos = 1;
  }

  while (texto.indexOf('.') >= 0)
   texto = apaga(texto, texto.indexOf('.'));
  while (texto.indexOf(',') >= 0)
   texto = apaga(texto, texto.indexOf(','));

  while (texto.charAt(0) == '0')  
    texto = texto.substring(1,texto.length); 

  while (texto.length <  3) texto = '0'+texto;

  texto = insere(texto, '.', texto.length-2);
  while (texto.indexOf('.') > 3)
    texto = insere(texto, '.', texto.indexOf('.')-3);
  texto = texto.substring(0, texto.length-3) + ',' + texto.substring(texto.length-2, texto.length);
  
  if (menos>0)
    texto = '-'+texto;

  return(texto);
}

function maskDate (obj)
{
    var retorno;
    retorno = 0;
    if (((event.keyCode >= 96) && (event.keyCode <= 105)) || ((event.keyCode >= 48) && (event.keyCode <= 57)))
    {
        retorno = 1;
    }
    if ((event.keyCode == 8) || (event.keyCode == 9) || (event.keyCode == 46))
    {
        retorno = 2;
    }
    if (retorno == 0)
    {
        event.returnValue = false;
    }
    if (retorno == 1)
    {
        if ((obj.value.length == 2) || (obj.value.length == 5))
        {
            obj.value = obj.value + '/';
        }
    }
}


//-- Funções Próprias
function tempo()
{
	status =  " ::::::: www.aguiarsoftware.com.br :::::::";
	timeFim = setTimeout("tempo()", 100);
}

function txtNumero(evtKeyPress)
{
     nTecla = evtKeyPress.keyCode;
    if (nTecla != 8 && nTecla != 44)
    { 
       return ((nTecla > 47) && (nTecla < 58));
    } 
}


function txtFormat(objForm, campo, sMask, evtKeyPress)
{
     var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

     objForm = document.all[objForm];     
     nTecla = evtKeyPress.keyCode;
     sValue = objForm[campo].value;

     // Limpa todos os caracteres de formatação que já estiverem no campo.
     sValue = sValue.toString().replace( "-", "" );
     sValue = sValue.toString().replace( "-", "" );
     sValue = sValue.toString().replace( ".", "" );
     sValue = sValue.toString().replace( ".", "" );
     sValue = sValue.toString().replace( "/", "" );
     sValue = sValue.toString().replace( "/", "" );
     sValue = sValue.toString().replace( "(", "" );
     sValue = sValue.toString().replace( "(", "" );
     sValue = sValue.toString().replace( ")", "" );
     sValue = sValue.toString().replace( ")", "" );
     sValue = sValue.toString().replace( " ", "" );
     sValue = sValue.toString().replace( " ", "" );
     fldLen = sValue.length;
     mskLen = sMask.length;

     i = 0;
     nCount = 0;
     sCod = "";
     mskLen = fldLen;
     while (i <= mskLen) {
       bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/"))
       bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
       if (bolMask) {
         sCod += sMask.charAt(i);
         mskLen++; }
       else {
         sCod += sValue.charAt(nCount);
         nCount++;
       }
       i++;
     }
     objForm[campo].value = sCod;
     if (nTecla != 8) { // backspace
       if (sMask.charAt(i-1) == "9") { // apenas números...
         return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9

       else { // qualquer caracter...
         return true;
       } }
     else {
       return true;
     }
}


function verfonte()
{
	if (event.button==2) { window.alert('Bem Vindo ao Clube Comary na Internet, desenvolvido pela Aguiar Software Condultoria em Informática Ltda.')}
}


function abrir(arquivo)
{
	janela=window.open(arquivo, 'Fotos', 'toolbar=0, location=0, scrollbars=yes, menubar=0, resizable=yes, top=10, left=10, width=500, height=510');
}


function RetiraAcentos(Campo)
{   
   var Acentos = "áàãââÁÀÃÂéêÉÊíÍóõôÓÔÕúüÚÜçÇabcdefghijklmnopqrstuvxwyz";
   var Traducao ="AAAAAAAAAEEEEIIOOOOOOUUUUCCABCDEFGHIJKLMNOPQRSTUVXWYZ";
   var Posic, Carac;
   var Temp = ""; 
   for (var i=0; i < Campo.length; i++)
   {
   	Carac = Campo.charAt (i);
   	Posic  = Acentos.indexOf (Carac);
   	if (Posic > -1)   
	   Temp += Traducao.charAt (Posic);
   	else  
      	   Temp += Campo.charAt (i);	  	   
   }
   return (Temp);
}

