
//===============================
//定义namespace
var NBA = new Object();

  NBA.hideNum = 0;
   NBA.hideMatch = new Object();
//公共变量
NBA.SplitDomain="$";
NBA.SplitRecord="~";
NBA.SplitColumn="^";

NBA.Lang=_glUtil.GetUrlArg("l");
if (_glUtil.GetUrlArg("l")=="")
      NBA.Lang="tr";

NBA.DataFull="data/bks_nba.js";
NBA.DataChange="data/bks_nba_chg.js";


NBA.ReflashMillisecond=1500;
NBA.ReadContentMillisecond=60000;








//==============================
//数据定义

//公共域数据
NBA.Public=new Object();
NBA.Public.TimeStamp=new Date().getMilliseconds();
NBA.Public.MatchNum=0;
NBA.Public.ControlKey="";
NBA.Public.ReflashTimes=0;

//导航域数据
NBA.Nav=new Object();
NBA.Nav.Head="";
NBA.Nav.Content="";

NBA.Reload=function(str){
  var href="?";
	href += "l="+NBA.Lang;
	location.href = href;
}
//构造比赛列表的页面显示
NBA.MatchStr= [];

//比赛项类
NBA.Match=function(infoStr){
	var infoArr=infoStr.split(NBA.SplitColumn);
	this.MatchId=infoArr[0];
	this.MatchTime=new Date(infoArr[1]*1000);
	this.StateId=infoArr[2];
	this.State=bks.getStatus(this.StateId);
	this.Losttime=infoArr[3];
	this.T1Id=infoArr[4];
	this.T1Tr=infoArr[5];
	this.T1Cn=infoArr[6];
	this.T1En=infoArr[7];
	this.T1First=infoArr[8];
	this.T1Second=infoArr[9];
	this.T1Third=infoArr[10];
	this.T1Fourth=infoArr[11];
	this.T1Ot1=infoArr[12];
	this.T1Ot2=infoArr[13];
	this.T1Ot3=infoArr[14];
	this.T1Ot4=infoArr[15];
	this.T1PtsId=infoArr[16];
	this.T1Pts=infoArr[17];
	this.T1RebId=infoArr[18];
	this.T1Reb=infoArr[19];
	this.T1AstId=infoArr[20];
	this.T1Ast=infoArr[21];
	this.T2Id=infoArr[22];
	this.T2Tr=infoArr[23];
	this.T2Cn=infoArr[24];
	this.T2En=infoArr[25];
	this.T2First=infoArr[26];
	this.T2Second=infoArr[27];
	this.T2Third=infoArr[28];
	this.T2Fourth=infoArr[29];
	this.T2Ot1=infoArr[30];
	this.T2Ot2=infoArr[31];
	this.T2Ot3=infoArr[32];
	this.T2Ot4=infoArr[33];
	this.T2PtsId=infoArr[34];
	this.T2Pts=infoArr[35];
	this.T2RebId=infoArr[36];
	this.T2Reb=infoArr[37];
	this.T2AstId=infoArr[38];
	this.T2Ast=infoArr[39];
	this.HAsOdds=infoArr[40];
	this.AsOdds=infoArr[41];
	this.HOverUnder=infoArr[42];
	this.OverUnder=infoArr[43];
	this.LiveBst_tr=infoArr[44];
	this.LiveBst_cn=infoArr[45];
	this.LiveBst_en=infoArr[46];
	this.liveUrl=infoArr[47];
	this.intro = infoArr[48];
	this.liveTV=infoArr[49];
	this.T1img=infoArr[50];
	this.T2img=infoArr[51];
	this.analysis = infoArr[52];
	this.T1range=infoArr[53];
    this.T2range=infoArr[54];
    this.hasPplv=infoArr[55];


	if(NBA.Lang=="en"){
		this.T1Name=this.T1En;
		this.T2Name=this.T2En;
		this.LiveBst=this.LiveBst_en;

        if(this.T1range) this.T1range = this.T1range.replace("东", "E");
		if(this.T1range) this.T1range = this.T1range.replace("西", "W");
        if(this.T2range) this.T2range = this.T2range.replace("东", "E");
		if(this.T2range) this.T2range = this.T2range.replace("西", "W");

	}
	else if(NBA.Lang=="cn"){
		this.T1Name=this.T1Cn;
		this.T2Name=this.T2Cn;
		this.LiveBst=this.LiveBst_cn;
	}
	else{
		this.T1Name=this.T1Tr;
		this.T2Name=this.T2Tr;
		this.LiveBst=this.LiveBst_tr;
		if(this.T1range) this.T1range = this.T1range.replace("东", "東");
        if(this.T2range) this.T2range = this.T2range.replace("东", "東");
	}
	}
NBA.Match.prototype={
	UpdateChange:function(chg){
		this.State=chg.State;
		this.Losttime=chg.Losttime;
		this.T1First=chg.T1First;
		this.T1Second=chg.T1Second;
		this.T1Third=chg.T1Third;
		this.T1Fourth=chg.T1Fourth;
		this.T1Ot1=chg.T1Ot1;
		this.T1Ot2=chg.T1Ot2;
		this.T1Ot3=chg.T1Ot3;
		this.T1Ot4=chg.T1Ot4;
		this.T1PtsId=chg.T1PtsId;
		this.T1Pts=chg.T1Pts;
		this.T1RebId=chg.T1RebId;
		this.T1Reb=chg.T1Reb;
		this.T1AstId=chg.T1AstId;
		this.T1Ast=chg.T1Ast;
		this.T2First=chg.T2First;
		this.T2Second=chg.T2Second;
		this.T2Third=chg.T2Third;
		this.T2Fourth=chg.T2Fourth;
		this.T2Ot1=chg.T2Ot1;
		this.T2Ot2=chg.T2Ot2;
		this.T2Ot3=chg.T2Ot3;
		this.T2Ot4=chg.T2Ot4;
		this.T2PtsId=chg.T2PtsId;
		this.T2Pts=chg.T2Pts;
		this.T2RebId=chg.T2RebId;
		this.T2Reb=chg.T2Reb;
		this.T2AstId=chg.T2AstId;
		this.T2Ast=chg.T2Ast;
        this.LiveBst=chg.LiveBst;
        this.intro = chg.intro;
	}
}

//比赛变化信息项类
NBA.MatchChg=function(infoStr){
	var infoArr=infoStr.split(NBA.SplitColumn);
	this.MatchId=infoArr[0];
	this.StateId=infoArr[1];
	this.State=bks.getStatus(this.StateId);
	this.Losttime=infoArr[2];
	this.T1First=infoArr[3];
	this.T1Second=infoArr[4];
	this.T1Third=infoArr[5];
	this.T1Fourth=infoArr[6];
	this.T1Ot1=infoArr[7];
	this.T1Ot2=infoArr[8];
	this.T1Ot3=infoArr[9];
	this.T1Ot4=infoArr[10];
	this.T1PtsId=infoArr[11];
	this.T1Pts=infoArr[12];
	this.T1RebId=infoArr[13];
	this.T1Reb=infoArr[14];
	this.T1AstId=infoArr[15];
	this.T1Ast=infoArr[16];
	this.T2First=infoArr[17];
	this.T2Second=infoArr[18];
	this.T2Third=infoArr[19];
	this.T2Fourth=infoArr[20];
	this.T2Ot1=infoArr[21];
	this.T2Ot2=infoArr[22];
	this.T2Ot3=infoArr[23];
	this.T2Ot4=infoArr[24];
	this.T2PtsId=infoArr[25];
	this.T2Pts=infoArr[26];
	this.T2RebId=infoArr[27];
	this.T2Reb=infoArr[28];
	this.T2AstId=infoArr[29];
	this.T2Ast=infoArr[30];
    this.LiveBst_tr=infoArr[31];
    this.LiveBst_cn=infoArr[32];
    this.LiveBst_en=infoArr[33];
    this.intro = infoArr[34];
   if(NBA.Lang=="en"){
		this.LiveBst=this.LiveBst_en;
	}
	else if(NBA.Lang=="cn"){
		this.LiveBst=this.LiveBst_cn;
	}
	else{
		this.LiveBst=this.LiveBst_tr;
	}

	}


