window.onload = function(){
	createTab();
	hideHeading();
	showCategory('eyelash');
	setTabClick('eyelashNav','eyelash');
	setTabClick('nailNav','nail');
    setTabClick('othersNav','others');
};

function hide(elementId) {
	document.getElementById(elementId).style.display = "none";
}
function show(elementId) {
	document.getElementById(elementId).style.display = "block";
}
function hideHeading() {
	hide('eyelashHeading');
	hide('nailHeading');
	hide('othersHeading');
}
function showCategory(categoryName){
	hide('eyelash'); 
	hide('nail');
    hide('others'); 
	show(categoryName);
	changeTab(categoryName);
}
function createTab() {
	var left = document.getElementById("left");
	var design = document.getElementById("menu");
	var nav = document.createElement("ul");
	nav.setAttribute('id','nav');
	nav.appendChild(createListItem('eyelashNav','#eyelash','まつげ'));
	nav.appendChild(createListItem('nailNav','#nail','ネイル'));
	nav.appendChild(createListItem('othersNav','#others','その他'));
	left.insertBefore(nav,menu);
}
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('nav');
	e.className = categoryName;
}
