// JavaScript Document
caminho_template = "08";
var attribCorOnline;
var srcImageCorOnline;

$(document).ready(function(){
	$('span[identifier=fb]:first').remove();
	if ($('.banners').height() < 10) $('.banners').remove();
	
	$('div[thumb_lanc=1]').click(function(){
		var f = $(this).attr('src').replace('t_','');
		mostraFotoLancamento(f);
	}).mouseover(function(){
		$(this).addClass('corBordaSite1');
	}).mouseout(function(){
		$(this).removeClass('corBordaSite1');
	}).css('cursor','pointer');
	
	$('body').append('<script id="scriptTagCorretorOnline" src="' + attribCorOnline + '"></script>');
	
	setTimeout('intChat()',1000);
});

function intChat() {
	if (srcImageCorOnline) {
		var imgTag = retorna_banner();
		$('#divRecebeScriptCorOnline').prepend('<div attrib="imobex">' + imgTag + '</div>');
	}else{
		setTimeout('intChat()',1000);
	}
}

function tempOnLoad() {
	if (document.getElementById('frameBannersChilds') && document.getElementById('frameBanners')) {
		if (document.getElementById('frameBannersChilds').innerHTML.length > 1) {
			document.getElementById('frameBanners').style.display = "";
		}
	}
}
function pesquisaSelecionaCombo(sItem,input) {
	if (sItem.className == "pesquisaPaginasComboItem") {
		input.checked = true;
		sItem.className = "pesquisaPaginasComboItemOn corSite1 corFonte2";
	}else{
		input.checked = false;
		sItem.className = "pesquisaPaginasComboItem";
	}
}

function enviaEscolheBairro(cod,tipo,cliente,caminho,msg) {
	if (tipo == "imo") {
		document.getElementById('recebe_cd_bairro').innerHTML = "<div style='margin:3px'>"+msg+"...</div>";
	}else{
		document.getElementById('recebe_cd_bairro_lanc').innerHTML = "<div style='margin:3px'>"+msg+"...</div>";
	}
	xajax_escolheBairro(cod,tipo,cliente,caminho);
}

function trocaAbaPesquisa(tipo) {
	if (tipo == "I") {
		document.getElementById('pesquisaImoveisEsc').style.display = '';
		document.getElementById('pesquisaLancamentosEsc').style.display = 'none';
		document.getElementById('abaPesquisaImoveis').className = 'abasPesquisaOn';
		document.getElementById('abaPesquisaLanc').className = 'abasPesquisaOff';
		document.getElementById('abaPesquisaImoveis').src = 'templates/'+caminho_template+'/'+idioma+'/img/aba_imoveis_on.png';
		document.getElementById('abaPesquisaLanc').src = 'templates/'+caminho_template+'/'+idioma+'/img/aba_lanc_off.png';
	}else{
		document.getElementById('pesquisaImoveisEsc').style.display = 'none';
		document.getElementById('pesquisaLancamentosEsc').style.display = '';
		document.getElementById('abaPesquisaImoveis').className = 'abasPesquisaOff';
		document.getElementById('abaPesquisaLanc').className = 'abasPesquisaOn';
		document.getElementById('abaPesquisaImoveis').src = 'templates/'+caminho_template+'/'+idioma+'/img/aba_imoveis_off.png';
		document.getElementById('abaPesquisaLanc').src = 'templates/'+caminho_template+'/'+idioma+'/img/aba_lanc_on.png';
	}
	document.getElementById('tipoPesq').value = tipo;
}

function trocaTransacaoPesquisa(valor,caminho) {
	document.getElementById('pesquisaTransacoesTexto1').className = "pesquisaTransacoesTexto";
	document.getElementById('pesquisaTransacoesTexto2').className = "pesquisaTransacoesTexto";
	document.getElementById('pesquisaTransacoesTexto3').className = "pesquisaTransacoesTexto";
	document.getElementById('pesquisaTransacoesTexto'+valor).className = "pesquisaTransacoesTextoOn";
	document.getElementById('selectFaixaPreco').style.visibility='hidden';
	xajax_faixaPreco(valor,caminho);
}

