var n_foto 			= [];
var n_foto_id 		= [];
var n_foto_cache	= {};
var n_id_list 		= [];
var n_foto_pagina 	= [];
var n_foto_ant_pro 	= [];
var n_pagina_atual	= "";
var n_foto_atual	= "";

var n_cores 		= {};
var n_favorito 		= [];
var n_link 			= [];
var n_noticia 		= [];
var n_comunidade 	= [];
var n_enquete 		= false;
var n_musica		= '';
var n_musica_foto	= '';
var n_musica_atual	= '';
var n_musica_base	= 'http://static.flogme.com.br/radio_xml/';
var url_static_img	= "http://static.flogme.com.br/img/";

var baixa_resolucao	= (typeof(screen.width) == 'undefined' || screen.width <= 800) ? '1' : '0';

var dados_perfil	= {'img':false,'apelido':'','cidade':'','id_cidade':'','uf':''};

var last_cadastros	= [];
var last_fotos		= [];
var last_top  		= [];
var timer_cadastros,timer_fotos,timer_top = '';

var sVersao	= navigator.appVersion;
var bIsIE = ( (sVersao.indexOf("IE") > -1) || (sVersao.indexOf("Mac") > -1) ) ;
var desc_comentario = {"2":"Somente usuários registrados do <b>FlogMe</b>","3":"Somente favoritos deste usuário"};
var revelacao_foto	= [];
var tituloCategoria = {1:'fotos pessoais',2:'Público',3:'Adulto/Erótico',4:'Educacional',5:'Montagens',6:'Animais',7:'Carros e Tuning',8:'Esportes',9:'Fotos de baladas',10:'Fotos do meu ídolo',11:'Games',12:'Gatas',13:'Gatos',14:'Gifs',15:'Humor',16:'Montagem',17:'Música',18:'Política',19:'Religião',20:'TV / Show',21:'Arte / Artesanato',22:'Anime & Mangá',23:'Bebês/Crianças'};

/*****************************
			Básicos
******************************/
function get(elemento){
	return document.getElementById(elemento);
}

function monta_fotolog(){
	/* Perfil */
	monta_perfil();
	
	/* Favoritos */
	monta_favoritos();
	
	/* Links */
	if(n_link.length){
		randArray(n_link);
		linkmax = (n_link.length > 10) ? 10 : n_link.length;
		get('boxD').innerHTML += "<br />"+monta_bloco('Link');
		var htmlLink = "";
		for(i=0;i<linkmax;i++){
			htmlLink += "<a target='_blank' href='http://www.flogme.com.br/link_out.php?link="+n_link[i]['id_link']+"' title='"+n_link[i]['desc_link']+" ("+n_link[i]['clics']+" cliques)'>"+n_link[i]['titulo_link']+"</a><br />";
		}
		get('tituloLink').innerHTML = "<p>Links</p>";
		get('corpoLink').innerHTML  = htmlLink;
	}
	
	/* Noticias */
	if(n_noticias.length){
		get('boxE').innerHTML += monta_bloco('Noticia')+"<br />";
		if(IE){
			var html_noticias = "<marquee scrollamount='2' direction='up' style='height: 150px;' onmouseover='this.stop()' onmouseout='this.start()' style='text-align: center;'>";	
		} else {
			get('tituloNoticia').style.overflow = 'auto';
			get('corpoNoticia').style.height	= '200px';
			html_noticias = '';
		}
		for(i=0;i<n_noticias.length;i++){
			html_noticias += "<a href='/?ver_noticia="+i+"' onClick='ver_noticia("+i+");return false;'><b>"+unescape(n_noticias[i]['dthr_noticia'])+"</b> <br> "+unescape(n_noticias[i]['titulo_noticia'])+"</a><br><br>";
		}
		if(IE){
			html_noticias += "</marquee>";	
		}
		get('tituloNoticia').innerHTML 	= "<p>Notícias</p>";
		get('corpoNoticia').innerHTML 	= html_noticias;
	}
	
	/* Player */
	if(n_musica != ''){
		monta_player(n_musica);
	}
	
	/* Enquete */
	if(n_enquete){
		monta_enquete();
	}

	monta_last_cadastros();
	monta_last_top();
	monta_last_fotos();

//	timerADS = setTimeout('populaADS()', 5000);
}

function monta_perfil(){
	get('boxE').innerHTML += monta_bloco('Perfil') + "<br />";
	get('tituloPerfil').innerHTML = 'Perfil';
	html  = '';
	if(dados_perfil['img']) html += '<img style="margin-top: 4px;" src="'+dados_perfil['img']+'"><br>';
	html += '<b>'+unescape(dados_perfil['apelido'])+'</b><br />';
	html += unescape(dados_perfil['cidade'])+' - '+unescape(dados_perfil['uf'])+'<br />';
	if(dados_perfil['idade'] != '') { html += 'idade: '+dados_perfil['idade']+'<br />'; }
	if(dados_perfil['signo'] != '') { html += 'signo: '+dados_perfil['signo']+'<br />'; }
	html += '<hr><div style="text-align: left; width: 100%; padding-left: 2px; padding-bottom: 3px; font-weith: bolder;">';
	html += '<a href="javascript:;" onClick="adicionar_aos_favoritos();return false"  title="Adicionar este usuário aos meus favoritos">&raquo; Add aos favoritos</a><br>';
	html += '<a href="javascript:;" onClick="convite_favorito_reverso();return false" title="Enviar convite para dono deste fotolog me adicionar como favorito">&raquo; Favorito reverso</a><br>';
	if(dados_perfil['priv_efetuadas'] == '1'){ html += '<a href="javascript:;" onClick="busca_visitas_efetuadas();return false" id="linkVisitasEfetuadas" title="Ver últimos fotologs visitados pelo dono deste fotolog">&raquo; Últimos visitados</a><br>'; }
	if(dados_perfil['priv_recebidas'] == '1'){ html += '<a href="javascript:;" onClick="busca_visitas_recebidas();return false" id="linkVisitasRecebidas" title="Ver últimos visitantes deste fotolog">&raquo; Últimos visitantes</a>'; }
	html += '</div>';
	html += '<hr><a href="http://del.icio.us/post?url=http://'+dominio_user+'/" title="del.icio.us"><img border=0 src="'+url_static_img+'delicious.gif" /></a><a style="margin-left: 5px;" href="http://digg.com/submit?url=http://'+dominio_user+'/" title="digg.com"><img border=0 src="'+url_static_img+'digg.gif" /></a>';
	//<a style="margin-left: 5px;" href="http://reddit.com/submit?url=http://'+dominio_user+'/" title="reddit.com"><img border=0 src="reddit.gif" /></a><a style="margin-left: 5px;" href="http://technorati.com/cosmos/search.html?url=http://'+dominio_user+'/" title="technorati.com"><img border=0 src="'+url_static_img+'technorati.gif" /></a>
	get('corpoPerfil').innerHTML  = html;
}

