// myscript.js
// $Id: gakutou.js 1.7 2000/01/13 09:05:10 takamoto Exp takamoto $

function browserNote() {
	var aname = navigator.appName;
	var uagent = navigator.userAgent;
	var osName = navigator.platform.substr(0, 3);	// Windowsなら'Win'
	
	document.writeln('<hr>');
	document.writeln('<table border=0 width=80% align=right>');
	document.writeln('<tr valign=top><td>');
	document.write('<a href="http://www.microsoft.com/windows/ie_intl/ja/default.htm"><img alt="Microsoft Internet Explorer" src="img/ie.gif" width=88 height=31 hspace=14 vspace=4 border=0></a>');
	document.writeln('</td><td>');
	document.write('<p class=small>このページは <span class=word>Windows</span>版の <a href="http://www.microsoft.com/windows/ie_intl/ja/default.htm"><span class=word>Microsoft Internet Explorer</span></a> 5 でごらんくださるのが最適です。');
	document.write('お使いのブラウザーは“<span class=word>', aname, '―', uagent, '</span>”のようです');
	if (uagent.indexOf('MSIE 5') >= 0) {
		if (osName == 'Win') {
			document.write('ので、これなら安心です。');
		} else {
			document.write('が、<span class=word>Windows</span>版ではないようですので、レイアウトなどで多少見づらいところがあるかもしれません。ご了承下さい。');
		}
	} else {
		document.write('ので、レイアウトなどで多少見づらいところがあるかもしれません。ご了承下さい。');
	}
	document.writeln('</p>');
	document.writeln('</td><td><img alt="" src="img/strut.gif" width=40 height=1 border=0></td>');
	document.writeln('</tr></table><br clear=all>');
}

// 引数に img までのルートを記述する（例: signature('../');）
function signature(pathRoute) {
	update = new Date(document.lastModified);
	theMonth = update.getMonth() + 1;
	theDate = update.getDate();
	theYear = update.getFullYear();
//	theYear = update.getYear();
//	if (theYear < 1900) {
//		theYear += 1900;
//	}
	theHours = update.getHours();
	if (theHours < 10) {
		theHours = "0" + theHours;
	}
	theMinutes = update.getMinutes();
	if (theMinutes < 10) {
		theMinutes = "0" + theMinutes;
	}
	theSeconds = update.getSeconds();
	if (theSeconds < 10) {
		theSeconds = "0" + theSeconds;
	}
	
	document.writeln('<hr>');
	document.writeln('<table border=0 align=right>');
	document.writeln('<tr valign=bottom>');
	document.writeln('<td><img alt="" src="', pathRoute, 'img/ball.gif" width=52 height=35></td>');
	document.writeln('<td><table border=0><tr valign=baseline>');
	document.writeln('<td nowrap>作成：</td>');
	document.write('<td nowrap> <ruby><rb><a href="mailto:takamoto@juen.ac.jp">');
	document.write('高本條治</a></rb><rp>（</rp><rt>たかもとじょうじ</rt>');
	document.write('<rp>）</rp></ruby> （<a href="mailto:takamoto@juen.ac.jp">');
	document.writeln('takamoto@juen.ac.jp</a>）</td></tr>');
	document.writeln('<tr><td nowrap>更新：</td>');
	document.writeln('<td nowrap>', theYear, '年', theMonth, '月', theDate, '日（',theHours, ':', theMinutes, ':', theSeconds,  '）</td></tr>');
	document.writeln('</table></td>');
	document.writeln('<td nowrap>　　　　　</td>');
	document.writeln('</tr></table><br clear=all>');
}

var imageDir = "img/";
var loadList;
var action = "off";

function preLoad() {
	loadList = new Array(
		"ball-1.gif","ball-2.gif"
	);
	onImages = new Array();
	for (field in loadList) {
		onImages[field] = new Image();
		onImages[field].src = imageDir + loadList[field];
	}
	action = "on";
}

function changeImage(fileName,imageName) {
	if(action == "on") {
		document.images[imageName].src =  imageDir + fileName;
	}
}

function reminder() {
	document.write('<img src="http://www.kokemus.kokugo.juen.ac.jp/cgi-bin/Count.cgi?df=gakutou.dat|sh=0" alt="" width=0 height=0 border=0>');
}

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

var maxMenu = 5;	// メニューの選択肢数

