// 外部JSファイル呼び出し記述

// <script language="JavaScript" type="text/javascript" src="../includes/menu.js"></script>

// 

// ======================================================================= //

// 2004/02/12 初版

// 2004/03/08 選択されているメニューについて追加

// ======================================================================= //



	var preLoad_status = "false";



/* ----------------------------------------------------------------------- 

　概要　：画像の先読込処理

　呼出　：preLoad()

　引数　：なし

　戻り値：なし



　使用されている画像の名前を利用してファイル名を取得。

　画像名の最初が下記のもの（３つ）の場合

　tab1_* , tab2_* , menu_*

----------------------------------------------------------------------- */

function preLoad() {

	if(document.images){

		menu_on_Images  = new Array();

		menu_of_Images  = new Array();

		menu_ov_Images  = new Array();



	 	tmp_img_name = "";



		for(file_loop = 0; file_loop < document.images.length; file_loop ++){



			tmp_img_name = document.images[file_loop].name ;



			// alert(tmp_img_name)



			base_folder = "../header/img/";

			menu_on_Images[tmp_img_name] = new Image();

			menu_on_Images[tmp_img_name].src = base_folder + tmp_img_name + "_on.gif";

			menu_of_Images[tmp_img_name] = new Image();

			menu_of_Images[tmp_img_name].src = base_folder + tmp_img_name + "_of.gif";

			menu_ov_Images[tmp_img_name] = new Image();

			menu_ov_Images[tmp_img_name].src = base_folder + tmp_img_name + "_ov.gif";

			menu_vi_Images[tmp_img_name] = new Image();

			menu_vi_Images[tmp_img_name].src = base_folder + tmp_img_name + "_vi.gif";

			menu_ex_Images[tmp_img_name] = new Image();

			menu_ex_Images[tmp_img_name].src = base_folder + tmp_img_name + "_ex.gif";

			menu_pr_Images[tmp_img_name] = new Image();

			menu_pr_Images[tmp_img_name].src = base_folder + tmp_img_name + "_pr.gif";

			menu_ne_Images[tmp_img_name] = new Image();

			menu_ne_Images[tmp_img_name].src = base_folder + tmp_img_name + "_ne.gif";

		}



		preLoad_status = "true";

	}

}





/* ----------------------------------------------------------------------------------------------------

　概要　：メニュー画像の変更

　呼出　：change(image_Name, image_status)

　引数　：image_Name 　= 変更するＩＭＧタグの名前 = 画像のファイル名（on,off）の前まで

　　　　　image_status = on か of 空白

　戻り値：なし



　使用例(初期値onのもの) ⇒ onMouseOut なし

　<img src="tab1_exh_on.gif" name="tab1_exh">



　使用例(通常)

　<a href="#" onMouseOver="change('tab1_exh','on');" onMouseOut="change('tab1_exh','of')">

　<img src="tab1_exh_of.gif" name="tab1_exh" border="0">

　</a>

---------------------------------------------------------------------------------------------------- */



/* ----- ヘッダー専用 ----- */

function change(image_Name, image_status) {





	if(preLoad_status == "true"){

		if(image_status=="on"){

			document.images[image_Name].src = menu_on_Images[image_Name].src;

		}

		else if(image_status=="of"){

			document.images[image_Name].src = menu_of_Images[image_Name].src;

		}

		else if(image_status=="ov"){

			document.images[image_Name].src = menu_ov_Images[image_Name].src;

		}

	}else{

		base_folder = "../header/img/";

		if(image_status==""){

			document.images[image_Name].src = base_folder + image_Name + ".gif";

		}else{

			document.images[image_Name].src = base_folder + image_Name + "_" + image_status + ".gif";

		}

	}

}





/* ----- 各ディレクトリ直下のimg用 ----- */

function change_each(image_Name, image_status) {



	base_folder = "./img/";

	if(image_status==""){

		document.images[image_Name].src = base_folder + image_Name + ".gif";

	}else{

		document.images[image_Name].src = base_folder + image_Name + "_" + image_status + ".gif";

	}

}



/* ----------------------------------------------------------------------------------------------------

　概要　：リロード時に再読込をする　NN4への対応

　呼出　：resize()

　引数　：なし

　戻り値：なし



　<body onResize="resize();">

---------------------------------------------------------------------------------------------------- */



function resize(e){

	if (document.layers) {window.location.reload();}

}



/* ----------------------------------------------------------------------------------------------------

　概要　：画像の変更

　呼出　：change(image_Name, image_status)

　引数　：image_Name 　= 変更するＩＭＧタグの名前 = 画像のファイル名（on,off）の前まで

　　　　　image_status = on か of 空白

　戻り値：なし



　使用例(初期値onのもの) ⇒ onMouseOut なし

　<img src="tab1_exh_on.gif" name="tab1_exh">



　使用例(通常)

　<a href="#" onMouseOver="change('tab1_exh','on');" onMouseOut="change('tab1_exh','of')">

　<img src="tab1_exh_of.gif" name="tab1_exh" border="0">

　</a>

---------------------------------------------------------------------------------------------------- */



function btchange(image_Name, image_status) {



	base_folder = "./img/";

	if(image_status==""){

		document.images[image_Name].src = base_folder + image_Name + ".gif";

	}else{

		document.images[image_Name].src = base_folder + image_Name + "_" + image_status + ".gif";

	}

}



