
$(document).ready(function () {
  $("#spouse_chk").click(function () {
    var total = $(this).find('input[name="spouse_Widowed_5_years[]"]:checked').length;
    if (total >= 2) {
      $("#next_btn_c").prop("disabled", true);
    } else {
      $("#next_btn_c").prop("disabled", false);
    }
  });
  $("#vechicles_currently_own, #vechiclesown_rental_property, #vechicles_other_land").click(function () {
    if ($("#vechicles_currently_own, #vechiclesown_rental_property, #vechicles_other_land").is(":checked")) {
      $("#equity_value").show(300);
    } else {
      $("#equity_value").hide(200);
    }
    if ($("#vechicles_currently_own").is(":checked")) {
      $("#div_homeown_ins").show();
    } else {
      $('#div_homeown_ins').hide();
    }
  });
});
//    formcq type
$(document).ready(function () {
  $("#vehicles_own,#vehicles_sold").change(function () {
    if ($("#vehicles_own,#vehicles_sold").is(":checked")) {
      $("#make_a_model,#fair_market").show(300);
    } else {
      $("#make_a_model,#fair_market").hide(200);
    }
  });
});
$(document).ready(function () {
  $("#vehicles_sold").change(function () {

    if ($("#vehicles_sold").is(":checked")) {
      $("#vehicles_date_sold").show(300);
    } else {
      $("#vehicles_date_sold").hide(200);
    }
  });
});
//    formcq end
$(document).ready(function () {
  $("#insurance_medicare,#insurance_medicare_replacement").change(function () {

    if ($("#insurance_medicare,#insurance_medicare_replacement").is(":checked")) {
      $("#medicare").show(300);
    } else {
      $("#medicare").hide(200);
    }
  });
});
//    2nd
$(document).ready(function () {
  $("#insurance_medicare_replacement").change(function () {

    if ($("#insurance_medicare_replacement").is(":checked")) {
      $("#medicare,#hmo_name_id").show(300);
    } else {
      $("#medicare,#hmo_name_id").hide(50);
    }
  });
});
//    3rd
$(document).ready(function () {
  $("#insurance_through_work,#insurance_medigap,#insurance_medicare_replacement").change(function () {

    if ($("#insurance_through_work,#insurance_medigap,#insurance_medicare_replacement").is(":checked")) {
      $("#hmo_name_id").show(300);
    } else {
      $("#hmo_name_id").hide(300);
    }
  });
});
//    life i
$(document).ready(function () {
  $("#insurance_life_insurance").change(function () {

    if ($("#insurance_life_insurance").is(":checked")) {
      $("#medicare_life_insurance,#medicare_cash_value,#medicare_policy").show(300);
    } else {
      $("#medicare_life_insurance,#medicare_cash_value,#medicare_policy").hide(300);
    }
  });
});

$(document).ready(function () {
  var sig1 = $('#sign').signature({syncField: '#main_sign', syncFormat: 'PNG'});
  $('#clear_sign').click(function (e) {
    e.preventDefault();
    sig1.signature('clear');
    $("#main_sign").val('');
  });
});


//for snf_prior page 3
//  function toggleElement() {
//    const element = document.querySelector('.snf_prior');
//    element.classList.toggle('hide');
//  }
function toggleElement_b() {
  const element = document.querySelector('.how_much_rent');
  element.classList.toggle('hide');
}

//  $('input[type="radio"]').click(function() {
//  if($(this).attr('value') == 'yes') {
//    $('#Medicaid_id').show();
//  } else {
//    $('#Medicaid_id').hide();
//  }
//});

$(document).ready(function () {
  $("#snf_living_yes").click(function () {
    $('#snf_val').val($(this).val());
    $('#menu_snf_prior').closest('li').show(1000);
  });
});
//$(document).ready(function () {
//    $("#spouse_never_married").click(function () {
//        $(".spouse_income").hide(300);
//        $('#snf_living_val').val('spouse_income');
//    });
//});
$(document).ready(function () {
  $("#snf_living_no").click(function () {
    $('#snf_val').val($(this).val());
    $('#menu_snf_prior').closest('li').hide(1000);
  });
});
$(document).ready(function () {
  $("#Medicaid_yes").change(function () {
    $(".Medicaid_id").show(300);
  });
});


$(document).ready(function () {
  $("#Medicaid_no").click(function () {
    $(".Medicaid_id").hide(300);
  });
});
$(document).ready(function () {
  $("#banking_no_cheak").click(function () {
    $(".banking_no").hide(1000);
  });
  $("#banking_yes").click(function () {
    $(".banking_no").show(1000);
  });
});
$(document).ready(function () {
  $("#spouse_banking_yes").change(function () {
    $(".spouse_banking_hide").show(300);
  });
});
$(document).ready(function () {
  $("#spouse_banking_no").click(function () {
    $(".spouse_banking_hide").hide(300);
  });
});

