/*////////////////////////////////////////////////////////////////////// */
/*  ---  目次  ---
● webフォント　ちらつき防止
● グローバルメニュー追従
● ハンバーガーメニュー
● タブ切り替え
● ページ内スクロール
● サムネイルの切り替え
● メニューの開閉
● ビジュアルエディタの調整
● お問い合わせフォーム
● コンテンツの高さ調整
● select placeholder色の変更
  ---  目次  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  webフォント　ちらつき防止  ---   */
window.WebFontConfig = {
  google: {
    families: ["Noto+Sans+JP:wght@400;500;700"],
  },
  active: function () {
    sessionStorage.fonts = true;
  },
};

(function () {
  var wf = document.createElement("script");
  wf.src = "//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js";
  wf.type = "text/javascript";
  wf.async = "true";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(wf, s);
})();
/*  ---  webフォント　ちらつき防止  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  グローバルメニュー追従  ---   */
const mediaQueryList_menu = window.matchMedia('(min-width: 992px)');
const event = (event) => {
    $(window).scroll(function () {
      if (event.matches) {
        if($(window).scrollTop() > 95) {
          $('.l-header_nav').addClass('nav-fixed');
        } else {
          $('.l-header_nav').removeClass('nav-fixed');
        }
      }
  });
};
mediaQueryList_menu.addEventListener("change", event);
event(mediaQueryList_menu);
/*  ---  グローバルメニュー追従  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  ハンバーガーメニュー  ---   */
$(".js-hamhamburger").on("click", function () {
  $(".l-header").toggleClass("is-open");
  $(".c-nav").toggleClass("is-active");
});

// const mediaQueryList = window.matchMedia('(min-width: 992px)');

// const listener = (event) => {
//   const boxheight = document.getElementById("slideItem").clientHeight;

//   let flug = false;
//   $("#js-navmenu").hover(function ()  {

//     if (event.matches) {
//       const boxheight = document.getElementById("slideItem").clientHeight;
//       flug = !flug
//       if (flug) {
//         document.getElementById("slide").style.height = boxheight + "px";
//         $(this).addClass('is-open');
//       } else {
//         document.getElementById("slide").style.height = 0 + "px";
//         $(this).removeClass('is-open');
//       }
//     }else{
     
//     }
//     },
//   );
//   if (!(event.matches)) {
//     $("#slide").removeAttr("style");
//   }
// };

// mediaQueryList.addEventListener("change", listener);

// listener(mediaQueryList);
/*  ---  ハンバーガーメニュー  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  タブ切り替え  ---   */
  jQuery(function ($) {
    $(".p-case .js-tab-btn").click(function () {
      $(".p-case .is-close").removeClass("is-close");
      $(".p-case .is-active").removeClass("is-active");
      $(this).addClass("is-active");
      $('.p-main-tab ').addClass("is-active");
      $(".p-case .is-show").removeClass("is-show");
      const index = $(this).index() -1;
      $(".p-case .p-sub-tab").eq(index).addClass("is-show");
    });
  });
/*  ---  タブ切り替え  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  ページ内スクロール  ---   */
// jQuery(function ($) {
//   const pageTop = $(".page-top.scroll");
//   pageTop.hide();
//   $(window).scroll(function () {
//     if ($(this).scrollTop() > 100) {
//       pageTop.fadeIn();
//     } else {
//       pageTop.fadeOut();
//     }
//   });
//   pageTop.click(function () {
//     $("body,html").animate(
//       {
//         scrollTop: 0,
//       },
//       50
//     );
//     return false;
//   });
// });
/*  ---  ページ内スクロール  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  サムネイルの切り替え  ---   */
$(function () {
  $(".js-thumbnail img").on("click", function () {
    // mainに切り替えるimgのsrc取得
    const img = $(this).attr("src");
    // mainのsrcを変更
    $(".single-imgArea_mainImg img").attr("src", img);
  });
});

$(function () {
  $(".js-thumbnail img").on("click", function () {
    $(".js-thumbnail img").removeClass("show");
    $(this).addClass("show");
  });
});
/*  ---  サムネイルの切り替え  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  メニューの開閉 ---   */
//フッター
jQuery(function ($) {
  $(".js-footer-tax").click(function () {
    $(this).toggleClass("is-open");
    $(this).next(".l-footer_subList").stop().slideToggle();
  });
});