function verifica_pesquisa() {
	var tipo = document.getElementById('tipoPesq').value;
	if (tipo == "I") {
		var texto = document.getElementById('cd_referencia').value;
		if (texto != "") {
			document.getElementById('tipoPesqI').value = "ref";
			document.fpesc.submit();
		}else{
			document.getElementById('tipoPesqI').value = "";
			document.fpesc.submit();
		}
	}else{
		document.fpesc.submit();
	}
}

function enviaSolicite() {
	document.getElementById('detalhesSoliciteDados').style.visibility = "hidden";
	var objForm = document.getElementById('formSolicite');
	var formElements = objForm.elements;
	var concatValues = "";
	
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	
	for( var i=0; i < formElements.length; i++)
	{
		var name = formElements[i].name;
		if (name)
		{
			if(formElements[i].type=='select-multiple')
			{
				for (var j = 0; j < formElements[i].length; j++)
				{
					if (formElements[i].options[j].selected == true)
						concatValues += name+"="+encodeURI(formElements[i].options[j].value)+"###";
				}
			}
			else
			{
				if (formElements[i].type=='radio')
				{
					if (formElements[i].checked == true)
						concatValues += name+"="+encodeURI(formElements[i].value)+"###";
				}
				else
				{
					concatValues += name+"="+encodeURI(formElements[i].value)+"###";
				}
			}
		} 
	}
	
	xajax_enviaSoliciteInformacoes(concatValues);
	
}

function enviaEnviarAmigo() {
	document.getElementById('detalhesEnviarAmigoDados').style.visibility = "hidden";
	document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "";
	var objForm = document.getElementById('formEnviarAmigo');
	var formElements = objForm.elements;
	var concatValues = "";
	
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	
	for( var i=0; i < formElements.length; i++)
	{
		var name = formElements[i].name;
		if (name)
		{
			if(formElements[i].type=='select-multiple')
			{
				for (var j = 0; j < formElements[i].length; j++)
				{
					if (formElements[i].options[j].selected == true)
						concatValues += name+"="+encodeURI(formElements[i].options[j].value)+"###";
				}
			}
			else
			{
				if (formElements[i].type=='radio')
				{
					if (formElements[i].checked == true)
						concatValues += name+"="+encodeURI(formElements[i].value)+"###";
				}
				else
				{
					concatValues += name+"="+encodeURI(formElements[i].value)+"###";
				}
			}
		} 
	}
	
	xajax_enviaEnviarParaAmigo(concatValues);
	
}

function enviaFinanciamento() {
	document.getElementById('financiamentoFormFrame').style.display = "none";
	document.getElementById('financiamentoRetorno').style.display = "";
	var objForm = document.getElementById('formFinanciamento');
	var formElements = objForm.elements;
	var concatValues = "";
	
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	
	for( var i=0; i < formElements.length; i++)
	{
		var name = formElements[i].name;
		if (name)
		{
			if(formElements[i].type=='select-multiple')
			{
				for (var j = 0; j < formElements[i].length; j++)
				{
					if (formElements[i].options[j].selected == true)
						concatValues += name+"="+encodeURI(formElements[i].options[j].value)+"###";
				}
			}
			else
			{
				if (formElements[i].type=='radio')
				{
					if (formElements[i].checked == true)
						concatValues += name+"="+encodeURI(formElements[i].value)+"###";
				}
				else
				{
					concatValues += name+"="+encodeURI(formElements[i].value)+"###";
				}
			}
		} 
	}
	
	xajax_enviaFinanciamento(concatValues);
	
}

function some(elem) {
	document.getElementById(elem).style.display = "none";
}

function returnElementPosition(elem) {
	if (elem) {
		var left = elem.offsetLeft;
		var top = elem.offsetTop;
		var handlerElem = elem.offsetParent;
		while (handlerElem) {
			left += handlerElem.offsetLeft;
			top += handlerElem.offsetTop;
			handlerElem = handlerElem.offsetParent;
		}
	}
	
	var retorno = new Array();
	retorno[0] = left;
	retorno[1] = top;
	
	return retorno;
}

function abreComboSecoes() {
	
	mouseOutComboSecoes = 1;
	taFechandoComboSecoes = 0;
	
	var left = $('#topoItemMaisPaginas').position().left;
	var top = $('#frameCabecalho').position().top;
	
	$('#topoComboMaisPaginas').css('left',left);
	$('#topoComboMaisPaginas').css('top',top);
	$('#topoComboMaisPaginas').slideDown(350);
	
}

