/* ----------------------------- funcções de cálculo do shopping -------------------------------------- */
function calculaItem(target) {
	var xmlHttp=GetXmlHttpObject();
	var resposta = "";
	var produto_id = document.getElementById('produto_id').value;
	
	/* preço id */
	if(document.getElementById('num_precos').value == 1) {
		var preco_id = document.getElementById('preco_id').value;
	} else {
		for(i=0; i<document.form_pedido.preco_id.length; i++ ) {
			if(document.form_pedido.preco_id[i].checked == true) { var preco_id = document.form_pedido.preco_id[i].value; }
		}
	}
	
	/* quantidade */
	var qtd = document.getElementById('qtd').options[document.getElementById('qtd').selectedIndex].value;
	
	/* adicionais - grupos */
	var adic_grupo = "";
	var adic_grupo_lista = document.getElementById('adic_grupo_lista').value;
	var num_grupos = adic_grupo_lista.split(',');
	for(x=0;x<num_grupos.length;x++) {
		var grupo_nome = 'adic_grupo_'+num_grupos[x];
		var grupoObj = document.forms['form_pedido'].elements[grupo_nome];

		for(i=0; i<grupoObj.length; i++) {
			if(grupoObj[i].checked == true) { var adic_grupo = adic_grupo + "&" + grupo_nome + "=" + grupoObj[i].value; }
		}
	}
	
	/* adicionais - itens */
	var adic_itens = "";
	var adic_itens_lista = document.getElementById('adic_itens_lista').value;
	var num_itens = adic_itens_lista.split(',');
	for(x=0;x<num_itens.length;x++) {
		var item_nome = 'adic_item_'+num_itens[x];
		var itemObj = document.forms['form_pedido'].elements[item_nome];
		if(itemObj.checked == true) { var adic_itens = adic_itens + "&" + item_nome + "=1"; }
	}
	
	if(target == 1) {
		/* monta a string, manda pro o PHP e prega o resultado no HTML DOM */
		var url = "shopping_pedido_calcula.php?produto_id="+produto_id+"&calcform=1";
		var url = url + "&preco_id="+preco_id;
		var url = url + "&qtd="+qtd;
		var url = url + adic_grupo;
		var url = url + adic_itens;
		
		var retorno = url;
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		
		var resposta = xmlHttp.responseText;
		resposta = resposta.replace(/\+/g," ");
		resposta = unescape(resposta);
		document.getElementById('container_valor').innerHTML = resposta;
	} else {
		/* monta a string para escrever na tabela temporária, fecha a janela, etc */
		var pedido_codigo = document.getElementById('pedido_codigo').value;
		var url = "shopping_pedido_insere.php?produto_id="+produto_id+"&pedido_codigo="+pedido_codigo;
		var url = url + "&preco_id="+preco_id;
		var url = url + "&qtd="+qtd;
		var url = url + "&adic_grupo_lista="+adic_grupo_lista;
		var url = url + adic_grupo;
		var url = url + "&adic_itens_lista="+adic_itens_lista;
		var url = url + adic_itens;
		
		var retorno = url;
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		
		var resposta = xmlHttp.responseText;
		top.document.getElementById('meuPedido').innerHTML = resposta;

		hidePopUp();
	}
}


/* banners -------------------------------------------------------------------------------------------- */
function bannerLoad(t) {
	var xmlHttp=GetXmlHttpObject();

	var url="includes/ajax_random_banner.php?bannerlist="+t;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	var thisBanner = resposta.split(';');
	var tempo = (thisBanner[2] * 1000);
	
	bannerShow(thisBanner[1]);
	/* setTimeout('bannerLoad('+thisBanner[0]+')', tempo); */
	/* alert(resposta); */
	setTimeout("bannerLoad('"+thisBanner[3]+"')", tempo);
}

function bannerShow(b) {
	var c = " classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' ";
	var p = " allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' ";
	
	var f = "<object "+c+" width='255' height='261' id='"+b+"' align='middle'>";
	var f = f + "<param name='allowScriptAccess' value='sameDomain'>";
	var f = f + "<param name='movie' value='banners/home_flash/"+b+"'>";
	var f = f + "<param name='wmode' value='transparent' />";
	var f = f + "<param name='menu' value='false'>";
	var f = f + "<param name='quality' value='high'>";
	var f = f + "<param name='bgcolor' value='#ffffff'>";
	var f = f + "<param name='loop' value='false'>";
	var f = f + "<embed src='banners/home_flash/"+b+"' menu='false' loop='false' quality='high' bgcolor='#ffffff' width='255' wmode='transparent' height='261' name='"+b+"' align='middle' "+p+" >";
	var f = f + "</object>";

	document.getElementById('FlashBanner').innerHTML = f;
}


/* input masks ---------------------------------------------------------------------------------------- */
function actField(campo) {
	document.getElementById(campo).value = "";
	document.getElementById(campo).style.color = "#000000";
}

function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function mascaraMoeda(v){
    v = v.replace(/\D/g,"");
	if(v.length > 2) { v = v.substring(0,v.length-2)+","+v.substring((v.length-2),v.lenght); }
	if(v.length > 6) { v = v.substring(0,v.length-6)+"."+v.substring((v.length-6),v.lenght); }
	if(v.length > 10) { v = v.substring(0,v.length-10)+"."+v.substring((v.length-10),v.lenght); }
	if(v.length > 14) { v = v.substring(0,v.length-14)+"."+v.substring((v.length-14),v.lenght); }
    return v
}

function mascaraMilhar(v){
    v = v.replace(/\D/g,"");
	if(v.length > 3) { v = v.substring(0,v.length-3)+"."+v.substring((v.length-3),v.lenght); }
	if(v.length > 7) { v = v.substring(0,v.length-7)+"."+v.substring((v.length-7),v.lenght); }
	if(v.length > 11) { v = v.substring(0,v.length-11)+"."+v.substring((v.length-11),v.lenght); }
    return v
}

function mascaraTelefone(v){
    v = v.replace(/\D/g,"");
	if(v.length > 4) { v = v.substring(0,v.length-4)+"-"+v.substring((v.length-4),v.lenght); }
    return v
}

function mascaraCep(v){
    v = v.replace(/\D/g,"");
	if(v.length > 3) { v = v.substring(0,v.length-3)+"-"+v.substring((v.length-3),v.lenght); }
    return v
}

function mascaraCepf(v){
    v = v.replace(/\D/g,"");
	if(v.length > 2) { v = v.substring(0,v.length-2)+"-"+v.substring((v.length-2),v.lenght); }
	if(v.length > 6) { v = v.substring(0,v.length-6)+"."+v.substring((v.length-6),v.lenght); }
    if(v.length > 10) { v = v.substring(0,v.length-10)+"."+v.substring((v.length-10),v.lenght); }
	return v
}


function maxLength(textAreaField, limit) {
	var ta = document.getElementById(textAreaField);
	if (ta.value.length >= limit) { ta.value = ta.value.substring(0, limit-1); }
}

function contaLetrinha(textAreaField, limit) {
	var ta = document.getElementById(textAreaField);
	if (ta.value.length >= limit) { ta.value = ta.value.substring(0, limit-1); }
}

function maxLengthConta(textAreaField, limit) {
	var ta = document.getElementById(textAreaField);
	if (ta.value.length >= limit) { ta.value = ta.value.substring(0, limit-1); }
	document.getElementById('contatexto').innerHTML = 500 - ta.value.length;
}

function limpa(block_id) {
	document.getElementById(block_id).value = "";
	document.getElementById(block_id).style.background = "#ffffff";
	document.getElementById(block_id).style.color = "#000000";
}


