function FormataRG() {
    RG = document.frmAssociado.RG.value;
    if (RG.length > 0) {
        while (RG.indexOf(".") > 0) {
            RG = RG.replace(".", "");
        }
        while (RG.indexOf("-") > 0) {
            RG = RG.replace("-", "");
        }
        RG = RG + "000000000";
        RG = RG.substring(0, 2) + "." + RG.substring(2, 5) + "." + RG.substring(5, 8) + "-" + RG.substring(8, 9);
        document.frmAssociado.RG.value = RG;
    }
}
function FormataRG3() {
    RG = document.frmVoluntario.RG.value;
    if (RG.length > 0) {
        while (RG.indexOf(".") > 0) {
            RG = RG.replace(".", "");
        }
        while (RG.indexOf("-") > 0) {
            RG = RG.replace("-", "");
        }
        RG = RG + "000000000";
        RG = RG.substring(0, 2) + "." + RG.substring(2, 5) + "." + RG.substring(5, 8) + "-" + RG.substring(8, 9);
        document.frmVoluntario.RG.value = RG;
    }
}
function FormataCPF() {
    CPF = document.frmDoacoes.CPF.value;
    if (CPF.length > 0) {
        while (CPF.indexOf(".") > 0) {
            CPF = CPF.replace(".", "");
        }
        while (CPF.indexOf("-") > 0) {
            CPF = CPF.replace("-", "");
        }
        CPF = CPF + "00000000000";
        CPF = CPF.substring(0, 3) + "." + CPF.substring(3, 6) + "." + CPF.substring(6, 9) + "-" + CPF.substring(9, 11);
        document.frmDoacoes.CPF.value = CPF;
    }
}
function FormataCPF2() {
    CPF = document.frmAssociado.CPF.value;
    if (CPF.length > 0) {
        while (CPF.indexOf(".") > 0) {
            CPF = CPF.replace(".", "");
        }
        while (CPF.indexOf("-") > 0) {
            CPF = CPF.replace("-", "");
        }
        CPF = CPF + "00000000000";
        CPF = CPF.substring(0, 3) + "." + CPF.substring(3, 6) + "." + CPF.substring(6, 9) + "-" + CPF.substring(9, 11);
        document.frmAssociado.CPF.value = CPF;
    }
}
function FormataCPF3() {
    CPF = document.frmVoluntario.CPF.value;
    if (CPF.length > 0) {
        while (CPF.indexOf(".") > 0) {
            CPF = CPF.replace(".", "");
        }
        while (CPF.indexOf("-") > 0) {
            CPF = CPF.replace("-", "");
        }
        CPF = CPF + "00000000000";
        CPF = CPF.substring(0, 3) + "." + CPF.substring(3, 6) + "." + CPF.substring(6, 9) + "-" + CPF.substring(9, 11);
        document.frmVoluntario.CPF.value = CPF;
    }
}

function FormataTelefone(TipoTelefone) {
    if (TipoTelefone == "Residencial") {
        Telefone = document.frmDoacoes.TelefoneResidencial.value;
        CampoTelefone = document.frmDoacoes.TelefoneResidencial;
    }
    if (TipoTelefone == "Comercial") {
        Telefone = document.frmDoacoes.TelefoneComercial.value;
        CampoTelefone = document.frmDoacoes.TelefoneComercial;
    }
    if (TipoTelefone == "Celular") {
        Telefone = document.frmDoacoes.TelefoneCelular.value;
        CampoTelefone = document.frmDoacoes.TelefoneCelular;
    }
    if (Telefone.length > 0) {
        while (Telefone.indexOf("-") > 0) {
            Telefone = Telefone.replace("-", "");
        }
        Telefone = Telefone + "0000000000";
        Telefone = Telefone.substring(0, 4) + "-" + Telefone.substring(4, 8);
        CampoTelefone.value = Telefone;
    }
}

function FormataTelefone2(TipoTelefone) {
    if (TipoTelefone == "Telefone") {
        Telefone = document.frmAssociado.Telefone.value;
        CampoTelefone = document.frmAssociado.Telefone;
    }
    if (TipoTelefone == "Celular") {
        Telefone = document.frmAssociado.Celular.value;
        CampoTelefone = document.frmAssociado.Celular;
    }
    if (Telefone.length > 0) {
        while (Telefone.indexOf("-") > 0) {
            Telefone = Telefone.replace("-", "");
        }
        Telefone = Telefone + "0000000000";
        Telefone = Telefone.substring(0, 4) + "-" + Telefone.substring(4, 8);
        CampoTelefone.value = Telefone;
    }
}

function FormataTelefone3(TipoTelefone) {
    if (TipoTelefone == "Telefone") {
        Telefone = document.frmVoluntario.Telefone.value;
        CampoTelefone = document.frmVoluntario.Telefone;
    }
    if (TipoTelefone == "Celular") {
        Telefone = document.frmVoluntario.Celular.value;
        CampoTelefone = document.frmVoluntario.Celular;
    }
    if (Telefone.length > 0) {
        while (Telefone.indexOf("-") > 0) {
            Telefone = Telefone.replace("-", "");
        }
        Telefone = Telefone + "0000000000";
        Telefone = Telefone.substring(0, 4) + "-" + Telefone.substring(4, 8);
        CampoTelefone.value = Telefone;
    }
}	 

function isCPF(st) {
    if (st == "")
        return (false);
    l = st.length;

    //aleterado para se usuário não digitar os zeros na frente do CPF, completar sozinho
    if ((l == 9) || (l == 8)) {
        for (i = l; i < 10; i++) {
            st = '0' + st
        }
    }
    l = st.length;
    st2 = "";
    for (i = 0; i < l; i++) {
        caracter = st.substring(i, i + 1);
        if ((caracter >= '0') && (caracter <= '9'));
        st2 = st2 + caracter;
    }
    if ((st2.length > 11) || (st2.length < 10))
        return (false);
    if (st2.length == 10)
        st2 = '0' + st2;
    digito1 = st2.substring(9, 10);
    digito2 = st2.substring(10, 11);
    digito1 = parseInt(digito1, 10);
    digito2 = parseInt(digito2, 10);
    sum = 0; mul = 10;
    for (i = 0; i < 9; i++) {
        digit = st2.substring(i, i + 1);
        tproduct = parseInt(digit, 10) * mul;
        sum += tproduct;
        mul--;
    }
    dig1 = (sum % 11);
    if (dig1 == 0 || dig1 == 1)
        dig1 = 0;
    else
        dig1 = 11 - dig1;
    if (dig1 != digito1)
        return (false);
    sum = 0;
    mul = 11;
    for (i = 0; i < 10; i++) {
        digit = st2.substring(i, i + 1);
        tproduct = parseInt(digit, 10) * mul;
        sum += tproduct;
        mul--;
    }
    dig2 = (sum % 11);
    if (dig2 == 0 || dig2 == 1)
        dig2 = 0;
    else
        dig2 = 11 - dig2;
    if (dig2 != digito2)
        return (false);
    return (true);
}

function ajaxInit() {
   var req;
   try {
      req = new ActiveXObject("Microsoft.XMLHTTP");
   } catch(e) {
      try {
         req = new ActiveXObject("Msxml2.XMLHTTP");
      } catch(ex) {
         try {
            req = new XMLHttpRequest();
         } catch(exc) {
            alert("Esse browser não tem recursos para uso do Ajax");
            req = null;
         }
      }
   }
   return req;
}

function EnviarMSGAgenda() {
    Nome = document.frmAgenda2.Nome;
    Email = document.frmAgenda2.Email;
    Mensagem = document.frmAgenda2.Mensagem;
    if (Nome.value.length == 0) {
        alert("Digite o seu nome!");
        Nome.focus();
        return;
    }
    if (Email.value.length == 0) {
        alert("Digite o seu E-Mail!");
        Email.focus();
        return;
    }
    AchouArroba = Email.value.indexOf("@");
    AchouPonto = Email.value.lastIndexOf(".");
    if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do seu e-Mail está inválido! Verifique!");
        Email.focus();
        return;
    }
    if (Mensagem.value.length == 0) {
        alert("Digite a Mensagem!");
        Mensagem.focus();
        return;
    }
    document.getElementById("form_agenda_loading").style.display = "block";
    document.getElementById("form_agenda").style.display = "none";
    document.frmAgenda2.submit();
}


function CadastrarNewsletter() {
   Nome = document.frmNewsletter.Nome;
   Email = document.frmNewsletter.Email;
   if (Nome.value.length == 0) {
      alert("Digite o seu nome!");
	  Nome.focus();
	  return;
   }
   if (Email.value.length == 0) {
      alert("Digite o seu E-Mail!");
	  Email.focus();
	  return;
   }
   AchouArroba = Email.value.indexOf("@");
   AchouPonto = Email.value.lastIndexOf(".");
   if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
      alert("O Formato do seu e-Mail está inválido! Verifique!");
	  Email.focus();
	  return;
   }   		    
   ajax = ajaxInit();
   resultado = "";
   document.getElementById("loading_newsletter").style.display = "block";
   document.getElementById("campos_newsletter").style.display = "none";   
   if (ajax) {
      ajax.open("GET", "cadastra_newsletter.asp?NomeNewsletter=" + Nome.value + "&EmailNewsletter=" + Email.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange = function() {
          if (ajax.readyState == 4) {
              if (ajax.status == 200) {
                  resultado = ajax.responseText;
                  if (resultado.length == 0) {
                      alert("Erro ao tentar efetuar o seu cadastro na nossa Newsletter. Tente novamente!");
                      document.getElementById("loading_newsletter").style.display = "none";
                      document.getElementById("campos_newsletter").style.display = "block";
                  } else {
                      if (resultado == "1") {
                          alert("ATENÇÃO:\n\nEste E-Mail já está cadastrado na nossa Newsletter!");
                          document.getElementById("loading_newsletter").style.display = "none";
                          document.getElementById("campos_newsletter").style.display = "block";
                      } else if (resultado == "2") {
                          alert("Erro ao tentar efetuar o seu cadastro na nossa Newsletter. Tente novamente!");
                          document.getElementById("loading_newsletter").style.display = "none";
                          document.getElementById("campos_newsletter").style.display = "block";
                      } else {
                          document.frmNewsletter.submit();
                          alert("CADASTRO REALIZADO COM SUCESSO!\n\nO usuário " + Nome.value + " (" + Email.value + ") foi cadastrado com sucesso na nossa Newsletter!");
                          document.getElementById("loading_newsletter").style.display = "none";
                          document.getElementById("campos_newsletter").style.display = "block";
                      }
                  }
              } else {
                  alert("Erro ao tentar efetuar o seu cadastro na Newsletter. Tente novamente!");
                  document.getElementById("loading_newsletter").style.display = "none";
                  document.getElementById("campos_newsletter").style.display = "block";
              }
          }
      }
      ajax.send(null);
   }   
}

