// JavaScript Document
caminho_template = "10";

// INCLUDES
$(document).ready(function(){
	$('<script language="javascript" type="text/javascript" src="templates/'+caminho_template+'/js/jquery.colorbox.js"></script>').appendTo('head');
	$('<script language="javascript" type="text/javascript" src="templates/'+caminho_template+'/js/jquery.fancybox.js"></script>').appendTo('head');
	
});

$(document).ready(function(){
	
	$('<script language="javascript" type="text/javascript" src="templates/'+caminho_template+'/js/script.js"></script>').appendTo('head');
	
	$("ul.tabs li").hover(function() {
		$(this).css("color","red");
	});
	
	//$("a[rel='example1']").colorbox();
	$(".fancybox").fancybox({
		prevEffect		: 'none',
		nextEffect		: 'none',
		helpers		: { 
			title	: { type : 'inside' }
		}
	});

	$("a.openTable").colorbox();
		
	if($(".indicadorItem").val() == undefined){
		$(".indicadores").css("display","none");
	}
	/**
	 * Rolagem na paginação IMÓVEIS - venda, aluguel, temporada
	 */
	$('.listarMaisButton').click(function(event){
		$('html,body').animate({scrollTop: $('.itemDestaque:last').offset().top}, 3000);
	});
	/**
	 * Rolagem na paginação EMPREENDIMENTOS
	 */
	$('.listarMaisButtonEmp').click(function(event){
		$('html,body').animate({scroll: $('.itemDestaqueEmp:last').offset().top}, 3000);
	});
	
	
	$('span[identifier=fb]:first').remove();
	if ($('.banners').height() < 10) $('.banners').remove();
	
	$('div[thumb_imo=1]').click(function(){
		var f = $(this).attr('src').replace('t_','');
		mostraFoto(f);
	}).mouseover(function(){
		$(this).addClass('corBordaSite1');
	}).mouseout(function(){
		$(this).removeClass('corBordaSite1');
	}).css('cursor','pointer');

	$('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');
	
	if ($('#capaDestaqueImoveis').size() > 0) {
		$('#itensDestaqueVenda').find('[value_type=venda]').show();
		$('#itensDestaqueLocacao').find('[value_type=locacao]').show();
		$('#itensDestaqueTemporada').find('[value_type=temporada]').show();
		
		var totSizeVenda = 0;
		$('#itensDestaqueVenda>.imovelItem').each(function(){
			totSizeVenda += parseInt($(this).width());
			totSizeVenda += parseInt($(this).css('margin-left'));
		});
		$('#itensDestaqueVenda').width(totSizeVenda);
		var totPagVenda = Math.ceil($('#itensDestaqueVenda>.imovelItem').size() / 3);
		$('#itensDestaqueVenda').attr('totPag',totPagVenda);
		for (i=1;i<=totPagVenda;i++) {
			var handOn = i==1?'On':'';
			$('#paginacaoDestaqueImoveisVenda').append('<div class="navegacaoItem'+handOn+'" pag_imo="1">'+i+'</div>');
		}
		
		var totSizeLocacao = 0;
		$('#itensDestaqueLocacao>.imovelItem').each(function(){
			totSizeLocacao += parseInt($(this).width());
			totSizeLocacao += parseInt($(this).css('margin-left'));
		});
		$('#itensDestaqueLocacao').width(totSizeLocacao);
		var totPagLocacao = Math.ceil($('#itensDestaqueLocacao>.imovelItem').size() / 3);
		$('#itensDestaqueLocacao').attr('totPag',totPagLocacao);
		for (i=1;i<=totPagLocacao;i++) {
			var handOn = i==1?'On':'';
			$('#paginacaoDestaqueImoveisLocacao').append('<div class="navegacaoItem'+handOn+'" pag_imo="1">'+i+'</div>');
		}
		
		var totSizeTemporada = 0;
		$('#itensDestaqueTemporada>.imovelItem').each(function(){
			totSizeTemporada += parseInt($(this).width());
			totSizeTemporada += parseInt($(this).css('margin-left'));
		});
		$('#itensDestaqueTemporada').width(totSizeTemporada);
		var totPagTemporada = Math.ceil($('#itensDestaqueTemporada>.imovelItem').size() / 3);
		$('#itensDestaqueTemporada').attr('totPag',totPagTemporada);
		for (i=1;i<=totPagTemporada;i++) {
			var handOn = i==1?'On':'';
			$('#paginacaoDestaqueImoveisTemporada').append('<div class="navegacaoItem'+handOn+'" pag_imo="1">'+i+'</div>');
		}
		
		selectAbaDestaqueImovel($('#listaImoveisCategoria>.categoriaItem:visible:first').attr('aba_id'));
		
		$('#listaImoveisCategoria>.categoriaItem:visible').click(function(){
			selectAbaDestaqueImovel($(this).attr('aba_id'));
		});
		
		$('[pag_imo=1]').click(function(){
			var idHand = $(this).parent().attr('id').replace('paginacaoDestaqueImoveis','itensDestaque');
			if ($(this).hasClass('navegacaoItem') && $('#'+idHand).attr('animating') != 's') {
				$('#'+idHand).attr('animating','s');
				$('#'+$(this).parent().attr('id')+'>.navegacaoItemOn').removeClass('navegacaoItemOn').addClass('navegacaoItem');
				$(this).removeClass('navegacaoItem').addClass('navegacaoItemOn');
				var unitWidth = parseInt($('#'+idHand+'>.imovelItem:first').width()) + parseInt($('#'+idHand+'>.imovelItem:first').css('margin-left'));
				var multHand = (parseInt($(this).html()) - 1) * 3;
				var marginHand = -multHand*unitWidth;
				$('#'+idHand).animate({'marginLeft':marginHand},1000,function(){
					$(this).attr('animating','n');
				});
			}
		});
		
		$('#botaoBackDestaqueImovel').click(function(){
			if(parseInt($('#barraPaginacaoDestaqueImovel>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').html()) > 0){
				$('#barraPaginacaoDestaqueImovel>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').prev().click();
			}
		});
		$('#botaoNextDestaqueImovel').click(function(){
			var handPos = parseInt($('#barraPaginacaoDestaqueImovel>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').html()) + 1;
			var handNext = parseInt($('#barraPaginacaoDestaqueImovel>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').next().html());
			if (handPos == handNext) {
				$('#barraPaginacaoDestaqueImovel>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').next().click();
			}
		});
	}
	
	if ($('#capaDestaqueLanc').size() > 0) {
		
		for (j=1;j<=4;j++) {
			var totSize = 0;
			$('#itensDestaque'+j+'>.imovelItem').each(function(){
				totSize += parseInt($(this).width());
				totSize += parseInt($(this).css('margin-left'));
			});
			$('#itensDestaque'+j).width(totSize);
			var totPag = Math.ceil($('#itensDestaque'+j+'>.imovelItem').size() / 3);
			$('#itensDestaque'+j).attr('totPag',totPag);
			for (i=1;i<=totPag;i++) {
				var handOn = i==1?'On':'';
				$('#paginacaoDestaqueLanc'+j).append('<div class="navegacaoItem'+handOn+'" pag_lanc="1">'+i+'</div>');
			}
		}
		
		selectAbaDestaqueLanc($('#listaLancCategoria>.categoriaItem:visible:first').attr('aba_id'));
		
		$('#listaLancCategoria>.categoriaItem:visible').click(function(){
			selectAbaDestaqueLanc($(this).attr('aba_id'));
		});
		
		$('[pag_lanc=1]').click(function(){
			var idHand = $(this).parent().attr('id').replace('paginacaoDestaqueLanc','itensDestaque');
			if ($(this).hasClass('navegacaoItem') && $('#'+idHand).attr('animating') != 's') {
				$('#'+idHand).attr('animating','s');
				$('#'+$(this).parent().attr('id')+'>.navegacaoItemOn').removeClass('navegacaoItemOn').addClass('navegacaoItem');
				$(this).removeClass('navegacaoItem').addClass('navegacaoItemOn');
				var unitWidth = parseInt($('#'+idHand+'>.imovelItem:first').width()) + parseInt($('#'+idHand+'>.imovelItem:first').css('margin-left'));
				var multHand = (parseInt($(this).html()) - 1) * 3;
				var marginHand = -multHand*unitWidth;
				$('#'+idHand).animate({'marginLeft':marginHand},1000,function(){
					$(this).attr('animating','n');
				});
			}
		});
		
		$('#botaoBackDestaqueLanc').click(function(){
			if(parseInt($('#barraPaginacaoDestaqueLanc>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').html()) > 0){
				$('#barraPaginacaoDestaqueLanc>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').prev().click();
			}
		});
		$('#botaoNextDestaqueLanc').click(function(){
			var handPos = parseInt($('#barraPaginacaoDestaqueLanc>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').html()) + 1;
			var handNext = parseInt($('#barraPaginacaoDestaqueLanc>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').next().html());
			if (handPos == handNext) {
				$('#barraPaginacaoDestaqueLanc>.barraNavegacaoConteudo:visible').find('.navegacaoItemOn').next().click();
			}
		});
	}
});

