
function valida_email(email){
     if (email==''){
	  document.getElementById("email_err").innerHTML= "<div style='float:left; width:495px; margin:0 0 5px 0;'><span style='float:left;'><img src='img/icon_alert.gif' border='0' alt='Alerta!' /></span><span style='float:left; color:#a64249; padding:8px 0 0 5px;'>Atenção! O campo <span style='font-weight:bold; font-style:italic; color:#333;'>E-mail</span> não pode permanecer VAZIO.</span></div>"
	  
	  document.getElementById("EMail").style.backgroundColor="#dfc2c6"
	  document.getElementById("email_err_titulo").style.color="#c20714"
	  document.thisform.nome.focus();
	  return false;  
	}
	if ((email=='')||(email.indexOf("@")==-1)||(email.indexOf(".")==-1)){
		  document.getElementById("email_err").innerHTML= "<div style='float:left; width:495px; margin:0 0 5px 0;'><span style='float:left;'><img src='img/icon_alert.gif' border='0' alt='Alerta!' /></span><span style='float:left; color:#a64249; padding:8px 0 0 5px;'>Atenção! Preencha corretamente o campo <span style='font-weight:bold; font-style:italic; color:#333;'>E-mail</span> para enviar o formulário.</span></div>"		
	  
	  document.getElementById("EMail").style.backgroundColor="#dfc2c6"
	  document.getElementById("email_err_titulo").style.color="#c20714"
	  document.thisform.nome.focus();
	  return false;      
	}
	  document.getElementById("EMail").style.backgroundColor="#fff"
	  document.getElementById("email_err_titulo").style.color="#000"
	  document.getElementById("email_err").innerHTML="<span id='email_err'></span>"
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function txtBoxFormat(objeto, sMask, evtKeyPress) {
    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;


if(document.all) { // Internet Explorer
    nTecla = evtKeyPress.keyCode;
} else if(document.layers) { // Nestcape
    nTecla = evtKeyPress.which;
} else {
    nTecla = evtKeyPress.which;
    if (nTecla == 8) {
        return true;
    }
}

    sValue = objeto.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( ")", "" );
    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) == "/") || (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++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58)); } 
      else { // qualquer caracter...
        return true;
      } 
    }
    else {
      return true;
    }
  }


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function valida_nascimento(){
  d=document.thisform;
  erro=0;
  hoje = new Date();
  anoAtual = hoje.getFullYear();
  barras = d.nasce.value.split("/");

	 if (barras.length == 3){
			   dia = barras[0];
			   mes = barras[1];
			   ano = barras[2];
			   resultado = (!isNaN(dia) && (dia > 0) && (dia < 32)) && (!isNaN(mes) && (mes > 0) && (mes < 13)) && (!isNaN(ano) && (ano.length == 4) && (ano <= anoAtual-1 && ano >= 1900));
			   if (!resultado) {
						 document.getElementById("data_err").innerHTML="<label style='color:#993333'>*</label>"
						 d.nasce.focus();
						 return false;
			   }
	 } else {
			   document.getElementById("data_err").innerHTML="<label style='color:#993333'>*</label>"
			   d.nasce.focus();
			   return false;
	}
	document.getElementById("data_err").innerHTML="<span id='email_err'></span>"
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function valida_nome(nome){
     if (nome==''){
	  document.getElementById("nome_err").innerHTML= "<div style='float:left; width:495px; margin:0 0 5px 0;'><span style='float:left;'><img src='img/icon_alert.gif' border='0' alt='Alerta!' /></span><span style='float:left; color:#a64249; padding:8px 0 0 5px;'>Atenção! O campo <span style='font-weight:bold; font-style:italic; color:#333;'>Nome</span> não pode permanecer VAZIO.</span></div>"
	  
	  document.getElementById("Nome").style.backgroundColor="#dfc2c6"
	  document.getElementById("nome_err_titulo").style.color="#c20714"
	  document.thisform.nome.focus();
	  return false;  
	}
	if (!isNaN(nome)) {
		  document.getElementById("nome_err").innerHTML= "<div style='float:left; width:495px; margin:0 0 5px 0;'><span style='float:left;'><img src='img/icon_alert.gif' border='0' alt='Alerta!' /></span><span style='float:left; color:#a64249; padding:8px 0 0 5px;'>Atenção! Preencha corretamente o campo <span style='font-weight:bold; font-style:italic; color:#333;'>Nome</span> para enviar o formulário.</span></div>"		
	  
	  document.getElementById("Nome").style.backgroundColor="#dfc2c6"
	  document.getElementById("nome_err_titulo").style.color="#c20714"
	  document.thisform.nome.focus();
	  return false;      
	}
	
	 document.getElementById("nome_err").innerHTML="<label style='color:#993333'></label>"
	  document.getElementById("nome_err_titulo").style.color="#000"
     document.getElementById("Nome").style.backgroundColor="#fff"
}

function valida_select(selecao){
     if (selecao==''){
	  document.getElementById("select_err").innerHTML= "<div style='float:left; width:495px; margin:0 0 5px 0;'><span style='float:left;'><img src='img/icon_alert.gif' border='0' alt='Alerta!' /></span><span style='float:left; color:#a64249; padding:8px 0 0 5px;'>Atenção! É necessário especificar <span style='font-weight:bold; font-style:italic; color:#333;'>Como nos conheceu</span>...</span></div>"
	  
	  document.getElementById("Conheceu").style.backgroundColor="#dfc2c6"
	  document.getElementById("select_err_titulo").style.color="#c20714"
	  document.thisform.nome.focus();
	  return false;  
	}
	 document.getElementById("select_err").innerHTML="<label style='color:#993333'></label>"
	  document.getElementById("select_err_titulo").style.color="#000"
     document.getElementById("Conheceu").style.backgroundColor="#fff"
}

function valida_comentario(comentario){
     if (comentario==''){
	  document.getElementById("comentario_err").innerHTML= "<div style='float:left; width:495px; margin:0 0 5px 0;'><span style='float:left;'><img src='img/icon_alert.gif' border='0' alt='Alerta!' /></span><span style='float:left; color:#a64249; padding:8px 0 0 5px;'>Atenção! O campo <span style='font-weight:bold; font-style:italic; color:#333;'>Comentário</span> não pode permanecer VAZIO.</span></div>"
	  
	  document.getElementById("Texto").style.backgroundColor="#dfc2c6"
	  document.getElementById("comentario_err_titulo").style.color="#c20714"
	  document.thisform.nome.focus();
	  return false;  
	}
	 document.getElementById("comentario_err").innerHTML="<label style='color:#993333'></label>"
	  document.getElementById("comentario_err_titulo").style.color="#000"
     document.getElementById("Texto").style.backgroundColor="#fff"
}

function valida_login(login){
     if (login==''){
	  document.getElementById("login_err").innerHTML="<label style='color:#993333'>*Preencha</label>"
	  document.thisform.login.focus();
	  return false;
	}
	 document.getElementById("login_err").innerHTML="<label style='color:#993333'></label>"
}
function valida_senha(conf){
    var senha=document.getElementById("senha").value;
	if (senha==''){
	  document.getElementById("senha_err").innerHTML="<label style='color:#993333'>*Preencha</label>"
	  document.thisform.con_senha.focus();
	  return false;
	}
	if (senha!=conf){
	  document.getElementById("senha_err").innerHTML="<label style='color:#993333'>*Senha diferente</label>"
	  document.thisform.con_senha.focus();
	  return false;
	}	
	 document.getElementById("senha_err").innerHTML="<label style='color:#993333'></label>"
}


function valida_contato(contato){
     if ((contato=='')||(!isNaN(contato))){
	  document.getElementById("contato_err").innerHTML="<label style='color:#993333'>*Preencha corretamente </label>"
	  document.thisform.contato.focus();
	  return false;
	}
	 document.getElementById("contato_err").innerHTML="<label style='color:#993333'></label>"
}
function valida_empresa(empresa){
     if (empresa==''){
	  document.getElementById("empresa_err").innerHTML="<label style='color:#993333'>*Preencha corretamente </label>"
	  document.thisform.empresa.focus();
	  return false;
	}
	 document.getElementById("empresa_err").innerHTML="<label style='color:#993333'></label>"
}
