﻿var fecharInfoViaEmail = true;

//DHTML
function DHTML(idEmpreendimento) {
    try {
        abrirEnvieMensagem();        
        setTimeout(function() {
            if (fecharInfoViaEmail) {
                    fecharLightBox();
                }
            }, 8000);

            $(".boxConteiner input").focus(function() {
            fecharInfoViaEmail = false;
        });
    }
    catch (e) {
    }
}

$(document).ready(function() {
	var homeId = null;	
	
	//seta resolução minima
	
	var resolucaoAtual = screen.width;

	$("a[rel=fecharBoxAvisohome]").click(function() {
	    $(".avisoHome").slideToggle('slow');
	});
	
	if(resolucaoAtual < '1024')
	{
	    $('.divConteinerCorretorOnline').css('left','980px');
	}
						   	
    if (homeId != undefined)
        var homeXml = 'util/xml/home/' + homeId + '.xml';

    $(".gallery a[rel^='prettyPhoto']").prettyPhoto({ theme: 'dark_rounded' });
    /* APLICA TV FLASH */
    //   var divFlash = $("#divFlash");
    //    if (divFlash) {
    //        $(divFlash).flash({
    //            src: '/Util/swf/tvFlashLiving.swf',
    //            width: 1002,
    //            height: 292
    //        });
    //    }

//    /* APLICA DESTAQUE IMOVEIS */
//    var galeriaDestaque = $("#galeriaDestaque");
//    if (galeriaDestaque) {
//        $(galeriaDestaque).flash(
//        {
//            src: '/Util/swf/esteiraDestaques.swf',
//            width: 742,
//            height: 317,
//            wmode: 'transparent',
//            flashvars: { xmlPath: homeXml }
//        },{AllowScriptAccess:'sameDomain'}
//        );
//    }

    /* APLICA DESTAQUE CONFIRA */
    var confiraTambem = $("#boxFlashConfira");
    if (confiraTambem) {
        $(confiraTambem).flash({
            src: '/Util/swf/flashConfiraTambem.swf',
            width: 983,
            height: 110,
            wmode: 'transparent'
        });
    }

    /* APLICA CENTRAL DE VENDAS */
    $("#boxCentralTelefone").flash({
        src: '/Util/swf/flashTelefoneCentral.swf',
        width: 242,
        height: 152,
        wmode: 'transparent'
    });

    /* APLICA JCAROUSEL NA FICHA */
    $('#listaImagemGaleria').jcarousel();
    $('#listaImagemGaleriaProjeto').jcarousel();
    $('#listaImagemGaleriaLazer').jcarousel();
    $('#listaImagemGaleriaEmpreendimento').jcarousel();
    $('#listaImagemGaleriaPlantas').jcarousel();
    $('#listaImagemGaleriaApartamento').jcarousel();
    $('#listaImagemGaleriaAcompanhe').jcarousel();
    $('#listaParceiros').jcarousel();
    $('#UL2').jcarousel();
    $('#UL3').jcarousel();
    $('#UL4').jcarousel();
    $('#UL5').jcarousel();
    $('#UL12').jcarousel();
    $('#UL13').jcarousel();
    $('#UL14').jcarousel();
    $('#UL15').jcarousel();
    $('#UL16').jcarousel();
    $('#UL17').jcarousel();

    /* Limpa o Input ao clicar */
    $('.nomeMask, .emailMask').focus(function() {
        if ($(this).val() == $(this).attr("title")) {
            $(this).val("");
            if ($(this).hasClass("password")) {
                $(this).attr("type", "password");
            }
            $(this).bind("blur", function() {
                if ($(this).val() == '') {
                    if ($(this).hasClass("password")) {
                        $(this).attr("type", "text");
                    }
                    $(this).val($(this).attr("title"));
                }
            });
        }
    });
    
//    $("#aspnetForm").submit( function() {
//		 if ($("#ctl00_ctl00_txtEmail").val() != '') {
//			  var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
//			  if (regmail.test($("#ctl00_ctl00_txtEmail").val())) {
//				   alert("E-mail válido");
//			  } else {
//				   alert("E-mail inválido");
//				   return false;
//			  }
//		 }
//	});

    /* DESTAQUE IMOVEL ATUAL NO BOX CONFIRA TAMBEM */
    $(".boxImovel").hover(function() {
        $(this).css({ "background-image": "url('/Util/img/bgImovelConfiraTambem.jpg')" })
    }, function() {
        $(this).css({ "background-image": "" });
    });

//    /* IMOVEIS DOS ULTIMOS IMOVEIS VISUALIZADOS */
//    $('.boxImoveisVisualizados .imoveis .btnFechar').click(function(e) {
//        $(this).parents('.imoveis').fadeOut('slow');
//        e.preventDefault();
//    });

//    /* EXCLUI TODOS OS IMOVEIS VISUALIZADOS */
//    $('.boxImoveisVisualizados .btnExcluirItens').click(function(e) {
//        $('.imoveis').each(function() {
//            $(this).fadeOut('slow');
//            e.preventDefault();
//        });
//    });

//    $('.boxEmpreendimentos .mioloEmpreendimentos .imagensNavegacao .imagem').each(function() {
//        $(this).hide();
//    });
   

    

    //    $('.boxList ul li').click(function(){
    //        $('.boxList ul li').each(function(){
    //            $(this).removeClass('balaoOff');
    //        });
    //        $(this).addClass('balaoOff');
    //    });

    $('ul.listBoxFicha li').click(function(e) {
        $('ul.listBoxFicha li').each(function() {
            $(this).removeClass('listBoxFichaAtivo');
        });
        $(this).addClass('listBoxFichaAtivo');
        e.preventDefault();
    });

    if ($('.containerGeral .containerConteudo .conteudo .imgLeft').length == 1) {
        $('.boxBread .breadCrumb').css('width', '442px');
    } else {
        $('.boxBread .breadCrumb').css('width', '585px');
    }

    /* 
	
	$('.boxGenericoFicha').css({'top':'0px'});
    
    var teste = ""; 
    $('.tourCondicao ul li').each(function(){
    teste = teste + 1;
    });
    if(teste == 1){
    larguraImg = $('.tourCondicao ul li a img').width();
    $('.tourCondicao ul').css({
    'width':larguraImg + 'px',
    'float':'none',
    'margin':'0 auto 0 auto',
    'display':'block'
    });
    }*/

    $('.boxGenericoFicha').css({ 'top': '0px' });
	 
	 /*Versão para Impressão */
	 $('.versaoImpressao').click(function(){  
	   //$('.containerGeral').css('height',$('.containerGeral').height());
	   //window.print();
	   //alert($('.conteudoFicha').html());
       //Titulo = $('.divMainWrapper .divMainContent #pagInterna.divContentPages h1').html();
       Conteudo = $('.conteudoFicha').html();
       document.write(Conteudo);
       regulamento = window.open('/Util/usc/Print.html','','width=600,height=300,menubar=no,channelmode=no,directories=no,fullscreen=no,location=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no');        
       
       if (regulamento != undefined)
        {
            //regulamento.document.write('<h1>'+ Titulo+ '</h1>' + Conteudo );
           regulamento.document.write(Conteudo);
           setTimeout(function()
           {
                regulamento.window.print();
            }, 100);
        }
    });
	 
	 /* Versão para Impressão */
	 
	 /* Tabela alternação de bg cores linha */	 
	     $(".boxPlantoes table tbody tr:even").addClass("escuro");
         $(".boxPlantoes table tbody tr:odd").addClass("claro"); 
     /* / Tabela alternação de bg cores linha */
     
     $('.telefone input, .celular input').mask('(99)9999-9999');
     $('.boxFormCadastro2 .boxConteiner .inpMaiorEnvieMen').mask('(99)9999-9999');

	 
});






