// source --> /commons/js/top.js?ver=210602043753 
$(function(){
  $('.main-slide').on('init', function(){
    $(this).addClass('initialized');
  });
	$('.main-slide').slick({
		//fade: true,
		dots: true,
		infinite: true,
		slidesToShow: 1,
		arrows: false,
		autoplay: true,
		autoplaySpeed: 5000,
		speed: 800,
	});
});
$(function(){
	var sthei = $(window).height()*0.80;
	$(".main-slide .slide").css({
		height : sthei + 'px'
	});
	$(window).scroll(function () {
		if ($(this).scrollTop() > sthei) {
			$('header#header').addClass('on');
		} else {
			$('header#header').removeClass('on');
		}
	});
	$(window).resize(function(){
		var sthei = $(this).height()*0.80;
		$(".main-slide .slide").css({
			height : sthei + 'px'
		});
		$(window).scroll(function () {
			if ($(this).scrollTop() > sthei) {
				$('header#header').addClass('on');
			} else {
				$('header#header').removeClass('on');
			}
		});
	})
});
// source --> /commons/js/common.js?ver=231019141433 
//set UserAgent
var _ua = (function (u) {
  return {
    Tablet: (u.indexOf("windows") != -1 && u.indexOf("touch") != -1 && u.indexOf("tablet pc") == -1) ||
      u.indexOf("ipad") != -1 ||
      (u.indexOf("android") != -1 && u.indexOf("mobile") == -1) ||
      (u.indexOf("firefox") != -1 && u.indexOf("tablet") != -1) ||
      u.indexOf("kindle") != -1 ||
      u.indexOf("silk") != -1 ||
      u.indexOf("playbook") != -1,
    Mobile: (u.indexOf("windows") != -1 && u.indexOf("phone") != -1) ||
      u.indexOf("iphone") != -1 ||
      u.indexOf("ipod") != -1 ||
      (u.indexOf("android") != -1 && u.indexOf("mobile") != -1) ||
      (u.indexOf("firefox") != -1 && u.indexOf("mobile") != -1) ||
      u.indexOf("blackberry") != -1
  };
})(window.navigator.userAgent.toLowerCase());

$(function(){
  window.onload = function() {
    //*  ページ移動  *//
    var url = $(location).attr('href');
    if (url.indexOf("?id=") == -1) {
      // スムーズスクロール以外の処理（必要なら）
    }else{
      // スムーズスクロールの処理
      var url_sp = url.split("?id=");
      var hash   = '#' + url_sp[url_sp.length - 1];
      var tgt    = $(hash);
      var pos    = tgt.offset().top;
      $("html, body").animate({scrollTop:pos}, 'slow', "swing");
    }
  };
	$('a.scrool[href^=#]').click(function(){
		var href= $(this).attr("href");
		var target = $(href == "#" || href == "" ? 'html' : href);
		var position = target.offset().top;
		$("html, body").animate({scrollTop:position}, 'slow', "swing");
		return false;
	});
	$('.info-body').slick({
		dots: false,
		slidesToShow: 1,
		arrows: false,
		autoplay: true,
		autoplaySpeed: 3000,
		speed: 1500,
		vertical:true,
	});
	$('.sp-menu').click(function(e){
    e.preventDefault();
		$(this).addClass('on');
		$('nav.header-nav').addClass('on');
	});
	$('.close-btn, .close_btn').click(function(){
		$('.sp-menu').removeClass('on');
		$('nav.header-nav').removeClass('on');
	});

  $('.js-menuClose').on('click', function(e){
    $('nav.header-nav').removeClass('on');
  })

  var topBtn = $('#pgTop a');
  //スクロールが100に達したらボタン表示
  $(window).scroll(function () {
      if ($(this).scrollTop() > 200) {
          topBtn.addClass('is_active');
      } else {
          topBtn.removeClass('is_active');
      }
  });
});

$(function() {
  // if (!_ua.Mobile && !_ua.Tablet) {
  //   var $win = $(window),
  //       $main = $('#wrap'),
  //       $nav = $('#sticky'),
  //       navHeight = $nav.outerHeight(),
  //       navPos = $nav.offset().top,
  //       fixedClass = 'sticky';

  //   $win.on('load scroll', function() {
  //     var value = $(this).scrollTop();
  //     if ( value > navPos ) {
  //       $nav.addClass(fixedClass);
  //       $main.css('margin-top', navHeight);
  //     } else {
  //       $nav.removeClass(fixedClass);
  //       $main.css('margin-top', '0');
  //     }
  //   });
  // }
  // タブ
  $('.tab__head .tabs').click(function() {
    var index = $('.tab__head .tabs').index(this);
    $('.tab__head .tabs').removeClass('is_current');
    $(this).addClass('is_current');
    $('.tab__body .tabs__content').removeClass('is_current').eq(index).addClass('is_current');
  });

  $('.overflow.is_active').on('click', function(){
    $(this).removeClass('is_active');
  });

  $(function(){
    var agent = navigator.userAgent;
    if (agent.search('iPad') != -1 || agent.search('Macintosh') != -1 && 'ontouchend' in document){
      $('head meta[name="viewport"]').attr('content','width=1260');
    }
  });

  $('.js-filter-form :radio').on('click', function(){
    var checked = [];
    $('.js-filter-form :checked').each(function(){
      checked.push($(this).val()); // pushは配列に値を追加します
    });
    var t = $(this).val();
    if (t == 'all') {
      $('.js-filter-items').removeClass('is_hidden');
      $('.js-pin').removeClass('is_active').addClass('is_active');;
    } else {
      $('.js-filter-items').each(function(){
        var tag = $(this).data('tag');
        var is_exist = $.inArray( tag, checked ); // inArray()は配列内に値があるかどうかを調べます
        if (is_exist != -1) {
          $(this).removeClass('is_hidden');
        } else {
          $(this).addClass('is_hidden');
        }
      })
      $('.js-pin').removeClass('is_active');
      $('.js-pin').each(function(){
        var pin = $(this).data('pin');
        var is_exist = $.inArray( pin, checked ); // inArray()は配列内に値があるかどうかを調べます
        if (is_exist != -1) {
          $(this).addClass('is_active');
        } else {
          $(this).removeClass('is_active');
        }
      })
    }
  });

});

$(document).ready(function () {
  if (window.performance.navigation.type == 2) {
    window.location.reload();
  }
});