//球员类
NBA.Player=function(infoStr){
	var infoArr=infoStr.split(NBA.SplitColumn);
	this.PId=infoArr[0];
	this.PTr=infoArr[1];
	this.PCn=infoArr[2];
	this.PEn=infoArr[3];
	if(NBA.Lang=="en"){
		this.PName=this.PEn;
	}
	else if(NBA.Lang=="cn"){
		this.PName=this.PCn;
	}
	else{
		this.PName=this.PTr;
	}


}

NBA.Playerchg=function(infoStr){
	var infoArr=infoStr.split(NBA.SplitColumn);
	this.PId=infoArr[0];
	this.PTr=infoArr[1];
	this.PCn=infoArr[2];
	this.PEn=infoArr[3];
	if(NBA.Lang=="en"){
		this.PName=this.PEn;
	}
	else if(NBA.Lang=="cn"){
		this.PName=this.PCn;
	}
	else{
		this.PName=this.PTr;
	}

}



//通用列表类，类似hashtable
NBA.List=function(infoStr){
	this.Items=new Object();
	this.GetArray=function(){
		var iterArr=new Array();
		var i=0;

 		for(var k in this.Items){
			if(typeof(this.Items[k])!="undefined"){
				iterArr[i]=this.Items[k];
				i++;
			}
		}
		return iterArr;
	}
	this.Add = function(key,value){
		if(typeof(key)!="undefined"){
				this.Items[key]=typeof(value)=="undefined"?null:value;
		}
	}
	this.Count = function(){
		var i=0;
		for(var k in this.Items){
			if(typeof(this.Items[k])!="undefined")
				i++;
		}
		return i;
	}
	this.GetByIndex = function (itemIndex){
		var i=0;
		for(var k in this.Items){
			if(i==parseInt(itemIndex, 10)){
				return this.Items[k];
			}
			i++;
		}
	}
	this.Get = function(key){
		return this.Items[key];
	}
	this.Clear=function(){
		for(var k in this.Items){
			delete this.Items[k];
		}
		delete this.Items;
		this.Items=null;
		this.Items=new Object();
	}
}




///留言

NBA.DataMessage="data/bks_bbs/bbs_chg.js";
NBA.MessageInfo=function(infoStr){
	var infoArr=infoStr.split(NBA.SplitColumn);
	this.MatchId=infoArr[0];
	this.personname=infoArr[1];
	this.content=infoArr[2];

	this.ipAddress=infoArr[3];

}


NBA.InitMessage=function(){

	$.ajax({
			type: "GET",
			url: NBA.DataMessage+"?"+_glUtil.RndStr(10),
			dataType: "html",
		    success: NBA.DataMessageHandler
          });

   window.setTimeout(NBA.InitMessage,10000);

}


 
 
NBA.DataMessageHandler=function(data){
	//分隔大数据域
   if(!data) return;

	var domains=data.split(NBA.SplitDomain);
     NBA.messageList = new NBA.List();
    var ls;


    var matchIdDomain=domains[1].split(NBA.SplitColumn);


    for(var j=0;j<matchIdDomain.length;j++){


         var bbb= document.getElementById("messagearray_"+matchIdDomain[j])  ;
         if(bbb) {
           bbb.style.display="";
           bbb.setAttribute("isshow", "1");
         }


	}



    var messagerDomain=domains[2].split(NBA.SplitRecord);
	for(var i=0;i<messagerDomain.length;i++){

		 if(messagerDomain[i].length>5) {
			var messageItem=new NBA.MessageInfo(messagerDomain[i]);

			 ls = NBA.messageList.Get(messageItem.MatchId);

                    



             if(ls==null) {
               ls = new Array();
               NBA.messageList.Add(messageItem.MatchId, ls);
            }

		       ls.push("<font color=\"FF1493\">"+messageItem.personname+"</font>:"+messageItem.content);


	    }


      



	}




         for(var mid in NBA.messageList.Items)  {

             

            var sss=    document.getElementById("message_"+mid)  ;

              if(sss)
              sss.innerHTML=NBA.messageList.Get(mid).join("  |  ");

			  
           
    }



  






}

//==========================
//定时器变量和清除方法
NBA.Interval=new Object();
NBA.Interval.ReflashChange=null;
NBA.Interval.ReflashTime=null;
NBA.Interval.InitLoad=null;
NBA.Interval.ReflashContent=null;

//清理定时器
NBA.Interval.Clear=function(){
	if(typeof(NBA.Interval.ReflashChange)!="undefined"){
		clearTimeout(NBA.Interval.ReflashChange);
		NBA.Interval.ReflashChange=null;
	}
	if(typeof(NBA.Interval.ReflashTime)!="undefined"){
		clearTimeout(NBA.Interval.ReflashTime);
		NBA.Interval.ReflashTime=null;
	}
	if(typeof(NBA.Interval.InitLoad)!="undefined"){
		clearTimeout(NBA.Interval.InitLoad);
		NBA.Interval.InitLoad=null;
	}
	if(typeof(NBA.Interval.ReflashContent)!="undefined"){
		clearTimeout(NBA.Interval.ReflashContent);
		NBA.Interval.ReflashContent=null;
	}
}

//全局数据项和数据列表容器
NBA.MatchTable = null;
NBA.MatchList=new NBA.List();
NBA.PlayerList=new NBA.List();

NBA.Init=function(){
	// 初始化全局变量
	NBA.Public.ReflashTimes=0
	NBA.MatchList.Clear();

    var c_l = _glUtil.GetCookie("_gl_lang");
    if(c_l && (c_l=="en" || c_l=="tr" || c_l=="cn")) NBA.Lang = c_l;
    NBA.setna();


    NBA.Interval.Clear();//清理定时器
	$.ajax({
			type: "GET",
			url: NBA.DataFull+"?"+_glUtil.RndStr(10),
			dataType: "html",
		    success: NBA.DataHandler});


}








NBA.mattchids="";





