// 初期化＆定義

new_infoColorAry = new Array();
new_infoJigyouAry = new Array();
new_infoNewAry = new Array();
new_infoDateAry = new Array();
new_infoTitleAry = new Array();
new_infoLinkAry = new Array();


new_videoAry = new Array();
new_widthAry = new Array();
new_heightAry = new Array();


var jigyou_spsubsidy		= 1;
var jigyou_spaward			= 2;
var jigyou_spresearch		= 3;
var jigyou_sptraining		= 4;
var jigyou_sporganization	= 5;
var jigyou_itsubsidy		= 6;
var jigyou_itaward			= 7;
var jigyou_cartoonist		= 8;
var jigyou_digitalgame		= 9;
var jigyou_venture			= 10;
var jigyou_itedutainment	= 11;
var jigyou_scholarship		= 12;
var jigyou_itequipment		= 13;
var jigyou_seminarroom		= 14;
var jigyou_other			= 15;

var nendo_2002				= 16;
var nendo_2003				= 17;
var nendo_2004				= 18;
var nendo_2005				= 19;
var nendo_2006				= 20;
var nendo_2007				= 21;
var nendo_2008				= 22;
var nendo_2009				= 23;
var nendo_2010				= 24;
var nendo_2011				= 25;

/* 更新部分 ここから */


// index用の最新動画ファイルデータ

// 最新動画ファイル名をここに入力
new_videoStr = '20111217_hyosyo_jtta.wmv';
// 上記のファイルの横幅を入力
new_widthNum = 480;
// 同じく縦幅を入力
new_heightNum = 270;


// 情報部分
// かならず1セットで増減させてください
// 上のセットが上に表示されます

// 事業の色対応表から色を指定（緑:g 赤:r 青:b）
// 事業名
// newマーク
// 日付
// タイトル
// リンク先

new_infoColorAry.push('b');
new_infoJigyouAry.push('感謝状');
new_infoNewAry.push(false);
new_infoDateAry.push('2011.12.17');
new_infoTitleAry.push('財団法人 日本卓球協会から感謝状を授与');
new_infoLinkAry.push('./other.html?name=20111217_hyosyo_jtta.wmv&width=480&height=270');

new_infoColorAry.push('b');
new_infoJigyouAry.push('スポーツ選手支援事業 / 上月スポーツ賞');
new_infoNewAry.push(false);
new_infoDateAry.push('2011.09.13');
new_infoTitleAry.push('2011年度「上月スポーツ選手支援事業」認定式 並びに「上月スポーツ賞」表彰式');
new_infoLinkAry.push('./spsubsidy.html?name=20110913_spsub_spawa.wmv&width=480&height=270');

new_infoColorAry.push('r');
new_infoJigyouAry.push('漫画家・アニメーター育成事業');
new_infoNewAry.push(false);
new_infoDateAry.push('2011.07.06');
new_infoTitleAry.push('第8回「漫画家・アニメーター育成事業」二次審査会');
new_infoLinkAry.push('./cartoonist.html?name=20110706_cartoonist.wmv&width=480&height=270');

// new_infoColorAry.push('b');
// new_infoJigyouAry.push('スポーツ功労団体表彰');
// new_infoNewAry.push(false);
// new_infoDateAry.push('2010.11.01');
// new_infoTitleAry.push('文部科学省「スポーツ功労者顕彰・国際競技大会優秀者等表彰及びスポーツ功労団体表彰」で表彰');
// new_infoLinkAry.push('./other.html?name=20101101_hyosyo_mext.wmv&width=480&height=270');

// new_infoColorAry.push('b');
// new_infoJigyouAry.push('スポーツ選手支援事業 / 上月スポーツ賞');
// new_infoNewAry.push(false);
// new_infoDateAry.push('2010.09.14');
// new_infoTitleAry.push('2010年度「上月スポーツ選手支援事業」認定式 並びに「上月スポーツ賞」表彰式');
// new_infoLinkAry.push('./spsubsidy.html?name=20100914_spsub_spawa.wmv&width=480&height=270');

