

var oXmlHttp = zXmlHttp.createRequest();
var oddsHttp = zXmlHttp.createRequest();

var i,j,xml1_xml,odds_xml,sclass;
var kk,matchcount,matchdata,sclasscount;
var output,m_language;
var soundCheck=true;
//var ScoreFile="NBA\\en.xml"

////<%
////if (seldate.ToShortDateString() != DateTime.Now.AddHours(-16).ToShortDateString())   Response.Write("ScoreFile=\"NBA\\\\Score.aspx?date=" + seldate.ToShortDateString() +"\"");
////%>

var flash_Goal = "<object clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='1' height='1' id='image1'><param name='movie' value='nba/sound.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><param name='menu' value='false'></object>"
var html;

var state=new Array(55);
state[0]="<font color=blue>Pause</font>";
state[1]="<font color=blue>Undecided</font>";
state[2]="<font color=black>Finished</font>";
state[3]="";
state[4]="1st Qtr";
state[5]="2nd Qtr";
state[6]="3rd Qtr";
state[7]="4th Qtr";
state[8]="1OT";
state[9]="2OT";
state[10]="3OT";
state[13]="1st Qtr";
state[15]="2nd Qtr";
state[53]="Hafe Time";
var week= new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");



function makeTable(i)
{
var txtstate=0;
	matchstate=parseInt(matchdata[i][5]);
	html.push("<table width=100% border=0 align=center cellpadding=2 cellspacing=1 id='table_" + matchdata[i][0] +"' index=" + i +" style='margin-bottom:-1px;' bgcolor=#DBDBDB><tr align=center class='Leaguestitle'><td colspan=2 width='21%' style='text-align:left;'><a href='javascript:winCheck(" + i + ")' title='Open/Close prompt windows'><img src='images/close_win.gif' id='win_" + matchdata[i][0] + "'></a> " +  showDate(matchdata[i][4]) + " &nbsp; ");
	if(matchdata[i][2]=="2" && (matchstate==1 || matchstate==3)) //only section 2
	{
		html.push("<span id=zt_" + matchdata[i][0] + " style='color=blue;'>" + state[matchstate+12] +"</span>");
		txtstate=matchstate+12;
		}
	else
	{
		html.push("<span id=zt_" + matchdata[i][0] + " style='color=blue;'>" + state[matchstate+3] +"</span>");
		txtstate=matchstate+3;
		}
	
	html.push(" &nbsp;<span id=jy_" + matchdata[i][0] + ">" + matchdata[i][6] + "</span></td>");
	
	if(matchstate==-1) score_class="red"; else score_class="blue";
	if(matchdata[i][21]=="") matchdata[i][21]=0;
	else matchdata[i][21]=parseInt(matchdata[i][21]);
    if(matchdata[i][2]=="4")
		html.push("<td width='" + Math.floor(28/(matchdata[i][21]+4)) +"%'>1</td><td width='" + Math.floor(28/(matchdata[i][21]+4)) +"%'>2</td><td width='" + Math.floor(28/(matchdata[i][21]+4)) +"%'>3</td><td width='" + Math.floor(28/(matchdata[i][21]+4)) +"%'>4</td>");
	else
		html.push("<td>Part 1</td><td>Part 2</td>");
	for(j=1;j<=matchdata[i][21];j++)
	    html.push("<td width='" + Math.floor(28/(matchdata[i][21]+4)) +"%'>"+ j + "'OT</td>");
	html.push("<td width='7%'>T</td><td width='6%'>HT</td><td width='6%'>SD</td><td width='6%'>Total</td><td width='5%'>1x2</td><td width='8%'>Handicap</td><td width='9%'>Over/Under</td><td width='4%'>Data</td></tr>");
	
	html.push("<tr align=center class=b1 ID=tr1_" + matchdata[i][0] + ">");
	html.push("<td rowspan=2 width='2%'><img src='images/lclose.gif' width='7' height='7' onclick='hidematch(" + i + ");' style='cursor:pointer;'/></td>");
	html.push("<td style='text-align:left'><a href='javascript:' onclick='Team("+matchdata[i][7] +")'>" + matchdata[i][8] + "</a></td>");
	
	html.push("<td id=hs1_" + matchdata[i][0] + ">" + matchdata[i][13] + "</td>");
	if(matchdata[i][2]=="4") html.push("<td id=hs2_" + matchdata[i][0] + ">" + matchdata[i][15] + "</td>");
	html.push("<td id=hs3_" + matchdata[i][0] + ">" + matchdata[i][17] + "</td>");
	if(matchdata[i][2]=="4") html.push("<td id=hs4_" + matchdata[i][0] + ">" + matchdata[i][19] + "</td>");
	for(j=1;j<=matchdata[i][21];j++) 
		html.push("<td id=hadd" + j +  "_" + matchdata[i][0] + ">" + matchdata[i][20+j*2] + "</td>");
	
	//hf
	if(matchstate!=0){
		if(matchdata[i][15]!="")  homehalfscore=parseInt(matchdata[i][13]) + parseInt(matchdata[i][15]);  else homehalfscore=parseInt(matchdata[i][13]);
		if(matchdata[i][16]!="")  guesthalfscore=parseInt(matchdata[i][14]) + parseInt(matchdata[i][16]); else guesthalfscore=parseInt(matchdata[i][14]);
	}
	homehalfscore2=0;
	guesthalfscore2=0;
	if(matchstate>=3 && matchstate<10 || matchstate==-1){
		if(matchdata[i][19]!="")  homehalfscore2=parseInt(matchdata[i][17]) + parseInt(matchdata[i][19]); else homehalfscore2=parseInt(matchdata[i][17]);
		if(matchdata[i][20]!="")  guesthalfscore2=parseInt(matchdata[i][18]) + parseInt(matchdata[i][20]); else guesthalfscore2=parseInt(matchdata[i][18]);
	}
	
	if(matchstate!=0)
		html.push("<td class=" + score_class + " id=hzf_" + matchdata[i][0] + ">" + matchdata[i][11] + "</td>");
	else
		html.push("<td class=" + score_class + " id=hzf_" + matchdata[i][0] + "> </td>");

	if (matchstate>2 || matchstate==-1)
		html.push("<td><font id=hbc_" + matchdata[i][0] + ">" + homehalfscore +  "</font> / ");
	else
		html.push("<td><font id=hbc_" + matchdata[i][0] + "></font> / ");

	if (matchstate>=3 && matchstate<10 || matchstate==-1)
		html.push("<font id=hbc2_" + matchdata[i][0] + ">" + homehalfscore2 +  "</font></td>");
	else
		html.push("<font id=hbc2_" + matchdata[i][0] + "></font></td>");

	if(matchstate!=0){
		html.push("<td id=bfc_" + matchdata[i][0] + ">H:"+ (homehalfscore-guesthalfscore) + "</td><td id=bzf_" + matchdata[i][0] + ">H:"+ (homehalfscore+guesthalfscore) + "</td>");
	}
	else{
		html.push("<td id=bfc_" + matchdata[i][0] + "></td><td id=bzf_" + matchdata[i][0] + "></td>");
	}
	html.push("<td id='hw_" + matchdata[i][0] +"' class=odds1>"+ matchdata[i][35].toString().split(',')[0]+"</td><td id='hl_" + matchdata[i][0] +"'  style='text-align:right'></td><td id='ht_" + matchdata[i][0] +"' style='text-align:right'></td>")
	html.push("<td><a href='nbaAnalysis/"+ matchdata[i][0] + ".html' target=_blank title='Match analysis'><img src='images/t2.gif'></a></td></tr>");
	
//---------------------------------------------

	html.push("<tr align=center class=b1 ID=tr1_" + matchdata[i][0] + ">");
	html.push("<td style='text-align:left'><a href='javascript:' onclick='Team("+matchdata[i][9] +")'>" + matchdata[i][10] + "</a></td>");
		
	html.push("<td id=gs1_" + matchdata[i][0] + ">" + matchdata[i][14] + "</td>");
	if(matchdata[i][2]=="4") html.push("<td id=gs2_" + matchdata[i][0] + ">" + matchdata[i][16] + "</td>");
	html.push("<td id=gs3_" + matchdata[i][0] + ">" + matchdata[i][18] + "</td>");
	if(matchdata[i][2]=="4") html.push("<td id=gs4_" + matchdata[i][0] + ">" + matchdata[i][20] + "</td>");
	for(j=1;j<=matchdata[i][21];j++)
		html.push("<td id=gadd" + j +  "_" + matchdata[i][0] + ">" + matchdata[i][21+j*2] + "</td>");

	//ft			
	if(matchstate!=0)
		html.push("<td class=" + score_class + " id=gzf_" + matchdata[i][0] + ">" + matchdata[i][12] + "</td>");
	else
		html.push("<td class=" + score_class + " id=gzf_" + matchdata[i][0] + "> </td>");

	//ht
	if (matchstate>2 || matchstate==-1)
		html.push("<td><font id=gbc_" + matchdata[i][0] + ">"  + guesthalfscore + "</font> / ");
	else
		html.push("<td><font id=gbc_" + matchdata[i][0] + "></font> / ");

	if ((matchstate>=3 && matchstate<10) || matchstate==-1)
		html.push("<font id=gbc2_" + matchdata[i][0] + ">" + guesthalfscore2 +  "</font></td>");
	else
		html.push("<font id=gbc2_" + matchdata[i][0] + "></font></td>");
	

	if(matchstate==-1 || matchstate>2 && matchstate!=50) 
		html.push("<td id=qfc_" + matchdata[i][0] + ">F:"+ (parseInt(matchdata[i][11]) - parseInt(matchdata[i][12])) +"</td><td id=qzf_" + matchdata[i][0] + ">F:"+ (parseInt(matchdata[i][11]) + parseInt(matchdata[i][12])) +"</td>");
	else
		html.push("<td id=qfc_" + matchdata[i][0] + "></td><td id=qzf_" + matchdata[i][0] + "></td>");

	html.push("<td id='gw_" + matchdata[i][0] +"' class=odds1>"+ matchdata[i][35].toString().split(',')[1]+"</td><td id='gl_" + matchdata[i][0] +"' style='text-align:right'></td><td id='gt_" + matchdata[i][0] +"' style='text-align:right'></td>")
	html.push("<td><a href='OddsCompBasket.aspx?id="+ matchdata[i][0] + "' target=_blank>Odds</a></tr>");

	//explain
	html.push("<tr height=20><td colspan=18 class=b1><table BORDER=0 CELLPADDING=0 CELLSPACING=0 width='99%'><tr><td style='text-align:left;color:#000088;padding-left:10px;' width=60% id=sm_" + matchdata[i][0] +">" + (matchdata[i][29]==""?"":("<a href='/textEn/"+matchdata[i][0]+"En.html' target='_blank' style='color:blue;'>" + (txtstate==2?"Play-By-Play":matchdata[i][29])+"</a>"))+"</td>");
	html.push("<td width=34% id=sm2_" + matchdata[i][0] +">" + (matchdata[i][34]==""?"":" " + matchdata[i][34])+"</td>");
	if(matchdata[i][28]=="True")
		html.push("<td width=6% id=js_" + matchdata[i][0] +"><a href='http://info.nowgoal.com/Basketball/League/Schedule/Statistics.aspx?id=" + matchdata[i][0] + "' target=_blank>[Boxscore]</a></td></tr></table></td></tr>");
	else
		html.push("<td width=6% id=js_" + matchdata[i][0] +"></td></tr></table></td></tr>");
	
	html.push("</table>");
}