/* form validation ------------------------------------------------------------------------------------ */
function validaGaragem() {
	var erros = 0;
	var resposta = "Não é possível enviar seu anúncio.\n\n";
	if(document.getElementById('texto').value.length < 5) { erros++; resposta = resposta+"• Descreva o produto.\n"; }
	if(document.getElementById('nome').value.length < 5) { erros++; resposta = resposta+"• Informe o seu nome.\n"; }
	if(document.getElementById('fone').value.length < 5) { erros++; resposta = resposta+"• Informe seu telefone.\n"; }
	if(document.getElementById('email').value.length < 5) { erros++; resposta = resposta+"• Informe um e-mail para contato.\n"; }
	
	var valor = document.getElementById('valor').value;
	if(valor != parseInt(valor)) { 
		erros++; resposta = resposta+"• Use apenas números para o preço.\nEm caso de trocas, doações ou pedidos de emprego, coloque o valor de R$ 1\n"; 
	} else { 
		if(valor > 150) { 
			erros++; resposta = resposta+"• O preço máximo para o produto é R$ 150,00\n"; 
		} 
	}

	if(erros == 0) { return true; } else { alert(resposta+"\n\n"); return false; }
}

function validaPromocaoNova(promocao_id) {
	var erros = 0;
	var erroChars = 0;
	var resposta = "Não é possível enviar sua inscrição.\n\n";
	var re = /^[\w ]+$/;
    /* validation fails if the input doesn't match our regular expression */
	
	if(document.getElementById('nome').value.length < 5) { erros++; resposta = resposta+"• Informe o seu nome (pelo menos 5 letras).\n"; }
	if(!re.test(document.getElementById('nome').value)) { erros++; erroChars++; }
	if(document.getElementById('fone').value.length < 8) { erros++; resposta = resposta+"• Informe seu telefone.\n"; }
	if(!re.test(document.getElementById('fone').value)) { erros++; erroChars++; }
	if(document.getElementById('rg').value.length < 8) { erros++; resposta = resposta+"• Informe um número válido de RG.\n"; }
	if(!re.test(document.getElementById('rg').value)) { erros++; erroChars++; }
	
	if(erroChars > 0) { resposta = resposta+"• Use somente letras, números e espaços.\n"; }
	
	if(erros == 0) { return true; } else { alert(resposta+"\n\n"); return false; }
}

function validaPromocaoNova(promocao_id) {
	var erros = 0;
	var erroChars = 0;
	var resposta = "Não é possível enviar sua inscrição.\n\n";
	var re = /^[\w ]+$/;
 	
	if(document.getElementById('cNome').value == "digite aqui seu nome") { erros++; resposta = resposta+"• Preencha corretamente seu nome.\n"; }
	if(document.getElementById('cNome').value.length < 5) { erros++; resposta = resposta+"• Informe o seu nome (pelo menos 5 letras).\n"; }
	if(!re.test(document.getElementById('cNome').value)) { erros++; erroChars++; }

	if(erroChars > 0) { resposta = resposta+"• Use somente letras no seu nome.\n"; }
	
	if(erros == 0) { return true; } else { alert(resposta+"\n\n"); return false; }
}


/* noticias - colaboracao ----------------------------------------------------------------------------- */
function upFoto(position) {
	var xmlHttp=GetXmlHttpObject();
	
	var url="includes/ajax_colaboracao_fotos.php?p="+position;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	
	document.getElementById('popup400px').style.visibility = "visible";
	document.getElementById('popup400px').innerHTML = xmlHttp.responseText;
}

function upFotoOK(position,file_name) {
	var box = "box_"+position;
	top.document.getElementById(position).value = file_name;
	top.document.getElementById(box).innerHTML = "<img src='fotos/colaboracao/"+file_name+"' border='0' style='max-width: 200px; max-height: 200px;'>";
	top.document.getElementById('popup400px').style.visibility = "hidden";
}

function closeMe(popup_name) {
	top.document.getElementById('popup400px').style.visibility = "hidden";
}

function validaColaboracao() {
	var erros = 0;
	var resposta = "<br>";
	if(document.getElementById('texto').value.length < 50) { erros++; resposta = resposta+"• Envie um texto com pelo menos 50 caracteres para que seja um tópico no fórum.<br>"; }
	
	if(erros == 0) { 
		return true; 
	} else { 
		var httpResp = "<h1 style='margin-top: 20px;'>Não é possível enviar sua postagem.</h1>";
		var httpResp = httpResp + "<div style='width: 250px; display: block; float: left;'><img src='img/alert140px.png' border='0' style='margin-top: 20px;'></div>";
		var httpResp = httpResp + "<div style='width: 450px; display: block; float: left; font-family: Tahoma, Arial; font-size: 11pt; line-height: 170%; text-align: left;'>";
		var httpResp = httpResp + resposta;
		var httpResp = httpResp + "<br><input type='button' value='Fechar' id='btn_geral_blue' onClick='javascript:hidePopUp(\"hideshow\");'><br><br><br>";
		var httpResp = httpResp + "</div>";
		var httpResp = httpResp + "<br clear='all'>";
		document.getElementById('hideshow').style.visibility = "visible";
		document.getElementById('popup750px').innerHTML = httpResp;
		return false; 
	}
}

function validaColaboracaoNoticia() {
	var erros = 0;
	var resposta = "<br>";
	if(document.getElementById('texto').value.length < 50) { erros++; resposta = resposta+"• O texto da notícia deve ter pelo menos 50 caracteres.<br>"; }
	
	if(erros == 0) { 
		return true; 
	} else { 
		var httpResp = "<h1 style='margin-top: 20px;'>Não é possível enviar sua notícia.</h1>";
		var httpResp = httpResp + "<div style='width: 250px; display: block; float: left;'><img src='img/alert140px.png' border='0' style='margin-top: 20px;'></div>";
		var httpResp = httpResp + "<div style='width: 450px; display: block; float: left; font-family: Tahoma, Arial; font-size: 11pt; line-height: 170%; text-align: left;'>";
		var httpResp = httpResp + resposta;
		var httpResp = httpResp + "<br><input type='button' value='Fechar' id='btn_geral_blue' onClick='javascript:hidePopUp(\"hideshow\");'><br><br><br>";
		var httpResp = httpResp + "</div>";
		var httpResp = httpResp + "<br clear='all'>";
		document.getElementById('hideshow').style.visibility = "visible";
		document.getElementById('popup750px').innerHTML = httpResp;
		return false; 
	}
}

/* 
currently off ?
function showBallon (balloon_id) {
	document.getElementById('balao200px').style.visibility = "visible";
}

function hideBallon (balloon_id) {
	document.getElementById('balao200px').style.visibility = "hidden";
}

function zoom(pag) {
	var xmlHttp=GetXmlHttpObject();
	var newimg = "<img src='pages/"+pag+".jpg' data-magnifysrc='zoom/"+pag+".jpg' id='myimage' border='0'>"; 
	document.getElementById("fullpage").innerHTML = newimg; 
}

function popup_comments_feedback(id) {
	var xmlHttp=GetXmlHttpObject();
	var url="popup_comments_feedback.php?id="+id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	document.getElementById('popup_comments_feedback').innerHTML = xmlHttp.responseText;
	document.getElementById('popup_comments_feedback').style.visibility = "visible";
}
*/

/* obituario - livro de recados ----------------------------------------------------------------------- */
function popup_obituario(block_id, obit_id) {
	var xmlHttp=GetXmlHttpObject();

	var url="guestbook_obit.php?id="+obit_id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	document.getElementById('hideshow').style.visibility = "visible";
	document.getElementById(block_id).innerHTML = xmlHttp.responseText;
	document.getElementById(block_id).style.visibility = "visible";
}

