$(document).ready(function () {
  $("body").on("blur", ".passport", getPass);

  function getPass() {
    var passport = $(".passport").val(),
      data = { passport: passport };

    $.ajax({
      type: "POST",
      dataType: "json",
      url: "get_courin.php",
      data: { passport: passport },
      success: function (response) {
        if (response != "") {
          var paxname = response.paxname,
            license = response.license,
            photo = response.photo,
            medical = response.medical,
            oldpass = response.oldpass;

          $(".paxname").val(paxname).trigger("change");
          if (medical == 1) {
            $(".medical").attr("checked", true);
          } else {
            $(".medical").attr("checked", false);
          }
          if (license == 1) {
            $(".license").attr("checked", true);
          } else {
            $(".license").attr("checked", false);
          }
          if (photo == 1) {
            $(".photo").attr("checked", true);
          } else {
            $(".photo").attr("checked", false);
          }
          if (oldpass == 1) {
            $(".oldpass").attr("checked", true);
          } else {
            $(".oldpass").attr("checked", false);
          }
        }
      },
      error: function (request, textStatus, errorThrown) {},
    });
  }
});
