window.onload = function fncOnLoad(){
	try{
		var g = eval(gnavi);
		var e = eval(toc);
		var s = eval(start);

		// 「ホーム」表示処理
		for(var i = 0; i < s.length; i++){
			if(s[i].type == "header"){
				for(var j = 0; j < s[i].child.length-1; j++){
					var objButton = document.createElement("button");
					objButton.innerHTML = s[i].child[j].title;
					objButton.className = "normal";
					objButton.href = s[i].child[j].href;
					objButton.onmouseover = function(){
						this.className = "over";
					}
					objButton.onmouseout = function(){
						this.className = "normal";
					}
					objButton.onclick = function(){
						document.location.href(this.href);
					}

					if(document.getElementById("id_header_buttons")){
						document.getElementById("id_header_buttons").appendChild(objButton);
					}
				}
			}
		}

		for(var m = 0; m < g.length; m++){			
			var objTd					= document.createElement("td");
			objTd.innerText				= g[m].name;
			objTd.className				= "contents";
			objTd.style.width			= (100/g.length)+"%";
			objTd.id					= g[m].type;
			if(m == g.length-1){
				objTd.style.borderRight = "None";
			}
			document.getElementById("id_contents").appendChild(objTd);

			for(var k = 0; k < g[m].child.length; k++){

				var objDivCh			= document.createElement("div");
				objDivCh.innerText		= g[m].child[k].id;
				objDivCh.className		= "ChContents";
				document.getElementById("id_contents").childNodes[m].appendChild(objDivCh);

				for(var i = 0; i < e.length; i++){
					
					if(e[i].chapter == g[m].child[k].id){
						var objDivMo			= document.createElement("div");

						if(e[i].level == "1"){
							objDivMo.className	= "level1";
						}else if(e[i].level == "2"){
							objDivMo.className	= "level2";
						}else if(e[i].level == "3"){
							objDivMo.className	= "level3";
						}else if(e[i].level == "4"){
							objDivMo.className	= "level4";
						}else if(e[i].level == "5"){
							objDivMo.className	= "level5";
						}
						
						if(e[i].href){
							objDivMo.innerHTML		= "<span style='cursor:Hand;' onclick='fncOnclick(this)' id='" + e[i].id + "' href='" + e[i].href + "'>" + h(e[i].node_name) + "</span>";
						}else{
							//objDivMo.innerHTML		= "<span style='color:#808080;'>" + e[i].title + "</span>";
							objDivMo.innerHTML		= "<span style='color:#000000;'>" + h(e[i].node_name) + "</span>";
						}

						document.getElementById("id_contents").childNodes[m].appendChild(objDivMo);
					}
				}

			}
		}
	}catch(e){
		if(e.description){
			alert(e.description);
		}else{
			alert(e);
		}
	}
}

function fncOnclick(eSrc){

	if(eSrc.parentNode.id == "id_header"){
		location.href = eSrc.href;
	}else if(eSrc.parentNode.className.indexOf("level") != "-1"){
		location.href = "../contents/" + eSrc.href;
	}
	
}
function fncOnmouseover(eSrc){
	eSrc.className = "over";
}
function fncOnmouseout(eSrc){
	eSrc.className = "normal";
}