function loadScore(){
	var homehalfscore,guesthalfscore,homehalfscore2,guesthalfscore2,leagueIndex=0,league="";
	xml1_xml="";
	html=new Array();
	if(ScoreFile.indexOf("?")>0)
	    oXmlHttp.open("get",ScoreFile +"&t=" +Date.parse(new Date()),false);
	else
	    oXmlHttp.open("get",ScoreFile +"?t=" +Date.parse(new Date()),false);
	 oXmlHttp.send(null);
    var root=oXmlHttp.responseXML.documentElement.childNodes[0];
	matchcount=root.childNodes.length;
	matchdata=new Array(matchcount);
	for(i=0;i<matchcount;i++){
        if(document.all)
    	    matchdata[i]=root.childNodes[i].childNodes[0].text.split("^");
        else
            matchdata[i]=root.childNodes[i].childNodes[0].textContent.split("^");

        if(league!=matchdata[i][33])
        {
            league=matchdata[i][33];            
		    var t = matchdata[i][4].split(",");
		    var t2 = new Date(t[0],eval(t[1]),t[2],t[3],t[4],t[5]);
		    t2 = new Date(Date.UTC(t2.getFullYear(),t2.getMonth(),t2.getDate(),t2.getHours(),t2.getMinutes(),t2.getSeconds()));             
            html.push("<table width=100% border=0 cellpadding=0 cellspacing=0 class='scoretitle'><tr id='table_"+ leagueIndex +"'><td><span class='l1'><b><font color=black>" +league +"</font></b> &nbsp; " + (t2.getMonth()+1) +"/" + t2.getDate() +"/" + t2.getFullYear()+ " ("+ week[t2.getDay()] +")</span> <span class='l2'></span></td></tr></table>");
//	        if(matchdata[i][31]!=""){
//	            if(matchdata[i][30]=="1")
//	   	            html.push("<a href='http://info.NowGoal.com/Basketball/League/Default.aspx#http://info.NowGoal.com/Basketball/League/Schedule/" + matchdata[i][31] + "/' target=_blank><img src='images/Schedule.gif'/></a> ");
//    	        else
//		            html.push("<a href='http://info.NowGoal.com/Basketball/League/Default.aspx#http://info.NowGoal.com/Basketball/cup/Schedule/" + matchdata[i][31] + "/' target=_blank><img src='images/Schedule.gif'/></a> ");
//	        }
//	        html.push("<a href=\"javascript:HiddenLeague(" + leagueIndex + ",false,'"+matchdata[i][1]+"')\" id='collapse"+ leagueIndex+"'><img src='images/collapse.gif'/></a><a href=\"javascript:HiddenLeague(" + leagueIndex + ",true,'"+matchdata[i][1]+"')\" id='expand"+ leagueIndex+"' style='display:none;'><img src='images/expand.gif'/></a><a href=\"javascript:CloseLeague(" + leagueIndex + ",'"+matchdata[i][1]+"')\"><img src='images/closes.gif'/></a></span></td></tr></table>");
            leagueIndex++;
        }

         makeTable(i);
	}
	if(matchcount==0)
	    document.getElementById("live").innerHTML= "<table width=98% height=40><tr><td  align=center class=f1 bgcolor=#F0F0F0>No Match Today!</td></tr></table>"
 	else
 	    document.getElementById("live").innerHTML=html.join("");

    //league
    if(document.all)
  	    sclass=oXmlHttp.responseXML.documentElement.childNodes[1].text.split(",");
    else
        sclass=oXmlHttp.responseXML.documentElement.childNodes[1].textContent.split(",");
    sclasscount=sclass.length-1;

    var leaguehtml="<table width='100%' border=0 cellpadding=0 cellspacing=0><tr>";
    for(i=0;i<sclasscount;i++){
	    leaguehtml+="<td><input onclick=\"CheckLeague(" + i + ",'" + sclass[i] + "')\" checked type=checkbox id='checkboxleague_" + i + "' value='" + sclass[i] + "'><label style='cursor:hand' for='checkboxleague_" + i + "'>" + sclass[i] + "</label></td>";
		if (i % 2==1) leaguehtml+="</tr><tr>"
	}
    leaguehtml+="</tr></table>";
//    document.getElementById("sclass").innerHTML=leaguehtml;
}