function selectAbaDestaqueImovel(ident) {
	$('#listaImoveisCategoria>.categoriaItem').removeClass('corSite1 corFonte1');
	$('#listaImoveisCategoria>[aba_id='+ident+']').addClass('corSite1 corFonte1');
	$('#mostraImoveisItens>.itensDestaque').hide();
	$('#mostraImoveisItens>#itensDestaque'+ident).show();
	$('#barraPaginacaoDestaqueImovel>.barraNavegacaoConteudo').hide();
	$('#barraPaginacaoDestaqueImovel>#paginacaoDestaqueImoveis'+ident).show();
}

function selectAbaDestaqueLanc(ident) {
	$('#listaLancCategoria>.categoriaItem').removeClass('corSite1 corFonte1');
	$('#listaLancCategoria>[aba_id='+ident+']').addClass('corSite1 corFonte1');
	$('#mostraLancItens>.itensDestaque').hide();
	$('#mostraLancItens>#itensDestaque'+ident).show();
	$('#barraPaginacaoDestaqueLanc>.barraNavegacaoConteudo').hide();
	$('#barraPaginacaoDestaqueLanc>#paginacaoDestaqueLanc'+ident).show();
}

function paginacaoDestaque() {
}

function tempOnLoad() {
}

function pesquisaSelecionaCombo(sItem,input) {
	if (sItem.className == "pesquisaPaginasComboItem") {
		input.checked = true;
		sItem.className = "pesquisaPaginasComboItemOn corSite2 corFonte2";
	}else{
		input.checked = false;
		sItem.className = "pesquisaPaginasComboItem";
	}
}