/* ----------------------------------------------------------------------------------------------------

　概要　：画像の変更

　呼出　：change(image_Name, image_status)

　引数　：image_Name 　= 変更するＩＭＧタグの名前 = 画像のファイル名（on,off）の前まで

　　　　　image_status = on か of 空白

　戻り値：なし



　使用例(初期値onのもの) ⇒ onMouseOut なし

　<img src="tab1_exh_on.gif" name="tab1_exh">



　使用例(通常)

　<a href="#" onMouseOver="change('tab1_exh','on');" onMouseOut="change('tab1_exh','of')">

　<img src="tab1_exh_of.gif" name="tab1_exh" border="0">

　</a>

---------------------------------------------------------------------------------------------------- */



function btplchange(image_Name, image_status, image_place) {



	base_folder = "./img/";

	if(image_status==""){

		document.images[image_place].src = base_folder + image_Name + ".gif";

	}else{

		document.images[image_place].src = base_folder + image_Name + "_" + image_status + ".gif";

	}

}



// ================================================================================================== //

// 　以下のfunctionは不要（上記functionひとつで対応）

// ================================================================================================== //





/* ----------------------------------------------------------------------------------------------------

　概要　：無線スポットの説明windowをOPEN

　呼出　：

　引数　：

　戻り値：

---------------------------------------------------------------------------------------------------- */

   function musen_spot(){ w = window.open("http://www.ceatec.com/ja/2005/visitors/musen_spot.html","popAc","directories=0,location=0,menubar=0,scrollbars=1,toolbar=1,resizable=1,top=20,left=20,width=680,height=570"); w.focus();

   }





//Countdown function at the header



//// Functions for outputting blocks of html

function eventinfo(){

	document.write("<td><img src='../header/img/ceatec_count_name.gif' width='176' height='12' alt='CEATEC JAPAN 2005'><br><img src='../header/img/ceatec_count_date.gif' width='189' height='20' alt='10/4→10/8 幕张会展中心'></td>");

}

function startingsoon() {

	document.write("<td align='right'><div style='background: #002A6A;margin-left: 3px;'><img src='../header/img/ceatec_count_mamonaku.gif' width='44' height='32' alt='明天开幕'></div></td>");

}

function inprogress(){

	document.write("<td align='right'><div style='background: #002A6A;margin-left: 3px;'><img src='../header/img/ceatec_count_kaisaichuu.gif' width='44' height='32' alt='展出中'></div></td>");

}

function countbox(strPicture1, strPicture2){

	document.write("<td align='right'><div style='background: #002A6A;margin-left: 3px;'><img src='../header/img/ceatec_count_001.gif' width='44' height='11' alt='离开幕还有'><br><img src='"+ strPicture1 + "' width='15' height='21'><img src='"+ strPicture2 + "' width='15' height='21'><img src='../header/img/ceatec_count_002.gif' width='11' height='21' alt='日'></div></td>");

}



// main function

function countdown(){

	//変数宣言

	var dtToday = new Date();



	//記念日をいれてください。

	//注意：月は０からスタートしているのに注意。(10月5日は2004,9,05)

	var dtCeatecOpen = new Date(2005,9,4);

	var dtCeatecClose = new Date(2005,9,8);



	//計算結果を表示していきます。

	var days = (dtCeatecOpen.getTime() - dtToday.getTime())/(24*60*60*1000);

	var close_days = (dtCeatecClose.getTime() - dtToday.getTime())/(24*60*60*1000);

	

	//残りの日数。最も近くて大きい整数を返す、Math.ceil()

        var nokori = Math.ceil(days) // nokori is the number of days till start of conference

        var nokori2 = Math.ceil(close_days) // this is number of days until end of conference

        //alert(nokori)



	//０から９までの画像を用意してください。

	//画像のURLを宣言します。

	var strPicture = new Array(

		"../header/img/ceatec_count_0.gif",

		"../header/img/ceatec_count_1.gif",

		"../header/img/ceatec_count_2.gif",

		"../header/img/ceatec_count_3.gif",

		"../header/img/ceatec_count_4.gif",

		"../header/img/ceatec_count_5.gif",

		"../header/img/ceatec_count_6.gif",

		"../header/img/ceatec_count_7.gif",

		"../header/img/ceatec_count_8.gif",

		"../header/img/ceatec_count_9.gif");



	//2桁に揃えておく

	if (nokori > 0 ){

		if (nokori < 10)

		{

			nokori = "0" + nokori;

		}else{

	                nokori = "" + nokori;

		}



		//数字に画像を当てるための準備です。

		var imgDate;

		imgDate= nokori.toString();



		//ここから表示

		if (nokori == 1 && dtToday.getHours() >= 18){ // One day away and after 18:00

			startingsoon();

			eventinfo();

		} else { // More than one day before the event

			countbox(strPicture[nokori.substring(0,1)], strPicture[nokori.substring(1,2)]);

			eventinfo();

		}



	}else{

		//ここから表示

		if(nokori2 >= 0){

			//台風情報			

			//通常会期中

			if (nokori == 0 && dtToday.getHours() < 10){ // Hasn't started yet

				startingsoon();

				eventinfo();

			} else if (nokori2 == 0 && dtToday.getHours() >= 17) {

				document.write("<td align='right'>");

				document.write("<img src='../header/img/spacer.gif' alt='' width='1' height='1'></td>");
				eventinfo();

			} else { // event in progress

				inprogress();

				eventinfo();

			}



		}else{

			if(nokori2 < 0){

				document.write("<td align='right'>");

				document.write("<img src='../header/img/spacer.gif' alt='' width='1' height='1'></td>");
				eventinfo();
			}

		}

	}

	    return;

}
