//DOCUMENTO JAVASCRIPT//
//RIMOL IMÓVEIS//
function inicial()      {
    document.location.href = "index.php";
}
function a_rimol()      {
    document.location.href = "a_rimol.php";
}
function servicos()     {
    document.location.href = "servicos.php";
}
function anuncie()      {
    document.location.href = "cadastro_imoveis.php";
}
function financiamento(){
    document.location.href = "financiamento.php";
}
function lancamentos()  {
    document.location.href = "lancamentos.php";
}
function empreendimentos()  {
    document.location.href = "empreendimentos.php";
}

function fale_conosco() {
    document.location.href = "fale_conosco.php";
}

function loading(id) {
    $('#'+id).html("<span style='padding-top:150px;'><center><img src='imagens/lightbox-ico-loading.gif' /></center></span>");
}

function enviar_anuncio() {
    if ($('#nome').val()=='' || ($('#email').val()=='' && $('#telefone').val()=='(__)____-____') || $('#cidade').val()=='' || $('#uf').val()=='' || $('#mensagem').val()=='') {
        $('#resposta').html('<center>CAMPOS OBRIGATÓRIOS EM BRANCO.</center>').css("color","red");
    } else {
        loading('resposta');
        $('#frm_anuncio').submit();
    }
}

function enviar_contato() {
    if ($('#nome').val()=='' || $('#rua').val()=='' || $('#cidade').val()=='' || $('#uf').val()==''
        || ($('#email').val()=='' && $('#telefone').val()=='(__)____-____') || $('#mensagem').val()=='') {
        $('#resposta').html('<center>CAMPOS OBRIGATÓRIOS EM BRANCO.</center>').css("color","red");
    } else {
        loading('resposta');
        $('#frm_contato').submit();
    }
}

function enviar_corretor() {
    if ($('#nome').val()=='' || $('#cpf').val()=='___.___.___-__' || $('#creci').val()=='' || $('#rua').val()=='' || $('#bairro').val()==''
        || $('#cidade').val()=='' || $('#uf').val()=='' || ($('#email').val()=='' && $('#telefone').val()=='(__)____-____') || $('#mensagem').val()=='') {
        $('#resposta').html('<center>CAMPOS OBRIGATÓRIOS EM BRANCO.</center>').css("color","red");
    } else {
        loading('resposta');
        $('#frm_corretor').submit();
    }
}

$(document).ready(function () {
    $('[rel$=fone]').mask('(99)9999-9999').Watermark('(__)____-____');
    $('[rel$=cpf]').mask('999.999.999-99').Watermark('___.___.___-__');
    $('[rel$=cep]').mask('99999-999').Watermark('_____-___');
    $('[rel$=data]').mask('99/99/9999').Watermark('__/__/____');

    $('#tipo>.img').cycle({
        fx:     'scrollHorz',
        speed:  'slow',
        timeout: 3000,
        next:   '#tipo>.avanca',
        prev:   '#tipo>.antecede'
    });
});
//////////////////////////////////enquete///////////////////////////////////////////////////
function enquete_resultados() {
    $.ajax({
        type: "GET",
        url: "zcms/enquete/enquete.php?enquete=show_only",
        cache: false,
        success: function(msg){
            $('#enq-box').html(msg).css({
                'min-height':'170px'
            }).fadeIn('fast');
        }
    });
}

function enquete_voltar() {
    $.ajax({
        type: "GET",
        url: "zcms/enquete/enquete.php?enquete=show",
        cache: false,
        success: function(msg){
            $('#enq-box').fadeOut('fast',function(){
                $('#enq-box').html(msg).css({
                    'margin-top':'2px'
                }).slideDown('slow');
            });
        }
    });
}

