/*-----------------------------------------------------
フレームの色を変えて、スクリーンにhtmlを表示し、
コンボボックスの内容を変更する関数
  引数
  ・category:選択されたカテゴリ
-----------------------------------------------------*/

function change_frame_color(category)
{
	var category_path; /* 選択されたカテゴリのパス */
	var color;	/* フレームの色 */
	var now_list_html;	/* 現在のリストHTML */

	switch (category) 
	{
		case "info":
			color = "#ff3300";
			break;
		case "cg":
			color = "#02026f";
			break;
		case "midi":
			color = "#006600";
			break;
		case "other":
			color = "#990066";
			break;
		case "link":
			color = "#cc6600";
			break;
		default:
			alert("Error! change_frame_color");
			break;
	}


	category_path =  "./" + category + "/";

	window.parent.document.all.body.style.borderColor = color;

	/* タグ切り替え関数の呼び出し */
	if(change_tag(category) != true){alert("change_tag error!");}


	now_list_html = window.parent.document.all.layer.innerHTML

	/* 現在表示されているリストと表示内容があっているか判定 */
	if(now_list_html.indexOf("/" + category + "/") == -1)
	{
		window.parent.document.all.layer.innerHTML = make_list_html(category);
	}
}

/*--------------------------------
背景画像をランダムに変更する関数
--------------------------------*/

function change_backimage()
{
	var image_data;	/* 背景画像のURL */
	var C_max_number = 5; /* 背景画像番号の最大値 */
	var random_number; /* ランダムな数字 */

	/* 1 〜 C_max_numberまでのランダムな数字を取得する */
	random_number = Math.ceil(Math.random() * C_max_number);

	/* 頭0埋めで画像番号を2桁に編集する */
	random_number = "00" + random_number
	random_number = random_number.substr(random_number.length - 2,2)

	/* 画像番号によって表示方法を変える */
	switch(random_number){
	case "02":
		document.all.tags("body")(0).style.backgroundRepeat = "repeat-y";
		document.all.tags("body")(0).style.backgroundPositionX = "2%";
		document.all.tags("body")(0).style.backgroundColor = "#87CEEB"
		break;

	case "03":
		document.all.tags("body")(0).style.backgroundRepeat = "repeat-y";
		document.all.tags("body")(0).style.backgroundPositionX = "85%";
		document.all.tags("body")(0).style.backgroundColor = "#F5F5DC"
		break;

	case "05":
		document.all.tags("body")(0).style.backgroundRepeat = "repeat-x";
		document.all.tags("body")(0).style.backgroundPositionY = "120px"
		document.all.tags("body")(0).style.backgroundColor = "#FFEFD5"
		break;

	case "99":
		document.all.tags("body")(0).style.backgroundRepeat = "no-repeat";
		document.all.tags("body")(0).style.backgroundColor = "#FFFFFF"
		break;

	case "99":
		document.all.tags("body")(0).style.backgroundRepeat = "repeat-x";
		document.all.tags("body")(0).style.backgroundColor = "#FFFFFF"
		break;

	default:
		document.all.tags("body")(0).style.backgroundRepeat = "repeat";
		document.all.tags("body")(0).style.backgroundColor = "#FFFFFF"
		break;
	}

	image_data = "http://www.trapezium.homeip.net/~utaken/data/back" + random_number + ".jpg";

/* ---for Test---					*/
/*	image_data = "./data/back" + "05" + ".jpg";	
	alert(image_data);				*/

	document.all.tags("body")(0).style.backgroundImage = "url(" + image_data + ")";
}


/*----------------------------------------
タグ部分の画像（on,off）を切り替える関数
----------------------------------------*/

function change_tag(category)
{
	var img_name; /* タグ画像の名前 */

	for(i = 0;i < window.parent.document.all.tags("img").length;i++)
	{
		img_name = window.parent.document.all.tags("img")(i).src
		if(window.parent.document.all.tags("img")(i).id == category)
		{
		/* 選択されたカテゴリの場合 */
			window.parent.document.all.tags("img")(i).src = img_name.replace("_off","_on");
		}
		else
		{
		/* 選択されたカテゴリではない場合 */
			window.parent.document.all.tags("img")(i).src = img_name.replace("_on","_off");
		}
	}

	return(true);

}


/*--------------------------------------------------------
コンボボックスの変更により、スクリーンにhtmlを表示する関数
  引数
  ・category:選択されたカテゴリ
--------------------------------------------------------*/

function disp_screen()
{
	var option_index;	/* 選択されたリスト番号 */

	option_index = window.document.list.slist.selectedIndex;
	html = window.document.list.slist.options[option_index].value;

/* ---for Test---	*/
/*	alert(html);	*/

	if(html != "")
	{
		window.open(html,"screen","scrollbar=no");
	}
}


/*----------------------------------------
リスト用のHTML文を作成して返す関数
  [引数]
　・category:選択されたカテゴリ
　
　[戻り値]
　・list_html:リスト部分のHTML
----------------------------------------*/

