// アンカーリンク
$(function () {
    $('a[href^="#"]').click(function () {
        var adjust = $('.smenu').outerHeight();
        var speed = 400;
        var href = $(this).attr("href");
        var target = $(href == "#" || href == "" ? 'html' : href);
        var position = target.offset().top - adjust;
        $('body,html').animate({scrollTop: position}, speed, 'swing');
        return false;
    });
});

// アコーディオン
$(function () {



    $('.btn_open,.nxt').click(function () {
        $(this).next().slideToggle();
        $(this).toggleClass("open");
        if($(this).hasClass('open')){
            $('.btn_open.open em,.nxt').text("閉じる")
        }else{
            $('.btn_open em,.nxt').text("続きを見る")
        }
    });
});

$(function () {

    $(".q").next().hide();
    $(".q.open").next().show();

    $('.q').click(function () {
        $(this).next().slideToggle();
        $(this).toggleClass("open");
    });

});


// inview
const headings = document.querySelectorAll('.anm,.anm_all');
const options = {threshold: 0.01};
const observer = new IntersectionObserver(showElements, options);
headings.forEach(heading => {
    observer.observe(heading);
});

function showElements(entries) {
    entries.forEach(entry => {
        if (entry.isIntersecting) {
            const order = entry + 1;
            setTimeout(() => {
                entry.target.classList.add('trigger');
            });
        }
    });
}


$(function () {
    $('#header').load('./inc/header.html'); // #headerにheader.htmlを読み込む
    $('#footer').load('./inc/footer.html'); // #headerにheader.htmlを読み込む
});


$(window).scroll(function (){
    $(".anm_all.trigger .item").each(function (i) {
        $(this).delay(i * 100).queue(function(){
            $(this).addClass('up');
        });
    });
});



$('#video_smaple').hover(
    function() {
        $('video').prop('muted',true);
        //マウスカーソルが重なった時の処理

    },
    function() {
        //マウスカーソルが離れた時の処理
    }
);