function enviaEscolheBairro(cod,tipo,cliente,caminho,msg) {
	if (tipo == "imo") {
		document.getElementById('cd_bairro').innerHTML = "<option style='margin:3px'>"+msg+"...</option>";
	}else{
		document.getElementById('cd_bairro_lanc').innerHTML = "<option style='margin:3px'>"+msg+"...</option>";
	}
	xajax_escolheBairroSelect(cod,tipo,cliente,caminho);
}


function trocaAbaPesquisa(tipo) {
	// função apenas para trocar a aba da pesquisa
	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_minPreco(valor,caminho);
	xajax_maxPreco(valor,caminho);
}

function listarMais(t,tg)
{
	$('#listarMaisButton'+t).hide();
	$('#listarLoding'+t).show();
	xajax_listaMais(t,tg,'a');
}

function listarEvents(t)
{
	$('#listarMaisButton'+t).show();
	$('#listarLoding'+t).hide();
	getFlash();
}

function listarHiddenButton(t)
{
	$('#listarMaisButton'+t).hide();
}

function getFlash()
{
	$('.flSWF').each(function(){
		var swf = $(this).text();
		swf = swf.split(',');
		var obj = returnFlash(swf[0],swf[1],swf[2],swf[3]);
		$(this).parent().html(obj);
	});
}
function verifica_pesquisa(tp) {
	if (tp == "I") {
		var texto = document.getElementById('cd_referencia').value;
		if (texto != "") {
			document.getElementById("pageTarget").value = "resultado";
			document.getElementById('tipoPesqI').value = "ref";
			document.fpesc.submit();
		}else{
			document.getElementById('tipoPesqI').value = "";
			document.fpesc.submit();
		}
		//document.getElementById("pageTarget").value = "resultado";
		document.getElementById("tipoPesq").value = tp;
	}else{
		document.getElementById('tipoPesq').value = tp;
		document.getElementById('tipoPesqI').value = "";
		document.fpesc.submit();
	}
}

function concatFormValues(objForm) {
	var formElements = objForm.elements;
	var concatValues = "";
	
	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)+"###";
				}
			}
		} 
	}
	
	return concatValues;
}

function clearForm(objForm,objCaptcha) {
	var formElements = objForm.elements;
	
	for( var i=0; i < formElements.length; i++)
	{
		switch (formElements[i].type)
		{
			case 'hidden': break;
			case 'select-multiple':
				for (var j=0; j<formElements[i].length; j++) formElements[i].options[j].selected = false;
				formElements[i].options[0].selected = true;
				break;
			case 'radio':
			case 'checkbox':
				formElements[i].checked = false;
				break;
			default:
				formElements[i].value = '';
				break;
		}
	}
	
	if (objCaptcha) {
		objCaptcha.src = '';
		objCaptcha.src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
	}
}

function enviaSolicite() {
	//document.getElementById('detalhesSoliciteTopo').style.display = "none";
	document.getElementById('detalhesSoliciteInfo').style.display = "none";
	document.getElementById('detalhesSoliciteDados').style.display = "none";
	document.getElementById('detalhesSoliciteMsgErr2').style.display = "none";
	document.getElementById('detalhesSoliciteMsgOk').style.display = "none";
	document.getElementById('detalhesSoliciteDadosEnviando').style.display = "";

	var objForm = document.getElementById('formSolicite');
	var concatValues = concatFormValues(objForm);
	
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	xajax_enviaSoliciteInformacoes2(concatValues);
}

function detalhesSoliciteAjaxReturn(resp,tipo) {
	if (resp == 'tipo_err') {
		document.getElementById('detalhesSoliciteTopo').style.display = "";
		document.getElementById('detalhesSoliciteInfo').style.display = "";
		document.getElementById('detalhesSoliciteDados').style.display = "";
	}else{
		switch (resp)
		{
			case 'captcha_nok':
			case 'info_err':
			case 'email_err':
				//document.getElementById('detalhesSoliciteTopo').style.display = "";
				document.getElementById('detalhesSoliciteInfo').style.display = "";
				document.getElementById('detalhesSoliciteDados').style.display = "";
				document.getElementById('detalhesSoliciteMsgErr2').style.display = "";
				document.getElementById('detalhesSoliciteDadosEnviando').style.display = "none";
				break;
			case 'ok':
				clearForm(document.getElementById('formSolicite'));
//				document.getElementById('detalhesSoliciteTopo').style.display = "none";
				document.getElementById('detalhesSoliciteInfo').style.display = "none";
				document.getElementById('detalhesSoliciteDados').style.display = "none";
				document.getElementById('detalhesSoliciteMsgErr2').style.display = "none";
				document.getElementById('detalhesSoliciteMsgOk').style.display = "";
				break;
		}
		document.getElementById('detalhesSoliciteDadosEnviando').style.display = "none";
	}
}