//よくある質問
jQuery(function ($) {
  $(".js-faq").click(function () {
    $(this).toggleClass("is-open");
    $(this).next(".c-faq-answer").stop().slideToggle();
  });
});
/*  ---  メニューの開閉  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  ビジュアルエディタの調整 ---   */
$(".c-editor-style img.aligncenter").parent('p').addClass('aligncenter');
$(".c-editor-style img.alignright").parent('p').addClass('alignright');
$(".c-editor-style img.alignleft").parent('p').addClass('alignleft');
$(".c-editor-style img.alignnone").parent('p').addClass('fleximg');

$(document).ready(function(){
  $('p.alignright,p.alignleft').next().addClass('after');
});

// 空のpタグを削除
const emptyParagraphs = document.querySelectorAll('.c-editor-style p:empty');
emptyParagraphs.forEach(paragraph => {
    paragraph.remove();
});
/*  ---  ビジュアルエディタの調整  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  お問い合わせフォーム ---   */
//select
$(function() {
  const Select = $('select.is-empty');
      $(Select).on('change', function(){
      if ($(Select).val() !== ""){
          $(this).removeClass('is-empty');
      } else {
          $(this).addClass('is-empty');
      }
  });
});

//file
function contactFile() {
	let $target = $(".file_attachment");
	
	$target.each(function(){
		let $this = $(this);
		let $file =  $this.find("input");
		let $textArea =  $this.find(".filetextdefault");
		let fileName = "";
		$file.on("change",function(){
			fileName = $file.prop('files')[0].name;
			if(fileName != "") {
				$textArea.text(fileName);
			} else {
				$textArea.text("ファイルを選択してください");
			}
		});
	});
}
contactFile();
/*  ---  お問い合わせフォーム セレクトボックス  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  コンテンツの高さ調整  ---   */
//高さ
/*
 * jquery-match-height 0.7.2 by @liabru
 * http://brm.io/jquery-match-height/
 * License MIT
 */