/* EXIBE ESTAGIO */
var largura = 0;
function ExibeEstagio(divEstagio, elementoClick) 
{
    $('.escondeDiv').each(function(){
         $(this).hide(); 
    });
    $("#" + divEstagio).show(); 
    
    $("#" + divEstagio + " .galeriaImagensCarrousel .jcarousel-container .jcarousel-clip ul li").each(function(){
        largura = largura + $(this).width() + 15;
        $("#" + divEstagio + " .galeriaImagensCarrousel .jcarousel-container .jcarousel-clip ul").css({"width":largura + "px"});
    });
    largura = 0;
    
    if (elementoClick != undefined) 
    {
        $('.balaoOff').removeClass("balaoOff");
        $("#" + elementoClick).parent().addClass("balaoOff");
    }
}

/* ALTERA O ICONE DO ESTAGIO */
function AlteraIcone(ClassImagem) {   
    $('.' + ClassImagem).each(function() {
        $(this).attr("src", "/Util/img/icoPrazo_on.gif")
    });
}

//Abre pop do Chat
function abreChat(url, width, height) {
    openChat(url, width, height);
}

function openChat(url, width, height) {
    window.open(url, "PopChat", "width=" + width + ",height=" + height);
}

//Abre pop do Tour
function abreTour(url, width, height) {
    window.open(url, "PopTour", "width=" + width + ",height=" + height);
}

