function gE(elemento) {
	return document.getElementById(elemento);
}

function gN(elemento) {
	return document.getElementByName(elemento);
}

function mostraOutro(){
	var outro 	= gE("txt_outro");
	var texto 	= gE("textoQual");
	outro.style.display = "block";
	outro.focus();
	texto.innerHTML = "Qual?<span>*</span>&nbsp;";
}

function someOutro(){
	var outro = gE("txt_outro");
	var texto = gE("textoQual");
	outro.style.display = "none";
	texto.innerHTML = " ";
}

function Valida(form) {
preencheu = false;
botoes = form.campo.length;
for (i=0;i<botoes;i++) {
if (form.campo[i].checked) {
preencheu = true;
break; }
}
if (preencheu) {
form.submit(); }
else {
alert("É necessário escolher uma das opções.");
}
}

function validaNewsletter(){
	var inputs = document.getElementsByTagName("input");
	var checks = new Array();
	var radio = new Array();
	var checados = 0;
	var marcados = -1;
	
	for (i=0; i<document.form_newsletter.txt_filiado.length; i++) {
		if (document.form_newsletter.txt_filiado[i].checked) {
			marcados = i
			filiacao = document.form_newsletter.txt_filiado[i].value
		}
	}

	for(i = 0; i <= inputs.length - 1; i++){
		if(inputs[i].type == "checkbox"){
			checks.push(inputs[i]);
		}
	}
	for(i = 0; i <= checks.length - 1; i++){
		if(checks[i].checked){
			checados++;
		}
	}
	
	
	var nome			= gE("txt_nome");
	var email			= gE("txt_email");
	var vemail1			= email.value.indexOf('@');
	var vemail2			= email.value.indexOf('.');
	var telefone		= gE("txt_tel");
	var celular			= gE("txt_cel");
	var cidade			= gE("txt_cidade");
	var estado			= gE("txt_estado");
	var dtnas			= gE("txt_datanas");
	var descobriu		= gE("txt_descobriu");
	var outro 			= gE("txt_outro");
	var observacao		= gE("txt_obs");
	var alerta			= gE("alerta");
	var filiado			= gE("txt_filiado");
	var opfiliado		= filiado.checked;
	
	if(nome.value == "" || nome.value == null){
		alerta.innerHTML = "Preencha o campo Nome.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#f7f7f7';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		nome.focus();
		return false;
	} else if (!isNaN(nome.value)){
		alerta.innerHTML = "Por favor, preencha o campo nome corretamente.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#f7f7f7';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		nome.focus();
		return false;
	} else if(email.value == "" || email.value == null){
		alerta.innerHTML = "Preencha o campo Email.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#f7f7f7';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		email.focus();
		return false;
	} else if(vemail1 == -1 || vemail2 == -1){
		alerta.innerHTML = "Preencha o campo Email corretamente.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#f7f7f7';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		email.focus();
		return false;
	} else if(telefone.value.length < 14 && telefone.value.length > 0){
		alerta.innerHTML = "Por favor, preencha o campo telefone corretamente.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#f7f7f7';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		telefone.focus();
		return false;
	} else if(celular.value.length < 14 && celular.value.length > 0){
		alerta.innerHTML = "Por favor, preencha o campo celular corretamente.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#f7f7f7';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		celular.focus();
		return false;
	} else if(cidade.value == "" || cidade.value == null){
		alerta.innerHTML = "Preencha o campo Cidade.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#f7f7f7';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		cidade.focus();
		return false;
	} else if(estado.value == "" || estado.value == null){
		alerta.innerHTML = "Selecione um Estado.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#f7f7f7';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		estado.focus();
		return false;
	} else if (!isNaN(cidade.value)){
		alerta.innerHTML = "Por favor, preencha o campo cidade corretamente.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#f7f7f7';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		cidade.focus();
		return false;
	} else if(dtnas.value.length < 8 && dtnas.value.length > 0){
		alerta.innerHTML = "Preencha o campo Data de Nascimento corretamente.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#f7f7f7';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		dtnas.focus();
		return false;
	} else if(marcados == -1){
		alerta.innerHTML = "Marque uma op&ccedil;&atilde;o.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		document.form_newsletter.txt_filiado[0].focus();
		return false;
	} else if(descobriu.value == "" || descobriu.value == null){
		alerta.innerHTML = "Preencha o campo Onde nos Descobriu.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#f7f7f7';
		outro.style.backgroundColor = '#FFFFFF';
		observacao.style.backgroundColor = '#FFFFFF';
		descobriu.focus();
		return false;
	} else if(outro.style.display == "block" && (outro.value == "" || outro.value == null)){
		alerta.innerHTML = "Preencha o campo Outra.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#f7f7f7';
		observacao.style.backgroundColor = '#FFFFFF';
		outro.focus();
		return false;
	} else if (!isNaN(outro.value) && outro.style.display == "block"){
		alerta.innerHTML = "Por favor, preencha o campo Outra corretamente.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		telefone.style.backgroundColor = '#FFFFFF';
		celular.style.backgroundColor = '#FFFFFF';
		cidade.style.backgroundColor = '#FFFFFF';
		estado.style.backgroundColor = '#FFFFFF';
		dtnas.style.backgroundColor = '#FFFFFF';
		descobriu.style.backgroundColor = '#FFFFFF';
		outro.style.backgroundColor = '#f7f7f7';
		observacao.style.backgroundColor = '#FFFFFF';
		outro.focus();
		return false;
	}	else {
		return true;
	}
}