//处理读取的数据
//处理方法:读入js普通变量或列表变量
NBA.DataHandler=function(data){
	//分隔大数据域
	var domains=data.split(NBA.SplitDomain);

	//处理公共数据域
	var publicDomain=domains[0].split(NBA.SplitColumn);
	if(parseInt(publicDomain[0], 10)>NBA.Public.TimeStamp){
		NBA.Public.TimeStamp=parseInt(publicDomain[0], 10);
		NBA.SetServerDate();
	}
	NBA.Public.MatchNum=publicDomain[2];
	NBA.Public.ControlKey=publicDomain[1];


	//处理比赛数据
	var matchDomain=domains[1].split(NBA.SplitRecord);
	for(var i=0;i<matchDomain.length;i++){
        if(matchDomain[i].length>5) {
			var matchItem=new NBA.Match(matchDomain[i]);
			NBA.MatchList.Add(matchItem.MatchId,matchItem);

			 if(i>0)NBA.mattchids += ",";
		      NBA.mattchids+=matchItem.MatchId;
         }
	}

	//处理球员数据域
	var playerDomain=domains[2].split(NBA.SplitRecord);
	for(var i=0;i<playerDomain.length;i++){
	    if(playerDomain[i].length>5) {
			var playerItem=new NBA.Player(playerDomain[i]);
			NBA.PlayerList.Add(playerItem.PId,playerItem);
	    }
	}

	//处理导航数据
	var navDomain=domains[3].split(NBA.SplitColumn);
	NBA.Nav.Content=navDomain[0];


	//把导航数据填入页面
	document.getElementById("navcontent").innerHTML=NBA.Nav.Content;
	if(NBA.Nav.Content=="") document.getElementById("div_content").style.display = "none";

   //构造联赛表格
 	NBA.MatchStr.push("<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataSheet \" id=\"Matchs\">");


	NBA.MatchListCount=NBA.MatchList.Count();
  NBA.MatchListArray = NBA.MatchList.GetArray();



	NBA.DomBuild();//构造比赛列表的页面显示
    NBA.InitMessage();
}

NBA.GetPlayer = function(playerId){
	if (!playerId)
	  return"";
	//for(var i=0; i<NBA.PlayerListArray.length; i++)
		//if(NBA.PlayerListArray[i].PId == playerId)
		//return NBA.PlayerListArray[i].PName;
	var player = NBA.PlayerList.Get(playerId);
		if(player) return '<a href="javascript:NBA.openPerson('+playerId+');" style="line-height:130%;">'+player.PName+'</a>';
	return "";
}

NBA.OTDisplay = function(otscore1,otscore2){
	if(otscore1 != ""||otscore2 != "")
		return "";
	else
		return "display: none;";
}
NBA.Otdisplay=function(css,id){
	$(".css").css("display","none");
}
NBA.AlignStr=function(value){
	 if (value == ""){
		value = "&nbsp;&nbsp;";
		}
		if(typeof(value)=="undefined") value = "";
		var count = 2-value.length;
		for(var i=0; i<count; i++)
			value = value + "&nbsp;";
		return value;
	}