var hand = $('<div></div>');

var mouseOutComboSecoes = 0;
var taFechandoComboSecoes = 1;
function fechaComboSecoes() {
	if (mouseOutComboSecoes == 0 && taFechandoComboSecoes == 0) {
		taFechandoComboSecoes = 1;
		$('#topoComboMaisPaginas').slideUp(100);
	}
}

function verificaMouseOut() {
	mouseOutComboSecoes = 0;
	setTimeout("fechaComboSecoes()",1000);
}

function topoComboMouseOver(obj) {
	mouseOutComboSecoes = 1;
	obj.className = "topoComboItemOn corSite1 corFonte1";
}

function topoComboMouseOut(obj) {
	obj.className = "topoComboItemOff";
}

function abreComboIdioma() {
	mouseOutComboIdioma = 1;
	var botao = document.getElementById('abaIdioma');
	var combo = document.getElementById('idiomaAbaCombo');
	var cabec = document.getElementById('frameCabecalho');

	var left = returnElementPosition(botao);
	var top = returnElementPosition(cabec);

	combo.style.display = "block";
	combo.style.left = left[0]+"px";
	combo.style.top = top[1]+"px";
}

var mouseOutComboIdioma = 0;
function fechaComboIdioma() {
	if (mouseOutComboIdioma == 0) {
		document.getElementById('idiomaAbaCombo').style.display = "none";
	}
}

function verificaMouseOutIdioma() {
	mouseOutComboIdioma = 0;
	setTimeout("fechaComboIdioma()",1000);
}

function change_detalhe(v,param) {
	var elemAtual = document.getElementById(v);
	var abas = new Array();
	abas[0] = "detalhesAbaGeral";
	abas[1] = "detalhesAbaFotos";
	abas[2] = "detalhesAbaVideo";
	abas[3] = "detalhesAbaLocalizacao";
	
	if (elemAtual.className == 'detalhesAbasOn' && v != "detalhesAbaGeral") {
		return true;
	}else{
		for(i=0;i<abas.length;i++) {
		//	document.getElementById(abas[i]).className = 'detalhesAbasOff ';
			$('#'+abas[i]).find('div').each( function() {
				$(this).removeClass('detalhesAbasOn');
				$(this).addClass('detalhesAbasOff');
				$(this).addClass('corSite1');
			//	$(this).addClass('corFonte1');
				$(this).css('background-position','0px 0px');
			});
		}
		
		$(elemAtual).find('div').each( function() {
			$(this).removeClass('corSite1');
		//	$(this).removeClass('corFonte1');
			$(this).removeClass('detalhesAbasOff');
			$(this).addClass('detalhesAbasOn');
			$(this).css('background-position','0px -33px');
		});
	//	elemAtual.className = 'detalhesAbasOn';
		
		jah(param,'detalhesRecebe');
	}
}

function change_detalhe_lanc(v,param) {
	var elemAtual = document.getElementById(v);
	var arrAbas = new Array();
	arrAbas[0] = "emp";
	arrAbas[1] = "uni";
	arrAbas[2] = "img";
	arrAbas[3] = "vid";
	arrAbas[4] = "map";
	
	for (i=0; i<arrAbas.length; i++) {
		document.getElementById("lancdetalhe_"+arrAbas[i]).className = 'detalhesAbasOff';
	}
	
	elemAtual.className = 'detalhesAbasOn';
		
	jah(param,'recebe_detalhe');
}

function destalhesLanc(valor,id) {
	if (valor != 0 && valor != "0") {
		window.location = "engine.php?id="+id+"&page=lancamento_detalhe&cd_lancamento="+valor;
	}
}

function rolaCalendarioDireita() {
	if (document.getElementById('calendarioInner').scrollLeft == 0) {
		var inicioTween = 0;
		var finalTween = 350;
		var tweenScroll = new Tween(document.getElementById('calendarioInner'),'scrollLeft',Tween.regularEaseOut,inicioTween,finalTween,0.5,'');
		tweenScroll.start();
	}
}

