﻿var zXml = {
    useActiveX: (typeof ActiveXObject != "undefined"),
    useXmlHttp: (typeof XMLHttpRequest != "undefined")
};

zXml.ARR_XMLHTTP_VERS = ["MSXML2.XmlHttp.6.0","MSXML2.XmlHttp.3.0"];

function zXmlHttp() {}

zXmlHttp.createRequest = function ()
{
    if (zXml.useXmlHttp)  return new XMLHttpRequest(); 

    if(zXml.useActiveX)  //IE < 7.0 = use ActiveX
    {  
        if (!zXml.XMLHTTP_VER) {
            for (var i=0; i < zXml.ARR_XMLHTTP_VERS.length; i++) {
                try {
                    new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);
                    zXml.XMLHTTP_VER = zXml.ARR_XMLHTTP_VERS[i];
                    break;
                } catch (oError) {}
            }
        }        
        if (zXml.XMLHTTP_VER) return new ActiveXObject(zXml.XMLHTTP_VER);
    } 
    alert("對不起，您的電腦不支援 XML 插件，請安裝好或升級流覽器。");
};

var m_language;
var lang;
var loaded=0, LoadTime=0,nofityTimer;
var flash_sound=Array(5);
var soundid=0;
var soundCheck=true;
var xml1_xml;
flash_sound[0] = "<embed wmode='transparent' src='http://img.zso8.com/live/nba1.swf' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' width='1' height='1'></embed>" ;
flash_sound[1] = "<embed wmode='transparent' src='http://img.zso8.com/live/shaosheng.swf' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' width='1' height='1'></embed>" ;
flash_sound[2] = "<embed wmode='transparent' src='http://img.zso8.com/live/msn.swf' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' width='1' height='1'></embed>" ;
flash_sound[3] = "<embed wmode='transparent' src='http://img.zso8.com/live/jingbao.swf' quality='high' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' width='1' height='1'></embed>" ;

var ShowLineCount = 0;
var old_xml="";
var	bg1 = "#FFFFFF";
var bg2 = "#EAF5FF";
var state=new Array(53);

state[0]="<b>中断</b>,<b>中斷</b>,<b>Pause</b>";
state[1]="<b>待定</b>,<b>待定</b>,<b>Undecided</b>";
state[2]="<b>完场</b>,<b>完場</b>,<b>FT</b>";
state[3]="未开场,未开場,";
state[4]="第1节,第1節,1st";
state[5]="第2节,第2節,2nd";
state[6]="第3节,第3節,3rd";
state[7]="第4节,第4節,4th";
state[8]="第1'OT,第1'OT,1'OT";
state[9]="第2'OT,第2'OT,2'OT";
state[10]="第3'OT,第3'OT,3'OT";
state[13]="上半场,上半場,1st";
state[14]="下半场,下半場,2nd";
state[15]="下半场,下半場,2nd";
state[53]="中场,中場,Half";