NBA.openMessage = function(mid) {



  var url = "messagelist.html?matchid="+mid+"&x="+new Date();



  window.open(url, "", "left=150,top=120,width=700,height=610,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
}















NBA.DomBuild=function(){


       NBA.hideNum = 0;





	for(var i=0;i<NBA.MatchListArray.length;i++){
		var MatchItem=NBA.MatchListArray[i];//当前加载的比赛项







       var bHide = NBA.hideMatch[MatchItem.MatchId]?true:false;
        if(bHide) NBA.hideNum++;






		//构建tr:比赛信息
		var	str = NBA.MatchStr;

		if(!MatchItem.MatchId)
		  continue;
		str.push("<tr id=\"tr"+MatchItem.MatchId+"\" mid=\""+MatchItem.MatchId+"\"   "+(bHide?' style="display:none;"':'')+" >");

		//构建td:球队
		var mKO;
	  if (MatchItem.Losttime!=""&&MatchItem.Losttime!=0){
	  	 mKO=NBA.Untility.TimeHandler(parseInt(MatchItem.Losttime/60)) +":"+NBA.Untility.TimeHandler(MatchItem.Losttime%60);}
	  	else{
	  	 mKO="&nbsp;";}

		var mTime=NBA.Untility.TimeHandler(MatchItem.MatchTime.getHours()) +":"+NBA.Untility.TimeHandler(MatchItem.MatchTime.getMinutes());
		if(MatchItem.State=="未") mTime = "<span id='mhd_"+MatchItem.MatchId+"'>" + (MatchItem.MatchTime.getMonth()+1) + "/" + MatchItem.MatchTime.getDate() + " </span>" + mTime;

		var HT1=parseInt(NBA.Untility.NumHandler(MatchItem.T1First))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Second));
		var HT2=parseInt(NBA.Untility.NumHandler(MatchItem.T2First))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Second));
		if (MatchItem.StateId=="17"||MatchItem.StateId=="18"||MatchItem.StateId=="26"||MatchItem.StateId=="27"){
		    HT1="0";
		    HT2="0";}

		var T1=parseInt(NBA.Untility.NumHandler(MatchItem.T1First))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Second))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Third))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Fourth))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Ot1))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Ot2))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Ot3))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Ot4));

		var T2=parseInt(NBA.Untility.NumHandler(MatchItem.T2First))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Second))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Third))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Fourth))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Ot1))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Ot2))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Ot3))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Ot4));

		var imgHttp1="";
		var imgHttp2="";
		if (MatchItem.T1img!="")
		   imgHttp1 ="<img src="+MatchItem.T1img+">";
		if (MatchItem.T2img!="")
		   imgHttp2 ="<img src="+MatchItem.T2img+">";
		str.push("<td style=\"padding: 0px;\" class=\"isDataSheet\" width=\"150\">");

    var mState="<span id=\"state_"+MatchItem.MatchId+"\" style=\"color:#0000FF;\">"+MatchItem.State+"</span>";
     if (MatchItem.State=="完")
         mState="<span id=\"state_"+MatchItem.MatchId+"\" style=\"color:#FF0000;font-weight:bold;\">"+MatchItem.State+"</span>";




		str.push("<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataSheet lightBlue\"><tr><td style='padding:0px;'><div class=\"left\"><input type='checkbox'checked onclick='NBA.hideMatch("+MatchItem.MatchId+");this.checked=true;'  />"+mTime+"|"+ mState +"&nbsp;<span id=\"mKO_"+MatchItem.MatchId+"\" style=\"color:#0000FF;\">"+mKO+"</span></div><div class='right'>"+(MatchItem.liveTV?"<img src='http://pic.gooooal.com/skins/default/space.gif' class='ico_TV' alt='"+MatchItem.liveTV+"' title='"+MatchItem.liveTV+"'>":"")+"</div><\/td><\/tr>"
		  + "<tr><td class=\"left\"><span style='float:left;'>"+imgHttp1+"&nbsp;</span><span style='float:left;'><a id=\"T1Name_"+MatchItem.MatchId+"\" href=\"javascript:toBksTeam("+MatchItem.T1Id+");\">"+ MatchItem.T1Name +"</a><\/span><span style='float:right;'>"+ MatchItem.T1range +"</span><\/td><\/tr><tr><td class=\"left\"><span style='float:left;'>"+imgHttp2+"&nbsp;</span><span style='float:left;'><a id=\"T2Name_"+MatchItem.MatchId+"\" href=\"javascript:toBksTeam("+MatchItem.T2Id+");\">"+ MatchItem.T2Name +"</a><\/span><span style='float:right;'>"+ MatchItem.T2range +"</span><\/td></tr><\/table><\/td>");


		//构建td:比分
		str.push("<td style=\"padding: 0px;\" class=\"isDataSheet\" width=\"260\">");
		str.push("<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataSheet lightBlue\"><tr class=\"title\"><td>一<\/td><td>二<\/td><td>三<\/td><td>四<\/td>");
		str.push("<td class=\"OT1_"+MatchItem.MatchId+"\" id=\"OT1_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot1,MatchItem.T2Ot1)+"\">加1</td><td  class=\"OT2_"+MatchItem.MatchId+"\" id=\"OT2_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot2,MatchItem.T2Ot2)+"\">加2</td><td class=\"OT3_"+MatchItem.MatchId+"\" id=\"OT3_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot3,MatchItem.T2Ot3)+"\">加3</td><td class=\"OT4_"+MatchItem.MatchId+"\" id=\"OT4_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot4,MatchItem.T2Ot4)+"\">加4</td><td width=\"40\">半<\/td><td width=\"40\">全<\/td><\/tr>");
		str.push("<tr><td id=\"T1st_"+MatchItem.MatchId+"\">"+MatchItem.T1First+"<\/td><td id=\"T1nd_"+MatchItem.MatchId+"\">"+MatchItem.T1Second+"<\/td><td id=\"T1rd_"+MatchItem.MatchId+"\">"+MatchItem.T1Third+"<\/td><td  id=\"T1th_"+MatchItem.MatchId+"\">"+MatchItem.T1Fourth+"<\/td>");
		str.push("<td class=\"OT1_"+MatchItem.MatchId+"\" id=\"T1OT1_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot1,MatchItem.T2Ot1)+"\">"+MatchItem.T1Ot1+"<\/td><td class=\"OT2_"+MatchItem.MatchId+"\" id=\"T1OT2_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot2,MatchItem.T2Ot2)+"\">"+MatchItem.T1Ot2+"<\/td><td class=\"OT3_"+MatchItem.MatchId+"\" id=\"T1OT3_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot3,MatchItem.T2Ot3)+"\">"+MatchItem.T1Ot3+"<\/td><td class=\"OT4_"+MatchItem.MatchId+"\" id=\"T1OT4_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot4,MatchItem.T2Ot4)+"\">"+MatchItem.T1Ot4+"<\/td>");
		str.push("<td id=\"HT1_"+MatchItem.MatchId+"\">"+HT1+"<\/td><td  id=\"T1_"+MatchItem.MatchId+"\" style=\"color:#FF0000;font-weight:bold;\">"+T1+"<\/td><\/tr>");
    str.push("<tr><td id=\"T2st_"+MatchItem.MatchId+"\">"+NBA.AlignStr(MatchItem.T2First)+"<\/td><td id=\"T2nd_"+MatchItem.MatchId+"\">"+NBA.AlignStr(MatchItem.T2Second)+"<\/td><td id=\"T2rd_"+MatchItem.MatchId+"\">"+NBA.AlignStr(MatchItem.T2Third)+"<\/td><td id=\"T2th_"+MatchItem.MatchId+"\">"+NBA.AlignStr(MatchItem.T2Fourth)+"<\/td>");
		str.push("<td class=\"OT1_"+MatchItem.MatchId+"\" id=\"T2OT1_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot1,MatchItem.T2Ot1)+"\">"+MatchItem.T2Ot1+"<\/td><td  class=\"OT2_"+MatchItem.MatchId+"\" id=\"T2OT2_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot2,MatchItem.T2Ot2)+"\">"+MatchItem.T2Ot2+"<\/td><td class=\"OT3_"+MatchItem.MatchId+"\" id=\"T2OT3_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot3,MatchItem.T2Ot3)+"\">"+MatchItem.T2Ot3+"<\/td><td class=\"OT4_"+MatchItem.MatchId+"\" id=\"T2OT4_"+MatchItem.MatchId+"\" style=\""+NBA.OTDisplay(MatchItem.T1Ot4,MatchItem.T2Ot4)+"\">"+MatchItem.T2Ot4+"<\/td>");
		str.push("<td  id=\"HT2_"+MatchItem.MatchId+"\">"+HT2+"<\/td><td  id=\"T2_"+MatchItem.MatchId+"\" style=\"color:#FF0000;font-weight:bold;\">"+T2+"<\/td><\/tr></table></td>");



		//构建td:场上信息
    str.push("<td style=\"padding: 0px;\" class=\"isDataSheet\" width=\"300\">");
		str.push("<table cellpadding=\"0\" cellspacing=\"0\" class=\"dataSheet lightBlue\"><tr class=\"title\"><td style=\"width: 95px;\" >得分</td><td style=\"width: 95px;\">篮板</td><td>助攻</td></tr>");
		str.push("<tr><td style=\"padding: 0 2px 0 2px;width:100px;\" id=\"T1PtsId_"+MatchItem.MatchId+"\">"+NBA.GetPlayer(MatchItem.T1PtsId)+":"+MatchItem.T1Pts+"</td><td style=\"padding: 0 2px 0 2px;width:100px;\" id=\"T1RebId_"+MatchItem.MatchId+"\">"+NBA.GetPlayer(MatchItem.T1RebId)+":"+MatchItem.T1Reb+"</td><td style=\"padding: 0 2px 0 2px;width:100px;\" id=\"T1AstId_"+MatchItem.MatchId+"\">"+NBA.GetPlayer(MatchItem.T1AstId)+":"+MatchItem.T1Ast+"</td></tr>");
		str.push("<tr><td style=\"padding: 0 2px 0 2px;width:100px;\" id=\"T2PtsId_"+MatchItem.MatchId+"\">"+NBA.GetPlayer(MatchItem.T2PtsId)+":"+MatchItem.T2Pts+"</td><td style=\"padding: 0 2px 0 2px;width:100px;\" id=\"T2RebId_"+MatchItem.MatchId+"\">"+NBA.GetPlayer(MatchItem.T2RebId)+":"+MatchItem.T2Reb+"</td><td style=\"padding: 0 2px 0 2px;width:100px;\" id=\"T2AstId_"+MatchItem.MatchId+"\">"+NBA.GetPlayer(MatchItem.T2AstId)+":"+MatchItem.T2Ast+"</td></tr></table>");
		str.push("</td>");
		str.push("</tr>");




		//构建tr:文字直播
		str.push("<tr class=\"end\" id=\"bst_"+MatchItem.MatchId+"\"  "+(bHide?' style="display:none;"':'')+"><td colspan=\"20\"><p class=\"float_l\"><span id=\"LiveBst_"+MatchItem.MatchId+"\">"+MatchItem.LiveBst+"</span>&nbsp;&nbsp;<!--a href=\"#\">文字直播</a--></p><p class=\"float_r\"  style=\"color:#0000FF;\">"
		  +(MatchItem.hasPplv=="1"?"<a href=\"javascript:openPplv("+MatchItem.MatchId+");\" style='color:red;'>视频</a>&nbsp;":"")
		  +"半场：<a href=\"javascript:NBA.openOdds("+MatchItem.MatchId+",'a1');\" style=\"color:#0000FF;\"><u>"+MatchItem.HAsOdds+"</u></a>/<a href=\"javascript:NBA.openOdds("+MatchItem.MatchId+",'o1');\" style=\"color:#0000FF;\"><u>"+MatchItem.HOverUnder+"</u></a> | 全场：<a href=\"javascript:NBA.openOdds("+MatchItem.MatchId+",'a');\" style=\"color:#0000FF;\"><u>"+MatchItem.AsOdds+"</u></a>/<a href=\"javascript:NBA.openOdds("+MatchItem.MatchId+",'o');\" style=\"color:#0000FF;\"><u>"+MatchItem.OverUnder+"</u></a>&nbsp;&nbsp;"
		  +(MatchItem.liveUrl!=""?("<a href='"+MatchItem.liveUrl+"' target='_blank'><font color=red><u>视频直播</u></font></a>&nbsp;"):"")
		  +"<a href=\"javascript:NBA.openLive("+MatchItem.MatchId+");\" title='文字直播'><img src='http://pic.gooooal.com/images/100028/100028933.gif'></a>&nbsp;"
		  +"<a href=\"javascript:NBA.openStat("+MatchItem.MatchId+");\"><img src='http://pic.gooooal.com/skins/newHeader/ico_mBasketball.gif' height='20' alt='技术统计' title='技术统计'></a>"
		  +"<a href='http://app.gooooal.com/bks/analysis.do?matchId="+MatchItem.MatchId+"&lang="+NBA.Lang+"' target='_blank' title='賽事分析'><img src='http://pic.gooooal.com/skins/default/space.gif' class='ico_analyse' /></a>"
		  +(MatchItem.analysis=="1"?"<a href=\"javascript:NBA.openAnalysis2("+MatchItem.MatchId+");\"><img title='赛前分析' alt='赛前分析' class='ico_analyse' src='http://pic.gooooal.com/skins/default/ico_xi.gif'/></a>":"")
		  +"</p></td></tr>");




		str.push("<tr id=\"intro_"+MatchItem.MatchId+"\" bgcolor=\"#fffbe8\" "+(MatchItem.intro?"":"style='display:none;' isshow='0'")+"    ><td colspan=\"20\">"+MatchItem.intro+"</td></tr>");




	    ///构建tr:留言
        str.push("<tr style=\"display:none\"  isshow=\"0\" id=\"messagearray_"+MatchItem.MatchId+"\" ><td colspan=4 bgcolor=\"#fffbe8\"><span style=\"float: left; margin: 2px 0;\" ><a href=\"javascript:NBA.openMessage("+MatchItem.MatchId+");\"><img src='http://pic.gooooal.com/images/100037/100037444.gif' title='留言区'>&nbsp;<span style=\"color: blue\">我要留言</span></a></span><span style=\"float: left;\">&nbsp;<marquee id=\"message_"+MatchItem.MatchId+"\" width=600 scrollamount=2 onmouseout='this.start();' onmouseover='this.stop();'> </marquee></span></td></tr>")
		

	
	}


	// 关闭加载提示消息
	document.getElementById("loading_tip").style.display = "none";
	document.getElementById("panel").style.display = "";

	var NBADiv = document.getElementById("panel");

	NBA.MatchStr.push("<\/table>");







	NBADiv.innerHTML = NBA.MatchStr.join("");


	NBA.MatchListArray.length = 0;
	NBA.MatchStr.length = 0;



	//初始化定时器
	NBA.Interval.ReflashChange=setTimeout(NBA.ReflashChange,NBA.ReflashMillisecond);


	NBA.showTextAd();

	return;
}
//============================
//刷新变化数据的控制器
NBA.ReflashState=1;//变化加载状态字:1表示可以请求数据,0表示正在请求数据
NBA.ReflashCounter=0;//不成功刷新次数计数器
NBA.ReflashChange=function(){
	try{
		//1时请求数据,计数器归0
		//0时等待,计数器加1
		if(NBA.ReflashState==1){
			NBA.ReflashState=0;
			NBA.ReflashCounter=0;
			NBA.ReflashData();
		}
		else{
			NBA.ReflashCounter++;
			//一定次数不成功,强制重新刷新
			if(NBA.ReflashCounter>15){
				NBA.ReflashCounter=0;
				NBA.ReflashData();
			}
		}
	}catch(e){}
	NBA.Interval.ReflashChange=setTimeout(NBA.ReflashChange,NBA.ReflashMillisecond);
}
//重置状态字
NBA.ReflashDataFinal=function(){
	NBA.ReflashState=1;
}