function rolaCalendarioEsquerda() {
	if (document.getElementById('calendarioInner').scrollLeft == 350) {
		var inicioTween = document.getElementById('calendarioInner').scrollLeft;
		var finalTween = 0;
		var tweenScroll = new Tween(document.getElementById('calendarioInner'),'scrollLeft',Tween.regularEaseOut,inicioTween,finalTween,0.5,'');
		tweenScroll.start();
	}
}

var intSlideFotos;
function slideFotos() {
	if (document.getElementById('detalhesFotosSlideBotao').style.backgroundPosition == "0px 0px") {
		slideFotosStop();
	}else{
		slideFotosStart();
	}
}

function slideFotosStart() {
	document.getElementById('detalhesFotosSlideBotao').style.backgroundPosition = "0px 0px";
	document.getElementById('detalhesFotosSlideProgress').style.display = "";
	document.getElementById('detalhesFotosSlideProgressBar').style.display = "";
	document.getElementById('detalhesFotosSlideProgressBar').style.height = "41px";
	intSlideFotos = setInterval("slideFotosProgress()",200);
}

function slideFotosStop() {
	clearInterval(intSlideFotos);
	document.getElementById('detalhesFotosSlideBotao').style.backgroundPosition = "0px -23px";
	document.getElementById('detalhesFotosSlideProgress').style.display = "none";
	document.getElementById('detalhesFotosSlideProgressBar').style.height = "41px";
}

function slideFotosInterval() {
	var count = foto_atual + 1;
	
	if (foto_detalhe.length > count) {
		var alturaThumb = 66;
		var posThumb = (count*alturaThumb)-(2*alturaThumb);
		document.getElementById('detalhesFotosThumbsFrame').scrollTop = posThumb;
		troca_foto_detalhes(count);
	}else{
		document.getElementById('detalhesFotosThumbsFrame').scrollTop = 0;
		troca_foto_detalhes(0);
	}
	
	document.getElementById('detalhesFotosSlideProgress').style.display = "";
	document.getElementById('detalhesFotosSlideProgressBar').style.display = "";
	document.getElementById('detalhesFotosSlideProgressBar').style.height = "41px";
	intSlideFotos = setInterval("slideFotosProgress()",250);
}

function slideFotosProgress() {
	var elem = document.getElementById('detalhesFotosSlideProgressBar');
	var atual = elem.offsetHeight;

	if (atual == 2) {
		elem.style.display = "none";
		clearInterval(intSlideFotos);
		slideFotosInterval();
	}else{
		var valor = atual-1;
		elem.style.height = valor+"px";
	}
}

function secaoMenuMouseOver(obj) {
	obj.style.backgroundPosition = "0px -30px";
}

function secaoMenuMouseOut(obj) {
	obj.style.backgroundPosition = "0px 0px";
}

function verTabelaUnid(unid,lanc,id) {
	$('object').css('visibility','hidden');
	$('body').attr('scroll','no').css('overflow','hidden');
	$('#cortinaPopup').show().height($('html').height()).css('opacity',0);
	$('#cortinaPopup').fadeTo('slow',0.5,function(){
		$('#popup').show();
		verificaPopup();
		jah('detlanc_uni_tab.php?lanc='+unid+'&unid='+unid+'&id='+id,'popup');
	});
}

function fechaTabelaUnid() {
	$('object').css('visibility','visible');
	$('body').attr('scroll','auto').css('overflow','auto');
	fechaPopup();
}

function deleteFavorito(cod,tipo,id) {
	var formContato = new Array();
	formContato[0] = "nome";
	formContato[1] = "email";
	formContato[2] = "ddd";
	formContato[3] = "telefone";
	formContato[4] = "mensagem";
	formContato[5] = "tipo_recebe_indiferente";
	formContato[6] = "tipo_recebe_email";
	formContato[7] = "tipo_recebe_telefone";
	
	var locacao = "del_favoritos.php?"; 
	
	if (tipo == "Empreendimento") {
		locacao += "cd_lancamento=";
	}else{
		locacao += "cd_imovel=";
	}
	
	locacao += cod;
	locacao += "&id="+id+"&page=contato&info=1";
	
	for (i=0;i<formContato.length;i++) {
		if (document.getElementById(formContato[i])) {
			if (document.getElementById(formContato[i]).type == "text") {
				locacao += "&"+formContato[i]+"="+encodeURIComponent(document.getElementById(formContato[i]).value);
			}
			if ((document.getElementById(formContato[i]).type == "checkbox" || document.getElementById(formContato[i]).type == "radio") && document.getElementById(formContato[i]).checked == true) {
				locacao += "&"+formContato[i]+"=checked";
			}
			if (formContato[i] == "mensagem") {
				locacao += "&"+formContato[i]+"="+encodeURIComponent(document.getElementById(formContato[i]).innerHTML);
			}
		}
	}
	
	window.location=locacao;
}