//pop do Como chegar
function boxComoChegarAbrir() {
    $('#boxComoChegar').show();
}

function boxComoChegarFechar() {
    $('#boxComoChegar').hide();
}

//lightbox indique
function indiqueBoxOpen() {
    $('#lightBoxIndique').show();
}
function indiqueBoxClose() {
    $('#lightBoxIndique').hide(); 
}

//lightbox envie mensagem
function envieBoxClose() {
    $('#lightBoxEnvie').hide(); 
}


function abrirLocalizacao() {
    document.getElementById("boxOverlay").style.display = "block";
    document.getElementById("divLightBox").style.display = "block";
}

function fecharLocalizacao() {
    document.getElementById("boxOverlay").style.display = "none";
    document.getElementById("divLightBox").style.display = "none";
    document.getElementById('chkTermoAceite').checked = "true"; 
}

function abrirIndiqueAmigo() {
    
    var bodyHeight = $(".conteudoFicha").height();
    $('#lightBoxIndique').show();
    $('#boxOverlay').show().height(bodyHeight);
    $('#divLightBox').show();
    $('#lightBoxEnvie').hide();
    $('#aFecharMensagem').hide();
    $('#h2EnvieMensagem').hide();
    $('#spFecharIndiqueAmigo').show();
    $('#h2TitEnvieAmigo').show();    
}

function overlayheight()
{
    var bodyHeight = $(".containerGeral").height();
    
    if(bodyHeight != null || bodyHeight > 0)
    {
        $('#boxOverlay').height(bodyHeight);
    }
    

    
}

function abrirEnvieMensagem() {
    var bodyHeight = $(".conteudoFicha").height();
    $('#lightBoxEnvie').show();
    $('#boxOverlay').show().height(bodyHeight);
    $('#divLightBox').show();
    $('#aFecharMensagem').show();
    $('#h2EnvieMensagem').show();
    $('#lightBoxIndique').hide();
    $('#spFecharIndiqueAmigo').hide();
    $('#h2TitEnvieAmigo').hide();
}

function fecharLightBox() {
    $('#lightBoxEnvie').hide();
    $('#boxOverlay').hide();
    $('#divLightBox').hide(); 
    $('#lightBoxIndique').hide();
}


function ExibeSimulador() {
    var elemento = document.getElementById("ifSimuladorCaixa");
    if (elemento != null) 
    {
        elemento.style.display = "block";
    }
}

function carregaDestaqueFicha(objId){
    /* ALTERA ABA DO BOX EMPREENDIMENTO */
   
    var atualDestaque = "#" + objId;
    var positionAtual = 0;
    $('ul.listBoxFicha li a').click(function(e) {
        atualDestaque = $(this).attr("href");
        $('.imagem').each(function() {
            $(this).hide();
        });
        $(atualDestaque).show();
        positionAtual = 0;
        e.preventDefault();
    });
    
    $('ul.listBoxFicha li:eq(0)').addClass('listBoxFichaAtivo');
    
    $('.btnNavegar').click(function(e){
        contDestaque = 0;
        nav = $(this).attr("title");
        $(atualDestaque + " .contDestaque").each(function(){
            contDestaque = contDestaque + 1;
        });
        contDestaque = contDestaque - 1;
        if(nav == "prox")
        {    
            if(positionAtual < contDestaque)
            {
                positionAtual = positionAtual + 1;
            }
            else
            {
                positionAtual = 0;
            }
            $(atualDestaque + " .contDestaque").each(function(){
                $(this).hide();
            });
            $(atualDestaque + " .contDestaque:eq(" + positionAtual + ")").show();
        }
        else
        {
            if(positionAtual == 0)
            {
                positionAtual = contDestaque;
            }
            else
            {
                positionAtual = positionAtual - 1;
            }
            
            $(atualDestaque + " .contDestaque").each(function(){
                $(this).hide();
            });
            
            
            $(atualDestaque + " .contDestaque:eq(" + positionAtual + ")").show();
        }        
        
        e.preventDefault();
    });
}

function RedirParent(url) {

    window.opener.location.href= url;

    window.close();

}


