window.onload = function fncOnLoad(){
	try{
		
		//***********************************************
		// Print処理
		//***********************************************
		if(document.location.search.indexOf("?print=yes") != -1){
			try{
				var objLink = document.getElementsByTagName("link");
				for(var i = 0; objLink.length; i++){
					if(objLink[i].title){
						if(objLink[i].title == "screen"){
							objLink[i].disabled = true;
						}
						if(objLink[i].title == "print"){
							objLink[i].disabled = false;
						}
					}
				}
			}catch(e){
			}
			window.print();
			window.close();
		}

		// JSONからデータを取得
		var r = eval(resource);
		var s = eval(start);
		var g = eval(gnavi);
		var t = eval(toc);

		// 変数定義
		var strFirstChapterName		= "";
		var strTopBottomLink		= "";

		//***********************************************
		// CopyRightとマニュアルタイトルの取得処理
		//***********************************************
		for(var i = 0; i < r.length; i++){
			if(document.getElementById("id_res_" + r[i].id)){
				document.getElementById("id_res_" + r[i].id).innerHTML = r[i].value;
			}
			if(!document.body.id){
				if(r[i].id == "title"){
					document.title = r[i].value;
				}
			}else{
				document.title = document.body.id;
			}			
		}

		//***********************************************
		// 「Home」表示処理
		//***********************************************
		if(document.getElementById("id_header_buttons")){
		
			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; j++){

						if(s[i].child[j].id == "001"){
							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);
							}
							document.getElementById("id_header_buttons").appendChild(objButton);
						}
					}
				}
			}
		}

		//***********************************************
		// OnLoadCateGoryを取得
		//***********************************************

		for(var n = 0; n < g.length; n++){

			var objCategoryButton = document.createElement("button");
			objCategoryButton.innerHTML = g[n].name;
			objCategoryButton.className = "normal";

			objCategoryButton.onmouseover = function(){
				this.className = "over";
			}

			objCategoryButton.onmouseout = function(){
				this.className = "normal";
			}

			//***********************************************
			// ★カテゴリの選択処理
			//***********************************************
			objCategoryButton.onclick = function(){
				//if(this.innerText == "Technology"){
				if(this.innerText == g[0].name){
					for(var k = 0; k < t.length; k++){
						if(t[k].chapter == g[0].child[0].id && t[k].href != ''){
							location.href = "../contents/" + t[k].href;
							break;
						}
					}
				//}else if(this.innerText == "Service"){
				}else if(this.innerText == g[1].name){
					for(var k = 0; k < t.length; k++){
						if(t[k].chapter == g[1].child[0].id && t[k].href != ''){
							location.href = "../contents/" + t[k].href;
							break;
						}
					}
				//}else if(this.innerText == "Appendix"){
				}else if(this.innerText == g[2].name){
					for(var k = 0; k < t.length; k++){
						if(t[k].chapter == g[2].child[0].id && t[k].href != ''){
							location.href = "../contents/" + t[k].href;
							break;
						}
					}
				}
			}
			
			if(document.getElementById("id_category_show")){
				document.getElementById("id_category_show").appendChild(objCategoryButton);
			}
		}

		for(var i = 0; i < s.length; i++){

			if(s[i].type == "top_img"){
				for(var j = 0; j < s[i].child.length; j++){
					if(document.getElementById("id_top_img")){
						document.getElementById("id_top_img").innerHTML = "<img src=\"" + s[i].child[j].href + "\">";
					}
				}
			}

			//***********************************************
			// Referenceページの表示処理
			//***********************************************
			if(s[i].type == "reference"){
				for(var j = 0; j < s[i].child.length; j++){

					var objButton = document.createElement("div");
					objButton.innerHTML = s[i].child[j].title;
					objButton.className = "normal";
					objButton.src = "column_topic_button";
					objButton.href = s[i].child[j].href;

					if(document.body.id == s[i].child[j].src){
						objButton.className = "normal";
					}
					
					objButton.onmouseover = function(){
						this.style.backgroundImage = "Url(\"../frame_images/" + this.src + "_over.gif\")";
					}
					objButton.onmouseout = function(){
						this.style.backgroundImage = "Url(\"../frame_images/" + this.src + "_out.gif\")";
					}

					// sitemapと履歴一覧の場合
					if(s[i].child[j].id == "004"){
						objButton.onclick = function(){
							window.open(this.href);
						}
					}else{

						objButton.onclick = function(){
							document.location.href = this.href;
						}
					}

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

		//***********************************************
		// MouseOver処理
		//***********************************************
		
		// 「検索」入力フォーム
		document.getElementById("id_search").onmouseover = function(){
			this.style.backgroundImage = "Url(\"../frame_images/header_search_background_over.gif\")";
		}
		document.getElementById("id_search").onmouseout = function(){
			this.style.backgroundImage = "Url(\"../frame_images/header_search_background_out.gif\")";
		}

		//***********************************************
		// 「How to use」、「Read me」
		// id_content_mainの幅と高さ計算
		//***********************************************
		if(document.getElementById("id_content_main")){
			document.getElementById("id_content_main").style.height = document.body.clientHeight - 172;
			document.getElementById("id_content_main").style.width = document.body.clientWidth - 333;
		}
		if(document.getElementById("id_content")){
			document.getElementById("id_content").style.width = document.body.clientWidth - 333;
		}
	}catch(e){
	}
}

function fncMouseOver(eSrc){
	if(eSrc.className == "normal"){
		eSrc.className = "over";
	}
}	
function fncMouseOut(eSrc){
	if(eSrc.className == "over"){
		eSrc.className = "normal";
	}
}

function fncOnclick(){
	var href = "history.xls";
	window.open(href,"History_xls","directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=yes,width=1000,height=700,left=100,top=10");
}

window.onresize = fncOnResize;
function fncOnResize(){
	try{

		var obj = window;
		if(window.opera){
			var w = obj.innerWidth;
			var h = obj.innerHeight;
		}else if(document.all){
			var w = obj.document.body.clientWidth;
			var h = obj.document.body.clientHeight;
		}else if(document.getElementById){
			var w = obj.innerWidth;
			var h = obj.innerHeight;
		}
		if(document.location.search.indexOf("?print=yes") == -1){
			document.getElementById("id_content").style.height = h - 72 + "px";
			document.getElementById("id_content").style.width = w - 300 + "px";
		}
	}catch(e){
	}
}
window.onbeforeprint = function fncResizeForPrint(){
	try{
		if(document.getElementById("id_content")){
			document.getElementById("id_content").style.width = "100%";
		}
	}catch(e){
	}
}
window.onafterprint = function fncResizeForScreen(){
	try{
		var obj = window;
		if(window.opera){
			var w = obj.innerWidth;
			var h = obj.innerHeight;
		}else if(document.all){
			var w = obj.document.body.clientWidth;
			var h = obj.document.body.clientHeight;
		}else if(document.getElementById){
			var w = obj.innerWidth;
			var h = obj.innerHeight;
		}
		
		if(document.getElementById("id_content")){
			document.getElementById("id_content").style.height = h - 72 + "px";
			document.getElementById("id_content").style.width = w - 300 + "px";
		}
	}catch(e){
	}
}

function fncPrint(){
	try{
		window.open(document.location.href + "?print=yes");
	}catch(e){
		if(e.description){
			alert(e.description);
		}else{
			alert(e);
		}
	}
}