function validate_encomende() {
	var formEncomende = new Array();
	formEncomende[0] = "nome";
	formEncomende[1] = "email";
	formEncomende[2] = "ddd";
	formEncomende[3] = "telefone";
	formEncomende[4] = "mensagem";
	formEncomende[5] = "valor";
	
	var objForm = document.getElementById('formEncomende');
	var formElements = objForm.elements;
	
	var validaCheckbox = new Array();
	validaCheckbox['cd_negocio'] = false;
	validaCheckbox['cd_tipo'] = false;
	validaCheckbox['cd_bairro'] = false;
	
	for( var i=0; i < formElements.length; i++)
	{
		var name = formElements[i].name;
		var nameHandler = name.substring(0,name.length-2);
		if (name)
		{
			if (formElements[i].type == 'checkbox')
			{
				if (formElements[i].checked == true)
				{
					validaCheckbox[nameHandler] = true;
				}
			}
			if (formElements[i].type == 'text' || formElements[i].type == 'textarea')
			{
				if (formElements[i].name == "captcha")
				{
					var valoresPossiveis = "bcdfghjklmnpqrstvwxyz";
					var captcha = formElements[i].value;
					if ((captcha.length != 4)||(valoresPossiveis.indexOf(captcha.charAt(0))==-1)||(valoresPossiveis.indexOf(captcha.charAt(1))==-1)||(valoresPossiveis.indexOf(captcha.charAt(2))==-1)||(valoresPossiveis.indexOf(captcha.charAt(3))==-1))
					{
						alert('Digite as quatro consoantes da imagem no campo de validação!');
						formElements[i].focus();
						return false;
					}
				}
				else
				{
					if (formElements[i].value == "")
					{
						alert('Preencha corretamente os campos obrigatórios!');
						formElements[i].focus();
						return false;
					}
				}
			}
		}
	}
	
	if ( validaCheckbox['cd_negocio'] != true ) {
		alert('É necessário escolher pelo menos uma das opções de negociação');
		return false;
	}
	
	if ( validaCheckbox['cd_tipo'] != true ) {
		alert('É necessário escolher pelo menos uma das opções de tipos de imóvel');
		return false;
	}
	
	objForm.submit();
}

function validate_cadastre() {
	var formCadastre = new Array();
	formCadastre[0] = "cd_tipo_padrao";
	formCadastre[1] = "estado_imovel";
	formCadastre[2] = "cidade_imovel";
	formCadastre[3] = "bairro_imovel";
	formCadastre[4] = "nome";
	formCadastre[5] = "ddd";
	formCadastre[6] = "telefone";
	formCadastre[7] = "real_email";
	
	
	var objForm = document.getElementById('formCadastre');
	var formElements = objForm.elements;
	
	var validaCheckbox = new Array();
	validaCheckbox['cd_negocio'] = false;
	
	for( var i=0; i < formElements.length; i++)
	{
		var name = formElements[i].name;
		var nameHandler = name.substring(0,name.length-2);
		if (name)
		{
			if (formElements[i].type == 'checkbox')
			{
				if (formElements[i].checked == true)
				{
					validaCheckbox[nameHandler] = true;
				}
			}
			else
			{
				if (formElements[i].name == "captcha")
				{
					var valoresPossiveis = "bcdfghjklmnpqrstvwxyz";
					var captcha = formElements[i].value;
					if ((captcha.length != 4)||(valoresPossiveis.indexOf(captcha.charAt(0))==-1)||(valoresPossiveis.indexOf(captcha.charAt(1))==-1)||(valoresPossiveis.indexOf(captcha.charAt(2))==-1)||(valoresPossiveis.indexOf(captcha.charAt(3))==-1))
					{
						alert('Digite as quatro consoantes da imagem no campo de validação!');
						formElements[i].focus();
						return false;
					}
				}
				else
				{
					if (formElements[i].value == "" && formCadastre.in_array(name))
					{
						alert('Preencha corretamente os campos obrigatórios!');
						formElements[i].focus();
						return false;
					}
				}
			}
		}
	}
	
	if ( validaCheckbox['cd_negocio'] != true ) {
		alert('É necessário escolher pelo menos uma das opções de negociação');
		return false;
	}
	
	objForm.submit();
}