function enquete_votar() {
    var Pega_Voto = '0';
    $('[id^=resposta_enquete_]').each(function() {
        if(this.checked == true) Pega_Voto = $(this).val();
    });
    if (Pega_Voto != '0') {
        $.ajax({
            type: "POST",
            url: "zcms/enquete/enquete.php?enquete=show_vote",
            data: ({
                resposta_enquete : Pega_Voto
            }),
            cache: false,
            success: function(msg){
                $('#enq-box').fadeOut('slow',function(){
                    $('#enq-box').html(msg).slideDown('slow').css('margin-top','-8px');
                });
            }
        });
    } else {
        var intervalo = window.setTimeout(function() {
            $('#msg').dialog('destroy')
        },2500);
        $('#msg').html('<span class="ui-icon ui-icon-alert" style="float:left; margin:-2px 7px 20px 0;"></span>&Eacute; Necess&aacute;rio Escolher uma Op&ccedil;&atilde;o para Votar!').css({
            'background-color':'#ffffff',
            'color':'#006600'
        }).dialog({
            closeOnEscape:false,
            width:320,
            minHeight:70,
            modal:true,
            title:'Mensagem!',
            buttons:{
                'OK':function(){
                    $(this).dialog('destroy');
                    window.clearInterval(intervalo);
                }
            }
        });
    }
}
//////////////////////////////////enquete///////////////////////////////////////////////////

////BACKGROUND SELECT FORMULÁRIO ////
$(document).ready(function(){

    if (!$.browser.opera) {

        // select element styling
        $('select.select').each(function(){
            var title = $(this).attr('title');
            $(this)
            .css({
                'z-index':10,
                'opacity':0,
                '-khtml-appearance':'none'
            })
            .after('<span class="select">' + title + '</span>')
            .change(function(){
                val = $('option:selected',this).text();
                $(this).next().text(val);
            })
        });

    };

});
///////////////////////
//Ajax Detalhes Imovel
function abrirDetalhes(link) {
    $("#__imoveis").fadeOut();
    $(".loader").show();
    $.ajax({
        type : "GET",
        url : "detalhes_imovel.php?rand="+Math.random()*999999,
        data : ({
            "link" : link
        }),
        success : function(msg) {
            $(".loader").hide();
            $("#boxDetalhes").html(msg);
            $("#boxDetalhes").fadeIn();
        /*$("#boxDetalhes").dialog({
                    autoOpen : true,
                    title : "DETALHAMENTO DE IMÓVEIS",
                    buttons : ({
                        "FECHAR" : function(){
                            $(this).dialog("close");
                        }
                    }),
                    width : 810,
                    height: 500
                });*/
        }
    });
}
function abrirDetalhesInicial(link) {
    $(".destaque").fadeOut();
    $(".loader").show();
    $.ajax({
        type : "GET",
        url : "detalhes_imovel.php?rand="+Math.random()*999999,
        data : ({
            "link" : link
        }),
        success : function(msg) {
            $(".loader").hide();
            $("#boxDetalhes").html(msg);
            $("#boxDetalhes").fadeIn();
        /*$("#boxDetalhes").dialog({
                    autoOpen : true,
                    title : "DETALHAMENTO DE IMÓVEIS",
                    buttons : ({
                        "FECHAR" : function(){
                            $(this).dialog("close");
                        }
                    }),
                    width : 810,
                    height: 500
                });*/
        }
    });
}
function voltar(){
    $("#boxDetalhes").fadeOut('slow',function(){
        $("#__imoveis").fadeIn();
        $(".destaque").fadeIn();
    });
    

}
function trocar_imagem(src) {
    $("#imggrande_popup1").attr("src",src);
    $("#imggrande_popup").attr("src","sistema/imagens/indicador_g.gif");
    $("#imggrande_popup").attr("width","40");
    $("#imggrande_popup").attr("height","40");
}

function mostrar_imagem() {
    $("#imggrande_popup").attr("src",$("#imggrande_popup1").attr("src"));
    $("#imggrande_popup").attr("width","320");
    $("#imggrande_popup").attr("height","245");
        
}

////////////////////


