window.onload = function fncOnLoad(){
	try{
		var r = eval(resource);
		var s = eval(search);
		var t = eval(toc);

		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;
			}
		}
		with(window){
			moveTo(screen.width - 400, 0);
			resizeTo(400, screen.height - 32);
			self.focus();
		}
		var strConditions = document.location.search;
		strConditions = strConditions.substring(12);
		document.getElementById("id_search").value = decodeURI(strConditions);

		//***********************************************
		// 検索処理
		// 現状は、大文字小文字を区別して検索している
		//***********************************************
		var strSearchHtml = "";
		var arrConditions = "";
		var strCount = 0;

		// 検索キーワードにスペースがある場合、ANDで検索をかける
		arrConditions = strConditions.split("%20");

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

			for(var j = 0; j < arrConditions.length; j++){

				// エスケープされた文字のデコード
				var strSearchTargetText = htmlspecialchars_decode(s[i].body);
				if((strSearchTargetText.indexOf(arrConditions[j]) != "-1") && (arrConditions[j])){

					strSearchHtml = strSearchHtml + "<div class=\"topic_title\" id=\"" + s[i].toc_id + "\">";
		
					for(var k = 0; k < t.length; k++){
						if(t[k].id == s[i].toc_id){
							//strSearchHtml = strSearchHtml + "<img src=\"../contents/styles/style000/style_link_to_upper.gif\" style=\"padding-right:4px;\" /><a href=\"javascript:try{window.opener.document.location.href='../contents/" + t[k].href + "'}catch(e){};void(0);\">" + t[k].title + "</a>";
							strSearchHtml = strSearchHtml + "<a href=\"javascript:try{window.opener.document.location.href='../contents/" + t[k].href + "'}catch(e){};void(0);\">" + h(t[k].node_name) + "</a>";
						}
					}

					// 一致した文字列をハイライトにする
					// <>などの特殊文字が来た場合に正しく動かない2010/06/23
					// s[i].body = s[i].body.replace(arrConditions[j] , "<span class=\"hit\">" + arrConditions[j] + "</span>");

					strSearchHtml = strSearchHtml + "</div><div class=\"topic_summary\">" + s[i].body + "</div>";
				}
				
			}
		}

		document.getElementById("id_results").innerHTML = strSearchHtml;

		// 同じ結果が複数の場合、最後の結果だけ残る
		for(var i = 0; i < document.getElementById("id_results").all.tags("div").length; i++){
			if((document.getElementById("id_results").all.tags("div")[i].className == "topic_title")&&(document.getElementById("id_results").all.tags("div")[i+2])){
				if(document.getElementById("id_results").all.tags("div")[i].id == document.getElementById("id_results").all.tags("div")[i+2].id){
					document.getElementById("id_results").all.tags("div")[i].style.display = "none";
					document.getElementById("id_results").all.tags("div")[i+1].style.display = "none";

					strCount = strCount + 1;
				}
			}
		}

		document.getElementById("id_count").innerText = document.getElementById("id_results").all.tags("div").length / 2 - strCount;

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

function fncOnclick(eSrc){
	try{
	}catch(e){
		if(e.description){
			alert(e.description);
		}else{
			alert(e);
		}
	}
}

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;
		}
		document.getElementById("id_results").style.height = h - 75 + "px";
	}catch(e){
	}
}