$("#field-faixa_preco_inicial").inputmask("currency", {
  autoUnmask: true,
  radixPoint: ",",
  groupSeparator: ".",
  allowMinus: false,
  prefix: "R$ ",
  digits: 2,
  digitsOptional: false,
  rightAlign: false,
  unmaskAsNumber: true
});

$("#field-faixa_preco_final").inputmask("currency", {
  autoUnmask: true,
  radixPoint: ",",
  groupSeparator: ".",
  allowMinus: false,
  prefix: "R$ ",
  digits: 2,
  digitsOptional: false,
  rightAlign: false,
  unmaskAsNumber: true
});

$('#field-telefone').inputmask({
    mask: ["(99) 99999-9999"]
});
/*
$('.btn-enviar-whats-anunciar-interesse').on('click',function(){
    loadButton($(this));
    $data = getForm($('.form-sugestoes-anunciar-interesse'));
    $telefone = {'name': 'telefone', 'value':$(this).data('telefone')};
    $data.push($telefone);
    
    get_ajax_($data, 'atendimento/ajax/Incorporadora_ajax/enviaSugestoes',
    success => {
        
        if(success.success == true){        
            $(".form-sugestoes-anunciar-interesse").prop("disabled",true);
            
            console.log(success);
           
            $('.result_envia_whats_interesse').html('');
            $('.result_envia_whats_interesse').append('<div class="alert alert-primary alert-dismissible fade show" role="alert"> '+success.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');
           
        }else{
            
            console.log(success);
            $('.result_envia_whats_interesse').html('');
            $('.result_envia_whats_interesse').append('<div class="alert alert-danger alert-dismissible fade show" role="alert"> '+success.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');
        }  
        
    });
});
*/
$('.btn-envia-email-sugestao').on('click',function(){
    loadButton($(this));
    $data = getForm($('.form-sugestoes-anunciar-interesse'));
    $email = {'name': 'email', 'value':$(this).data('email')};
    $data.push($email);
    get_ajax_($data, 'atendimento/ajax/Incorporadora_ajax/enviaEmailSugestoes',
    success => {
        
        if(success.success == true){        
            $(".form-sugestoes-anunciar-interesse").prop("disabled",true);
            
            console.log(success);
           
            $('.result_envia_whats_interesse').html('');
            $('.result_envia_whats_interesse').append('<div class="alert alert-primary alert-dismissible fade show" role="alert"> '+success.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');
           
        }else{
            
            console.log(success);
            $('.result_envia_whats_interesse').html('');
            $('.result_envia_whats_interesse').append('<div class="alert alert-danger alert-dismissible fade show" role="alert"> '+success.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>');
        }  
        
    });
});


$('.checkbox_sugestoes_imoveis_todos').on('change', function(){
    if($('.checkbox_sugestoes_imoveis_todos').prop("checked") == true){
        $('.checkbox_sugestoes_imoveis').prop("checked", true);
    }
    else{
        $('.checkbox_sugestoes_imoveis').prop("checked", false);
    }
});