function popup_temporada(block_id, imovel_id) {
	var xmlHttp=GetXmlHttpObject();

	var url="temporada_detalhes.php?id="+imovel_id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	document.getElementById(block_id).innerHTML = xmlHttp.responseText;
	document.getElementById(block_id).style.visibility = "visible";
}

function thumb_zoom(photo) { document.getElementById('photo_frame').innerHTML = "<img src='"+photo+"' border='0' width='620'>"; }
function thumb_autos(photo) { document.getElementById('autos_detalhe_zoom').innerHTML = "<img src='"+photo+"' border='0'>"; }
function thumb_imov(photo) { document.getElementById('imoveis_detalhe_zoom').innerHTML = "<img src='"+photo+"' border='0'>"; }

function showPopUp(div_block, php_script, id) {
	var xmlHttp=GetXmlHttpObject();
	
	var url="includes/"+php_script+".php?id="+id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	document.getElementById(div_block).innerHTML = resposta;
	document.getElementById('hideshow').style.visibility = "visible";
}

function showPopUpShop(div_block, id) {
	var xmlHttp=GetXmlHttpObject();
	
	var url="shopping_pedido.php?produto_id="+id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	document.getElementById(div_block).innerHTML = resposta;
	document.getElementById('hideshow').style.visibility = "visible";
}

function showPopUpObituario(div_block, php_script, id) {
	var xmlHttp=GetXmlHttpObject();
	
	var url=php_script+".php?id="+id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	top.document.getElementById(div_block).innerHTML = resposta;
	top.document.getElementById('hideshow').style.visibility = "visible";
}

function albumPopUp(div_block, noticia_id, foto_id) {
	var xmlHttp=GetXmlHttpObject();
	
	var url="includes/popupAlbum.php?noticia_id="+noticia_id+"&foto_id="+foto_id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	document.getElementById(div_block).innerHTML = resposta;	
	document.getElementById('hideshow').style.visibility = "visible";
}

function noticiaColaborar(php_script, noticia_id, account_id) {
	var xmlHttp=GetXmlHttpObject();
	
	var url="includes/popup_noticia_colaborar.php?popup_source="+php_script+"&noticia_id="+noticia_id+"&account_id="+account_id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	document.getElementById('popup750px').innerHTML = resposta;
	document.getElementById('hideshow').style.visibility = "visible";
}

function popupPerfil(account_id) {
	var xmlHttp=GetXmlHttpObject();
	
	var url="includes/popup_profile.php?account_id="+account_id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	document.getElementById('popup750px').innerHTML = resposta;
	document.getElementById('hideshow').style.visibility = "visible";
}

/*
function hidePopUp(number) {
	var popup_to_close = "hideshow" + number
	document.getElementById(popup_to_close).style.visibility = "hidden";
}
*/

function hidePopUp() {
	document.getElementById('hideshow').style.visibility = "hidden";
}

function closePopUp() {
	document.getElementById('hideshow').style.visibility = "hidden";
}

function anuncie_pag(tipo, id) {
	var xmlHttp=GetXmlHttpObject();
	
	var url = "includes/ajax_anuncie_jornal.php?tipo="+tipo+"&id="+id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	document.getElementById('imagem').innerHTML = resposta;	
}


/* --------------------------------------------------- notícias - comentários dos comentários --------------------------------- */
function mmenu(img_name, img_src) {
   document[img_name].src = img_src;
}

function noticiaComentar(c_id, n_id, a_id, new_level, c_base, mostra_form) {
	var retorno = "<table border='0' cellspacing='0' id='tbl_write_comment'>";
	if(mostra_form == 1) {
		if(a_id == 0) {
			var retorno = retorno + "<tr><th>seu nome</td><td colspan='2'><input type='text' id='comentar_nome_"+c_id+"' class='field'></td></tr>";
			var retorno = retorno + "<tr><th>cidade</th><td colspan='2'><input type='text' id='comentar_cid_"+c_id+"' class='field'></td></tr>";
		} else {
			/* libera para comentar*/
			var xmlHttp=GetXmlHttpObject();
			var url="includes/ajax_getAccountData.php?account_id="+a_id;
			xmlHttp.open("GET",url,false);
			xmlHttp.send(null);
			var myAccount = xmlHttp.responseText.split('|');
			
			var retorno = retorno + "<tr>";
			var retorno = retorno + "<th style='background-color: #eef; padding: 4px;'><img src='fotos/profile/thumb/"+myAccount[2]+"' width='35'></th>";
			var retorno = retorno + "<td style='background-color: #eef; padding: 4px;' colspan='2'><span style='font-weight: bold; color: #007;'>"+myAccount[0]+"</span><br>"+myAccount[1]+"</td>";
			var retorno = retorno + "</tr>";
		}
		
		var retorno = retorno + "<tr>";
		var retorno = retorno + "<th>comentário</th>";
		var retorno = retorno + "<td><textarea cols='50' rows='3' id='comentario_"+c_id+"' class='tArea''></textarea></td>";
		var retorno = retorno + "<td><input type='button' onClick='Javascript:noticiaComentar_append("+c_id+", "+n_id+", "+a_id+", "+new_level+", "+c_base+");' value='enviar' class='botao'></td>";
		var retorno = retorno + "</tr>";
	} else {
		var retorno = retorno + "<tr>";
		var retorno = retorno + "<td><div style='text-align: center; font-weight: bold; font-size: 12pt; color: #3327af; margin-left: 20px;'>Para comentar esta notícia você deve estar logado.";
		var retorno = retorno + "<br><span style='font-weight:normal;'><a href='index.php?page=perfil'>Faça login</a> ou <a href='index.php?page=perfil'>cadastre-se</a></span></div></td>";
		var retorno = retorno + "</tr>";
	}
	var retorno = retorno + "</table>";
	
	document.getElementById('comentar_comentario_'+c_id).style.display = 'block';
	document.getElementById('comentar_comentario_'+c_id).innerHTML = retorno;
}

function noticiaComentar_append(c_id, n_id, a_id, new_level, c_base) {
	var xmlHttp=GetXmlHttpObject();

	var texto = document.getElementById('comentario_'+c_id).value;
	if(a_id == 0) {
		var nome = document.getElementById('comentar_nome_'+c_id).value;
		var cid = document.getElementById('comentar_cid_'+c_id).value;
	} else {
		var nome = " ";
		var cid = " ";
	}
	
	// alert(encodeURIComponent(texto));
	
	var url="includes/ajax_noticias_comentar.php?comentario_id="+c_id+"&texto="+encodeURIComponent(texto)+"&nome="+nome+"&cidade="+cid+"&account_id="+a_id+"&new_level="+new_level+"&noticia_id="+n_id+"&c_base="+c_base;
	
	
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	if(c_base == 0) { 
		var div_resposta = 'comentario_principal'; 
		var resposta = "<div style='text-align: center; font: bold 12pt Tahoma; color: #007; padding: 30px 10px 30px 10px; border: 1px solid #00c;'>Seu comentário foi enviado.</div>";
	} else { 
		var div_resposta = 'comentar_comentario_'+c_id; 
		var resposta = "<div style='text-align: center; font: bold 12pt Tahoma; color: #007; padding: 30px 10px 30px 10px;'>Seu comentário foi enviado.</div>";
	}
	document.getElementById(div_resposta).innerHTML = resposta;
}