function enviaEnviarAmigo() {
	//document.getElementById('detalhesEnviarAmigoTopo').style.display = "none";
	document.getElementById('detalhesEnviarAmigoInfo').style.display = "none";
	document.getElementById('detalhesEnviarAmigoDados').style.display = "none";
	document.getElementById('detalhesEnviarAmigoMsgErr2').style.display = "none";
	document.getElementById('detalhesEnviarAmigoMsgOk').style.display = "none";
	document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "";

	var objForm = document.getElementById('formEnviarAmigo');
	var concatValues = concatFormValues(objForm);
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	xajax_enviaEnviarParaAmigo2(concatValues);
}

function detalhesEnvieAjaxReturn(resp,tipo) {
	if (resp == 'tipo_err') {
		document.getElementById('detalhesEnviarAmigoTopo').style.display = "";
		document.getElementById('detalhesEnviarAmigoInformacoes').style.display = "";
		document.getElementById('detalhesEnviarAmigoDados').style.display = "";
	}else{
		switch (resp)
		{
			case 'info_err':
			case 'email_err':
			case 'captcha_nok':
				document.getElementById('detalhesEnviarAmigoMsgErr2').style.display = "";
				document.getElementById('detalhesEnviarAmigoTopo').style.display = "";
				document.getElementById('detalhesEnviarAmigoInfo').style.display = "";
				document.getElementById('detalhesEnviarAmigoDados').style.display = "";
				document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "none";
				break;
			case 'ok':
				clearForm(document.getElementById('formEnviarAmigo'));
				document.getElementById('detalhesEnviarAmigoTopo').style.display = "none";
				document.getElementById('detalhesEnviarAmigoInfo').style.display = "none";
				document.getElementById('detalhesEnviarAmigoDados').style.display = "none";
				document.getElementById('detalhesEnviarAmigoMsgErr2').style.display = "none";
				document.getElementById('detalhesEnviarAmigoMsgOk').style.display = "";
				document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "none";
				break;
		}
	}
}

function enviaFinanciamento() {
	document.getElementById('financiamentoFormFrame').style.display = "none";
	document.getElementById('formulariosInfoFinancamento').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)+"###";
				}detalhesSoliciteAjaxReturn
			}
			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) {
//	var arrAbas = new Array();
//	arrAbas[0] = "cabecalho";
//	arrAbas[1] = "descricao";
//	arrAbas[2] = "caracteristicas";
//	arrAbas[3] = "fotos";
//	arrAbas[4] = "video";
//	arrAbas[5] = "mapa";
//	arrAbas[6] = "precos";
//	arrAbas[7] = "solicite";
//	arrAbas[8] = "envie";
//	
//	if(v == 'geral') {
//		for (i=0; i<7; i++) {
//			document.getElementById("imodetalhecont_"+arrAbas[i]).style.display = '';
//		}
//		document.getElementById("imodetalhecont_"+arrAbas[i++]).style.display = 'none';
//		document.getElementById("imodetalhecont_"+arrAbas[i]).style.display = 'none';
//	} else {
//		for (i=0; i<arrAbas.length; i++) {
//			document.getElementById("imodetalhecont_"+arrAbas[i]).style.display = 'none';
//		}
//	}
//	document.getElementById("detalhesSoliciteMsgErr1").style.display = 'none';
//	document.getElementById("detalhesSoliciteMsgErr2").style.display = 'none';
//	document.getElementById("detalhesEnviarAmigoMsgErr1").style.display = 'none';
//	document.getElementById("detalhesEnviarAmigoMsgErr2").style.display = 'none';
//	document.getElementById('captchaSourceSolicite').src = '';
//	document.getElementById('captchaSourceSolicite').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
//	document.getElementById('captchaSourceEnviarAmigo').src = '';
//	document.getElementById('captchaSourceEnviarAmigo').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
//	document.getElementById('captchaSolicite').value = '';
//	document.getElementById('captchaSolicite').src = '';
//	document.getElementById('captchaEnviarAmigo').value = '';
//	document.getElementById('captchaEnviarAmigo').src = '';
//	document.getElementById("detalhesEnviarAmigoTopo").style.display = '';
//	document.getElementById("detalhesEnviarAmigoInfo").style.display = '';
//	document.getElementById("imodetalhecont_"+v).style.display = '';
//}

//function change_detalhe_lanc(v) {
//	var arrAbas = new Array();
//	arrAbas[0] = "descricao";
//	arrAbas[1] = "caracteristicas";
//	arrAbas[2] = "fotos";
//	arrAbas[3] = "unidades";
//	arrAbas[4] = "localizacao";
//	arrAbas[5] = "videos";
//	arrAbas[6] = "solicite";
//	arrAbas[7] = "envie";
//	if(v == 'geral') {
//		for (i=0; i<6; i++) {
//			document.getElementById("lancdetalhecont_"+arrAbas[i]).style.display = '';
//		}
//		document.getElementById("lancdetalhecont_"+arrAbas[i++]).style.display = 'none';
//		document.getElementById("lancdetalhecont_"+arrAbas[i]).style.display = 'none';
//	} else {
//		for (i=0; i<arrAbas.length; i++) {
//			document.getElementById("lancdetalhecont_"+arrAbas[i]).style.display = 'none';
//		}
//	}
//	document.getElementById("detalhesSoliciteMsgErr1").style.display = 'none';
//	document.getElementById("detalhesSoliciteMsgErr2").style.display = 'none';
//	document.getElementById("detalhesEnviarAmigoMsgErr1").style.display = 'none';
//	document.getElementById("detalhesEnviarAmigoMsgErr2").style.display = 'none';
////	document.getElementById("tabelaLanc").style.display = 'none';
//
//	document.getElementById('captchaSourceSolicite').src = '';
//	document.getElementById('captchaSourceSolicite').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
//	document.getElementById('captchaSourceEnviarAmigo').src = '';
//	document.getElementById('captchaSourceEnviarAmigo').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
//	document.getElementById('captchaSolicite').value = '';
//	document.getElementById('captchaSolicite').src = '';
//	document.getElementById('captchaEnviarAmigo').value = '';
//	document.getElementById('captchaEnviarAmigo').src = '';
//
//	if(v != 'geral')
//		document.getElementById("lancdetalhecont_"+v).style.display = '';
//
//}

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 = 520;
		var tweenScroll = new Tween(document.getElementById('calendarioInner'),'scrollLeft',Tween.regularEaseOut,inicioTween,finalTween,0.5,'');
		tweenScroll.start();
	}
}

