dbData = new MakeArray(3);

function MakeArray(n)
{
	this.length = n;
	for (var i = 1; i <= n; i++) this[i] = 0;
	return this;
}

function dbName(title, tail, keywords)
{
	this.title    = title;
	this.tail     = tail;
	this.keywords = keywords;
}

function check(){
	if (event.keyCode == 13) keyword_search();
}

function clearAll(entry) {
	document.searchform.keyword.value = entry;
	document.searchform.keyword.focus();
}

function keyword_search() {
	var entry_org = document.searchform.keyword.value;
	var entry = document.searchform.keyword.value.toLowerCase();
	var found = 0;
	var result = "";

	if (entry == "") {
		alert(strKeywordEmpty);
		clearAll(entry_org);
		document.searchform.keyword.focus();
	}
	else
	{
		for (var file = 0; file < 3; ++file)
		{
			for (var i = 0; i < dbData[file].length; i++)
			{
				var lengthA  = dbData[file][i].keywords.length;
				var lengthB  = entry.length;
				var thisData = dbData[file][i].keywords;
				for (var j = 0; j <= lengthA; j++) {
					if (entry == thisData.substring(j, j + lengthB))
					{
						++found;
						encoded = entry;
						result += '<ol start="' + found + '">\n<li class="found"><a href="javascript:openDocs(\'';
						result += dbData[file][i].title + "', '" + encoded + "', '" + encoded;
						result += '\');">' + dbData[file][i].tail;
						result += '</li>\n</ol>\n<div><img src="../img/search_line.gif" width="100%" height="9"></div>\n';
						break;
					}
				}
			}
		}
		if (found != 0)
		{
			resultMsg = '<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n<meta http-equiv="Content-Style-Type" content="text/css">\n<meta http-equiv="Content-Script-Type" content="text/javascript">\n<script language="javascript" type="text/javascript" src="../js/head.js"></script>\n<script language="javascript" type="text/javascript">function openDocs(pagename, search, mySearch){var url = "index.html?page=" + pagename + ".html";url = url + "&search=" + search + "&mySearch=" + mySearch;var iwidth = screen.availWidth;var iheight = screen.availHeight;var X = 0;var Y = 0;var W = 800;var H = iheight - 88;if (H >760 ) H=760;var style = "top="+Y+",left="+X+",screenX="+X+",screenY="+Y+",toolbar=1,scrollbars=1,menubar=1,resizable=1,width="+W+",height="+H;w = window.open(url,"star",style);}</script>\n<link rel="stylesheet" type="text/css" href="../css/search.css">\n<title>' + strSearchResult + '</title>\n</head>\n<body>\n<table width="100%" height="30" border="0" cellpadding="0" cellspacing="0">\n<tr>\n<td height="30" background="../img/bg04.gif">&nbsp;</td>\n<td width="196" height="30" background="../img/bg04.gif"><img src="../img/search_top.gif" width="212" height="30" alt="' + strSearchResult +'"></td>\n<td height="30" align="left" valign="middle" background="../img/bg04.gif">&nbsp;</td>\n</tr>\n</table>\n<div class="results">\n';
			resultMsg += result + "</div>\n</body>\n</html>";
			result_window = window.open('', 'result_window', 'width=450,height=500,directories=0,location=0,menubar=0,scrollbars=1,status=1,toolbar=0,resizable=1');
			result_window.document.open();
			result_window.document.write(resultMsg);
			result_window.document.close();
			result_window.focus();
		}
		else
		{
			alert(strNotFound)
			clearAll(entry);
			document.searchform.keyword.focus();
		}
	}
	return(0);
}
function openSitemap()
{
	sitemap_window = window.open('../sitemap.html', 'sitemap_window', 'width=800,directories=0,location=0,menubar=0,scrollbars=1,status=0,toolbar=0,resizable=1');
	sitemap_window.focus();
}

function switchMain()
{
	if (parent.location.href.indexOf('?page') != -1)
	{
		strLocation = parent.location.href;
		strLocation = strLocation.substr(strLocation.indexOf('?page') + 6, strLocation.length);
		if (strLocation.indexOf('&search') != -1)
		{
			strLocation = strLocation.substr(0, strLocation.indexOf('&search')) + "?" + strLocation.substr(strLocation.indexOf('&search') + 1, strLocation.length);
		}
		parent.main.location.href = strLocation;
	}
}
