window.onload = function(){
	createTab();
	hideHeading();
	showCategory('process');
	setTabClick('processNav','process');
	setTabClick('standardNav','standard');
	setTabClick('fixNav','fix');
	setTabClick('qaNav','qa');
};

function hide(elementId) {
	document.getElementById(elementId).style.display = "none";
}
function show(elementId) {
	document.getElementById(elementId).style.display = "block";
}
function hideHeading() {
	hide('processHeading');
	hide('standardHeading');
	hide('fixHeading');
	hide('qaHeading');
}
function showCategory(categoryName){
	hide('process'); 
	hide('standard'); 
	hide('fix'); 
	hide('qa'); 
	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('processNav','#process',''));
	nav.appendChild(createListItem('standardNav','#standard',''));
	nav.appendChild(createListItem('fixNav','#fix',''));	
	nav.appendChild(createListItem('qaNav','#qa',''));	
	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;
}