/* --------------------------------------------------- notícias - complementar------------------------------------------------- */
function Complementar(noticia_id) {
	var retorno = "<table border='0'>";
	var retorno = retorno + "<tr><td valign='top' align='right'>informações</td><td><textarea cols='50' rows='3' id='complementar_texto' style='width: 400px; height: 60px; font: 8pt Tahoma;'></textarea></td></tr>";
	var retorno = retorno + "<tr><td valign='top' align='right'>seu nome</td><td><input type='text' name='3' id='complementar_nome' style='width: 400px; font: 8pt Tahoma;'></td></tr>";
	var retorno = retorno + "<tr><td colspan='2' align='right'><input type='button' onClick='Javascript: Complementar_append("+noticia_id+");' value='enviar' class='botao'></td></tr>";
	var retorno = retorno + "</table>";

	document.getElementById('div_complementar').style.visibility = 'visible';
	document.getElementById('div_complementar').style.background = '#eee';
	document.getElementById('div_complementar').innerHTML = retorno;
}

function Complementar_append(noticia_id) {
	var xmlHttp=GetXmlHttpObject();

	var texto = document.getElementById('complementar_texto').value;
	var nome = document.getElementById('complementar_nome').value;
	var url="includes/ajax_noticia_complementar.php?noticia_id="+noticia_id+"&texto="+encodeURIComponent(texto)+"&nome="+nome;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = "<div style='text-align: center; font: bold 10pt Tahoma; color: #007; padding: 20px;'>Suas informações foram enviadas.</div>";
	document.getElementById('div_complementar').innerHTML = resposta;
}

/* -------------------------------------------- notícias - enviar colaboração ------------------------------------------------- */
function sendColab(modulo, noticia_id, account_id) {
	var xmlHttp=GetXmlHttpObject();

	var texto = document.getElementById('texto').value;
	var url="includes/ajax_noticias_colab.php?modulo="+modulo+"&noticia_id="+noticia_id+"&account_id="+account_id+"&texto="+encodeURIComponent(texto);
	
	if(account_id == 0) {
		var nome = document.getElementById('nome').value;
		var cid = document.getElementById('cid').value;
		var url = url + "&nome="+nome+"&cid="+cid;
	} else 
	
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var retorno = xmlHttp.responseText;
	retorno = retorno.replace(/\+/g," ");
    retorno = unescape(retorno);
	
	document.getElementById('tbl_popup_noticias').innerHTML = retorno;
}

/* -------------------------------------------- notícias - denunciar ---------------------------------------------------------- */
function comentarioDenunciar(comentario_id, account_id, nivel, local, local_id) {
	var xmlHttp=GetXmlHttpObject();
	
	var url="includes/popup_comentario_denunciar.php?&comentario_id="+comentario_id+"&account_id="+account_id+"&nivel="+nivel+"&local="+local+"&local_id="+local_id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	document.getElementById('popup750px').innerHTML = resposta;
	document.getElementById('hideshow').style.visibility = "visible";
}

/* -------------------------------------------- notícias - likes & dislikes --------------------------------------------------- */
function concordo(source, comentario_id, account_id) {
	var xmlHttp=GetXmlHttpObject();
	
	/* sources: 1 = notícia comentário; 2 = fórum tópico; 3 = fórum comentário */
	// if(source == 1) {
		var url="includes/ajax_concordo.php?source="+source+"&comentario_id="+comentario_id+"&account_id="+account_id;
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		
		var retorno = xmlHttp.responseText;
		retorno = retorno.replace(/\+/g," ");
		retorno = unescape(retorno);
	
		document.getElementById('lks_'+comentario_id).innerHTML = retorno;
	// }
	
}

function discordo(source, comentario_id, account_id) {
	var xmlHttp=GetXmlHttpObject();
	
	/* sources: 1 = notícia comentário; 2 = fórum tópico; 3 = fórum comentário */
	// if(source == 1) {
		var url="includes/ajax_discordo.php?source="+source+"&comentario_id="+comentario_id+"&account_id="+account_id;
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		
		var retorno = xmlHttp.responseText;
		retorno = retorno.replace(/\+/g," ");
		retorno = unescape(retorno);
	
		document.getElementById('lks_'+comentario_id).innerHTML = retorno;
	// }
}

/* --------------------------------------------------- artigos ---------------------------------------------------------------- */
function comentar(origem, referencia_id, c_base) {
	/* origem: 1 = notícias, 2 = recados, 3 = artigos colaboradores ====== confirmar se isto funciona!!! ========== */
	
	var resposta = "";
	resposta += "<table border='0' cellpadding='0' cellspacing='0' id='nada' class='nada'>";
	resposta += "<tr><th valign='top'>comentário</th><td><textarea name='comentario' id='comentario_texto_"+c_base+"' class='campo' style='height: 60px;'></textarea></td></tr>";
	resposta += "<tr><th valign='top'>seu nome</th><td><input type='text' name='nome' id='comentario_nome_"+c_base+"' class='campo'></td></tr>";
	resposta += "<tr><th>&nbsp;</th><td><input type='button' value='enviar' class='botao' onClick='Javascript:enviaComentario(\"colaboradores\", \"comentar_"+c_base+"\", "+referencia_id+", "+c_base+");'></td></tr>";
	resposta += "</table>";
	
	document.getElementById('comentar_'+c_base).style.display = "block";
	document.getElementById('comentar_'+c_base).innerHTML = resposta;
}

function enviaComentario(tipo, bloco, referencia_id, comentario_base ) {
	var xmlHttp=GetXmlHttpObject();

	if(tipo == "colaboradores") { var url = "includes/colaboradores_artigos_comentarios_insert.php"; }
	
	var texto = document.getElementById('comentario_texto_'+comentario_base).value;
	var nome = document.getElementById('comentario_nome_'+comentario_base).value;
	var url = url+"?referencia_id="+referencia_id+"&comentario_base="+comentario_base+"&texto="+encodeURIComponent(texto)+"&nome="+nome;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = "<div style='text-align: center; font: bold 10pt Tahoma; color: #007; padding: 20px;'>Seu comentário foi enviado!</div>";
	/* var resposta = xmlHttp.responseText; */
	document.getElementById(bloco).innerHTML = resposta;
}

/* --------------------------------------------------- agenda ----------------------------------------------------------- */
function agendaComentar(agenda_id) {
	var xmlHttp=GetXmlHttpObject();

	var uid = document.getElementById('myId').value;
	var msg = document.getElementById('mensagem_'+agenda_id).value;
	
	var url="includes/ajax_agenda_comentar.php?account_id="+uid+"&agenda_id="+agenda_id+"&mensagem="+encodeURIComponent(msg);
	
	if(uid == 0) { 
		var nome = document.getElementById('nome_'+agenda_id).value;
		var url = url + "&nome=" + nome; 
	}
	
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = "<div style='text-align: center; font: bold 11pt Tahoma; color: #fff; padding: 60px 0px 50px 60px;'>Seu comentário foi enviado.</div>";
	document.getElementById('agenda_comentar_'+agenda_id).innerHTML = resposta;
}

function fieldBlack(field, dValue) {
	if(document.getElementById(field).value == dValue) { document.getElementById(field).value = ""; }
	document.getElementById(field).style.color = "#000000";
}


/* --------------------------------------------------- fale conosco ----------------------------------------------------------- */
function enviarFaleConosco() {
	var xmlHttp=GetXmlHttpObject();

	var texto = document.getElementById('texto').value;
	var nome = document.getElementById('nome').value;
	var cid = document.getElementById('cid').value;
	var contato = document.getElementById('contato').value;
	var url="includes/ajax_faleconosco_newMessage.php?texto="+encodeURIComponent(texto)+"&nome="+nome+"&cid="+cid+"&contato="+contato;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	document.getElementById('faleconosco_form').innerHTML = "<div style='padding: 30px; font-weight: bold; font-size: 11pt; color: #00c; text-align: center;'>Sua mensagem foi enviada</div>";
}	


