/*
 * Popup Hint v 0.1 - JavaScript
 * Copyright (C) 2001 Seiichi Yamazaki. All rights reserved.
 * URI : http://www3.freeweb.ne.jp/play/ymchn/
 */



/*
 * 項目変更時は、左右の : や ; を削除しないように注意してください。
 * また、指定部分の左右が ' ' で囲まれている場合、これらの ' ' を
 * 削除しないでください。
 */

/*
 * 表示する文字列と、その文字列に対応する ID の組です。
 * Popup Hint でどのメッセージを表示するか指定するとき、この ID を
 * 使用します。
 *       'ID',
 *       	'文字列',
 * の順に書きます。なお、最終項目の文字列の後ろには , をつけないで下さい。
 * HTML タグを使用できますが、' を使用する場合は \' に置き換えてください。
 */
var msgs = new Array (
	'welcome',
		'私のホームページへようこそ !',
	'board',
		'掲示板です。<BR>どんどん<BIG>書き込んで〜</BIG>。',
	'diary',
		'日記です。<BR><STRONG>普段の生活</STRONG>を書いてます。',
	'links',
		'リンク集です。<BR>また来てね〜。'
);

/*
 * フェードインの速度 [%/160ms]
 * ポップアップは徐々に表示されますが、その表示速度を
 * 指定します。単位は 「0.16 秒あたりのパーセント濃度の変化」
 * (まるで化学だ (^^;)) です。
 */
once = 4;

/*
 * ポップアップ表示の不透明度 [%]
 * フェードイン終了後のポップアップ表示の濃度を指定します。
 * 100% にすると不透過になります。単位はパーセントです。
 */
maxdepth = 80;



/*
 * 以下は、JavaScript についての知識をお持ちの方のみ変更してください。
 */
var DIV = false, LAYER = false, initfilter = false;
var fp = null;
init ();

function popup (msgid) {

	if (!initfilter && DIV) {
		document.all.popupdiv.style.filter = 'Alpha("Opacity=0")';
		initfilter = true;
	}

	// Debug
	var ForceMsgShow = false;

	// Debug : ForceMsgShow
	if (ForceMsgShow) {
		var tmpr = '';
		for (i = 0; i < msgs.length; i += 2) {
			tmpr += (msgs[i] + '\n\t' + msgs[i + 1] + '\n');
		}
		alert (tmpr);
		return false;
	}

	var msg = '';

	for (i = 0; i < msgs.length; i += 2) {
		if (msgs[i] == msgid) {
			msg = msgs[i + 1];
			break;
		}
	}

	if (msg == '') {
		msg = msgid;
	}

	if (DIV) {
		with (document.all.popupdiv) {
			innerHTML = msg;
			style.posLeft = document.body.scrollLeft + window.event.x + 10;
			style.posTop = document.body.scrollTop + window.event.y + 10;
			style.visibility = 'visible';
		}
	}
	/*
	else if (LAYER) {
		document.popupdiv.write (msg);
		document.popupdiv.close ();
		document.popupdiv.pageX = e.pageX;
		document.popupdiv.pageY = e.pageY;
	}
	*/

	if (DIV) setTimeout ('fadepopup ()', 1);

	return false;

}

function fadepopup () {

	var alp = document.all.popupdiv.filters['Alpha'];
	alp.Opacity += once;
	
	fp = setTimeout ('fadepopup ()', 16);
	if (alp.Opacity >= maxdepth) {
		clearTimeout (fp);
		alp.Opacity = maxdepth;
	}

	return true;

}

function popupdel () {

	if (!DIV) return false;

	if (fp != null) {
		clearTimeout (fp);
	}
	document.all.popupdiv.filters['Alpha'].Opacity = 0;
	document.all.popupdiv.style.visibility = 'hidden';

	return false;

}

function init () {

	if (document.all) {
		DIV = true;
	}
	else if (document.layers) {
		/*
		LAYER = true;
		document.popupdiv.captureEvents (Event.MOUSEOVER | Event.MOUSEOUT);
		document.popupdiv.document.onMouseOver = popup;
		document.popupdiv.document.onMouseOut = popupdel;status=2;
		*/
	}

	return true;

}