function CadastrarNewsletter2() {
   Nome = document.frmNewsletter2.Nome;
   Email = document.frmNewsletter2.Email;
   if (Nome.value.length == 0) {
      alert("Digite o seu nome!");
	  Nome.focus();
	  return;
   }
   if (Email.value.length == 0) {
      alert("Digite o seu E-Mail!");
	  Email.focus();
	  return;
   }
   AchouArroba = Email.value.indexOf("@");
   AchouPonto = Email.value.lastIndexOf(".");
   if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
      alert("O Formato do seu e-Mail está inválido! Verifique!");
	  Email.focus();
	  return;
   }   		    
   ajax = ajaxInit();
   resultado = "";
   document.getElementById("form_newsletter_cadastra_loading").style.display = "block";
   document.getElementById("form_newsletter_cadastra").style.display = "none";   
   if (ajax) {
      ajax.open("GET", "cadastra_newsletter.asp?NomeNewsletter=" + Nome.value + "&EmailNewsletter=" + Email.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange = function() {
         if (ajax.readyState == 4) {
            if (ajax.status == 200) {
               resultado = ajax.responseText; 
			   if (resultado.length == 0) {
			      alert("Erro ao tentar efetuar o seu cadastro na nossa Newsletter. Tente novamente!");
				  document.getElementById("form_newsletter_cadastra_loading").style.display = "none";
                  document.getElementById("form_newsletter_cadastra").style.display = "block";   			   	
			   } else {
				   if (resultado == "1") {
			          alert("ATENÇÃO:\n\nEste E-Mail já está cadastrado na nossa Newsletter!");
					  document.getElementById("form_newsletter_cadastra_loading").style.display = "none";
                      document.getElementById("form_newsletter_cadastra").style.display = "block";   			   						   
				   } else if (resultado == "2") {
			          alert("Erro ao tentar efetuar o seu cadastro na nossa Newsletter. Tente novamente!");
				      document.getElementById("form_newsletter_cadastra_loading").style.display = "none";
                      document.getElementById("form_newsletter_cadastra").style.display = "block";
                   } else {
                      document.frmNewsletter2.submit();
			          alert("CADASTRO REALIZADO COM SUCESSO!\n\nO usuário " + Nome.value + " (" + Email.value + ") foi cadastrado com sucesso na nossa Newsletter!");
					  document.getElementById("form_newsletter_cadastra_loading").style.display = "none";
                      document.getElementById("form_newsletter_cadastra").style.display = "block";   			   						   					   
				   }
			   }
            } else {
		       alert("Erro ao tentar efetuar o seu cadastro na Newsletter. Tente novamente!");				   				
               document.getElementById("form_newsletter_cadastra_loading").style.display = "none";
               document.getElementById("form_newsletter_cadastra").style.display = "block";   			   	
			}
         }
      }
      ajax.send(null);
   }   
}

function RetirarNewsletter() {
   Email = document.frmNewsletter3.Email;
   if (Email.value.length == 0) {
      alert("Digite o seu E-Mail!");
	  Email.focus();
	  return;
   }
   AchouArroba = Email.value.indexOf("@");
   AchouPonto = Email.value.lastIndexOf(".");
   if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
      alert("O Formato do seu e-Mail está inválido! Verifique!");
	  Email.focus();
	  return;
   }   		    
   ajax = ajaxInit();
   resultado = "";
   document.getElementById("form_newsletter_retirar_loading").style.display = "block";
   document.getElementById("form_newsletter_retirar").style.display = "none";   
   if (ajax) {
      ajax.open("GET", "retira_newsletter.asp?EmailNewsletter=" + Email.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
      ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax.onreadystatechange = function() {
         if (ajax.readyState == 4) {
            if (ajax.status == 200) {
               resultado = ajax.responseText; 
			   if (resultado.length == 0) {
			      alert("Erro ao tentar efetuar retirar o seu E-Mail na nossa Newsletter. Tente novamente!");
				  document.getElementById("form_newsletter_retirar_loading").style.display = "none";
                  document.getElementById("form_newsletter_retirar").style.display = "block";   			   	
			   } else {
				   if (resultado == "1") {
			          alert("ATENÇÃO:\n\nEste E-Mail não está cadastrado na nossa Newsletter!");
					  document.getElementById("form_newsletter_retirar_loading").style.display = "none";
                      document.getElementById("form_newsletter_retirar").style.display = "block";   			   						
				   } else if (resultado == "2") {
		              alert("Erro ao tentar efetuar retirar o seu E-Mail na nossa Newsletter. Tente novamente!");
				      document.getElementById("form_newsletter_retirar_loading").style.display = "none";
                      document.getElementById("form_newsletter_retirar").style.display = "block";
                   } else {
                      document.frmNewsletter3.submit();
			          alert("E-MAIL RETIRADO COM SUCESSO!\n\nO E-Mail " + Email.value + " foi retirado com sucesso na nossa Newsletter!");
					  document.getElementById("form_newsletter_retirar_loading").style.display = "none";
                      document.getElementById("form_newsletter_retirar").style.display = "block";   			   						   					   
				   }
			   }
            } else {
		       alert("Erro ao tentar efetuar retirar o seu E-Mail na nossa Newsletter. Tente novamente!");
               document.getElementById("form_newsletter_retirar_loading").style.display = "none";
               document.getElementById("form_newsletter_retirar").style.display = "block";   			   	
			}
         }
      }
      ajax.send(null);
   }   
}

function Avaliacao(Acao,Objeto,idMidia,UsuarioCookie) {
   if (Acao == "click") {
      Voto = Objeto.id.substring(5,6);
	  if ((idMidia.length > 0) && (Voto.length > 0) && (UsuarioCookie.length > 0)) {
	     if ((parseInt(Voto) >= 1) && (parseInt(Voto) <= 5)) {
            ajax2 = ajaxInit();
            resultado2 = "";
            document.getElementById("nota_loading").style.display = "block";
            document.getElementById("nota").style.display = "none";   
            if (ajax2) {
               ajax2.open("GET", "votar.asp?idMidia=" + idMidia + "&Voto=" + Voto + "&Cookie=" + UsuarioCookie + "&Rand=" + Math.ceil(Math.random() * 100000), true);
               ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
               ajax2.onreadystatechange = function() {
                  if (ajax2.readyState == 4) {
                     if (ajax2.status == 200) {
                        resultado2 = ajax2.responseText; 
						splitResultado = resultado2.split("|");
						resultado2 = splitResultado[0];
			            if (resultado2.length == 0) {
			               alert("Erro ao tentar avaliar esta mídia. Tente novamente!");
				           document.getElementById("nota_loading").style.display = "none";
                           document.getElementById("nota").style.display = "block";  
                           document.getElementById("nota_ok").style.display = "none";						   
			            } else {
						   if (resultado2 == "1") {
			                  alert("ATENÇÃO:\n\nVocê já avaliou esta mídia anteriormente!");
					          document.getElementById("nota_loading").style.display = "none";
                              document.getElementById("nota").style.display = "none";
                              document.getElementById("nota_ok").style.display = "block";
					       } else if (resultado2 == "2") {
		                      alert("Erro ao tentar avaliar esta mídia. Tente novamente!");
				              document.getElementById("nota_loading").style.display = "none";
                              document.getElementById("nota").style.display = "block";   			   	
                              document.getElementById("nota_ok").style.display = "none";
				           } else {
			                  alert("AVALIAÇÂO REALIZADA COM SUCESSO!\n\nO sistema registrou com sucesso a nota " + Voto + " que você deu para esta mídia!");
					          document.getElementById("nota_loading").style.display = "none";
                              document.getElementById("nota").style.display = "none";
                              document.getElementById("nota_ok").style.display = "block";							  
							  document.getElementById("media").innerHTML = "<font style='font-family: Arial; font-size: 14px;'><b>" + splitResultado[1] + "</b></font>";
							  document.getElementById("estrela").src = "adm/images/estrela" + splitResultado[2] + ".png";							  				           }
			            }
                     } else {
		                alert("Erro ao tentar avaliar esta mídia. Tente novamente!");
                        document.getElementById("nota_loading").style.display = "none";
                        document.getElementById("nota").style.display = "block"; 
                        document.getElementById("nota_ok").style.display = "none";						
			         }
                  }
               }
               ajax2.send(null);
            }   			     
		 }
	  } else {
         alert("Dados Inválidos!");
	  }
   }
   if (Acao == "over") {
	   Objeto.style.cursor = "pointer";
	   Opcao = Objeto.id.substring(5,6);
	   for (x = 1; x <= Opcao; x++) {
	      document.getElementById("nota_" + x).src = document.getElementById("nota_" + x).src.replace("1.png","3.png");		   
	   }
	   if (Opcao == "1") {
	      document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>péssimo</font>";
	   } 
	   if (Opcao == "2") {
	      document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>ruim</font>";
	   } 
	   if (Opcao == "3") {
	      document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>regular</font>";
	   } 
	   if (Opcao == "4") {
	      document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>bom</font>";
	   } 
	   if (Opcao == "5") {
	      document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>ótimo</font>";
	   } 
   }
   if (Acao == "out") {
	   Objeto.style.cursor = "default";
	   Opcao = Objeto.id.substring(5,6);
	   for (x = 1; x <= Opcao; x++) {
	      document.getElementById("nota_" + x).src = document.getElementById("nota_" + x).src.replace("3.png","1.png");		   
	   }
	   document.getElementById("qualificacao").innerHTML = "selecione";
   }
}