function selectBairroEncomende(cd_bairro,status) {
	var obj = document.getElementById("encomendeBairroItem"+cd_bairro);
	
	if (obj.className == "encomendeBairroItem") {
		obj.className = "encomendeBairroItemSelected";
	}else{
		obj.className = "encomendeBairroItem";
	}
}

Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}

function mostraFotoLancamento(f) {
	$('object').css('visibility','hidden');
	
	var fThumb = f.replace('lanc','t_lanc');
	var legendaAtual = '';
	var indiceAtual;
	$('div[thumb_lanc=1]').each(function(){
		if ($(this).attr('src') == fThumb) {
			indiceAtual = $(this).attr('indice');
			legendaAtual = $(this).attr('legenda');
		}
	});
	
	$('body').prepend('<div id="layerUp" style="display:none;"></div><div id="layerUpCortina"></div><div class="layerUpLegenda"><div>'+legendaAtual+'</div></div><div class="layerUpAbaFecha" title="Fechar" alt="Fechar"></div>').attr('scroll','no').css('overflow','hidden');
	
	if ($('div[thumb_lanc=1]').size() > 1) {
		$('body').prepend('<div class="layerUpNavegaLeft" title="Visualizar foto anterior" alt="Visualizar foto anterior"></div><div class="layerUpNavegaRight" title="Visualizar foto seguinte" alt="Visualizar foto seguinte"></div>');
	}
	
	$('.layerUpNavegaLeft,.layerUpNavegaRight,.layerUpLegenda,.layerUpAbaFecha').hide();
	
	$('#layerUpCortina').addClass('layerUpCortina').width($('html').width()).height($('html').height()).css('opacity',0).fadeTo('slow',.75);
	
	var l = $('body').width() / 2 - $('#layerUp').width() / 2;
	var t = $('#tamanhoTela').height() / 2 - $('#layerUp').height() / 2;
	
//	if(t < 0){t=0;$('#layerUp > img').attr('height',$('#tamanhoTela').height()-(2*$('#layerUp').css('padding')))}
	
	t += $('body').scrollTop();
	
	var flashObj = returnFlash($('div[thumb_lanc=1][indice='+indiceAtual+']').attr('w'),$('div[thumb_lanc=1][indice='+indiceAtual+']').attr('h'),'img.swf',$('div[thumb_lanc=1][indice='+indiceAtual+']').attr('fv'),'objFlashFotoLanc' + indiceAtual);
	
	$('#layerUp').addClass('layerUp').html(flashObj).css({left:l,top:t}).fadeIn();
	
	$('.layerUpAbaFecha').click(function(){
		$('#layerUp,#layerUpCortina,.layerUpNavegaLeft,.layerUpNavegaRight,.layerUpLegenda,.layerUpAbaFecha').remove();
		$('body').attr('scroll','auto').css('overflow','auto');
		$('object').css('visibility','visible');
	});
	
	$('.layerUpNavegaLeft').click(function(){
		$('.layerUpLegenda').hide();
		var velhaFoto = parseInt($('#layerUp > object').attr('id').replace('objFlashFotoLanc',''));
		fThumb = $('div[thumb_lanc=1][indice='+velhaFoto+']').attr('src');
		var novaFoto = '';
		if ($('div[thumb_lanc=1]:first').attr('src') == fThumb) {
			novaFoto = $('div[thumb_lanc=1]:last').attr('indice');
		}else{
			var handIndice = new Array();
			var posAtual;
			var i = 0;
			$('div[thumb_lanc=1]').each(function(){
				handIndice[i] = $(this).attr('indice');
				if ($(this).attr('src') == fThumb) posAtual = i;
				i++;
			});
			novaFoto = handIndice[posAtual - 1];
		}
		
		var novaLegenda = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('legenda');
		var novaFlashVars = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('fv');
		var novaW = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('w');
		var novaH = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('h');
		
		flashObj = returnFlash(novaW,novaH,'img.swf',novaFlashVars,'objFlashFotoLanc'+novaFoto);
		
		$('.layerUpLegenda').html('<div>'+novaLegenda+'</div>');
		
		$('#layerUp').html(flashObj);
		posicionaLayerUp(novaFoto);
	});
	
	$('.layerUpNavegaRight').click(function(){
		$('.layerUpLegenda').hide();
		var velhaFoto = parseInt($('#layerUp > object').attr('id').replace('objFlashFotoLanc',''));
		fThumb = $('div[thumb_lanc=1][indice='+velhaFoto+']').attr('src');
		var novaFoto = '';
		if ($('div[thumb_lanc=1]:last').attr('src') == fThumb) {
			novaFoto = $('div[thumb_lanc=1]:first').attr('indice');
		}else{
			var handIndice = new Array();
			var posAtual;
			var i = 0;
			$('div[thumb_lanc=1]').each(function(){
				handIndice[i] = $(this).attr('indice');
				if ($(this).attr('src') == fThumb) posAtual = i;
				i++;
			});
			novaFoto = handIndice[posAtual + 1];
		}
		
		var novaLegenda = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('legenda');
		var novaFlashVars = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('fv');
		var novaW = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('w');
		var novaH = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('h');
		
		flashObj = returnFlash(novaW,novaH,'img.swf',novaFlashVars,'objFlashFotoLanc'+novaFoto);
		
		$('.layerUpLegenda').html('<div>'+novaLegenda+'</div>');
		
		$('#layerUp').html(flashObj);
		posicionaLayerUp(novaFoto);
	});
	
	posicionaLayerUp(indiceAtual);
	
}

