/*
 * include id-specified html into corresponding div
 */
window.addEventListener(
"DOMContentLoaded",
function () {
    function includeIdFiles() {
	for (let id of ["header", "footer"]) {
	    let e   = document.getElementById(id);
	    if (!e) continue;
	    let dir = (e.getAttribute("dir") || ".."),
		fn  = dir + "/" + e.id + ".html";
	    fetch(fn).then((resp) => {
		resp.text().then((text) => {
		    let newmenu = e.insertAdjacentHTML("afterend", text);
		    e.remove();
		    newmenu.id = id;
		});
	    });
	    
	}
    }
    function init() {
	includeIdFiles();
    }
    init();
});
window.addEventListener("scroll", function(){
    var header = document.querySelector("header");
header.classList.toggle("scroll-nav", window.scrollY > 0)
});
window.addEventListener("DOMContentLoaded", function(){
	const faqs = document.querySelectorAll("div.faq-list dl");
	console.log(faqs);
	faqs.forEach(faqs => {
		faqs.addEventListener("click",()=> {
			faqs.classList.toggle("act");
			faqs.children[0].classList.toggle("question");
			faqs.children[1].classList.toggle("faq-show");
		});
	});
});