//=======================
//读取变化数据
NBA.ReflashData=function(){
	//读取3600次后强制刷新页面,清理浏览器内存
	NBA.Public.ReflashTimes++;
	if(NBA.Public.ReflashTimes>3600)
	{
		NBA.Reload(NBA.Lang);
		return;
	}

	NBA.ReflashState=0;//状态置设为0
	$.ajax({
		type: "GET",
		url: NBA.DataChange+"?"+_glUtil.RndStr(10),
		dataType: "html",
		success: NBA.ChangeDataHandler,
		complete: function(){NBA.ReflashState=1;}});
}

//处理读取的数据
NBA.ChangeDataHandler=function(data){
	try{
		var domains=data.split(NBA.SplitDomain);

		//处理公共域
		var publicDomain=domains[0].split(NBA.SplitColumn);
		var TimeStamp=parseInt(publicDomain[0], 10);
		var ControlKey=publicDomain[1];

     if(ControlKey=="1"&&NBA.Public.ControlKey!="1")
		{
		    NBA.Public.ControlKey=ControlKey;
		    NBA.Reload(NBA.Lang);
			return;
		}
		NBA.Public.ControlKey=ControlKey;

		//根据时间戳判断是否读取到新数据
		if(NBA.Public.TimeStamp>=TimeStamp)
			return;

	   NBA.Public.TimeStamp=TimeStamp;



		//处理比赛数据
		var matchDomain=domains[1].split(NBA.SplitRecord);
		var tmpMatchs=new NBA.List();
        for(var i=0;i<matchDomain.length;i++){
				var matchItem=new NBA.MatchChg(matchDomain[i]);
				tmpMatchs.Add(matchItem.MatchId,matchItem);
		}

		var playerDomain=domains[2].split(NBA.SplitRecord);
      //var tmpPlayers=new NBA.List();
       if(playerDomain!=""){
        for(var i=0;i<playerDomain.length;i++){
				var playerItem=new NBA.Playerchg(playerDomain[i]);
				//tmpPlayers.Add(playerItem.PId,playerItem);
				NBA.PlayerList.Add(playerItem.PId,playerItem);
		    }
		   }
		NBA.ChangeDom(tmpMatchs);

	}
	catch(e){}
}