function Avaliacao2(Acao, Objeto, idForum, UsuarioCookie) {
    if (Acao == "click") {
        Voto = Objeto.id.substring(5, 6);
        if ((idForum.length > 0) && (Voto.length > 0) && (UsuarioCookie.length > 0)) {
            if ((parseInt(Voto) >= 1) && (parseInt(Voto) <= 5)) {
                ajax2 = ajaxInit();
                resultado2 = "";
                document.getElementById("nota_loading").style.display = "block";
                document.getElementById("nota").style.display = "none";
                if (ajax2) {
                    ajax2.open("GET", "votar2.asp?idForum=" + idForum + "&Voto=" + Voto + "&Cookie=" + UsuarioCookie + "&Rand=" + Math.ceil(Math.random() * 100000), true);
                    ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                    ajax2.onreadystatechange = function() {
                        if (ajax2.readyState == 4) {
                            if (ajax2.status == 200) {
                                resultado2 = ajax2.responseText;
                                splitResultado = resultado2.split("|");
                                resultado2 = splitResultado[0];
                                if (resultado2.length == 0) {
                                    alert("Erro ao tentar avaliar este tópico do fórum. Tente novamente!");
                                    document.getElementById("nota_loading").style.display = "none";
                                    document.getElementById("nota").style.display = "block";
                                    document.getElementById("nota_ok").style.display = "none";
                                } else {
                                    if (resultado2 == "1") {
                                        alert("ATENÇÃO:\n\nVocê já avaliou este tópico do fórum anteriormente!");
                                        document.getElementById("nota_loading").style.display = "none";
                                        document.getElementById("nota").style.display = "none";
                                        document.getElementById("nota_ok").style.display = "block";
                                    } else if (resultado2 == "2") {
                                        alert("Erro ao tentar avaliar este tópico do fórum. Tente novamente!");
                                        document.getElementById("nota_loading").style.display = "none";
                                        document.getElementById("nota").style.display = "block";
                                        document.getElementById("nota_ok").style.display = "none";
                                    } else {
                                        alert("AVALIAÇÂO REALIZADA COM SUCESSO!\n\nO sistema registrou com sucesso a nota " + Voto + " que você deu para este tópico do fórum!");
                                        document.getElementById("nota_loading").style.display = "none";
                                        document.getElementById("nota").style.display = "none";
                                        document.getElementById("nota_ok").style.display = "block";
                                        document.getElementById("media").innerHTML = "<font style='font-family: Arial; font-size: 14px;'><b>" + splitResultado[1] + "</b></font>";
                                        document.getElementById("estrela").src = "adm/images/estrela" + splitResultado[2] + ".png";
                                    }
                                }
                            } else {
                                alert("Erro ao tentar avaliar este tópico do fórum. Tente novamente!");
                                document.getElementById("nota_loading").style.display = "none";
                                document.getElementById("nota").style.display = "block";
                                document.getElementById("nota_ok").style.display = "none";
                            }
                        }
                    }
                    ajax2.send(null);
                }
            }
        } else {
            alert("Dados Inválidos!");
        }
    }
    if (Acao == "over") {
        Objeto.style.cursor = "pointer";
        Opcao = Objeto.id.substring(5, 6);
        for (x = 1; x <= Opcao; x++) {
            document.getElementById("nota_" + x).src = document.getElementById("nota_" + x).src.replace("1.png", "3.png");
        }
        if (Opcao == "1") {
            document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>péssimo</font>";
        }
        if (Opcao == "2") {
            document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>ruim</font>";
        }
        if (Opcao == "3") {
            document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>regular</font>";
        }
        if (Opcao == "4") {
            document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>bom</font>";
        }
        if (Opcao == "5") {
            document.getElementById("qualificacao").innerHTML = "<font color='#01a451'>ótimo</font>";
        }
    }
    if (Acao == "out") {
        Objeto.style.cursor = "default";
        Opcao = Objeto.id.substring(5, 6);
        for (x = 1; x <= Opcao; x++) {
            document.getElementById("nota_" + x).src = document.getElementById("nota_" + x).src.replace("3.png", "1.png");
        }
        document.getElementById("qualificacao").innerHTML = "selecione";
    }
}

function EnviarComentario(idMidia) {
   Nome = document.frmComentarios.Nome;
   if (Nome.value.length == 0) {
      alert("Digite o seu Nome!");
	  Nome.focus();
	  return;
   }
   Email = document.frmComentarios.Email;
   if (Email.value.length == 0) {
      alert("Digite o seu E-Mail!");
	  Email.focus();
	  return;
   }
   AchouArroba = Email.value.indexOf("@");
   AchouPonto = Email.value.lastIndexOf(".");
   if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
      alert("O Formato do seu e-Mail está inválido! Verifique!");
	  Email.focus();
	  return;
   }   		   
   Mensagem = document.frmComentarios.Mensagem;
   if (Mensagem.value.length == 0) {
      alert("Digite a Mensagem!");
	  Mensagem.focus();
	  return;
   }   
   ajax3 = ajaxInit();
   resultado3 = "";
   document.getElementById("form_indicacao_loading").style.display = "block";
   document.getElementById("form_indicacao").style.display = "none";   
   if (ajax3) {
      ajax3.open("GET", "envia_comentario.asp?idMidia=" + idMidia + "&Nome=" + Nome.value + "&Mensagem=" + Mensagem.value + "&Email=" + Email.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
      ajax3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax3.onreadystatechange = function() {
          if (ajax3.readyState == 4) {
              if (ajax3.status == 200) {
                  resultado3 = ajax3.responseText;
                  if (resultado3.length == 0) {
                      alert("Erro ao tentar enviar o seu comentário. Tente novamente!");
                      document.getElementById("form_indicacao_loading").style.display = "none";
                      document.getElementById("form_indicacao").style.display = "block";
                  } else {
                      if (resultado3 == "2") {
                          alert("Erro ao tentar enviar o seu comentário. Tente novamente!");
                          document.getElementById("form_indicacao_loading").style.display = "none";
                          document.getElementById("form_indicacao").style.display = "block";
                      } else {
                          document.frmComentarios.submit();
                          alert("COMENTÁRIO ENVIADO COM SUCESSO!\n\nO seu comentário foi enviado com sucesso e passará por um processo de aprovação antes de estar disponível no site!");
                          document.getElementById("form_indicacao_loading").style.display = "none";
                          document.getElementById("form_indicacao").style.display = "block";
                          Nome.value = "";
                          Email.value = "";
                          Mensagem.value = "";
                          Nome.focus();
                      }
                  }
              } else {
                  alert("Erro ao tentar enviar o seu comentário. Tente novamente!");
                  document.getElementById("form_indicacao_loading").style.display = "none";
                  document.getElementById("form_indicacao").style.display = "block";
              }
          }
      }
      ajax3.send(null);
   }   	
}

function EnviarComentarioForum(idForum) {
    Nome = document.frmComentarios.Nome;
    if (Nome.value.length == 0) {
        alert("Digite o seu Nome!");
        Nome.focus();
        return;
    }
    Email = document.frmComentarios.Email;
    if (Email.value.length == 0) {
        alert("Digite o seu E-Mail!");
        Email.focus();
        return;
    }
    AchouArroba = Email.value.indexOf("@");
    AchouPonto = Email.value.lastIndexOf(".");
    if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do seu e-Mail está inválido! Verifique!");
        Email.focus();
        return;
    }
    Mensagem = document.frmComentarios.Mensagem;
    if (Mensagem.value.length == 0) {
        alert("Digite a Mensagem!");
        Mensagem.focus();
        return;
    }
    ajax3 = ajaxInit();
    resultado3 = "";
    document.getElementById("form_comentarios_loading").style.display = "block";
    document.getElementById("form_comentarios").style.display = "none";
    if (ajax3) {
        ajax3.open("GET", "envia_comentario_forum.asp?idForum=" + idForum + "&Nome=" + Nome.value + "&Mensagem=" + Mensagem.value + "&Email=" + Email.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajax3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax3.onreadystatechange = function() {
            if (ajax3.readyState == 4) {
                if (ajax3.status == 200) {
                    resultado3 = ajax3.responseText;
                    if (resultado3.length == 0) {
                        alert("Erro ao tentar enviar o seu comentário. Tente novamente!");
                        document.getElementById("form_comentarios_loading").style.display = "none";
                        document.getElementById("form_comentarios").style.display = "block";
                    } else {
                        if (resultado3 == "2") {
                            alert("Erro ao tentar enviar o seu comentário. Tente novamente!");
                            document.getElementById("form_comentarios_loading").style.display = "none";
                            document.getElementById("form_comentarios").style.display = "block";
                        } else {
                            document.frmComentarios.submit();
                            alert("COMENTÁRIO ENVIADO COM SUCESSO!\n\nO seu comentário foi enviado com sucesso e passará por um processo de aprovação antes de estar disponível no fórum!");
                            document.getElementById("form_comentarios_loading").style.display = "none";
                            document.getElementById("form_comentarios").style.display = "block";
                            Nome.value = "";
                            Email.value = "";
                            Mensagem.value = "";
                            Nome.focus();
                        }
                    }
                } else {
                    alert("Erro ao tentar enviar o seu comentário. Tente novamente!");
                    document.getElementById("form_comentarios_loading").style.display = "none";
                    document.getElementById("form_comentarios").style.display = "block";
                }
            }
        }
        ajax3.send(null);
    }
}

function Imprimir() {
   window.print();	
}

function Favoritos() {
   URL = document.location;
   Titulo = document.title;
   if (window.sidebar) {
      window.sidebar.addPanel(Titulo, URL,"");
   } else if (window.opera && window.print) {
      mbm = document.createElement('a');
      mbm.setAttribute('rel','sidebar');
      mbm.setAttribute('href',URL);
      mbm.setAttribute('title',Titulo);
      mbm.click();
    } else if (document.all) {
      window.external.AddFavorite(URL,Titulo);
	}
}

function CancelarAmigo() {
	document.frmIndicacao.Nome.value = "";
	document.frmIndicacao.Email.value = "";	
	document.frmIndicacao.NomeAmigo.value = "";
	document.frmIndicacao.EmailAmigo.value = "";	
	document.getElementById("indicar").style.display = "none";
	document.getElementById("principal").style.display = "block";	
	document.getElementById("indicacao").style.display = "none";		
}

function IndicarAmigo() {
	document.getElementById("indicar").style.display = "block";
	document.getElementById("indicacao").style.display = "block";	
	document.getElementById("principal").style.display = "none";	
}

function Compartilhar() {
	document.getElementById("compartilhar").style.display = "block";
	document.getElementById("principal").style.display = "none";	
}

function CancelarCompartilhar() {
	document.getElementById("compartilhar").style.display = "none";
	document.getElementById("principal").style.display = "block";	
}