LoadLiveFile();
function LoadLiveFile()
{	xml1_xml = ""
    document.getElementById("allDate").src="http://api.zso8.com/xml/basketball.js?" + Math.floor(Math.random()*1000);
    window.setTimeout("LoadLiveFile()",3600*1000);
}
function ShowBf()
{   var sclass;
    loaded=0;
    if(window.location.href.indexOf("?")>0)
    {
	    lang=location.href.substring(window.location.href.indexOf("?")+1);
	    
        if (lang=="0" || lang=="1" || lang=="2"){ 
        	m_language=parseInt(lang);
	   		writeCookie("zsoNBAlive_SelLanguage", m_language);
	    }
	    if (lang=="NBA" || lang == "nba") sclass = "NBA";
	}
    else
    {
	    lang=getCookie("zsoNBAlive_SelLanguage");	    
	    if(lang==null) lang="1";
	    writeCookie("zsoNBAlive_SelLanguage", lang);
	}
    if (sclass=="NBA") m_language= parseInt(getCookie("zsoNBAlive_SelLanguage"));
	if(m_language==null) m_language= 1;
	//hiddenID=getCookie("zsoNBAlive_hiddenID");
	//if(hiddenID==null) hiddenID="_";

	if(sclass=="NBA")
		 MakeTable(sclass);
	else
		 MakeTable(m_language);
	MakeSclass();
	//setMatchTime();
    //hideSelMatch();
}
function MakeTable(sclass)
{	
	var matchstate;
	var html=new Array();
  	html.push("<table id='table_live' width=700 bgcolor=#d6e0ef align=center cellspacing=1 border=0><tr><td>");	
 
 
 	for(var i=1; i<=matchcount;i++)
	{
	   if(sclass=="NBA") {
		if(A[i][1]!="NBA")
		 break;
		}
		
	  try{
	  
	   		matchstate=parseInt(A[i][5]);
	   		html.push("<table width=100% border=0 align=center cellpadding=0 cellspacing=1 bgcolor=#ffffff id='table_" + A[i][0] +"' index=" + i +"><tr align=center class=trcls height=18>");
	   		html.push("<td rowspan=3  bgcolor='" + A[i][3] + "' width='7%'>");
	   		//League
			if(A[i][33]!=""){
			    if(A[i][32]=="1")
			   //html.push("<a class='a12' href='#" + A[i][33] + "' style='color:white'><u>" + A[i][1] + "</u></a><br/>");
			    html.push("<a class='a12'style='color:white'>" + A[i][1] + "</a><br/>");
    			else
    			html.push("<a class='a12'style='color:white'>" + A[i][1] + "</a><br/>");
    			 
	        }else
	        	html.push(A[i][1] + "<br/>");
	        html.push("<input type=checkbox checked onclick='hidematch(" + i + ");return false;' class=inp>");
			html.push("</td>");
			//matchtime
	   		html.push("<td  rowspan=3 width='7%'>" + A[i][4].replace("月","-").replace("日",""));
			html.push("</td>");
			//team start  
	   		html.push("<td colspan=1  width='25%'  align=left><table width='98%' border=0 align=center cellpadding=0 cellspacing=0><tr><td width='90%' class=white>");
	        	
	        //matchstate
	        if(A[i][2]=="2" && (matchstate==1 || matchstate==3)) 
				html.push("<span id=zt_" + A[i][0] + ">" + state[matchstate+12].split(",")[m_language]);//只分2节
			else	
				html.push("<span id=zt_" + A[i][0] + ">" + state[matchstate+3].split(",")[m_language]);  //4节
				
			if(matchstate==-1) score_class="td_scoreR"; else score_class="td_score";
			 //TV	
	   		tv="&nbsp;"
	   		if(A[i][29]!="")  tv="<img alt='" + A[i][29] + "' src=http://img.zso8.com/live/tv_n.gif width=12 height=14>";
	   		//playing time
	   		html.push("</span> &nbsp;<span id=jy_" + A[i][0] + ">" + A[i][6] + "</span></td><td width='10%'>" + tv + "</td></tr></table></td>");
	   		if(A[i][21]=="") A[i][21]="0";
	   		switch(m_language){
			  case 0:
				if(A[i][2]=="4")
					html.push("<td>一節</td><td>二節</td><td>三節</td><td>四節</td>");
				else
					html.push("<td>上半場</td><td>下半場</td>");
				//OT					
				for(j=1;j<=A[i][21];j++)
					html.push("<td>" + j + "'OT</td>");
				html.push("<td width='8%'>上/下</td><td width='8%'>全場</td><td width='7%'>分差</td><td width='9%'>總分</td></tr>");//<td width='6%'>数据</td></tr>");
				break;	
				case 1:
				if(A[i][2]=="4")
					html.push("<td>一節</td><td>二節</td><td>三節</td><td>四節</td>");
				else
					html.push("<td>上半場</td><td>下半場</td>");
				//OT					
				for(j=1;j<=A[i][21];j++)
					html.push("<td>" + j + "'OT</td>");
				html.push("<td width='8%'>上/下</td><td width='8%'>全場</td><td width='7%'>分差</td><td width='9%'>總分</td></tr>");//<td width='6%'>数据</td></tr>");
				break;		
			  case 2:
				if(A[i][2]=="4")
					html.push("<td>Part 1</td><td>Part 2</td><td>Part 3</td><td>Part 4</td>");
				else
					html.push("<td>Part 1</td><td>Part 2</td>");
				for(j=1;j<=A[i][21];j++)
					html.push("<td>"+ j + "'OT</td>");
				html.push("<td width='7%'>H</td><td width='8%'>T</td><td width='8%'>SD</td><td width='9%'>Total</td></tr>");//<td width='6%'>Data</td></tr>");
				break;
			}
			html.push("<tr align=center height=20 class=tr_color1 ID=tr1_" + A[i][0] + ">");
			//home
			html.push("<td align=left><a class='a12'>" + A[i][8].split(",")[m_language] + "</a></td>");
			//1'st score
			html.push("<td id=hs1_" + A[i][0] + ">" + A[i][13] + "</td>");
			//2'st score
			if(A[i][2]=="4") html.push("<td id=hs2_" + A[i][0] + ">" + A[i][15] + "</td>");
	   		//3'st score
	   		html.push("<td id=hs3_" + A[i][0] + ">" + A[i][17] + "</td>");
	   		//4'st score
	   		if(A[i][2]=="4") html.push("<td id=hs4_" + A[i][0] + ">" + A[i][19] + "</td>");
	   		//OT score
	   		for(j=1;j<=A[i][21];j++) 
				html.push("<td id=hadd" + j +  "_" + A[i][0] + ">" + A[i][20+j*2] + "</td>");
			//半場比分
			if(matchstate!=0){
				if(A[i][15]!="")  homehalfscore=parseInt(A[i][13]) + parseInt(A[i][15]);  else homehalfscore=parseInt(A[i][13]);
				if(A[i][16]!="")  guesthalfscore=parseInt(A[i][14]) + parseInt(A[i][16]); else guesthalfscore=parseInt(A[i][14]);
			}
			homehalfscore2=0;
			guesthalfscore2=0;
			if(matchstate>=3 && matchstate<10 || matchstate==-1){
				if(A[i][19]!="")  homehalfscore2=parseInt(A[i][17]) + parseInt(A[i][19]); else homehalfscore2=parseInt(A[i][17]);
				if(A[i][20]!="")  guesthalfscore2=parseInt(A[i][18]) + parseInt(A[i][20]); else guesthalfscore2=parseInt(A[i][18]);
			}
			if (matchstate>2 || matchstate==-1)
				html.push("<td><font color=blue id=hbc_" + A[i][0] + ">" + homehalfscore +  "</font><font color=#60BBFF>/</font>");
			else
				html.push("<td><font color=blue id=hbc_" + A[i][0] + "></font><font color=#60BBFF>/</font>");
			if (matchstate>=3 && matchstate<10 || matchstate==-1)
				html.push("<font color=blue id=hbc2_" + A[i][0] + ">" + homehalfscore2 +  "</font></td>");
			else
				html.push("<font color=blue id=hbc2_" + A[i][0] + "></font></td>");

			//全場比分	
			if(matchstate!=0){
				html.push("<td class=" + score_class + " id=hzf_" + A[i][0] + ">" + A[i][11] + "</td>");
				html.push("<td id=bfc_" + A[i][0] + ">半:"+ (homehalfscore-guesthalfscore) + "</td><td id=bzf_" + A[i][0] + ">半:"+ (homehalfscore+guesthalfscore) + "</td>");
			}
			else{
				html.push("<td class=td_score id=hzf_" + A[i][0] + "> </td>");
				html.push("<td id=bfc_" + A[i][0] + "></td><td id=bzf_" + A[i][0] + "></td>");
			}
			//html.push("<td><a class='a12' href='http://data.zso8.com/nba-analysis/"+ A[i][0] + ".html' target=_blank>分析</a></td></tr>");
			html.push("</tr>");
//---------------------------------------------
			html.push("<tr align=center height=20 class=tr_color1 ID=tr1_" + A[i][0] + ">");
			//guest
			html.push("<td align=left><a class='a12'>" + A[i][10].split(",")[m_language] + "</a></td>");
			
			html.push("<td id=gs1_" + A[i][0] + ">" + A[i][14] + "</td>");
			if(A[i][2]=="4") html.push("<td id=gs2_" + A[i][0] + ">" + A[i][16] + "</td>");
			html.push("<td id=gs3_" + A[i][0] + ">" + A[i][18] + "</td>");
			if(A[i][2]=="4") html.push("<td id=gs4_" + A[i][0] + ">" + A[i][20] + "</td>");
			for(j=1;j<=A[i][21];j++)
				html.push("<td id=gadd" + j +  "_" + A[i][0] + ">" + A[i][21+j*2] + "</td>");

			//半場比分
			if (matchstate>2 || matchstate==-1)//下半場或完場显示半場比分
				html.push("<td><font color=blue id=gbc_" + A[i][0] + ">"  + guesthalfscore + "</font><font color=#60BBFF>/</font>");
			else
				html.push("<td><font color=blue id=gbc_" + A[i][0] + "></font><font color=#60BBFF>/</font>");

			if ((matchstate>=3 && matchstate<10) || matchstate==-1)
				html.push("<font color=blue id=gbc2_" + A[i][0] + ">" + guesthalfscore2 +  "</font></td>");
			else
				html.push("<font color=blue id=gbc2_" + A[i][0] + "></font></td>");
	
			//全場比分					
			if(matchstate!=0)
				html.push("<td class=" + score_class + " id=gzf_" + A[i][0] + ">" + A[i][12] + "</td>");
			else
				html.push("<td class=td_score id=gzf_" + A[i][0] + "> </td>");

			if(matchstate==-1 || matchstate>2 && matchstate!=50) 
				html.push("<td id=qfc_" + A[i][0] + ">全:"+ (parseInt(A[i][11]) - parseInt(A[i][12])) +"</td><td id=qzf_" + A[i][0] + ">全:"+ (parseInt(A[i][11]) + parseInt(A[i][12])) +"</td>");
			else
				html.push("<td id=qfc_" + A[i][0] + "></td><td id=qzf_" + A[i][0] + "></td>");
			//html.push("<td><a class='a12' href='"+ A[i][0] + "' target=_blank>亚</a> <a class='a12' href='"+ A[i][0] + ".htm' target=_blank>欧</a></td></tr>");
			//html.push("<td><a class='a12' href='http://data.zso8.com/nba-panlu/"+ A[i][0] + ".html' target=_blank>盘路</a></td></tr>");
			html.push("</tr>");
			//賽事說明
			html.push("<tr height=20><td colspan=14 bgcolor=#F0F0F0 align=right><table BORDER=0 CELLPADDING=0 CELLSPACING=0 width='99%'><tr><td width=60% align=left class=explain id=sm_" + A[i][0] +">" + A[i][30] +"</td>");
			html.push("<td width=33% id=sm2_" + A[i][0] +" style='color:#666666;' align=left>" + A[i][31] +"</td>");
			if(A[i][28]=="True")
				//html.push("<td width=7% id=js_" + A[i][0] +"><a class='a12' href='http://data.zso8.com/nba-stat/" + A[i][0] + ".html' target=_blank>[统计]</a></td></tr></table></td></tr>");
				html.push("<td width=7% id=js_" + A[i][0] +"></td></tr></table></td></tr>");	
				else
				html.push("<td width=7% id=js_" + A[i][0] +"></td></tr></table></td></tr>");

			//廣告		
			if(i<adinfo1.length)
			html.push("<tr height=20><td colspan=14 bgcolor=#F0F0F0 align=center><a class='a12' href='" + adinfo1[i] + "' target=_blank><b>" + adinfo2[i] + "</b></a></td></tr>");
           
	   	html.push("</table>")
		}catch(e){}//end try
    }//end for
 	html.push("</td></tr></table>")

 	if(matchcount==0)
	    document.getElementById("live").innerHTML= "<table width=98% height=40><tr><td  align=center class=f1 bgcolor=#F0F0F0>當日沒有籃球賽事!</td></tr></table>"
 	else
 	    document.getElementById("live").innerHTML=html.join("");
 	document.getElementById("loading").style.display="none";
 	window.setTimeout("getxml()",3000);
}
var oXmlHttp = zXmlHttp.createRequest();
function getxml_1()
{	
    oXmlHttp.open("get","../xml/ch_nba.xml?" + Date.parse(new Date()),true);
    oXmlHttp.onreadystatechange = refresh;	        
    oXmlHttp.send(null);
    window.setTimeout("getxml()",3000);
}
function createXml(str){
　　if(document.all){
　　var xmlDom=new ActiveXObject("Microsoft.XMLDOM")
　　xmlDom.loadXML(str)
　　return xmlDom
　　}
　　else
　　return new DOMParser().parseFromString(str, "text/xml")
　　} 
var number1 = 1;
window.status = "籃球比分";
function getxml(){
	number1++;
 	url = "http://api.zso8.com/xml/ch_nba.xml?" + number1 ;  
	AjaxCrossDomainRequest(url, "GET", "cross_domain_form", "refresh()");	
	window.setTimeout("getxml()",3000);
	 
}

