jQuery(function($){
	var input_busca = $('input#input_busca');
	input_busca.val('Busca')
		.css({'text-shadow' : '1px 1px 1px #fff'})
		.focus(function(){
			if( $(this).val() == 'Busca' ) {
				$(this).val('');
			} // if
		}) // focus
		.blur(function(){
			if( $(this).val() == '' ) {
				$(this).val('Busca');
			} // if
		}); // blur
		
		
		
		$(window).load(function(){
			$( '#page .content-imoveis .jCarouselLite ul' ).css( 'left', 0 );
		});
		
		
		
		
		
		
		if( $( '#container_contato' )[0] ){
			$( '#ddd_telefone_contato' ).mask('99');
			$( '#telefone_contato' ).mask('9999-9999?9');
			
		}
});


function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


function txtBoxFormat(objeto, sMask, evtKeyPress){

    var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;

	if(document.all) { // Internet Explorer
	    nTecla = evtKeyPress.keyCode;
	} else if(document.layers) { // Nestcape
	    nTecla = evtKeyPress.which;
	} else {
	    nTecla = evtKeyPress.which;
	    if (nTecla == 8) {
	        return true;
	    }
	}

    sValue = objeto.value;
    // Limpa todos os caracteres de formatação que
    // já estiverem no campo.

    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( "-", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( ".", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( "/", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( ":", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( "(", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( ")", "" );
    sValue = sValue.toString().replace( " ", "" );
    sValue = sValue.toString().replace( " ", "" );
    fldLen = sValue.length;
    mskLen = sMask.length;

    i = 0;
    nCount = 0;
    sCod = "";
    mskLen = fldLen;

    while (i <= mskLen) {
      bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
      bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))

      if (bolMask) {
        sCod += sMask.charAt(i);
        mskLen++;
	  } else {
        sCod += sValue.charAt(nCount);
        nCount++;
      }

      i++;
    }

    objeto.value = sCod;

    if (nTecla != 8) { // backspace
      if (sMask.charAt(i-1) == "9") { // apenas números...
        return ((nTecla > 47) && (nTecla < 58));
	  } else { // qualquer caracter...
        return true;
      }
    } else {
      return true;
    }

}

/*
 * Valores padr�o para campos de formul�rios.
 *
 * As chaves do array devem ser o id do campo e o valor o valor padr�o. Esse
 * array pode ser usado em campos que t�m seus labels escondidos e cont�m como
 * valor o conte�do do label, por exemplo.
 */
var default_values = [];

/*
 * O ID do intervalo usado pelo carrosel de banners da home.
 */
var carrousel_interval = undefined;

/*
 * Dura��o, em milisegundos, do efeito de (des)aparecimento dos banners da
 * home.
 *
 * Podem ser usadas as strings 'fast', 'normal' e 'slow' para definir os
 * valores de 200, 400 e 600 milisegundos, respectivamente.
 */
var carrousel_fade_duration = 500;

/*
 * Tudo que � executado no fim do carregamento do documento.
 */
$(document).ready(function () {


		if ($('#tabs-images .jCarouselLite')[0]) {
			//alert('a');
			$("#tabs-images .jCarouselLite").jCarouselLite({
				btnNext: "#tabs-images .jCarouselLiteNext",btnPrev: " #tabs-images.content-imoveis .jCarouselLitePrev",mouseWheel: true,scroll: 3, circular: false
			});
		}
		
		if ($('#tabs-plantas .jCarouselLite')[0]) {
			//alert('b');
			$("#tabs-plantas .jCarouselLite").jCarouselLite({
				btnNext: "#tabs-plantas .jCarouselLiteNext",btnPrev: " #tabs-plantas.content-imoveis .jCarouselLitePrev",mouseWheel: true,scroll: 3, circular: false
			});
		}
		
		if ($('#tabs-areas-comuns .jCarouselLite')[0]) {
			//alert('c');
			$("#tabs-areas-comuns .jCarouselLite").jCarouselLite({btnNext: "#tabs-areas-comuns.content-imoveis .jCarouselLiteNext",btnPrev: "#tabs-areas-comuns.content-imoveis .jCarouselLitePrev",mouseWheel: true,scroll: 3, circular: false });
		}
		if ($('#tabs-interior .jCarouselLite')[0]) {
			//alert('d');
			$("#tabs-interior .jCarouselLite").jCarouselLite({btnNext: "#tabs-interior.content-imoveis .jCarouselLiteNext",btnPrev: "#tabs-interior.content-imoveis .jCarouselLitePrev",mouseWheel: true,scroll: 3, circular: false });
		}
		if ($('#tabs-obras .jCarouselLite')[0]) {
			//alert('e');
			$("#tabs-obras .jCarouselLite").jCarouselLite({btnNext: "#tabs-obras.content-imoveis .jCarouselLiteNext",btnPrev: "#tabs-obras.content-imoveis .jCarouselLitePrev",mouseWheel: true,scroll: 3, circular: false });
		}
		if ($('#tabs-videos .jCarouselLite')[0]) {
			//alert('g');
			$("#tabs-videos .jCarouselLite").jCarouselLite({btnNext: "#tabs-videos.content-imoveis .jCarouselLiteNext",btnPrev: "#tabs-videos.content-imoveis .jCarouselLitePrev",mouseWheel: true,scroll: 3, circular: false });
		}
		if ($('#tabs-downloads .jCarouselLite')[0]) {
			//alert('f');
			$("#tabs-downloads .jCarouselLite").jCarouselLite({btnNext: "#tabs-downloads.content-imoveis .jCarouselLiteNext",btnPrev: "#tabs-downloads.content-imoveis .jCarouselLitePrev",mouseWheel: true,scroll: 3, circular: false });
		}
		if ($('#tabs-decorado .jCarouselLite')[0]) {
			//alert('g');
			$("#tabs-decorado .jCarouselLite").jCarouselLite({btnNext: "#tabs-decorado.content-imoveis .jCarouselLiteNext",btnPrev: "#tabs-decorado.content-imoveis .jCarouselLitePrev",mouseWheel: true,scroll: 3, circular: false });
		}
		
		/*
        $("div#controller-slides").jFlow({
            slides: "#slides",
            width: "100%",
            height: "335px",
			duration: 300 
        });
		*/

		
		if( $( '#slides' )[0] ){
			$( '#slides' ).jcarousel({
				scroll : 1,
				auto   : 5,
				wrap   : 'circular'
			});
		}
		
		
		
		
		
		
		
		
		
		if( $( '.fancybox' )[0] ){
			$(".fancybox").click(function(e) {
				e.preventDefault();
				$.fancybox({
						'padding'		: 10,
						'autoScale'		: false,
						'transitionIn'	: 'none',
						'transitionOut'	: 'none',
						'title'			: this.title,
						'width'		    : 680,
						'height'		: 495,
						'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
						'type'			: 'swf',
						'swf'			: {
							 'wmode'		: 'transparent',
							'allowfullscreen'	: 'true'
						}
					});
			});
		}
		
		
		
		
		
		
		$('#slides div img').css('display','block');
		//alert('aa');
		
		$('.tabs-invespark').tabs();
		$("#jslides").jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev"
	   });
		
		//window.setInterval(document.getElementById('aaaaa').click(),500);

  /*
   * Modo bacana (webstandards friendly) de abrir um link em outra janela.
   */
  $('a[rel~=external]').attr('target', '_blank');

  /*
   * Carrosel de banners.
   */
  if ($('#carrousel').size() > 0) {

    /*
     * Loop dos banners.
     */
	  $('#carrousel dt.active').show();
    carrousel_interval = window.setInterval(function () {
      var dt = $('#carrousel dt.active');
      var next = $(dt.nextAll('dt').get(0));
      if (next.size() == 0) {
        next = $('#carrousel dt.first');
      }
      dt.removeClass('active');
      dt.next('dd').fadeOut(carrousel_fade_duration);
      next.addClass('active');
      next.next('dd').fadeIn(carrousel_fade_duration);
    }, 5 * 1000);

    /*
     * A��o dos links.
     */
    $('#carrousel dt a').click(function () {
      if (typeof(carrousel_interval) != 'undefined') {
        window.clearInterval(carrousel_interval);
      }
      var dt = $('#carrousel dt.active');
      dt.removeClass('active');
      dt.next('dd').fadeOut(carrousel_fade_duration);
      var parent = $(this).parent();
      parent.addClass('active');
      parent.next('dd').fadeIn(carrousel_fade_duration);
      return false;
    });
  }

  /*
   * Traz os valores dos labels para os campos do formul�rio de newsletter.
   */
  /*$('#newsletter input').each(function () {
    default_values[this.id] = $(this).prev('label').text();
    if (!$(this).val()) {
      $(this).val(default_values[this.id]);
    }
    $(this).focus(function () {
      if ($(this).val().match(/^\s*$/i) || $(this).val() == default_values[this.id]) {
        $(this).val('');
      }
    });
    $(this).blur(function () {
      if ($(this).val().match(/^\s*$/i)) {
        $(this).val(default_values[this.id]);
      }
    });
  });*/

  if ($('div.tabs').size() > 0) {
    $('li a', $('div.tabs').children('ul')).click(function () {
      var li = $(this).parent();
      var id = $(this).attr('href').match(/#([a-z0-9\-]+)$/i)[1];
      li.siblings().removeClass('active');
      li.addClass('active');
      var tabs = li.parents('div.tabs');
      $('.tab', tabs).removeClass('active');
      $('.tab#' + id, tabs).addClass('active');
      return false;
    });

    /*$('div.tabs#gallery .tab ul').each(function () {
      var tab = $(this).parent();
      if ($(this).children().size() > 5) {
        $('a.prev', tab).click(function () {
          var ul = $('ul', $(this).parent());
          ul.children(':first').before(ul.children(':last'));
          return false;
        });
        $('a.next', tab).click(function () {
          var ul = $('ul', $(this).parent());
          ul.children(':last').after(ul.children(':first'));
          return false;
        });
      } else {
        $('a.prev', tab).hide();
        $('a.next', tab).hide();
      }
    });*/

  }

});

function limparTexto(texto,idInput)
{
	if($('#'+idInput).val()==texto)
	{
		$('#'+idInput).attr('value', "");
	}
}

function voltarTexto(texto,idInput)
{
	if($('#'+idInput).val()=="")
	{
		$('#'+idInput).attr('value', texto);
	}
}
var tagAlvo = new Array('p','h3');
var tamanhos = new Array( '16px','17px','19px','21px','23px','25px','27px' );
var tamanhoInicial = 1;
function mudaTamanho( idAlvo,acao ){
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 6 ) tamanho = 6;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  selecionados.style.fontSize = tamanhos[ tamanho ];
  selecionados.style.lineHeight = tamanhos[ tamanho ];
  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) {tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ]; tagsAlvo[ j ].style.lineHeight = tamanhos[ tamanho ];}
  }
}

function modal(idModal)
{
	//armazena a largura e a altura da tela
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	//Define largura e altura do div#mask iguais �s dimens�oes da tela
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	//efeito de transi��o
	$('#mask').fadeIn(500);
	$('#mask').fadeTo("slow",0.9);
	//armazena a largura e a altura da janela
	var winH = $(window).height();
	var winW = $(window).width();
	//centraliza na tela a janela popup
	$("#"+idModal).css('top',  winH/2-$("#"+idModal).height()/2);
	$("#"+idModal).css('left', winW/2-$("#"+idModal).width()/2);
	$("#"+idModal).css('position', 'fixed');
	//efeito de transi��o
	$("#"+idModal).fadeIn(1000);
}

function fecharModal()
{
	$('#mask, .window').hide();
}