function EnviarAmigo(idMidia) {
   Nome = document.frmIndicacao.Nome;
   if (Nome.value.length == 0) {
      alert("Digite o seu Nome!");
	  Nome.focus();
	  return;
   }
   Email = document.frmIndicacao.Email;
   if (Email.value.length == 0) {
      alert("Digite o seu E-Mail!");
	  Email.focus();
	  return;
   }
   AchouArroba = Email.value.indexOf("@");
   AchouPonto = Email.value.lastIndexOf(".");
   if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
      alert("O Formato do seu e-Mail está inválido! Verifique!");
	  Email.focus();
	  return;
   }   		   
   NomeAmigo = document.frmIndicacao.NomeAmigo;
   if (NomeAmigo.value.length == 0) {
      alert("Digite o Nome do seu amigo!");
	  NomeAmigo.focus();
	  return;
   }
   EmailAmigo = document.frmIndicacao.EmailAmigo;
   if (EmailAmigo.value.length == 0) {
      alert("Digite o E-Mail do seu amigo!");
	  EmailAmigo.focus();
	  return;
   }
   AchouArroba = EmailAmigo.value.indexOf("@");
   AchouPonto = EmailAmigo.value.lastIndexOf(".");
   if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
      alert("O Formato do e-Mail do seu amigo está inválido! Verifique!");
	  EmailAmigo.focus();
	  return;
   }   		   
   ajax5 = ajaxInit();
   resultado5 = "";
   document.getElementById("indicacao_loading").style.display = "block";
   document.getElementById("indicacao").style.display = "none";
   if (ajax5) {
      ajax5.open("GET", "indicar.asp?idMidia=" + idMidia + "&Nome=" + Nome.value + "&Email=" + Email.value + "&NomeAmigo=" + NomeAmigo.value + "&EmailAmigo=" + EmailAmigo.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
      ajax5.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax5.onreadystatechange = function() {
          if (ajax5.readyState == 4) {
              if (ajax5.status == 200) {
                  resultado5 = ajax5.responseText;
                  if (resultado5.length == 0) {
                      alert("Erro ao tentar enviar a indicação. Tente novamente!");
                      document.getElementById("indicacao_loading").style.display = "none";
                      document.getElementById("indicacao").style.display = "block";
                  } else {
                      if (resultado5 == "2") {
                          alert("Erro ao tentar enviar a indicação. Tente novamente!");
                          document.getElementById("indicacao_loading").style.display = "none";
                          document.getElementById("indicacao").style.display = "block";
                      } else {
                          alert("INDICAÇÃO ENVIADA COM SUCESSO!\n\nO seu amigo " + Nome.value + " (" + Email.value + ") receberá um E-Mail em breve com a indicação desta mídia!");
                          document.getElementById("indicacao_loading").style.display = "none";
                          document.getElementById("indicacao").style.display = "block";
                          Nome.value = "";
                          Email.value = "";
                          NomeAmigo.value = "";
                          EmailAmigo.value = "";
                          Nome.focus();
                      }
                  }
              } else {
                  alert("Erro ao tentar enviar a indicação. Tente novamente!");
                  document.getElementById("indicacao_loading").style.display = "none";
                  document.getElementById("indicacao").style.display = "block";
              }
          }
      }
      ajax5.send(null);
   }   		
}

function EnviarAmigo2(idForum) {
    Nome = document.frmIndicacao.Nome;
    if (Nome.value.length == 0) {
        alert("Digite o seu Nome!");
        Nome.focus();
        return;
    }
    Email = document.frmIndicacao.Email;
    if (Email.value.length == 0) {
        alert("Digite o seu E-Mail!");
        Email.focus();
        return;
    }
    AchouArroba = Email.value.indexOf("@");
    AchouPonto = Email.value.lastIndexOf(".");
    if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do seu e-Mail está inválido! Verifique!");
        Email.focus();
        return;
    }
    NomeAmigo = document.frmIndicacao.NomeAmigo;
    if (NomeAmigo.value.length == 0) {
        alert("Digite o Nome do seu amigo!");
        NomeAmigo.focus();
        return;
    }
    EmailAmigo = document.frmIndicacao.EmailAmigo;
    if (EmailAmigo.value.length == 0) {
        alert("Digite o E-Mail do seu amigo!");
        EmailAmigo.focus();
        return;
    }
    AchouArroba = EmailAmigo.value.indexOf("@");
    AchouPonto = EmailAmigo.value.lastIndexOf(".");
    if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do e-Mail do seu amigo está inválido! Verifique!");
        EmailAmigo.focus();
        return;
    }
    ajax5 = ajaxInit();
    resultado5 = "";
    document.getElementById("indicacao_loading").style.display = "block";
    document.getElementById("indicacao").style.display = "none";
    if (ajax5) {
        ajax5.open("GET", "indicar2.asp?idForum=" + idForum + "&Nome=" + Nome.value + "&Email=" + Email.value + "&NomeAmigo=" + NomeAmigo.value + "&EmailAmigo=" + EmailAmigo.value + "&Rand=" + Math.ceil(Math.random() * 100000), true);
        ajax5.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        ajax5.onreadystatechange = function() {
            if (ajax5.readyState == 4) {
                if (ajax5.status == 200) {
                    resultado5 = ajax5.responseText;
                    if (resultado5.length == 0) {
                        alert("Erro ao tentar enviar a indicação. Tente novamente!");
                        document.getElementById("indicacao_loading").style.display = "none";
                        document.getElementById("indicacao").style.display = "block";
                    } else {
                        if (resultado5 == "2") {
                            alert("Erro ao tentar enviar a indicação. Tente novamente!");
                            document.getElementById("indicacao_loading").style.display = "none";
                            document.getElementById("indicacao").style.display = "block";
                        } else {
                            alert("INDICAÇÃO ENVIADA COM SUCESSO!\n\nO seu amigo " + Nome.value + " (" + Email.value + ") receberá um E-Mail em breve com a indicação deste tópico do fórum!");
                            document.getElementById("indicacao_loading").style.display = "none";
                            document.getElementById("indicacao").style.display = "block";
                            Nome.value = "";
                            Email.value = "";
                            NomeAmigo.value = "";
                            EmailAmigo.value = "";
                            Nome.focus();
                        }
                    }
                } else {
                    alert("Erro ao tentar enviar a indicação. Tente novamente!");
                    document.getElementById("indicacao_loading").style.display = "none";
                    document.getElementById("indicacao").style.display = "block";
                }
            }
        }
        ajax5.send(null);
    }
}

function ExibeComentariosVolta() {
   document.frmComentarios.VoltarComentarios.style.display = "none";		
   document.getElementById("form_comentarios").style.display = "block";
   document.getElementById("lista_comentarios").style.display = "none";
   document.getElementById("lista_lista_comentarios").style.display = "block";
   document.getElementById("loading_lista_comentarios").style.display = "none";   
   document.getElementById("total_comentarios").style.display = "none";      
}

function ExibeComentarios(idMidia) {
   ajax6 = ajaxInit();
   resultado6 = "";
   document.getElementById("form_comentarios").style.display = "none";
   document.getElementById("lista_comentarios").style.display = "block";
   document.getElementById("lista_lista_comentarios").style.display = "none";
   document.getElementById("loading_lista_comentarios").style.display = "block";
   document.getElementById("total_comentarios").style.display = "block";         
   document.frmComentarios.VoltarComentarios.style.display = "block";
   if (ajax6) {
      ajax6.open("GET", "carregar_comentarios.asp?idMidia=" + idMidia + "&Rand=" + Math.ceil(Math.random() * 100000), true);
      ajax6.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
      ajax6.onreadystatechange = function() {
         if (ajax6.readyState == 4) {
            if (ajax6.status == 200) {
               resultado6 = ajax6.responseText; 
			   if (resultado6.length == 0) {
			      alert("Erro ao tentar carregar os comentários. Tente novamente!");
				  document.getElementById("form_comentarios").style.display = "block";
                  document.getElementById("lista_comentarios").style.display = "none";   			   	
                  document.getElementById("lista_lista_comentarios").style.display = "none";
                  document.getElementById("loading_lista_comentarios").style.display = "none";   				  
			   } else {
				   splitResultado = resultado6.split("||");
				   if (splitResultado[0] == "2") {
		              alert("Erro ao tentar carregar os comentários. Tente novamente!");
				      document.getElementById("form_comentarios").style.display = "block";
                      document.getElementById("lista_comentarios").style.display = "none";   			   	
                      document.getElementById("lista_lista_comentarios").style.display = "none";
                      document.getElementById("loading_lista_comentarios").style.display = "none";
				  } else if (splitResultado[0] == "0") {
                      document.getElementById("total_comentarios").innerHTML = "<font style='font-size: 11px;'>Total: <b>0 comentários</b></font><br />";
					  document.getElementById("lista_lista_comentarios").innerHTML = "<div style='margin-top: 10px;'><font style='font-size: 14px;'>Não existem comentários no momento!<br /></font></div>";
					  document.getElementById("form_comentarios").style.display = "none";
                      document.getElementById("lista_comentarios").style.display = "block";
                      document.getElementById("lista_lista_comentarios").style.display = "block";
                      document.getElementById("loading_lista_comentarios").style.display = "none";
				  } else {
					  document.getElementById("form_comentarios").style.display = "none";
                      document.getElementById("lista_comentarios").style.display = "block";
                      document.getElementById("lista_lista_comentarios").style.display = "block";
                      document.getElementById("loading_lista_comentarios").style.display = "none";
					  splitComentarios = splitResultado[1].split("--");
                      document.getElementById("total_comentarios").innerHTML = "<font style='font-size: 11px;'>Total: <b>" + (splitComentarios.length-1) + " comentário(s)</b></font><br />";
					  if (splitComentarios.length > 0) {
                         ListaComentarios = "<table cellspacing='1' cellpadding='2' border='0' style='width: 340px; margin-top: 4px;'>";
						 for (x = 0; x < (splitComentarios.length-1); x++) {
					        subsplitComentarios = splitComentarios[x].split("&&");
						    ListaComentarios = ListaComentarios + "<tr><td style='width: 52px;' align='center' valign='top'><font style='font-size: 11px; color: darkred;'>" + subsplitComentarios[1] + "</font></td><td valign='top' align='center' style='width: 10px;'><font style='font-size: 11px; color: #000000;'>-</font></td><td align='left' valign='top'><font style='font-size: 11px; color: #000000;'>" + subsplitComentarios[0] + "<br /><font style='color: #444444;'>por " + subsplitComentarios[2] + " (" + subsplitComentarios[3] + ")</font></font></td></tr>";
					     }
						 ListaComentarios = ListaComentarios + "</table>";
						 document.getElementById("lista_lista_comentarios").innerHTML = ListaComentarios;
					  } else {
				         document.getElementById("lista_lista_comentarios").innerHTML = "<div style='margin-top: 10px;'><font style='font-size: 14px;'>Não existem comentários no momento!<br /></font></div>";
					  }
				   }
			   }
            } else {
		       alert("Erro ao tentar carregar os comentários. Tente novamente!");
               document.getElementById("form_comentarios").style.display = "block";
               document.getElementById("lista_comentarios").style.display = "none";   			   	
               document.getElementById("lista_lista_comentarios").style.display = "none";
               document.getElementById("loading_lista_comentarios").style.display = "none";			   
			}
         }
      }
      ajax6.send(null);
   }   		
}