/*$(document).ready(function () {
 $(".spouse_yes").click(function () {
 $(".spouse_yes_show").show(300);
 });
 });
 $(document).ready(function () {
 $("#spouse_never_married").click(function () {
 $(".spouse_yes_show").hide(300);
 });
 });
 $(document).ready(function () {
 $("#spouse_Widowed_5_years").click(function () {
 $(".spouse_yes_show").show(300);
 });
 });
 $(document).ready(function () {
 $("#spouse_divorced_5_years").click(function () {
 $(".spouse_yes_show").show(300);
 });
 });*/

function ShowHideSet(hideid, showid) {
  if (hideid != '') {
    $('#' + hideid).hide(1000);
  }
  if (showid != '') {
    if (showid == 'snf_prior' && $('#snf_val').val() == 0) {
      if (hideid == 'spouse') {
        showid = 'address';
      } else {
        showid = 'spouse';
      }
    } else if (showid == 'sold_property' && $('#sold_last5yrs').val() == 0) {
      if (hideid == 'insurance_info') {
        showid = 'real_state_vechicles';
      } else {
        showid = 'insurance_info';
      }
    } else if (showid === 'spouse_banking' && $('#have_spouse').val() == 0) {
      if (hideid == 'funeral_info') {
        showid = 'banking';
      } else {
        showid = 'funeral_info';
      }
    } else if (showid === 'spouses_name' && $('#have_spouse').val() == 0) {
      if (hideid == 'best_contact') {
        showid = 'funeral_info';
      } else {
        showid = 'best_contact';
      }
    }
    $('#' + showid).show(1000);
  }
}

/*$(document).ready(function () {
 $('input[name="spouse_yes"]').change(function () {
 if ($(this).val() == "Never married") {
 $('#spouse_income').hide();
 } else {
 $('#spouse_income').show();
 }
 });
 });*/
$(document).ready(function () {
  $('#vechicles_sold').change(function () {
    if ($(this).is(':checked')) {
      $('#sold_last5yrs').val(1);
      $('#menu_sold_property').closest('li').show(1000);
    } else {
      $('#sold_last5yrs').val(0);
      $('#menu_sold_property').closest('li').hide(1000);
    }
  });
  $('input[name="spouse_yes"]').change(function () {
    if ($(this).val() === 'yes' || $(this).val() === 'Widowed in past 5 years' || $(this).val() === 'Divorced in past 5 years') {
      $('#have_spouse').val(1);
      $('#spouse_income').show();
      $('#spouse_investments').show();
      $('#spouse_burial_div').show();
      $('#menu_spouse_banking').closest('li').show(1000);
      $('#menu_spouses_name').closest('li').show(1000);
    } else {
      $('#have_spouse').val(0);
      $('#spouse_income').hide();
      $('#spouse_investments').hide();
      $('#spouse_burial_div').hide();
      $('#menu_spouse_banking').closest('li').hide(1000);
      $('#menu_spouses_name').closest('li').hide(1000);
    }
  });
  //File upload code 
  $('#page1_add_file').click(function () {
    var htm_ctrl = $('.page1_file_control').html();
    $('#page1_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#address_add_file').click(function () {
    var htm_ctrl = $('.address_file_control').html();
    $('#address_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#snf_add_file').click(function () {
    var htm_ctrl = $('.snf_file_control').html();
    $('#snf_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#spouse_add_file').click(function () {
    var htm_ctrl = $('.spouse_file_control').html();
    $('#spouse_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#demographics_add_file').click(function () {
    var htm_ctrl = $('.demographics_file_control').html();
    $('#demographics_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#real_state_vechicles_add_file').click(function () {
    var htm_ctrl = $('.real_state_vechicles_file_control').html();
    $('#real_state_vechicles_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#sold_property_add_file').click(function () {
    var htm_ctrl = $('.sold_property_file_control').html();
    $('#sold_property_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#insurance_info_add_file').click(function () {
    var htm_ctrl = $('.insurance_info_file_control').html();
    $('#insurance_info_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#income_add_file').click(function () {
    var htm_ctrl = $('.income_file_control').html();
    $('#income_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#investments_add_file').click(function () {
    var htm_ctrl = $('.investments_file_control').html();
    $('#investments_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#banking_add_file').click(function () {
    var htm_ctrl = $('.banking_file_control').html();
    $('#banking_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#spouse_banking_add_file').click(function () {
    var htm_ctrl = $('.spouse_banking_file_control').html();
    $('#spouse_banking_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#funeral_info_add_file').click(function () {
    var htm_ctrl = $('.funeral_info_file_control').html();
    $('#funeral_info_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#spouses_name_add_file').click(function () {
    var htm_ctrl = $('.spouses_name_file_control').html();
    $('#spouses_name_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  $('#best_contact_add_file').click(function () {
    var htm_ctrl = $('.best_contact_file_control').html();
    $('#best_contact_file_main').append('<div class="col-md-12">' + htm_ctrl + '</div>');
  });
  ////////////////////////////
  //Top menu functionality
  $('#navbarCollapse li a').click(function (e) {
    e.preventDefault();
    $('#job_form').find('fieldset').hide(1000);
    var fid = (this.id);
    fid = fid.replace('menu_', '');
    $("#" + fid).show(1000);
  });
  ///////////////////////////
});