/* フレームが用意されていない場合の設定 */
if(parent.location.href == location.href){
	lf = location.href;
	cap = "";
	if(lf.indexOf("/zaurus/") != -1 || lf.indexOf("/test/") != -1 || lf.indexOf("/shopping/") != -1 || lf.indexOf("/point/") != -1){
		cap = "../";
	}
	while(lf.indexOf("/") != -1){
		lf = lf.replace("/","<>");
	}
	location.href = cap + "index.htm" + "?" + lf;
}

// ドキュメント関連のプログラム
document.open();


/*
	文字列から指定部分を抽出するプログラム
	
	引数	gc2_s	切り取り開始文字列
			gc2_e	切り取り終了文字列
			gc2		切り取り対象文字列
	
	返り値	gc2_s と gc2_e の間にはさまれた文字列
*/
function getCut2(gc2_s, gc2_e, gc2){
	gc2_i = gc2.indexOf(gc2_s);
	gc2_j = gc2.indexOf(gc2_e, gc2_i+gc2_s.length);
	return gc2.substring(gc2_i+gc2_s.length, gc2_j);
}


/*
	文字列にリンクを貼り付けるプログラム
	l_opt は拡張用引数
	[]指定でフルタイトル、[[]]指定で入力文字列が挿入される
*/
function l(l_src,l_opt){
	l_book = parent.topFrame.document.manager.autolink.value;
	output = "";
	
	while(l_src.indexOf("[[") != -1){
		word = getCut2("[[","]]",l_src);
		l_color = "c-blue";
		
		if(l_book.indexOf(word) != -1){
			output_tag = word;
			output_i = l_book.indexOf(word+"　");
			if(word.indexOf(".htm")!=-1){
				output_i = l_book.indexOf(word);
			}
			output_j = l_book.indexOf(",",output_i);
			output_k = l_book.lastIndexOf("　",output_j);
			output_link = l_book.substring(output_k+1, output_j);
		} else {
			output_tag = word;
			if(word.indexOf("http") == -1){
				output_link = "error.html";
				l_color = "c-red";
			} else {
				output_link = word;
			}
		}
		
		if(l_opt.indexOf("-gray") != -1) l_color = "c-gray";
		
		if(output_link.indexOf(".htm") != -1 || output_link.indexOf("/") != -1){
			if(l_opt.indexOf("-gray") != -1) l_color = "c-gray";
			if(output_link.indexOf(".htm") != -1 && output_link.indexOf("http") == -1){
				output = "<a href='" + output_link + "' target='mainFrame' id='" + l_color + "'>" + output_tag + "</a>";
			} else {
				output = "<a href='" + output_link + "' target='_blank' id='" + l_color + "'>" + output_tag + "</a>";
			}
		} else {
			if(output_link.indexOf("(small)") == -1){
				output = "<span style='background-color:" + output_link + "; color:white;'><b>" + output_tag + "</b></span>";
			} else {
				output_link = output_link.replace("(small)", "");
				output = "<small><span style='background-color:" + output_link + "; color:white;'>" + output_tag + "</span></small>";
			}
		}
		
		l_src = l_src.replace("[["+word+"]]", output);
	}


	while(l_src.indexOf("[") != -1){
		word = getCut2("[","]",l_src);
		l_color = "c-blue";
		
		if(l_book.indexOf(word) != -1){
			output_i = l_book.indexOf(word+"　");
			if(word.indexOf(".htm")!=-1){
				output_i = l_book.indexOf(word);
			}
			output_j = l_book.lastIndexOf(",",output_i);
			output_k = l_book.indexOf("　",output_j);
			output_tag = l_book.substring(output_j+1, output_k);

			output_j = l_book.indexOf(",",output_i);
			output_k = l_book.lastIndexOf("　",output_j);
			output_link = l_book.substring(output_k+1, output_j);
		} else {
			output_tag = word;
			if(word.indexOf("http") == -1){
				output_link = "error.html";
				l_color = "c-red";
			} else {
				output_link = word;
			}
		}
		
		if(output_link.indexOf(".htm") != -1 || output_link.indexOf("/") != -1){
			if(l_opt.indexOf("-gray") != -1) l_color = "c-gray";
			if(output_link.indexOf(".htm") != -1 && output_link.indexOf("http") == -1){
				output = "<a href='" + output_link + "' target='mainFrame' id='" + l_color + "'>" + output_tag + "</a>";
			} else {
				output = "<a href='" + output_link + "' target='_blank' id='" + l_color + "'>" + output_tag + "</a>";
			}
		} else {
			if(output_link.indexOf("(small)") == -1){
				output = "<span style='background-color:" + output_link + "; color:white;'><b>" + output_tag + "</b></span>";
			} else {
				output_link = output_link.replace("(small)", "");
				output = "<small><span style='background-color:" + output_link + "; color:white;'>" + output_tag + "</span></small>";
			}
		}
		
		l_src = l_src.replace("["+word+"]", output);
	}
	
	if(l_opt.indexOf("-pt") != -1){
		p_title = l_src;
	} else if(l_opt.indexOf("-href") != -1){
		p_title = output_link;
	} else {
		document.write(l_src);
	}
}