function MudaCursor(Objeto,Acao) {
   if (Acao == "over") {
      Objeto.style.cursor = "pointer";   
   } else {
      Objeto.style.cursor = "default";	   
   }
}

function SelecionaCategoria(Objeto,Valor) {
   if (Valor == "efetivo") {
      document.getElementById("efetivo").src = document.getElementById("efetivo").src.replace(".png","b.png");
      document.getElementById("colaborador").src = document.getElementById("colaborador").src.replace("b.png",".png");
      document.getElementById("benemerito").src = document.getElementById("benemerito").src.replace("b.png",".png");
      document.frmAssociado.Categoria.value = Valor;	  
   } 
   if (Valor == "colaborador") {
      document.getElementById("efetivo").src = document.getElementById("efetivo").src.replace("b.png",".png");
      document.getElementById("colaborador").src = document.getElementById("colaborador").src.replace(".png","b.png");
      document.getElementById("benemerito").src = document.getElementById("benemerito").src.replace("b.png",".png");
      document.frmAssociado.Categoria.value = Valor;	  
   } 
   if (Valor == "benemerito") {
      document.getElementById("efetivo").src = document.getElementById("efetivo").src.replace("b.png",".png");
      document.getElementById("colaborador").src = document.getElementById("colaborador").src.replace("b.png",".png");
      document.getElementById("benemerito").src = document.getElementById("benemerito").src.replace(".png","b.png");
      document.frmAssociado.Categoria.value = Valor;	  
   } 
}

function SelecionaDoacao(Objeto,Valor) {
   if (Valor == "20") {
      document.getElementById("valor_20").src = document.getElementById("valor_20").src.replace(".png","b.png");
      document.getElementById("valor_40").src = document.getElementById("valor_40").src.replace("b.png",".png");
      document.getElementById("valor_80").src = document.getElementById("valor_80").src.replace("b.png",".png");
      document.getElementById("valor_120").src = document.getElementById("valor_120").src.replace("b.png",".png");
      document.getElementById("valor_240").src = document.getElementById("valor_240").src.replace("b.png",".png");
      document.getElementById("valor_outros").src = document.getElementById("valor_outros").src.replace("b.png",".png");	  
      document.getElementById("div_valor_unico_doacao").style.display = "none";
      document.frmDoacoes.ValorMensal.value = Valor;
      document.frmDoacoes.ValorUnico.value = "";	  
   } 
   if (Valor == "40") {
      document.getElementById("valor_20").src = document.getElementById("valor_20").src.replace("b.png",".png");
      document.getElementById("valor_40").src = document.getElementById("valor_40").src.replace(".png","b.png");
      document.getElementById("valor_80").src = document.getElementById("valor_80").src.replace("b.png",".png");
      document.getElementById("valor_120").src = document.getElementById("valor_120").src.replace("b.png",".png");
      document.getElementById("valor_240").src = document.getElementById("valor_240").src.replace("b.png",".png");
      document.getElementById("valor_outros").src = document.getElementById("valor_outros").src.replace("b.png",".png");	 
      document.getElementById("div_valor_unico_doacao").style.display = "none";
      document.frmDoacoes.ValorMensal.value = Valor;
      document.frmDoacoes.ValorUnico.value = "";	  
   } 
   if (Valor == "80") {
      document.getElementById("valor_20").src = document.getElementById("valor_20").src.replace("b.png",".png");
      document.getElementById("valor_40").src = document.getElementById("valor_40").src.replace("b.png",".png");
      document.getElementById("valor_80").src = document.getElementById("valor_80").src.replace(".png","b.png");
      document.getElementById("valor_120").src = document.getElementById("valor_120").src.replace("b.png",".png");
      document.getElementById("valor_240").src = document.getElementById("valor_240").src.replace("b.png",".png");
      document.getElementById("valor_outros").src = document.getElementById("valor_outros").src.replace("b.png",".png");	  
      document.getElementById("div_valor_unico_doacao").style.display = "none";
      document.frmDoacoes.ValorMensal.value = Valor;
      document.frmDoacoes.ValorUnico.value = "";	  
   } 
   if (Valor == "120") {
      document.getElementById("valor_20").src = document.getElementById("valor_20").src.replace("b.png",".png");
      document.getElementById("valor_40").src = document.getElementById("valor_40").src.replace("b.png",".png");
      document.getElementById("valor_80").src = document.getElementById("valor_80").src.replace("b.png",".png");
      document.getElementById("valor_120").src = document.getElementById("valor_120").src.replace(".png","b.png");
      document.getElementById("valor_240").src = document.getElementById("valor_240").src.replace("b.png",".png");
      document.getElementById("valor_outros").src = document.getElementById("valor_outros").src.replace("b.png",".png");	  
      document.getElementById("div_valor_unico_doacao").style.display = "none";
      document.frmDoacoes.ValorMensal.value = Valor;
      document.frmDoacoes.ValorUnico.value = "";	  
   } 
   if (Valor == "240") {
      document.getElementById("valor_20").src = document.getElementById("valor_20").src.replace("b.png",".png");
      document.getElementById("valor_40").src = document.getElementById("valor_40").src.replace("b.png",".png");
      document.getElementById("valor_80").src = document.getElementById("valor_80").src.replace("b.png",".png");
      document.getElementById("valor_120").src = document.getElementById("valor_120").src.replace("b.png",".png");
      document.getElementById("valor_240").src = document.getElementById("valor_240").src.replace(".png","b.png");
      document.getElementById("valor_outros").src = document.getElementById("valor_outros").src.replace("b.png",".png");	  
      document.getElementById("div_valor_unico_doacao").style.display = "none";
      document.frmDoacoes.ValorMensal.value = Valor;
      document.frmDoacoes.ValorUnico.value = "";	  
   } 
   if (Valor == "outros") {
      document.getElementById("valor_20").src = document.getElementById("valor_20").src.replace("b.png",".png");
      document.getElementById("valor_40").src = document.getElementById("valor_40").src.replace("b.png",".png");
      document.getElementById("valor_80").src = document.getElementById("valor_80").src.replace("b.png",".png");
      document.getElementById("valor_120").src = document.getElementById("valor_120").src.replace("b.png",".png");
      document.getElementById("valor_240").src = document.getElementById("valor_240").src.replace("b.png",".png");
      document.getElementById("valor_outros").src = document.getElementById("valor_outros").src.replace(".png","b.png");
      document.getElementById("div_valor_unico_doacao").style.display = "block";
      document.frmDoacoes.ValorMensal.value = "";
      document.frmDoacoes.ValorUnico.value = "";	  
   } 
}

function AlteraDoacao(Tipo) {
   if (Tipo == "mensal") {
      document.getElementById("doacao_mensal").style.display = "block";   
      document.getElementById("doacao_unica").style.display = "none";   	  
   } else {
      document.getElementById("doacao_mensal").style.display = "none";	  
      document.getElementById("doacao_unica").style.display = "block";   	  

   }
   document.frmDoacoes.ValorMensal.value = "";
   document.frmDoacoes.ValorUnico.value = "";	  
   document.getElementById("div_valor_unico_doacao").style.display = "none";
   document.getElementById("valor_20").src = document.getElementById("valor_20").src.replace("b.png",".png");
   document.getElementById("valor_40").src = document.getElementById("valor_40").src.replace("b.png",".png");
   document.getElementById("valor_80").src = document.getElementById("valor_80").src.replace("b.png",".png");
   document.getElementById("valor_120").src = document.getElementById("valor_120").src.replace("b.png",".png");
   document.getElementById("valor_240").src = document.getElementById("valor_240").src.replace("b.png",".png");
   document.getElementById("valor_outros").src = document.getElementById("valor_outros").src.replace("b.png",".png");

}