function validaForum(){
	var marcados = -1;
	
	for (i=0; i<document.form_forum.txt_privacidade.length; i++) {
		if (document.form_forum.txt_privacidade[i].checked) {
			marcados = i;
		}
	}
	
	var nome			= gE("txt_nome");
	var email			= gE("txt_email");
	var vemail1			= email.value.indexOf('@');
	var vemail2			= email.value.indexOf('.');
	var assunto			= gE("txt_assunto");
	var descricao		= gE("txt_descricao");
	var alerta			= gE("alerta");
	
	if(nome.value == "" || nome.value == null){
		alerta.innerHTML = "Preencha o campo Nome.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#f7f7f7';
		email.style.backgroundColor = '#FFFFFF';
		descricao.style.backgroundColor = '#FFFFFF';
		nome.focus();
		return false;
	} else if (!isNaN(nome.value)){
		alerta.innerHTML = "Por favor, preencha o campo nome corretamente.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#f7f7f7';
		email.style.backgroundColor = '#FFFFFF';
		descricao.style.backgroundColor = '#FFFFFF';
		nome.focus();
		return false;
	} else if(email.value == "" || email.value == null){
		alerta.innerHTML = "Preencha o campo Email.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#f7f7f7';
		descricao.style.backgroundColor = '#FFFFFF';
		email.focus();
		return false;
	} else if(vemail1 == -1 || vemail2 == -1){
		alerta.innerHTML = "Preencha o campo Email corretamente.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#f7f7f7';
		descricao.style.backgroundColor = '#FFFFFF';
		email.focus();
		return false;
	}
	else if(assunto.value == "" || assunto.value == null){
		alerta.innerHTML = "Preencha o campo Assunto.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#f7f7f7';
		email.style.backgroundColor = '#FFFFFF';
		descricao.style.backgroundColor = '#FFFFFF';
		assunto.focus();
		return false;
	}
	else if(descricao.value == "" || descricao.value == null){
		alerta.innerHTML = "Preencha o campo Descri&ccedil;&atilde;o.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		descricao.style.backgroundColor = '#f7f7f7';
		descricao.focus();
		return false;
	} else if(marcados == -1){
		alerta.innerHTML = "Marque uma op&ccedil;&atilde;o.";
		alerta.className = "news_alerta";
		nome.style.backgroundColor = '#FFFFFF';
		email.style.backgroundColor = '#FFFFFF';
		descricao.style.backgroundColor = '#FFFFFF';
		document.form_forum.txt_privacidade[0].focus();
		return false;
	}	else {
		return true;
	}
}

function MascaraTel(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 MascaraDtnas(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 Somente_Num(campo)
{
	var digits="0123456789,.-/"
	var campo_temp 
	for (var i=0;i<campo.value.length;i++)
	{
	  campo_temp=campo.value.substring(i,i+1)	
	  if (digits.indexOf(campo_temp)==-1)
	  {
		    campo.value = campo.value.substring(0,i);
		    break;
	  }
	}
}