function rolaCalendarioEsquerda() {
	if (document.getElementById('calendarioInner').scrollLeft == 520) {
		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()",200);
//}

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) {
	document.getElementById('cortinaPopup').style.display = "";
	document.getElementById('popup').style.display = "";
	verificaPopup();
	jah('detlanc_uni_tab.php?lanc='+unid+'&unid='+unid+'&id='+id,'popup');
}

//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');
//	});	
//	document.getElementById('cortinaPopup').style.display = "";
//	document.getElementById('popup').style.display = "";
//	jah('detlanc_uni_tab.php?lanc='+unid+'&unid='+unid+'&id='+id,'popup');
//	verificaPopup();
//}

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 mostraFoto(f) {
//	$('object').css('visibility','hidden');
//	
////	var fThumb = f.replace('lanc','t_lanc');
//	var legendaAtual = '';
//	var indiceAtual = f;
//	$('div[thumb_imo=1]').each(function(){
//		if ($(this).attr('indice') == f) {
//			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_imo=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 novaH;
//	var novaW;
//	var fv = $('div[thumb_imo=1][indice='+indiceAtual+']').attr('fv');
//	if($('div[thumb_imo=1][indice='+indiceAtual+']').attr('h') > document.body.clientHeight) {
//		novaH = parseInt(document.body.clientHeight - 10);
//		novaW = parseInt((novaH * parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('w')) / parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('h'))) - 10);
//		if(novaW > document.body.clientWidth) {
//			novaH = novaH*(document.body.clientWidth - 110) / novaW;
//			novaW = document.body.clientWidth - 110;
//		}
//		fv = fv.replace('fvHeight='+$('div[thumb_imo=1][indice='+indiceAtual+']').attr('h'),'fvHeight='+novaH);
//		fv = fv.replace('fvWidth='+$('div[thumb_imo=1][indice='+indiceAtual+']').attr('w'),'fvWidth='+novaW);
//	} else {
//		novaH = parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('h'));
//		novaW = parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('w'));
//	}
//	
//	var flashObj = returnFlash(novaW,novaH,'img.swf',fv,'objFlashFoto' + indiceAtual);
//	
//	$('#layerUp').addClass('layerUp').html(flashObj).css({left:l,top:t}).fadeIn();
//
//	$('#layerUp').css('height', novaH);
//	$('#layerUp').css('width', novaW);
//
//	posicionaLayerUp(indiceAtual,'imo',novaW,novaH);
//	
//	$('.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('objFlashFoto',''));
//		fThumb = $('div[thumb_imo=1][indice='+velhaFoto+']').attr('src');
//		var novaFoto = '';
//		if ($('div[thumb_imo=1]:first').attr('indice') == indiceAtual) {
//			novaFoto = $('div[thumb_imo=1]:last').attr('indice');
//			indiceAtual = $('div[thumb_imo=1]:last').attr('indice');
//		}else{
//			var handIndice = new Array();
//			var posAtual;
//			var i = 0;
//			$('div[thumb_imo=1]').each(function(){
//				handIndice[i] = $(this).attr('indice');
//			if ($(this).attr('indice') == indiceAtual) posAtual = i;
//				i++;
//			});
//			novaFoto = handIndice[posAtual - 1];
//			indiceAtual = novaFoto;
//		}
//		var novaLegenda = $('div[thumb_imo=1][indice='+novaFoto+']').attr('legenda');
//		var novaFlashVars = $('div[thumb_imo=1][indice='+novaFoto+']').attr('fv');
//	if($('div[thumb_imo=1][indice='+indiceAtual+']').attr('h') > document.body.clientHeight) {
//		novaH = parseInt(document.body.clientHeight - 10);
//		novaW = parseInt((novaH * parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('w')) / parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('h'))) - 10);
//		if(novaW > document.body.clientWidth) {
//			novaH = novaH*(document.body.clientWidth - 110) / novaW;
//			novaW = document.body.clientWidth - 110;
//		}
//		novaFlashVars = fv.replace('fvHeight='+$('div[thumb_imo=1][indice='+indiceAtual+']').attr('h'),'fvHeight='+novaH);
//		novaFlashVars = fv.replace('fvWidth='+$('div[thumb_imo=1][indice='+indiceAtual+']').attr('w'),'fvWidth='+novaW);
//	} else {
//		novaH = parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('h'));
//		novaW = parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('w'));
//	}
//		
//		flashObj = returnFlash(novaW,novaH,'img.swf',novaFlashVars,'objFlashFoto'+novaFoto);
//		
//		$('.layerUpLegenda').html('<div>'+novaLegenda+'</div>');
//		
//		$('#layerUp').html(flashObj);
//		posicionaLayerUp(novaFoto,'imo',novaW,novaH);
//	});
//	
//	$('.layerUpNavegaRight').click(function(){
//		$('.layerUpLegenda').hide();
//		var velhaFoto = parseInt($('#layerUp > object').attr('id').replace('objFlashFoto',''));
//		fThumb = $('div[thumb_imo=1][indice='+velhaFoto+']').attr('src');
//		var novaFoto = '';
//		if ($('div[thumb_imo=1]:last').attr('indice') == indiceAtual) {
//			novaFoto = $('div[thumb_imo=1]:first').attr('indice');
//			indiceAtual = $('div[thumb_imo=1]:first').attr('indice');
//		}else{
//			var handIndice = new Array();
//			var posAtual;
//			var i = 0;
//			$('div[thumb_imo=1]').each(function(){
//				handIndice[i] = $(this).attr('indice');
//				if ($(this).attr('indice') == indiceAtual) posAtual = i;
//				i++;
//			});
//			novaFoto = handIndice[posAtual + 1];
//			indiceAtual = novaFoto;
//		}
//		
//		var novaLegenda = $('div[thumb_imo=1][indice='+novaFoto+']').attr('legenda');
//		var novaFlashVars = $('div[thumb_imo=1][indice='+novaFoto+']').attr('fv');
//	if($('div[thumb_imo=1][indice='+indiceAtual+']').attr('h') > document.body.clientHeight) {
//		novaH = parseInt(document.body.clientHeight - 10);
//		novaW = parseInt((novaH * parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('w')) / parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('h'))) - 10);
//		if(novaW > document.body.clientWidth) {
//			novaH = novaH*(document.body.clientWidth - 110) / novaW;
//			novaW = document.body.clientWidth - 110;
//		}
//		novaFlashVars = fv.replace('fvHeight='+$('div[thumb_imo=1][indice='+indiceAtual+']').attr('h'),'fvHeight='+novaH);
//		novaFlashVars = fv.replace('fvWidth='+$('div[thumb_imo=1][indice='+indiceAtual+']').attr('w'),'fvWidth='+novaW);
//	} else {
//		novaH = parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('h'));
//		novaW = parseInt($('div[thumb_imo=1][indice='+indiceAtual+']').attr('w'));
//	}
//		
//		flashObj = returnFlash(novaW,novaH,'img.swf',novaFlashVars,'objFlashFoto'+novaFoto);
//		
//		$('.layerUpLegenda').html('<div>'+novaLegenda+'</div>');
//		
//		$('#layerUp').html(flashObj);
//		posicionaLayerUp(novaFoto,'imo',novaW,novaH);
//	});
//}

//function mostraFotoLancamento(f) {
//	$('object').css('visibility','hidden');
//	
////	var fThumb = f.replace('lanc','t_lanc');
//	var legendaAtual = '';
//	var indiceAtual = f;
//	$('div[thumb_lanc=1]').each(function(){
//		if ($(this).attr('indice') == f) {
//			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 novaH;
//	var novaW;
//	var fv = $('div[thumb_lanc=1][indice='+indiceAtual+']').attr('fv');
//	if($('div[thumb_lanc=1][indice='+indiceAtual+']').attr('h') > document.body.clientHeight) {
//		novaH = parseInt(document.body.clientHeight - 10);
//		novaW = parseInt((novaH * parseInt($('div[thumb_lanc=1][indice='+indiceAtual+']').attr('w')) / parseInt($('div[thumb_lanc=1][indice='+indiceAtual+']').attr('h'))) - 10);
//		if(novaW > document.body.clientWidth) {
//			novaH = novaH*(document.body.clientWidth - 110) / novaW;
//			novaW = document.body.clientWidth - 110;
//		}
//		fv = fv.replace('fvHeight='+$('div[thumb_lanc=1][indice='+indiceAtual+']').attr('h'),'fvHeight='+novaH);
//		fv = fv.replace('fvWidth='+$('div[thumb_lanc=1][indice='+indiceAtual+']').attr('w'),'fvWidth='+novaW);
//	} else {
//		novaH = parseInt($('div[thumb_lanc=1][indice='+indiceAtual+']').attr('h'));
//		novaW = parseInt($('div[thumb_lanc=1][indice='+indiceAtual+']').attr('w'));
//	}
//	
//	var flashObj = returnFlash(novaW,novaH,'img.swf',fv,'objFlashFotoLanc' + indiceAtual);
//	
//	$('#layerUp').addClass('layerUp').html(flashObj).css({left:l,top:t}).fadeIn();
//	
//	$('#layerUp').css('height', novaH);
//	$('#layerUp').css('width', novaW);
//
//	posicionaLayerUp(indiceAtual,'lanc',novaW,novaH);
//
//	$('.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('indice') == indiceAtual) {
//			novaFoto = $('div[thumb_lanc=1]:last').attr('indice');
//			indiceAtual = $('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('indice') == indiceAtual) posAtual = i;
//				i++;
//			});
//			novaFoto = handIndice[posAtual - 1];
//			indiceAtual = novaFoto;
//		}
//		var novaLegenda = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('legenda');
//		var novaFlashVars = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('fv');
//	if($('div[thumb_lanc=1][indice='+novaFoto+']').attr('h') > document.body.clientHeight) {
//		novaH = parseInt(document.body.clientHeight - 10);
//		novaW = parseInt((novaH * parseInt($('div[thumb_lanc=1][indice='+novaFoto+']').attr('w')) / parseInt($('div[thumb_lanc=1][indice='+novaFoto+']').attr('h'))) - 10);
//		if(novaW > document.body.clientWidth) {
//			novaH = novaH*(document.body.clientWidth - 110) / novaW;
//			novaW = document.body.clientWidth - 110;
//		}
//		novaFlashVars = fv.replace('fvHeight='+$('div[thumb_lanc=1][indice='+novaFoto+']').attr('h'),'fvHeight='+novaH);
//		novaFlashVars = fv.replace('fvWidth='+$('div[thumb_lanc=1][indice='+novaFoto+']').attr('w'),'fvWidth='+novaW);
//	} else {
//		novaH = parseInt($('div[thumb_lanc=1][indice='+novaFoto+']').attr('h'));
//		novaW = parseInt($('div[thumb_lanc=1][indice='+novaFoto+']').attr('w'));
//	}
//		
//		flashObj = returnFlash(novaW,novaH,'img.swf',novaFlashVars,'objFlashFotoLanc'+novaFoto);
//		
//		$('.layerUpLegenda').html('<div>'+novaLegenda+'</div>');
//		
//		$('#layerUp').html(flashObj);
//		posicionaLayerUp(novaFoto,'lanc',novaW,novaH);
//	});
//	
//	$('.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('indice') == indiceAtual) {
//			novaFoto = $('div[thumb_lanc=1]:first').attr('indice');
//			indiceAtual = $('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('indice') == indiceAtual) posAtual = i;
//				i++;
//			});
//			novaFoto = handIndice[posAtual + 1];
//			indiceAtual = novaFoto;
//		}
//		
//		var novaLegenda = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('legenda');
//		var novaFlashVars = $('div[thumb_lanc=1][indice='+novaFoto+']').attr('fv');
//	if($('div[thumb_lanc=1][indice='+novaFoto+']').attr('h') > document.body.clientHeight) {
//		novaH = parseInt(document.body.clientHeight - 10);
//		novaW = parseInt((novaH * parseInt($('div[thumb_lanc=1][indice='+novaFoto+']').attr('w')) / parseInt($('div[thumb_lanc=1][indice='+novaFoto+']').attr('h'))) - 10);
//		if(novaW > document.body.clientWidth) {
//			novaH = novaH*(document.body.clientWidth - 110) / novaW;
//			novaW = document.body.clientWidth - 110;
//		}
//		novaFlashVars = fv.replace('fvHeight='+$('div[thumb_lanc=1][indice='+novaFoto+']').attr('h'),'fvHeight='+novaH);
//		novaFlashVars = fv.replace('fvWidth='+$('div[thumb_lanc=1][indice='+novaFoto+']').attr('w'),'fvWidth='+novaW);
//	} else {
//		novaH = parseInt($('div[thumb_lanc=1][indice='+novaFoto+']').attr('h'));
//		novaW = parseInt($('div[thumb_lanc=1][indice='+novaFoto+']').attr('w'));
//	}
//		
//		flashObj = returnFlash(novaW,novaH,'img.swf',novaFlashVars,'objFlashFotoLanc'+novaFoto);
//		
//		$('.layerUpLegenda').html('<div>'+novaLegenda+'</div>');
//		
//		$('#layerUp').html(flashObj);
//		posicionaLayerUp(novaFoto,'lanc',novaW,novaH);
//	});
//}

//function posicionaLayerUp(par_indice,tipo,layerWidth,layerHeight) {
//	var newWidth = layerWidth;
//	var newHeight = layerHeight;
//	$('.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() {
	window.parent.document.getElementById('boxFavoritos').style.display = "";
}

function mostraIndicadores() {
	document.getElementById('indicadores').style.display = "";
}

function mostraClima() {
	document.getElementById('boxClimatempo').style.display = "";
}

$(document).ready(function(){
	// banners parceiros
	if($("frameBannersChilds").html() != null){
		$("#frameBanners").hide();
	}
	
	$("#mostraAmigo").click(function () {
		$("#enviarAmigo").fadeIn();
		$(".formularioCaptcha").append("<img id='captcha_imagem' src='captcha_numerico.php' style='margin:-5px 0 0;'/>");
	});
	$(".escondeAmigo").click(function () {
	  $("#enviarAmigo").fadeOut(100);
	  $("#detalhesEnviarAmigoMsgErr2").hide();
	  $("#captcha_imagem").remove();
	});
	$("#mostraRecebeInfo").click(function () {
	  $("#recebeInfo").fadeIn(100);
	  $(".formularioCaptchaInfo").append("<img id='captcha_imagem' src='captcha_numerico.php' style='margin:-5px 0 0;'/>");	  
	});
	$(".escondeRecebeInfo").click(function () {
		$("#captcha_imagem_info").remove();
		$("#recebeInfo").fadeOut(100);
		$("#detalhesSoliciteMsgErr2").hide();
	});
	$("div:odd").removeClass("indicadorBackground");
	
	 if ($('.emptySlot1').height() < 18) $('.ifVazio1').remove();
	 if ($('.emptySlot2').html() == '') $('.ifVazio2').remove();
	 if ($('.emptySlot3').height() < 18) $('.ifVazio3').remove();
	 if ($('.emptySlot4').height() < 25) $('.ifVazio4').remove();
	 if ($('.emptySlot5').height() < 18) $('.ifVazio5').remove();
	 if ($('.emptySlot6').height() < 18) $('.ifVazio6').remove();
	 if ($('.emptySlot7').height() < 18) $('.ifVazio7').remove();
	 
	$('.empty-check:empty').parent().parent().remove();
	//$('.redes-sociais-check:empty').parent().parent().remove();
	$('.navegue-aqui-check:empty').parent().parent().remove();
	
});
$(document).ready(function() {
	$(".nietszche").autoEllipsis();
});
/*
	by Homam Hosseini
	http://abstractform.wordpress.com
	bluesnowball@gmail.com

*/


jQuery.fn.autoEllipsis = function(options) {
    var get_AutoEllipsisScroller = function(id) {
        var aeScrollerId = "WingooliAutoEllipsisScroller_" + id
        if (!document.getElementById(aeScrollerId)) {
            var div = document.createElement("div");
            div.id = aeScrollerId + "_Container";
            div.innerHTML = "<span id=\"" + aeScrollerId + "\" style=\"overflow: visible; position: absolute; top: -2000px; color: orange\"></span>";
            document.body.appendChild(div);
        }
        return document.getElementById(aeScrollerId);
    };

    var StringEllipsesByMaxLetters = function(element, originalText, maxLettersAllowed) {
        element.title = "";
        var text = originalText;
        if (text == null || text == "") text = element.innerHTML;
        var maxAllowedLatterIndex = text.length - maxLettersAllowed;
        if (maxAllowedLatterIndex > 0) {
            element.title = text;
            if (originalText == null)
                originalText = text;
            element.innerHTML = text.substr(0, maxLettersAllowed - 2) + "&hellip;";
        } else {
            element.innerHTML = text;
        }
    };

    var _this = this;

    var settings = jQuery.extend({}, options);
    this.each(function(i) {
        var aeScroller = get_AutoEllipsisScroller(i);
        saeScroller = $(aeScroller);
        sthis = $(this);
        saeScroller.text(sthis.text());

        var origText = sthis.html();

        var element = this;
        var elementBounds = { width: element.offsetWidth, height: element.offsetHeight };

        var jAeScroller = $(aeScroller);
        var jElement = $(element);

        var props = ["font-size", "font-weight", "font-family", "font-style", "padding"];

        for (var i = 0; i < props.length; i++) {
            try {
                jAeScroller.css(props[i], jElement.css(props[i]));
            } catch (ex) { }
        }
        jElement.css("overflow", "visible");


        jAeScroller.width(jElement.width());

        var isIe = (document.all != undefined);
        var scrollerWidth = jAeScroller.width();
        var scrollerHeight = jAeScroller.height();
        var fitText = saeScroller.text();

        while (scrollerHeight > elementBounds.height && fitText != "") {
            fitText = fitText.substr(0, fitText.length - 2);
            var autoScrollerInnerHTML = fitText + "&hellip;";
            saeScroller.html(autoScrollerInnerHTML);
            scrollerHeight = jAeScroller.height();
        }
        if (fitText == "") {
            fitText = origText;
            saeScroller.html(fitText);
            jElement.css("whiteSpace", "nowrap");
            jAeScroller.width("");
            var scrollerWidth = jAeScroller.width();
        }

        while (scrollerWidth > elementBounds.width && fitText != "") {
            fitText = fitText.substr(0, fitText.length - 2);
            var autoScrollerInnerHTML = fitText + "&hellip;";
            saeScroller.html(autoScrollerInnerHTML);
            scrollerWidth = jAeScroller.width();
        }
        var scrollerHeight = aeScroller.offsetHeight;
        var r = (Math.ceil(elementBounds.height / scrollerHeight) - 1);
        r += (r == 0) ? 1 : 0;
        var maxLettersAllowed = fitText.length * r;

        StringEllipsesByMaxLetters(element, origText, maxLettersAllowed + (r + 1));
    });
}