function EnviarDoacao() {
    tipo_doacao = document.frmDoacoes.Tipo;
    if (tipo_doacao[0].checked) {
       tipo_doacao = "Mensal";
    } else {
       tipo_doacao = "Única";
   }
   if (tipo_doacao == "Mensal") {
       valor_unico_doacao = document.frmDoacoes.ValorMensal.value;
   } else {
       valor_unico_doacao = document.frmDoacoes.ValorUnico.value;
       if (valor_unico_doacao < 15) {
           alert("O Valor Mínimo para doação é de R$ 15,00!");
           document.frmDoacoes.ValorUnico.focus();
           return;
       }
   }
   if (valor_unico_doacao.length == 0) {
       alert("Informe o valor da doação!");
       if (tipo_doacao == "Mensal") {
           if (document.getElementById("valor_outros").src.indexOf("b.png") >= 0) {
               document.frmDoacoes.ValorMensal.focus();
           } else {
               document.frmDoacoes.Tipo[0].focus();
           }
       } else {
           document.frmDoacoes.ValorUnico.focus();
       }
       return;
   }
   nome_doacao = document.frmDoacoes.Nome;
   if (nome_doacao.value.length == 0) {
       alert("Digite o seu Nome Completo!");
       nome_doacao.focus();
       return;
   }
   email_doacao = document.frmDoacoes.Email;
   if (email_doacao.value.length == 0) {
       alert("Digite o seu E-Mail!");
       email_doacao.focus();
       return;
   }
   AchouArroba = email_doacao.value.indexOf("@");
   AchouPonto = email_doacao.value.lastIndexOf(".");
   if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
       alert("O Formato do seu e-Mail está inválido! Verifique!");
       email_doacao.focus();       
       return;
   }
   cpf_doacao = document.frmDoacoes.CPF;
   if (cpf_doacao.value.length == 0) {
       alert("Digite o seu CPF!");
       cpf_doacao.focus();
       return;
   }
   cpf_doacao = cpf_doacao.value.replace(".", "");
   cpf_doacao = cpf_doacao.replace(".", "");
   cpf_doacao = cpf_doacao.replace("-", "");
   if (isCPF(cpf_doacao) == false) {
       alert("CPF inválido! Verifique!");
       document.frmDoacoes.CPF.focus();
       return;
   }
   sexo_doacao = document.frmDoacoes.Sexo;
   if (sexo_doacao.selectedIndex == 0) {
       alert("Informe o seu Sexo!");
       sexo_doacao.focus();
       return;
   }
   ddd_residencial_doacao = document.frmDoacoes.DDDTelefoneResidencial;
   if (ddd_residencial_doacao.value.length == 0) {
       alert("Informe o DDD do seu Telefone Residencial!");
       ddd_residencial_doacao.focus();
       return;
   }
   telefone_residencial_doacao = document.frmDoacoes.TelefoneResidencial;
   if (telefone_residencial_doacao.value.length == 0) {
       alert("Informe o seu Telefone Residencial!");
       telefone_residencial_doacao.focus();
       return;
   }
   endereco_doacao = document.frmDoacoes.Endereco;
   if (endereco_doacao.value.length == 0) {
       alert("Informe o seu Endereço!");
       endereco_doacao.focus();
       return;
   }
   numero_endereco_doacao = document.frmDoacoes.NumeroEndereco;
   if (numero_endereco_doacao.value.length == 0) {
       alert("Informe o Número do seu Endereço!");
       numero_endereco_doacao.focus();
       return;
   }
   bairro_doacao = document.frmDoacoes.Bairro;
   if (bairro_doacao.value.length == 0) {
       alert("Informe o seu Bairro!");
       bairro_doacao.focus();
       return;
   }
   cidade_doacao = document.frmDoacoes.Cidade;
   if (cidade_doacao.value.length == 0) {
       alert("Informe a sua Cidade!");
       cidade_doacao.focus();
       return;
   }
   estado_doacao = document.frmDoacoes.Estado;
   if (estado_doacao.selectedIndex == 0) {
       alert("Informe o seu Estado!");
       estado_doacao.focus();
       return;
   }
   cep_doacao = document.frmDoacoes.CEP[0];
   if (cep_doacao.value.length == 0) {
       alert("Informe o seu CEP!");
       cep_doacao.focus();
       return;
   }
   cep_doacao = document.frmDoacoes.CEP[1];
   if (cep_doacao.value.length == 0) {
       alert("Informe o seu CEP!");
       cep_doacao.focus();
       return;
   }
   document.frmDoacoes.submit();
}

function EnviarAssociado() {
    CategoriaAssociado = document.frmAssociado.Categoria;
    if (CategoriaAssociado.value.length == 0) {
        alert("Informe a Categoria!");
        return;
    }
    NomeAssociado = document.frmAssociado.Nome;
    if (NomeAssociado.value.length == 0) {
        alert("Digite o seu Nome Completo!");
        NomeAssociado.focus();
        return;
    }
    EmailAssociado = document.frmAssociado.Email;
    if (EmailAssociado.value.length == 0) {
        alert("Digite o seu E-Mail!");
        EmailAssociado.focus();
        return;
    }
    AchouArroba = EmailAssociado.value.indexOf("@");
    AchouPonto = EmailAssociado.value.lastIndexOf(".");
    if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do seu e-Mail está inválido! Verifique!");
        EmailAssociado.focus();
        return;
    }
    RGAssociado = document.frmAssociado.RG;
    if (RGAssociado.value.length == 0) {
        alert("Digite o seu RG!");
        RGAssociado.focus();
        return;
    }
    CPFAssociado = document.frmAssociado.CPF;
    if (CPFAssociado.value.length == 0) {
        alert("Digite o seu CPF!");
        CPFAssociado.focus();
        return;
    }
    CPFAssociado = CPFAssociado.value.replace(".", "");
    CPFAssociado = CPFAssociado.replace(".", "");
    CPFAssociado = CPFAssociado.replace("-", "");
    if (isCPF(CPFAssociado) == false) {
        alert("CPF inválido! Verifique!");
        document.frmAssociado.CPF.focus();
        return;
    }
    SexoAssociado = document.frmAssociado.Sexo;
    if (SexoAssociado.selectedIndex == 0) {
        alert("Informe o seu Sexo!");
        SexoAssociado.focus();
        return;
    }
    EnderecoAssociado = document.frmAssociado.Endereco;
    if (EnderecoAssociado.value.length == 0) {
        alert("Informe o seu Endereço!");
        EnderecoAssociado.focus();
        return;
    }
    NumeroEnderecoAssociado = document.frmAssociado.NumeroEndereco;
    if (NumeroEnderecoAssociado.value.length == 0) {
        alert("Informe o Número do seu Endereço!");
        NumeroEnderecoAssociado.focus();
        return;
    }
    BairroAssociado = document.frmAssociado.Bairro;
    if (BairroAssociado.value.length == 0) {
        alert("Informe o seu Bairro!");
        BairroAssociado.focus();
        return;
    }
    CidadeAssociado = document.frmAssociado.Cidade;
    if (CidadeAssociado.value.length == 0) {
        alert("Informe a sua Cidade!");
        CidadeAssociado.focus();
        return;
    }
    EstadoAssociado = document.frmAssociado.Estado;
    if (EstadoAssociado.selectedIndex == 0) {
        alert("Informe o seu Estado!");
        EstadoAssociado.focus();
        return;
    }
    CEPAssociado = document.frmAssociado.CEP[0];
    if (CEPAssociado.value.length == 0) {
        alert("Informe o seu CEP!");
        CEPAssociado.focus();
        return;
    }
    CEPAssociado = document.frmAssociado.CEP[1];
    if (CEPAssociado.value.length == 0) {
        alert("Informe o seu CEP!");
        CEPAssociado.focus();
        return;
    }
    DDDTelefoneAssociado = document.frmAssociado.DDDTelefone;
    if (DDDTelefoneAssociado.value.length == 0) {
        alert("Informe o DDD do seu Telefone Residencial!");
        DDDTelefoneAssociado.focus();
        return;
    }
    TelefoneAssociado = document.frmAssociado.Telefone;
    if (TelefoneAssociado.value.length == 0) {
        alert("Informe o seu Telefone Residencial!");
        TelefoneAssociado.focus();
        return;
    }
    if (document.frmAssociado.Votacao.checked == false) {
        alert("Você deve marcar se solicita a votação de seu nome para associado da Associação Brasileira de Gagueira - ABRA GAGUEIRA na próxima Assembléia Geral a ser realizada!");
        document.frmAssociado.Votacao.focus();
        return;
    }
    document.frmAssociado.submit();
}

function EnviarVoluntario() {
    NomeVoluntario = document.frmVoluntario.Nome;
    if (NomeVoluntario.value.length == 0) {
        alert("Digite o seu Nome Completo!");
        NomeVoluntario.focus();
        return;
    }
    EmailVoluntario = document.frmVoluntario.Email;
    if (EmailVoluntario.value.length == 0) {
        alert("Digite o seu E-Mail!");
        EmailVoluntario.focus();
        return;
    }
    AchouArroba = EmailVoluntario.value.indexOf("@");
    AchouPonto = EmailVoluntario.value.lastIndexOf(".");
    if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do seu e-Mail está inválido! Verifique!");
        EmailVoluntario.focus();
        return;
    }
    RGVoluntario = document.frmVoluntario.RG;
    if (RGVoluntario.value.length == 0) {
        alert("Digite o seu RG!");
        RGVoluntario.focus();
        return;
    }
    CPFVoluntario = document.frmVoluntario.CPF;
    if (CPFVoluntario.value.length == 0) {
        alert("Digite o seu CPF!");
        CPFVoluntario.focus();
        return;
    }
    CPFVoluntario = CPFVoluntario.value.replace(".", "");
    CPFVoluntario = CPFVoluntario.replace(".", "");
    CPFVoluntario = CPFVoluntario.replace("-", "");
    if (isCPF(CPFVoluntario) == false) {
        alert("CPF inválido! Verifique!");
        document.frmVoluntario.CPF.focus();
        return;
    }
    SexoVoluntario = document.frmVoluntario.Sexo;
    if (SexoVoluntario.selectedIndex == 0) {
        alert("Informe o seu Sexo!");
        SexoVoluntario.focus();
        return;
    }
    EnderecoVoluntario = document.frmVoluntario.Endereco;
    if (EnderecoVoluntario.value.length == 0) {
        alert("Informe o seu Endereço!");
        EnderecoVoluntario.focus();
        return;
    }
    NumeroEnderecoVoluntario = document.frmVoluntario.NumeroEndereco;
    if (NumeroEnderecoVoluntario.value.length == 0) {
        alert("Informe o Número do seu Endereço!");
        NumeroEnderecoVoluntario.focus();
        return;
    }
    BairroVoluntario = document.frmVoluntario.Bairro;
    if (BairroVoluntario.value.length == 0) {
        alert("Informe o seu Bairro!");
        BairroVoluntario.focus();
        return;
    }
    CidadeVoluntario = document.frmVoluntario.Cidade;
    if (CidadeVoluntario.value.length == 0) {
        alert("Informe a sua Cidade!");
        CidadeVoluntario.focus();
        return;
    }
    EstadoVoluntario = document.frmVoluntario.Estado;
    if (EstadoVoluntario.selectedIndex == 0) {
        alert("Informe o seu Estado!");
        EstadoVoluntario.focus();
        return;
    }
    CEPVoluntario = document.frmVoluntario.CEP[0];
    if (CEPVoluntario.value.length == 0) {
        alert("Informe o seu CEP!");
        CEPVoluntario.focus();
        return;
    }
    CEPVoluntario = document.frmVoluntario.CEP[1];
    if (CEPVoluntario.value.length == 0) {
        alert("Informe o seu CEP!");
        CEPVoluntario.focus();
        return;
    }
    DDDTelefoneVoluntario = document.frmVoluntario.DDDTelefone;
    if (DDDTelefoneVoluntario.value.length == 0) {
        alert("Informe o DDD do seu Telefone Residencial!");
        DDDTelefoneVoluntario.focus();
        return;
    }
    TelefoneVoluntario = document.frmVoluntario.Telefone;
    if (TelefoneVoluntario.value.length == 0) {
        alert("Informe o seu Telefone Residencial!");
        TelefoneVoluntario.focus();
        return;
    }
    document.frmVoluntario.submit();
}