/* --------------------------------------------------- recados ---------------------------------------------------------------- */
function enviarRecado(a) {
	var xmlHttp=GetXmlHttpObject();

	var texto = document.getElementById('input_forum_texto').value;
	texto = texto.replace('\n','<br>');
	texto = texto.replace('\r','<br>');
	if(a == 0) {
		var nome = document.getElementById('input_forum_nome').value;
		var cid = document.getElementById('input_forum_cid').value;
		var url="includes/ajax_forum_newTopic.php?texto="+encodeURIComponent(texto)+"&nome="+nome+"&cid="+cid;
	} else {
		var url="includes/ajax_forum_newTopic.php?account_id="+a+"&texto="+encodeURIComponent(texto);
	}
		
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	/* var resposta = xmlHttp.responseText; */
	/* document.getElementById('recado_form').innerHTML = resposta; */
	document.getElementById('recado_form').innerHTML = "<div style='font-size: 11pt; font-weight: bold; color: #00c; padding: 20px;'>Seu recado foi enviado.</div>";
}	

function recadoComentar(c_id, t_id, a_id, new_level, c_base) {
	var retorno = "<table border='0' cellspacing='0' id='tbl_write_comment' style='background-color: #bbb; width: 99%; padding-bottom: 15px;'>";
	
	if(a_id == 0) {
		var retorno = retorno + "<tr><td colspan='4' class='novo_login' style='text-align: center; padding-top: 15px;'><a href='index.php?page=perfil'>Registre-se</a> para postar e comentar com seu nick e foto.</td></tr>";
		var retorno = retorno + "<tr><th>seu nome</td><td colspan='2'><input type='text' id='comentar_nome_"+c_id+"' class='field' style='width:410px'></td></tr>";
		var retorno = retorno + "<tr><th>cidade</th><td colspan='2'><input type='text' id='comentar_cid_"+c_id+"' class='field' style='width:410px'></td></tr>";
	} else {
		var xmlHttp=GetXmlHttpObject();
		var url="includes/ajax_getAccountData.php?account_id="+a_id;
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		var myAccount = xmlHttp.responseText.split('|');
		
		var retorno = retorno + "<tr>";
		var retorno = retorno + "<th style='background-color: #ee7; padding: 4px;'><img src='fotos/profile/thumb/"+myAccount[2]+"' width='35'></th>";
		var retorno = retorno + "<td style='background-color: #ee7; padding: 4px;' colspan='2'><span style='font-weight: bold; color: #007;'>"+myAccount[0]+"</span><br>"+myAccount[1]+"</td>";
		var retorno = retorno + "</tr>";
	}
	
	var retorno = retorno + "<tr>";
	var retorno = retorno + "<th>comentário</th>";
	var retorno = retorno + "<td width='410'><textarea cols='50' rows='3' id='comentario_"+c_id+"' class='tArea' style='width:410px;''></textarea></td>";
	var retorno = retorno + "<td align='left'><input type='button' onClick='Javascript:recadoComentar_append("+c_id+", "+t_id+", "+a_id+", "+new_level+", "+c_base+");' value='enviar' class='botao'></td>";
	var retorno = retorno + "</tr>";
	
	var retorno = retorno + "</table>";
	
	if(c_base == 0) {
		document.getElementById('recado_comentar_topico_'+t_id).style.display = 'block';
		document.getElementById('recado_comentar_topico_'+t_id).innerHTML = retorno;
	} else {
		document.getElementById('recado_comentar_comentario_'+c_id).style.display = 'block';
		document.getElementById('recado_comentar_comentario_'+c_id).innerHTML = retorno;
	}	
}

function recadoComentar_append(c_id, t_id, a_id, new_level, c_base) {
	var xmlHttp=GetXmlHttpObject();

	var texto = document.getElementById('comentario_'+c_id).value;
	texto = texto.replace('\n','<br>');
	texto = texto.replace('\r','<br>');
	if(a_id == 0) {
		var nome = document.getElementById('comentar_nome_'+c_id).value;
		var cid = document.getElementById('comentar_cid_'+c_id).value;
	} else {
		var nome = " ";
		var cid = " ";
	}
	var url="includes/ajax_recados_comentar.php?comentario_id="+c_id+"&texto="+encodeURIComponent(texto)+"&nome="+nome+"&cidade="+cid+"&account_id="+a_id+"&new_level="+new_level+"&topico_id="+t_id+"&c_base="+c_base;
	
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = "<div style='text-align: center; font: bold 12pt Tahoma; color: #007; padding: 30px 10px 20px 10px;'>Seu comentário foi enviado.</div><div style='text-align: center; font: bold 9pt Tahoma; color: #007; padding: 0px 10px 30px 10px;'>Poderá demorar um pouco para ser aprovado.</div> ";
	if(c_base == 0) { 
		var div_resposta = 'recado_comentar_topico_'+t_id; 
	} else { 
		var div_resposta = 'recado_comentar_comentario_'+c_id; 
	}
	document.getElementById(div_resposta).innerHTML = resposta;
}
function clearInput(block_id) {
	if( document.getElementById(block_id).value == "escreva seu recado agora" ) { document.getElementById(block_id).value = ""; } 
	if( document.getElementById(block_id).value == "nome ou um apelido" ) { document.getElementById(block_id).value = ""; }
	if( document.getElementById(block_id).value == "cidade" ) { document.getElementById(block_id).value = ""; }
	if( document.getElementById(block_id).value == "escreva aqui sua frase" ) { document.getElementById(block_id).value = ""; }
	document.getElementById(block_id).style.color = '#000';
}
function clearInputPerfil(block_id,user_id) {
	if( document.getElementById(block_id).value == "Escreva uma mensagem para "+user_id ) { document.getElementById(block_id).value = ""; } 
	document.getElementById(block_id).style.color = '#000';
}
/* --------------------------------------------------- frases -----------------------------------------------------------------*/
function enviarFrase(a) {
	var xmlHttp=GetXmlHttpObject();
	
	var texto = document.getElementById('input_forum_texto').value;
	if(a == 0) {
		var cid = document.getElementById('input_forum_cid').value;
		var nome = document.getElementById('input_forum_nome').value;
		var url="includes/ajax_blog_newFrase.php?texto="+texto+"&nome="+nome+"&cid="+cid;
	} else {
		var url="includes/ajax_blog_newFrase.php?account_id="+a+"&texto="+texto;
	}
		
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	/* var resposta = xmlHttp.responseText; */
	/* document.getElementById('recado_form').innerHTML = resposta; */
	document.getElementById('recado_form').innerHTML = "<div style='font-size: 11pt; font-weight: bold; color: #00c; padding: 20px;'>Sua frase foi enviada.<br>Poderá demorar para ser aprovada.</div>";
}	

