window.onload = function(){
	createTab();
	hideHeading();
	showCategory('about');
	setTabClick('aboutNav','about');
	setTabClick('activityNav','activity');
	setTabClick('newsNav','news');
};

function hide(elementId) {
	document.getElementById(elementId).style.display = "none";
}
function show(elementId) {
	document.getElementById(elementId).style.display = "block";
}
function hideHeading() {
	hide('aboutHeading');
	hide('activityHeading');
	hide('newsHeading');
}
function showCategory(categoryName){
	hide('about'); 
	hide('activity'); 
	hide('news'); 
	show(categoryName);
	changeTab(categoryName);
}
function createTab() {
	var wrapper = document.getElementById("wrapper");
	var content = document.getElementById("content");
	var nav = document.createElement("ul");
	nav.setAttribute('id','nav');
	nav.appendChild(createListItem('aboutNav','#about','home'));
	nav.appendChild(createListItem('activityNav','#activity','Movies for experiment'));
	nav.appendChild(createListItem('newsNav','#news','Podcast for iPod'));	
	wrapper.insertBefore(nav,content);
}
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;
}