NBA.Styles=new Array();
NBA.ChangeDom=function(tmpMatchs){
	var MatchArr=tmpMatchs.GetArray();

	for(var i=0;i<MatchArr.length;i++){
		var MatchItem=MatchArr[i];
		var OldMatch=NBA.MatchList.Get(MatchItem.MatchId);

		if((!MatchItem)||(!OldMatch))
			continue;
		if(OldMatch.MatchId!=MatchItem.MatchId)
			continue;
        try{
			var T1=document.getElementById("T1_"+MatchItem.MatchId);
			var T2=document.getElementById("T2_"+MatchItem.MatchId);
			var HT1=document.getElementById("HT1_"+MatchItem.MatchId);
			var HT2=document.getElementById("HT2_"+MatchItem.MatchId);
			var T1First=document.getElementById("T1First_"+MatchItem.MatchId);
			var T1Second=document.getElementById("T1Second_"+MatchItem.MatchId);
			var T1Third=document.getElementById("T1Third_"+MatchItem.MatchId);
			var T1Fourth=document.getElementById("T1Fourth_"+MatchItem.MatchId);
			var T2First=document.getElementById("T2First_"+MatchItem.MatchId);
			var T2Second=document.getElementById("T2Second_"+MatchItem.MatchId);
			var T2Third=document.getElementById("T2Third_"+MatchItem.MatchId);
			var T2Fourth=document.getElementById("T2Fourth_"+MatchItem.MatchId);
			var T1OT1=document.getElementById("T1OT1_"+MatchItem.MatchId);
			var T1OT2=document.getElementById("T1OT2_"+MatchItem.MatchId);
			var T1OT3=document.getElementById("T1OT3_"+MatchItem.MatchId);
			var T1OT4=document.getElementById("T1OT4_"+MatchItem.MatchId);
			var T2OT1=document.getElementById("T2OT1_"+MatchItem.MatchId);
			var T2OT2=document.getElementById("T2OT2_"+MatchItem.MatchId);
			var T2OT3=document.getElementById("T2OT3_"+MatchItem.MatchId);
			var T2OT4=document.getElementById("T2OT4_"+MatchItem.MatchId);


			var T1v=parseInt(NBA.Untility.NumHandler(MatchItem.T1First))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Second))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Third))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Fourth))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Ot1))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Ot2))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Ot3))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Ot4));

			var T2v=parseInt(NBA.Untility.NumHandler(MatchItem.T2First))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Second))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Third))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Fourth))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Ot1))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Ot2))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Ot3))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Ot4));


			var HT1v=parseInt(NBA.Untility.NumHandler(MatchItem.T1First))+parseInt(NBA.Untility.NumHandler(MatchItem.T1Second));
  		var HT2v=parseInt(NBA.Untility.NumHandler(MatchItem.T2First))+parseInt(NBA.Untility.NumHandler(MatchItem.T2Second));


  		if(OldMatch.State=="未" && MatchItem.State!=OldMatch.State) {
  		  var smd = document.getElementById("mhd_"+MatchItem.MatchId);
  		  if(smd) smd.innerHTML = "";
  		}


  		if (MatchItem.StateId=="17"||MatchItem.StateId=="18"||MatchItem.StateId=="26"||MatchItem.StateId=="27"){
  		   HT1v="0";
  		   HT2v="0";}

			NBA.ChgStyle(HT1.innerHTML, HT1v,"HT1_",MatchItem.MatchId);
			NBA.ChgStyle(HT2.innerHTML, HT2v,"HT2_",MatchItem.MatchId);

			T1.innerHTML=T1v;
			T2.innerHTML=T2v;

			if(OldMatch.State != MatchItem.State){
				var state=document.getElementById("state_"+MatchItem.MatchId);
				var T1name=document.getElementById("T1Name_"+MatchItem.MatchId).innerHTML;
				var T2name=document.getElementById("T2Name_"+MatchItem.MatchId).innerHTML;

				state.innerHTML=MatchItem.State;

				if (MatchItem.State!="完"){
    				NBA.ChgBlueStyle(OldMatch.State, MatchItem.State,"state_",MatchItem.MatchId);
    				Notice.Show(MatchItem.State,T1v,T2v,T1name,T2name);}
    			else{
    				state.style.color="#FF0000";
  				   state.style.fontWeight="bold";
  				   var MatchState="<font style=\"color:#FF0000;\">"+ MatchItem.State +"</font>";
  				   Notice.Show(MatchState,T1v,T2v,T1name,T2name);}

				//待,改,取,完
				if(MatchItem.State=="待"){
					T1.innerHTML = "?";
					T2.innerHTML = "?";
          T1First.innerHTML = "";
					T1Second.innerHTML = "";
					T1Third.innerHTML = "";
					T1Fourth.innerHTML = "";
					T2First.innerHTML = "";
					T2Second.innerHTML = "";
					T2Third.innerHTML = "";
					T2Fourth.innerHTML = "";
					T1OT1.innerHTML = "";
					T1OT2.innerHTML = "";
					T1OT3.innerHTML = "";
					T1OT4.innerHTML = "";
					T2OT1.innerHTML = "";
					T2OT2.innerHTML = "";
					T2OT3.innerHTML = "";
					T2OT4.innerHTML = "";
				}
				if(MatchItem.State=="改"||MatchItem.State=="待"){
					T1.innerHTML = "";
					T2.innerHTML = "";
          T1First.innerHTML = "";
					T1Second.innerHTML = "";
					T1Third.innerHTML = "";
					T1Fourth.innerHTML = "";
					T2First.innerHTML = "";
					T2Second.innerHTML = "";
					T2Third.innerHTML = "";
					T2Fourth.innerHTML = "";
					T1OT1.innerHTML = "";
					T1OT2.innerHTML = "";
					T1OT3.innerHTML = "";
					T1OT4.innerHTML = "";
					T2OT1.innerHTML = "";
					T2OT2.innerHTML = "";
					T2OT3.innerHTML = "";
					T2OT4.innerHTML = "";
				}
				if(MatchItem.State=="待"|MatchItem.State=="取"||MatchItem.State=="改"||MatchItem.State=="完"||MatchItem.State=="斩"){
                    document.getElementById("Matchs").tBodies[0].appendChild(document.getElementById("tr"+MatchItem.MatchId));
					document.getElementById("Matchs").tBodies[0].appendChild(document.getElementById("bst_"+MatchItem.MatchId));
					document.getElementById("Matchs").tBodies[0].appendChild(document.getElementById("intro_"+MatchItem.MatchId));
					document.getElementById("Matchs").tBodies[0].appendChild(document.getElementById("messagearray_"+MatchItem.MatchId));
					var bbb= document.getElementById("messagearray_"+MatchItem.MatchId)  ;
                    if(bbb) {
                      bbb.style.display="none";
                      bbb.setAttribute("isshow", "0");
                    }
					NBA.showTextAd();
				}
			}
			if(OldMatch.Losttime != MatchItem.Losttime){
				var matchtime=document.getElementById("mKO_"+MatchItem.MatchId);
				if (MatchItem.Losttime!="")
				 matchtime.innerHTML=NBA.Untility.TimeHandler(parseInt(MatchItem.Losttime/60)) +":"+NBA.Untility.TimeHandler(MatchItem.Losttime%60);
				else
				 matchtime.innerHTML= "&nbsp;";
				}

			var LiveBst=document.getElementById("LiveBst_"+MatchItem.MatchId);
			LiveBst.innerHTML=MatchItem.LiveBst;

			NBA.ChgStyle(OldMatch.T1First, MatchItem.T1First,"T1st_",MatchItem.MatchId);
			NBA.ChgStyle(OldMatch.T1Second, MatchItem.T1Second,"T1nd_",MatchItem.MatchId);
			NBA.ChgStyle(OldMatch.T1Third, MatchItem.T1Third,"T1rd_",MatchItem.MatchId);
			NBA.ChgStyle(OldMatch.T1Fourth, MatchItem.T1Fourth,"T1th_",MatchItem.MatchId);
			NBA.ChgStyle(OldMatch.T2First, MatchItem.T2First,"T2st_",MatchItem.MatchId);
			NBA.ChgStyle(OldMatch.T2Second, MatchItem.T2Second,"T2nd_",MatchItem.MatchId);
			NBA.ChgStyle(OldMatch.T2Third, MatchItem.T2Third,"T2rd_",MatchItem.MatchId);
			NBA.ChgStyle(OldMatch.T2Fourth, MatchItem.T2Fourth,"T2th_",MatchItem.MatchId);
			NBA.ChgOtScore(OldMatch.T1Ot1, MatchItem.T1Ot1,"1","1",MatchItem.MatchId);
			NBA.ChgOtScore(OldMatch.T1Ot2, MatchItem.T1Ot2,"1","2",MatchItem.MatchId);
			NBA.ChgOtScore(OldMatch.T1Ot3, MatchItem.T1Ot3,"1","3",MatchItem.MatchId);
			NBA.ChgOtScore(OldMatch.T1Ot4, MatchItem.T1Ot4,"1","4",MatchItem.MatchId);
			NBA.ChgOtScore(OldMatch.T2Ot1, MatchItem.T2Ot1,"2","1",MatchItem.MatchId);
			NBA.ChgOtScore(OldMatch.T2Ot2, MatchItem.T2Ot2,"2","2",MatchItem.MatchId);
			NBA.ChgOtScore(OldMatch.T2Ot3, MatchItem.T2Ot3,"2","3",MatchItem.MatchId);
			NBA.ChgOtScore(OldMatch.T2Ot4, MatchItem.T2Ot4,"2","4",MatchItem.MatchId);



			if(OldMatch.intro != MatchItem.intro) {
			  var tr_iro = document.getElementById("intro_"+MatchItem.MatchId)
			  if(tr_iro) {
			    tr_iro.cells[0].innerHTML = MatchItem.intro;
			    tr_iro.style.display = MatchItem.intro?"":"none";
			    tr_iro.setAttribute("isshow", MatchItem.intro?"1":"0");
			  }
			}




      var Pts1=document.getElementById("T1PtsId_"+MatchItem.MatchId);
			var Reb1=document.getElementById("T1RebId_"+MatchItem.MatchId);
			var Ast1=document.getElementById("T1AstId_"+MatchItem.MatchId);
			var Pts2=document.getElementById("T2PtsId_"+MatchItem.MatchId);
			var Reb2=document.getElementById("T2RebId_"+MatchItem.MatchId);
			var Ast2=document.getElementById("T2AstId_"+MatchItem.MatchId);

		  Pts1.innerHTML=NBA.GetPlayer(MatchItem.T1PtsId)+":"+MatchItem.T1Pts;
			Pts2.innerHTML=NBA.GetPlayer(MatchItem.T2PtsId)+":"+MatchItem.T2Pts;
			Reb1.innerHTML=NBA.GetPlayer(MatchItem.T1RebId)+":"+MatchItem.T1Reb;
			Reb2.innerHTML=NBA.GetPlayer(MatchItem.T2RebId)+":"+MatchItem.T2Reb;
			Ast1.innerHTML=NBA.GetPlayer(MatchItem.T1AstId)+":"+MatchItem.T1Ast;
			Ast2.innerHTML=NBA.GetPlayer(MatchItem.T2AstId)+":"+MatchItem.T2Ast;



		 }
		 catch(e){}
		 //2秒后列表变化样式恢复

		 NBA.MatchList.Get(MatchItem.MatchId).UpdateChange(MatchItem);//更新变化数据到js公共数据列表

	}


}