!(function (t) {
  "use strict";
  "function" == typeof define && define.amd
    ? define(["jquery"], t)
    : "undefined" != typeof module && module.exports
    ? (module.exports = t(require("jquery")))
    : t(jQuery);
})(function (t) {
  var e = -1,
    o = -1,
    n = function (t) {
      return parseFloat(t) || 0;
    },
    a = function (e) {
      var o = 1,
        a = t(e),
        i = null,
        r = [];
      return (
        a.each(function () {
          var e = t(this),
            a = e.offset().top - n(e.css("margin-top")),
            s = r.length > 0 ? r[r.length - 1] : null;
          null === s
            ? r.push(e)
            : Math.floor(Math.abs(i - a)) <= o
            ? (r[r.length - 1] = s.add(e))
            : r.push(e),
            (i = a);
        }),
        r
      );
    },
    i = function (e) {
      var o = {
        byRow: !0,
        property: "height",
        target: null,
        remove: !1,
      };
      return "object" == typeof e
        ? t.extend(o, e)
        : ("boolean" == typeof e
            ? (o.byRow = e)
            : "remove" === e && (o.remove = !0),
          o);
    },
    r = (t.fn.matchHeight = function (e) {
      var o = i(e);
      if (o.remove) {
        var n = this;
        return (
          this.css(o.property, ""),
          t.each(r._groups, function (t, e) {
            e.elements = e.elements.not(n);
          }),
          this
        );
      }
      return this.length <= 1 && !o.target
        ? this
        : (r._groups.push({ elements: this, options: o }),
          r._apply(this, o),
          this);
    });
  (r.version = "0.7.2"),
    (r._groups = []),
    (r._throttle = 80),
    (r._maintainScroll = !1),
    (r._beforeUpdate = null),
    (r._afterUpdate = null),
    (r._rows = a),
    (r._parse = n),
    (r._parseOptions = i),
    (r._apply = function (e, o) {
      var s = i(o),
        h = t(e),
        l = [h],
        c = t(window).scrollTop(),
        p = t("html").outerHeight(!0),
        u = h.parents().filter(":hidden");
      return (
        u.each(function () {
          var e = t(this);
          e.data("style-cache", e.attr("style"));
        }),
        u.css("display", "block"),
        s.byRow &&
          !s.target &&
          (h.each(function () {
            var e = t(this),
              o = e.css("display");
            "inline-block" !== o &&
              "flex" !== o &&
              "inline-flex" !== o &&
              (o = "block"),
              e.data("style-cache", e.attr("style")),
              e.css({
                display: o,
                "padding-top": "0",
                "padding-bottom": "0",
                "margin-top": "0",
                "margin-bottom": "0",
                "border-top-width": "0",
                "border-bottom-width": "0",
                height: "100px",
                overflow: "hidden",
              });
          }),
          (l = a(h)),
          h.each(function () {
            var e = t(this);
            e.attr("style", e.data("style-cache") || "");
          })),
        t.each(l, function (e, o) {
          var a = t(o),
            i = 0;
          if (s.target) i = s.target.outerHeight(!1);
          else {
            if (s.byRow && a.length <= 1) return void a.css(s.property, "");
            a.each(function () {
              var e = t(this),
                o = e.attr("style"),
                n = e.css("display");
              "inline-block" !== n &&
                "flex" !== n &&
                "inline-flex" !== n &&
                (n = "block");
              var a = {
                display: n,
              };
              (a[s.property] = ""),
                e.css(a),
                e.outerHeight(!1) > i && (i = e.outerHeight(!1)),
                o ? e.attr("style", o) : e.css("display", "");
            });
          }
          a.each(function () {
            var e = t(this),
              o = 0;
            (s.target && e.is(s.target)) ||
              ("border-box" !== e.css("box-sizing") &&
                ((o +=
                  n(e.css("border-top-width")) +
                  n(e.css("border-bottom-width"))),
                (o += n(e.css("padding-top")) + n(e.css("padding-bottom")))),
              e.css(s.property, i - o + "px"));
          });
        }),
        u.each(function () {
          var e = t(this);
          e.attr("style", e.data("style-cache") || null);
        }),
        r._maintainScroll &&
          t(window).scrollTop((c / p) * t("html").outerHeight(!0)),
        this
      );
    }),
    (r._applyDataApi = function () {
      var e = {};
      t("[data-match-height], [data-mh]").each(function () {
        var o = t(this),
          n = o.attr("data-mh") || o.attr("data-match-height");
        n in e ? (e[n] = e[n].add(o)) : (e[n] = o);
      }),
        t.each(e, function () {
          this.matchHeight(!0);
        });
    });
  var s = function (e) {
    r._beforeUpdate && r._beforeUpdate(e, r._groups),
      t.each(r._groups, function () {
        r._apply(this.elements, this.options);
      }),
      r._afterUpdate && r._afterUpdate(e, r._groups);
  };
  (r._update = function (n, a) {
    if (a && "resize" === a.type) {
      var i = t(window).width();
      if (i === e) return;
      e = i;
    }
    n
      ? o === -1 &&
        (o = setTimeout(function () {
          s(a), (o = -1);
        }, r._throttle))
      : s(a);
  }),
    t(r._applyDataApi);
  var h = t.fn.on ? "on" : "bind";
  t(window)[h]("load", function (t) {
    r._update(!1, t);
  }),
    t(window)[h]("resize orientationchange", function (t) {
      r._update(!0, t);
    });
});

$(function () {
  $(".swiper_content li").matchHeight();
  $(".p-top-advices_item").matchHeight();
});
/*  ---  コンテンツの高さ調整  ---   */
/*////////////////////////////////////////////////////////////////////// */
/*  ---  select placeholder色の変更  ---   */
$(function(){
  $('select.your-family').on('change', function(){
      if($(this).val() == ""){//first_as_labelのvalueは空文字で出力される。
          $(this).css('color','#A3A3A3');
      } else {
          $(this).css('color','#1C1C1C');
      }
  });
});
/*  ---  select placeholder色の変更  ---   */
/*////////////////////////////////////////////////////////////////////// */