// 男子スコア用メソッド ==============================================
function topScore_make_m(json_obj) {
	// 必要な情報
	var game_date = json_obj.Basketball[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 phase = json_obj.Basketball[0].Phase;

	// 書き出す HTML
	var out_html = '<h4>男子</h4>' + "\n" +
'<div class="tableTitle tableTitleP">' + "\n" +
'<h5>' + game_date_MM + '月' + game_date_DD + '日&nbsp;' + phase + '</h5>' + "\n" +
'</div>' + "\n" +
'<table border="1" summary="本日 男子の日程＆結果">' + "\n" +
'<tr>' + "\n" +
'<th scope="col" class="bg">出場校</th>' + "\n" +
'<th scope="col">スコア</th>' + "\n" +
'<th scope="col">出場校</th>' + "\n" +
'</tr>' + "\n";

	// 試合分を繰り返す
	for (var i = 0; i < json_obj.Basketball[0].GameInfo.length; i++) {
		// ホームチーム
		out_html += '<tr>' + "\n" +
'<td class="line school">' + json_obj.Basketball[0].GameInfo[i].HomeInfo.TeamName + '（' + json_obj.Basketball[0].GameInfo[i].HomeInfo.Block + '）</td>' + "\n";

		// スコア
		out_html += '<td class="score">(' + json_obj.Basketball[0].GameInfo[i].Quater + ')<br />';
		out_html += json_obj.Basketball[0].GameInfo[i].HomeInfo.Score + '-' + json_obj.Basketball[0].GameInfo[i].VisitorInfo.Score + '</td>' + "\n";

		// ビジターチーム
		out_html += '<td class="school">' + json_obj.Basketball[0].GameInfo[i].VisitorInfo.TeamName + '（' + json_obj.Basketball[0].GameInfo[i].VisitorInfo.Block + '）</td>' + "\n" +
'</tr>' + "\n";
	}

	// 閉じタグ
	out_html += '</table>' + "\n";
	
	if(json_obj.Basketball[1]){
	
// 決勝追加
		out_html += '<div class="tableTitle tableTitleP">' + "\n" +
'<h5>' + game_date_MM + '月' + game_date_DD + '日&nbsp;決勝</h5>' + "\n" +
'</div>' + "\n" +
'<table border="1" summary="本日 男子の日程＆結果">' + "\n" +
'<tr>' + "\n" +
'<th scope="col" class="bg">出場校</th>' + "\n" +
'<th scope="col">スコア</th>' + "\n" +
'<th scope="col">出場校</th>' + "\n" +
'</tr>' + "\n";
	
		for (var i = 0; i < json_obj.Basketball[1].GameInfo.length; i++) {
			// ホームチーム
			out_html += '<tr>' + "\n" +
	'<td class="line school">' + json_obj.Basketball[1].GameInfo[i].HomeInfo.TeamName + '（' + json_obj.Basketball[1].GameInfo[i].HomeInfo.Block + '）</td>' + "\n";
	
			// スコア
			out_html += '<td class="score">(' + json_obj.Basketball[1].GameInfo[i].Quater + ')<br />';
			out_html += json_obj.Basketball[1].GameInfo[i].HomeInfo.Score + '-' + json_obj.Basketball[1].GameInfo[i].VisitorInfo.Score + '</td>' + "\n";
	
			// ビジターチーム
			out_html += '<td class="school">' + json_obj.Basketball[1].GameInfo[i].VisitorInfo.TeamName + '（' + json_obj.Basketball[1].GameInfo[i].VisitorInfo.Block + '）</td>' + "\n" +
	'</tr>' + "\n";
		}
	
		// 閉じタグ
		out_html += '</table>' + "\n";
	}
	
	
	

	// 表示
	document.getElementById("bkm_today_games").innerHTML = out_html;
}


// 女子スコア用メソッド ==============================================
function topScore_make_w(json_obj) {
	// 必要な情報
	var game_date = json_obj.Basketball[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 phase = json_obj.Basketball[0].Phase;

	// 書き出す HTML
	var out_html = '<h4>女子</h4>' + "\n" +
'<div class="tableTitle tableTitleP">' + "\n" +
'<h5>' + game_date_MM + '月' + game_date_DD + '日&nbsp;' + phase + '</h5>' + "\n" +
'</div>' + "\n" +
'<table border="1" summary="本日 女子の日程＆結果">' + "\n" +
'<tr>' + "\n" +
'<th scope="col" class="bg">出場校</th>' + "\n" +
'<th scope="col">スコア</th>' + "\n" +
'<th scope="col">出場校</th>' + "\n" +
'</tr>' + "\n";

	// 試合分を繰り返す
	for (var i = 0; i < json_obj.Basketball[0].GameInfo.length; i++) {
		// ホームチーム
		out_html += '<tr>' + "\n" +
'<td class="line school">' + json_obj.Basketball[0].GameInfo[i].HomeInfo.TeamName + '（' + json_obj.Basketball[0].GameInfo[i].HomeInfo.Block + '）</td>' + "\n";

		// スコア
		out_html += '<td class="score">(' + json_obj.Basketball[0].GameInfo[i].Quater + ')<br />';
		out_html += json_obj.Basketball[0].GameInfo[i].HomeInfo.Score + '-' + json_obj.Basketball[0].GameInfo[i].VisitorInfo.Score + '</td>' + "\n";

		// ビジターチーム
		out_html += '<td class="school">' + json_obj.Basketball[0].GameInfo[i].VisitorInfo.TeamName + '（' + json_obj.Basketball[0].GameInfo[i].VisitorInfo.Block + '）</td>' + "\n" +
'</tr>' + "\n";
	}
	

	// 閉じタグ
	out_html += '</table>' + "\n";
	
	if(json_obj.Basketball[1]){
	
// 決勝追加
		out_html += '<div class="tableTitle tableTitleP">' + "\n" +
'<h5>' + game_date_MM + '月' + game_date_DD + '日&nbsp;決勝</h5>' + "\n" +
'</div>' + "\n" +
'<table border="1" summary="本日 女子の日程＆結果">' + "\n" +
'<tr>' + "\n" +
'<th scope="col" class="bg">出場校</th>' + "\n" +
'<th scope="col">スコア</th>' + "\n" +
'<th scope="col">出場校</th>' + "\n" +
'</tr>' + "\n";
	
		for (var i = 0; i < json_obj.Basketball[1].GameInfo.length; i++) {
			// ホームチーム
			out_html += '<tr>' + "\n" +
	'<td class="line school">' + json_obj.Basketball[1].GameInfo[i].HomeInfo.TeamName + '（' + json_obj.Basketball[1].GameInfo[i].HomeInfo.Block + '）</td>' + "\n";
	
			// スコア
			out_html += '<td class="score">(' + json_obj.Basketball[1].GameInfo[i].Quater + ')<br />';
			out_html += json_obj.Basketball[1].GameInfo[i].HomeInfo.Score + '-' + json_obj.Basketball[1].GameInfo[i].VisitorInfo.Score + '</td>' + "\n";
	
			// ビジターチーム
			out_html += '<td class="school">' + json_obj.Basketball[1].GameInfo[i].VisitorInfo.TeamName + '（' + json_obj.Basketball[1].GameInfo[i].VisitorInfo.Block + '）</td>' + "\n" +
	'</tr>' + "\n";
		}
	
		// 閉じタグ
		out_html += '</table>' + "\n";
	}

	// 表示
	document.getElementById("bkw_today_games").innerHTML = out_html;
}


// メイン ==============================================
// 男子
var bkmObj = new Object;
bkmObj = eval("(" + resultText_m + ")");

// 女子
var bkwObj = new Object;
bkwObj = eval("(" + resultText_w + ")");

// 実行
topScore_make_m(bkmObj);
topScore_make_w(bkwObj);

