jQuery.noConflict();
(function ($) {
    $(function () {
        $(document).ready(function () {
            //detecção de página ativa e aplicação de jQuery em cada uma
            var pagina = window.location.pathname;
            pagina = pagina.substring(pagina.lastIndexOf("/") + 1, pagina.length).replace(".aspx", "").toLocaleLowerCase();
            switch (pagina) {
                case "":
                    numMenu = 1;
                    break;

                default:
                    numMenu = 0;
                    break;
            }

            //menu
            $('.mainNav li').mouseover(function () {
                $(this).children('span').animate({ top: "0px" }, 100);
            });
            $('.mainNav li').mouseleave(function () {
                if ($(this).hasClass("selecionado")) {
                    $(this).children('span').css("top", "0px");
                }
                else {
                    $(this).children('span').animate({ top: "46px" }, 100);
                }
            });


            //        BOTÃO
            var botao = $('input.botao');
            $(botao).each(function () {
                if (!$(this).parent().hasClass('planoBT')) {
                    $(this).before('<div class="planoBT"></div>');
                    $('div.planoBT').html(this);
                    $('div.planoBT').append('<span class="btR">&nbsp;</span>');
                }
            });

            var botaoA = $('a.botao');
            $(botaoA).append('<span class="btsR">&nbsp;</span>');

            $('span.telefone input:first').addClass('campoDDD');

            //icones redes sociais
            $('.lkRede').mouseover(function () {
                $(this).children('img').animate({ width: "28px", height: "28px", top: "0px", left: "0px;" }, 200);
            });
            $('.lkRede').mouseleave(function () {
                $(this).children('img').animate({ width: "24px", height: "24px", top: "2px", left: "2px" }, 100);
            });

            //colunas detalhe imovel
            var colLeftH = $('.baseDetalhe div.colLeft').height();
            var colRightH = $('.baseDetalhe div.colRight').height();
            if (colRightH > colLeftH) {
                $('div.colLeft').css("height", colRightH);
            };
            if (colRightH < colLeftH) {
                $('div.colRight').css("height", colLeftH);
            };

            $("#SliderValor").slider({ 
                from: 000, 
                to: 101000, 
                step: 1000, 
                smooth: true, 
                round: 0, 
                dimension: "R$&nbsp;", 
                skin: "plastic" 
            });

            //personaliza combobox
            $(".baseRadio label").addClass("styleRadio");
            $(".styleCombobox select").styleCombobox({
                classFocus: "comboboxFocus"
            });
            $(".detalheEquipe  input:checkbox, .filtros input:checkbox, .campoComparar input:checkbox, .formContato input:checkbox, .formImovel input:checkbox").styleRadioCheckbox({
                classChecked: "inputCheckboxChecked",
                classFocus: "inputFocus"
            });
            $(".filtroTipo input:radio").styleRadioCheckbox({
                classChecked: "inputRadioChecked",
                classFocus: "inputFocus"
            });

            //fecha alertas
            $('.boxAlerta').click(function () {
                $(this).css('display', 'none');
            });

            //insere separador e alinha listas
            var separador = $('<li></li>').addClass('separador');
            $('.listaParceiros li:nth-child(3n)').css("margin-right", "0px").after(separador);
            $('.listaFavoritos li:odd').after(separador);

            //tabela comparacao
            $('.grid tr:odd').addClass('semBG');

            //lista downloads
            $('.nivel_1').click(function () {
                if ($(this).next('ul').is(':visible')) {
                    $(this).next('ul').slideUp();
                } else {
                    $(this).next('ul').slideDown();
                }
            });

        });
        //$(".nav a#menu"+numMenu).addClass("selecionado");

        //galeria
        $(function () {
            //$('img.image1').data('ad-desc', 'Whoa! This description is set through elm.data("ad-desc") instead of using the longdesc attribute.<br>And it contains <strong>H</strong>ow <strong>T</strong>o <strong>M</strong>eet <strong>L</strong>adies... <em>What?</em> That aint what HTML stands for? Man...');
            //$('img.image1').data('ad-title', 'Title through $.data');
            //$('img.image4').data('ad-desc', 'This image is wider than the wrapper, so it has been scaled down');
            //$('img.image5').data('ad-desc', 'This image is higher than the wrapper, so it has been scaled down');
            var galleries = $('.ad-gallery').adGallery();
            $('#switch-effect').change(
                function () {
                    galleries[0].settings.effect = $(this).val();
                    return false;
                }
            );
            $('#toggle-slideshow').click(
                function () {
                    galleries[0].slideshow.toggle();
                    return false;
                }
            );

            //galleries[0].settings.description_wrapper = $('#descriptions');

            //fecha modal com "esc"
            jQuery(document).keyup(function(e) {
                if (e.keyCode == 27) {
                    jQuery('.baseModal').fadeOut(100);
                    jQuery('.bgModal').fadeOut(100);
                }
            });

        });
    });
})(jQuery);

function ampliaIMG() {
    var altura = jQuery(window).height() + 10;
    jQuery('<div class="bgModal"></div>').insertBefore('.header').css("height", altura).fadeIn(200);
    jQuery('.modalAmpliacao').insertBefore('.header').fadeIn(300).css("top", "50px");
}
function fechaAmpliacao() {
    jQuery('.modalAmpliacao').fadeOut(200);
    jQuery('.bgModal').fadeOut(200);
}

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(
    function () {
        jQuery(".styleCombobox select").styleCombobox({
            classFocus: "comboboxFocus"
        });

        jQuery(".filtroTipo input:radio").styleRadioCheckbox({
            classChecked: "inputRadioChecked",
            classFocus: "inputFocus"
        });

    });
    

