function trim(str)
{
  return str.replace(/^\s*|\s*$/g,"");
}

function checa_email(email)
{
  aux = trim(email)
  aux_pos = aux.indexOf("@");
  aux_pos2 = aux.indexOf(" ");
  if ((aux_pos <= 1) || (aux == '') || (aux_pos2 > 0))
    return false
  else
    return true;
}


function mascara_cpf(campo, teclapres)
{

 tecla = teclapres.keyCode;

 vr = new String(campo.value);
 vr = vr.replace(".", "");
 vr = vr.replace(".", "");
 vr = vr.replace("/", "");
 vr = vr.replace("-", "");

 tam = vr.length + 1 ;

 if (tecla != 9 && tecla != 8)
 {
  if (tam > 3 && tam < 7)
   campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);
   if (tam >= 7 && tam < 10)
    campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
   if (tam >= 10 && tam < 14)
    campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
 }
}

function verifica_cpf(valor)
{
 erro = 0;
 aux1 = 0;
 aux2 = 0;
 aux3 = 1;
 for (i=0;i<valor.length-2;i++)
 {
  if ((valor.substr(i,1) != "/") && (valor.substr(i,1) != "-") && (valor.substr(i,1) != "."))
  {
   aux1 = aux1+(11-aux3)*valor.substr(i,1);
   aux2 = aux2+(12-aux3)*valor.substr(i,1);
   aux3++;
  }
 }
 resto = aux1-((Math.floor(aux1/11))*11);
 (resto < 2) ? dig1=0 : dig1=11-resto;
 aux2 = aux2+(2*dig1);
 resto = aux2-((Math.floor(aux2/11))*11);
 (resto < 2) ? dig2=0 : dig2=11-resto;
 aux = dig1+" "+dig2;
 aux = aux.substr(0,1)+aux.substr(2,1);
 if (aux != valor.substr(valor.length-2))
  return false;
 else
  if ((valor == "000.000.000-00") || (valor == "111.111.111-11") || (valor == "222.222.222-22") ||
  (valor == "333.333.333-33") || (valor == "444.444.444-44") || (valor == "555.555.555-55") ||
  (valor == "666.666.666-66") || (valor == "777.777.777-77") || (valor == "888.888.888-88") ||
  (valor == "999.999.999-99"))
   return false;
  else
   return true;
}

function verifica_email(email)
{
 if (email.indexOf("@") < 3)
  return false;
 else
  return true;
}

function so_numero(campo, evento)
{
 if (campo.length ==0)
  campo.value=0;
 var key;
 var keychar;
 if (window.event)
  key = window.event.keyCode;
 else
  if (evento)
   key = evento.which;
  else
   return true;
 keychar = String.fromCharCode(key);
 if ((key==null) || (key==0) || (key==8) || (key==9)|| (key==13)|| (key==27) )
  return true;
 else
  if ((("0123456789").indexOf(keychar) > -1))
   return true;
  else
   return false;
}

function MostrarData() {
  Hoje = new Date()
  Data = Hoje.getDate()
  Dia = Hoje.getDay()
  Mes = Hoje.getMonth()
  Ano = Hoje.getYear()
  //
  if (Data<10) {
    Data = "0" + Data
  }
  var sNavegador = navigator.appName;
  if (sNavegador == "Microsoft Internet Explorer")
  {
    if (Ano < 2000) {
      Ano = "19" + Ano
    }
  }
  else
  {
    Ano = Ano + 1900;
  }
  //
  NomeDia = new Array(7)
  NomeDia[0] = "Domingo"
  NomeDia[1] = "Segunda-feira"
  NomeDia[2] = "Terça-feira"
  NomeDia[3] = "Quarta-feira"
  NomeDia[4] = "Quinta-feira"
  NomeDia[5] = "Sexta-feira"
  NomeDia[6] = "Sábado"
  //
  NomeMes = new Array(12)
  NomeMes[0] = "Janeiro"
  NomeMes[1] = "Fevereiro"
  NomeMes[2] = "Março"
  NomeMes[3] = "Abril"
  NomeMes[4] = "Maio"
  NomeMes[5] = "Junho"
  NomeMes[6] = "Julho"
  NomeMes[7] = "Agosto"
  NomeMes[8] = "Setembro"
  NomeMes[9] = "Outubro"
  NomeMes[10] = "Novembro"
  NomeMes[11] = "Dezembro"
  //
  document.write (Data + " " + NomeMes[Mes] + " " + Ano)
}