function getoddsxml()
{
    oddsHttp.open("get",oddsUrl+"&" + Date.parse(new Date()),true);
    oddsHttp.onreadystatechange = oddsRefresh;	        
    oddsHttp.send(null);
    window.setTimeout("getoddsxml()",60000);
}

function oddsRefresh()
{
    if(oddsHttp.readyState!=4 || (oddsHttp.status!=200 && oddsHttp.status!=0)) return;    
    var tmp=oddsHttp.responseText;
    if(tmp==odds_xml || tmp=="") return;
    odds_xml=tmp;
    var root=oddsHttp.responseXML.documentElement;   
    var C,matchid;
    for(i=0;i<root.childNodes.length;i++){    
        if(document.all)
  	        C=root.childNodes[i].text.split(",");
        else
            C=root.childNodes[i].textContent.split(",");
	    matchid=C[0];
    	
	    var tr=document.getElementById("table_" + matchid);
        if(tr==null)  continue;
        
//        document.getElementById("hw_" + matchid).innerHTML=C[7];
//        document.getElementById("gw_" + matchid).innerHTML=C[8];
        if(C[1]!=""){
            if(parseFloat(C[2])>0){
                document.getElementById("hl_" + matchid).innerHTML="<span class=odds2>"+C[2] +"</span>&nbsp; <span class=odds1>" +C[1]+"</span>&nbsp;";
                document.getElementById("gl_" + matchid).innerHTML="<span class=odds1>"+C[3]+"</span>&nbsp;";
            }
            else{
                document.getElementById("hl_" + matchid).innerHTML="<span class=odds1>"+C[1]+"</span>&nbsp;";
                document.getElementById("gl_" + matchid).innerHTML="<span class=odds2>"+(-C[2]) +"</span>&nbsp; <span class=odds1>"+C[3]+"</span>&nbsp;";
            }
        }
        if(C[4]!=""){
            document.getElementById("ht_" + matchid).innerHTML="O:<span class=odds2>"+ C[5] +"</span> <span class=odds1>" +C[4]+"</span>&nbsp;";
            document.getElementById("gt_" + matchid).innerHTML="U:<span class=odds2>"+ C[5] +"</span> <span class=odds1>" +C[6]+"</span>&nbsp;";
        }
    }
}		
		
		
function getxml()
{
    oXmlHttp.open("get","nba/change_en.xml?" + Date.parse(new Date()),true);
    oXmlHttp.onreadystatechange = refresh;	        
    oXmlHttp.send(null);
    window.setTimeout("getxml()",3000);
}