function ver_pagina(pg, mudar_foto){
	if(n_pagina_atual != pg){
		n_pagina_atual = pg;
		vp_dest = pg * 5;
		if(vp_dest > n_foto.length){
			vp_dest = n_foto.length;
			vp_ori = (pg-1) * 5; 
		} else { 
			vp_ori  = vp_dest-5;
		};
		html	= "<table id='tFotos'>";
		for(i=vp_ori;i<vp_dest;i++){
			html += "<tr><td valign='middle' id='span_"+n_foto[i]['id_foto']+"'><a href='/?id_foto="+n_foto[i]['id_foto']+"' onClick='ver_foto("+n_foto[i]['id_foto']+");return false;'><img id='foto_"+n_foto[i]['id_foto']+"' src='"+n_foto[i]['thumb_url']+"' border=0><div class='corpo' style='overflow: hidden; width: 100px; height: 16px;'>"+unescape(n_foto[i]['titulo'])+"</div></a></td></tr>";
		}
		html	+= "</table>";
		html 	+= "<div class='titulo'><a href='?galeria&fotos=1' onClick='ver_todas_fotos(); return false;' style='font-size: 10px'>Ver todas fotos</a></div>";
		html_crt= '<span class="info">página '+pg+' de '+n_tot_pagina+'</span>';
		if(pg != 1){
			html_crt += "<a href='/?ver_pagina="+(pg-1)+"' onClick='ver_pagina("+(pg-1)+",true); return false;' class='menos'>&laquo;</a>";
		}
		if(pg < n_tot_pagina){
			html_crt += "<a href='/?ver_pagina="+(pg+1)+"' onClick='ver_pagina("+(pg+1)+",true); return false;' class='mais'>&raquo;</a>";
		}

		get('pgStrip').innerHTML 	= html_crt;
		get('fotosStrip').innerHTML = html;
		//Caso o usuário não tenha foto
		if(n_foto.length == 0){
			sem_nenhuma_foto();
		} else {
			if( (n_foto_atual == '' || (n_foto_atual != n_foto[vp_ori]['id_foto'] && n_foto_atual != n_foto[(vp_dest-1)]['id_foto'])) && mudar_foto){ver_foto(n_foto[vp_ori]['id_foto']);}
		}
	}
}

function ver_foto(ft){
	if(n_foto_atual != ft){
		n_foto_atual = ft;

		if(n_foto_pagina[ft] != n_pagina_atual) ver_pagina(n_foto_pagina[ft], false);
		busca_foto(ft);
		for(i=0;i<n_foto.length; i++){
			if(n_foto_pagina[n_foto[i]['id_foto']] == n_pagina_atual){
				get('span_'+n_foto[i]['id_foto']).style.border = "2px solid "+n_bg;
				//get('span_'+n_foto[i]['id_foto']).bgColor = n_bg;
			}
		}
		get('span_'+ft).style.border 	= "2px outset "+n_bg_down;
		//get('span_'+ft).bgColor 	= n_bg_down;
		get('foto_'+ft).style.opacity 	= 1;
		get('foto_'+ft).style.MozOpacity = 1;
		get('foto_'+ft).style.filter 	= 'alpha(opacity=100)';
	}
}

function ver_todas_fotos(){
	objPaginador.configura('foto', n_foto, 16);
}

function monta_bloco(di){
	concatena   = '<div class="boxLateral">'+"\n";
	concatena  += '<div class="up"><div class="R"></div><div class="L"></div></div>'+"\n";
	concatena  += '<div id="titulo'+di+'" class="titulo"></div>'+"\n";
	concatena  += '<div id="corpo'+di+'" class="corpo"></div>'+"\n";
	concatena  += '<div class="down"><div class="R"></div><div class="L"></div></div>'+"\n";
	concatena  += '</div>';
	return concatena;
}

/*****************************
			Player
******************************/
function player_nunca_mais(){
	setCookie('player', '1', 'Thursday, September 15, 2010 GMT', '/', dominio);
	monta_player(n_musica);
}

function player_novamente(){
	deleteCookie('player', '/', dominio);
	monta_player(n_musica);
}

var player_play_status=0;
function player_pause(player_novo_status){
	if(IE && player_play_status > 0){
		if(player_novo_status != player_play_status){
			switch(player_play_status){
				case 2:
					//pausado
					if (mediaPlayer.controls.isavailable('play')){
						mediaPlayer.controls.play();
						player_play_status = 1;
					}
				break;
				case 1:
					//play --> pause
					if (mediaPlayer.controls.isavailable('pause')){
						mediaPlayer.controls.pause();
						player_play_status = 2;
					}
				break;
			}
		}
	}
}

function monta_player(url_xml, tituloMusica){
	if(getCookie('player') == null){
		var random_num 	= (Math.round((Math.random()*9)+1));
		if(!url_xml.match('http:\/\/')){
			url_xml = n_musica_base+url_xml+'?'+random_num;
		}
		var playerConfig 	= {
			'file'			: url_xml,
			'displayheight'	: '0',
			'autostart'		: 'true',
//			'shuffle'		: 'true',
			'repeat'		: 'list',
			'backcolor'		: "0x"+n_bg_down.replace('#',''),
			'frontcolor'	: "0x"+n_bg_font.replace('#',''),
			'lightcolor'	: "0x"+n_bg.replace('#','')
		}
		if(typeof(tituloMusica) != 'undefined'){
			playerConfig['title'] = tituloMusica;
		}
		var url_swf = 'http://static.flogme.com.br/swf/flvplayer.swf?';
		for(x in playerConfig){
			url_swf += x+'='+playerConfig[x]+'&';
		}
		var s1  	= new SWFObject(url_swf,'radioPlayer','400','170','9');
		for(x in playerConfig){
			s1.addVariable(x, playerConfig[x]);
		}
		s1.write('boxMusica');
		
		get('boxMusica').style.display = 'block';
		get('boxMusica').style.height = '190px';
		get('boxMusica').innerHTML += "<br><a href='javascript:player_nunca_mais();' style='font-size: 11px;'>clique aqui para não ouvir rádio</a>"; 
		player_play_status=1;
	} else {
		get('boxMusica').style.display = 'block';
		get('boxMusica').style.height = '50px';
		get('boxMusica').innerHTML = "<br><a href='javascript:player_novamente();' style='font-size: 11px;'>clique para ouvir rádio</a>";
		player_play_status=0;
	}
}


