function validaNumero(campo)
{
  i = 0;
  while (i <= campo.value.length-1)
  { 
    caracter = campo.value.charCodeAt(i);
     if ((caracter < 48) || (caracter > 57))
    {
      alert("Digite somente números");
      campo.value = "";
      campo.focus();
      return(false);
    }      
    i++;
  }  
}


function validaData(campo)
{
  if (campo.value != '')
  {
  data = campo.value;

  var dia = parseInt(data.substring(0,2),10);
  var mes = parseInt(data.substring(3,5),10);
  var ano = parseInt(data.substring(6,10),10);

  if (dia <= 31 && mes <=12 && ano >= 1000)
  {
    if (data.substring(0,1)=='0' && data.substring(1,2) != '0' || data.substring(0,1)!='0')
    {
      if (data.substring(2,3)=="/")
      {
        if (data.substring(3,4)=='0' && data.substring(4,5)!='0' || data.substring(3,4)!='0')
        {
          if (data.substring(5,6)=="/")
          {
            if (data.substring(6,7)== '0' || data.substring(6,7)=='' && data.substring(7,8)!='0')
            {
              window.alert('O ano que você digitou não existe!');
              return false;
              if (mes == 2)
              {  
                if ((dia > 0 ) && (dia <= 29))
                {
                  if (dia == 29)
                  {
                    if ((ano % 4) == 0)
                    {
                      return true;
                    }
                    else
                    {
                      window.alert('Este dia não existe, certifique - se de que digitou corretamente!');
                      campo.value = "";
                      campo.focus();
                      return false;
                    }
                  }
                }
                else
                {
                  window.alert('Este dia não existe, certifique - se de que digitou corretamente!');
                  campo.value = "";
                  campo.focus();
                  return false; 
                }
              } 
              if ((mes == 4)||(mes == 6)||(mes == 9)||(mes == 11))
              {
                if ((dia > 0 ) && (dia <= 30))
                {
                  return true;
                }
                else
                {
                  window.alert('Este dia não existe, certifique - se de que digitou corretamente!');
                  campo.value = "";
                  campo.focus();
                  return false;
                }
              }
                if ((mes == 1)||(mes == 3)||(mes == 5)||(mes ==7)||(mes == 8)||(mes == 10)||(mes == 12))
                {
                  if ((dia > 0) && (dia <= 31)) 
                  {
                    return true;
                  }
                  else
                  {
                    window.alert('Este dia não existe, certifique -se de que digitou corretamente!');
                    campo.value = "";
                    campo.focus();
                    return false;
                  }
                }
              }
            }
            else
            {
              window.alert('A data foi digitada fora do padrão (dd/mm/aaaa) !');
              campo.value = "";
              campo.focus();
              return false;
            }
          }
          else
          {
            window.alert('Você digitou um mês que não existe!');
            campo.value = "";
            campo.focus();
            return false;
          }
        }
        else
        {
          window.alert('A data foi digitada fora do padrão(dd/mm/aaaa) !');
          campo.value = "";
          campo.focus();
          return false;
        }
      }
      else
      {
        window.alert('Você digitou um dia que não existe!');
        campo.value = "";
        campo.focus();
        return false;
      }
    }
    else
    {
      window.alert('O dia e/ou o mês que você digitou não existe, ou Você digitou fora do padrão (dd/mm/aaaa) !');
      campo.value = "";
      campo.focus();
      return false;
    }
    return true;
  }
}

function abreJanela(param, h, w, t, l)
{
  novaJanela = window.open(param, 'eventos','height=' + h + ',width=' + w + ',scrollbars=yes,status=no,top=' + t + ',left=' + l);
}

function removeAspas(campo)
{
  texto = campo.value;
  texto1 = campo.value.replace(/\"/g,'');
  texto1 = texto1.replace(/\'/g,'');
  if (texto != texto1)
  {
    campo.value = texto1;
    alert("Este campo não aceita aspas");
    return(false);
  }      
}

//===== Rotina que escreve na barra de status o nome da empresa


var data="";

//set to 1 if not decrypting, set to 0 if decrypting
var done=1;


function statusIn(text){
	decrypt(text,2,1);
}

function statusOut(){
self.status='';
done=1;
}

function decrypt(text, max, delay){
	if (done){
		done = 0;
		decrypt_helper(text, max, delay,  0, max);
		}
	
}

function decrypt_helper(text, runs_left, delay, charvar, max){
	if (!done){
	runs_left = runs_left - 1;
	var status = text.substring(0,charvar);
	for(var current_char = charvar; current_char < text.length; current_char++){
		status += data.charAt(Math.round(Math.random()*data.length));
		}
	window.status = status;
	var rerun = "decrypt_helper('" + text + "'," + runs_left + "," + delay + "," + charvar + "," + max + ");"
	var new_char = charvar + 1;
	var next_char = "decrypt_helper('" + text + "'," + max + "," + delay + "," + new_char + "," + max + ");"
	if(runs_left > 0){
		setTimeout(rerun, delay);
		}
	else{
		if (charvar < text.length){
			setTimeout(next_char, Math.round(delay*(charvar+3)/(charvar+1)));
			}
		else
			{
			done = 1;
			}
		}
	}
}

//===== Fim da Rotina que escreve na barra de status