function refresh()
{
    if(oXmlHttp.readyState!=4 || (oXmlHttp.status!=200 && oXmlHttp.status!=0)) return;    
    var winStr="";
    var matchNum=0;
    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")
    {
		loadScore();
		return;
    }
    var C,matchid,sclassType;
  for(i=0;i<root.childNodes.length;i++){
    var scoreChange=false;
    var score="";
    if(document.all)
  	    C=root.childNodes[i].text.split("^");
    else
        C=root.childNodes[i].textContent.split("^");
	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=matchdata[match_index][5];
		 var txtstate=0;
    //state
	if(matchstate!=C[1]){
		matchdata[match_index][5]=C[1];
		if(sclassType==2 && (C[1]==1 || C[1]==3))  //only 2 part
		{
			document.getElementById("zt_" + matchid).innerHTML=state[C[1]+12];
			txtstate=C[1]+12;
			}
		else
		{
			document.getElementById("zt_" + matchid).innerHTML=state[C[1]+3];
			txtstate=C[1]+3;
			}
				
		if(C[1]==-1){
			document.getElementById("hzf_" + matchid).className="red";
			document.getElementById("gzf_" + matchid).className="red";
        }
    }
    
	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]);
	}		
	//score
	if(matchdata[match_index][11]!=C[3]){
	    document.getElementById("hzf_" + matchid).style.backgroundColor="yellow";
	    document.getElementById("hzf_" + matchid).innerHTML=C[3];
	    score="<font color=red>" + C[3] +"</font>";
	    scoreChange=true;
	}
	else score=C[3];	
	if(matchdata[match_index][12]!=C[4]){
		document.getElementById("gzf_" + matchid).style.backgroundColor="yellow";
		document.getElementById("gzf_" + matchid).innerHTML=C[4];
	    score+="-<font color=red>" + C[4] +"</font>";
	    scoreChange=true;
    }
    else score+="-" + C[4];

	if(matchdata[match_index][11]!=C[3] || matchdata[match_index][12]!=C[4]){
        if(soundCheck && tr.style.display=="")	document.getElementById("sound").innerHTML=flash_Goal;
	    window.setTimeout("timecolors("+matchid+")",15000);
    	matchdata[match_index][11]=C[3];
	    matchdata[match_index][12]=C[4];		
	    if((matchdata[match_index][5]>=3 && matchdata[match_index][5]!=50) || matchdata[match_index][5]==-1){ //下半场或完场
		    document.getElementById("qfc_" + matchid).innerHTML="F:" + (matchdata[match_index][11]-matchdata[match_index][12]);
		    document.getElementById("qzf_" + matchid).innerHTML="F:" + (parseInt(matchdata[match_index][11])+parseInt(matchdata[match_index][12]));
	    }
	    else{
       	    document.getElementById("bfc_" + matchid).innerHTML="H:" + (matchdata[match_index][11]-matchdata[match_index][12]);
	        document.getElementById("bzf_" + matchid).innerHTML="H:" + (parseInt(matchdata[match_index][11])+parseInt(matchdata[match_index][12]));
	    }
    }
		
	//
	if(C[2]=="0:0" || C[2]=="0.0" || C[2]=="0"){
		if(C[1]==-1 || C[1]==50)  //ft ht
			document.getElementById("jy_" + matchid).innerHTML="";
		else
			document.getElementById("jy_" + matchid).innerHTML="Over";
	}
	else
		document.getElementById("jy_" + matchid).innerHTML=C[2];

	//score 1 2 3 4
	if(matchdata[match_index][13]!=C[5]){
   	    document.getElementById("hs1_" + matchid).innerHTML="<span style='color:red'>" + C[5] +"</span>";
        matchdata[match_index][13]=C[5];
   	    window.setTimeout("scorecolors('hs1_" + matchid+"')",15000);
    }
	if(matchdata[match_index][14]!=C[6]){
   	    document.getElementById("gs1_" + matchid).innerHTML="<span style='color:red'>" + C[6] +"</span>";
        matchdata[match_index][14]=C[6];
   	    window.setTimeout("scorecolors('gs1_" + matchid+"')",15000);
    }
	
    if(matchdata[match_index][2]=="4" && matchdata[match_index][15]!=C[7]){
        document.getElementById("hs2_" + matchid).innerHTML="<span style='color:red'>" + C[7] +"</span>";
        matchdata[match_index][15]=C[7];
   	    window.setTimeout("scorecolors('hs2_" + matchid+"')",15000);
    }
    if(matchdata[match_index][2]=="4" && matchdata[match_index][16]!=C[8]){
   	    document.getElementById("gs2_" + matchid).innerHTML="<span style='color:red'>" + C[8] +"</span>";
        matchdata[match_index][16]=C[8];
        window.setTimeout("scorecolors('gs2_" + matchid+"')",15000);
	}
	
	if(matchdata[match_index][17]!=C[9]){
   	    document.getElementById("hs3_" + matchid).innerHTML="<span style='color:red'>" + C[9] +"</span>";
        matchdata[match_index][17]=C[9];
   	    window.setTimeout("scorecolors('hs3_" + matchid+"')",15000);
    }
	if(matchdata[match_index][18]!=C[10]){
   	    document.getElementById("gs3_" + matchid).innerHTML="<span style='color:red'>" + C[10] +"</span>";
        matchdata[match_index][18]=C[10];
   	    window.setTimeout("scorecolors('gs3_" + matchid+"')",15000);
    }
   
    if(matchdata[match_index][2]=="4" && matchdata[match_index][19]!=C[11]){
        document.getElementById("hs4_" + matchid).innerHTML="<span style='color:red'>" + C[11] +"</span>";
        matchdata[match_index][19]=C[11];
   	    window.setTimeout("scorecolors('hs4_" + matchid+"')",15000);
    }
    if(matchdata[match_index][2]=="4" && matchdata[match_index][20]!=C[12]){
   	    document.getElementById("gs4_" + matchid).innerHTML="<span style='color:red'>" + C[12] +"</span>";
        matchdata[match_index][20]=C[12];
        window.setTimeout("scorecolors('gs4_" + matchid+"')",15000);
	}

    if(matchdata[match_index][21]!=C[13]){
        matchdata[match_index][21]=C[13]
		matchdata[match_index][22]=C[16];
		matchdata[match_index][23]=C[17];
		matchdata[match_index][24]=C[18];
		matchdata[match_index][25]=C[19];
		matchdata[match_index][26]=C[20];
		matchdata[match_index][27]=C[21];
	    matchdata[match_index][30]=C[14];
	    matchdata[match_index][31]=C[22];    
		html=new Array();
		makeTable(match_index);
		tr.outerHTML=html.join("");
		continue;
    }
    if(C[13]>=1){ //1ot
		if(matchdata[match_index][22]!=C[16]) document.getElementById("hadd1_" + matchid).innerHTML=C[16];
		if(matchdata[match_index][23]!=C[17]) document.getElementById("gadd1_" + matchid).innerHTML=C[17];
		matchdata[match_index][22]=C[16];
		matchdata[match_index][23]=C[17];
	}
	if(C[13]>=2){ //2ot
		if(matchdata[match_index][24]!=C[18]) document.getElementById("hadd2_" + matchid).innerHTML=C[18];
		if(matchdata[match_index][25]!=C[19]) document.getElementById("gadd2_" + matchid).innerHTML=C[19];
		matchdata[match_index][24]=C[18];
		matchdata[match_index][25]=C[19];
	}
	if(C[13]>=3){ //3ot
		if(matchdata[match_index][26]!=C[20]) document.getElementById("hadd3_" + matchid).innerHTML=C[20];
		if(matchdata[match_index][27]!=C[21]) document.getElementById("gadd3_" + matchid).innerHTML=C[21];
		matchdata[match_index][26]=C[20];
		matchdata[match_index][27]=C[21];
	}
    //explain
	if(matchdata[match_index][29]!=C[14]){
	    document.getElementById("sm_" + matchid).innerHTML=" <a href='/textEn/"+matchid+"En.html' target='_blank' style='color:blue;' >" + (txtstate==2?"Play-By-Play":C[14])+"</a>";
	    matchdata[match_index][29]=C[14];
	}
	if(matchdata[match_index][34]!=C[23]){
	    document.getElementById("sm2_" + matchid).innerHTML=" "+ C[23];
	    matchdata[match_index][34]=C[23];
	}

	if(C[22]=="True")
		document.getElementById("js_" + matchid).innerHTML= "<a href='http://info.nowgoal.com/Basketball/League/Schedule/Statistics.aspx?id=" + matchid + "' target=_blank>[Boxscore]</a>";

	if(matchdata[match_index][32]=="1" && scoreChange){
	    if(matchNum++ % 2==0)
		    winStr+= "<tr bgcolor=#ffffff align=center class=line><td><font color=#1705B1>" + document.getElementById("zt_" + matchid).innerHTML +" " + C[2] +"</font></td><td><b>"+ matchdata[match_index][8].split("[")[0] +"</b></td><td style='font-size: 16px;font-family:Verdana;font-weight:bold;'>" + score + "</td><td><b>" + matchdata[match_index][10].split("[")[0]  +"</b></td></tr>";
		else
			winStr+= "<tr bgcolor=#FDF1E7 align=center class=line><td><font color=#1705B1>" + document.getElementById("zt_" + matchid).innerHTML +" " + C[2] +"</font></td><td><b>"+ matchdata[match_index][8].split("[")[0] +"</b></td><td style='font-size: 16px;font-family:Verdana;font-weight:bold;'>" + score + "</td><td><b>" + matchdata[match_index][10].split("[")[0]  +"</b></td></tr>";
	}
  }
  if(matchNum>0) ShowCHWindow(winStr,matchNum);
}