/*****************************
		Comentário
******************************/
function monta_FormComentario(id_foto, podeComentar, qmComenta){
	if(podeComentar){
		var htmlForm = "";
		htmlForm += '<center><br><br><div id="comente">';
		htmlForm += '<div class="up"><div class="R"></div><div class="L"></div></div>';
		htmlForm += "<input type='hidden' name='comentario'><input type='hidden' id='dados[id_foto]' value='"+id_foto+"'>";
		htmlForm += "<table align='center' cellpadding='0' cellspacing='0' id='ftcwcomentario'>";
		htmlForm += "<tr><td id='trComent1' colspan='2' align='center'><b>Envie Seu Coment&aacute;rio</b></td></tr>";
		htmlForm += "<tr id='trComent2'><td>&nbsp;Seu nome: </td><td>&nbsp;<input name='dados[nome]' type='text' id='dados[nome]' value='"+unescape(from_name)+"' class='snd_comment_frm' tabindex='1'></td></tr>";
		htmlForm += "<tr id='trComent3'><td>&nbsp;Seu Fotolog/e-mail:</td><td>&nbsp;<input name='dados[site]' type='text' id='dados[site]' value='"+from_url+"' size='30' class='snd_comment_frm' tabindex='2'></td></tr>";
		htmlForm += "<tr id='trComent4'><td colspan='2'> &nbsp;Coment&aacute;rio <br>&nbsp;<textarea name='dados[comentario]' id='dados[comentario]' cols='45' rows='6' wrap='VIRTUAL'  onKeyUp='javascript:div_altera_texto(\"contador\", \"&nbsp;&nbsp;\" + this.value.length + \"/1000 caracteres\")' class='snd_comment_frm'  tabindex='3'></textarea><div id='contador'></div><div align=right><a href='javascript:emotion_info();' class='snd_comment_bod'>Info Emotions</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' value='enviar comentário' class='snd_comment_frm' tabindex='4' onclick='envia_comentario_ajax();'>&nbsp;&nbsp;</p></td></tr>";
		htmlForm += "<tr id='trComentAguarde' style='display:none;'><td colspan='2' align='center'><b><br><br><img src='"+url_static_img+"loading_circulo3.gif' title='enviando seu comentario'><br>enviando seu comentario</b></td></tr>";
		htmlForm += '</table><div class="down"><div class="R"></div><div class="L"></div></div>';
		htmlForm += '</div></center>';
		parent.get('boxForm').innerHTML = htmlForm;
	} else {
		var htmlForm = "";
		htmlForm += '<center><br><br><div id="comente">';
		htmlForm += '<div class="up"><div class="R"></div><div class="L"></div></div>';
		htmlForm += desc_comentario[qmComenta] + " podem comentar neste fotolog";
		htmlForm += '<div class="down"><div class="R"></div><div class="L"></div></div>';
		htmlForm += '</div></center>';
		parent.get('boxForm').innerHTML = htmlForm;
	}
}

function envia_comentario_ajax(){
	if(vr_envio_coment()){
		get('trComent1').style.display = 'none';get('trComent2').style.display = 'none';get('trComent3').style.display = 'none';get('trComent4').style.display = 'none';get('trComentAguarde').style.display = '';
		get_url('/conector.php', 'eval', 'acao=comentar&id_foto='+get('dados[id_foto]').value+'&dados[nome]='+escape(trim(get('dados[nome]').value))+'&dados[site]='+escape(trim(get('dados[site]').value))+'&dados[comentario]='+escape(trim(get('dados[comentario]').value)));
	}
}

function popula_comentario(dados){
	eval(unescape(dados));
	var html_comment = "";
	for(i=0;i<dados_comment.length;i++){
		html_comment += dados_comment[i]['dthr']+" - "+dados_comment[i]['urlfrom']+" - "+unescape(dados_comment[i]['nome'])+" - "+unescape(dados_comment[i]['comment'])+"<br>";
	}
	get('corpoFoto').innerHTML += html_comment;
}

/*****************************
		Foto
******************************/
function sem_nenhuma_foto(){
	get('tituloFoto').innerHTML = "<center><br><br>Este usuário não possui nenhuma foto publicada<br><br></center>";
	get('corpoFoto').innerHTML  = "<center><br><br>Este usuário não possui nenhuma foto publicada<br><br></center>";
}

function foto_removida(){
	get('tituloFoto').innerHTML = "foto removida pelo usuário";
	get('corpoFoto').innerHTML  = "<br>Esta foto foi removida pelo dono";
}

function vr_cache_foto(id_foto_cache){
	for(x in n_foto_cache){
		if(x == id_foto_cache){
			return true;	
		}
	}
	return false;
}

function busca_foto(id_foto){
	if(get('img_loading')) get('img_loading').style.display = 'block';
	get('tituloFoto').innerHTML = "&nbsp;"+unescape(n_foto_id[id_foto]['titulo']);
	if(vr_cache_foto(id_foto)){
		popula_foto(n_foto_cache[id_foto]);
	} else {
		get_url('/conector.php', 'popula_foto', 'acao=foto&id_foto='+id_foto+'&priv_foto='+dados_perfil['priv_foto']+'&baixa_resolucao='+baixa_resolucao);
	}
}

var musica_post = false;
function popula_foto(dados){
	if(typeof(dados) == 'string'){
		eval(dados);
		n_foto_cache[dados_foto['id_foto']] = dados_foto;
	} else {
		dados_foto = dados;
	}
	
	//get('tituloFoto').innerHTML = unescape(dados_foto['titulo']);
	get('boxComentario').innerHTML = "";
	if(get('boxEscondido').style.display == '') get('boxEscondido').style.display = "none";
	if(get('meioComentario').style.display == 'none') get('meioComentario').style.display = "";
	document.title = unescape(dados_foto['titulo'])+' - '+unescape(dados_perfil['apelido']);
	var html_adp = "<div style='float: right;'><div id='img_loading'><img src='"+url_static_img+"loading_circulo3.gif'><br>carregando</div></div><center><table border=0 width='500px' align='center' id='controleADP'><tr>";
	if(n_foto_ant_pro[dados_foto['id_foto']]['proxima'] != ''){html_adp +="<td width='33%' align=center><a href='/?ver_foto="+n_foto_ant_pro[dados_foto['id_foto']]['proxima']+"' onClick='javascript:ver_foto("+n_foto_ant_pro[dados_foto['id_foto']]['proxima']+"); return false;'><img src='"+url_static_img+"anterior.gif' border=0 align=absmiddle> Anterior</a></td>";}else{html_adp +="<td width='33%'>&nbsp;</td>";}
	html_adp+="<td width='33%' align=center><a href='javascript:denuncia(\"/?denuncia&denuncia_id_foto="+dados_foto['id_foto']+"&denuncia_razao=\");'><img src='"+url_static_img+"denunciar.gif' border=0 align=absmiddle> Denunciar</a></td>";
	if(n_foto_ant_pro[dados_foto['id_foto']]['anterior'] != ''){html_adp +="<td align=center><a href='/?ver_foto="+n_foto_ant_pro[dados_foto['id_foto']]['anterior']+"' onClick='javascript:ver_foto("+n_foto_ant_pro[dados_foto['id_foto']]['anterior']+"); return false;'>Próxima <img src='"+url_static_img+"proxima.gif' border=0 align=absmiddle></a></td>";}else{html_adp +="<td width='33%'>&nbsp;</td>";}
	html_adp+="</tr></table></center>";
	get('corpoFoto').innerHTML 			= html_adp+"</center>";
	get('corpoFotoDescricao').innerHTML = unescape(dados_foto['descricao'])+"<br /><br />";
	get('consoleComment').innerHTML 	= '<iframe src="/conector.php?acao=comentario&id_foto='+dados_foto['id_foto']+'&id_usuario='+id_usuario+'"></iframe>';
	player_pause(dados_foto['acao_player']);
	if(dados_foto['musica']){
		monta_player(unescape(dados_foto['musica']), unescape(dados_foto['musica_desc']));
		musica_post = true;
	} else {
		if(musica_post){
			musica_post = false;
			monta_player(n_musica);
		}
	}
}