function posicionaLayerUp(par_indice) {
	var newWidth = parseInt($('div[thumb_lanc=1][indice='+par_indice+']').attr('w'));
	var newHeight = parseInt($('div[thumb_lanc=1][indice='+par_indice+']').attr('h'));
	
	$('.layerUpNavegaLeft,.layerUpNavegaRight,.layerUpLegenda,.layerUpAbaFecha').hide();
	$('#layerUp').animate({'width':newWidth+10},250,function(){
		$('#layerUp').animate({'height':newHeight+10},250,function(){
			var l = $('body').width() / 2 - $('#layerUp').width() / 2;
			var t = $('#tamanhoTela').height() / 2 - $('#layerUp').height() / 2;
			t += $('body').scrollTop();
			$('#layerUp').animate({left:l,top:t},200,function(){
				var ll = l-$('.layerUpNavegaLeft').width();
				var tl = $('#tamanhoTela').height() / 2 - $('.layerUpNavegaLeft').height() / 2;
				$('.layerUpNavegaLeft').css({left:ll,top:tl+$('body').scrollTop()});
				var lr = l+$('#layerUp').width();
				var tr = $('#tamanhoTela').height() / 2 - $('.layerUpNavegaRight').height() / 2;
				$('.layerUpNavegaRight').css({left:lr,top:tr+$('body').scrollTop()});
				var tleg = $('#layerUp').height() + t;
				$('.layerUpLegenda').width($('#layerUp').width()).css({left:l,top:tleg});
				$('.layerUpAbaFecha').css({left:lr,top:t});
				
				$('.layerUpNavegaLeft,.layerUpNavegaRight,.layerUpAbaFecha').show();
				if ($('.layerUpLegenda > div').html() != '' && $('.layerUpLegenda > div').html() != 'undefined') $('.layerUpLegenda').show();
			});
		});
	});
}

function mostraFavoritos() {
	if (window.parent.document.getElementById('boxFavoritos'))
		window.parent.document.getElementById('boxFavoritos').style.display = "";
}

function mostraIndicadores() {
	document.getElementById('boxIndicadores').style.display = "";
}

function mostraClima() {
	document.getElementById('boxClimatempo').style.display = "";
}