function bloquearTeclas(e) {
    var key;
    var keychar;
    var reg;
    if (window.event) {
        key = e.keyCode;
    } else if (e.which) {
        key = e.which;
    } else {
        return true;
    }

    keychar = String.fromCharCode(key);
    reg = /\d/;
    return reg.test(keychar);
}

function DefineCaracterizacao(Valor) {
    if (Valor == "Outros") {
        document.frmAssociado.CaracterizacaoOutros.disabled = false;
        document.frmAssociado.CaracterizacaoOutros.value = "";
        document.frmAssociado.CaracterizacaoOutros.focus();
    } else {
        document.frmAssociado.CaracterizacaoOutros.disabled = true;
        document.frmAssociado.CaracterizacaoOutros.value = "";
    }
}

function DefineCaracterizacao2(Valor) {
    if (Valor == "Outros") {
        document.frmVoluntario.CaracterizacaoOutros.disabled = false;
        document.frmVoluntario.CaracterizacaoOutros.value = "";
        document.frmVoluntario.CaracterizacaoOutros.focus();
    } else {
        document.frmVoluntario.CaracterizacaoOutros.disabled = true;
        document.frmVoluntario.CaracterizacaoOutros.value = "";
    }
}

function FormataCEP(Valor) {
    cep = document.frmDoacoes.CEP[Valor].value + "00000";
    if (Valor == "0") {
        cep = cep.substring(0, 5);
    } else {
       cep = cep.substring(0, 3);
    }
    document.frmDoacoes.CEP[Valor].value = cep;
}

function FormataCEP2(Valor) {
    cep = document.frmAssociado.CEP[Valor].value + "00000";
    if (Valor == "0") {
        cep = cep.substring(0, 5);
    } else {
        cep = cep.substring(0, 3);
    }
    document.frmAssociado.CEP[Valor].value = cep;
}

function FormataCEP3(Valor) {
    cep = document.frmVoluntario.CEP[Valor].value + "00000";
    if (Valor == "0") {
        cep = cep.substring(0, 5);
    } else {
        cep = cep.substring(0, 3);
    }
    document.frmVoluntario.CEP[Valor].value = cep;
}

function PreencheIdade() {
    Idade = CalculaIdade();
    if (Idade < 0) {
        document.getElementById("IdadeDIV").innerHTML = "indefinida";
        document.frmAssociado.Idade.value = "";
    } else {
        if (Idade == 1) {
            document.getElementById("IdadeDIV").innerHTML = "<font color='#006aa8'>" + Idade + " ano</font>";
            document.frmAssociado.Idade.value = Idade + " ano";
        } else {
        document.getElementById("IdadeDIV").innerHTML = "<font color='#006aa8'>" + Idade + " anos</font>";
            document.frmAssociado.Idade.value = Idade + " anos";
        }
    }
}

function PreencheIdade3() {
    Idade = CalculaIdade3();
    if (Idade < 0) {
        document.getElementById("IdadeDIV").innerHTML = "indefinida";
        document.frmSoftware.Idade.value = "";
    } else {
        if (Idade == 1) {
            document.getElementById("IdadeDIV").innerHTML = "<font color='#006aa8'>" + Idade + " ano</font>";
            document.frmSoftware.Idade.value = Idade + " ano";
        } else {
            document.getElementById("IdadeDIV").innerHTML = "<font color='#006aa8'>" + Idade + " anos</font>";
            document.frmSoftware.Idade.value = Idade + " anos";
        }
    }
}

function PreencheIdade2() {    
    Idade = CalculaIdade2();    
    if (Idade < 0) {
        document.getElementById("IdadeDIV").innerHTML = "indefinida";
        document.frmVoluntario.Idade.value = "";
    } else {
        if (Idade == 1) {
            document.getElementById("IdadeDIV").innerHTML = "<font color='#006aa8'>" + Idade + " ano</font>";
            document.frmVoluntario.Idade.value = Idade + " ano";
        } else {
            document.getElementById("IdadeDIV").innerHTML = "<font color='#006aa8'>" + Idade + " anos</font>";
            document.frmVoluntario.Idade.value = Idade + " anos";
        }
    }
}

function Verifica(Valor) {
    if (Valor.length > 0) {
        document.frmAssociado.Caracterizacao[1].checked = false;
        document.frmAssociado.Caracterizacao[2].checked = false;
        document.frmAssociado.Caracterizacao[3].checked = true;
    } else {
        document.frmAssociado.Caracterizacao[1].checked = false;
        document.frmAssociado.Caracterizacao[2].checked = false;
        document.frmAssociado.Caracterizacao[3].checked = false;
    }
}

function Verifica2(Valor) {
    if (Valor.length > 0) {
        document.frmVoluntario.Caracterizacao[1].checked = false;
        document.frmVoluntario.Caracterizacao[2].checked = false;
        document.frmVoluntario.Caracterizacao[3].checked = true;
    } else {
        document.frmVoluntario.Caracterizacao[1].checked = false;
        document.frmVoluntario.Caracterizacao[2].checked = false;
        document.frmVoluntario.Caracterizacao[3].checked = false;
    }
}

function CalculaIdade() {
    Dia = document.frmAssociado.DiaNascimento.value;
    Mes = document.frmAssociado.MesNascimento.value;
    Ano = document.frmAssociado.AnoNascimento.value;
    data = "";
    if ((Dia.length > 0) && (Mes.length > 0) && (Ano.length > 0)) {
        data = Dia + "/" + Mes + "/" + Ano;
        //calculo a data de hoje 
        hoje = new Date()
        //alert(hoje) 

        //calculo a data que recebo 
        //descomponho a data em um array 
        var array_data = data.split("/")
        //se o array nao tem tres partes, a data eh incorreta 
        if (array_data.length != 3)
            return -1;

        //comprovo que o ano, mes, dia são corretos 
        var ano
        ano = parseInt(array_data[2]);
        if (isNaN(ano))
            return -1;

        var mes
        mes = parseInt(array_data[1]);
        if (isNaN(mes))
            return -1;

        var dia
        dia = parseInt(array_data[0]);
        if (isNaN(dia))
            return -1;


        //se o ano da data que recebo so tem 2 cifras temos que muda-lo a 4 
        if (ano <= 99)
            ano += 1900

        //subtraio os anos das duas datas 
        idade = hoje.getYear() - ano - 1; //-1 porque ainda nao fez anos durante este ano 

        //se subtraio os meses e for menor que 0 entao nao cumpriu anos. Se for maior sim ja cumpriu 
        if (hoje.getMonth() + 1 - mes < 0) //+ 1 porque os meses comecam em 0 
            return idade
        if (hoje.getMonth() + 1 - mes > 0)
            return idade + 1

        //entao eh porque sao iguais. Vejo os dias 
        //se subtraio os dias e der menor que 0 entao nao cumpriu anos. Se der maior ou igual sim que já cumpriu 
        if (hoje.getUTCDate() - dia >= 0)
            return idade + 1

        return idade
    } else {
        return -1;
    }        
}

function CalculaIdade2() {
    Dia = document.frmVoluntario.DiaNascimento.value;
    Mes = document.frmVoluntario.MesNascimento.value;
    Ano = document.frmVoluntario.AnoNascimento.value;
    data = "";
    if ((Dia.length > 0) && (Mes.length > 0) && (Ano.length > 0)) {
        data = Dia + "/" + Mes + "/" + Ano;
        //calculo a data de hoje 
        hoje = new Date()
        //alert(hoje) 

        //calculo a data que recebo 
        //descomponho a data em um array 
        var array_data = data.split("/")
        //se o array nao tem tres partes, a data eh incorreta 
        if (array_data.length != 3)
            return -1;

        //comprovo que o ano, mes, dia são corretos 
        var ano
        ano = parseInt(array_data[2]);
        if (isNaN(ano))
            return -1;

        var mes
        mes = parseInt(array_data[1]);
        if (isNaN(mes))
            return -1;

        var dia
        dia = parseInt(array_data[0]);
        if (isNaN(dia))
            return -1;


        //se o ano da data que recebo so tem 2 cifras temos que muda-lo a 4 
        if (ano <= 99)
            ano += 1900

        //subtraio os anos das duas datas 
        idade = hoje.getYear() - ano - 1; //-1 porque ainda nao fez anos durante este ano 

        //se subtraio os meses e for menor que 0 entao nao cumpriu anos. Se for maior sim ja cumpriu 
        if (hoje.getMonth() + 1 - mes < 0) //+ 1 porque os meses comecam em 0 
            return idade
        if (hoje.getMonth() + 1 - mes > 0)
            return idade + 1

        //entao eh porque sao iguais. Vejo os dias 
        //se subtraio os dias e der menor que 0 entao nao cumpriu anos. Se der maior ou igual sim que já cumpriu 
        if (hoje.getUTCDate() - dia >= 0)
            return idade + 1

        return idade
    } else {
        return -1;
    }
}

function CalculaIdade3() {
    Dia = document.frmSoftware.DiaNascimento.value;
    Mes = document.frmSoftware.MesNascimento.value;
    Ano = document.frmSoftware.AnoNascimento.value;
    data = "";
    if ((Dia.length > 0) && (Mes.length > 0) && (Ano.length > 0)) {
        data = Dia + "/" + Mes + "/" + Ano;
        //calculo a data de hoje 
        hoje = new Date()
        //alert(hoje) 

        //calculo a data que recebo 
        //descomponho a data em um array 
        var array_data = data.split("/")
        //se o array nao tem tres partes, a data eh incorreta 
        if (array_data.length != 3)
            return -1;

        //comprovo que o ano, mes, dia são corretos 
        var ano
        ano = parseInt(array_data[2]);
        if (isNaN(ano))
            return -1;

        var mes
        mes = parseInt(array_data[1]);
        if (isNaN(mes))
            return -1;

        var dia
        dia = parseInt(array_data[0]);
        if (isNaN(dia))
            return -1;


        //se o ano da data que recebo so tem 2 cifras temos que muda-lo a 4 
        if (ano <= 99)
            ano += 1900

        //subtraio os anos das duas datas 
        idade = hoje.getYear() - ano - 1; //-1 porque ainda nao fez anos durante este ano 

        //se subtraio os meses e for menor que 0 entao nao cumpriu anos. Se for maior sim ja cumpriu 
        if (hoje.getMonth() + 1 - mes < 0) //+ 1 porque os meses comecam em 0 
            return idade
        if (hoje.getMonth() + 1 - mes > 0)
            return idade + 1

        //entao eh porque sao iguais. Vejo os dias 
        //se subtraio os dias e der menor que 0 entao nao cumpriu anos. Se der maior ou igual sim que já cumpriu 
        if (hoje.getUTCDate() - dia >= 0)
            return idade + 1

        return idade
    } else {
        return -1;
    }
}