/*****************************
		Favoritos
******************************/
function monta_favoritos(){
	if(n_favorito.length){
		var html_fav = monta_bloco('Favorito')+"<br />";
		get('boxE').innerHTML = get('boxE').innerHTML + html_fav;
		get('tituloFavorito').innerHTML = "<p>Favoritos</p>";
		get('corpoFavorito').className  = "fotosLaterais";
		var html = '';
		for(i=0;i<n_favorito.length;i++){
			html += "<a href='http://"+n_favorito[i]['login']+".flogme.com.br'><img src='"+n_favorito[i]['url_thumb']+"'><br />"+unescape(n_favorito[i]['apelido'])+"</a><br />";
		}
		get('corpoFavorito').innerHTML = html;
		get('corpoFavorito').innerHTML += "<div class='titulo'><a id='linkTodosFav' style='font-size: 10px' href='/?galeria&favoritos=1' onClick='busca_todos_favoritos(); return false;'>Todos Favoritos</a></div>";
	}
}

function busca_favorito(){
	monta_fotolog();
}

function busca_todos_favoritos(){
	get('linkTodosFav').innerHTML = 'Carregando...';
	get('linkTodosFav').onClick   = 'return false;';
	get_url('/conector.php','popula_todos_favoritos', 'acao=todos_favoritos&id_usuario='+id_usuario);
}

function popula_todos_favoritos(dados){
	get('linkTodosFav').innerHTML = 'Todos Favoritos';
	get('linkTodosFav').onClick   = 'busca_todos_favoritos(); return false;';
	n_foto_atual = '';

	eval(unescape(dados));
	
	objPaginador.configura('favorito', todos_favoritos, 12);	
	return false;
}

function adicionar_aos_favoritos(){
	get_url('/conector.php?acao=adicionar_aos_favoritos&id_favorito='+id_usuario, 'eval');
}

function convite_favorito_reverso(){
	get_url('/conector.php?acao=adicionar_favorito_reverso&id_favorito='+id_usuario, 'eval');
}

/*****************************
		Enquete
******************************/
function monta_enquete(){
	var html_enquete = '<strong><center>'+unescape(enquete_config['pergunta'])+'</center></strong>\n';
	for(uia in enquete_opcao){
		if(enquete_config['multipla'] == true){
			html_enquete += '<input type="checkbox" name="enquete_resposta[]" value="'+uia+'"> '+unescape(enquete_opcao[uia])+'<br />\n';
		} else {
			html_enquete += '<input type="radio" name="enquete_resposta[]" value="'+uia+'"> '+unescape(enquete_opcao[uia])+'<br />\n';
		}
	};
	html_enquete += '<center><br><input type="submit" value="Votar"><br>';
	if(enquete_config['publica']){
		html_enquete += '<br><a href="javascript:;" onClick="ver_resultado_enquete('+enquete_config['id_enquete']+'); return false;">Ver Resultado</a>';
	}
	html_enquete += '</center>';		
	if(!document.vota_enquete){
		get('boxE').innerHTML += '<form name="vota_enquete" onSubmit="return valida_enquete();" action="/vota_enquete.php?id_enquete='+enquete_config['id_enquete']+'" method="post" target="targetEnquete">'+monta_bloco('Enquete')+ '</form>';
	}
	get('tituloEnquete').innerHTML = "<p>Enquete</p>";
	get('corpoEnquete').innerHTML = html_enquete;
}

function valida_enquete(){
	var respostas = document.getElementsByName("enquete_resposta[]");
	var valido = false;
	for(i=0;i<respostas.length;i++){
		if(respostas[i].checked) valido=true;
	}
	if(!valido){
		alert((enquete_config['multipla'] == false) ? 'Selecione a sua resposta' : 'Selecione a(s) sua(s) resposta(s)');
	} else {
		get('consoleEnqueteDiv').innerHTML = "<iframe id='consoleEnquete' name='targetEnquete'></iframe>";
	}
	return valido;
}

function ver_resultado_enquete(id_enquete){
	get('consoleEnqueteDiv').innerHTML = "<iframe id='consoleEnquete' name='targetEnquete'></iframe>";
	get('consoleEnquete').src = 'vota_enquete.php?ver_resultado=1&id_enquete='+id_enquete;
}

/*****************************
		notícias
******************************/
function ver_noticia(id_noticia){
	if(n_noticias.length){
		var dados_noticia = n_noticias[id_noticia];
		html_noticia =  '<center><div style="width: 500px; display: block; margin-top: 4px; text-aling: left;">';
		html_noticia += unescape(dados_noticia['corpo_noticia']);
		html_noticia += '</div></center>';
		get('tituloFoto').innerHTML = unescape(dados_noticia['titulo_noticia'])+"<br>"+unescape(dados_noticia['dthr_noticia']);
		get('corpoFoto').innerHTML  = html_noticia+"<br><br><br>";
		get('meioComentario').style.display = 'none';
		get('boxComentario').innerHTML = '';
		n_foto_atual = '';
	}
}

/*****************************
		menu do usuário
******************************/
function verificaMenu(){
	var menuContext = get('menuContext');
	if(menuContext.style.display=="block"){
		menuContext.style.display="none";
	}
}

function contextmenu(e){
	mostraMenu(e);
	return false;
}

function mostraMenu(e){
	var maxX = IE ? document.body.clientWidth : window.innerWidth;
	var menuContext = get('menuContext');
	var tamanhoMenu = 200;

	var leftPX = IE ? window.document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX; //position the horizontal position of the menu where the mouse was clicked
	var topPX  = IE ? window.document.body.scrollTop + event.clientY : window.pageYOffset+e.clientY;

	if((leftPX+200)>maxX){
		leftPX = maxX - tamanhoMenu - 30;
	}

	menuContext.style.top  = topPX + "px";
	menuContext.style.left = leftPX+ "px";
	if(IE) window.scrollTo(0,0);
	menuContext.style.display="block";
	return false;
}