$(document).ready(function()
{
	
	
	$('.link_to_tab').click(function(){
		
		$('#tabs-informacoes').find('.ui-tabs-selected').removeClass('ui-tabs-selected');
		$('#tabs-informacoes').find('.ui-state-active').removeClass('ui-state-active');
		//$('.content-imoveis').css('display','none');
		
		$('li#precos-condicoes a').click();
		
		$( 'html, body' ).animate({ scrollTop : 850 }, 400);
		$('#tabs-5').css('display','block');
		//document.location = '#precos-condicoes';
		
	});
	
	//seleciona os elementos a com atributo name="modal"
	$('a[name=modal]').click(function(e)
	{
		//cancela o comportamento padr�o do link
		e.preventDefault();
		//armazena o atributo href do link
		var id = $(this).attr('href');
		if(this.id.indexOf("geral")>=0)
		{
			mostrarGaleria("geral");
		}
		else if(this.id.indexOf("planta")>=0)
		{
			mostrarGaleria("planta");
		}
		else if(this.id.indexOf("imagens")>=0)
		{
			mostrarGaleria("gerais");
		}
		else if(this.id.indexOf("interior")>=0)
		{
			mostrarGaleria("interior");
		}
		else if(this.id.indexOf("fale_conosco")>=0)
		{
			limparContato();
			
			local = $('.imoveis-interna-info-nome h1').text();
			
			
			if ($('.imoveis-interna-info-nome')[0]) {
				$('#fale_conosco #empreendimento option').each(function() {
					//alert($(this).val()+'   '+local)
					if ($(this).val().trim() == local) {
						$(this).attr('selected',true);
					}
				}); 
			}
			
			
			
			
		}
		else if(this.id.indexOf("newsletter")>=0)
		{
			limparNewsletter();
		}
		else if(this.id.indexOf("login")>=0)
		{
			limparModalLogin();
		}
		//armazena a largura e a altura da tela
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
		//Define largura e altura do div#mask iguais �s dimens�oes da tela
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		//efeito de transi��o
		$('#mask').fadeIn(500);
		$('#mask').fadeTo("slow",0.9);
		//armazena a largura e a altura da janela
		var winH = $(window).height();
		var winW = $(window).width();
		//centraliza na tela a janela popup
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
		$(id).css('position', 'fixed');
		//efeito de transi��o
		$(id).fadeIn(1000);
	});
	//se o bot�oo fechar for clicado
	$('.window .close').click(function (e)
	{
		//cancela o comportamento padr�o do link
		e.preventDefault();
		$('#mask, .window').hide();
	});
	//se div#mask for clicado
	$('#mask').click(function ()
	{
		$(this).hide();
		$('.window').hide();
	});
});

var idImagemAtual = 0;
var idImgSelecionada = "";
var tipoGaleria = "geral";
var divSelecionadaThumbs = 0;
var qtdDivs = 0;
var qtdDivsGeral = 0;
var qtdDivsPlantas = 0;
var qtdDivsGerais = 0;
var qtdDivsInterior = 0;
var idImgSelecionadaPlantas = "";
var idImgSelecionadaGeral = "";
var idImgSelecionadaGerais = "";
var idImgSelecionadaInterior = "";
var legendaGeral = "";
var legendaPlantas = "";
var legendaGerais = "";
var legendaInterior = "";
function mostrarGaleria(tipo)
{
	tipoGaleria = tipo;
	divSelecionadaThumbs = 0;
	$("#imagem_"+idImagemAtual).hide();
	$("#imagens_todas_geral").hide();
	$("#imagens_plantas").hide();
	$("#imagens_gerais").hide();
	$("#imagens_interior").hide();
	$('#seta_cima').hide();
	var aux = "";
	if(tipo=="geral")
	{
		idImagemAtual = 0;
		idImgSelecionada = idImgSelecionadaGeral;
		qtdDivs = qtdDivsGeral;
		aux = "imagens_todas_";
		$("#legenda_imagem").html(legendaGeral);
		$("#imagens_todas_geral").show();
	}
	else if(tipo=="planta")
	{
		idImagemAtual = inicioImagensPlantas;
		idImgSelecionada = idImgSelecionadaPlantas;
		qtdDivs = qtdDivsPlantas;
		aux = "imagens_plantas_";
		$("#legenda_imagem").html(legendaPlantas);
		$("#imagens_plantas").show();
	}
	else if(tipo=="gerais")
	{
		idImagemAtual = inicioImagensGerais;
		idImgSelecionada = idImgSelecionadaGerais;
		qtdDivs = qtdDivsGerais;
		aux = "imagens_gerais_";
		$("#legenda_imagem").html(legendaGerais);
		$("#imagens_gerais").show();
	}
	else if(tipo=="interior")
	{
		idImagemAtual = inicioImagensInterior;
		idImgSelecionada = idImgSelecionadaInterior;
		qtdDivs = qtdDivsInterior;
		aux = "imagens_interior_";
		$("#legenda_imagem").html(legendaInterior);
		$("#imagens_interior").show();
	}
	if(qtdDivs>1) { $('#seta_baixo').show(); }else{ $('#seta_baixo').hide(); }
	var c = 0;
	while(c<qtdDivs)
	{
		$("#"+aux+c).hide();
		c++;
	}
	$("#"+aux+"0").show();
	$("#imagem_"+idImagemAtual).show();
}
function avancarGaleria()
{
	if(tipoGaleria == "geral")
	{
		var aux = "#imagens_todas_";
	}
	else if(tipoGaleria == "planta")
	{
		var aux = "#imagens_plantas_";
	}
	else if(tipoGaleria == "gerais")
	{
		var aux = "#imagens_gerais_";
	}
	else if(tipoGaleria == "interior")
	{
		var aux = "#imagens_interior_";
	}
	$(aux+divSelecionadaThumbs).hide();
	divSelecionadaThumbs++;
	if(divSelecionadaThumbs) { $('#seta_cima').show(); }
	if(divSelecionadaThumbs==(qtdDivs-1))
	{
		$('#seta_baixo').hide();
	}
	else
	{
		$('#seta_baixo').show();
	}
	$(aux+divSelecionadaThumbs).fadeIn(1000);
}
function voltarGaleria()
{
	if(tipoGaleria == "geral")
	{
		var aux = "#imagens_todas_";
	}
	else if(tipoGaleria == "planta")
	{
		var aux = "#imagens_plantas_";
	}
	else if(tipoGaleria == "gerais")
	{
		var aux = "#imagens_gerais_";
	}
	else if(tipoGaleria == "interior")
	{
		var aux = "#imagens_interior_";
	}
	$(aux+divSelecionadaThumbs).hide();
	divSelecionadaThumbs--;
	if(divSelecionadaThumbs==0)
	{
		$('#seta_cima').hide();
	}
	$('#seta_baixo').show();
	$(aux+divSelecionadaThumbs).fadeIn(1000);
}
function alterarImagemGaleria(idImagem,idImg,legenda)
{
	$("#imagem_"+idImagemAtual).hide();
	$("#imagem_"+idImagem).fadeIn(500);
	$("#"+idImgSelecionada).attr('class','');
	$("#"+idImg).attr('class',"selecionada");
	$("#legenda_imagem").html(legenda);
	idImgSelecionada = idImg;
	idImagemAtual = idImagem;
}

function verificaemail(email)
{
	var achou_ponto=false;
	var achou_arroba=false;
	var achou_caracter=false;

	for (var i=0; i<email.length; i++)
	{
		if (email.charAt(i)=="@") achou_arroba=true;
		else if (email.charAt(i)==".") achou_ponto=true;
		else if (email.charAt(i)!=" ") achou_caracter=true;
	}
	return (achou_ponto & achou_arroba & achou_caracter);
}

function limparNewsletter()
{
	$('#erro-campo-nome_news_modal').hide();
	$('#erro-campo-email_news_modal').hide();
	$('#erro-campo-email_news_modal').html("campo obrigat&aocute;rio");
	$('#nome_news_modal').val("");
	$("#nome_news_modal").attr('class',"");
	$('#email_news_modal').val("");
	$("#email_news_modal").attr('class',"");
	$('#loading_newsletter').hide();
	$('#retorno_newsletter').hide();
	$('#msg_retorno_newsletter').hide();
	$('#container_newsletter').show();
}

function voltarRetornoNewsletterModal()
{
	$('#retorno_newsletter').hide();
	$('#container_newsletter').show();
}