function humorComentar(a_id, post_id) {
	var retorno = "<table border='0' cellspacing='0' id='tbl_write_comment'>";
	
	if(a_id == 0) {
		var retorno = retorno + "<tr><th>seu nome</td><td colspan='2'><input type='text' id='comentar_nome_"+post_id+"' class='field'></td></tr>";
	} else {
		var xmlHttp=GetXmlHttpObject();
		var url="includes/ajax_getAccountData.php?account_id="+a_id;
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		var myAccount = xmlHttp.responseText.split('|');
		
		var retorno = retorno + "<tr>";
		var retorno = retorno + "<th style='background-color: #eef; padding: 4px;'><img src='fotos/profile/thumb/"+myAccount[2]+"' width='35'></th>";
		var retorno = retorno + "<td style='background-color: #eef; padding: 4px;' colspan='2'><span style='font-weight: bold; color: #007;'>"+myAccount[0]+"</span><br>"+myAccount[1]+"</td>";
		var retorno = retorno + "</tr>";
	}
	
	var retorno = retorno + "<tr>";
	var retorno = retorno + "<th>comentário</th>";
	var retorno = retorno + "<td><textarea cols='50' rows='3' id='comentario_"+post_id+"' class='tArea''></textarea></td>";
	var retorno = retorno + "<td><input type='button' onClick='Javascript:humorComentar_append("+post_id+", "+a_id+");' value='enviar' class='botao'></td>";
	var retorno = retorno + "</tr>";
	
	var retorno = retorno + "</table>";
	
	document.getElementById('comentar_comentario_'+post_id).style.display = 'block';
	document.getElementById('comentar_comentario_'+post_id).innerHTML = retorno;
	
}


function humorComentar_append(post_id, a_id) {
	var xmlHttp=GetXmlHttpObject();

	var texto = document.getElementById('comentario_'+post_id).value;
	if(a_id == 0) {
		var nome = document.getElementById('comentar_nome_'+post_id).value;
	} else {
		var nome = "";
	}
	
	var url="includes/ajax_humor_comentar.php?comentario_id="+post_id+"&texto="+texto+"&nome="+nome+"&account_id="+a_id;
	
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	
		var div_resposta = 'comentar_comentario_'+post_id; 
		var resposta = "<div style='text-align: center; font: bold 12pt Tahoma; color: #007; padding: 30px 10px 30px 10px; border: 1px solid #00c;'>Sua frase foi enviada.</div>";
	
	document.getElementById(div_resposta).innerHTML = resposta;
}



/* --------------------------------------------------- anuncie ---------------------------------------------------------------- */
function anuncieCalcula() {
	var ed = document.getElementById('num_edicoes').value;
	var valor = ed * 10;
	document.getElementById('anuncio_valor').innerHTML = "R$ "+valor+",00";
}


function enviarAnuncioPadrao() {
	var xmlHttp=GetXmlHttpObject();
	
	var erros = 0;
	
	var nome = document.getElementById('nome').value;
	var email = document.getElementById('email').value;
	var ende = document.getElementById('ende').value;
	
	var a_tit = document.getElementById('a_tit').value;
	var a_texto = document.getElementById('a_texto').value;
	var a_fone = document.getElementById('a_fone').value;
	
	for (i=1; i<5; i++) { if (document.getElementById('a_sem_'+i).checked == true) { var a_semanas = i; } }
	for (i=1; i<4; i++) { if (document.getElementById('a_pgt_'+i).checked == true) { var a_pgt = i; } }
	
	var resposta = "<br>";

	if(nome.length < 5) { erros++; resposta = resposta+"• Preencha corretamente seu nome completo.<br>"; }
	if(ende.length < 5) { erros++; resposta = resposta+"• Informe seu endereço para cobrança.<br>"; }
	if(email.length < 5) { erros++; resposta = resposta+"• Informe um e-mail válido.<br>"; }
	
	if(a_tit.length < 3) { erros++; resposta = resposta+"• Informe um título válido para o seu anúncio.<br>"; }
	if(a_texto.length < 5) { erros++; resposta = resposta+"• Digite o texto do anúncio.<br>"; }
	if(a_fone.length < 8) { erros++; resposta = resposta+"• Informe um número de telefone válido.<br>"; }

	if(!document.getElementById('a_concordo').checked) { erros++; resposta = resposta+"• <b>Você deve ler e concordar com as regras,<br>&nbsp;&nbsp;&nbsp;e marcar a opção correspondente</b>"; }
	
	if(erros == 0) {
		var url = "includes/ajax_anuncie_padrao.php?nome="+nome+"&email="+email+"&ende="+ende+"&a_tit="+a_tit+"&a_texto="+a_texto+"&a_fone="+a_fone+"&a_pgt="+a_pgt+"&a_semanas="+a_semanas;
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		document.getElementById('anuncie_big_box').innerHTML = xmlHttp.responseText;
		return false; 
	} else { 
		var httpResp = "<h1 style='margin-top: 20px;'>Não é possível enviar seu anúncio.</h1>";
		var httpResp = httpResp + "<div style='width: 250px; display: block; float: left;'><img src='img/alert140px.png' border='0' style='margin-top: 20px;'></div>";
		var httpResp = httpResp + "<div style='width: 450px; display: block; float: left; font-family: Tahoma, Arial; font-size: 11pt; line-height: 170%; text-align: left;'>";
		var httpResp = httpResp + resposta;
		var httpResp = httpResp + "<br><br><input type='button' value='Fechar' id='btn_geral_blue' onClick='javascript:hidePopUp(\"hideshow\");'><br><br><br>";
		var httpResp = httpResp + "</div>";
		var httpResp = httpResp + "<br clear='all'>";
		document.getElementById('hideshow').style.visibility = "visible";
		document.getElementById('popup750px').innerHTML = httpResp;
		return false; 
	}
}

/* --------------------------------------------------- login e cadastro ------------------------------------------------------- */
function mainLogin() {
	var xmlHttp=GetXmlHttpObject();
	
	var email = document.getElementById('login').value;
	var senha = document.getElementById('passw').value;
	
	var url = "includes/authenticate.php?login=1&email="+email+"&senha="+senha;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	var retorno = xmlHttp.responseText.split(';');
	
	if(retorno[0] == 'true') {
		var resposta = "<img src='fotos/profile/thumb/"+retorno[3]+"' style='max-width: 25px;' />"+"&nbsp;<a href='index.php?page=perfil'>"+retorno[2]+"</a>. <span style='padding: 20px;'>|</span><a href='Javascript:logout();'>sair</a>";
	} else {
		var resposta = "e-mail ou senha inválidos - <a href='' onclick='window.location.reload()'>tentar novamente</a>";
		var resposta = resposta + "<span>|</span>";
		var resposta = resposta + "<a href='index.php?page=auth_recoverpassword'>esqueci minha senha</a>";
		var resposta = resposta + "<span>|</span>";
		var resposta = resposta + "<a href='index.php?page=cadastro'>registre-se</a>";
	}
	document.getElementById('login_area').innerHTML = resposta;
}

function profileLogin() {
	var xmlHttp=GetXmlHttpObject();
	
	var email = document.getElementById('loginF').value;
	var senha = document.getElementById('passwF').value;
	
	var url = "includes/authenticate.php?login=1&email="+email+"&senha="+senha;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	var retorno = xmlHttp.responseText.split(';');
	
	/*
	if(retorno[0] == 'true') {
		var resposta = "Olá "+retorno[2]+". <span style='padding: 0px 30px 0px 30px;'>[ <a href='index.php?page=perfil'>meu perfil</a> ]</span>[ <a href='Javascript:logout("+retorno[1]+");'>sair</a> ]";
	} else {
		var resposta = "e-mail e/ou senha inválidos";
	}
	document.getElementById('login_area').innerHTML = resposta;
	*/
	
	if(retorno[0] == 'true') {
		 /* window.location.href = "index.php?page=perfil&user_id="+retorno[1]; */
		 window.location.href = "index.php";
	} else {
		document.getElementById('login_msg').innerHTML = "Login e/ou senha incorretos! Verifique seus dados e tente novamente!";
	}
}