function escondeMenu(e){
	var menuContext = get('menuContext');
	menuContext.style.display = "none";
}

function ajustaThumb(elemImg){
	var tot = (100 - parseInt(elemImg.height)) / 2;
	elemImg.style.marginTop = tot+"px";
}

/********************************
	últimas visitas recebidas
	
	get('linkTodosFav').innerHTML = 'Carregando...';
	get('linkTodosFav').onClick   = 'return false;';
	get_url('/conector.php?acao=todos_favoritos&id_usuario='+id_usuario,'popula_todos_favoritos');
}

function popula_todos_favoritos(dados){
	get('linkTodosFav').innerHTML = 'Todos Favoritos';
	get('linkTodosFav').onClick   = 'busca_todos_favoritos(); return false;';
********************************/
function busca_visitas_recebidas(toEval){
	get('linkVisitasRecebidas').innerHTML = 'Carregando...';
	get('linkVisitasRecebidas').onClick   = 'return false;';
	get_url('/conector.php', 'popula_visitas_recebidas', 'acao=visitas_recebidas&id_usuario='+dados_perfil['id_usuario']);
}

function popula_visitas_recebidas(toEval){
	n_foto_atual = '';
	eval(toEval);
	objPaginador.configura('visitas recebidas', visita_recebidas, 12);	
	get('linkVisitasRecebidas').innerHTML = '» Últimos visitantes';
	get('linkVisitasRecebidas').onClick   = 'busca_visitas_recebidas(); return false';
	return false;
}

function busca_visitas_efetuadas(toEval){
	get('linkVisitasEfetuadas').innerHTML = 'Carregando...';
	get('linkVisitasEfetuadas').onClick   = 'return false;';
	get_url('/conector.php', 'popula_visitas_efetuadas', 'acao=visitas_efetuadas&id_usuario='+dados_perfil['id_usuario']);
}

function popula_visitas_efetuadas(toEval){
	n_foto_atual = '';
	eval(toEval);
	objPaginador.configura('visitas efetuadas', visitas_efetuadas, 12);	
	get('linkVisitasEfetuadas').innerHTML = '» Últimos visitados';
	get('linkVisitasEfetuadas').onClick   = 'busca_visitas_efetuadas(); return false';
	return false;
}


/********************************
Tops/Novas Fotos/Novos Cadastros
ver tops
ver ultimas fotos
ver ultimos cadastros
	0 - texto
	1 - desativado
	2 - texto e imagem
*********************************/
function monta_last_top(){
	clearTimeout(timer_top);
	var preferencia = getCookie('prefLT');
	var preferencia_limit = getCookie('prefLimitT');
	if(preferencia_limit == null) preferencia_limit = 10;
	if(last_top.length){
		if(document.getElementById('corpoLastTops') == null){
			var html = monta_bloco('LastTops');
			get('boxE').innerHTML += "<br />"+html;
			get('tituloLastTops').innerHTML = "<p>Top Categoria<br>"+tituloCategoria[id_categoria]+"</p>";
			get('corpoLastTops').className  = "fotosLaterais";
		}
		var html = '';
		if(preferencia != 1){
			if(preferencia_limit > last_top.length) preferencia_limit = last_top.length;
			if(preferencia == 2){
				html += "<a href='javascript:;' onClick='set_last(\"prefLT\",\"0\",\"monta_last_top();\");'><img title='Exibir Somente Texto' src='"+url_static_img+"btn_text.gif' style='margin-right: 3px;'></a>";
			} else {
				html += "<a href='javascript:;' onClick='set_last(\"prefLT\",\"2\",\"monta_last_top();\");'><img title='Exibir Texto e Foto do usuário' src='"+url_static_img+"btn_imagem.gif' style='margin-right: 3px;'></a>";
			}
			html += "<a href='javascript:;' onClick='set_last(\"prefLimitT\",\"prompt\",\"monta_last_top();\", "+preferencia_limit+");'><img title='Configure o número de novas fotos exibidas' src='"+url_static_img+"btn_limit.gif' style='margin-right: 3px;'></a>";
			html += "<a href='javascript:;' onClick='set_last(\"prefLT\",\"1\",\"monta_last_top();\");'><img title='Não Exibir Tops' src='"+url_static_img+"btn_cancel.gif' style='margin-right: 3px;'></a>";
			html += "<hr height='1px' />";
			for(x=0; x<preferencia_limit; x++){
				html += '<a href="http://'+last_top[x]['login']+'.'+dominio+'/">';
				if(preferencia == 2){
					html += '<img border=0 src="'+last_top[x]['url_thumb']+'"><br />';				
				}
				html += unescape(last_top[x]['apelido'])+'</a><br />';
			}
		} else {
			html += "<a href='javascript:;' onClick='set_last(\"prefLT\",\"0\",\"monta_last_top();\");'><img title='Exibir Tops' src='"+url_static_img+"btn_text.gif' style='margin-right: 3px;'></a>";
		}
		get('corpoLastTops').innerHTML = html;
	} else {
		timer_top = setTimeout('monta_last_top()', 1000);
	}
}

