﻿$(document).ready(function () {
    if (navigator.appName == "Microsoft Internet Explorer") {
        $('.conteudo_tabs').css('filter', 'Alpha(Opacity=0)');
        $('#prelancamentos').css('filter', 'Alpha(Opacity=100)');
        $('#prelancamentos').css('z-index', '3');
    }

    if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
        $('.conteudo_tabs').css('margin-top', '50px');
        $('textarea').css('resize', 'none');
    }

    $('.tabs li a').click(function () {

        $('.tabs li a').removeClass('ativo');

        var tab = $(this).attr('class').replace('link_', '#');

        if (navigator.appName == "Microsoft Internet Explorer") {
            $('.conteudo_tabs').css({
                'z-index': '1',
                'filter': 'Alpha(Opacity=0)'
            });
        } else {
            $('.conteudo_tabs').css({
                'opacity': '0',
                'z-index': '1'
            });
        }

        $(this).addClass('ativo');

        $('.conteudo_tabs').children('a.botao').hide();

        $(tab).children('a.botao').css('display', 'block');

        if (navigator.appName == "Microsoft Internet Explorer") {
            $(tab).css({
                'z-index': '3',
                'filter': 'Alpha(Opacity=100)'
            });
        } else {
            $(tab).css({
                'z-index': '3',
                'opacity': '1'
            });
        }


    });

    $('.lista_imagens li a').click(function () {

        $('.lista_imagens li a').removeClass('ativo');

        var tab = $(this).attr('class').replace('item_', '#');

        $('.conteudo_tabs_detalhe').css({
            'opacity': '0',
            'z-index': '1'
        });

        $(tab).children('a.botao').css('display', 'block');

        $(this).addClass('ativo');

        $(tab).css({
            'opacity': '1',
            'z-index': '3'
        });
    });

    /*CAROUSELS*/

    //detalhe
    if ($('div.scrolldet ul li').size() > 0) {
        $('div.scrolldet').jCarouselLite({
            btnNext: ".bt_pro_lan",
            btnPrev: ".bt_ant_lan",
            circular: false
        });
    }

    //pre lancamento home
    if ($('div.scrollpre ul li').size() > 0) {
        $('div.scrollpre').jCarouselLite({
            btnNext: ".bt_pro_pre",
            btnPrev: ".bt_ant_pre",
            circular: false
        });
    }

    //pre lancamento imoveis
    if ($('div.scrollpre ul li').size() > 0) {
        $('div.scrollpre').jCarouselLite({
            btnNext: ".bt_pro_pre_di",
            btnPrev: ".bt_ant_pre_di",
            circular: false
        });
    }

    //lancamento home
    if ($('div.scrolllan ul li').size() > 0) {
        $('div.scrolllan').jCarouselLite({
            btnNext: ".bt_pro_lan",
            btnPrev: ".bt_ant_lan",
            circular: false
        });
    }

    //lancamento imoveis
    if ($('div.scrolllan ul li').size() > 0) {
        $('div.scrolllan').jCarouselLite({
            btnNext: ".bt_pro_lan_di",
            btnPrev: ".bt_ant_lan_di",
            circular: false
        });
    }


    //obras home
    if ($('div.scrollobr ul li').size() > 0) {
        $('div.scrollobr').jCarouselLite({
            btnNext: ".bt_pro_obr",
            btnPrev: ".bt_ant_obr",
            circular: false
        });
    }

    //obras imoveis
    if ($('div.scrollobr ul li').size() > 0) {
        $('div.scrollobr').jCarouselLite({
            btnNext: ".bt_pro_obr_di",
            btnPrev: ".bt_ant_obr_di",
            circular: false
        });
    }

    //prontos home
    if ($('div.scrollmor ul li').size() > 0) {
        $('div.scrollmor').jCarouselLite({
            btnNext: ".bt_pro_mor",
            btnPrev: ".bt_ant_mor",
            circular: false
        });
    }
    //prontos imoveis
    if ($('div.scrollmor ul li').size() > 0) {
        $('div.scrollmor').jCarouselLite({
            btnNext: ".bt_pro_mor_di",
            btnPrev: ".bt_ant_mor_di",
            circular: false
        });
    }

    /*detalhe imovel*/

    //fotos empreendimento
    if ($('div.scrolldetemp ul li').size() > 0) {
        $('div.scrolldetemp').jCarouselLite({
            btnNext: ".bt_pro_emp_di",
            btnPrev: ".bt_ant_emp_di",
            circular: false
        });
    }

    if ($('div.scrolldetpln ul li').size() > 0) {
        $('div.scrolldetpln').jCarouselLite({
            btnNext: ".bt_pro_pln_di",
            btnPrev: ".bt_ant_pln_di",
            circular: false
        });
    }

    if ($('div.scrolldetamb ul li').size() > 0) {
        $('div.scrolldetamb').jCarouselLite({
            btnNext: ".bt_pro_amb_di",
            btnPrev: ".bt_ant_amb_di",
            circular: false
        });
    }

    if ($('div.scrolldetfot ul li').size() > 0) {
        $('div.scrolldetfot').jCarouselLite({
            btnNext: ".bt_pro_fot_di",
            btnPrev: ".bt_ant_fot_di",
            circular: false
        });
    }

    if ($('div.scrolldetloc ul li').size() > 0) {
        $('div.scrolldetloc').jCarouselLite({
            btnNext: ".bt_pro_loc_di",
            btnPrev: ".bt_ant_loc_di",
            circular: false
        });
    }


    //cliente
    if ($('div.scrolldetemp ul li').size() > 0) {
        $('div.scrolldetemp').jCarouselLite({
            btnNext: ".bt_pro_emp",
            btnPrev: ".bt_ant_emp",
            circular: false
        });
    }

    /*PERGUNTAS FREQUENTES*/
    $('.lista_perguntas li a').click(function () {
        var texto = $(this).parent('li').children('p');

        texto.slideToggle();
        $(this).toggleClass('ativo');
    });

    /*SUB MENU*/
    $('.sublink, .submenu').mouseover(function () {
        $('.submenu').show();
        $('.sublink').addClass('ativo');
    }).mouseout(function () {
        $('.submenu').hide();
        $('.sublink').removeClass('ativo');
    });

    /*FANCY*/
    $('.fancy').fancybox({
        'titlePosition': 'inside'
    });
    $('.fancybox').fancybox({
        'titlePosition': 'inside'
    });
    $('.fancy_map').fancybox({
        'autoScale': false,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'iframe',
        'width': '53%',
        'height': '73%'
    });


    //    $('.fancy_map').fancybox({
    //        'zoomOpacity': true,
    //        'zoomSpeedIn': 500,
    //        'zoomSpeedOut': 500,
    //        'overlayOpacity': 0.75,
    //        'frameWidth': 530,
    //        'frameHeight': 400,
    //        'callbackOnClose': function () {
    //            $("#fancy_content").empty();
    //        } 
    //    });

    $('.videos li a').click(function () {

        var video = $(this).attr('href');

        $('.video_big').empty();

        $('.video_big').append('<object width="593" height="358"><param name="movie" value="' + video + '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + video + '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="593" height="358"></embed></object>');

        return false;

    });

    /*BUSCA*/
    $('.item_busca').hide();
    $('h2.trigger').click(function () {
        var texto = $(this).parent('div.result_busca').children('.item_busca');

        texto.slideToggle();
        $(this).toggleClass('ativo');
    });

});


function Abrir(strMensagem) {
    $(document).ready(function () {
        jQuery.facebox(strMensagem);
    })
}
/* Fecha popup */
function hidePop ( popup ) {
    $('.' + popup).hide();
}