function timecolors(matchid){
  try{
    document.getElementById("hzf_" + matchid).style.backgroundColor="";
    document.getElementById("gzf_" + matchid).style.backgroundColor="";
  }
  catch(e){}
}
function scorecolors(id){
    if(document.all)
  	    document.getElementById(id).innerHTML=document.getElementById(id).innerText;
    else
        document.getElementById(id).innerHTML=document.getElementById(id).textContent;
}

function hidematch(i){
    document.getElementById("table_" + matchdata[i][0]).style.display="none";
	document.getElementById("hiddencount").innerHTML=parseInt(document.getElementById("hiddencount").innerHTML)+1;
}

function winCheck(i){
	if(matchdata[i][32]=="1") //选中变不选中
	{
		matchdata[i][32]="0"
		document.getElementById("win_" + matchdata[i][0]).src="images/close_win.gif";
	}
	else
	{
		matchdata[i][32]="1"
		document.getElementById("win_" + matchdata[i][0]).src="images/open_win.gif";
	}
}
 
function CheckLeague(i,name){
	try{        
	    var hh=parseInt(document.getElementById("hiddencount").innerHTML);
        if(document.getElementById("checkboxleague_" + i).checked){
           document.getElementById("table_" + i).style.display="";
           for(var j=0;j<matchcount;j++){
              if(matchdata[j][1]==name){
                 document.getElementById("table_" + matchdata[j][0]).style.display="";
			     hh=hh-1;
              }
           } 
        } 
        else{
           document.getElementById("table_" + i).style.display="none";
           for(var j=0;j<matchcount;j++){
              if(matchdata[j][1]==name){
                 document.getElementById("table_" + matchdata[j][0]).style.display="none";
			     hh=hh+1;
              }
           } 
       }
       document.getElementById("hiddencount").innerHTML=hh;
    }
    catch(e){}    
}
function CloseLeague(i,name){
    document.getElementById("checkboxleague_" +  i).checked=false;
    CheckLeague(i,name);
}