NBA.ChgStyle=function(olds,s,d,id){
      if(olds != s){
			var td=document.getElementById(d+id);
			td.innerHTML=s;
			NBA.Effect.SetStyle(td);
			NBA.Styles.push({"c":td, "t":new Date()});
			}
			NBA.ReChange();
}

NBA.ChgOtScore=function(olds,s,t,d,id){
      if(olds != s){
			var td=document.getElementById("T"+t+"OT"+d+"_"+id);
			$("."+"OT"+d+"_"+id+"").css("display","");
			td.innerHTML=s;
			NBA.Effect.SetStyle(td);
			NBA.Styles.push({"c":td, "t":new Date()});
			}
      NBA.ReChange();
}
NBA.ChgBlueStyle=function(olds,s,d,id){
      if(olds != s){
  			var td=document.getElementById(d+id);
  			td.innerHTML=s;
  			NBA.Effect.SetStyle(td);
			}
			setTimeout(function(){
				NBA.Effect.ReSetColor(d,id,"blue");
			},2000);

}
NBA.ReChange=function(){
	   try{
			var now=new Date();
			while(NBA.Styles.length>0){
				if(now-NBA.Styles[0].t > 2000){
				   var obj = NBA.Styles.shift();
				   obj.c.style.color="#000000";
				   obj.c.style.fontWeight="";
			    }
				else
					break;
			}

			}
		catch(e){}
}
//===========================
NBA.Effect=new Object();
//设置比分td样式

NBA.Effect.SetStyle=function(td){
	try{
		td.style.color="#FF0000";
		td.style.fontWeight="bold";
	}catch(e){}
}

NBA.Effect.ReSetColor=function(d,id,color){
		try{
			document.getElementById(d+id).style.color=color;
			document.getElementById(d+id).style.fontWeight="";

		}
	catch(e){}
}


//==============================
NBA.Untility=new Object();
//处理数字为2位
NBA.Untility.TimeHandler=function(num){
	if(num.toString().length<2)
		return "0"+num.toString();

	return num.toString();
}
NBA.Untility.NumHandler=function(num){
	if(num==null||num.toString()=="")
		return "0";
     return num.toString();

}
NBA.Untility.Name=function(id,pid){
	if(id=pid)
		return "0";
     return num.toString();

}
NBA.SetServerDate=function(timeStamp){
    var serverDate = timeStamp ? new Date(timeStamp) : new Date(NBA.Public.TimeStamp*1000);
    if(serverDate)
	    document.getElementById("server_date").innerHTML = serverDate.getFullYear()+"-"+(serverDate.getMonth()+1)+"-"+serverDate.getDate();
}
//显示今天的日期
NBA.Untility.DisplayToday=function(){
	var Sea=new Date();

	document.write((Sea.getMonth()+1)+"月"+Sea.getDate()+"日");
}

var Notice=new Object();
Notice.RecentEvent = [];//最新赛况
Notice.HisEvent=[];
Notice.Show = function(state,score1,score2,t1,t2){
	try{
	    var chgHTML,chgTR;

	        chgHTML = "<b>"+state+"</b>&nbsp; " + t1 + " <font color=#AE0B0B>" + score1+"-"+score2 + "</font> " + t2;
	        chgTR = '<tr><td width="70"><b>'+state+'</b></td><td width="100" style="text-align:right;">'+t1+'</td><td width="50" style="text-align:center;font-color:#AE0B0B; font-weight: bold;">'+ score1+'-'+score2 +'</td><td width="100" style="text-align:left;">'+t2+'</td></tr>';
	    if(chgTR){
	        Notice.HisEvent.unshift(chgTR);
	        while(Notice.HisEvent.length > 15)
	            Notice.HisEvent.pop();

	        document.getElementById("match_event").innerHTML = '<table class="dataSheet" width="240">' + Notice.HisEvent.join("") + '</table>';
	    }
	    if(chgHTML){
	        Notice.RecentEvent.unshift(chgHTML);
	        while(Notice.RecentEvent.length > 5)
	            Notice.RecentEvent.pop();

		    $("#goal_info").fadeOut("fast", Notice.LeftTopShowIn);
		}
	}catch(e){}
}



Notice.LeftTopShowIn=function(){
   $("#goal_info").html(Notice.RecentEvent.join("&nbsp;|&nbsp;")).fadeIn("fast");
}



