$(document).ready(function () {
  $(".select2").select2();
}),
  $(document).ready(function () {
    $(".file-upload").on("change", function () {
      !(function (e) {
        if (e.files && e.files[0]) {
          var t = new FileReader();
          (t.onload = function (e) {
            $(".profile-pic").attr("src", e.target.result);
          }),
            t.readAsDataURL(e.files[0]);
        }
      })(this);
    }),
      $(".upload-button").on("click", function () {
        $(".file-upload").click();
      });
  });

$(function () {
  $("[name=toggler]").click(function () {
    $(".toHide").hide();
    $("#blk-" + $(this).val()).show();
  });
});

function myNote() {
  var x = document.getElementById("note-form");
  if (x.style.display === "block") {
    x.style.display = "none";
  } else {
    x.style.display = "block";
  }
}

function mainNote() {
  var x = document.getElementById("main-note");
  if (x.style.display === "block") {
    x.style.display = "none";
  } else {
    x.style.display = "block";
  }
}

function myFunction() {
  var x = document.getElementById("phone-search");
  if (x.style.display === "block") {
    x.style.display = "none";
  } else {
    x.style.display = "block";
  }
}

function demoFunction() {
  var x = document.getElementById("trial-store");
  if (x.style.display === "block") {
    x.style.display = "none";
  } else {
    x.style.display = "block";
  }
}

$(window).scroll(function () {
  if ($(this).scrollTop() > 67) {
    $(".subnav").addClass("fixed-top");
  } else {
    $(".subnav").removeClass("fixed-top");
  }
});

$(window).scroll(function () {
  if ($(this).scrollTop() > 67) {
    $(".list,.singbar,.cartbar").addClass("nav-fixed");
  } else {
    $(".list,.singbar,.cartbar").removeClass("nav-fixed");
  }
});

jQuery(document).ready(function () {
  /*
      Sidebar
  */
  /*-------------------------------------------------------------------------*/
  $(".cart-dismiss, .overlay").on("click", function () {
    $(".cartbar").removeClass("active");
    $(".overlay").removeClass("active");
  });

  $(".open-menu").on("click", function (e) {
    e.preventDefault();
    $(".cartbar").addClass("active");
    $(".overlay").addClass("active");
    // close opened sub-menus
    $(".collapse.show").toggleClass("show");
    $("a[aria-expanded=true]").attr("aria-expanded", "false");
  });

  /*-------------------------------------------------------------------------*/
  $(".list-dismiss, .overlay").on("click", function () {
    $(".list").removeClass("active");
    $(".overlay").removeClass("active");
  });

  $(".open-list").on("click", function (e) {
    e.preventDefault();
    $(".list").addClass("active");
    $(".overlay").addClass("active");
    // close opened sub-menus
    $(".collapse.show").toggleClass("show");
    $("a[aria-expanded=true]").attr("aria-expanded", "false");
  });
  /*-------------------------------------------------------------------------*/
  /*
    /*-------------------------------------------------------------------------*/
  $(".sing-dismiss, .overlay").on("click", function () {
    $(".singbar").removeClass("active");
    $(".overlay").removeClass("active");
  });

  $(".btn-sing,.btn-login").on("click", function (e) {
    e.preventDefault();
    $(".singbar").addClass("active");
    $(".overlay").addClass("active");
    // close opened sub-menus
    $(".collapse.show").toggleClass("show");
    $("a[aria-expanded=true]").attr("aria-expanded", "false");
  });
  /*-------------------------------------------------------------------------*/
});