function refresh()
{	var tmp =AjaxCrossDomainResponse;
	if(xml1_xml == tmp) return;
    xml1_xml = tmp;
    var root=createXml(tmp).documentElement;
    


    //if(oXmlHttp.readyState!=4 || (oXmlHttp.status!=200 && oXmlHttp.status!=0)) return;    
    //var tmp=oXmlHttp.responseText;
    //if(tmp==xml1_xml || tmp=="") return;
    //if(xml1_xml=="")
    //{
    //    xml1_xml=tmp;
    //    return;
    //}
    //else
    //    xml1_xml=tmp;
         
    //var root=oXmlHttp.responseXML.documentElement;
    if(root.attributes[0].value!="0")
    {
		LoadLiveFile();
		return;
    }
    var C,matchid,sclassType;
   
  for(i=0;i<root.childNodes.length;i++){
    if(document.all)
  	    C=root.childNodes[i].text.split("^");
    else
        C=root.childNodes[i].textContent.split("^");//firefox
       
	matchid=C[0];
	sclassType=C[15];
	C[1]=parseInt(C[1]);
	C[2]=C[2];
	
	var tr=document.getElementById("table_" + matchid);
    if(tr==null)  continue;
	match_index=tr.attributes["index"].value;
	matchstate=A[match_index][5];
		
    //状态
	if(matchstate!=C[1]){
		A[match_index][5]=C[1];
		if(sclassType==2 && (C[1]==1 || C[1]==3))  //只分两节
			document.getElementById("zt_" + matchid).innerHTML=state[C[1]+12].split(",")[m_language];
		else
			document.getElementById("zt_" + matchid).innerHTML=state[C[1]+3].split(",")[m_language];
				
		if(C[1]==-1){
			document.getElementById("hzf_" + matchid).className="td_scoreR";
			document.getElementById("gzf_" + matchid).className="td_scoreR";
        }
    }
    
	if(C[1]>=3 || C[1]==-1){
		if(C[7]!="")
			document.getElementById("hbc_" + matchid).innerHTML=parseInt(C[5]) + parseInt(C[7]) ;
		else
			document.getElementById("hbc_" + matchid).innerHTML=parseInt(C[5]);
	
		if(C[8]!="")
			document.getElementById("gbc_" + matchid).innerHTML=parseInt(C[6]) + parseInt(C[8]);
		else
			document.getElementById("gbc_" + matchid).innerHTML=parseInt(C[6]);
	}		

	if(C[1]>=3 && C[1]<10 || C[1]==-1){
		if(C[11]!="")
			document.getElementById("hbc2_" + matchid).innerHTML=parseInt(C[9]) + parseInt(C[11]) ;
		else
			document.getElementById("hbc2_" + matchid).innerHTML=parseInt(C[9]);
	
		if(C[12]!="")
			document.getElementById("gbc2_" + matchid).innerHTML=parseInt(C[10]) + parseInt(C[12]);
		else
			document.getElementById("gbc2_" + matchid).innerHTML=parseInt(C[10]);
	}		
	//总分
	if(A[match_index][11]!=C[3]){
	    document.getElementById("hzf_" + matchid).style.backgroundColor="yellow";
	    document.getElementById("hzf_" + matchid).innerHTML=C[3];
	}
	if(A[match_index][12]!=C[4]){
		document.getElementById("gzf_" + matchid).style.backgroundColor="yellow";
		document.getElementById("gzf_" + matchid).innerHTML=C[4];
    }
    //
	if(A[match_index][11]!=C[3] || A[match_index][12]!=C[4]){
        if(soundCheck && tr.style.display=="")	document.getElementById("sound").innerHTML = flash_sound[soundid];
	    window.setTimeout("timecolors("+matchid+")",15000);
    	A[match_index][11]=C[3];
	    A[match_index][12]=C[4];		
	    if((A[match_index][5]>=3 && A[match_index][5]!=50) || A[match_index][5]==-1){ //下半场或完场
		    document.getElementById("qfc_" + matchid).innerHTML="全:" + (A[match_index][11]-A[match_index][12]);
		    document.getElementById("qzf_" + matchid).innerHTML="全:" + (parseInt(A[match_index][11])+parseInt(A[match_index][12]));
	    }
	    else{
       	    document.getElementById("bfc_" + matchid).innerHTML="半:" + (A[match_index][11]-A[match_index][12]);
	        document.getElementById("bzf_" + matchid).innerHTML="半:" + (parseInt(A[match_index][11])+parseInt(A[match_index][12]));
	    }
    }
		
	//节余
	if(C[2]=="0:0" || C[2]=="0.0" || C[2]=="0"){
		if(C[1]==-1 || C[1]==50)  //完场 中场
			document.getElementById("jy_" + matchid).innerHTML="";
		else
			document.getElementById("jy_" + matchid).innerHTML="完";
	}
	else
		document.getElementById("jy_" + matchid).innerHTML=C[2];

	//分节比分
	if(A[match_index][13]!=C[5]){
   	    document.getElementById("hs1_" + matchid).innerHTML="<span style='color:red'>" + C[5] +"</span>";
        A[match_index][13]=C[5];
   	    window.setTimeout("scorecolors('hs1_" + matchid+"')",15000);
    }
	if(A[match_index][14]!=C[6]){
   	    document.getElementById("gs1_" + matchid).innerHTML="<span style='color:red'>" + C[6] +"</span>";
        A[match_index][14]=C[6];
   	    window.setTimeout("scorecolors('gs1_" + matchid+"')",15000);
    }
	
    if(A[match_index][2]=="4" && A[match_index][15]!=C[7]){
        document.getElementById("hs2_" + matchid).innerHTML="<span style='color:red'>" + C[7] +"</span>";
        A[match_index][15]=C[7];
   	    window.setTimeout("scorecolors('hs2_" + matchid+"')",15000);
    }
    if(A[match_index][2]=="4" && A[match_index][16]!=C[8]){
   	    document.getElementById("gs2_" + matchid).innerHTML="<span style='color:red'>" + C[8] +"</span>";
        A[match_index][16]=C[8];
        window.setTimeout("scorecolors('gs2_" + matchid+"')",15000);
	}
	
	if(A[match_index][17]!=C[9]){
   	    document.getElementById("hs3_" + matchid).innerHTML="<span style='color:red'>" + C[9] +"</span>";
        A[match_index][17]=C[9];
   	    window.setTimeout("scorecolors('hs3_" + matchid+"')",15000);
    }
	if(A[match_index][18]!=C[10]){
   	    document.getElementById("gs3_" + matchid).innerHTML="<span style='color:red'>" + C[10] +"</span>";
        A[match_index][18]=C[10];
   	    window.setTimeout("scorecolors('gs3_" + matchid+"')",15000);
    }
   
    if(A[match_index][2]=="4" && A[match_index][19]!=C[11]){
        document.getElementById("hs4_" + matchid).innerHTML="<span style='color:red'>" + C[11] +"</span>";
        A[match_index][19]=C[11];
   	    window.setTimeout("scorecolors('hs4_" + matchid+"')",15000);
    }
    if(A[match_index][2]=="4" && A[match_index][20]!=C[12]){
   	    document.getElementById("gs4_" + matchid).innerHTML="<span style='color:red'>" + C[12] +"</span>";
        A[match_index][20]=C[12];
        window.setTimeout("scorecolors('gs4_" + matchid+"')",15000);
	}

    if(A[match_index][21]!=C[13]){
        A[match_index][21]=C[13]
		A[match_index][22]=C[16];
		A[match_index][23]=C[17];
		A[match_index][24]=C[18];
		A[match_index][25]=C[19];
		A[match_index][26]=C[20];
		A[match_index][27]=C[21];
	    A[match_index][30]=C[14];
	    A[match_index][31]=C[22];    
		html=new Array();
		makeTable(match_index);
		tr.outerHTML=html.join("");
		continue;
    }
    if(C[13]>=1){ //第1加时
		if(A[match_index][22]!=C[16]) document.getElementById("hadd1_" + matchid).innerHTML=C[16];
		if(A[match_index][23]!=C[17]) document.getElementById("gadd1_" + matchid).innerHTML=C[17];
		A[match_index][22]=C[16];
		A[match_index][23]=C[17];
	}
	if(C[13]>=2){ //第2加时
		if(A[match_index][24]!=C[18]) document.getElementById("hadd2_" + matchid).innerHTML=C[18];
		if(A[match_index][25]!=C[19]) document.getElementById("gadd2_" + matchid).innerHTML=C[19];
		A[match_index][24]=C[18];
		A[match_index][25]=C[19];
	}
	if(C[13]>=3){ //第3加时
		if(A[match_index][26]!=C[20]) document.getElementById("hadd3_" + matchid).innerHTML=C[20];
		if(A[match_index][27]!=C[21]) document.getElementById("gadd3_" + matchid).innerHTML=C[21];
		A[match_index][26]=C[20];
		A[match_index][27]=C[21];
	}

	if(A[match_index][30]!=C[14]){
	    document.getElementById("sm_" + matchid).innerHTML= C[14];//直播
	    A[match_index][30]=C[14];
	}
	if(A[match_index][31]!=C[22]){
	    document.getElementById("sm2_" + matchid).innerHTML=C[22];//说明
	    A[match_index][31]=C[22];
	}

	//if(C[23]=="True")
		//document.getElementById("js_" + matchid).innerHTML= "<a class='a12' href='http://data.zso8.com/nba-stat/" + matchid + ".html' target=_blank>[统计]</a>";

  }
}
function MakeSclass()
{
	var st;
	var leaguehtml=new Array();
	leaguehtml.push("<TABLE WIDTH='100%' BORDER=0 CELLPADDING=0 CELLSPACING=0 id='checkboxleague'><tr>");
	for(var i=1;i<=sclasscount;i++)
	{	
		leaguehtml.push("<td width=22%><input onclick=\"CheckLeague('" + i + "','" + B[i] + "')\" checked type=checkbox id='checkboxleague_" + i + "' value='" + B[i] + "'><label style='cursor:pointer' for='checkboxleague_" + i + "'>" + B[i] + "</label></td>");
		if(B[i][3]=="1")
		leaguehtml.push("<td width=1%> </td><td width=1%> </td><td width=1%> </td>");	
    	else
		    leaguehtml.push("<td width=1%> </td><td width=1%> </td><td width=1%> </td>");

		if (i % 4==0) leaguehtml.push( "</tr><tr>");
    }
    leaguehtml.push("</tr></TABLE>");
	document.getElementById("myleague").innerHTML=leaguehtml.join("");
}
//选联赛
function CheckLeague(i,name){
	try{     
	    var hh=parseInt(document.getElementById("hiddencount").innerHTML);
        if(document.getElementById("checkboxleague_" + i).checked){
           for(var j=1;j<=matchcount;j++){
              if(A[j][1]==name){
                 document.getElementById("table_" + A[j][0]).style.display="";
			     hh=hh-1;
              }
           } 
        } 
        else{
           for(var j=1;j<=matchcount;j++){
              if(A[j][1]==name){
                 document.getElementById("table_" + A[j][0]).style.display="none";
			     hh=hh+1;
              }
           } 
       }
       document.getElementById("hiddencount").innerHTML=hh;
    }
    catch(e){}    
}
//全选
function ShowAllMatch(){
	try{ 
        for(var i=1;i<=sclasscount;i++)
            document.getElementById("checkboxleague_" + i).checked=true;  
        //alert("OK");         
        for(var j=1;j<=matchcount;j++)
             document.getElementById("table_" + A[j][0]).style.display = "";      
        document.getElementById("hiddencount").innerHTML = "0" ;
    }
    catch(e){}    
}
//反选
function SelectOtherLeague(){
	try{ 
	    var hh=0;
        for(var i=1;i<=sclasscount;i++){
		    var sclassname=document.getElementById("checkboxleague_" + i).value;
		   // alert(sclassname);
		    if(document.getElementById("checkboxleague_" + i).checked){
			    document.getElementById("checkboxleague_" + i).checked=false;
			    for(var j=1;j<=matchcount;j++){
                    if(A[j][1]==sclassname){
                        document.getElementById("table_" + A[j][0]).style.display="none";
			            hh=hh+1;
			        }
                }
            }
            else{
               document.getElementById("checkboxleague_" + i).checked=true;
               for(var j=1;j<=matchcount;j++){
                  if(A[j][1]==sclassname)  document.getElementById("table_" + A[j][0]).style.display="";
               }
            }
        }
        document.getElementById("hiddencount").innerHTML=hh;
    }
    catch(e){}    
}
function ShowMatchByMatchState(n){
	try{
	    var hh=0;
        if(n==0)
            ShowAllMatch();
        else{
            for(var i=1;i<=matchcount;i++){
                if(n==1 && parseInt(A[i][5])>0  || n==2 && parseInt(A[i][5])==-1   || n==3 && parseInt(A[i][5])==0)
		    	    document.getElementById("table_" + A[i][0]).style.display="";
		        else{
			        document.getElementById("table_" + A[i][0]).style.display="none";
			        hh=hh+1;
		        }
            }
	    } 
	    document.getElementById("hiddencount").innerHTML=hh;
    }
    catch(e){}    
}
function hidematch(i){
    document.getElementById("table_" + A[i][0]).style.display="none";
	document.getElementById("hiddencount").innerHTML=parseInt(document.getElementById("hiddencount").innerHTML)+1;
}
function scorecolors(id){
    if(document.all)
  	    document.getElementById(id).innerHTML=document.getElementById(id).innerText;
    else
        document.getElementById(id).innerHTML=document.getElementById(id).textContent;
}
function timecolors(matchid){
  try{
    document.getElementById("hzf_" + matchid).style.backgroundColor="";
    document.getElementById("gzf_" + matchid).style.backgroundColor="";
  }
  catch(e){}
}
function CheckSound(n){
	soundid=n;
	document.getElementById("sound").innerHTML = flash_sound[soundid];
}

