// JavaScript Document

var atag_tmp  = "<a href=\"{0}\" class=\"{1}\">{2}</a>";

var _url = document.location.href;
var menuNowIdx = 0;

// 選單名稱
var menu_li_name = new Array("NBA", "比分直播", "賽程表", "影音直播", "影音隨選", "戰績" , "數據", "球隊球員", "新聞", "專欄", "相片" );

// 檔案名稱
var menu_file_name = new Array("index", "scoreboard", "schedule", "other", "other", "standings", "stats" , "team", "news", "column", "photo");

// 連結
var menu_link = new Array("/nba/", 
						  "Scoreboard.do", 
						  "schedule.html", 
						  "http://hichannel.hinet.net/NBA/", 
						  "http://hichannel.hinet.net/NBA/vod_1.html",  
						  "standings.html", 
						  "stats.html" , 
						  "teamsmap.html", 
						  "News.do", 
						  "column.html", 
						  "Photo.do");

function messageFormat( _tmp , obj) {
	var text = _tmp;
	for(var i = 0 ; i < obj.length ; i ++){
		var oldstr = "{" + i + "}";
		while( text.indexOf(oldstr) != -1 ) {
			text = text.replace(oldstr ,  obj[i]);
		}
	}
	return text;
}
$('#sub_nav').append("<ul></ul>");   
$(function() {
		
		menuInit();
		function menuInit() {
				var i=1;
				jQuery.each(menu_link, function() {
										  var className = "sub_out";
										  if (_url.indexOf(menu_file_name[i-1]) != -1 || _url.toLowerCase().indexOf(menu_file_name[i-1].toLowerCase()) != -1) {
										  	className = "sub_over";
										  }
										  $('#sub_nav ul').append("<li id='menu_li_" + i +"'><a href='"+ menu_link[i-1] + "' class='"+ className+"'>"+ menu_li_name[i-1] + "</a></li>");
										  i++;
										  });
				//alert(_url);
				
				if (_url == "http://sports.hinet.net/nba/") {
					$('#menu_li_1 a').attr("class" , "sub_over");
				}else if(_url.indexOf("Player") != -1) {
					$('#menu_li_8 a').attr("class" , "sub_over");
				}else if(_url.indexOf("Winner") != -1) {
					$('#menu_li_11 a').attr("class" , "sub_over");
				}else if(_url.indexOf("Question") != -1) {
					$('#menu_li_11 a').attr("class" , "sub_over");
				}else if(_url.indexOf("album") != -1) {
					$('#menu_li_12 a').attr("class" , "sub_over");
				}
		};
});