Meses = new Array('Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro');
Dias =  new Array('Domingo','2ª Feira','3ª Feira','4ª Feira','5ª Feira','6ª Feira','Sábado');

function Saudacao() {
    var hoje = new Date();
    var horas = hoje.getHours();
    var sauda = new String;

    if (horas < 12) 
        sauda = 'Bom dia';
    else if (horas < 18) 
        sauda = 'Boa Tarde';
    else 
        sauda = 'Boa Noite';

    document.write(sauda + ', ');
}       

function DataHoje() {
  var hoje = new Date();
  var horas = hoje.getHours();
  if (horas < 12) sauda = '';
  else if (horas < 18) sauda = '';
  else sauda = '';
  var semana = Dias[hoje.getDay()];
  var mes = Meses[hoje.getMonth()];
  var dia = hoje.getDate();
  var ano = hoje.getFullYear();
  document.write(semana + ', ' + dia + ' de ' + mes + ' de ' + ano);
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}

function checkdata(formulario) {
  if (formulario == "frmCadastroUsuario" ) {
    with(document.frmCadastroUsuario) { 
      if (txtNome.value == "") {
        alert("Favor digite seu nome!");
        txtNome.focus();
        return false; 
      }
      if (txtFirstName.value == "") {
        alert("Favor digite seu First Name!");
        txtFirstName.focus();
        return false; 
      }
      if (txtLastName.value == "") {
        alert("Favor digite seu Last Name!");
        txtLastName.focus();
        return false; 
      }   
      if (txtEndereco.value == "") {
        alert("Favor digite seu Endereço Completo!");
        txtEndereco.focus();
        return false; 
      }   
      if (txtTelefone.value == "") {
        alert("Favor digite seu Telemovel! (ex.: 000000000)");
        txtTelefone.focus();
        return false; 
      }   
      if (txtLocalidade.value == "") {
        alert("Favor digite sua Localidade!");
        txtLocalidade.focus();
        return false; 
      }         
      if (txtCodigoPostal.value == "") {
        alert("Favor digite seu Código Postal!");
        txtCodigoPostal.focus();
        return false; 
      }         
      if (txtEmail.value == "") {
        alert("Digite seu email!");
        txtEmail.focus();
        return false; 
      }
      if (txtSenha.value == "") {
        alert("Preencha sua Senha corretamente!");
        txtSenha.focus();
        return false; 
      }                                            
      if (txtConfSenha.value != txtSenha.value) {
        alert("A senha que você digitou não esta correta. Digite a senha em ambas caixas de texto!");
        txtSenha.focus();
        return false; 
      }                                                 
      submit();
    }
  }  
  if (formulario == "frmFecharPedido" ) {
    with(document.frmFecharPedido) { 
      if (cmbPagamento.value == "") {
        alert("Favor selecione uma forma de pagamento!");
        cmbPagamento.focus();
        return false; 
      }
      submit();
    }
  }  
  if (formulario == "frmConfirmarPagamento" ) {
    with(document.frmConfirmarPagamento) { 
      if (cmbPagamento.value == "") {
        alert("Favor selecione uma forma de pagamento!");
        cmbPagamento.focus();
        return false; 
      }
      if (txtValorPagamento.value == "") {
        alert("Favor informe o valor do pagamento realizado!");
        txtValorPagamento.focus();
        return false; 
      }
      if (txtDataPagamento.value == "") {
        alert("Favor informe a data e hora que o pagamento foi realizado! Ex.: DD/MM/YYYY HH:MM");
        txtDataPagamento.focus();
        return false; 
      }   
      submit();
    }
  }  
} 
 
function valida_cpf(){
    with(document.frmCadastroUsuario) {
        var i;
        s = document.frmConUsuarios.txtCPF.value;
        if (s.length != 11) {
        alert ("Tamanho do CPF deve ser de 11 caracteres!");
        document.frmConUsuarios.txtCPF.focus();
        return false;
        }
        var c = s.substr(0,9);
        var dv = s.substr(9,2);
        var d1 = 0;
        for (i = 0; i < 9; i++) {
        d1 += c.charAt(i)*(10-i);
        }
        if (d1 == 0){
        alert("CPF Invalido!");
        document.frmConUsuarios.txtCPF.focus();
        return false;
        }

        d1 = 11 - (d1 % 11);
        if (d1 > 9){
        d1 = 0;
        }

        if (dv.charAt(0) != d1) {
        alert("CPF Invalido!");
        document.frmConUsuarios.txtCPF.focus();
        return false;
        }

        d1 *= 2;
        for (i = 0; i < 9; i++) {
        d1 += c.charAt(i)*(11-i);
        }

        d1 = 11 - (d1 % 11);
        if (d1 > 9){
        d1 = 0
        }

        if (dv.charAt(1) != d1) {
            alert("CPF Invalido!");
            document.frmConUsuarios.txtCPF.focus();
            return false;
        }
        return true;
    }
}