// JavaScript Document
window.onload = function(){
	createTab();
	hideHeading();
	showCategory('about1');
	setTabClick('about1nav','about1');
	setTabClick('about2nav','about2');
	setTabClick('about3nav','about3');
	setTabClick('about4nav','about4');
};

function hide(elementId) {
	document.getElementById(elementId).style.display = "none";
}
function show(elementId) {
	document.getElementById(elementId).style.display = "block";
}
function hideHeading() {
	hide('about1');
	hide('about2');
	hide('about3');
	hide('about4');
}
function showCategory(categoryName){
	hide('about1'); 
	hide('about2'); 
	hide('about3'); 
	hide('about4'); 
	show(categoryName);
	changeTab(categoryName);
}

function createTab() {
	var aboutcontent_footer = document.getElementById("aboutcontent_footer");
	var aboutcontent = document.getElementById("aboutcontent");
	var nav = document.createElement("ul");
	nav.setAttribute('id','aboutnav');
	nav.appendChild(createListItem('about1nav','#about1','名称の由来'));
	nav.appendChild(createListItem('about2nav','#about2','施設のご案内'));
	nav.appendChild(createListItem('about3nav','#about3','メンバーシップ'));
	nav.appendChild(createListItem('about4nav','#about4','写真'));	
	aboutcontent_footer.insertBefore(nav,aboutcontent);
}
function createListItem(id,href,text) {
	var li = document.createElement("li");
	var a = document.createElement("a");
	var t = document.createTextNode(text);
	li.setAttribute('id',id);
	a.setAttribute('href',href);
	a.appendChild(t);
	li.appendChild(a);
	return li;
}

function setTabClick(listName,categoryName) {
	var e = document.getElementById(listName).getElementsByTagName('a')[0];
	e.onclick = function(){
		showCategory(categoryName);
		return false;
	};
}

function changeTab(categoryName){
	var e = document.getElementById('aboutnav');
	e.className = categoryName;
}