// new_infoColorAry.push('r');
// new_infoJigyouAry.push('ベンチャービジネス支援事業');
// new_infoNewAry.push(false);
// new_infoDateAry.push('2010.09.08');
// new_infoTitleAry.push('第12回「ベンチャービジネス支援事業」選考発表大会');
// new_infoLinkAry.push('./other.html?name=20100908_venture.wmv&width=480&height=270');

// new_infoColorAry.push('r');
// new_infoJigyouAry.push('漫画家育成事業');
// new_infoNewAry.push(false);
// new_infoDateAry.push('2010.06.30');
// new_infoTitleAry.push('第7回「漫画家育成事業」二次審査会');
// new_infoLinkAry.push('./cartoonist.html?name=20100630_cartoonist.wmv&width=480&height=270');

// new_infoColorAry.push('r');
// new_infoJigyouAry.push('デジタルゲームクリエイター育成事業');
// new_infoNewAry.push(false);
// new_infoDateAry.push('2008.07.08');
// new_infoTitleAry.push('第6回「デジタルゲームクリエイター育成事業」認定式');
// new_infoLinkAry.push('./other.html?name=20080708_digitalgame.wmv&width=480&height=360');


// 各事業の最新ムービー
// 法則に従って増減させてください

// ファイル名、幅、高さ


// スポーツ選手支援事業
new_videoAry[jigyou_spsubsidy] = '20110913_spsub_spawa.wmv';
new_widthAry[jigyou_spsubsidy] = 480;
new_heightAry[jigyou_spsubsidy] = 270;

// 上月スポーツ賞
new_videoAry[jigyou_spaward] = '20110913_spsub_spawa.wmv';
new_widthAry[jigyou_spaward] = 480;
new_heightAry[jigyou_spaward] = 270;

// スポーツ団体・競技大会助成事業
new_videoAry[jigyou_sporganization] = '20060808_sporganization.wmv';
new_widthAry[jigyou_sporganization] = 480;
new_heightAry[jigyou_sporganization] = 360;

// スポーツトレーニング調査・研究事業
new_videoAry[jigyou_sptraining] = '20070327_sptraining.wmv';
new_widthAry[jigyou_sptraining] = 480;
new_heightAry[jigyou_sptraining] = 360;

// 漫画家・アニメーター育成事業
new_videoAry[jigyou_cartoonist] = '20110706_cartoonist.wmv';
new_widthAry[jigyou_cartoonist] = 480;
new_heightAry[jigyou_cartoonist] = 270;

// デジタルゲームクリエイター育成事業
// new_videoAry[jigyou_digitalgame] = '20080708_digitalgame.wmv';
// new_widthAry[jigyou_digitalgame] = 480;
// new_heightAry[jigyou_digitalgame] = 360;

// ベンチャービジネス支援事業
// new_videoAry[jigyou_venture] = '20100908_venture.wmv';
// new_widthAry[jigyou_venture] = 480;
// new_heightAry[jigyou_venture] = 270;

// 教育・文化振興助成事業
new_videoAry[jigyou_itequipment] = '20070209_foodforce.wmv';
new_widthAry[jigyou_itequipment] = 480;
new_heightAry[jigyou_itequipment] = 360;

// 上月情報教育賞
// new_videoAry[jigyou_itaward] = '20060806_itaward.wmv';
// new_widthAry[jigyou_itaward] = 480;
// new_heightAry[jigyou_itaward] = 360;

// その他
new_videoAry[jigyou_other] = '20111217_hyosyo_jtta.wmv';
new_widthAry[jigyou_other] = 480;
new_heightAry[jigyou_other] = 270;

// 2002年度
new_videoAry[nendo_2002] = '20021120_venture.rm';
new_widthAry[nendo_2002] = 320;
new_heightAry[nendo_2002] = 240;

