function urlencode(str) {
str = escape(str);
str = str.replace('+', '%2B');
str = str.replace('%20', '+');
str = str.replace('*', '%2A');
str = str.replace('/', '%2F');
str = str.replace('@', '%40');
return str;
}

function urldecode(str) {
str = str.replace('+', ' ');
str = unescape(str);
return str;
}
function PostarResp() { 
	did = document.getElementById('comentarios');
	if (did.foto.value == "" && CKEDITOR.instances.texto.getData() != "") {
		str_id_forum = did.id_forum.value;
		str_texto = CKEDITOR.instances.texto.getData();
		//str_texto = str_texto.replace(/\n/g, "<br>");
		str_texto = urlencode(str_texto);
		ajaxGet('GET', 'ajax_forum_msg_add.php?id_forum='+str_id_forum+'&texto='+str_texto+'&meu_total='+meu_total+'&total='+mtotal, 'executor');
		CKEDITOR.instances.texto.setData("");
		CKEDITOR.instances.texto.focus();
		return (false);
	} 
	else if (did.foto.value == "" && CKEDITOR.instances.texto.getData() == "") { alert('Digite a mensagem antes cara de bolacha rsrsrs'); CKEDITOR.instances.texto.focus(); return (false); }
}
function Executor() {
cmd_executor = document.getElementById('executor').innerHTML;
eval(cmd_executor);
document.getElementById('executor').innerHTML = "";
tempoexecutor = setTimeout('Executor();', 1000);
}
function NovasMsgs(id_forum, total, meu_total) { 
	ajaxGet('GET', 'ajax_novas_msgs.php?id_forum='+id_forum+'&total='+total+'&meu_total='+meu_total, 'executor');
	tempomsg = setTimeout('NovasMsgs('+id_forum+','+total+','+meu_total+');', 5000);
}
function ExibirMsgs(id_forum, total, sobra, meu_total) {
	mtotal = meu_total;
if (total > vtotal) { vtotal = total; 
	//alert("Total: "+total); alert("Sobra: "+sobra); alert("MeuTotal: "+meu_total); 
	div_resp++;
	//document.getElementById('maisres').innerHTML = '';
	ajaxGet('GET', 'ajax_novas_msgs_exibir.php?id_forum='+id_forum+'&total='+total+'&meu_total='+meu_total+'&div_resp='+div_resp+'&sobra='+sobra, 'div_resp'+div_resp);
	clearTimeout(tempomsg);
	tempomsg = setTimeout('NovasMsgs('+id_forum+','+meu_total+','+meu_total+');', 5000);
}
}
function TopicoEditar(id_forum) {
	document.getElementById('topico_editar').innerHTML = '<img src="img/loading3.gif" align="absmiddle" border="0"> Aguarde...';
	ajaxGet('GET', 'topico_editar.php?id='+id_forum, 'topico_editar');
}
function TopicoDel(id) {
	if (confirm('Deseja realmente deletar este tópico?') == true) {
	window.top.location='forum_del.php?id='+id;
	}
}
function Cadastre_se() {
did = document.getElementById('visor');
msg = '<div id="telapreta"></div>';
msg = msg+'<div id="r_conversa" style="height:290px;margin-top:0px; overflow:none;"><div id="btn_fechar" style="margin-top:-11px; margin-right:-11px;"><a href="javascript:FechaTela(\'r_conversa\');">fechar</a></div><div id="quadrado" style="border:0px;"><span class="veja_todos" style="font-weight:bold; font-size:16px; color:#0066CC;">ENTRE EM SUA CONTA PARA TER ACESSO</span>  <form id="logar" name="logar" method="post" action="login.php" style="margin:0px;">  <div id="separador"><span class="texto_esquerda" style="width:40px;">Login:</span><input name="login" type="text" class="form_texto" id="login" size="25" value="" />  </div>  <span class="texto_esquerda" style="width:40px;">Senha:</span><input name="senha" type="password" class="form_texto" id="senha" size="25" />  <div class="linha"></div>  <div id="separador">  <div class="texto_esquerda" style="width:135px; padding-top:5px;"><a href="javascript:RSenha();">esqueci minha senha!</a></div>    <span><input type="submit" name="cad_popup" id="cad_popup" value="Enviar" /></span>  <div id="rsenha" class="texto_esquerda" style="display:none;width:225px; padding-top:5px; border-top:1px dashed #CCCCCC; margin-top:10px;">  <div class="linha"></div>  Digite seu email para enviarmos sua senha:<br />  <input name="email_senha" type="text" class="form_texto" id="email_senha" size="25" /> <input name="ok2" type="button" value="Enviar" onclick="RSenha_Enviar();" /></div>  <div class="linha"></div>  </div>  </form>    <span class="veja_todos"><a href="cadastro.htm" style="font-weight:bold; font-size:16px; color:#0066CC;">NÃO TEM CONTA?  CLIQUE AQUI E CADASTRE-SE GRATUITAMENTE!</a></span></div></div>'; 
did.innerHTML = msg;
}
function RespostaApagar(id, id_associado) {
	document.getElementById('forum_msg'+id).style.display = 'none';
	ajaxGet('GET', 'ajax_apagar_resposta.php?id='+id+'&id_associado='+id_associado, '');
}
function RSenha_Enviar() {
	did = document.getElementById('email_senha').value;
	if (did) {
		document.getElementById('rsenha').innerHTML = '<img src="img/loading3.gif" align="absmiddle" border="0"> Aguarde...';
		ajaxGet('GET', 'ajax_rsenha.php?email='+did, 'rsenha');
		}
		else { alert('Você esqueceu o email cabeça :)'); document.getElementById('email_senha').focus(); }
	}
