// $(window).on("load", function(){
//   $(".loading").fadeOut();
// });

$(function(){
  setTimeout(function(){
    $(".loading").fadeOut();
  },2000);
});
//ドロワー
$(function(){
  $("#nav-toggle").on("click", function(){
    $("body").toggleClass("open");
  });
  $(".close-btn , .access a").on("click", function(){
    $("body").removeClass("open");
  });
});

//スクロール系
$(function(){
  var hs = $("header");
  var spf = $(".sp-foot");
  $(window).scroll(function () {
    if ( $(this).scrollTop() > 100 ) {
      hs.addClass("header-bg");
      spf.addClass("fixed-foot");
    } else {
      hs.removeClass("header-bg");
      spf.removeClass("fixed-foot");
    }
  });
});

//アコーディオンFAQ
$(function(){
	$(".accordion li div").on("click", function() {
		$(this).next().slideToggle();
		if ($(this).children(".accordion_icon").hasClass('active')) {
			$(this).children(".accordion_icon").removeClass('active');
		}
		else {
			$(this).children(".accordion_icon").addClass('active');
		}
	});
});

//スムーススクロール
$(function(){
  $('a[href^="#"]').click(function(){
    var speed = 500;
    var href = $(this).attr("href");
    var target = $(href == "#" || href == "" ? 'html' : href);
    var header = $('header').height();
    var position = target.offset().top - header;
    $("html, body").animate({scrollTop:position}, speed, "swing");
    return false;
  });
});

//バリデート
$(function() {
    $("#mail").on("keyup", function() {
        if ($(this).val() != $('#mail2').val()) {
            $("#agreement").prop("disabled", true);
            $('#err').show();
        } else {
            $("#agreement").prop("disabled", false);
            $('#err').hide();
        }
    });
    $("#mail2").on("keyup", function() {
        if ($(this).val() != $('#mail').val()) {
            $("#agreement").prop("disabled", true);
            $('#err').show();
        } else {
            $("#agreement").prop("disabled", false);
            $('#err').hide();
        }
    });
});

$(function() {
    $("#submit").prop("disabled", true);

    $("#agreement").on("click", function() {
        if ($(this).prop("checked") == false) {
            $("#submit").prop("disabled", true);
        } else {
            $("#submit").prop("disabled", false);
        }
    });
});

//Modal Window
$(function(){
  var winScrollTop;
  $(".js-modal-open").each(function(){
    $(this).on('click',function(){
      //スクロール位置を取得
      winScrollTop = $(window).scrollTop();
      var target = $(this).data("target");
      var modal = document.getElementById(target);
      $(modal).fadeIn();
      return false;
    });
  });
  $(".js-modal-close").on("click",function(){
    $(".js-modal").fadeOut();
    $("body,html").stop().animate({scrollTop:winScrollTop}, 100);
    return false;
  });
});

$(function(){
  $('#staff-order').on('change',function(){
    $('#staff-search').submit();
  });
});

//WOW
$(function() {
	new WOW().init();
});