function monta_last_fotos(codigo_exec){
	clearTimeout(timer_fotos);
	if(codigo_exec) eval(codigo_exec);
	var preferencia = getCookie('prefLF');
	var preferencia_limit = getCookie('prefLimitF');
	if(preferencia_limit == null) preferencia_limit = 10;
	if(last_fotos.length){
		if(document.getElementById('corpoLastFotos') == null){
			var html = monta_bloco('LastFotos');
			get('boxE').innerHTML += "<br />"+html;
			get('tituloLastFotos').innerHTML = "<p>FlogMe<br>novas fotos</p>";
			get('corpoLastFotos').className  = "fotosLaterais";
		}
		var html = '';
		if(preferencia != 1){
			if(preferencia_limit > last_fotos.length) preferencia_limit = last_fotos.length;
			if(preferencia == 2){
				html += "<a href='javascript:;' onClick='set_last(\"prefLF\",\"0\",\"monta_last_fotos();\");'><img title='Exibir Somente Texto' src='"+url_static_img+"btn_text.gif' style='margin-right: 3px;'></a>";
			} else {
				html += "<a href='javascript:;' onClick='set_last(\"prefLF\",\"2\",\"monta_last_fotos();\");'><img title='Exibir Texto e Foto do usuário' src='"+url_static_img+"btn_imagem.gif' style='margin-right: 3px;'></a>";
			}
			html += "<a href='javascript:;' onClick='set_last(\"prefLimitF\",\"prompt\",\"monta_last_fotos();\", "+preferencia_limit+");'><img title='Configure o número de novas fotos exibidas' src='"+url_static_img+"btn_limit.gif' style='margin-right: 3px;'></a>";
			html += "<a href='javascript:;' onClick='get(\"img_update_last_fotos\").src=\""+url_static_img+"btn_update_loading.gif\";get_url(\"/conector.php?acao=last_fotos\",\"monta_last_fotos\"); return false'><img id='img_update_last_fotos' title='Atualizar novas fotos' src='"+url_static_img+"btn_update.gif' style='margin-right: 3px;'></a>";
			html += "<a href='javascript:;' onClick='set_last(\"prefLF\",\"1\",\"monta_last_fotos();\");'><img title='Não Exibir Novas Fotos' src='"+url_static_img+"btn_cancel.gif' style='margin-right: 3px;'></a>";
			if(codigo_exec){
				var d = new Date();
				html += "<div style='font-size: 10px;'>atualizado em<br>"+(d.getHours() < 10 ? '0'+d.getHours() : d.getHours())+":"+(d.getMinutes() < 10 ? '0'+d.getMinutes() : d.getMinutes())+":"+(d.getSeconds() < 10 ? '0'+d.getSeconds() : d.getSeconds())+"</div>";	
			}
			html += "<hr height='1px' />";
			for(x=0; x<preferencia_limit; x++){
				html += '<a href="http://'+last_fotos[x]['login']+'.'+dominio+'/?id_foto='+last_fotos[x]['id_foto']+'">';
				if(preferencia == 2){
					html += '<img border=0 src="'+last_fotos[x]['url_thumb']+'"><br />';				
				}
				html += unescape(last_fotos[x]['apelido'])+'</a><br />';
			}
		} else {
			html += "<a href='javascript:;' onClick='set_last(\"prefLF\",\"0\",\"monta_last_fotos();\");'><img title='Exibir Últimas Fotos' src='"+url_static_img+"btn_text.gif' style='margin-right: 3px;'></a>";
		}
		get('corpoLastFotos').innerHTML = html;
	} else {
		timer_fotos = setTimeout('monta_last_fotos()', 1000);
	}
}

function monta_last_cadastros(codigo_exec){
	clearTimeout(timer_cadastros);
	if(codigo_exec) eval(codigo_exec);
	var preferencia = getCookie('prefLC');
	var preferencia_limit = getCookie('prefLimitC');
	if(preferencia_limit == null) preferencia_limit = 10;
	if(last_cadastros.length){
		if(document.getElementById('corpoLastCadastros') == null){
			var html = monta_bloco('LastCadastros');
			get('boxD').innerHTML += "<br />"+html;
			get('tituloLastCadastros').innerHTML = "<p>FlogMe<br>novos cadastros</p>";
			get('corpoLastCadastros').className  = "fotosLaterais";
		}
		var html = '';
		if(preferencia != 1){
			if(preferencia_limit > last_cadastros.length) preferencia_limit = last_cadastros.length;
			if(preferencia == 2){
				html += "<a href='javascript:;' onClick='set_last(\"prefLC\",\"0\",\"monta_last_cadastros();\");'><img title='Exibir Somente Texto' src='"+url_static_img+"btn_text.gif' style='margin-right: 3px;'></a>";
			} else {
				html += "<a href='javascript:;' onClick='set_last(\"prefLC\",\"2\",\"monta_last_cadastros();\");'><img title='Exibir Texto e Foto do usuário' src='"+url_static_img+"btn_imagem.gif' style='margin-right: 3px;'></a>";
			}
			html += "<a href='javascript:;' onClick='set_last(\"prefLimitC\",\"prompt\",\"monta_last_cadastros();\", "+preferencia_limit+");'><img title='Configure o número de novos cadastros exibidos' src='"+url_static_img+"btn_limit.gif' style='margin-right: 3px;'></a>";
			html += "<a href='javascript:;' onClick='get_url(\"/conector.php?acao=last_cadastros\",\"monta_last_cadastros\");get(\"img_update_last_cadastros\").src=\""+url_static_img+"btn_update_loading.gif\"; return false;'><img id='img_update_last_cadastros' title='Atualizar novos cadastros' src='"+url_static_img+"btn_update.gif' style='margin-right: 3px;'></a>";
			html += "<a href='javascript:;' onClick='set_last(\"prefLC\",\"1\",\"monta_last_cadastros();\");'><img title='Não Exibir Novos Cadastros' src='"+url_static_img+"btn_cancel.gif' style='margin-right: 3px;'></a>";
			if(codigo_exec){
				var d = new Date();
				html += "<div style='font-size: 10px;'>atualizado em<br>"+(d.getHours() < 10 ? '0'+d.getHours() : d.getHours())+":"+(d.getMinutes() < 10 ? '0'+d.getMinutes() : d.getMinutes())+":"+(d.getSeconds() < 10 ? '0'+d.getSeconds() : d.getSeconds())+"</div>";	
			}
			html += "<hr height='1px' />";
			for(x=0; x<preferencia_limit; x++){
				html += '<a href="http://'+last_cadastros[x]['login']+'.'+dominio+'/">';
				if(preferencia == 2){
					html += '<img border=0 src="'+last_cadastros[x]['url_thumb']+'"><br />';				
				}
				html += unescape(last_cadastros[x]['apelido'])+'</a><br />';
			}
		} else {
			html += "<a href='javascript:;' onClick='set_last(\"prefLC\",\"0\",\"monta_last_cadastros();\");'><img title='Exibir Últimos Cadastros' src='"+url_static_img+"btn_text.gif' style='margin-right: 3px;'></a>";
		}
		get('corpoLastCadastros').innerHTML = html;
	} else {
		timer_cadastros = setTimeout('monta_last_cadastros()', 1000);
	}
}

function set_last(nome_cookie,valor_cookie,funcao_retorno,valor_atual){
	if(valor_cookie == 'prompt'){
		pergunta_div(50);
		valor_cookie = prompt("Qual o número a ser exibido? (de 1 até 25)", valor_atual);
		remove_pergunta();
		valor_cookie = parseInt(valor_cookie);
		if(valor_cookie < 1 || valor_cookie > 25 || isNaN(valor_cookie)) valor_cookie = 10;
	}
	
	setCookie(nome_cookie, valor_cookie, 'Thursday, September 15, 2010 GMT', '/', dominio);
	eval(funcao_retorno);
}

/**********************
		Tools
***********************/
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";var chr1, chr2, chr3;var enc1, enc2, enc3, enc4;var i = 0;
   do {
		chr1 = input.charCodeAt(i++);chr2 = input.charCodeAt(i++);chr3 = input.charCodeAt(i++);
		enc1 = chr1 >> 2;enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);enc4 = chr3 & 63;
		if (isNaN(chr2)) {enc3 = enc4 = 64;} else if (isNaN(chr3)) {enc4 = 64;}
		output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
		keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   return output;
}