function make_list_html(category)
{
	var list_html;			/* リスト用html文 */
	var category_path; 		/* 選択されたカテゴリのパス */
	tmp_list = new Array();		/* リストの文字列と値を格納する配列 */
	list_value = new Array(2);	/* 添字[0]は作品タイトル、添字[1]は選択時表示ファイル */


/* リストの項目追加はここで行う	*/
/* 設定する値はカンマ区切りで	*/
/* [表示文字列],[表示ファイル]	*/

	switch(category)
	{
		case "info":
/*			tmp_list[2] = "about [T],[T].htm";
			tmp_list[1] = "about creation,creation.htm"; */
			tmp_list[1] = "about [T],[T].htm";
			tmp_list[0] = "about utaken,utaken.htm";
			break;

		case "cg":
			tmp_list[35] = "道,cg36.htm";
			tmp_list[34] = "2004年賀状,cg35.htm";
			tmp_list[33] = "鉄塔,cg34.htm";
			tmp_list[32] = "渇き,cg33.htm";
			tmp_list[31] = "2002年賀状,cg32.htm";
			tmp_list[30] = "2001残暑見舞い,cg31.htm,";
			tmp_list[29] = "怪獣,cg30.htm";
			tmp_list[28] = "2001年賀状,cg29.htm";
			tmp_list[27] = "心臓,cg28.htm";
			tmp_list[26] = "sneer,cg27.htm";
			tmp_list[25] = "おやじ（洋）,cg26.htm";
			tmp_list[24] = "１６２cm,cg25.htm";
			tmp_list[23] = "きたかぜ,cg24.htm";
			tmp_list[22] = "たいよう,cg23.htm";
			tmp_list[21] = "自画像(2000/04/16),cg22.htm";
			tmp_list[20] = "狼,cg21.htm";
			tmp_list[19] = "ウサギ,cg20.htm";
			tmp_list[18] = "2000年賀状,cg19.htm";
			tmp_list[17] = "光線,cg18.htm";
			tmp_list[16] = "女性２,cg17.htm";
			tmp_list[15] = "影の精霊,cg16.htm";
			tmp_list[14] = "Ｈｅａｄ,cg15.htm";
			tmp_list[13] = "China Kiss,cg14.htm";
			tmp_list[12] = "赤い情欲,cg13.htm";
			tmp_list[11] = "カレー,cg12.htm";
			tmp_list[10] = "骸骨,cg11.htm";
			tmp_list[9] = "ナルシスト,cg10.htm";
			tmp_list[8] = "1999暑中見舞い,cg09.htm";
			tmp_list[7] = "ギター,cg08.htm";
			tmp_list[6] = "Hの肖像,cg07.htm";
			tmp_list[5] = "Yの肖像,cg06.htm";
			tmp_list[4] = "ギタリスト,cg05.htm";
			tmp_list[3] = "春,cg04.htm";
			tmp_list[2] = "女性,cg03.htm";
			tmp_list[1] = "1999年賀状,cg02.htm";
			tmp_list[0] = "FACE,cg01.htm";
			break;

		case "midi":
/*			tmp_list[9] = "季節,midi10.htm"; */
			tmp_list[8] = "space inhavitant,midi09.htm";
			tmp_list[7] = "Metro,midi08.htm";
			tmp_list[6] = "綿毛の冒険,midi07.htm";
			tmp_list[5] = "森の微笑,midi06.htm";
			tmp_list[4] = "誕生日,midi05.htm";
			tmp_list[3] = "歌と共に…,midi04.htm";
			tmp_list[2] = "成人,midi03.htm";
			tmp_list[1] = "要塞攻略,midi02.htm";
			tmp_list[0] = "ナーガ,midi01.htm";
			break;

		case "other":
			tmp_list[4] = "今自分,imajibun/ima.htm";
			tmp_list[3] = "幻想列車,gensou/gensou.htm";
			tmp_list[2] = "SHADOW OF FAITH,sof/sof.htm";
			tmp_list[1] = "家計簿[T],money/money.htm";
			tmp_list[0] = "present from friends,thanks/thanks.htm";
			break;

		case "link":
			tmp_list[4] = "create,create.htm";
			tmp_list[3] = "diary,diary.htm";
			tmp_list[2] = "community,community.htm";
			tmp_list[1] = "useful,useful.htm";
			tmp_list[0] = "rest,rest.htm";
			break;

		default:
			alert("make_list_html error!");
	}

	category_path =  "./" + category + "/";

	list_html = "\n<form name=\"list\">\n"
	list_html = list_html + "<select name=\"slist\" onChange=\"disp_screen()\">\n"
	list_html = list_html + "<option value=\"" + category_path + "start.htm\">" + category + "</option>\n"
	list_html = list_html + "<option>--------------------</option>\n"

	for(i = tmp_list.length - 1; i >= 0 ; i--)
	{
		list_value = tmp_list[i].split(",",2)
		list_html = list_html + "<option value=\"" + category_path + list_value[1] + "\">" + list_value[0] + "</option>\n"
	}

	list_html = list_html + "</select>\n"
	list_html = list_html + "</form>\n"

	return(list_html);

}

/*----------------------------------------
エレメントを拡大してから消す関数
  [引数]
　・element:選択されたカテゴリ
----------------------------------------*/

function puff_element(element)
{
	new Effect.Puff(element);
}