// 2003年度
new_videoAry[nendo_2003] = '20040321_venture.wmv';
new_widthAry[nendo_2003] = 320;
new_heightAry[nendo_2003] = 240;

// 2004年度
new_videoAry[nendo_2004] = '20041126_venture.wmv';
new_widthAry[nendo_2004] = 320;
new_heightAry[nendo_2004] = 240;

// 2005年度
new_videoAry[nendo_2005] = '20060330_spaward.wmv';
new_widthAry[nendo_2005] = 480;
new_heightAry[nendo_2005] = 360;

// 2006年度
new_videoAry[nendo_2006] = '20070327_sptraining.wmv';
new_widthAry[nendo_2006] = 480;
new_heightAry[nendo_2006] = 360;

// 2007年度
new_videoAry[nendo_2007] = '20080331_spaward.wmv';
new_widthAry[nendo_2007] = 480;
new_heightAry[nendo_2007] = 360;

// 2008年度
new_videoAry[nendo_2008] = '20080910_venture.wmv';
new_widthAry[nendo_2008] = 480;
new_heightAry[nendo_2008] = 360;

// 2009年度
new_videoAry[nendo_2009] = '20090910_venture.wmv';
new_widthAry[nendo_2009] = 480;
new_heightAry[nendo_2009] = 270;

// 2010年度
new_videoAry[nendo_2010] = '20110214_info_05.wmv';
new_widthAry[nendo_2010] = 480;
new_heightAry[nendo_2010] = 270;

// 2011年度
new_videoAry[nendo_2011] = '20111217_hyosyo_jtta.wmv';
new_widthAry[nendo_2011] = 480;
new_heightAry[nendo_2011] = 270;


/* 更新部分 ここまで */

/*
new_heightNumPlus = (parseInt(new_heightNum) + 46);
tapAry = new_videoStr.split(".");
new_mediaStr = tapAry[1];
*/


/*	・最新情報書き出し関数					*
*											*
*	年度とかでページ分けると				*
*	複数更新する必要が出てくるので			*
*	その手間を極力最小限にしようと思ったり	*
*											*
*	その割には凄い力ずくなのは秘密。		*
*											*
*	更新方法								*
*	・下の部分をコピーして増やす			*/