function logout() {
	/*
	var xmlHttp=GetXmlHttpObject();
	
	var url = "includes/authenticate.php?logout=1&account_id="+account_id;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	*/
	/*
	var retorno = xmlHttp.responseText;
	retorno = retorno.replace(/\+/g," ");
    retorno = unescape(retorno);
	
	document.getElementById('login_area').innerHTML = retorno;
	*/
	
	window.location.href = "index.php?action=logout";
}

function validaCadastroUser(seed) {
	var xmlHttp=GetXmlHttpObject();
	
	var erros = 0;
	var resposta = "";
	var tPattern = /^[\w ]+$/;
	/* validation fails if the input doesn't match our regular expression */
	/* if(!tPattern.test(document.getElementById('email').value)) { erros++; erroChars++; } */
	
	document.getElementById('td_nick').innerHTML = "&nbsp;";
	document.getElementById('td_mail').innerHTML = "&nbsp;";
	document.getElementById('td_sen1').innerHTML = "&nbsp;";
	document.getElementById('td_sen2').innerHTML = "&nbsp;";
	
	var nick = document.getElementById('nick').value;
	var email = document.getElementById('email').value;
	
	var url = "includes/ajax_valida_cadastro_user.php?nick="+nick+"&email="+email;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	
	var retorno = xmlHttp.responseText;
		
	if(retorno > 0) {
		erros++;
		if( retorno == 1 || retorno == 3 ) { document.getElementById('td_nick').innerHTML = "• Esse nick já está em uso. Escolha outro apelido."; }
		if( retorno == 2 || retorno == 3 ) { document.getElementById('td_mail').innerHTML = "• Esse e-mail já está em uso na rede."; }
	}
	
	if(nick.length < 4) { erros++; document.getElementById('td_nick').innerHTML = "• Seu nome / apelido / nick deve ter pelo menos 4 letras."; }
	if(!tPattern.test(nick)) { erros++; document.getElementById('td_nick').innerHTML = "• Caracteres inválidos. Use somente letras e espaços."; }
	
	if(email.length < 8) { erros++; document.getElementById('td_mail').innerHTML = "• O endereço de e-mail '"+document.getElementById('email').value+"' não é válido."; }
	
	
	var atpos=email.indexOf("@");
	var dotpos=email.lastIndexOf(".");
	if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)  {
		erros++; document.getElementById('td_mail').innerHTML = "• O endereço de e-mail '"+document.getElementById('email').value+"' não é válido.";
	}
	
	
	if(document.getElementById('pwd1').value.length < 5) { erros++; document.getElementById('td_sen1').innerHTML = "• A senha deve ter pelo menos 5 caracteres."; } 
	if(document.getElementById('pwd1').value !== document.getElementById('pwd2').value) { erros++; document.getElementById('td_sen1').innerHTML = "• As senhas digitadas são diferentes."; }
		
	if(erros == 0) { 
		return true; 
	} else { 
		/*
		var httpResp = "<div class='header_orange'>Não foi possível completar sua inscrição...</div>";
		var httpResp = httpResp + "<div style='width: 180px; display: block; float: left;'><img src='img/alert140px.png' border='0'></div>";
		var httpResp = httpResp + "<div style='width: 520px; display: block; float: left; font-family: Tahoma, Arial; font-size: 10pt; line-height: 170%; text-align: left;'>";
		var httpResp = httpResp + resposta;
		var httpResp = httpResp + "<br>Por favor, verifique seus dados e envie novamente.<br>";
		var httpResp = httpResp + "<br><input type='button' value='Fechar' class='btn_geral_orange' onClick='javascript:hidePopUp(3);' style='margin-left: 80px;'><br><br>";
		var httpResp = httpResp + "</div>";
		var httpResp = httpResp + "<br clear='all'>";
		document.getElementById('hideshow3').style.visibility = "visible";
		document.getElementById('popupCadastro').innerHTML = httpResp;
		*/
		return false; 
	}
}

function recuperaSenha() {
	var erros1 = 0;
	var respo1 = "";
	var email = document.getElementById('email').value;

	if( email.length < 8 ) { erros1++; var respo1 = respo1 + "Informe seu endereço de e-mail<br>registrado no Parabrisa On-Line"; }
	
	if(erros1 == 0) {
		return true;
	} else {
		var httpResp = "<div class='header_orange'>Não foi possível reenviar sua senha...</div>";
		var httpResp = httpResp + "<div style='width: 180px; display: block; float: left;'><img src='img/alert140px.png' border='0'></div>";
		var httpResp = httpResp + "<div style='width: 520px; display: block; float: left; font-family: Tahoma, Arial; font-size: 10pt; line-height: 170%; text-align: left;'>";
		var httpResp = httpResp + respo1;
		var httpResp = httpResp + "<br>Por favor, verifique seus dados e envie novamente.<br>";
		var httpResp = httpResp + "<br><input type='button' value='Fechar' class='btn_geral_orange' onClick='javascript:hidePopUp(3);' style='margin-left: 80px;'><br><br>";
		var httpResp = httpResp + "</div>";
		var httpResp = httpResp + "<br clear='all'>";
		document.getElementById('hideshow3').style.visibility = "visible";
		document.getElementById('popupCadastro').innerHTML = httpResp;
		return false; 
	}
}

function comboCidade() {
	var xmlHttp=GetXmlHttpObject();
	
	var uf = document.getElementById('uf_id').value;
	var url = "includes/ajax_combo_cidade_ibge.php?uf="+uf;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	
	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);

	document.getElementById('combo_cidade').innerHTML = resposta;
}

/* ------------------------------------------------ profile +  friends ------------------------------------------------ */
function tabPerfil(tab_id) {
	for(i=1;i<8;i++) {
		if(i == tab_id) {
			document.getElementById('tab'+i+'_body').style.display = "block";
			document.getElementById('tab'+i+'_link').className = "tab_on";
		} else {
			document.getElementById('tab'+i+'_body').style.display = "none";
			document.getElementById('tab'+i+'_link').className = "tab_off";
		}
	}
}


function tabPerfilId(tab_id) {
	for(i=1;i<5;i++) {
		if(i == tab_id) {
			document.getElementById('tabId'+i+'_body').style.display = "block";
			document.getElementById('tabId'+i+'_link').className = "tab_on";
		} else {
			document.getElementById('tabId'+i+'_body').style.display = "none";
			document.getElementById('tabId'+i+'_link').className = "tab_off";
		}
	}
}

function friendAccept(a1, a2) {
	var xmlHttp=GetXmlHttpObject();

	var url = "includes/perfil/ajax_friends.php?accept=1&a1="+a1+"&a2="+a2;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	
	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);

	document.getElementById('ajax_friends').innerHTML = resposta;	
}


function fanAdd(fan_id, seed) {
	var xmlHttp=GetXmlHttpObject();

	var url = "includes/ajax_fan_add.php?fan_id="+fan_id+"&seed="+seed;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	
	window.location.reload();
}

function mural(friend_id, reply) {
	var xmlHttp=GetXmlHttpObject();
	if(reply == 1) {
		mural_msg = document.getElementById('mural_msg').value;
		var url = "perfil_mural.php?friend_id="+friend_id+"&mural_msg="+mural_msg;
	} else {
		var url = "perfil_mural.php?friend_id="+friend_id;
	}
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	
	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);

	document.getElementById('tab2_body').innerHTML = resposta;	
}

