// JavaScript Document
caminho_template = "11";

// "INCLUDES"
$(document).ready(function(){
	$('<script language="javascript" type="text/javascript" src="templates/'+caminho_template+'/js/script.js"></script>').appendTo('head');
	$('<script language="javascript" type="text/javascript" src="templates/'+caminho_template+'/js/lightbox.js"></script>').appendTo('head');
	//$('<script language="javascript" type="text/javascript" src="templates/'+caminho_template+'/js/mask.js"></script>').appendTo('head');
	$('<script language="javascript" type="text/javascript" src="templates/'+caminho_template+'/js/jquery.colorbox-min.js"></script>').appendTo('head');
});

$(document).ready(function(){
	$("a[rel='example1']").colorbox();
	$("a.openTable").colorbox();
		
	if($(".indicadorItem").val() == undefined){
		$(".indicadores").css("display","none");
	}

	$('.listarMaisButton').click(function(event){
		$('html,body').animate({scrollTop: $('.itemDestaque: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();
			}
		});
	}
	
	
	if($(".indice").html() == null){
		$(".indices-economicos").css("display","none");
	}
	
	if($(".bannersTemplate").html() == null){
		$("#linkPgs").css("display","none");
	}
	
	if($(".banners-parceiros").html() == null){
		$(this).css("display","none");
	}
	
	
	
	$(".anuncioDestaque").hover(function(){
		$(this).find(".btnDetalhes img").animate( { opacity:"1"}, 100 )
		$(this).find(".fotoAnuncio").find(".ver-mais-informacoes2").fadeIn(90)
	},function(){
		$(this).find(".btnDetalhes img").animate( { opacity:"0.7"}, 0 )
		$(this).find(".fotoAnuncio").find(".ver-mais-informacoes2").hide()
	});
	

	
	$(".pesquisaResultado").click(function () {
	   $(".pesquisaResultadoBox").toggle("fast");
	   $(this).find("div").find("img").toggle(10)
	});
	
	if ($('#supertramp').height() < 15) $('#preview-caracteristicas').remove();
	
	if ($('.removivel').width < 160) {
		$(this).remove();
	}
	

	$("#envia-amigo").click(function() {
		$(".enviar-para-amigo").show();
		$(".seta-enviar-amigo").show();
		$(".receber-informacoes").hide();
		$(".seta-receber-informacoes").hide();
		$("#captcha_imagem").remove();
		$("#validation-amigo").append("<img id='captcha_imagem' src='captcha_numerico.php' style='margin:-5px 0 0;'/>");
	});
	$("#receba-info").click(function(){
		$(".receber-informacoes").show();
		$(".seta-receber-informacoes").show();
		$(".enviar-para-amigo").hide();
		$(".seta-enviar-amigo").hide();
		$("#captcha_imagem").remove();
		$("#validation").append("<img id='captcha_imagem' src='captcha_numerico.php' style='margin:-5px 0 0;'/>");
	});
	$(".fecha-janela", "").click(function(){
		$(".receber-informacoes").hide();
		$(".seta-receber-informacoes").hide();
		$(".enviar-para-amigo").hide();
		$(".seta-enviar-amigo").hide();
		$("#captcha_imagem").remove();
	});
	
	$("ul.menu > li").mouseover(function() {
		if($(this).attr("tipo_negocio") > 0){
			$(this).find("ul span").html($("#negocio_tipo_"+$(this).attr("tipo_negocio")).find("div").html());
		}
		$(this).addClass("open")
	}).mouseout(function() {
		$(this).removeClass("open")
	});
	$("ul.menu > li").each(function() {
		if($(this).children("ul").length > 0) {
			$(this).children("a").click(function() {
				return false
			})
		}
	});
	$("li.plus").hover(
		function () {$(this).animate({opacity: 0.7}, 100 )},
		function () {(this).animate({opacity: 1.0}, 100 )}
	);


	
	// manipulação dos detalhes - conteúdos - do imóvel
	if($("ul.preview-caracteristicas > li").text()==""){
		$("ul.preview-caracteristicas").parent().css("display","none");
	}
	if($("ul.preview-recursos > li").text()==""){
		$("ul.preview-recursos").parent().css("display","none");
	}
	if($(".item-detalhes div.infotec > span").text()==""){
		$(".item-detalhes div.infotec >  span").parent().parent().hide();
	}
	
	// envia formulário SOLICITE INFORMAÇÃO
	$("#send-solicite").click(function(){
		$(this).hide();
		$("#close-solicite").hide();
		$("#send-process").show();
		
		$.post('mail_ajax.php',$("#formSolicite").serialize(), function(data) {
			if(data == "sucesso"){
				$("#formSolicite").hide();
				$("#sucesso").html("Sua solicitação foi enviada com sucesso! <br/> Para continuar, <a href='javascript:window.location.reload()'>clique aqui</a>. ")
				alert(data);
			}
			else{
				$("#send-process").hide();
				$("#send-solicite, #close-solicite").show();
				$("#status").html(data).show();
			}
		});
	});
	
	
	
	
	
});

//function mostraFavoritos() {
//	window.parent.document.getElementById('listImoveis').style.display = "";
//}

function mostraIndicadores() {
	document.getElementById('boxIndicadores').style.display = "";
}

function mostraClima() {
	document.getElementById('boxClimatempo').style.display = "";
}

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';
	}else{
		document.getElementById('pesquisaImoveisEsc').style.display = 'none';
		document.getElementById('pesquisaLancamentosEsc').style.display = '';
		//document.getElementById('abaPesquisaImoveis').className = 'abasPesquisaOff';
		//document.getElementById('abaPesquisaLanc').className = 'abasPesquisaOn';
	}
	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 listarMais(t,tg)
{
	$('#listarMaisButton'+t).hide();
	$('#listarLoding'+t).show();
	xajax_listaMais(t,tg,'a');
}

function listarEvents(t)
{
	$('#listarMaisButton'+t).show();
	$('#listarLoding'+t).hide();
	$(".anuncioDestaque").hover(function(){
	$(this).find(".btnDetalhes img").animate( { opacity:"1"}, 100 )
	$(this).find(".fotoAnuncio").find(".ver-mais-informacoes2").fadeIn(90)
	},function(){
	$(this).find(".btnDetalhes img").animate( { opacity:"0.7"}, 0 )
	$(this).find(".fotoAnuncio").find(".ver-mais-informacoes2").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 posicionaChamado(){
	
}
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 'info_err':
			case 'email_err':
			case 'captcha_nok':
				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('detalhesEnviarAmigoTudo').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('detalhesEnviarAmigoTudo').style.display = "";
	}else{
		switch (resp)
		{
			case 'info_err':
			case 'email_err':
      case 'captcha_nok':
				document.getElementById('detalhesEnviarAmigoMsgErr2').style.display = "";
				document.getElementById('detalhesEnviarAmigoTudo').style.display = "";
				document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "none";
				break;
			case 'ok':
				clearForm(document.getElementById('formEnviarAmigo'));
				document.getElementById('detalhesEnviarAmigoTudo').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)+"###";
				}
			}
			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 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 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;
}