function HiddenLeague(i,b,name){
    document.getElementById("checkboxleague_" +  i).checked=b;
    if(b){
      document.getElementById("expand" +  i).style.display="none";
      document.getElementById("collapse" +  i).style.display="";
    }
    else{
      document.getElementById("expand" +  i).style.display="";
      document.getElementById("collapse" +  i).style.display="none";
    }
    document.getElementById("table_" + i).style.display="none";
    CheckLeague(i,name);
    document.getElementById("table_" + i).style.display="";
}


function ShowAllMatch(){
	try{        
        for(var i=0;i<sclasscount;i++){
            document.getElementById("checkboxleague_" + i).checked=true;        
            document.getElementById("table_" + i).style.display="";
        }
        for(var i=0;i<matchcount;i++)
            document.getElementById("table_" + matchdata[i][0]).style.display="";        
        document.getElementById("hiddencount").innerHTML=0;
    }
    catch(e){}    
}


//by state
function ShowMatchByMatchState(n){
	try{
	    var hh=0;
        if(n==0)
            ShowAllMatch();
        else{
            for(var i=0;i<sclasscount;i++){
                var show=false;
                for(var j=0;j<matchcount;j++){
                    if(matchdata[j][1]==sclass[i]){
                        if(n==1 && parseInt(matchdata[j][5])>0  || n==2 && parseInt(matchdata[j][5])==-1   || n==3 && parseInt(matchdata[j][5])==0){
		    	            document.getElementById("table_" + matchdata[j][0]).style.display="";
		    	            show=true;
		    	        }
		                else{
			                document.getElementById("table_" + matchdata[j][0]).style.display="none";
			                hh=hh+1;
		                }
                    }
                }
                if(show){
                    document.getElementById("checkboxleague_" + i).checked=true;        
                    document.getElementById("table_" + i).style.display="";
                }
                else{
                    document.getElementById("checkboxleague_" + i).checked=false;        
                    document.getElementById("table_" + i).style.display="none";
                }
                
            }
        
	    } 
	    document.getElementById("hiddencount").innerHTML=hh;
    }
    catch(e){}    
}
function showDate(t1)
{
    var t2=t1.split(","); 
	var t = new Date(t2[0],eval(t2[1]),t2[2],t2[3],t2[4],t2[5]);
	t = new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds())); 
    var y=t.getYear();
    var M=t.getMonth()+1;    
    var d=t.getDate();
    var h=t.getHours();
    var m=t.getMinutes();
    if(M<10) M="0" + M;
    if(d<10) d="0" + d;
    if(h<10) h="0" + h;
    if(m<10) m="0" + m;    
    return (M+"-" + d +" " + h +":" + m);
}	
function ReplaceStyle(css)
{
    document.getElementById("cssLink").href="style/" + css +".css";
    writeCookie("css", css);
}
function changeFontSize(obj,size){
    document.getElementById(obj).style.fontSize=size;
}
function Team(id){
    window.open("http://info.NowGoal.com/basketball/Team/Default.aspx?TeamID=" + id);
}
loadScore();
getoddsxml();
window.setTimeout("getxml()",4000);