function RSenha() {
	did = document.getElementById('rsenha');
	if (did.style.display == 'none') { 
	document.getElementById('rsenha').style.display = '';
	document.getElementById('rsenha').innerHTML = '<div class="linha"></div>Digite seu email para enviarmos sua senha:<br /><input name="email_senha" type="text" class="form_texto" id="email_senha" size="25" /> <input name="ok2" type="button" value="Enviar" onclick="RSenha_Enviar();" /></div><div class="linha"></div>'
	document.getElementById('email_senha').focus(); }
	else { document.getElementById('rsenha').style.display = 'none'; }
}

function Enviando() { document.getElementById('enviando_dados').style.display = ''; }
function rolagem_vertical(id,num){
var el = document.getElementById(id);
var nu = parseInt(num);
i = setInterval(function() {  el.scrollTop += parseInt(nu);   },120);
}
function rolagem_horizontal(id,num){
var el = document.getElementById(id);
var nu = parseInt(num);
i = setInterval(function() {  el.scrollLeft += parseInt(nu);   },120);
}
function FechaTela(did) {
document.getElementById('telapreta').style.display = 'none';
document.getElementById(did).style.display = 'none';
}
function Localizar(tabela, did, palavra) {
	ajaxGet('GET', 'ajax_busca.php?tabela='+tabela+'&palavra='+palavra+'&did='+did, did);
}
CodDown = '321SD856';
function Download(id, site) {
window.open('http://'+site);
if (CodDown == '321SD856') {
ajaxGet('GET', 'ajax_download.php?id='+id, '');
CodDown = 0;
}
}
function NLista() {
	divID = document.getElementById('categorias_lista');
	if (divID.style.display == 'none') { divID.style.display = ''; }
	else { divID.style.display = 'none'; }
}
function VLogin() {
login = document.getElementById('cadastro').login.value;
if (login == '') { alert('Digite o login antes de verificar se ele já existe.'); document.getElementById('cadastro').login.focus(); }
else {
divID = document.getElementById('div_vr');
divID.innerHTML = '<img src="img/Spin.gif" border="0"> Checando...';
ajaxGet('GET', 'ajax_vlogin.php?login='+login, 'div_vr');
}
}
var tam=12;
function MFonte(tipo, divID) {
	if (tipo=="mais") {
		if (tam < 26) {
			tam+=2;
			}
		}
		else {
			if (tam > 14) {
			tam-=2;
		}
	} 
	document.getElementById(divID).style.fontSize=tam+'px' ;
}
function Comentar(associado) { 
divID = document.getElementById('add_comentario');
if (associado) {
if (divID.style.display == 'none') { divID.style.display = ''; } 
else { divID.style.display = 'none';  }
}
else { divID.style.display = ''; divID.innerHTML = '<div style="font-size:12px; padding:5px; margin-bottom:10px;border: 1px solid #666666; background-color:#C7ECFE;">Você precisar ser cadastrado(a) e estar logado(a). <a href="cadastro.php"><b>Clique aqui</b></a> para se cadastrar.</div>'; }
}