function muralPostar(friend_id, reply, mural_id){
	var xmlHttp=GetXmlHttpObject();
	if(reply == 1){
		mural_msg = document.getElementById('mural_msg'+mural_id).value;
		mural_msg = mural_msg.replace('\n','<br>');
		mural_msg = mural_msg.replace('\r','<br>');
		var url = "perfil_mural.php?friend_id="+friend_id+"&mural_msg="+mural_msg;
		
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		
		document.getElementById('mural_reply'+mural_id).innerHTML = "<div style='font-weight: bold; color: #0000AA; font-size: 10pt; padding: 10px 5px 10px 5px;'>Mensagem Enviada.</div>";
		
	}else{
		document.getElementById('mural_bt'+mural_id).style.display = "none";
		document.getElementById('mural_reply'+mural_id).style.display = "block";
	}
	
}

function medalha_hide(max_id, block_id){
	if(block_id == 0){
		for(i = 1; i <= max_id; i++){
			if(document.getElementById('medalha'+i) !== null){
				document.getElementById('medalha'+i).style.display = "none";
			}		
		}
	}else{
		document.getElementById('medalha'+max_id+block_id).style.display = "none";
	}
}

function medalha_total_esconder(max_id, block_id){
		for(i = 1; i <= max_id; i++){
			document.getElementById('medalha'+i+block_id).style.display = "none";	
		}
}

function medalha_show(id, block_id){
	if(block_id == 0){
		document.getElementById('medalha'+id).style.display = "block";
	}else{
		document.getElementById('medalha'+id+block_id).style.display = "block";
	}
}

function recadoPerfil(c_id, t_id, a_id, new_level, c_base, reply){
	var xmlHttp=GetXmlHttpObject();
	if(reply == 1){
		recado_msg = document.getElementById('recado_msg'+c_id).value;
		var nome = " ";
		var cid = " ";
		
		var url="includes/ajax_recados_comentar.php?comentario_id="+c_id+"&texto="+recado_msg+"&nome="+nome+"&cidade="+cid+"&account_id="+a_id+"&new_level="+new_level+"&topico_id="+t_id+"&c_base="+c_base;
		
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		
		document.getElementById('recado_reply'+c_id).innerHTML = "<span style='color: #0000AA; font-size 9pt;'>Comentário enviado! Pode demorar para ser aprovado.</span>";
		
	}else{
		document.getElementById('recado_bt'+c_id).style.display = "none";
		document.getElementById('recado_reply'+c_id).style.display = "block";
	}
	
}

function mudarPagina(page,php){
var xmlHttp=GetXmlHttpObject();
	var url = "includes/perfil/"+php+".php"+"?&n="+page;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	document.getElementById(''+php+'').innerHTML = resposta;
	
}

function medalhas(id,block,name){
var xmlHttp=GetXmlHttpObject();
	var url = "includes/perfil/ajax_medalhas.php?&id="+id+"&b="+block+"&n="+name;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	document.getElementById('medalhas'+name).innerHTML = resposta;
	
}

function amigos_pendentes(id){
var xmlHttp=GetXmlHttpObject();

	if(id > 0){
		var url = "includes/perfil/ajax_amigos_pendentes.php?&id="+id;
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);
		var resposta = xmlHttp.responseText;
		resposta = resposta.replace(/\+/g," ");
		resposta = unescape(resposta);
		
		document.getElementById('amigos_fans').style.display = "none";
		document.getElementById('amigos_penden').style.display = "block";
		document.getElementById('amigos_penden').innerHTML = resposta;
	}else{
		document.getElementById('amigos_fans').style.display = "block";
		document.getElementById('amigos_penden').style.display = "none";
	}
}

function friendDel(id1,id2){
			
	var xmlHttp=GetXmlHttpObject();
	var url = "includes/perfil/ajax_friends.php?id1="+id1+"&id2="+id2;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	
	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);

	document.getElementById('ajax_friends').innerHTML = resposta;	
	
}

function todasMedalhas() {
	var xmlHttp=GetXmlHttpObject();
	
	var url="includes/popup_todas_medalhas.php";
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	document.getElementById('popup750px').innerHTML = resposta;
	document.getElementById('hideshow').style.visibility = "visible";
}

function mudarAvatar(file) {
	var xmlHttp=GetXmlHttpObject();
	
	var url="includes/popup_avatar.php?&file="+file;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);

	var resposta = xmlHttp.responseText;
	resposta = resposta.replace(/\+/g," ");
    resposta = unescape(resposta);
	
	document.getElementById('popup750px').innerHTML = resposta;
	document.getElementById('hideshow').style.visibility = "visible";
}



/* ------------------------------------------------ novidades ------------------------------------------------ */
function showNovidade(a_id){
	var xmlHttp=GetXmlHttpObject();
	var qt;
	
	if(document.getElementById('novidades').style.display == 'none'){
		var url="includes/ajax_novidades.php?account_id="+a_id;
		xmlHttp.open("GET",url,false);
		xmlHttp.send(null);

		var resposta = xmlHttp.responseText;
		resposta = resposta.replace(/\+/g," ");
		resposta = unescape(resposta);
		
		if(resposta == ""){
			document.getElementById('novidades_txt').style.display = 'none';
		}else{
			qt = parseInt(document.getElementById('novQt').innerHTML);
			if(qt>5){
				document.getElementById('novQt').innerHTML = qt-5;
			
			}else{
				document.getElementById('novQt').innerHTML = 0;
			}
			
			document.getElementById('novidades').innerHTML = resposta;
			document.getElementById('novidades').style.display = 'block';
			
		}
	}else{
		qt = parseInt(document.getElementById('novQt').innerHTML);
		if(qt < 1){
			document.getElementById('novidades_txt').style.display = 'none';
		}
		document.getElementById('novidades').style.display = 'none';
	
	}
}

/* ---------------------------------------------- Lista telefonica -------------------------------------------------- */
function verificaNumero(value, ddd, block){
	var xmlHttp=GetXmlHttpObject();
	
	if(ddd.length > 1 && ddd > 0){
		if(value.length > 8){
			var url="includes/ajax_lista_verifica.php?v="+value+"&ddd="+ddd;
			xmlHttp.open("GET",url,false);
			xmlHttp.send(null);
			
			var resposta = xmlHttp.responseText;
			resposta = resposta.replace(/\+/g," ");
			resposta = unescape(resposta);
			
			document.getElementById('verificaFone'+block).innerHTML = resposta;
		}
	}else{
		if( value.length > 8 ){ document.getElementById('verificaFone'+block).innerHTML = "<span style='color: #d95b5b;'>digite o DDD</span>"; }
	}
	
}

/* ------------------------------------------------ funções exclusivas do admin --------------------------------------- 
function vendagaragemMotivo(id) {
	switch(id) {
		case 1: texto = "Você não colocou o preço;"; break;
		case 2: texto = "O preço parece inadequado;"; break;
		case 3: texto = "Mais de um produto por anúncio, coloque um de cada vez;"; break;
		case 4: texto = "Este espaço é destinado apenas a negócios particulares;"; break;
		case 5: texto = "O valor excedeu o limite de R$ 150,00;"; break;
		case 6: texto = "O valor máximo é R$ 150, para negócio à vista;"; break;
		case 7: texto = "Seu anúncio está incompleto, ambíguo ou confuso;"; break;
		case 8: texto = "Trocas e compras devem respeitar o limite de R$ 150,00;"; break;
		case 9: texto = "Este tipo de anúncio não é adequado para o Venda de Garagem;"; break;
		case 10: texto = "Porque hoje não estou de bom humor;"; break;
	}
	
	mailbody = document.getElementById('mailbody').value;
	mailbody.replace("são: \n\n", "são: \n\n"+texto+"\n");
	document.getElementById('mailbody').value = mailbody;

}
*/

/* ------------------------------------------------ ajax object - enviroment setup ------------------------------------ */
function GetXmlHttpObject() {
	var xmlHttp;
	try {
	  xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