selectMenu = new makeArray(maxMenu+1);
selectMenu[1] = "文章を作るための情報収集法";
selectMenu[2] = "ハイパーテキストの整理法";
selectMenu[3] = "電子メディアによる情報発信法";
selectMenu[4] = "『國文學』2000年2月臨時号";
selectMenu[5] = "サポートページのトップ"; 

// URLの記述は「gakutou/」を基準
urlMenu = new makeArray(maxMenu+1);
urlMenu[1] = "support/shushu/index.html";
urlMenu[2] = "support/seiri/index.html";
urlMenu[3] = "support/hasshin/index.html";
urlMenu[4] = "gakutou.html";
urlMenu[5] = "index.html";

function selectJump(theSelection, pathRoute) {
	var selected = theSelection.selectedIndex;
	window.open(pathRoute + theSelection.options[selected].value, "_top");
}

// 引数に img までのルートを記述する（例: jumpMenuGuide('../');）
// 引数が空文字列の場合だけ、最初に水平線を引く
function jumpMenuGuide(pathRoute) {
	var topPageUrl = "index.html";
	var i;
	if (pathRoute == '') {
		document.writeln('<hr>');
	}
	document.writeln('<div align=center style="text-align: center;">');
	document.writeln('<table border=0>');
	document.writeln('<tr valign=top align=center>');
	document.writeln('<td>');
	document.write('<a href="JavaScript: history.back()" ');
	document.write('onMouseOver="window.status=', "'履歴の前のページに戻ります'", '; return true;" ');
	document.write('onMouseOut="window.status=', "''", '; return true;">');
	document.write('<img alt="前に戻る" src="', pathRoute, 'img/left.gif" width=24 height=24 border=0 hspace=20>');
	document.writeln('<br>前に戻る</a>');
	document.writeln('</td>');
	document.writeln('<td>');
	document.write('<a href="', pathRoute, topPageUrl, '" target="_top" ');
	document.write('onMouseOver="window.status=', "'トップのページに戻ります'", '; return true;" ');
	document.write('onMouseOut="window.status=', "''", '; return true;">');
	document.write('<img alt="トップへ" src="', pathRoute, 'img/up.gif" width=24 height=24 border=0 hspace=20>');
	document.writeln('<br>トップへ</a>');
	document.writeln('</td>');
	document.writeln('<td nowrap>');
	document.writeln('<form name="jumpForm">');
	document.writeln('<select name="jumpSelect">');
	for (i = 1; i <= maxMenu; i++) {
		document.writeln('<option value="', urlMenu[i], '">', selectMenu[i], '</option>');
	}
	document.writeln('</select>のページへ');
	document.writeln('</form>');
	document.writeln('</td>');
	document.writeln('<td align=left>');
	document.write('<a href="JavaScript: selectJump(this.jumpForm.jumpSelect, ', "'", pathRoute, "'", ')"');
	document.write('onMouseOver="window.status=', "'左側のメニューで選択したページにジャンプします'", '; return true;" ');
	document.write('onMouseOut="window.status=', "''", '; return true;">');
	document.write('<img alt="ジャンプ" src="', pathRoute, 'img/right.gif" width=24 height=24 border=0 hspace=10>');
	document.writeln('<br>ジャンプ</a>');
	document.writeln('</td>');
	document.writeln('</tr>');
	document.writeln('</table>');
	document.writeln('</div>');
}

function mainSectionJump(theSelection) {
	var selected = theSelection.selectedIndex;
	if (selected > 0) {
		parent.main.location.href=theSelection.options[selected].value;
	}
}

function findKeyword(word) {
	var matchNum = 0;
	if (word == '') {
		alert('検索文字列が指定されていません。');
		return;
	}
	tags = parent.main.document.body.all.tags("p");
	var re = new RegExp("(" + word + ")", "gi");
	for (i = 0; i < tags.length; i++) {
		text = tags[i].innerHTML;
		if (text.match(re)) {
			if (matchNum < 1) {
				tags[i].scrollIntoView();
			}
			matchNum++;
		}
		newtext = text.replace(re, "<span style='background: yellow'>$1</span>");
		tags[i].innerHTML = newtext;
	}
	if (matchNum < 1) {
		alert('「' + word + '」は見つかりませんでした。');
	} else {
		alert('「' + word + '」を含む段落が ' + matchNum + ' 個あります。');
	}
}

// <a href="URL" target="notes">〜</a>の代わりに
// <a href="JavaScript: jumpNotes('URL')">〜</a>と使う
function jumpNotes(url) {
	window.open(url, "notes");
}

// マーククリアボタン用
function reloadMain() {
	window.open(parent.main.location.toString(), "main");
}
