$(document).ready(function(){
$('#rg, #rg_pj').mask('99.999.999-9');
$('#cpf, #cpf_pj').mask('999.999.999-99');
$('#data_nascimento, #data_nascimento_pj').mask('99/99/9999');
$('#cep, #cep_pj').mask('99999-999');
$('#celular, #celular_pj').mask('(99) 9999-9999?9');
$('#telefone_residencial, #telefone_residencial_pj, #telefone_comercial, #telefone_comercial_pj').mask('(99) 9999-9999');
$('#cnpj').mask('99.999.999/9999-99');
$('#remuneracao, #faturamento_mensal').priceFormat({
prefix: 'R$ ',
centsSeparator: ',',
thousandsSeparator: '.'
});
$("#ajaxondeestamos").fancybox({
'width' : 710,
'height' : '100%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});
$("#ajaxchat_form").fancybox({
'width' : 400,
'height' : '5%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});
$("#ajaxsimule_form").fancybox({
'width' : 400,
'height' : '5%',
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});
$(window).scroll(function (event) {
var scroll = $(window).scrollTop();
if(scroll >= 40){
$("#top").css({'position':'fixed', 'top': 0});
}else{
$("#top").css({'position':'relative', 'top': 0});
}
});
$('#modelo').on('change', function(){
var modelo_carro = $( "#modelo option:selected" ).text();
$('.modelo_form').val(modelo_carro);
$("#option_modelo").attr('disabled', 'disabled');
$(".option_ajax").remove();
$.ajax({
type: "POST",
dataType: "json",
url: "apoio.php",
data: 'carro='+$(this).val(),
success: function(data) {
var option = '';
if(data['mais_leve'])
option += '';
if(data['leve'])
option += '';
if(data['normal'])
option += '';
if(data['gold'])
option += '';
$("#plano_option").after(option);
}
});
});
$("#plano_modelo").on('change', function(){
var plano_carro = $( "#plano_modelo option:selected" ).text();
$('.plano_form').val(plano_carro);
$("#plano_option").attr('disabled', 'disabled');
if($(this).val() ==0)
return false;
$("#preco").show();
str = $(this).val();
retorno = str.split("_");
valor = retorno[0].split(",");
$("#valor").html(valor[0]);
$("#cents").html(','+valor[1]);
$('.valor_parcela_form').val(valor[0] + ',' + valor[1]);
$("#val_credito").html('R$ ' + retorno[3]);
$('.credito_form').val('R$ ' + retorno[3]);
$("#val_prazo").html(retorno[2] + ' Meses');
$('.prazo_form').val(retorno[2] + ' Meses');
$("#val_plano").html(retorno[1]);
$("#description_plano").show();
});
$('.thumb_veiculo').on('click', function(){
$(".imgbig").hide();
strid = $(this).attr('id');
thumb = strid.split("_");
$("#img_big_"+thumb[1]).fadeIn();
});
$('.radio_tipo').on('change', function(){
if($(this).val() == 0){
$('#form_pj').hide();
$('#form_pf').css('display', 'table');
} else {
$('#form_pf').hide();
$('#form_pj').css('display', 'table');
}
});
});