function enviarNewsletterModal()
{
	var erros = 0;
	if(!$("#nome_news_modal").val())
	{
		$('#erro-campo-nome_news_modal').show();
		$("#nome_news_modal").attr('class',"ativo");
		erros++;
	}
	else
	{
		$('#erro-campo-email_news_modal').hide();
		$("#email_news_modal").attr('class',"");
	}

	if(!$("#email_news_modal").val())
	{
		$('#erro-campo-email_news_modal').html("campo obrigat&oacute;rio");
		$('#erro-campo-email_news_modal').show();
		$("#email_news_modal").attr('class',"ativo");
		erros++;
	}
	else
	{
		//verifica se o email eh valido
		if(!verificaemail($("#email_news_modal").val()))
		{
			$('#erro-campo-email_news_modal').html("&nbsp;&nbsp;&nbsp;e-mail inv&aacute;lido");
			$('#erro-campo-email_news_modal').show();
			$("#email_news_modal").attr('class',"ativo");
			erros++;
		}
		else
		{
			$('#erro-campo-email_news_modal').hide();
			$("#email_news_modal").attr('class',"");
		}
	}

	if(!erros)
	{
		var dadosFormulario = $('#frm_newsletter_modal').serialize();
		$('#container_newsletter').hide();
		$('#loading_newsletter').show();
		$.ajax({type: "POST",  url: urlSite+"ajaxNewsletter.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
		success: function(retorno)
		{

			if(retorno=="OK")
			{
				limparNewsletter();
				$('#container_newsletter').hide();
				$('#icone_retorno_erro_newsletter').hide();
				$('#icone_retorno_sucesso_newsletter').show();
				$('#titulo_retorno_newsletter').html("Newsletter");
				$('#msg_retorno_newsletter').html("Seu cadastro foi realizado com sucesso!");
				$('#msg_retorno_newsletter').show();
				$('#retorno_newsletter').show();
			}
			else
			{
				$('#loading_newsletter').hide();
				$('#icone_retorno_sucesso_newsletter').hide();
				$('#icone_retorno_erro_newsletter').show();
				$('#titulo_retorno_newsletter').html("Newsletter");
				$('#msg_retorno_newsletter').html(retorno);
				$('#msg_retorno_newsletter').show();
				$('#bt_voltar_retorno_newsletter').show();
				$('#retorno_newsletter').show();
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert("ERRO: "+textStatus);
		}
		});
	}
	return false;
}

function exibirRetorno(tipo,titulo,msgRetorno)
{
	if(tipo=="ERRO")
	{
		$('#icone_retorno_sucesso').hide();
		$('#icone_retorno_erro').show();
	}
	else if(tipo=="SUCESSO")
	{
		$('#icone_retorno_erro').hide();
		$('#icone_retorno_sucesso').show();
	}
	$('#titulo_retorno').html(titulo);
	$('#msg_retorno').html(msgRetorno);
	modal("retorno_operacoes");
}

function enviarNewsletterSemModal()
{
	if(!$("#nome_news").val() && !$("#email_news").val())
	{
		exibirRetorno("ERRO","Newsletter","Digite seu nome e seu e-mail.");
	}
	else
	{
		if(!$("#nome_news").val())
		{
			exibirRetorno("ERRO","Newsletter","Digite seu nome.");
		}
		else
		{
			if(!$("#email_news").val())
			{
				exibirRetorno("ERRO","Newsletter","Digite seu e-mail.");
			}
			else
			{
				//valida o email
				if(!verificaemail($("#email_news").val()))
				{
					exibirRetorno("ERRO","Newsletter","E-mail inválido.");
				}
				else
				{
					//efetua o ajax da newsletter
					var dadosFormulario = $('#frm_newsletter').serialize();
					$.ajax({type: "POST",  url: urlSite+"ajaxNewsletter.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
					success: function(retorno)
					{
						if(retorno=="OK")
						{
							$('#nome_news').val("");
							$('#email_news').val("");
							exibirRetorno("SUCESSO","Newsletter","Seu cadastro foi realizado com sucesso!");
						}
						else
						{
							exibirRetorno("ERRO","Newsletter",retorno);
						}
					},
					error: function(XMLHttpRequest, textStatus, errorThrown)
					{
						alert("ERRO: "+textStatus);
					}
					});
				}
			}
		}
	}
	return false;
}

function limparContato()
{
	$('#erro-campo-nome_contato').hide();
	$('#erro-campo-email_contato').hide();
	$('#erro-campo-email_contato').html("campo obrigat&aocute;rio");
	$('#erro-campo-mensagem_contato').hide();
	$('#loading_contato').hide();
	$('#retorno_contato').hide();
	$('#msg_retorno_contato').hide();
	$('#nome_contato').val("");
	$("#nome_contato").attr('class',"");
	$('#email_contato').val("");
	$("#email_contato").attr('class',"");
	$('#mensagem_contato').val("");
	$("#mensagem_contato").attr('class',"");
	$('#ddd_telefone_contato').val("");
	$('#telefone_contato').val("");
	$("#tipofoneum").attr("checked","checked");
	$("#tipofonedois").attr("checked","");
	$("#tipofonetres").attr("checked","");
	$('#container_contato').show();
}

function enviarContato()
{
	var erros = 0;
	if(!$("#nome_contato").val())
	{
		$('#erro-campo-nome_contato').show();
		$("#nome_contato").attr('class',"ativo");
		erros++;
	}
	else
	{
		$('#erro-campo-nome_contato').hide();
		$("#nome_contato").attr('class',"");
	}

	if(!$("#email_contato").val())
	{
		$('#erro-campo-email_contato').html("campo obrigat&oacute;rio");
		$('#erro-campo-email_contato').show();
		$("#email_contato").attr('class',"ativo");
		erros++;
	}
	else
	{
		//verifica se o email eh valido
		if(!verificaemail($("#email_contato").val()))
		{
			$('#erro-campo-email_contato').html("e-mail inv&aacute;lido");
			$('#erro-campo-email_contato').show();
			$("#email_contato").attr('class',"ativo");
			erros++;
		}
		else
		{
			$('#erro-campo-email_contato').hide();
			$("#email_contato").attr('class',"");
		}
	}

	if(!$("#mensagem_contato").val())
	{
		$('#erro-campo-mensagem_contato').show();
		$("#mensagem_contato").attr('class',"ativo");
		erros++;
	}
	else
	{
		$('#erro-campo-mensagem_contato').hide();
		$("#mensagem_contato").attr('class',"");
	}
	
	if(!$("#empreendimento").val())
	{
		$('#erro-campo-empreendimento').show();
		$("#empreendimento").attr('class',"ativo");
		erros++;
	}
	else
	{
		$('#erro-campo-empreendimento').hide();
		$("#empreendimento").attr('class',"");
	}

	if(!erros)
	{
		var dadosFormulario = $('#frm_contato').serialize();
		$('#container_contato').hide();
		$('#loading_contato').show();
		$.ajax({type: "POST",  url: urlSite+"ajaxContato.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
		success: function(retorno)
		{
			if(retorno=="OK")
			{
				limparContato();
				$('#container_contato').hide();
				$('#icone_retorno_erro_contato').hide();
				$('#icone_retorno_sucesso_contato').show();
				$('#titulo_retorno_contato').html("Fale conosco");
				$('#msg_retorno_contato').html("Seu contato foi enviado com sucesso.");
				$('#msg_retorno_contato').show();
				$('#retorno_contato').show();
				_gaq.push(['_trackPageview', '/fale-conosco/modal/atendimentonline']);
				//pageTracker._trackPageview('/fale-conosco/modal/atendimentonline');
			}
			else
			{
				$('#loading_contato').hide();
				$('#icone_retorno_sucesso_contato').hide();
				$('#icone_retorno_erro_contato').show();
				$('#titulo_retorno_contato').html("Recuperar senha");
				$('#msg_retorno_contato').html(retorno);
				$('#msg_retorno_contato').show();
				$('#bt_voltar_retorno_contato').show();
				$('#retorno_contato').show();
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert("ERRO: "+textStatus);
		}
		});
	}

	return false;
}

var ulAtualImagensGeral = 0;
var ulAtualImagensInterior = 0;
var ulAtualImagensDownloads = 0;
var ulAtualImagensPlantas = 0;
var ulAtualImagensAreasComuns = 0;
var ulAtualImagensObras = 0;
var ulAtualImagensInstitucional = 0;
var ulAtualImagensDecorado = 0;

function proximoImagensImovel(tipo)
{
	var atual = 0;
	var proxima = 0;
	var id = "";
	if(tipo=="geral")
	{
		atual = ulAtualImagensGeral;
		proxima = ulAtualImagensGeral+1;
		ulAtualImagensGeral++;
		id = "ul_imagens_geral_";

		if(ulAtualImagensGeral+1==qtdUlImagensGeral)
		{
			$('#proximo_img_geral').hide();
		}
		$('#anterior_img_geral').show();
	}
	else if(tipo=="planta")
	{
		atual = ulAtualImagensPlantas;
		proxima = ulAtualImagensPlantas+1;
		ulAtualImagensPlantas++;
		id = "ul_imagens_plantas_";
		if(ulAtualImagensPlantas+1==qtdUlImagensPlantas)
		{
			$('#proximo_img_plantas').hide();
		}
		$('#anterior_img_plantas').show();
	}
	else if(tipo=="interior")
	{
		atual = ulAtualImagensInterior;
		proxima = ulAtualImagensInterior+1;
		ulAtualImagensInterior++;
		id = "ul_imagens_interior_";
		if(ulAtualImagensInterior+1==qtdUlImagensInterior)
		{
			$('#proximo_img_interior').hide();
		}
		$('#anterior_img_interior').show();
	}
	else if(tipo=="downloads")
	{
		atual = ulAtualImagensDownloads;
		proxima = ulAtualImagensDownloads+1;
		ulAtualImagensDownloads++;
		id = "ul_imagens_downloads_";
		if(ulAtualImagensDownloads+1==qtdUlImagensDownloads)
		{
			$('#proximo_img_downloads').hide();
		}
		$('#anterior_img_downloads').show();
	}
	else if(tipo=="obra")
	{
		atual = ulAtualImagensObras;
		proxima = ulAtualImagensObras+1;
		ulAtualImagensObras++;
		id = "ul_imagens_obras_";
		if(ulAtualImagensObras+1==qtdUlImagensObras)
		{
			$('#proximo_img_obras').hide();
		}
		$('#anterior_img_obras').show();
	}
	else if(tipo=="areas_comuns")
	{
		atual = ulAtualImagensAreasComuns;
		proxima = ulAtualImagensAreasComuns+1;
		ulAtualImagensAreasComuns++;
		id = "ul_imagens_areas_comuns_";
		if(ulAtualImagensAreasComuns+1==qtdUlImagensAreasComuns)
		{
			$('#proximo_img_areas_comuns').hide();
		}
		$('#anterior_img_areas_comuns').show();
	}
	else if(tipo=="institucional")
	{
		atual = ulAtualImagensInstitucional;
		proxima = ulAtualImagensInstitucional+1;
		ulAtualImagensInstitucional++;
		id = "ul_imagens_institucional_";
		if(ulAtualImagensInstitucional+1==qtdUlImagensInstitucional)
		{
			$('#proximo_img_institucional').hide();
		}
		$('#anterior_img_institucional').show();
	}
	else if(tipo=="decorado")
	{
		atual = ulAtualImagensDecorado;
		proxima = ulAtualImagensDecorado+1;
		ulAtualImagensDecorado++;
		id = "ul_imagens_decorado_";
		if(ulAtualImagensDecorado+1==qtdUlImagensDecorado)
		{
			$('#proximo_img_institucional').hide();
		}
		$('#proximo_img_decorado').show();
	}

	$('#'+id+atual).hide();
	$('#'+id+proxima).show();
}

function anteriorImagensImovel(tipo)
{
	var atual = 0;
	var anterior = 0;
	var id = "";
	if(tipo=="geral")
	{
		atual = ulAtualImagensGeral;
		anterior = ulAtualImagensGeral-1;
		ulAtualImagensGeral--;
		id = "ul_imagens_geral_";
		if(ulAtualImagensGeral==0)
		{
			$('#anterior_img_geral').hide();
		}
		$('#proximo_img_geral').show();
	}
	else if(tipo=="planta")
	{
		atual = ulAtualImagensPlantas;
		anterior = ulAtualImagensPlantas-1;
		ulAtualImagensPlantas--;
		id = "ul_imagens_plantas_";
		if(ulAtualImagensPlantas==0)
		{
			$('#anterior_img_plantas').hide();
		}
		$('#proximo_img_plantas').show();
	}
	else if(tipo=="interior")
	{
		atual = ulAtualImagensInterior;
		anterior = ulAtualImagensInterior-1;
		ulAtualImagensInterior--;
		id = "ul_imagens_interior_";
		if(ulAtualImagensInterior==0)
		{
			$('#anterior_img_interior').hide();
		}
		$('#proximo_img_interior').show();
	}
	else if(tipo=="downloads")
	{
		atual = ulAtualImagensDownloads;
		anterior = ulAtualImagensDownloads-1;
		ulAtualImagensDownloads--;
		id = "ul_imagens_downloads_";
		if(ulAtualImagensDownloads==0)
		{
			$('#anterior_img_downloads').hide();
		}
		$('#proximo_img_downloads').show();
	}
	else if(tipo=="obra")
	{
		atual = ulAtualImagensObras;
		anterior = ulAtualImagensObras-1;
		ulAtualImagensObras--;
		id = "ul_imagens_obras_";
		if(ulAtualImagensObras==0)
		{
			$('#anterior_img_obras').hide();
		}
		$('#proximo_img_obras').show();
	}
	else if(tipo=="areas_comuns")
	{
		atual = ulAtualImagensAreasComuns;
		anterior = ulAtualImagensAreasComuns-1;
		ulAtualImagensAreasComuns--;
		id = "ul_imagens_areas_comuns_";
		if(ulAtualImagensAreasComuns==0)
		{
			$('#anterior_img_areas_comuns').hide();
		}
		$('#proximo_img_areas_comuns').show();
	}
	else if(tipo=="institucional")
	{
		atual = ulAtualImagensInstitucional;
		anterior = ulAtualImagensInstitucional-1;
		ulAtualImagensInstitucional--;
		id = "ul_imagens_institucional_";
		if(ulAtualImagensInstitucional==0)
		{
			$('#anterior_img_institucional').hide();
		}
		$('#proximo_img_institucional').show();
	}
	else if(tipo=="decorado")
	{
		atual = ulAtualImagensDecorado;
		anterior = ulAtualImagensDecorado-1;
		ulAtualImagensDecorado--;
		id = "ul_imagens_decorado_";
		if(ulAtualImagensDecorado==0)
		{
			$('#anterior_img_decorado').hide();
		}
		$('#proximo_img_decorado').show();
	}

	$('#'+id+atual).hide();
	$('#'+id+anterior).show();
}


var focusAutocompletar = false;
var focusInputBusca = false;
var palavraAtualAutocompletar = -1;
var autocompletarVisivel = false;
var palavraDigitadaBusca = "";

function esconderAutocompletar()
{
	if(!focusAutocompletar) { $('#autocompletar').hide(); palavraAtualAutocompletar = -1; autocompletarVisivel = false; focusAutocompletar = false;}
}

function entrarAutocompletar()
{
	focusAutocompletar = true;
}

function sairAutocompletar()
{
	focusAutocompletar = false;
	if(!focusInputBusca && !$('#input_busca').onFocus())
	{
		palavraAtualAutocompletar = -1;
		autocompletarVisivel = false;
		$('#autocompletar').hide();
	}
}

function setaBaixoAutocompletar()
{
	if(palavraAtualAutocompletar<0) { palavraDigitadaBusca = $('#input_busca').val(); }
	if(autocompletarVisivel && document.getElementById('autocompletar_palavra_'+(palavraAtualAutocompletar+1)))
	{
		if(document.getElementById('autocompletar_palavra_'+palavraAtualAutocompletar)) {$('#autocompletar_palavra_'+(palavraAtualAutocompletar)).attr('class','');}
		$('#autocompletar_palavra_'+(palavraAtualAutocompletar+1)).attr('class','ativo');
		$('#input_busca').val(document.getElementById('autocompletar_palavra_'+(palavraAtualAutocompletar+1)).title);
		palavraAtualAutocompletar++;
	}
}

function setaCimaAutocompletar()
{
	if(autocompletarVisivel && document.getElementById('autocompletar_palavra_'+(palavraAtualAutocompletar-1)))
	{
		if(document.getElementById('autocompletar_palavra_'+palavraAtualAutocompletar)) {$('#autocompletar_palavra_'+(palavraAtualAutocompletar)).attr('class','');}
		$('#autocompletar_palavra_'+(palavraAtualAutocompletar-1)).attr('class','ativo');
		$('#input_busca').val(document.getElementById('autocompletar_palavra_'+(palavraAtualAutocompletar-1)).title);
		palavraAtualAutocompletar--;
	}
	else if(palavraAtualAutocompletar==0)
	{
		$('#autocompletar_palavra_0').attr('class','');
		$('#input_busca').val(palavraDigitadaBusca);
		palavraAtualAutocompletar--;
	}
}

function selecionarAutocompletarPorMouse(numeroPalavra)
{
	if(palavraAtualAutocompletar<0) { palavraDigitadaBusca = $('#input_busca').val(); }
	if(document.getElementById('autocompletar_palavra_'+palavraAtualAutocompletar)) {$('#autocompletar_palavra_'+(palavraAtualAutocompletar)).attr('class','');}
	$('#autocompletar_palavra_'+(numeroPalavra)).attr('class','ativo');
	$('#input_busca').val(document.getElementById('autocompletar_palavra_'+numeroPalavra).title);
	palavraAtualAutocompletar = numeroPalavra;
}

function autocompletar(event)
{
	if(document.all) { // Internet Explorer
	   var nTecla = event.keyCode;
	} else if(document.layers) { // Firefox
	   var nTecla = event.which;
	} else {
	    nTecla = event.which;
	}
	if(nTecla!=13 && nTecla!=38 && nTecla!=40 && nTecla!=37 && nTecla!=39 && nTecla!=27)
	{
		palavraAtualAutocompletar = -1;

		if(trim($('#input_busca').val()))
		{
			var dadosFormulario = $('#frm_busca_topo').serialize();
			$.ajax({type: "POST",  url: urlSite+"ajaxAutocompletar.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
			success: function(retorno)
			{
				if(retorno!="ND")
				{
					var palavras = retorno.split("####");
					var retornoPalavras = "";
					for(var i in palavras)
					{
						if(palavras[i]) { retornoPalavras += '<li><a id="autocompletar_palavra_'+i+'" href="'+urlSite+'?s='+palavras[i]+'" title="'+palavras[i]+'" onmouseover="selecionarAutocompletarPorMouse('+i+');">'+palavras[i]+'</a></li>';}
					}
					$('#autocompletar').html(retornoPalavras);
					autocompletarVisivel = true;
					$('#autocompletar').show();
				}
				else
				{
					$('#autocompletar').hide();
				}
			},
			error: function(XMLHttpRequest, textStatus, errorThrown)
			{
				alert("ERRO: "+textStatus);
			}
			});
		}
	}
	else
	{
		if(nTecla==40)
		{
			setaBaixoAutocompletar();
		}
		else if(nTecla==38)
		{
			setaCimaAutocompletar();
		}
		else if(nTecla==27)
		{
			if(palavraDigitadaBusca) {$('#input_busca').val(palavraDigitadaBusca); palavraDigitadaBusca = ""; }
			esconderAutocompletar();
		}
	}
}

var tagAlvo = new Array('p','strong');
var tamanhos = new Array( '14px','16px','18px','20px','22px','24px','26px' );
var tamanhoInicial = 0;

function mudaTamanho(idAlvo,acao)
{
  if (!document.getElementById) return
  var selecionados = null,tamanho = tamanhoInicial,i,j,tagsAlvo;
  tamanho += acao;
  if ( tamanho < 0 ) tamanho = 0;
  if ( tamanho > 6 ) tamanho = 6;
  tamanhoInicial = tamanho;
  if ( !( selecionados = document.getElementById( idAlvo ) ) ) selecionados = document.getElementsByTagName( idAlvo )[ 0 ];
  selecionados.style.fontSize = tamanhos[ tamanho ];
  selecionados.style.lineHeight = tamanhos[ tamanho ];

	var tamanhoLinha = tamanhos[tamanho];
	if(tamanho<2) { tamanhoLinha = "16px"; }
  for ( i = 0; i < tagAlvo.length; i++ ){
    tagsAlvo = selecionados.getElementsByTagName( tagAlvo[ i ] );
    for ( j = 0; j < tagsAlvo.length; j++ ) {tagsAlvo[ j ].style.fontSize = tamanhos[ tamanho ]; tagsAlvo[ j ].style.lineHeight = tamanhoLinha;}
  }
}

function enviarComentario()
{
	if(!$("#nome_comentario").val() && !$("#email_comentario").val() && !$("#comentario").val())
	{
		exibirRetorno("ERRO","Comentários","Digite seu nome, e-mail e comentário.");
	}
	else
	{
		if(!$("#nome_comentario").val())
		{
			exibirRetorno("ERRO","Comentários","Digite seu nome.");
		}
		else
		{
			if(!$("#email_comentario").val())
			{
				exibirRetorno("ERRO","Comentários","Digite seu e-mail.");
			}
			else
			{
				//valida o email
				if(!verificaemail($("#email_comentario").val()))
				{
					exibirRetorno("ERRO","Comentários","E-mail inválido.");
				}
				else
				{
					if(!$("#comentario").val())
					{
						exibirRetorno("ERRO","Comentários","Digite seu comentário.");
					}
					else
					{
						//envia o comentario
						var dadosFormulario = $('#frm_comentario').serialize();
						$.ajax({type: "POST",  url: urlSite+"ajaxNovoComentario.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
						success: function(retorno)
						{
							if(retorno=="OK")
							{
								$("#nome_comentario").val("");
								$("#email_comentario").val("");
								$("#comentario").val("");
								exibirRetorno("SUCESSO","Comentários","Seu comentário foi adicionado com sucesso!<br/>Após aprovação ele será exibido no site.");
							}
							else
							{
								exibirRetorno("ERRO","Comentários",retorno);
							}
						},
						error: function(XMLHttpRequest, textStatus, errorThrown)
						{
							alert("ERRO: "+textStatus);
						}
						});
					}
				}
			}
		}
	}
	return false;
}

function limparModalLogin()
{
	$('#loading_cadastro').hide();
	$('#retorno_cadastro').hide();
	$('#recuperar_senha').hide();
	$('#erro-campo-email_login').hide();
	$("#email_login").attr('class',"");
	$('#erro-campo-senha_login').hide();
	$("#senha_login").attr('class',"");
	$("#email_login").val("");
	$("#senha_login").val("");

	$("#nome_novo_cadastro").val("");
	$("#email_novo_cadastro").val("");
	$("#nome_novo_cadastro").attr('class',"");
	$("#email_novo_cadastro").attr('class',"");

	$('#bt_voltar_retorno_cadastro').hide();

	$('#container_cadastro').show();
}

var voltarModalLogin = "container_cadastro";

function loginUsuario()
{
	var erros = 0;
	if(!$("#email_login").val())
	{
		$('#erro-campo-email_login').html("campo obrigat&oacute;rio");
		$('#erro-campo-email_login').show();
		$("#email_login").attr('class',"ativo");
		erros++;
	}
	else
	{
		$('#erro-campo-email_login').hide();
		$("#email_login").attr('class',"");
	}

	if(!$("#senha_login").val())
	{
		$('#erro-campo-senha_login').html("campo obrigat&oacute;rio");
		$('#erro-campo-senha_login').show();
		$("#senha_login").attr('class',"ativo");
		erros++;
	}
	else
	{
		$('#erro-campo-senha_login').hide();
		$("#senha_login").attr('class',"");
	}

	if(!erros)
	{
		//tenta efetuar o login
		$('#container_cadastro').hide();
		$('#loading_cadastro').show();
		var dadosFormulario = $('#frm_login').serialize();
		$.ajax({type: "POST",  url: urlSite+"ajaxLogin.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
		success: function(retorno)
		{
			if(retorno=="OK")
			{
				document.location.reload();
			}
			else
			{
				$('#loading_cadastro').hide();
				$('#icone_retorno_sucesso_cadastro').hide();
				$('#icone_retorno_erro_cadastro').show();
				$('#titulo_retorno_cadastro').html("Login");
				$('#msg_retorno_cadastro').html(retorno);
				$('#container_cadastro').hide();
				$('#bt_voltar_retorno_cadastro').show();
				$('#retorno_cadastro').show();
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert("ERRO: "+textStatus);
		}
		});
	}
	return false;
}

function voltarRetornoCadastro()
{
	$('#retorno_cadastro').hide();
	$('#'+voltarModalLogin).show();
}

function adicionarUsuario()
{
	var erros = 0;
	if(!$("#nome_novo_cadastro").val())
	{
		$('#erro-campo-nome_novo_cadastro').html("campo obrigat&oacute;rio");
		$('#erro-campo-nome_novo_cadastro').show();
		$("#nome_novo_cadastro").attr('class',"ativo");
		erros++;
	}
	else
	{
		$('#erro-campo-nome_novo_cadastro').hide();
		$("#nome_novo_cadastro").attr('class',"");
	}

	if(!$("#email_novo_cadastro").val())
	{
		$('#erro-campo-email_novo_cadastro').html("campo obrigat&oacute;rio");
		$('#erro-campo-email_novo_cadastro').show();
		$("#email_novo_cadastro").attr('class',"ativo");
		erros++;
	}
	else
	{
		//verifica se o email eh valido
		if(!verificaemail($("#email_novo_cadastro").val()))
		{
			$('#erro-campo-email_novo_cadastro').html("e-mail inv&aacute;lido");
			$('#erro-campo-email_novo_cadastro').show();
			$("#email_novo_cadastro").attr('class',"ativo");
			erros++;
		}
		else
		{
			$('#erro-campo-email_novo_cadastro').hide();
			$("#email_novo_cadastro").attr('class',"");
		}
	}

	if(!erros)
	{
		//tenta cadastrar o usuário
		$('#container_cadastro').hide();
		$('#loading_cadastro').show();
		var dadosFormulario = $('#frm_cadastro').serialize();
		$.ajax({type: "POST",  url: urlSite+"ajaxLogin.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
		success: function(retorno)
		{
			$('#loading_cadastro').hide();
			if(retorno=="OK")
			{
				$('#icone_retorno_erro_cadastro').hide();
				$('#icone_retorno_sucesso_cadastro').show();
				$('#titulo_retorno_cadastro').html("Novo usu&aacute;rio");
				$('#msg_retorno_cadastro').html("Seu usuário foi adicionado com sucesso!\n\nVocê receberá um e-mail confirmando seu cadastro e contendo seus dados de acesso com sua senha provisória.");
				$('#container_cadastro').hide();
				$('#retorno_cadastro').show();
			}
			else
			{
				$('#icone_retorno_sucesso_cadastro').hide();
				$('#icone_retorno_erro_cadastro').show();
				$('#titulo_retorno_cadastro').html("Novo usu&aacute;rio");
				$('#msg_retorno_cadastro').html(retorno);
				$('#container_cadastro').hide();
				$('#bt_voltar_retorno_cadastro').show();
				$('#retorno_cadastro').show();
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert("ERRO: "+textStatus);
		}
		});
	}
	return false;
}

function voltarRecuperarSenha()
{
	$('#recuperar_senha').hide();
	voltarModalLogin = "container_cadastro";
	$('#container_cadastro').show();
}

function recuperarSenha()
{
	$('#erro-campo-email_recuperar_senha').hide();
	$('#email_recuperar_senha').val("");
	$("#email_recuperar_senha").attr('class',"");

	$('#container_cadastro').hide();
	$('#recuperar_senha').show();
}

function enviarRecuperarSenha()
{
	var erros = 0;
	if(!$("#email_recuperar_senha").val())
	{
		$('#erro-campo-email_recuperar_senha').html("campo obrigat&oacute;rio");
		$('#erro-campo-email_recuperar_senha').show();
		$("#email_recuperar_senha").attr('class',"ativo");
		erros++;
	}
	else
	{
		//verifica se o email eh valido
		if(!verificaemail($("#email_recuperar_senha").val()))
		{
			$('#erro-campo-email_recuperar_senha').html("e-mail inv&aacute;lido");
			$('#erro-campo-email_recuperar_senha').show();
			$("#email_recuperar_senha").attr('class',"ativo");
			erros++;
		}
		else
		{
			$('#erro-campo-email_recuperar_senha').hide();
			$("#email_recuperar_senha").attr('class',"");
		}
	}

	if(!erros)
	{
		//tenta recuperar a senha o usuário
		$('#recuperar_senha').hide();
		$('#loading_cadastro').show();
		var dadosFormulario = $('#frm_recuperar_senha').serialize();
		//alert(dadosFormulario);
		$.ajax({type: "POST",  url: urlSite+"ajaxLogin.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
		success: function(retorno)
		{
			$('#loading_cadastro').hide();
			if(retorno=="OK")
			{
				$('#icone_retorno_erro_cadastro').hide();
				$('#icone_retorno_sucesso_cadastro').show();
				$('#titulo_retorno_cadastro').html("Recuperar senha");
				$('#msg_retorno_cadastro').html("Um e-mail foi enviado a você com os procedimentos para a recuperação de sua senha.");
				$('#recuperar_senha').hide();
				$('#retorno_cadastro').show();
			}
			else
			{
				$('#icone_retorno_sucesso_cadastro').hide();
				$('#icone_retorno_erro_cadastro').show();
				$('#titulo_retorno_cadastro').html("Recuperar senha");
				$('#msg_retorno_cadastro').html(retorno);
				voltarModalLogin = "recuperar_senha";
				$('#recuperar_senha').hide();
				$('#bt_voltar_retorno_cadastro').show();
				$('#retorno_cadastro').show();
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert("ERRO: "+textStatus);
		}
		});
	}
	return false;
}

function abrirCentralVendasGaleria()
{
	fecharModal();
	modal('central_vendas');
}

function abrirContatoGaleria()
{
	fecharModal();
	modal('fale_conosco');
}

var numeroImagemAberta = 0;
var qtdTotalImagensGaleria = 0;

function proximaImagem()
{
	var proxima = numeroImagemAberta+1;
	if(proxima<qtdTotalImagensGaleria)
	{
		var legendaImagem = "";
		$('#imagem_galeria_imovel_'+numeroImagemAberta).hide();
		$('#imagem_galeria_imovel_'+proxima).show();
		numeroImagemAberta = proxima;
		$('#legenda-imagem-galeria').html($("#imagem_galeria_imovel_"+proxima).attr('title'));
		$('#imagem_atual_galeria_imovel').html(numeroImagemAberta+1);

		$('#link_imprimir_galeria_imovel').attr('href',urlSite+'imprimirImagem.php?i='+$("#imagem_galeria_imovel_"+proxima).attr('name'));
	}

	if(proxima+1>=qtdTotalImagensGaleria)
	{
		$('#proxima_galeria_imovel').hide();
	}
	$('#anterior_galeria_imovel').show();
}

function imagemAnterior()
{
	var anterior = numeroImagemAberta-1;
	if(anterior>=0)
	{
		var legendaImagem = "";
		$('#imagem_galeria_imovel_'+numeroImagemAberta).hide();
		$('#imagem_galeria_imovel_'+anterior).show();
		numeroImagemAberta = anterior;
		//legendaImagem = $("#imagem_galeria_imovel_"+anterior).attr('title');
		$('#legenda-imagem-galeria').html($("#imagem_galeria_imovel_"+anterior).attr('title'));
		$('#imagem_atual_galeria_imovel').html(numeroImagemAberta+1);

		$('#link_imprimir_galeria_imovel').attr('href',urlSite+'imprimirImagem.php?i='+$("#imagem_galeria_imovel_"+anterior).attr('name'));
	}

	if(anterior<=0)
	{
		$('#anterior_galeria_imovel').hide();
	}
	if(qtdTotalImagensGaleria>1) { $('#proxima_galeria_imovel').show(); }
}

function abrirGaleria(numeroImagem,legendaImagem,idImagem)
{
	if(numeroImagemAberta!=numeroImagem)
	{
		$('#imagem_galeria_imovel_'+numeroImagemAberta).hide();
		$('#imagem_galeria_imovel_'+numeroImagem).show();
		numeroImagemAberta = numeroImagem;
	}
	$('#legenda-imagem-galeria').html(legendaImagem);
	$('#imagem_atual_galeria_imovel').html(numeroImagem+1);
	$('#total_imagens_galeria_imovel').html(qtdTotalImagensGaleria);

	if(numeroImagem==0)
	{
		$('#anterior_galeria_imovel').hide();
	}
	else
	{
		$('#anterior_galeria_imovel').show();
	}

	if(numeroImagem+1>=qtdTotalImagensGaleria)
	{
		$('#proxima_galeria_imovel').hide();
	}
	else if(qtdTotalImagensGaleria>1)
	{
		$('#proxima_galeria_imovel').show();
	}

	$('#link_imprimir_galeria_imovel').attr('href',urlSite+'imprimirImagem.php?i='+idImagem);

	//armazena a largura e a altura da tela
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	//Define largura e altura do div#mask iguais �s dimens�oes da tela
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	//efeito de transicao
	$('#mask').fadeIn(500);
	$('#mask').fadeTo("slow",0.9);
	//armazena a largura e a altura da janela
	var winH = $(window).height();
	var winW = $(window).width();
	//centraliza na tela a janela popup
	$("#galeria").css('top',  10);
	$("#galeria").css('left', winW/2-$("#galeria").width()/2);
	$("#galeria").css('position', 'absolute');
	//efeito de transicao
	$("#galeria").fadeIn(1000);
	scrollTo( 0, 0, {queue:true} );
}










function voltarRetornoContato()
{
	$('#retorno_contato').hide();
	$('#container_contato').show();
}

//**** GMAPS ***///

// Referência para a instância de GMap2
var mapa;

// Referência para a instância de GClientGeocoder

// Array para mapear níveis de Zoom com a precisão do resultado
var nivelZoom = [];
    nivelZoom[0] = 2;
    nivelZoom[1] = 8;
    nivelZoom[2] = 10;
    nivelZoom[3] = 12;
    nivelZoom[4] = 13;
    nivelZoom[5] = 14;
    nivelZoom[6] = 15;
    nivelZoom[7] = 16;
    nivelZoom[8] = 18;

var latitudeImovel = "";
var longitudeImovel = "";
var enderecoImovel = "";
var enderecoRota = "";
var nomeImovel = "";

function verificaCoordenadasEnderecoRota(imovel)
{
	var geocoder = new GClientGeocoder();
	var endereco = $('#end_rota').val();
	if(endereco.indexOf("Curitiba")<0 && endereco.indexOf("curitiba")<0 && endereco.indexOf("CURITIBA")<0) { endereco = endereco + ", Curitiba - PR, Brasil"; }
	enderecoRota = endereco;
	nomeImovel = imovel;
	geocoder.getLatLng(endereco, abrirJanelaRota);
}

function abrirJanelaRota(pontos)
{
	if(pontos.x && pontos.y)
	{
		//abre a janela para exibir a rota
		var de = "";
		var para = "";
		var enderecoDE = "";
		var enderecoPARA = "";
		if(document.getElementById('tipo_rota_de').checked) { de = pontos.y+";"+pontos.x; para = latitudeImovel+";"+longitudeImovel; enderecoDE = enderecoRota; enderecoPARA = nomeImovel + " ("+enderecoImovel+")"; }
		if(document.getElementById('tipo_rota_para').checked) { de = latitudeImovel+";"+longitudeImovel; para = pontos.y+";"+pontos.x; enderecoDE = nomeImovel + " ("+enderecoImovel+")"; enderecoPARA = enderecoRota; }
		window.open(urlSite+"como-chegar.php?de="+de+"&para="+para+"&endD="+enderecoDE+"&endP="+enderecoPARA+"&i="+nomeImovel, "Cálculo de rota", "height = 500, width = 600, scrollbars = yes, location = no, menubar=yes");
	}
}

function exibirRota(latitudePara,longitudePara,latitudeDe,longitudeDe)
{
	mapa = new GMap2(document.getElementById("mapa"));

	mapa.addControl(new GLargeMapControl());

	mapa.addControl(new GMapTypeControl());

	var p = new GLatLng(latitudePara,longitudePara);
	var p2 = new GLatLng(latitudeDe,longitudeDe);

    // Cria um novo marcador que sera exibido no ponto p solicitado
    var marcador = new GMarker(p);
    var marcador2 = new GMarker(p2);

    // Centraliza o mapa na coordenada com nível de zoom
    mapa.setCenter(p2, 1);

    directionsPanel = document.getElementById("rota_txt");
    directions = new GDirections(mapa, directionsPanel);

	directions.load("from: "+latitudeDe+" "+longitudeDe+" to: "+latitudePara+" "+longitudePara, {travelMode: G_TRAVEL_MODE_DRIVING});
}

function verificaCoordenadasEnderecoImovel(endereco)
{
	var geocoder = new GClientGeocoder();
	enderecoImovel = endereco;
	if (geocoder)	geocoder.getLatLng(endereco, setCoordenadasEnderecoImovel);
}

function setCoordenadasEnderecoImovel(point)
{
	longitudeImovel = point.x;
	latitudeImovel = point.y;
}

function inicializarMapa(idMapa)
{
	if (GBrowserIsCompatible())
	{
		mapa = new GMap2(document.getElementById(idMapa));
		mapa.setCenter(new GLatLng(longitudeImovel,latitudeImovel), 16);
		if(!geocoder) {var geocoder = new GClientGeocoder();}
	}
}

var mapaAtivo = false;
var pontosImovel;
function exibirEnderecoGmaps(endereco,etapa)
{
	if(!etapa || etapa==1)
	{
		setTimeout("exibirEnderecoGmaps('"+endereco+"',2)", 50)
	}
	else if(!mapaAtivo)
	{
		var p = new GLatLng(latitudeImovel,longitudeImovel);
	    inicializarMapa('mapa_localizacao_imovel');
		mapaAtivo = true;
	    mapa.setCenter(p, 16);

	    // Adicionamos um controle de zoom e de translação do mapa.
	    // Uma outra opção seria GSmallMapControl para um controle
	    // diminuto
		mapa.addControl(new GLargeMapControl());

	    // Adiciona as opções de visualização do mapa.
	    // As opções disponíveis são: normal, híbrido e satélite
		mapa.addControl(new GMapTypeControl());


         var marker = new GMarker(p);
         mapa.addOverlay(marker);
         marker.openInfoWindowHtml("<img src='"+urlSite+"wp-content/themes/invespark/images/logo-large.jpg' /><br/><br/>"+endereco);

		/*var geocoder = new GClientGeocoder();
		if (geocoder)
		{
			geocoder.getLatLng(endereco,
	          function(point)
	          {
	            if(!point)
	            {
	              	alert(address + " não localizado");
	            }
	            else
	            {
		              inicializarMapa('mapa_localizacao_imovel',point);
					  mapaAtivo = true;
					  pontosImovel = point;
		              mapa.setCenter(point, 16);

					    // Adicionamos um controle de zoom e de translação do mapa.
					    // Uma outra opção seria GSmallMapControl para um controle
					    // diminuto
						mapa.addControl(new GLargeMapControl());

					    // Adiciona as opções de visualização do mapa.
					    // As opções disponíveis são: normal, híbrido e satélite
						mapa.addControl(new GMapTypeControl());

		              var marker = new GMarker(point);
		              mapa.addOverlay(marker);
		              marker.openInfoWindowHtml("<img src='"+urlSite+"wp-content/themes/invespark/images/logo-large.jpg' /><br/><br/>"+endereco);
	            }
	          }
	        );
		}*/
	}
}

//**** FIM GMAPS ***///

function ampliarImagem(idImagem,srcImagem,legenda)
{
	$('#link_imprimir_imagem_ampliada').attr('href',urlSite+'imprimirImagem.php?i='+idImagem);
	$('#imagem_ampliada').attr('src',srcImagem);
	if(legenda)
	{
		$('#legenda-imagem-ampliada').html(legenda);
		$('#div-legenda-imagem-ampliada').show();
	}
	else
	{
		$('#div-legenda-imagem-ampliada').hide();
	}

	//armazena a largura e a altura da tela
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	//Define largura e altura do div#mask iguais �s dimens�oes da tela
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	//efeito de transicao
	$('#mask').fadeIn(500);
	$('#mask').fadeTo("slow",0.9);
	//armazena a largura e a altura da janela
	var winH = $(window).height();
	var winW = $(window).width();
	//centraliza na tela a janela popup
	$("#imagem-ampliada").css('top',  10);
	$("#imagem-ampliada").css('left', winW/2-$("#imagem-ampliada").width()/2);
	$("#imagem-ampliada").css('position', 'absolute');
	//efeito de transicao
	$("#imagem-ampliada").fadeIn(1000);
	scrollTo( 0, 0, {queue:true} );
}

function limparTrabalheConosco()
{
	$('#nome').val("");
	$('#sobrenome').val("");
	$('#dd').val("");
	$('#mm').val("");
	$('#aaaa').val("");
	$('#sexo_m').attr("checked","checked");
	$('#sexo_f').attr("checked","");
	document.getElementById('estado-civil').options[0].selected = "selected";
	$('#cidade').val("");
	$('#estado').val("");
	$('#pais').val("");
	$('#ddd').val("");
	$('#telefone').val("");
	$('#ddd-celular').val("");
	$('#telefone-celular').val("");
	$('#endereco').val("");
	$('#numero').val("");
	$('#complemento').val("");
	$('#email').val("");

	$('#qtdEscolaridade').val("1");
	html = "";
	html += '<table border="0" cellpadding="0" cellspacing="5" class="formulario trabalhe-conosco">';
	html += '<tr>';
	html += 		'<td>';
	html += 			'<label>Nivel de Escolaridade:</label>';
	html += 			'<select name="escolaridade_nivel_0" id="escolaridade_nivel_0">';
	html += 				'<option value="">-- Selecione --</option>';
	html += 				'<option value="Ensino médio incompleto">Ensino médio incompleto</option>';
	html += 				'<option value="Ensino médio completo">Ensino médio completo</option>';
	html += 				'<option value="Superior cursando">Superior cursando</option>';
	html += 				'<option value="Superior incompleto">Superior incompleto</option>';
	html += 				'<option value="Superior completo">Superior completo</option>';
	html += 			'</select>';
	html += 		'</td>';
	html += 		'<td>';
	html += 			'<label>Curso:</label>';
	html += 			'<input type="text" class="curso" name="escolaridade_curso_0" id="escolaridade_curso_0" /></td>';
	html += 		'</td>';
	html += '</tr>';
	html += '<tr>';
	html += 		'<td width="243">';
	html += 			'<label>Data de Inicio: <span class="disclaimer">MM/AAAA</span> </label>';
	html += 			'<input type="text" class="data-inicio-mm" maxlength="2" name="escolaridade_dtinicio_mes_0" id="escolaridade_dtinicio_mes_0" />';
	html += 			'&nbsp;&nbsp;<input type="text" class="data-inicio-aaaa" maxlength="4" name="escolaridade_dtinicio_ano_0" id="escolaridade_dtinicio_ano_0" /></td>';
	html += 		'</td>';
	html += 		'<td width="242">';
	html += 			'<label>Data de conclusão:<span class="disclaimer">MM/AAAA</span></label>';
	html += 			'<input type="text" class="data-conclusao-mm" maxlength="2" name="escolaridade_dtconclusao_mes_0" id="escolaridade_dtconclusao_mes_0" />';
	html += 			'&nbsp;&nbsp;<input type="text" class="data-conclusao-aaaa" maxlength="4" name="escolaridade_dtconclusao_ano_0" id="escolaridade_dtconclusao_ano_0" />';
	html += 		'</td>';
	html += '</tr>';
	html += '<tr>';
	html += 		'<td colspan="2">';
	html += 			'<label>Nome da instituição: </label>';
	html += 			'<input type="text" class="instituicao" name="escolaridade_instituicao_0" id="escolaridade_instituicao_0" />';
	html += 		'</td>';
	html += '</tr>';
	html += '<tr>';
	html += 		'<td>';
	html += 			'<label>Cidade/Estado:</label>';
	html += 			'<input type="text" name="escolaridade_cidade_estado_0" id="escolaridade_cidade_estado_0" class="estado" />';
	html += 		'</td>';
	html += 		'<td>';
	html += 			'<label>País: </label>';
	html += 			'<input type="text"  name="escolaridade_pais_0" id="escolaridade_pais_0" class="pais" value="Brasil" />';
	html += 		'</td>';
	html += '</tr>';
	html += '</table>';
	$('#div_trabalhe_escolaridade').html(html);

	$('#qtdExperiencias').val("1");
	html = "";
	html += '<table border="0" cellpadding="0" cellspacing="5" class="formulario trabalhe-conosco">';
	html += 		'<tr>';
	html += 			'<td colspan="2">';
	html += 				'<strong>Última experiência</strong>';
	html += 			'</td>';
	html += 		'</tr>';
	html += 		'<tr>';
	html += 			'<td>';
	html += 				'<label>Título do Cargo ocupado:</label>';
	html += 				'<input type="text" name="experiencia_cargo_ocupado_0" id="experiencia_cargo_ocupado_0" class="cargo" />';
	html += 			'</td>';
	html += 			'<td>';
	html += 				'<label>Nível Hierarquico:</label>';
	html += 				'<input type="text" name="experiencia_nivel_hierarquico_0" id="experiencia_nivel_hierarquico_0" class="nivel-hierarquico"/>';
	html += 			'</td>';
	html += 		'</tr>';
	html += 		'<tr>';
	html += 			'<td colspan="2">';
	html += 				'<label>Razão Social: </label>';
	html += 				'<input type="text" name="experiencia_razao_social_0" id="experiencia_razao_social_0" class="razao-social" />';
	html += 			'</td>';
	html += 		'</tr>';
	html += 		'<tr>';
	html += 			'<td width="242">';
	html += 				'<label>Data de Inicio:</label>';
	html += 				'<input type="text" class="data-inicio-mm" maxlength="2" name="experiencia_dtinicio_mes_0" id="experiencia_dtinicio_mes_0" />&nbsp;&nbsp;<input type="text" class="data-inicio-aaaa" maxlength="4" name="experiencia_dtinicio_ano_0" id="experiencia_dtinicio_ano_0" />&nbsp;mm/aaaa';
	html += 			'</td>';
	html += 			'<td width="243">';
	html += 				'<label>Data de saída:</label>';
	html += 				'<input type="text" class="data-saida-mm" maxlength="2" name="experiencia_dtsaida_mes_0" id="experiencia_dtsaida_mes_0" />&nbsp;&nbsp;<input type="text" class="data-saida-aaaa" maxlength="4" name="experiencia_dtsaida_ano_0" id="experiencia_dtsaida_ano_0" />&nbsp;mm/aaaa';
	html += 			'</td>';
	html += 		'</tr>';
	html += 		'<tr>';
	html += 			'<td>';
	html += 				'<label>Área profissional: </label>';
	html += 				'<input type="text" class="area" name="experiencia_area_profissional_0" id="experiencia_area_profissional_0" />';
	html += 			'</td>';
	html += 			'<td>';
	html += 				'<label>Especialização: </label>';
	html += 				'<input type="text" class="especializacao" name="experiencia_especializacao_0" id="experiencia_especializacao_0" />';
	html += 			'</td>';
	html += 		'</tr>';
	html += 		'<tr>';
	html += 			'<td>';
	html += 				'<label>Estado: </label>';
	html += 				'<input type="text" name="experiencia_estado_0" id="experiencia_estado_0" class="estado" />';
	html += 			'</td>';
	html += 			'<td>';
	html += 				'<label>País: </label>';
	html += 				'<input type="text" name="experiencia_pais_0" id="experiencia_pais_0" class="pais" value="Brasil" />';
	html += 			'</td>';
	html += 		'</tr>';
	html += 		'<tr>';
	html += 			'<td colspan="2">';
	html += 				'<label>Descrição do cargo / atividades desenvolvidas: </label>';
	html += 				'<textarea name="experiencia_descricao_cargo_atividades_0" id="experiencia_descricao_cargo_atividades_0"></textarea>';
	html += 			'</td>';
	html += 		'</tr>';
	html += '</table>';
	$('#div_trabalhe_experiencia_profissional').html(html);

	$('#qtdIdiomas').val("1");
	html = "";
	html += '<tr>';
	html += 		'<td width="267">';
	html += 			'<label>Idiomas: </label>';
	html += 			'<input type="text" name="nome_idioma_0" id="nome_idioma_0" class="idiomas" />';
	html += 		'</td>';
	html += 		'<td width="218">';
	html += 			'<label>Nível: </label>';
	html += 			'<select class="nivel" name="nivel_idioma_0" id="nivel_idioma_0">';
	html += 				'<option value="">-- Selecione --</option>';
	html += 				'<option value="Básico">Básico</option>';
	html += 				'<option value="Intermediário">Intermediário</option>';
	html += 				'<option value="Avançado">Avançado</option>';
	html += 			'</select>';
	html += 		'</td>';
	html += '</tr>';
	$('#table_trabalhe_idiomas').html(html);

	$('#experiencia_nao_tem').attr("checked","");
	$('#experiencia_situacao_atual_emp').attr("checked","");
	$('#experiencia_situacao_atual_desemp').attr("checked","");
	$('#experiencia_situacao_atual_desemp').attr("checked","");
	$('#trabalhe_disponibilidade_viajar_sim').attr("checked","checked");
	$('#trabalhe_disponibilidade_viajar_nao').attr("checked","");
	$('#trabalhe_disponibilidade_mudar_sim').attr("checked","checked");
	$('#trabalhe_disponibilidade_mudar_nao').attr("checked","");
	$('#trabalhe_cnh_a').attr("checked","");
	$('#trabalhe_cnh_b').attr("checked","");
	$('#trabalhe_cnh_c').attr("checked","");
	$('#trabalhe_cnh_d').attr("checked","");
	$('#trabalhe_cnh_e').attr("checked","");
	$('#trabalhe_tipo_veiculo_carro').attr("checked","");
	$('#trabalhe_tipo_veiculo_moto').attr("checked","");
	$('#trabalhe_tipo_veiculo_caminhao').attr("checked","");
	$('#trabalhe_tipo_veiculo_outros').attr("checked","");
}

function enviarFormularioTrabalheConosco()
{
	//valida os campos
	var erros = 0;
	var emailInvalido = false;

	if(!$('#nome').val())
	{
		erros++;
	}

	if(!$('#sobrenome').val())
	{
		erros++;
	}

	if(!$('#ddd').val() || !$('#telefone').val())
	{
		erros++;
	}


	if(!$('#dd').val() || !$('#mm').val() || !$('#aaaa').val())
	{
		erros++;
	}

	if(!$('#estado-civil').val())
	{
		erros++;
	}

	if(!$('#cidade').val())
	{
		erros++;
	}

	if(!$('#estado').val())
	{
		erros++;
	}

	if(!$('#pais').val())
	{
		erros++;
	}

	if(!$('#endereco').val())
	{
		erros++;
	}

	if(!$('#numero').val())
	{
		erros++;
	}

	if(!$('#email').val())
	{
		erros++;
	}
	else if(!erros)
	{
		if(!verificaemail($("#email").val()))
		{
			erros++;
			emailInvalido = true;
		}
	}

	if(!erros)
	{
		var dadosFormulario = $('#frm_trabalhe_conosco').serialize();
		modal("loading");
		$.ajax({type: "POST",  url: urlSite+"ajaxTrabalheConosco.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
		success: function(retorno)
		{
			if(retorno=="OK")
			{
				limparTrabalheConosco();
				fecharModal();
				exibirRetorno("SUCESSO","Fale conosco - Trabalhe Conosco","Seu cadastro foi enviado com sucesso!");
			}
			else
			{
				fecharModal();
				exibirRetorno("ERRO","Fale conosco - Trabalhe Conosco",retorno);
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert("ERRO: "+textStatus);
		}
		});
	}
	else
	{
		if(emailInvalido)
		{
			exibirRetorno("ERRO","Fale conosco - Trabalhe Conosco","E-mail inválido!")
		}
		else
		{
			exibirRetorno("ERRO","Fale conosco - Trabalhe Conosco","Preencha todos os campos em asterisco!")
		}
	}
	return false;
}

function enviarFormularioFornecedores()
{
	//valida os campos
	var erros = 0;
	var emailInvalido = false;

	if(!$('#nome').val())
	{
		erros++;
	}

	if(!$('#empresa').val())
	{
		erros++;
	}

	if(!$('#seguimento').val())
	{
		erros++;
	}

	if(!$('#ddd_telefone').val() || !$('#telefone').val())
	{
		erros++;
	}

	if(!$('#email').val())
	{
		erros++;
	}
	else if(!erros)
	{
		if(!verificaemail($("#email").val()))
		{
			erros++;
			emailInvalido = true;
		}
	}

	if(!erros)
	{
		var dadosFormulario = $('#frm_fale_conosco_fornecedores').serialize();
		modal("loading"); //esta modal esta servindo apenas para loading
		return true;
		/*$.ajax({type: "POST",  url: urlSite+"ajaxFaleConoscoFornecedores.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
		success: function(retorno)
		{
			if(retorno=="OK")
			{
				limparFaleConoscoFornecedores();
				fecharModal();
				exibirRetorno("SUCESSO","Fale conosco - Fornecedores","Seu contato foi enviado com sucesso!");
			}
			else
			{
				fecharModal();
				exibirRetorno("ERRO","Fale conosco - Fornecedores",retorno);
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert("ERRO: "+textStatus);
		}
		});*/
	}
	else
	{
		if(emailInvalido)
		{
			exibirRetorno("ERRO","Fale conosco - Fornecedores","E-mail inválido!")
		}
		else
		{
			exibirRetorno("ERRO","Fale conosco - Fornecedores","Preencha todos os campos em asterisco!")
		}
	}
	return false;
}

function limparFaleConoscoFornecedores()
{
	$('#nome').val("");
	$('#sobrenome').val("");
	$('#email').val("");
	$('#ddd_telefone').val("");
	$('#telefone').val("");
	$('#mensagem').val("");
	$('#ddd_celular').val("");
	$('#celular').val("");

	$('#sms').attr("checked","");
	$('#newsletter').attr("checked","");

	$('#contato_telefone').attr("checked","");
	$('#contato_email').attr("checked","");
	$('#contato_indiferente').attr("checked","checked");

	$('#nome_empresa').val("");
	$('#cnpj').val("");
	$('#tipo_servico').val("");
	$('#mensagem').val("");
}

function limparFaleConoscoClientes()
{
	$('#nome').val("");
	$('#empreendimento').val("");
	$('#email').val("");
	$('#ddd_telefone').val("");
	$('#telefone').val("");
	
	$('#mensagem').val("");
	$('#sms').attr("checked","");
	$('#newsletter').attr("checked","");

	$('#residencialtipo').attr("checked","checked");
	$('#comercialtipo').attr("checked","");
	$('#celulartipo').attr("checked","");

	$('#contato_indiferente').attr("checked","checked");
	$('#contato_telefone').attr("checked","");
	$('#contato_email').attr("checked","");
}

function enviarFormularioClientes()
{
	//valida os campos
	var erros = 0;
	var emailInvalido = false;

	if(!$('#empreendimento').val())
	{
		erros++;
	}

	if(!$('#nome').val())
	{
		erros++;
	}

	if(!$('#ddd_telefone').val() || !$('#telefone').val())
	{
		erros++;
	}


	if(!$('#mensagem').val() || $('#mensagem').val()=="")
	{
		erros++;
	}

	if(!$('#email').val())
	{
		erros++;
	}
	else if(!erros)
	{
		if(!verificaemail($("#email").val()))
		{
			erros++;
			emailInvalido = true;
		}
	}

	if(erros)
	{
		var dadosFormulario = $('#frm_fale_conosco_clientes').serialize();
		modal("loading");
		//$('#loading_contato').show();
		$.ajax({type: "POST",  url: urlSite+"ajaxFaleConoscoClientes.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
		success: function(retorno)
		{
			if(retorno=="OK")
			{
				limparFaleConoscoClientes();
				fecharModal();
				exibirRetorno("SUCESSO","Fale conosco - Clientes","Seu contato foi enviado com sucesso!");
			}
			else
			{
				fecharModal();
				exibirRetorno("ERRO","Fale conosco - Clientes",retorno);
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert("ERRO: "+textStatus);
		}
		});
	}
	else
	{
		if(emailInvalido)
		{
			exibirRetorno("ERRO","Fale conosco - Clientes","E-mail inválido!")
		}
		else
		{
			exibirRetorno("ERRO","Fale conosco - Clientes","Preencha todos os campos em asterisco!")
		}
	}
	return false;
}

function limparFaleConoscoTerrenos()
{
	$('#nome').val("");
	$('#email').val("");
	$('#ddd_telefone').val("");
	$('#telefone').val("");
	$('#ddd_celular').val("");
	$('#celular').val("");
	
	$('#indicacaofiscal').val("")
	$('#areatotal').val("");

	$('#estado').val("");
	$('#cidade').val("");
	$('#endereco').val("");
	$('#numero').val("");
	$('#complemento').val("");
	$('#msg').val("");
}

function enviarFormularioTerrenos()
{
	//valida os campos
	var erros = 0;
	var emailInvalido = false;

	if(!$('#nome').val())
	{
		erros++;
	}

	if(!$('#ddd_telefone').val() || !$('#telefone').val())
	{
		erros++;
	}


	if(!$('#indicacaofiscal').val())
	{
		erros++;
	}

	if(!$('#areatotal').val())
	{
		erros++;
	}
	
	if(!$('#estado').val())
	{
		erros++;
	}

	if(!$('#cidade').val())
	{
		erros++;
	}

	if(!$('#endereco').val())
	{
		erros++;
	}

	if(!$('#numero').val())
	{
		erros++;
	}

	if(!$('#msg').val())
	{
		erros++;
	}

	if(!$('#email').val())
	{
		erros++;
	}
	else if(!erros)
	{
		if(!verificaemail($("#email").val()))
		{
			erros++;
			emailInvalido = true;
		}
	}

	if(!erros)
	{
		var dadosFormulario = $('#frm_fale_conosco_terrenos').serialize();
		modal("loading");
		//$('#loading_contato').show();
		$.ajax({type: "POST",  url: urlSite+"ajaxFaleConoscoTerrenos.php", data: dadosFormulario, global: false, dataType: "html", cache: "false",
		success: function(retorno)
		{
			if(retorno=="OK")
			{
				limparFaleConoscoTerrenos();
				fecharModal();
				exibirRetorno("SUCESSO","Fale conosco - Propostas de Terrenos","Seu contato foi enviado com sucesso!");
			}
			else
			{
				fecharModal();
				exibirRetorno("ERRO","Fale conosco - Propostas de Terrenos",retorno);
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown)
		{
			alert("ERRO: "+textStatus);
		}
		});
	}
	else
	{
		if(emailInvalido)
		{
			exibirRetorno("ERRO","Fale conosco - Propostas de Terrenos","E-mail inválido!")
		}
		else
		{
			exibirRetorno("ERRO","Fale conosco - Propostas de Terrenos","Preencha todos os campos em asterisco!")
		}
	}
	return false;

}

function mostrarEsconderFaq(id)
{
	if($('#'+id).attr("name")=="fechado")
	{
		$('#'+id).show();
		$('#'+id).attr("name","aberto");
	}
	else
	{
		$('#'+id).hide();
		$('#'+id).attr("name","fechado");
	}
}

function adicionarEscolaridade()
{
	var retorno = "";
	var qtdFormEscolaridade = parseInt($('#qtdEscolaridade').val());

	for(i=0;i<qtdFormEscolaridade;i++)
	{
		// style="border-bottom: 1px solid #CCCCCC;"
		var medioIncompleto = "";
		var medioCompleto = "";
		var superiorCursando = "";
		var superiorCompleto = "";
		var superiorIncompleto = "";
		var tipoCurso = "";

		if($('#escolaridade_nivel_'+i).val()=="Ensino médio incompleto") { medioIncompleto = 'selected="selected"';}
		if($('#escolaridade_nivel_'+i).val()=="Ensino médio completo") { medioCompleto = 'selected="selected"';}
		if($('#escolaridade_nivel_'+i).val()=="Superior cursando") { superiorCursando = 'selected="selected"';}
		if($('#escolaridade_nivel_'+i).val()=="Superior incompleto") { superiorIncompleto = 'selected="selected"';}
		if($('#escolaridade_nivel_'+i).val()=="Superior completo") { superiorCompleto = 'selected="selected"';}

		if(!i) { retorno += '<table border="0" cellpadding="0" cellspacing="5" class="formulario trabalhe-conosco">'; }else{ retorno += '<table border="0" cellpadding="0" cellspacing="5" class="formulario trabalhe-conosco" style="padding-top: 15px; margin-top: 15px; border-top: 1px solid #cccccc;">'; }
		retorno += '<tr>';
		retorno += 		'<td>';
		retorno += 			'<label>Nivel de Escolaridade:</label>';
		retorno += 			'<select name="escolaridade_nivel_'+i+'" id="escolaridade_nivel_'+i+'">';
		retorno += 				'<option value="">-- Selecione --</option>';
		retorno += 				'<option value="Ensino médio incompleto" '+medioIncompleto+'>Ensino médio incompleto</option>';
		retorno += 				'<option value="Ensino médio completo" '+medioCompleto+'>Ensino médio completo</option>';
		retorno += 				'<option value="Superior cursando" '+superiorCursando+'>Superior cursando</option>';
		retorno += 				'<option value="Superior incompleto" '+superiorIncompleto+'>Superior incompleto</option>';
		retorno += 				'<option value="Superior completo" '+superiorCompleto+'>Superior completo</option>';
		retorno += 			'</select>';
		retorno += 		'</td>';
		retorno += 		'<td>';
		retorno += 			'<label>Curso:</label>';
		retorno += 			'<input type="text" class="curso" name="escolaridade_curso_'+i+'" id="escolaridade_curso_'+i+'" value="'+$('#escolaridade_curso_'+i).val()+'" /></td>';
		retorno += 		'</td>';
		retorno += '</tr>';
		/*retorno += '<tr>';
		retorno += 		'<td colspan="2">';
		retorno += 			'<input name="escolaridade_tipo_curso_'+i+'" class="radio" id="escolaridade_tipo_curso_concluido_'+i+'" type="radio"  value="Concluído" />';
		retorno += 			'<label for="concluido" class="radio">Concluído</label>';
		retorno += 			'&nbsp;&nbsp;<input name="escolaridade_tipo_curso_'+i+'" class="radio" type="radio" value="Cursando" id="escolaridade_tipo_curso_concluido_'+i+'" />';
		retorno +=			'<label class="radio">Cursando</label>';
		retorno += 		'</td>';
		retorno += '</tr>';*/
		retorno += '<tr>';
		retorno += 		'<td width="243">';
		retorno += 			'<label>Data de Inicio: <span class="disclaimer">MM/AAAA</span> </label>';
		retorno += 			'<input type="text" class="data-inicio-mm" maxlength="2" name="escolaridade_dtinicio_mes_'+i+'" id="escolaridade_dtinicio_mes_'+i+'" value="'+$('#escolaridade_dtinicio_mes_'+i).val()+'" />';
		retorno += 			'&nbsp;&nbsp;<input type="text" class="data-inicio-aaaa" maxlength="4" name="escolaridade_dtinicio_ano_'+i+'" id="escolaridade_dtinicio_ano_'+i+'" value="'+$('#escolaridade_dtinicio_ano_'+i).val()+'" /></td>';
		retorno += 		'</td>';
		retorno += 		'<td width="242">';
		retorno += 			'<label>Data de conclusão:<span class="disclaimer">MM/AAAA</span></label>';
		retorno += 			'<input type="text" class="data-conclusao-mm" maxlength="2" name="escolaridade_dtconclusao_mes_'+i+'" id="escolaridade_dtconclusao_mes_'+i+'" value="'+$('#escolaridade_dtconclusao_mes_'+i).val()+'" />';
		retorno += 			'&nbsp;&nbsp;<input type="text" class="data-conclusao-aaaa" maxlength="4" name="escolaridade_dtconclusao_ano_'+i+'" id="escolaridade_dtconclusao_ano_'+i+'" value="'+$('#escolaridade_dtconclusao_ano_'+i).val()+'" />';
		retorno += 		'</td>';
		retorno += '</tr>';
		retorno += '<tr>';
		retorno += 		'<td colspan="2">';
		retorno += 			'<label>Nome da instituição: </label>';
		retorno += 			'<input type="text" class="instituicao" name="escolaridade_instituicao_'+i+'" id="escolaridade_instituicao_'+i+'" value="'+$('#escolaridade_instituicao_'+i).val()+'" />';
		retorno += 		'</td>';
		retorno += '</tr>';
		retorno += '<tr>';
		retorno += 		'<td>';
		retorno += 			'<label>Cidade/Estado:</label>';
		retorno += 			'<input type="text" name="escolaridade_cidade_estado_'+i+'" id="escolaridade_cidade_estado_'+i+'" class="estado" value="'+$('#escolaridade_cidade_estado_'+i).val()+'" />';
		retorno += 		'</td>';
		retorno += 		'<td>';
		retorno += 			'<label>País: </label>';
		retorno += 			'<input type="text"  name="escolaridade_pais_'+i+'" id="escolaridade_pais_'+i+'" class="pais" value="'+$('#escolaridade_pais_'+i).val()+'" />';
		retorno += 		'</td>';
		retorno += '</tr>';
		retorno += '</table>';
	}

	retorno += '<table border="0" cellpadding="0" cellspacing="5" class="formulario trabalhe-conosco" style="margin-top: 15px; padding-top: 15px; border-top: 1px solid #cccccc;">';
	retorno += '<tr>';
	retorno += 		'<td>';
	retorno += 			'<label>Nivel de Escolaridade:</label>';
	retorno += 			'<select name="escolaridade_nivel_'+i+'" id="escolaridade_nivel_'+i+'">';
	retorno += 				'<option value="">-- Selecione --</option>';
	retorno += 				'<option value="Ensino médio incompleto">Ensino médio incompleto</option>';
	retorno += 				'<option value="Ensino médio completo">Ensino médio completo</option>';
	retorno += 				'<option value="Superior cursando">Superior cursando</option>';
	retorno += 				'<option value="Superior incompleto">Superior incompleto</option>';
	retorno += 				'<option value="Superior completo">Superior completo</option>';
	retorno += 			'</select>';
	retorno += 		'</td>';
	retorno += 		'<td>';
	retorno += 			'<label>Curso:</label>';
	retorno += 			'<input type="text" class="curso" name="escolaridade_curso_'+i+'" id="escolaridade_curso_'+i+'" /></td>';
	retorno += 		'</td>';
	retorno += '</tr>';
	/*retorno += '<tr>';
	retorno += 		'<td colspan="2">';
	retorno += 			'<input name="escolaridade_tipo_curso_'+i+'" class="radio" id="escolaridade_tipo_curso_concluido_'+i+'" type="radio"  value="Concluído" />';
	retorno += 			'<label for="concluido" class="radio">Concluído</label>';
	retorno += 			'&nbsp;&nbsp;<input name="escolaridade_tipo_curso_'+i+'" class="radio" type="radio" value="Cursando" id="escolaridade_tipo_curso_concluido_'+i+'" />';
	retorno +=			'<label class="radio">Cursando</label>';
	retorno += 		'</td>';
	retorno += '</tr>';*/
	retorno += '<tr>';
	retorno += 		'<td width="243">';
	retorno += 			'<label>Data de Inicio: <span class="disclaimer">MM/AAAA</span> </label>';
	retorno += 			'<input type="text" class="data-inicio-mm" maxlength="2" name="escolaridade_dtinicio_mes_'+i+'" id="escolaridade_dtinicio_mes_'+i+'" />';
	retorno += 			'&nbsp;&nbsp;<input type="text" class="data-inicio-aaaa" maxlength="4" name="escolaridade_dtinicio_ano_'+i+'" id="escolaridade_dtinicio_ano_'+i+'" /></td>';
	retorno += 		'</td>';
	retorno += 		'<td width="242">';
	retorno += 			'<label>Data de conclusão:<span class="disclaimer">MM/AAAA</span></label>';
	retorno += 			'<input type="text" class="data-conclusao-mm" maxlength="2" name="escolaridade_dtconclusao_mes_'+i+'" id="escolaridade_dtconclusao_mes_'+i+'" />';
	retorno += 			'&nbsp;&nbsp;<input type="text" class="data-conclusao-aaaa" maxlength="4" name="escolaridade_dtconclusao_ano_'+i+'" id="escolaridade_dtconclusao_ano_'+i+'" />';
	retorno += 		'</td>';
	retorno += '</tr>';
	retorno += '<tr>';
	retorno += 		'<td colspan="2">';
	retorno += 			'<label>Nome da instituição: </label>';
	retorno += 			'<input type="text" class="instituicao" name="escolaridade_instituicao_'+i+'" id="escolaridade_instituicao_'+i+'" />';
	retorno += 		'</td>';
	retorno += '</tr>';
	retorno += '<tr>';
	retorno += 		'<td>';
	retorno += 			'<label>Cidade/Estado:</label>';
	retorno += 			'<input type="text" name="escolaridade_cidade_estado_'+i+'" id="escolaridade_cidade_estado_'+i+'" class="estado" />';
	retorno += 		'</td>';
	retorno += 		'<td>';
	retorno += 			'<label>País: </label>';
	retorno += 			'<input type="text"  name="escolaridade_pais_'+i+'" id="escolaridade_pais_'+i+'" class="pais" value="Brasil" />';
	retorno += 		'</td>';
	retorno += '</tr>';
	retorno += '</table>';

	qtdFormEscolaridade++;
	$('#qtdEscolaridade').val(qtdFormEscolaridade);
	$('#div_trabalhe_escolaridade').html(retorno);
	return false;
}


function adicionarExperienciaProfissional()
{
	var retorno = "";
	var qtdFormExperiencia = parseInt($('#qtdExperiencias').val());

	for(i=0;i<qtdFormExperiencia;i++)
	{
		if(!i) { retorno += '<table border="0" cellpadding="0" cellspacing="5" class="formulario trabalhe-conosco">'; }else{ retorno += '<table border="0" cellpadding="0" cellspacing="5" class="formulario trabalhe-conosco" style="margin-top: 15px; padding-top: 15px; border-top: 1px solid #cccccc;">'; }
		retorno += 		'<tr>';
		retorno += 			'<td colspan="2">';
		if(!i) { retorno += 	'<strong>Última experiência</strong>'; }else{ retorno += '<strong>Experiência '+(i+1)+'</strong>'; }
		retorno += 			'</td>';
		retorno += 		'</tr>';
		retorno += 		'<tr>';
		retorno += 			'<td>';
		retorno += 				'<label>Título do Cargo ocupado:</label>';
		retorno += 				'<input type="text" name="experiencia_cargo_ocupado_'+i+'" id="experiencia_cargo_ocupado_'+i+'" class="cargo" />';
		retorno += 			'</td>';
		retorno += 			'<td>';
		retorno += 				'<label>Nível Hierarquico:</label>';
		retorno += 				'<input type="text" name="experiencia_nivel_hierarquico_'+i+'" id="experiencia_nivel_hierarquico_'+i+'" class="nivel-hierarquico"/>';
		retorno += 			'</td>';
		retorno += 		'</tr>';
		retorno += 		'<tr>';
		retorno += 			'<td colspan="2">';
		retorno += 				'<label>Razão Social: </label>';
		retorno += 				'<input type="text" name="experiencia_razao_social_'+i+'" id="experiencia_razao_social_'+i+'" class="razao-social" />';
		retorno += 			'</td>';
		retorno += 		'</tr>';
		retorno += 		'<tr>';
		retorno += 			'<td width="242">';
		retorno += 				'<label>Data de Inicio:</label>';
		retorno += 				'<input type="text" class="data-inicio-mm" maxlength="2" name="experiencia_dtinicio_mes_'+i+'" id="experiencia_dtinicio_mes_'+i+'" />&nbsp;&nbsp;<input type="text" class="data-inicio-aaaa" maxlength="4" name="experiencia_dtinicio_ano_'+i+'" id="experiencia_dtinicio_ano_'+i+'" />&nbsp;mm/aaaa';
		retorno += 			'</td>';
		retorno += 			'<td width="243">';
		retorno += 				'<label>Data de saída:</label>';
		retorno += 				'<input type="text" class="data-saida-mm" maxlength="2" name="experiencia_dtsaida_mes_'+i+'" id="experiencia_dtsaida_mes_'+i+'" />&nbsp;&nbsp;<input type="text" class="data-saida-aaaa" maxlength="4" name="experiencia_dtsaida_ano_'+i+'" id="experiencia_dtsaida_ano_'+i+'" />&nbsp;mm/aaaa';
		retorno += 			'</td>';
		retorno += 		'</tr>';
		retorno += 		'<tr>';
		retorno += 			'<td>';
		retorno += 				'<label>Área profissional: </label>';
		retorno += 				'<input type="text" class="area" name="experiencia_area_profissional_'+i+'" id="experiencia_area_profissional_'+i+'" />';
		retorno += 			'</td>';
		retorno += 			'<td>';
		retorno += 				'<label>Especialização: </label>';
		retorno += 				'<input type="text" class="especializacao" name="experiencia_especializacao_'+i+'" id="experiencia_especializacao_'+i+'" />';
		retorno += 			'</td>';
		retorno += 		'</tr>';
		retorno += 		'<tr>';
		retorno += 			'<td>';
		retorno += 				'<label>Estado: </label>';
		retorno += 				'<input type="text" name="experiencia_estado_'+i+'" id="experiencia_estado_'+i+'" class="estado" />';
		retorno += 			'</td>';
		retorno += 			'<td>';
		retorno += 				'<label>País: </label>';
		retorno += 				'<input type="text" name="experiencia_pais_'+i+'" id="experiencia_pais_'+i+'" class="pais" value="Brasil" />';
		retorno += 			'</td>';
		retorno += 		'</tr>';
		retorno += 		'<tr>';
		retorno += 			'<td colspan="2">';
		retorno += 				'<label>Descrição do cargo / atividades desenvolvidas: </label>';
		retorno += 				'<textarea name="experiencia_descricao_cargo_atividades_'+i+'" id="experiencia_descricao_cargo_atividades_'+i+'"></textarea>';
		retorno += 			'</td>';
		retorno += 		'</tr>';
		retorno += '</table>';
	}

	retorno += '<table border="0" cellpadding="0" cellspacing="5" class="formulario trabalhe-conosco" style="margin-top: 15px; padding-top: 15px; border-top: 1px solid #cccccc;">';
	retorno += 		'<tr>';
	retorno += 			'<td colspan="2">';
	retorno += 				'<strong>Experiência '+(i+1)+'</strong>';
	retorno += 			'</td>';
	retorno += 		'</tr>';
	retorno += 		'<tr>';
	retorno += 			'<td>';
	retorno += 				'<label>Título do Cargo ocupado:</label>';
	retorno += 				'<input type="text" name="experiencia_cargo_ocupado_'+i+'" id="experiencia_cargo_ocupado_'+i+'" class="cargo" />';
	retorno += 			'</td>';
	retorno += 			'<td>';
	retorno += 				'<label>Nível Hierarquico:</label>';
	retorno += 				'<input type="text" name="experiencia_nivel_hierarquico_'+i+'" id="experiencia_nivel_hierarquico_'+i+'" class="nivel-hierarquico"/>';
	retorno += 			'</td>';
	retorno += 		'</tr>';
	retorno += 		'<tr>';
	retorno += 			'<td colspan="2">';
	retorno += 				'<label>Razão Social: </label>';
	retorno += 				'<input type="text" name="experiencia_razao_social_'+i+'" id="experiencia_razao_social_'+i+'" class="razao-social" />';
	retorno += 			'</td>';
	retorno += 		'</tr>';
	retorno += 		'<tr>';
	retorno += 			'<td width="242">';
	retorno += 				'<label>Data de Inicio:</label>';
	retorno += 				'<input type="text" class="data-inicio-mm" maxlength="2" name="experiencia_dtinicio_mes_'+i+'" id="experiencia_dtinicio_mes_'+i+'" />&nbsp;&nbsp;<input type="text" class="data-inicio-aaaa" maxlength="4" name="experiencia_dtinicio_ano_'+i+'" id="experiencia_dtinicio_ano_'+i+'" />&nbsp;mm/aaaa';
	retorno += 			'</td>';
	retorno += 			'<td width="243">';
	retorno += 				'<label>Data de saída:</label>';
	retorno += 				'<input type="text" class="data-saida-mm" maxlength="2" name="experiencia_dtsaida_mes_'+i+'" id="experiencia_dtsaida_mes_'+i+'" />&nbsp;&nbsp;<input type="text" class="data-saida-aaaa" maxlength="4" name="experiencia_dtsaida_ano_'+i+'" id="experiencia_dtsaida_ano_'+i+'" />&nbsp;mm/aaaa';
	retorno += 			'</td>';
	retorno += 		'</tr>';
	retorno += 		'<tr>';
	retorno += 			'<td>';
	retorno += 				'<label>Área profissional: </label>';
	retorno += 				'<input type="text" class="area" name="experiencia_area_profissional_'+i+'" id="experiencia_area_profissional_'+i+'" />';
	retorno += 			'</td>';
	retorno += 			'<td>';
	retorno += 				'<label>Especialização: </label>';
	retorno += 				'<input type="text" class="especializacao" name="experiencia_especializacao_'+i+'" id="experiencia_especializacao_'+i+'" />';
	retorno += 			'</td>';
	retorno += 		'</tr>';
	retorno += 		'<tr>';
	retorno += 			'<td>';
	retorno += 				'<label>Estado: </label>';
	retorno += 				'<input type="text" name="experiencia_estado_'+i+'" id="experiencia_estado_'+i+'" class="estado" />';
	retorno += 			'</td>';
	retorno += 			'<td>';
	retorno += 				'<label>País: </label>';
	retorno += 				'<input type="text" name="experiencia_pais_'+i+'" id="experiencia_pais_'+i+'" class="pais" value="Brasil" />';
	retorno += 			'</td>';
	retorno += 		'</tr>';
	retorno += 		'<tr>';
	retorno += 			'<td colspan="2">';
	retorno += 				'<label>Descrição do cargo / atividades desenvolvidas: </label>';
	retorno += 				'<textarea name="experiencia_descricao_cargo_atividades_'+i+'" id="experiencia_descricao_cargo_atividades_'+i+'"></textarea>';
	retorno += 			'</td>';
	retorno += 		'</tr>';
	retorno += '</table>';

	qtdFormExperiencia++;
	$('#qtdExperiencias').val(qtdFormExperiencia);
	$('#div_trabalhe_experiencia_profissional').html(retorno);
	return false;
}

function adicionarIdioma()
{
	var retorno = "";
	var qtdFormIdiomas = parseInt($('#qtdIdiomas').val());

	for(i=0;i<qtdFormIdiomas;i++)
	{
		var selectedBasico = "";
		var selectedIntermediario = "";
		var selectedAvancado = "";
		if($('#nivel_idioma_'+i).val()=="Básico") { selectedBasico = 'selected="selected"';}
		if($('#nivel_idioma_'+i).val()=="Intermediário") { selectedIntermediario = 'selected="selected"';}
		if($('#nivel_idioma_'+i).val()=="Avançado") { selectedAvancado = 'selected="selected"';}

		retorno += '<tr>';
		retorno += 		'<td width="267">';
		retorno += 			'<label>Idiomas: </label>';
		retorno += 			'<input type="text" name="nome_idioma_'+i+'" id="nome_idioma_'+i+'" class="idiomas" value="'+$("#nome_idioma_"+i).val()+'" />';
		retorno += 		'</td>';
		retorno += 		'<td width="218">';
		retorno += 			'<label>Nível: </label>';
		retorno += 			'<select class="nivel" name="nivel_idioma_'+i+'" id="nivel_idioma_'+i+'">';
		retorno += 				'<option value="">-- Selecione --</option>';
		retorno += 				'<option value="Básico" '+selectedBasico+'>Básico</option>';
		retorno += 				'<option value="Intermediário" '+selectedIntermediario+'>Intermediário</option>';
		retorno += 				'<option value="Avançado" '+selectedAvancado+'>Avançado</option>';
		retorno += 			'</select>';
		retorno += 		'</td>';
		retorno += '</tr>';
	}

	retorno += '<tr>';
	retorno += 		'<td width="267">';
	retorno += 			'<label>Idiomas: </label>';
	retorno += 			'<input type="text" name="nome_idioma_'+i+'" id="nome_idioma_'+i+'" class="idiomas" />';
	retorno += 		'</td>';
	retorno += 		'<td width="218">';
	retorno += 			'<label>Nível: </label>';
	retorno += 			'<select class="nivel" name="nivel_idioma_'+i+'" id="nivel_idioma_'+i+'">';
	retorno += 				'<option value="">-- Selecione --</option>';
	retorno += 				'<option value="Básico">Básico</option>';
	retorno += 				'<option value="Intermediário">Intermediário</option>';
	retorno += 				'<option value="Avançado">Avançado</option>';
	retorno += 			'</select>';
	retorno += 		'</td>';
	retorno += '</tr>';

	qtdFormIdiomas++;
	$('#qtdIdiomas').val(qtdFormIdiomas);
	$('#table_trabalhe_idiomas').html(retorno);
	return false;
}