function decode64(input) {
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;
	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
	do {
	  enc1 = keyStr.indexOf(input.charAt(i++));enc2 = keyStr.indexOf(input.charAt(i++));enc3 = keyStr.indexOf(input.charAt(i++));enc4 = keyStr.indexOf(input.charAt(i++));
	  chr1 = (enc1 << 2) | (enc2 >> 4);chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);chr3 = ((enc3 & 3) << 6) | enc4;output = output + String.fromCharCode(chr1);
	  if (enc3 != 64) {output = output + String.fromCharCode(chr2);}
	  if (enc4 != 64) {output = output + String.fromCharCode(chr3);}
	} while (i < input.length);
	return output;
}

function randArray(queridaArray) {
  var i = queridaArray.length;
  if ( i == 0 ) return false;
  while ( --i ) {
     var j = Math.floor( Math.random() * ( i + 1 ) );
     var tempi = queridaArray[i];
     var tempj = queridaArray[j];
     queridaArray[i] = tempj;
     queridaArray[j] = tempi;
   }
}

function setCookie(name, value, expires, path, domain, secure){
    document.cookie= name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name){
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1){
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1){
        end = dc.length;
	}
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain){
    if (getCookie(name)){
        document.cookie = name + "=" + 
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


/***************************************************/
function includeJS(elementoDestino, url_include){
	novoElemento = document.createElement("SCRIPT");
	novoElemento.setAttribute('src',		url_include);
	novoElemento.setAttribute('type',		'text/javascript');
	novoElemento.setAttribute('language',	'javascript');
	get(elementoDestino).appendChild(novoElemento);
}

function addFotoRevelacao(url_Foto, expiracao){
	revelacao_foto = [url_Foto, expiracao];
	if(typeof(revelacao) != 'object'){
		includeJS();
	} else {
		revelacao.interfaceUp();
		revelacao.addFoto(url_Foto, expiracao);
	}
}

/**************************************************/
function paginador(){
	this.titulo 		= '';
	this.total_elementos= '';
	this.total_paginas	= '';
	this.pagina_atual	= '';
	this.pagina_store	= {};
	this.array_elementos= [];
	
	this.configura		= function(titulo, arraySrc, totPorPagina){
		this.titulo 		 = titulo;
		this.pagina_atual 	 = (typeof(this.pagina_store[this.titulo]) == 'undefined') ? 1 : this.pagina_store[this.titulo];
		this.array_elementos = arraySrc;
		this.total_elementos = this.array_elementos.length;
		this.totPorPagina	 = (typeof(totPorPagina) == 'undefined') ? 12 : totPorPagina;
		this.total_paginas	 = Math.ceil(this.total_elementos / this.totPorPagina);
		n_foto_atual		 = 0;
		this.monta_html();
	}
	
	this.monta_html		= function(){
		get('tituloFoto').innerHTML = 'página '+this.pagina_atual+' de '+this.total_paginas+" - "+this.total_elementos+" "+this.titulo+((this.total_elementos>1) ? 's' : '');

		/* Tabela */
		html = '<table width=540 align=center>'+
		'<tr><td width="33%" align="center">'+((this.pagina_atual > 1) ? "<a href='javascript:;' onClick='objPaginador.anterior(); return false;' style='font-size: 10px;'><img src='"+url_static_img+"anterior.gif' border=0 align=absmiddle> anterior</a>" : "")+'</td><td width="33%"></td><td width="33%" align="center">'+((this.pagina_atual < this.total_paginas) ?  "<a style='font-size: 10px;' href='javascript:;' onClick='objPaginador.proxima(); return false;'>próxima <img src='"+url_static_img+"proxima.gif' border=0 align=absmiddle></a>"  : '')+'</td></tr>'+
		'<tr><td colspan=3 id="tdTodas"></td></tr>'+
		'<tr><td width="33%" align="center">'+((this.pagina_atual > 1) ? "<a href='javascript:;' onClick='objPaginador.anterior(); return false;' style='font-size: 10px;'><img src='"+url_static_img+"anterior.gif' border=0 align=absmiddle> anterior</a>" : "")+'</td><td width="33%" style="font-size: 10px;" align=center>página '+this.pagina_atual+' de '+this.total_paginas+'</td><td width="33%" align="center">'+((this.pagina_atual < this.total_paginas) ?  "<a style='font-size: 10px;' href='javascript:;' onClick='objPaginador.proxima(); return false;'>próxima <img src='"+url_static_img+"proxima.gif' border=0 align=absmiddle></a>"  : '')+'</td></tr>'+
		'</table>';
		get('corpoFoto').innerHTML = html;
		html = '';
		/* for elementos */
		if(this.total_elementos){
			for(i=((this.pagina_atual-1)*this.totPorPagina);i<( (this.pagina_atual == this.total_paginas) ? (this.total_elementos) : (this.pagina_atual*this.totPorPagina) );i++){
				html += this.trataElemento(this.array_elementos[i]);
			}
		}
		get('tdTodas').innerHTML 			= "<div style='float: right;'><div id='img_loading'><img src='"+url_static_img+"loading_circulo3.gif'><br>carregando</div></div>"+html;
		get('meioComentario').style.display = 'none';
		get('boxComentario').innerHTML 		= ''; 
	}
	
	this.proxima		= function(){
		if(this.pagina_atual < this.total_paginas) {
			this.pagina_atual++;
			this.pagina_store[this.titulo] = this.pagina_atual;
			this.monta_html();
		}
	}

	this.anterior		= function(){
		if(this.pagina_atual > 1) {
			this.pagina_atual--;
			this.pagina_store[this.titulo] = this.pagina_atual;
			this.monta_html();
		}

	}
	
	this.trataElemento  = function(elementoSwitch){
		switch(this.titulo){
			case 'favorito': 
				return "<div class='thumbTodas' style='border: 1px outset "+n_bg_down+"; cursor: pointer;' onMouseOver='this.style.border=\"1px solid "+n_bg_down+"\";' onMouseOut='this.style.border=\"1px outset "+n_bg_down+"\";'>" + 
					"<div style='height: 100px; overflow:hidden;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'><img src='"+elementoSwitch['url_thumb']+"' onLoad='ajustaThumb(this);' /></a></div>" +
					"<div style='font-size: 11px; font-weight: bolder; height: 14px; line-height:14px; overflow:hidden;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'>"+unescape(elementoSwitch['apelido']) + "</a></div>"+
					"<div style='font-size: 9px;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'>"+unescape(elementoSwitch['dthr'])+ "</a></div>" +
					"</div>\n";	
			break;
			
			case 'visitas recebidas':
				return "<div class='thumbTodas' style=' height: 159px; border: 1px outset "+n_bg_down+"; cursor: pointer;' onMouseOver='this.style.border=\"1px solid "+n_bg_down+"\";' onMouseOut='this.style.border=\"1px outset "+n_bg_down+"\";'>" + 
					"<div style='height: 100px; overflow:hidden;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'><img src='"+elementoSwitch['url_thumb']+"' onLoad='ajustaThumb(this);' /></a></div>" +
					"<div style='font-size: 11px; font-weight: bolder; height: 14px; line-height:14px; overflow:hidden;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'>"+unescape(elementoSwitch['apelido']) + "</a></div>"+
					"<div style='font-size: 9px;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'> Visitou em: <br>"+unescape(elementoSwitch['dthr'])+ "</a></div>" +
					"<div style='font-size: 9px;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'> Comentou: "+((elementoSwitch['comentou'] == '1') ? 'Sim' : 'Não')+ "</a></div>" +
					"</div>\n";
			break;

			case 'visitas efetuadas':
				return "<div class='thumbTodas' style=' height: 159px; border: 1px outset "+n_bg_down+"; cursor: pointer;' onMouseOver='this.style.border=\"1px solid "+n_bg_down+"\";' onMouseOut='this.style.border=\"1px outset "+n_bg_down+"\";'>" + 
					"<div style='height: 100px; overflow:hidden;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'><img src='"+elementoSwitch['url_thumb']+"' onLoad='ajustaThumb(this);' /></a></div>" +
					"<div style='font-size: 11px; font-weight: bolder; height: 14px; line-height:14px; overflow:hidden;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'>"+unescape(elementoSwitch['apelido']) + "</a></div>"+
					"<div style='font-size: 9px;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'> Visitou em: <br>"+unescape(elementoSwitch['dthr'])+ "</a></div>" +
					"<div style='font-size: 9px;'><a href='http://"+elementoSwitch['login']+".flogme.com.br'> Comentou: "+((elementoSwitch['comentou'] == '1') ? 'Sim' : 'Não')+ "</a></div>" +
					"</div>\n";
			break;

			default:
				return "<div class='thumbTodas' style='border: 1px outset "+n_bg_down+"; cursor: pointer;' onMouseOver='this.style.border=\"1px solid "+n_bg_down+"\";' onMouseOut='this.style.border=\"1px outset "+n_bg_down+"\";'>" + 
					"<div style='height: 100px; overflow:hidden;'><a href='/?id_foto="+elementoSwitch['id_foto']+"' onClick='ver_foto("+elementoSwitch['id_foto']+"); return false;'><img src='"+elementoSwitch['thumb_url']+"' onLoad='ajustaThumb(this);' /></a></div>" +
					"<div style='font-size: 11px; font-weight: bolder; height: 14px; line-height:14px; overflow:hidden;'><a href='/?id_foto="+elementoSwitch['id_foto']+"' onClick='ver_foto("+elementoSwitch['id_foto']+"); return false;'>"+unescape(elementoSwitch['titulo']) + "</a></div>"+
					"<div style='font-size: 9px;'><a href='/?id_foto="+elementoSwitch['id_foto']+"' onClick='ver_foto("+elementoSwitch['id_foto']+"); return false;'>"+unescape(elementoSwitch['dthr'])+ "</a></div>" +
					"</div>\n";
			break;
		}
	}
}

var objPaginador = new paginador();

if(!IE){
	document.captureEvents(Event.ONCONTEXTMENU);
	document.captureEvents(Event.MOUSEMOVE);
	document.captureEvents(Event.KEYPRESS);
}

function anti_ps(){
	if(from_url != 'http://totoro.'+dominio){
		var msg_ps = 'Acesse: http://'+dominio_user;
		if(IE){
			Copied = textPS.createTextRange();
			Copied.execCommand("Copy");
			setTimeout('anti_ps()', 333); 
		} else {
			setClipboardFF(msg_ps);
			setTimeout('anti_ps()', 1000); 
		}
	}
}

function mais_foto(id_foto){
	tabelaMI = get('tableMaisInfo');
	tabelaMI.style.display = (tabelaMI.style.display == 'none') ? 'block' : 'none';
}

/*
	Popula Anuncios do Google
*/
var timerADS = '';
function populaADS(){
	clearTimeout(timerADS);
	
}

/*
	Para maiores de idade
*/
function soudemaior(){
	setCookie('soumaiordeidade', '1', 'Thursday, September 15, 2010 GMT', '/', dominio);
	window.location = 'http://'+dominio+'?'+Math.random();
}

/*
	Set ClipBoard
*/
function setClipboardFF(text){
	var url = [
		'data:text/html;charset=utf-8;base64,PGJvZHk+PC9ib2','R5PjxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0Ij4KKGZ1','bmN0aW9uKGVuY29kZWQpe3ZhciBzd2ZfZGF0YSA9IFsKICdkYX','RhOmFwcGxpY2F0aW9uL3gtc2hvY2t3YXZlLWZsYXNoO2Jhc2U2',
		'NCxRMWRUQjJ3JywKICdBQUFCNG5EUGdZbGpBd01qSTRNejAlMk','YlMkY5JTJGZTJaZkJnYUdhV3dNRE1uNUthJywKICdrTU10TjRH','ZGdaZ1NJTXdaWEZKYW01UUFFJTJCQm9iaTFCTG5uTXlDcFB6RW',
		'9oU0dJJywKICdQRnAlMkZBeHNEREJRa3BGWkRGUUZGQ2d1eVM4','QXlqSTRBRVVCaXkwVndBJTNEJTNEJwpdLmpvaW4oIiIpOwpkb2','N1bWVudC5ib2R5LmlubmVySFRNTCA9IFsKICc8ZW1iZWQgc3Jj',
		'PSInLHN3Zl9kYXRhLCciICcsCiAnRmxhc2hWYXJzPSJjb2RlPS','csZW5jb2RlZCwnIj4nLAogJzwvZW1iZWQ+JwpdLmpvaW4oIiIp','Owp9KSgi',
		base64encode( encodeURIComponent(text) + '")</'+'script>')
	].join("");
	var tmp = document.createElement("div");
	tmp.innerHTML = [
		 '<iframe src="',url,'"'
		,' width="0" height="0">'
		,'</iframe>'
	].join("");
	with(tmp.style){
		position ="absolute";left = "-10px";top  = "-10px";visibility = "hidden";
	};
	document.body.appendChild(tmp);
	setTimeout(function(){document.body.removeChild(tmp)}, 500);
}

function base64encode(str){
	var Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");
	var c1, c2, c3;
	var buf = [];
	var len = str.length;
	var i = 0;
	while(i < len){
		c1 = str.charCodeAt(i) & 0xff;
		c2 = str.charCodeAt(i+1);
		c3 = str.charCodeAt(i+2);
		buf.push(Chars[(c1 >> 2)]);
		if(i+1 == len){
			buf.push(Chars[(c1 & 0x3) << 4],"==");
			break;
		}
		buf.push(Chars[((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)]);
		if(i+2 == len){
			buf.push(Chars[(c2 & 0xF) << 2],"=");
			break;
		}
		buf.push(
			Chars[((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)],
			Chars[(c3 & 0x3F)]
		);
		i+=3;
	}
	return buf.join("")
}
