// トップスコア用メソッド ==============================================
function score_make(json_obj) {
	// 必要な情報

	var game_date = json_obj.Tabletennis[0].GameInfo[0].GameDate;
	var game_date_MM = parseInt(game_date.substring(4, 6));
	var game_date_DD = parseInt(game_date.substring(6, 8));
	var category = json_obj.Tabletennis[0].Category;
	
	// 書き出す HTML

	var out_html = '<div class="dataContents">' + "\n";

	out_html += '<div class="tableTitle tableTitleWttc">' + "\n";
	out_html += '<h3 title="今日の試合">今日の試合</h3>' + "\n";
	out_html += '<p>[ <a href="/sports/wttc/2009/score/top-score.html" title="スコア速報へ">スコア速報</a> ]</p>' + "\n";
	out_html += '</div>' + "\n";

	// ヘッダ
	out_html += '<table border="1" summary="世界卓球スコア">' + "\n";

	out_html += '<tr>' + "\n";
	out_html += '<th scope="col" class="bg game" abbr="種目">種目</th>' + "\n";
	out_html += '<th scope="col" class="phase" abbr="フェーズ">フェーズ</th>' + "\n";
	out_html += '<th scope="col" class="player1" abbr="選手">選手名（国）</th>' + "\n";
	out_html += '<th scope="col" class="score" abbr="スコア">スコア</th>' + "\n";
	out_html += '<th scope="col" class="player2" abbr="選手">選手名（国）</th>' + "\n";
	out_html += '</tr>' + "\n";

	var gamecount=0;

	for (var j = 0; j < json_obj.Tabletennis.length; j++) {
		var category = json_obj.Tabletennis[j].Category;
		var phase = json_obj.Tabletennis[j].Phase;

		// 試合分を繰り返す
		for (var i = 0; i < json_obj.Tabletennis[j].GameInfo.length; i++) {
			var game_info = json_obj.Tabletennis[j].GameInfo[i];

			if(game_info.Set == '開始前'){
				continue;
			}
			

			// 試合情報 チーム＆スコア
			
			out_html += '<tr>' + "\n";
			out_html += '<td scope="row" class="line game">' + category + '</td>' + "\n";
			out_html += '<td scope="row" class="phase">' + phase + '</td>' + "\n";

			if((category == '男子シングルス')||(category == '女子シングルス')){

				out_html += '<td scope="row" class="player1">' + game_info.HomeInfo.TeamName + '（' + game_info.HomeInfo.Block + '）</td>' + "\n";
				out_html += '<td scope="row" class="score">' + game_info.HomeInfo.Score + '−' + game_info.VisitorInfo.Score + '</td>' + "\n";
				out_html += '<td scope="row" class="player2">' + game_info.VisitorInfo.TeamName + '（' + game_info.VisitorInfo.Block + '）</td>' + "\n";

			}
			else{
				out_html += '<td scope="row" class="player1">' + game_info.HomeInfo.TeamName + '、' + game_info.HomeInfo.TeamName2 + '（' + game_info.HomeInfo.Block + '）</td>' + "\n";
				out_html += '<td scope="row" class="score">' + game_info.HomeInfo.Score + '−' + game_info.VisitorInfo.Score + '</td>' + "\n";
				out_html += '<td scope="row" class="player2">' + game_info.VisitorInfo.TeamName + '、' + game_info.VisitorInfo.TeamName2 + '（' + game_info.VisitorInfo.Block + '）</td>' + "\n";
			}

			out_html += '</tr>' + "\n";
			gamecount++;
			
		}
	
	}
	out_html += '</table>' + "\n";
	
	// 表示

	
	
	if(gamecount > 0){
		document.getElementById("todayGameBox").innerHTML = out_html;
	}
}

// メイン ==============================================

// 卓球トップ用
var ttObj = new Object;
ttObj = eval("(" + resultText + ")");
if(ttObj.Tabletennis){
	score_make(ttObj);
}