NBA.popMenu = new Array("  ", "简体", "繁体", "English");
NBA.ShowPopup = function(Input) {

    var div_p = document.getElementById("div_popup");
    if( div_p.style.display != "none") {
      div_p.style.display = "none";

      return;
    }
    NBA.clkbt = Input;

    var arr = new Array();
    arr.push("<table cellpadding=0 cellspacing=0 class='dataSheet lightBlue'");
    for(var i=1; i<NBA.popMenu.length; i++)
      arr.push("<tr><td style='cursor:pointer; text-align: center;' onmouseover='this.bgColor=\"#e8e8ff\";' onmouseout='this.bgColor=\"#ffffff\";' onclick='NBA.ChaSet("+i+");'>"+NBA.popMenu[i]+"</td></tr>");
    arr.push("</table>");

    var el = Input;
    var showy = 0, showx = 0;
    while(el) {
      showy += el.offsetTop;
      showx += el.offsetLeft;
	  el = el.offsetParent;
    }

    div_p.innerHTML = arr.join("");
    div_p.style.left = showx + "px";
    div_p.style.top = (showy + 20) + "px";
    div_p.style.width = "80px";
    div_p.style.display = "";



}
NBA.dmclick = function(e) {
    if(window.event)
      ee = event.srcElement;
    else
      ee = e.target;
    if(NBA.clkbt != ee) {
      var div_p = document.getElementById("div_popup");
      if(div_p.style.display != "none") {
        while(ee) {
          if(ee==div_p) break;
          ee = ee.offsetParent;
        }
        if(!ee) div_p.style.display = "none";
      }
    }
    if(NBA.olddc) NBA.olddc(e);
  }

 NBA.olddc = document.onclick;
  document.onclick =NBA.dmclick;

NBA.ChaSet=function(v){
	 NBA.Lang = (v==1?"cn":(v==2?"tr":"en"));
	 _glUtil.SetCookie("_gl_lang", NBA.Lang, new Date((new Date()).getTime()+1000*60*60*24*300));
	 NBA.Reload(NBA.Lang);
	}
NBA.setna=function(){
	//document.getElementById("bt_set_0").value= NBA.popMenu[0] + NBA.popMenu[NBA.Lang=="tr"?2:(NBA.Lang=="en"?3:1)];
  NBA.showSelLang()
}

NBA.selLang = function(l) {
  NBA.Lang = l;
  _glUtil.SetCookie("_gl_lang", NBA.Lang, new Date((new Date()).getTime()+1000*60*60*24*300));
  NBA.Reload(NBA.Lang);
}

function chgLang(ln) {
  NBA.selLang(ln);
}

NBA.showSelLang = function() {
  var s;
  if(NBA.Lang=="cn")
    s = "<font color=red><b>简体中文</b></font> | <a href=\"javascript:NBA.selLang('tr');\">繁體中文</a> | <a href=\"javascript:NBA.selLang('en');\">English</a>";
  else if(NBA.Lang=="tr")
    s = "<a href=\"javascript:NBA.selLang('cn');\">简体中文</a> | <font color=red><b>繁體中文</b></font> | <a href=\"javascript:NBA.selLang('en');\">English</a>";
  else if(NBA.Lang=="en")
    s = "<a href=\"javascript:NBA.selLang('cn');\">简体中文</a> | <a href=\"javascript:NBA.selLang('tr');\">繁體中文</a> | <font color=red><b>English</b></font>";
  document.getElementById("dv_sel_lang").innerHTML = s;
  var mmm = document.getElementById("div_ext_memo");
  if(mmm) mmm.style.display = (NBA.Lang=="en"?"":"none");
  try{_gl.setLang(NBA.Lang);} catch(e) {}
}


NBA.openStat = function(mid) {
  var url = "bks_stat.html?m="+mid+"&l="+NBA.Lang;
  window.open(url);
}
NBA.openLive = function(mid) {
  var url = "bks_livecast.html?m="+mid+"&l="+NBA.Lang;
  window.open(url);
}
NBA.openOdds = function(mid, t) {
  var url = "http://odds.gooooal.com/bks_detail.html?m="+mid+"&t="+t+"&l="+NBA.Lang;
  window.open(url, "", "left=200,top=100,width=610,height=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}
NBA.openAnalysis2 = function(mid, t) {
  var url = "http://app.gooooal.com/bksMatchAnalyseInfo.do?matchId="+mid;
  window.open(url, "", "left=150,top=120,width=770,height=550,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}
NBA.openPerson = function(pid) {
  if(pid) {
    var url = "http://app.gooooal.com/bks/player.do?pid="+pid+"&lang="+NBA.Lang;
    window.open(url, "", "left=200,top=200,width=500,height=300,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
  }
}

function openPplv(mid) {
  window.open("http://app.gooooal.com/video.do?method=showMatchLive&matchType=2&matchId="+mid);
}

$(document).ready(function(){
	 NBA.Init();
	 //_AD.Init();
	$(".ctrl_menu_link, .ctrl_menu").mouseover(function(){
	    var menu = this.getAttribute("menu");
	    if(!menu)
	        menu = this.id;

	    var menuAlign = this.getAttribute("menu_align");
	    if(!menuAlign)
	        menuAlign = "left";
	    gPopup.Show(this, menu, menuAlign);
	}).mouseout(function(){ gPopup.TryClose(); });
})


NBA.showTextAd = function() {
  if(typeof(GL_AD_text)=="undefined" || !GL_AD_text) return;
  var tb = document.getElementById("Matchs");
  if(!tb || tb.tagName!="TABLE") return;
  var i, n = 0, tr, td, adc;
  try {
    for(i=0; i<tb.rows.length; i++) {
      tr = tb.rows[i];
      if(tr.getAttribute("tr_ad")=="1") {
        tb.deleteRow(i);
        i--;
      } else if(tr.style.display!="none" && tr.cells.length==3) {
        adc = GL_AD_text[n];
        if(n>0 && adc) {
          tr = tb.insertRow(i);
          tr.setAttribute("tr_ad", "1");
          td = tr.insertCell(-1);
          td.colSpan = 3;
          td.style.textAlign = "center";
          td.bgColor = "#fffbe8";
          td.innerHTML = adc;
          i++;
        }
        n++;
      }
    }

    for(p in GL_AD_text) {
      if(parseInt(p)>=n && parseInt(p)>0) {
        adc = GL_AD_text[p];
        if(adc) {
          tr = tb.insertRow(-1);
          tr.setAttribute("tr_ad", "1");
          td = tr.insertCell(-1);
          td.colSpan = 3;
          td.style.textAlign = "center";
          td.bgColor = "#fffbe8";
          td.innerHTML = adc;
        }
      }
    }
  } catch(e) {}
}

  NBA.hideMatch = function(mid) {
    var tr_m = document.getElementById("tr"+mid);



    if(tr_m) tr_m.style.display = "none";


    var tr_1 = document.getElementById("bst_"+mid);
    if(tr_1) tr_1.style.display = "none";

    tr_1 = document.getElementById("intro_"+mid);
    if(tr_1) tr_1.style.display = "none";

    
    var bbb= document.getElementById("messagearray_"+mid)  ;
         if(bbb) bbb.style.display="none";


    NBA.hideMatch[mid] = 1;
    NBA.hideNum++;
    NBA.setHideNum();
    
    NBA.showTextAd();
  }

  NBA.showAll = function() {
    var n = 0;
    for(var m in NBA.hideMatch) {
      delete NBA.hideMatch[m];
      n++;
    }

    var i, row, arr;
      var tb_d = document.getElementById("Matchs");

      for(i=0; i<tb_d.rows.length; i++) {
        row = tb_d.rows[i];
        if(row.style.display=="none") {
          if(row.getAttribute("isshow")!="0")  row.style.display = "";
        }


      }

      NBA.hideNum = 0;
      NBA.setHideNum();

      NBA.showTextAd();
  }

    NBA.setHideNum = function() {
    var s = "<u>隐藏赛事:"+NBA.hideNum+"场</u>";
    document.getElementById("dv_hide_m").innerHTML = s;
	}