/* 参照ジャンプ（未実装） */
function refer(ref, word){
	l(word,"-lk");
	parent.document.manager.refer.value = ref;
	location.href = p_title; // p_title にジャンプ
}


/* 時間変数定義関数 */
function define_clock(){
	year = parent.topFrame.document.manager.time_year.value - 0;	/* 年 */
	month = parent.topFrame.document.manager.time_month.value - 0;	/* 月 */
	date = parent.topFrame.document.manager.time_date.value - 0;	/* 日 */
	day = parent.topFrame.document.manager.time_day.value - 0;		/* 曜日 */
	hour = parent.topFrame.document.manager.time_hour.value - 0;	/* 時 */
	min = parent.topFrame.document.manager.time_min.value - 0;		/* 分 */
	sec = parent.topFrame.document.manager.time_sec.value - 0;		/* 秒 */
}


/* 参照ジャンプ先処理（未実装） */
// refer が用語をストックしている場合
if(parent.topFrame.document.manager.refer.value != ""){
	refer = parent.topFrame.document.manager.refer.value;
	document.write("<font color='gray'>＜ [" + refer + "] ＞から転送</font><br><br>");// 灰色で「＜[<<refer>>]＞から転送」と表示
	parent.topFrame.document.manager.refer.value = ""; // refer の値をクリアする
}


/* account manager */
if(parent.topFrame.document.manager.id_code.value.indexOf("-ht") != -1){
	parent.document.title = "Administrator < " + parent.topFrame.document.manager.id_user.value + " >";
} else {
	if(parent.topFrame.document.title == parent.mainFrame.document.title){
		parent.document.title = parent.mainFrame.document.title;
	} else {
		parent.document.title = parent.topFrame.document.title + "『" + parent.mainFrame.document.title + "』";
	}
}


/* メンテナンス実施時は次の行を有効にしてください */
//document.write('<p align=\"center\"><b><font color="red">サイトメンテナンス中</font></b></p><br><br>');


/* リナックス環境でなければ画像を表示するスクリプト */
function judge_linux(fname){
	if(navigator.platform != "Linux"){
		document.write('<img src="' + fname + '">');
	}
}


/* テストページの明記 */
if(location.pathname.indexOf("_test.htm")!=-1) document.write("<br><br><font color='red'><p align='center'>このページは試験用に作成されたものです。</p></font><br><br>");


/* リンクカラー設定 */
document.write('<STYLE type="text/css">#c-green { color: green }</STYLE>');
document.write('<STYLE type="text/css">#c-gray { color: gray }</STYLE>');
document.write('<STYLE type="text/css">#c-red { color: red }</STYLE>');
document.write('<STYLE type="text/css">#c-blue { color: blue }</STYLE>');


/* fontサイズの設定 */
document.write('<STYLE type="text/css">body { font-size:smaller;');
document.write('background-color: #9dd8ea; }');
document.write('</STYLE>');


/* あなたのメモリーに関するボタンのページ内貼り付け */
if(location.href.indexOf("index_") == -1){
	document.write("<small><a href='javascript:insert_your_memory()'>あなたのメモリーに追加</a></small><br><br>");
}


/* ドキュメント編集用設定 */
document.write("<span id='body_part'>");