function Ampliar(Arquivo) {
    JanelaAmpliada = window.open("ampliada.asp?Arquivo=" + Arquivo, "JanelaAmpliada", "width=700,height=640,left=10,top=10,scrollbars=yes");
    JanelaAmpliada.focus();
}

function MudaContato(Valor) {
    if (Valor == "abragagueira@abragagueira.org.br") {
        document.frmContato.Destinatario.value = "Diretoria da Abra Gagueira|eduardo@id360.com.br";
    } else {
        document.frmContato.Destinatario.value = "Coordenação de Grupos de Apoio|eduardo@id360.com.br";
    }
}

function EnviarContato() {
    Nome = document.frmContato.Nome;
    if (Nome.value.length == 0) {
        alert("Digite o seu Nome Completo!");
        Nome.focus();
        return;
    }
    Email = document.frmContato.Email;
    if (Email.value.length == 0) {
        alert("Digite o seu E-Mail!");
        Email.focus();
        return;
    }
    AchouArroba = Email.value.indexOf("@");
    AchouPonto = Email.value.lastIndexOf(".");
    if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do seu e-Mail está inválido! Verifique!");
        Email.focus();
        return;
    }
    Assunto = document.frmContato.Assunto[1];
    if (Assunto.value.length == 0) {
        alert("Digite o Assunto!");
        Assunto.focus();
        return;
    }
    Mensagem = document.frmContato.Mensagem;
    if (Mensagem.value.length == 0) {
        alert("Digite a Mensagem!");
        Mensagem.focus();
        return;
    }
    document.frmContato.submit();
}

function IsDate(day, month, year) {
    //IsDate(29, 2, 2005)
    //IsDate(29, 2, 2004)
    var date = new Date();
    var blnRet = false;
    var blnDay;
    var blnMonth;
    var blnYear;

    date.setFullYear(year, month - 1, day);

    blnDay = (date.getDate() == day);
    blnMonth = (date.getMonth() == month - 1);
    blnYear = (date.getFullYear() == year);

    if (blnDay && blnMonth && blnYear)
        blnRet = true;

    return blnRet;
}


function EnviarCadastroSoftware() {
    Nome = document.frmSoftware.Nome;
    if (Nome.value.length == 0) {
        alert("Digite o seu Nome Completo!");
        Nome.focus();
        return;
    }
    Email = document.frmSoftware.Email;
    if (Email.value.length == 0) {
        alert("Digite o seu E-Mail!");
        Email.focus();
        return;
    }
    AchouArroba = Email.value.indexOf("@");
    AchouPonto = Email.value.lastIndexOf(".");
    if ((AchouArroba > AchouPonto) || (AchouArroba <= 0 || AchouPonto <= 0)) {
        alert("O Formato do seu e-Mail está inválido! Verifique!");
        Email.focus();
        return;
    }
    EmailConfirma = document.frmSoftware.EmailConfirma;
    if (EmailConfirma.value.length == 0) {
        alert("Confirme o E-Mail digitado!");
        EmailConfirma.focus();
        return;
    }
    if (EmailConfirma.value != Email.value) {
        alert("O E-Mail digitado está diferente do informado acima!");
        EmailConfirma.focus();
        return;
    }
    Idade = document.frmSoftware.Idade;
    if (Idade.value.length == 0) {
        alert("Digite a sua Idade!");
        Idade.focus();
        return;
    }
    Sexo = document.frmSoftware.Sexo;
    if (Sexo.selectedIndex == 0) {
        alert("Informe o seu Sexo!");
        Sexo.focus();
        return;
    }
    Cidade = document.frmSoftware.Cidade;
    if (Cidade.value.length == 0) {
        alert("Digite a sua Cidade!");
        Cidade.focus();
        return;
    }
    Estado = document.frmSoftware.Estado;
    if (Estado.selectedIndex == 0) {
        alert("Informe o seu Estado!");
        Estado.focus();
        return;
    }
    Pais = document.frmSoftware.Pais;
    if (Pais.value.length == 0) {
        alert("Digite a sua País!");
        Pais.focus();
        return;
    }
    Pergunta1Parente = document.frmSoftware.Pergunta1Parente;
    Pergunta1Outro = document.frmSoftware.Pergunta1Outro;
    Pergunta1 = document.frmSoftware.Pergunta1;
    if ((Pergunta1[0].checked == false) && (Pergunta1[1].checked == false) && (Pergunta1[2].checked == false) && (Pergunta1[3].checked == false) && (Pergunta1[4].checked == false) && (Pergunta1[5].checked == false)) {
        alert("Responda a pergunta: 'Você é?'");
        Pergunta1[0].focus();
        return;
    }
    if ((Pergunta1[1].checked) && ((Pergunta1Parente.value.length == 0) || (Pergunta1Parente.value == "digite o parentesco!"))) {
        alert("Digite o parentesco!");
        Pergunta1Parente.focus();
        return;
    }
    if ((Pergunta1[5].checked) && ((Pergunta1Outro.value.length == 0) || (Pergunta1Outro.value == "digite a resposta!"))) {
        alert("Digite a resposta!");
        Pergunta1Outro.focus();
        return;
    }
    Pergunta2 = document.frmSoftware.Pergunta2;
    if ((Pergunta2[0].checked == false) && (Pergunta2[1].checked == false) && (Pergunta2[2].checked == false)) {
        alert("Responda a pergunta: 'O software será utilizado para qual finalidade?'");
        Pergunta2[0].focus();
        return;
    }
    Pergunta3 = document.frmSoftware.Pergunta3;
    if ((Pergunta3[0].checked == false) && (Pergunta3[1].checked == false)) {
        alert("Responda a pergunta: 'Gostaria de sugerir outros materiais de apoio ou terapêuticos?'");
        Pergunta3[0].focus();
        return;
    }
    Pergunta4 = document.frmSoftware.Pergunta4;
    if ((Pergunta4[0].checked == false) && (Pergunta4[1].checked == false)) {
        alert("Responda a pergunta: 'Gostaria de receber informações futuras sobre o software?'");
        Pergunta4[0].focus();
        return;
    }
    document.frmSoftware.submit();
}

function bloquearTeclas(e) {
    var key;
    var keychar;
    var reg;
    if (window.event) {
        key = e.keyCode;
    } else if (e.which) {
        key = e.which;
    } else {
        return true;
    }

    keychar = String.fromCharCode(key);
    reg = /\d/;
    return reg.test(keychar);
}

Pergunta1ParenteTemp = "";
Pergunta1OutroTemp = "";

function HabilitaPergunta1(Opcao) {
    Pergunta1 = document.frmSoftware.Pergunta1;
    if (Opcao == 1) {
        if (document.frmSoftware.Pergunta1Outro.value != "digite a resposta!") {
            Pergunta1OutroTemp = document.frmSoftware.Pergunta1Outro.value;
        } else {
            Pergunta1OutroTemp = "";
        }
        document.frmSoftware.Pergunta1Outro.value = "";
        document.frmSoftware.Pergunta1Outro.disabled = true;
        document.frmSoftware.Pergunta1Parente.disabled = false;
        if (Pergunta1ParenteTemp.length == 0) {
            document.frmSoftware.Pergunta1Parente.value = "digite o parentesco!";
        } else {
            document.frmSoftware.Pergunta1Parente.value = Pergunta1ParenteTemp;
        }
    } else if (Opcao == 5) {
        if (document.frmSoftware.Pergunta1Parente.value != "digite o parentesco!") {
            Pergunta1ParenteTemp = document.frmSoftware.Pergunta1Parente.value;
        } else {
            Pergunta1ParenteTemp = "";
        }
        document.frmSoftware.Pergunta1Parente.value = "";
        document.frmSoftware.Pergunta1Parente.disabled = true;
        document.frmSoftware.Pergunta1Outro.disabled = false;
        if (Pergunta1OutroTemp.length == 0) {
            document.frmSoftware.Pergunta1Outro.value = "digite a resposta!";
        } else {
            document.frmSoftware.Pergunta1Outro.value = Pergunta1OutroTemp;
        }
    } else {
        if (document.frmSoftware.Pergunta1Parente.value != "digite o parentesco!") {
            Pergunta1ParenteTemp = document.frmSoftware.Pergunta1Parente.value;
        } else {
            Pergunta1ParenteTemp = "";
        }
        if (document.frmSoftware.Pergunta1Outro.value != "digite a resposta!") {
            Pergunta1OutroTemp = document.frmSoftware.Pergunta1Outro.value;
        } else {
            Pergunta1OutroTemp = "";
        }
        document.frmSoftware.Pergunta1Parente.value = "";
        document.frmSoftware.Pergunta1Outro.value = "";
        document.frmSoftware.Pergunta1Parente.disabled = true;
        document.frmSoftware.Pergunta1Outro.disabled = true;
    }
}

function VerificaOutro(Acao) {
    if (Acao == "in") {
        if (document.frmSoftware.Pergunta1Outro.value == "digite a resposta!") {
            document.frmSoftware.Pergunta1Outro.value = "";
        }
    } else {
        if (document.frmSoftware.Pergunta1Outro.value.length == 0) {
            document.frmSoftware.Pergunta1Outro.value = "digite a resposta!";
        }
    }
}

function VerificaParente(Acao) {
    if (Acao == "in") {
        if (document.frmSoftware.Pergunta1Parente.value == "digite o parentesco!") {
            document.frmSoftware.Pergunta1Parente.value = "";
        }
    } else {
        if (document.frmSoftware.Pergunta1Parente.value.length == 0) {
            document.frmSoftware.Pergunta1Parente.value = "digite o parentesco!";
        }
    }
}