function Vi_new(){
	var getStr = getQuery();
	heightNum = 0;
	widthNum = 0;
	if(getStr != null){
		if(getStr.indexOf("%26") != -1){
			var getStrAry = getStr.split("%26");
		}else{
			var getStrAry = getStr.split("&");
		}
		for(i=0;i<getStrAry.length;i++){
			var searchStr = getStrAry[i];
			if(searchStr.indexOf('width') == 0){
				var tapAry = searchStr.split("=");
				widthNum = tapAry[1];
			
			
			}else if(searchStr.indexOf('height') == 0){
				var tapAry = searchStr.split("=");
				heightNum = tapAry[1];
			}
		}
	}else{
		/* 最新動画ファイルの縦幅と横幅 */
		heightNum = new_heightNum;
		widthNum = new_widthNum;
	}
	spacerWidth = (760 - (parseInt(widthNum) + 95));
		//alert("spacerWidth="+spacerWidth);

	document.open();
	document.writeln('<td align="left" valign="top" height="'+heightNum+'">');
	document.writeln('<img src="images/spacer.gif" width="'+spacerWidth+'" height="1"><br>');
	document.writeln('<table border="0" cellpadding="0" cellspacing="4">');
		document.writeln('<tr>');
		document.writeln('<td align="left"><img src="images/vs_tit_eizo.gif" width="170" height="15"></td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('<td>&nbsp;</td>');
		document.writeln('</tr>');
	for(i=0;i<new_infoJigyouAry.length;i++){
		document.writeln('<tr>');
		document.writeln('<td><img src="images/vs_p_'+new_infoColorAry[i]+'.gif" width="10" height="10">　<span style="font-weight:bold">'+new_infoJigyouAry[i]+'</span></td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('<td>'+new_infoDateAry[i]+'');
		if(new_infoNewAry[i]){
			document.writeln('<img src="../img_fmt/new.gif" width="31" height="12">');
		}
		document.writeln('</td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('<td><a href="'+new_infoLinkAry[i]+'">'+new_infoTitleAry[i]+'</a></td>');
		document.writeln('</tr>');
		document.writeln('<tr>');
		document.writeln('<td>&nbsp;</td>');
		document.writeln('</tr>');
	}
	document.writeln('</table>');
	document.writeln('</td>');
	document.close();
}




/*	・ムービー書き出し関数					*
*	パラメータの数や種類がぜんぜん違うので	*
*	関数ごと分けてます						*
*											*
*	※Vi_movieより呼び出し					*
*											*
*	引数									*
*	name:ファイル名							*
*	width:幅								*
*	height:高さ								*
*	heightPlus:高さ+46						*/


function Vi_rm(name,width,height,heightPlus,startFlag){
	document.open();
	document.writeln('<object classid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" height="'+heightPlus+'" width="'+width+'">');
	document.writeln('<param name="SRC" value="movie/'+name+'">');
	document.writeln('<param name="AUTOSTART" value="'+startFlag+'">');
	document.writeln('<param name="CONTROLS" value="ImageWindow,ControlPanel">');
	document.writeln('<param name="CONSOLE" value="cons">');
	document.writeln('<param name="NOLOGO" value="true">');
	document.writeln('</object>');
	document.close();
}
function Vi_wmv(name,width,height,heightPlus,startFlag){
	document.open();
	document.writeln('<object id="MediaPlayer" width="'+width+'" height="'+heightPlus+'" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">');
	document.writeln('<param name="ShowStatusBar" value="false">');
	document.writeln('<param name="Volume" value="true">');
	document.writeln('<param name="ShowDisplay" value="false">');
	document.writeln('<param name="ShowControls" value="true">');
	document.writeln('<param name="ShowAudioControls" value="true">');
	document.writeln('<param name="TransparentAtStart" value="true">');
	document.writeln('<param name="ShowPositionControls" value="false">');
	document.writeln('<param name="AutoStart" value="'+startFlag+'">');
	document.writeln('<param name="FileName" value="movie/'+name+'">');
	document.writeln('<param name="NOLOGO" value="true">');
	document.writeln('<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" showcontrols="1" showdisplay="0" showstatusbar="0" width="'+width+'" height="'+heightPlus+'" autostart="'+startFlag+'" displaysize="1" filename="movie/'+name+'" src="movie/'+name+'" showvolumecontrols="1"></embed>');
	document.writeln('</object>');
	document.close();
}

/*	投げるデータ
*
*	name	ムービーのファイル名を入れる（拡張子ごと）
*	width	ムービーの幅を入れる
*	height	ムービーの高さを入れる
*
*	※どうやら高さはコントローラー含む高さのようなので注意
*
*	例：hoge.html?name=test.wmv&width=300&height=200
*
*/


/* GET取得関数 */
function getQuery(){
	var url = location.href;
	var urlAry = url.split("?");
	return urlAry[1];
}
/* Name取得関数 */
function getUrlName(){
	var url = location.href;
	var urlAry = url.split("/");
	urlAry.reverse();
	var urlAry2 = urlAry[0].split(".");
	return urlAry2[0];
}
/* ロード時にGET判断してムービー展開する関数 */
function Vi_load(){
	var getStr = getQuery();
	var nameStr = 0;
	var widthNum = 0;
	var heightNum = 0;
	var heightNumPlus = 0;
	var mediaStr = 0;
	var startFlag = true;
	if(getStr != null){
	//GETデータが存在した場合
		if(getStr.indexOf("%26") != -1){
			var getStrAry = getStr.split("%26");
		}else{
			var getStrAry = getStr.split("&");
		}
		for(j=0;j<getStrAry.length;j++){
			var searchStr = getStrAry[j];
			if(searchStr.indexOf('name') == 0){
				var tapAry = searchStr.split("=");
				nameStr = tapAry[1];
			}else if(searchStr.indexOf('width') == 0){
				var tapAry = searchStr.split("=");
				widthNum = tapAry[1];
			}else if(searchStr.indexOf('height') == 0){
				var tapAry = searchStr.split("=");
				heightNum = tapAry[1];
			}
		}
		var tapAry = nameStr.split(".");
		mediaStr = tapAry[1];
		heightNumPlus = (parseInt(heightNum) + 46);
		startFlag = true;
		/* 確認 
		alert("name="+nameStr);
		alert("width="+widthNum);
		alert("height="+heightNum);
		alert("media="+mediaStr);
		alert("heightNumPlus="+heightNumPlus);
		*/
		
		Vi_movie(nameStr,widthNum,heightNum,heightNumPlus,mediaStr,startFlag);
		
	}else{
		/*	最新版のデータを						*
		*	まずurlから自分自身のページをチェック	*/
		var myName = getUrlName();
		//alert("myName="+myName);
		
		// ページによって展開するものを変える
		
		// 年度トップ「nen_index」だけは特殊処理
		// 年度更新時にはこの部分を調整してください
		if(myName == 'nen_index'){
			new_videoStr = new_videoAry[nendo_2011];
			new_widthNum = new_widthAry[nendo_2011];
			new_heightNum = new_heightAry[nendo_2011];
		}else if(parseInt(myName) > 2000){
			new_videoStr = new_videoAry[eval('nendo_'+myName)];
			new_widthNum = new_widthAry[eval('nendo_'+myName)];
			new_heightNum = new_heightAry[eval('nendo_'+myName)];
		}else if(myName != 'index'){
			new_videoStr = new_videoAry[eval('jigyou_'+myName)];
			new_widthNum = new_widthAry[eval('jigyou_'+myName)];
			new_heightNum = new_heightAry[eval('jigyou_'+myName)];
		}
		
		// 値を整理
		new_heightNumPlus = (parseInt(new_heightNum) + 46);
		tapAry = new_videoStr.split(".");
		new_mediaStr = tapAry[1];
		
		// ムービーを呼ぶ
		Vi_movie(new_videoStr,new_widthNum,new_heightNum,new_heightNumPlus,new_mediaStr,startFlag);
	}
}



/*	・ムービー周辺の画像を出力する関数	*
*	480と320で別のページ作るのは		*
*	正直面倒だと思います。				*
*										*
*	※Vi_loadより呼び出し				*
*/



function Vi_movie(nameStr,widthNum,heightNum,heightNumPlus,mediaStr,startFlag){
	imgWidth = (parseInt(widthNum) + 40);
	document.open();
	document.writeln('<tr>');
	document.writeln('<td colspan="3"><img src="images/vs_main'+widthNum+'_01.gif" width="'+imgWidth+'" height="20"></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td width="20" background="images/vs_main'+widthNum+'_02.gif"><img src="images/spacer.gif" width="20" height="1"></td>');
	document.writeln('<td width="'+widthNum+'" background="images/vs_def_'+widthNum+''+heightNum+'.gif">');
	document.close();
	//
		// 規約を同意していたらムービーを出力する
	//	if(CheckCookie()){			
			if(mediaStr == 'rm'){
				Vi_rm(nameStr,widthNum,heightNum,heightNumPlus,startFlag);
			}else if(mediaStr == 'wmv'){
				Vi_wmv(nameStr,widthNum,heightNum,heightNumPlus,startFlag);
			}
	//	}
	//	else{
	//		Vi_first(widthNum,heightNumPlus);		// 同意を求める画面を出力
	//	}
	//
	document.open();
	document.writeln('</td>');
	document.writeln('<td width="20" background="images/vs_main'+widthNum+'_04.gif"><img src="images/spacer.gif" width="20" height="1"></td>');
	document.writeln('</tr>');
	document.writeln('<tr>');
	document.writeln('<td colspan="3"><img src="images/vs_main'+widthNum+'_05.gif" width="'+imgWidth+'" height="20"><br><div align="right"><a href="../news/readme.html#v_news">ご視聴についての注意事項</a></div></td>');
	document.writeln('</tr>');
	document.close();
}

/* クッキー判定 */
function CheckCookie(){
	num = GetCookie();
	if(num == ""){
		return false;
	}	
	else{
		return true;
	}
}

/* クッキーの取得 */
function GetCookie(tmp,pos1,pos2){
    tmp = " " + document.cookie + ";";
    pos1 = tmp.indexOf("=", 0);
    if(pos1 != -1){
		pos2 = tmp.indexOf(";",pos1);
		return((tmp.substring(pos1+1, pos2)));
    }
    else{
    	return("");
	}
}

/* クッキーの設定 */
function SetCookie(val, tmp) {
    tmp = "Count=" + escape(val) + "; ";
    document.cookie = tmp;
}

/* 同意した */
function AddCount(){
	SetCookie(1);
}


/*	・同意を求める画面を出力する関数		 *
*	width	ムービーの幅					 *
*	height	ムービーの高さ（※）			 *
*	※高さはコントローラー含む高さなので注意 *
*											 *
*	囲う画像を再利用するので、				 *
*	Vi_movie関数から呼び出します			 *
*											 *
*	※Vi_movieより呼び出し					 *
*/
function Vi_first(width,height){
	var url = location.href;
	var imgHeight;
	var btnSpace = 30;
	var topSpace;
	var bottomSpace;
	
	// 画像の大きさと、スペースの大きさを取得
	if(width == 320){
		imgHeight = 50;
		topSpace = 80;
	}
	
	else if(width == 480){
		imgHeight = 40;
		topSpace = 150;
	}
	bottomSpace = height - topSpace - imgHeight - btnSpace - 25 - 30;	// 下のスペースの高さを求める（25…同意するボタンの高さ, 30…規約文とボタンの間）
	
	document.open();
	document.writeln('<table border="0" cellpadding="0" cellspacing="0" background="images/vs_main'+width+'_03.gif" width="'+width+'" height="'+height+'">');
	document.writeln('<tr><td colspan="3"><img src="images/spacer.gif" width="1" height="'+topSpace+'"></td></tr>');
	document.writeln('<tr>');
	document.writeln('<td colspan="3"><img src="images/vs_main'+width+'_cau_txt.gif" border="0" width="'+width+'" height="');
	document.writeln(imgHeight+'" alt="当財団ホームページに掲載されている映像その他の情報を無断で複製、改変、転載等（リンクを含む）し、利用、使用することはお断り致します。"></td>');
	document.writeln('</tr>');
	document.writeln('<tr><td colspan="3"><img src="images/spacer.gif" width="1" height="30"></td></tr>');
	document.writeln('<tr>');
	document.writeln('<td align="right" valign="top"><a href="'+url+'" onClick="AddCount();" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'yes01\',\'\',\'images/vs_yes_o.gif\',1)" onFocus="this.blur()"><img name="yes01" border="0" src="images/vs_yes_d.gif" width="120" height="25" alt="同意する"></a></td>');
	document.writeln('<td align="center"><img src="images/spacer.gif" width="'+btnSpace+'"></td>');
	document.writeln('<td align="left" valign="top"><a href="../index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'no01\',\'\',\'images/vs_no_o.gif\',1)" onFocus="this.blur()"><img name="no01" border="0" src="images/vs_no_d.gif" width="120" height="25" alt="同意しない"></a></td>');
	document.writeln('</tr>');
	document.writeln('<tr><td colspan="3"><img src="images/spacer.gif" width="1" height="'+bottomSpace+'"></td></tr>');
	document.writeln('</table>');
	document.close();
}






