﻿//顯示進球窗口
var startani_C,startani_A,startani_B,pop_TC
function ShowCHWindow(str,matchnum)
{
imagewidth=421;
imageheight=28+34*matchnum ;
var st

st="<table width=420 border=0 cellpadding=1 cellspacing=0 bgcolor=#0099CC>"
st=st + "  <tr><td><table width=418 border=0 cellpadding=0 cellspacing=0>"
st=st + "      <tr><td colspan=3 height=24 bgcolor=#0099CC><font color=white>&nbsp;&nbsp;Zso8.com入球提示</font></td><td colspan=2 align=right><img src='http://img.zso8.com/live/close1.gif' alt='關閉' border='0'>&nbsp;</td></tr>"
st=st + str
st=st + "    </table></td>"
st=st + "  </tr>"
st=st + "</table>"  

st=st + "<style type='text/css'>"
st=st + "td {font-family: 'Tahoma', '宋体';font-size: 13px;}"
st=st + ".line td { border-bottom:solid 1px #FFD8CA; line-height:32px;}"
st=st + "</style>"
//alert(st);
oPopup = window.createPopup();
oPopupBody = oPopup.document.body;
oPopupBody.bgColor="white";

oPopupBody.innerHTML = st
x=280;
y=1;
var winLoc = document.getElementById("winLocation").options[document.getElementById("winLocation").selectedIndex].value; //= "0" 
switch(winLoc)
{			
    case "0":
        x=(screen.width-imagewidth)/2;
        y=1;
        break;
    case "1":
        x=(screen.width-imagewidth)/2;
        y=screen.height-imageheight-30;
        break;
    case "2":
        x=2;
        y=(screen.height-imageheight)/2;
        break;
    case "3":
        x=screen.width-imagewidth-2;
        y=(screen.height-imageheight)/2;
        break;
    case "4":
        x=1;
        y=1;
        break;
    case "5":
        x=screen.width-imagewidth-2;
        y=1;
        break;
    case "6":
        x=1;
        y=screen.height-imageheight-30;
        break;
    case "7":
        x=screen.width-imagewidth-2;
        y=screen.height-imageheight-30;
        break;
}
oPopupBody.style.cursor="hand";
oPopup.document.body.onmouseover=new Function("clearTimeout(startani_A)");
oPopup.document.body.onmouseout=pop;    
oPopup.document.body.onclick=dismisspopup;
oPopup.document.body.oncontextmenu=dismisspopup;
pop_TC=100;
pop();
}

function pop(){
	oPopup.show(x,y,imagewidth, imageheight);
	startani_A=setTimeout("pop()",100);  //显示15秒
	if(pop_TC<0){dismisspopup();};
	pop_TC=pop_TC-1;
}
function dismisspopup()
{	clearTimeout(startani_A);
	oPopup.hide();
}

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.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);
    } 
    if (zXml.useXmlHttp)  return new XMLHttpRequest();
    alert("對不起，您的電腦不支援 XML 外掛程式，請安裝好或升級流覽器。");
};

var m_language;
var loaded=0, LoadTime=0,nofityTimer;
var flash_sound=Array(5);
flash_sound[0] = "<embed wmode='transparent' src='http://img.zso8.com/live/sound.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 loadDetailFileTime=new Date();
var lastUpdateTime, oldUpdateTime="";
var lastUpdateFileTime=0;
var soundid=0;
var hiddenID="_";
var ShowLineCount = 0;
var old_xml="";
var	bg1 = "#FFFFFF";
var bg2 = "#EAF5FF";
var state_ch=Array(17);
state_ch[0]="推迟,推遲,Defer";
state_ch[1]="中断,中斷,Halt";
state_ch[2]="腰斩,腰斬,Halt";
state_ch[3]="<font color=green>待定</font>,<font color=green>待定</font>,<font color=green>Wait</font>";
state_ch[13]="<b>完</b>,<b>完</b>,<b>Ft</b>";
state_ch[14]=",,";
state_ch[15]="上,上,Part1";
state_ch[16]="<font color=blue>中</font>,<font color=blue>中</font>,<font color=blue>Half</font>";
state_ch[17]="下,下,Part2";
var GoalCn="平手,平/半,半球,半/一,一球,一/球半,球半,球半/两,两球,两/两球半,两球半,两球半/三,三球,三/三球半,三球半,三球半/四球,四球,四球/四球半,四球半,四球半/五球,五球,五球/五球半,五球半,五球半/六球,六球,六球/六球半,六球半,六球半/七球,七球,七球/七球半,七球半,七球半/八球,八球,八球/八球半,八球半,八球半/九球,九球,九球/九球半,九球半,九球半/十球,十球".split(",");
function Goal2GoalCn(goal){ //数字盘口转汉汉字	
    if (goal=="")
        return "";
    else{
	    if(goal>=0)  return GoalCn[parseInt(goal*4)];
	    else return "受讓"+ GoalCn[Math.abs(parseInt(goal*4))];
	}
}

function ShowBf()
{   
    m_language=1;
    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("zsolive_SelLanguage", m_language);
	}
    else
    {
	    lang=getCookie("zsolive_SelLanguage");	    
	    if(lang==null) lang="1";
	}
    if (lang=="0" || lang=="1" || lang=="2") m_language=parseInt(lang);

	hiddenID=getCookie("zsolive_hiddenID");
	if(hiddenID==null) hiddenID="_";
	
	MakeTable();
	MakeSclass();
	setMatchTime();
    	hideSelMatch();
}


function MakeTable()
{  
	var state;
	var H_redcard,G_redcard,H_yellow,G_yellow;

    var html=new Array();
	html.push("<table id='table_live' width=700 bgcolor=#d6e0ef align=center cellspacing=1 border=0><tr class='lightBlueth' id='tr_0' bgcolor='#AA0000' align=center>");	
    switch(m_language)
        {
        case 1:  //繁體
           html.push("<td  width=3% bgcolor='#ff9933' height=20>選</td><td  width=10%>" + matchdate +"</td><td  width=6% >時間</td><td  width=6% >狀態</td><td  width=21%>對賽隊伍</td><td  width=9%>比分</td><td  width=22%>對賽隊伍</td><td  width=8%>半場</td><td  width=15%>數據分析</td>");//<td width=7%><font color=white>資訊</font></td></tr>");
           break;
        case 2: //英文
           html.push("<td  width=3% bgcolor='#ff9933' height=20>Sel</td><td  width=10%>" + matchdate +"</td><td  width=6% >Time</td><td  width=6% >State</td><td  width=21%>Team A</td><td  width=9%>Score</td><td  width=22%>Team B</td><td  width=8%>Half</td><td  width=15%>Data</td>");//<td width=7%><font color=white>Info</font></td></tr>");
           break;
        default: //簡體
           html.push("<td  width=3% bgcolor='#ff9933' height=20>选</td><td  width=10%>" + matchdate +"</td><td  width=6% >时间</td><td  width=6% >状态</td><td  width=21%>比赛球队</td><td  width=9%>比分</td><td  width=22%>比赛球队</td><td  width=8%>半场</td><td  width=15%>数据分析</td>");//<td width=7%><font color=white>资讯</font></td></tr>");
           break;
    }
	
	for(var i=1; i<=matchcount;i++)
	{
	  try{
	    state=parseInt(A[i][13]); 
		switch(state)
		{
			case 0:
			    if(A[i][27]=="1") match_score = "陣容"; else  match_score = "-";
			    match_half = "-";
			    break;
			case 1:
			    match_score = A[i][14] + "-" + A[i][15];
 			    match_half = "-";
 			    break;
			case -11:
			case -14:
			    match_score = "";
			    match_half = "";
			    break;
			default:
			    match_score =A[i][14] + "-" + A[i][15];
			    match_half=A[i][16] + "-" + A[i][17];
			    break;
		}
        if(A[i][18]!="0") H_redcard = "<img src='http://img.zso8.com/live/redcard" + A[i][18] + ".gif'>"; else H_redcard = "";
        if(A[i][19]!="0") G_redcard = "<img src='http://img.zso8.com/live/redcard" + A[i][19] +  ".gif'>"; else  G_redcard = "";
        if(A[i][20]!="0") H_yellow = "<img src='http://img.zso8.com/live/yellow" + A[i][20] + ".gif'>"; else H_yellow = "";
        if(A[i][21]!="0") G_yellow = "<img src='http://img.zso8.com/live/yellow" + A[i][21] +  ".gif'>"; else  G_yellow = "";        
        if(A[i][1].indexOf("#") != 0) A[i][1] = "#" + A[i][1];
		if(i % 2==0) bg=bg1; else bg=bg2;
        html.push("<tr align=center id='tr1_" + A[i][0] +"' bgcolor='" + bg +"' index='"  + i + "'>");
        html.push("<td height=18><input type=checkbox checked onclick='hidematch(" + i + ");return false;' class='inp'></td>");
		
		if (A[i][31] != "")
			html.push("<td bgcolor='" + A[i][1] + "' style='color:white;'><a class='a12' id='http://db.zso.com.cn" +A[i][31] +"'><font color=white>" + A[i][2+m_language] + "</font></a></td>"); //聯賽
		else
			html.push("<td bgcolor='" + A[i][1] +"' style='color:white;'>" + A[i][2+m_language] + "</td>");

	    html.push("<td align=center id='mt_" + A[i][0] +"'>" + A[i][11] + "</td>");

        if(A[i][13] =="-1")
           classx2 = "td_scoreR";
        else
           classx2 = "td_score";

        html.push("<td align=center id='time_" + A[i][0] +"' class='td_status'>" +state_ch[state+14].split(",")[m_language] +"</td>");
        html.push("<td id='td_team1_" + A[i][0] +"' align=right><span id=horder_" + A[i][0] +"></span><a id='yellow1_" + A[i][0] +"'>" + H_yellow + "</a><a id='redcard1_" + A[i][0] +"'>" + H_redcard + "</a><a class='a12' id='team1_" + A[i][0] +"' href='javascript:' onclick='TeamPanlu_10(" +A[i][0] +")' title='"+A[i][22]+"'>" + A[i][5+m_language] + "</a></td>");
        html.push("<td onclick='showgoallist(" + A[i][0] + ")' class='" + classx2 + "' onmouseover='showdetail(" + i + ")' onmouseout='hiddendetail()'><font id='score_" + A[i][0] +"'>" + match_score + "</font></td>");
        html.push("<td id='td_team2_" + A[i][0] +"'  align=left><a class='a12' id='team2_" + A[i][0] +"' href='javascript:' onclick='TeamPanlu_10(" + A[i][0] +")'  title='"+A[i][23]+"'>" + A[i][8+m_language]+ "</a><a id='redcard2_" + A[i][0] +"'>" + G_redcard + "</a><a id='yellow2_" + A[i][0] +"'>" + G_yellow + "</a><span id=gorder_" + A[i][0] +"></span></td>");
        
        if(state=="0" || state=="1" || state=="-11" || state=="-12" || state=="-13" || state=="-14")
            classx = "td_half";
        else
            classx = "td_halfR";
         
        html.push( "<td  id='half_" + A[i][0] +"' class=" + classx + ">" + match_half + "</td>");
		html.push("<td><a class='a12' href=javascript: onclick=analysis("+ A[i][0] + ") title='數據分析'>析</a> <a class='a12' href=javascript: onclick=\"AsianOdds("+ A[i][0] +");return false\" title='亞盤指數'>亞</a> <a class='a12' href='javascript:EuropeOdds(" + A[i][0] +")' title='百家歐賠'>歐</a>");
		if(A[i][28]=="True") 
		    html.push(" <img src='http://img.zso8.com/live/zd.gif' height=10 width=10 title='滾球'>");
		else
		    html.push(" <img  height=0 width=10>");
		//html.push("</td>");
		//if(A[i][29]!="") 
	      //  html.push("<a href='javascript:advices(" +A[i][0] +")'><img src='image/fx2.gif' height=12 width=8 title='網友情報' style='margin-left:4px'></a>");
		//else
	      //  html.push("<img height=0 width=8 title='網友情報' style='margin-left:4px'>");
		    

		if(A[i][26]!="") 
		    html.push("<img src='http://img.zso8.com/live/tv.gif' title='"  + A[i][26] +"' style='margin-left:4px'>");
		else
		    html.push("<img height=0  width=10 style='margin-left:0px'> ");
		html.push("</td></tr>");
		
        if(A[i][30] == "") classx="none"; else classx="";  
       // classx="none"; 
        html.push("<tr id='tr2_" + A[i][0] +"' style='display:" + classx + "' bgcolor='#FFFFE8'><td colspan=9 align=center height=18 style='color:green;padding-left:10px;' id='other_" + A[i][0] +"'>" + A[i][30] + "</td></tr>");

		if((i+1)/2<adinfo1.length && (i+1) % 2==0) //廣告
			html.push("<tr id=tr_ad"+ (i+1)/2 +"><td colspan=9 bgcolor=#FFFFE8 align=center height=18><a class='a12' href='" + adinfo1[(i+1)/2] + "' target=_blank style='color:blue'><b>" + adinfo2[(i+1)/2] + "</b></a></td></tr>");
      }catch(e){}
    }
	html.push("</table>")
 	document.getElementById("live").innerHTML=html.join("");
 document.getElementById("loading").style.display="none";
 //document.getElementById("main").style.height = "1000px"; 
}


//联赛/杯赛名列表
function MakeSclass2()
{
	var st;
	var leaguehtml=new Array();
	leaguehtml.push("<TABLE class='leaguetd' WIDTH='100%' BORDER=0 CELLPADDING=0 CELLSPACING=0 id='checkboxleague'><tr>");
	for(var i=1;i<=sclasscount;i++)
	{	
		leaguehtml.push("<td width=32% class='leaguetd'><input onclick='CheckLeague(" + i + ")' checked type=checkbox id='checkboxleague_" + i + "'><label style='cursor:pointer' for='checkboxleague_" + i + "'>" + B[i][m_language] + "</label></td>");
		//if(B[i][3]=="1")
    	//	leaguehtml.push("<td width=6% ><a href='http://data.6666ball.com/Score/2008-2009/" + B[i][4] + ".htm' target=_blank class=blue>历</a></td><td width=6%><a href='http://info.6666ball.com/score/2008-2009/"+ B[i][4] + ".htm' target=_blank class=blue>积</a></td><td width=6%><a href='http://info.6666ball.com/league_data/2008-2009/"+ B[i][4] + ".htm' target=_blank class=blue>盘</a></td>");
		//else
		//    leaguehtml.push("<td width=6%> </td><td width=6%> </td><td width=6%> </td>");
		
		//if (i % 2==0) leaguehtml.push( "</tr><tr>");
		leaguehtml.push( "</tr><tr>");    }
    leaguehtml.push("</tr></TABLE>");
	document.getElementById("myleague").innerHTML=leaguehtml.join("");
}
function MakeSclass()
{
	var st;
	var leaguehtml=new Array();
	var Leaguecolor = "#000000";
	leaguehtml.push("<TABLE WIDTH='100%' BORDER=0 CELLPADDING=0 CELLSPACING=0 id='checkboxleague'><tr>");
	for(var i=1;i<=sclasscount;i++)
	{	Leaguecolor = "#000000";
		switch(B[i][4])
		 	{	 
		 		case '8':
		 		case '11':
		 		case '31':
		 		case '34':
		 		case '36':
		 		case '37':
		 		case '44':
		 		case '51':
		 		case '54':
		 		case '67':
		 		case '75':
			 	case '81':
			 	case '83':
			 	case '90':
		 		case '103':
		 		case '401':	 		
		 		Leaguecolor = "#FF0000";
		 		default:
		 		LeagueColor = "#000000";
		 	}

		leaguehtml.push("<td width=22%><input onclick='CheckLeague(" + i + ")' checked type=checkbox id='checkboxleague_" + i + "'><label style='cursor:pointer;color:" + Leaguecolor +  "' for='checkboxleague_" + i + "'>" + B[i][m_language] + "</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("");
}
var oXmlHttp = zXmlHttp.createRequest();
//////////////////////////////////////////////firefox支持
//////////////////////////////////////////////
function gettime()
{
	try
	{
	    LoadTime=(LoadTime+1)  % 60;
	    if(LoadTime==0)
		    getxml();
	    else
	    {
            oXmlHttp.open("get","xml/time.txt?" + Math.floor(Math.random()*10000),true);
            oXmlHttp.onreadystatechange = function()
	        {	        
                if (oXmlHttp.readyState == 4 && oXmlHttp.status == 200) {
                    if(oXmlHttp.responseText!="" && parseInt(oXmlHttp.responseText)>parseInt(lastUpdateFileTime))
                    {
                        lastUpdateFileTime=oXmlHttp.responseText;
                        getxml();                        
                    }                         
                }
            };
            oXmlHttp.send(null);	    
	    }	
	   
	}
	catch(e){}
	
	
	//window.setTimeout("gettime()",1000);
}
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/change.xml?" + number1 ;  
	AjaxCrossDomainRequest(url, "GET", "cross_domain_form", "refresh()");	
	window.setTimeout("getxml()",2000);
	 
}
function getxml2()
{
    number1++;
 	url = "http://api.zso8.com/xml/change2.xml?" + number1 ;  
	AjaxCrossDomainRequest(url, "GET", "cross_domain_form", "refresh()");	
	window.setTimeout("getxml2()",10000);
}
function refresh()
{
    if(old_xml == AjaxCrossDomainResponse) return;
    old_xml = AjaxCrossDomainResponse;
    var root=createXml(AjaxCrossDomainResponse).documentElement;
    lastUpdateTime=new Date(); 

    var D=new Array();
    var matchindex;
    var score1change, score2change, scorechange;
    var goTime;
    var hometeam,guestteam,sclassname,score1,score2;
    
    var matchNum=0;
    var winStr="";
    var firefoxFlag = 1;
    var UpdateMatchCount = root.getElementsByTagName("h").length; //for firefox and ie
    
    if(root.text) firefoxFlag = 0;
    
    //for(var i = 0;i<root.childNodes.length;i++)
    for(var i = 0;i<UpdateMatchCount;i++) //for firefox and ie
    {  
		if(firefoxFlag == 0){
	    	D=root.childNodes[i].text.split("^"); //0:ID,1:state,2:score1,3:score2,4:half1,5:half2,6:card1,7:card2,8:time1,9:time2,10:explain,11:lineup	    
    	}else{
    		D=root.getElementsByTagName("h")[i].textContent.split("^"); //firefox
    	}
    	D[0] = eval(D[0]); //for firefox
    	D[1] = eval(D[1]);
    	//D[2] = eval(D[2]);
    	//D[3] = eval(D[3]);
    	//D[4] = eval(D[4]);
    	//D[5] = eval(D[5]);
    	D[6] = eval(D[6]);
    	D[7] = eval(D[7]);
    	D[12] = eval(D[12]);
    	D[13] = eval(D[13]);
    	if(document.getElementById("tr1_" + eval(D[0]))==null)  continue;
		matchindex=document.getElementById("tr1_" + eval(D[0])).attributes["index"].value;
		score1change=false;
		if(A[matchindex][14]!=D[2])
		{
			A[matchindex][14]=D[2];
			score1change=true;
			document.getElementById("td_team1_" + D[0]).style.backgroundColor="#bbbb22";//主队进球了
		}
		score2change=false;
		if(A[matchindex][15]!=D[3])
		{
			A[matchindex][15]=D[3];
			score2change=true;
			document.getElementById("td_team2_" + D[0]).style.backgroundColor="#bbbb22";//客队进球了
		}
		scorechange=score1change || score2change;
		 
		//附加说明改时变了'
		if(A[matchindex][30]!= D[10])
		{
			A[matchindex][30]= D[10];
			document.getElementById("other_" + D[0]).innerHTML=D[10];
			if(D[10]=="")
				document.getElementById("tr2_" + D[0]).style.display="none";
			else
				document.getElementById("tr2_" + D[0]).style.display="";			
		}
		
		//红牌变化了
		if(D[6]!=A[matchindex][18])
		{
			A[matchindex][18]=D[6];
			if(D[6]=="0")
				document.getElementById("redcard1_" + D[0]).innerHTML="";
			else
				document.getElementById("redcard1_" + D[0]).innerHTML= "<img src=http://img.zso8.com/live/redcard" + D[6] + ".gif border='0'> "; 			
			if(document.getElementById("RedCheck").checked) document.getElementById("td_team1_" + D[0]).style.backgroundColor="#ff8888";	
			window.setTimeout("timecolors(" + D[0] +","+ matchindex + ")",12000);
		}
		if(D[7]!=A[matchindex][19])
		{
			A[matchindex][19]=D[7];
			if(D[7]=="0")
				document.getElementById("redcard2_" + D[0]).innerHTML="";
			else
				document.getElementById("redcard2_" + D[0]).innerHTML= "<img src=http://img.zso8.com/live/redcard" + D[7] + ".gif border='0'> "; 			
			if(document.getElementById("RedCheck").checked) document.getElementById("td_team2_" + D[0]).style.backgroundColor="#ff8888";	
			window.setTimeout("timecolors(" + D[0] +","+ matchindex + ")",12000);
		}		
		//黄牌变化了
		if(D[12]!=A[matchindex][20])
		{
			A[matchindex][20]=D[12];
			if(D[12]=="0")
				document.getElementById("yellow1_" + D[0]).innerHTML="";
			else
				document.getElementById("yellow1_" + D[0]).innerHTML= "<img src=http://img.zso8.com/live/yellow" + D[12] + ".gif border='0'> "; 			
		}
		if(D[13]!=A[matchindex][21])
		{
			A[matchindex][21]=D[13];
			if(D[13]=="0")
				document.getElementById("yellow2_" + D[0]).innerHTML="";
			else
				document.getElementById("yellow2_" + D[0]).innerHTML= "<img src=http://img.zso8.com/live/yellow" + D[13] + ".gif border='0'> "; 			
		}		

		//开赛
		if(A[matchindex][11]!=D[8]) document.getElementById("mt_" + D[0]).innerHTML=D[8];
		A[matchindex][11]=D[8];
		A[matchindex][12]=D[9];

		//半场比分
		A[matchindex][16]=D[4];
		A[matchindex][17]=D[5];

		//状态
		if(A[matchindex][13]!= D[1])
		{
			A[matchindex][13]=D[1];
			switch(A[matchindex][13])
			{
			case 0:
					document.getElementById("time_" + D[0]).innerHTML="";
					break;
			case 1:
				    var t = A[matchindex][12].split(",");
			        var t2 = new Date(t[0],t[1],t[2],t[3],t[4],t[5]);
			        //alert(t2);
			        goTime = Math.floor((new Date()-t2-difftime)/60000);
			        //alert(goTime);
					if(goTime>45) goTime = "45+"
					if(goTime<1) goTime = "1";
					document.getElementById("time_" + D[0]).innerHTML = goTime + "<img src='http://img.zso8.com/live/in.gif'>";
					break;
			case 2:
					document.getElementById("time_" + D[0]).innerHTML=state_ch[parseInt(D[1])+14].split(",")[m_language];
					break;
			case 3:
				    var t = A[matchindex][12].split(",");
        			var t2 = new Date(t[0],t[1],t[2],t[3],t[4],t[5]);
		        	goTime = Math.floor((new Date()-t2-difftime)/60000)+46;
					if(goTime>90) goTime = "90+";
					if(goTime<46) goTime = "46";
					document.getElementById("time_" + D[0]).innerHTML = goTime + "<img src='http://img.zso8.com/live/in.gif'>";
					break;
			case -1:
					document.getElementById("time_" + D[0]).innerHTML=state_ch[parseInt(D[1])+14].split(",")[m_language];
					document.getElementById("score_" + D[0]).style.color = "red";
					window.setTimeout("MoveToBottom(" + D[0] + "," + firefoxFlag + ")",25000);
					break;
			default:
					document.getElementById("time_" + D[0]).innerHTML=state_ch[parseInt(D[1])+14].split(",")[m_language];
				    
					window.setTimeout("MoveToBottom(" + D[0] + "," + firefoxFlag + ")",5000);
					break;			
   			}
		}

		//score
		switch(A[matchindex][13])
		{
			case "0":
				if(D[11]=="1")
				    document.getElementById("score_" + D[0]).innerHTML="阵容"; 
				else
				    document.getElementById("score_" + D[0]).innerHTML="-";
				break;
			case "1":			
				document.getElementById("score_" + D[0]).innerHTML=A[matchindex][14] + "-" + A[matchindex][15];
				break;
			case "-11":
			case "-14":
				document.getElementById("score_" + D[0]).innerHTML="-";
				document.getElementById("half_" + D[0]).innerHTML="-";
				break;
			default:  //2 3 -1 -12 -13			
				document.getElementById("score_" + D[0]).innerHTML=A[matchindex][14] + "-" + A[matchindex][15];
				document.getElementById("half_" + D[0]).innerHTML=A[matchindex][16] + "-" + A[matchindex][17];
				document.getElementById("half_" + D[0]).style.color="red";
				break;
		}
		
		if(scorechange)
		{	
			ShowFlash(D[0],matchindex,firefoxFlag);
			if(document.getElementById("tr1_" + D[0]).style.display!="none")
			{	
				//hometeam=A[matchindex][5+m_language].substring(0,7);
				hometeam=A[matchindex][5+m_language].replace("(中)"," 中").substring(0,7);
				guestteam=A[matchindex][8+m_language].substring(0,7);
				sclassname=A[matchindex][2+m_language];
				if(score1change){				
				    hometeam="<font color=red>" + hometeam +"</font>";
				    score1="<font color=red>" + D[2] +"</font>";
				    score2="<font color=blue>" + D[3] +"</font>";		    
				}
				if(score2change){
				    guestteam="<font color=red>" + guestteam + "<font>";
				    score1="<font color=blue>" + D[2]+"</font>";
				    score2="<font color=red>" + D[3] +"</font>";
				}	
				window.clearTimeout(nofityTimer);
				
				ShowLineCount = ShowLineCount + 1;
				//if(ShowLineCount == 20){ clearNotify()}
				

				//if(document.getElementById("notify").innerHTML="") document.getElementById("notify").innerHTML="<font color=#6666FF><B>入球提示：</b></font>";
				document.getElementById("notify").innerHTML = "<span style='font-size:12px'>" + sclassname +":"+ hometeam + " <font color=blue>" + score1 +"-" + score2 + "</font> " +guestteam +" &nbsp;</span> ";// + document.getElementById("notify").innerHTML ;
				//nofityTimer=window.setTimeout("clearNotify()",20000);

				if(document.getElementById("windowCheck").checked && parseInt(D[1])>=-1){
					
				    if(matchNum % 2==0)
				    	
					    winStr+= "<tr bgcolor=#ffffff height=34 align=center class=line><td width=18%><font color=#1705B1>" + sclassname +"</font></td><td width=9%> " + document.getElementById("time_" + D[0]).innerHTML + "'</td><td width=31%><b>"+ hometeam +"</b></td><td width=11% style='font-size: 18px;font-family:Verdana;font-weight:bold;'>" + score1 + "-" + score2 + "</td><td width=31%><b>" + guestteam +"</b></td></tr>";
					else
					    winStr+= "<tr bgcolor=#FDF1E7 height=34 align=center class=line><td width=18%><font color=#1705B1>" + sclassname +"</font></td><td width=9%> " + document.getElementById("time_" + D[0]).innerHTML + "'</td><td width=31%><b>"+ hometeam +"</b></td><td width=11% style='font-size: 18px;font-family:Verdana;font-weight:bold;'>" + score1 + "-" + score2 + "</td><td width=31%><b>" + guestteam +"</b></td></tr>";
					//alert(winStr);
					matchNum=matchNum+1
				    
				}
				
			}
			
			if(matchNum>0) ShowCHWindow(winStr,matchNum);
		}//scorechange
		//alert(winStr);
    } //end for
    
    
}

function ShowFlash(id,n,firefoxFlag){
    try{
	    if(document.getElementById("soundCheck").checked && parseInt(A[n][13])>=-1){
	    	
		    if(document.getElementById("tr1_" + id).style.display!="none"){
		    if(firefoxFlag==1) //for firefox
		  		document.getElementById("sound").innerHTML= "<object classid='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'><param name='movie' value='http://img.zso8.com/live/sound.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://img.zso8.com/live/sound.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='0' height='0'></embed></object>"
		    else document.getElementById("sound").innerHTML= flash_sound[soundid] 
		     //document.getElementById("half_" + id).innerHTML= flash_sound[soundid] ;   
		    }
	    }
	}
	catch(e){};
    window.setTimeout("timecolors(" + id +","+ n + ")",120000);
}
	
function CheckSound(n){
	soundid=n;
	document.getElementById("sound").innerHTML=flash_sound[soundid];
}

function timecolors(matchid,n){
	try{
        if(A[n][13]=="0") document.getElementById("score_" + matchid).innerHTML="-";
        document.getElementById("td_team1_" + matchid).style.backgroundColor="";
        document.getElementById("td_team2_" + matchid).style.backgroundColor="";
        if(A[n][13]=="2" ||A[n][13]=="3" ||A[n][13]=="-1")
           document.getElementById("half_" + matchid).innerHTML=A[n][16] +  "-" +  A[n][17];
	    else
	       document.getElementById("half_" +  matchid).innerHTML="";
    }
    catch(e){}
}

function clearNotify(){
   document.getElementById("notify").innerHTML="";
}

function ShowAllMatch(){
    var i,j,inputs;
    inputs=document.getElementById("checkboxleague").getElementsByTagName("input");
	for(var i=0; i<inputs.length;i++)
	    inputs[i].checked=true;

	inputs=document.getElementById("table_live").getElementsByTagName("tr");
	for(var i=0; i<inputs.length;i++)	
	    if(inputs[i].getAttribute("index")!=null) inputs[i].style.display="";

    for(var i=1;i<=matchcount;i++)
        if(A[i][30]!="") document.getElementById("tr2_" +  A[i][0]).style.display="";
    document.getElementById("hiddencount").innerHTML="0";
    hiddenID="_";
	writeCookie("zsolive_hiddenID", hiddenID);    
}

//'按比赛状态显示
function ShowMatchByMatchState(n){
    var i,j;
	var hh=0;
	var trs=document.getElementById("table_live").getElementsByTagName("tr");
	for(var i=1; i<trs.length;i++){	
	    if(trs[i].getAttribute("index")!=null){
	        trs[i].style.display="none";
	        trs[i+1].style.display="none";
	    }
	} 

	for(var i=1;i<=matchcount;i++){
		if(n==1 && parseInt(A[i][13])>0 || n==2 && A[i][13]=="-1" || n==3 && A[i][13]=="0" || n==4 && A[i][28]=="True")
		{
			document.getElementById("tr1_" +  A[i][0]).style.display="";
			if(A[i][30]!="") document.getElementById("tr2_" +  A[i][0]).style.display="";			
			hh=hh+1;
		}		
	}
	document.getElementById("hiddencount").innerHTML=matchcount -hh;
}

function ShowWord(){
	if(document.getElementById("WordCheck").checked==true)
	{
		for(var i=1;i<=matchcount;i++)
			if(A[i][30]!="") document.getElementById("tr2_" +  A[i][0]).style.display="";
    }
	else
	{
		for(var i=1;i<=matchcount;i++)
			document.getElementById("tr2_" +  A[i][0]).style.display="none";
	}
}

function ChangeBgColor(color){
    var bg;
    bg1 = "#FFFFFF";
    bg2=color
    if(bg2=="F0F0F0") bg1 = "FFFDF3";
   	var trs=document.getElementById("table_live").getElementsByTagName("tr");
	for(var i=1; i<trs.length;i++){
	    if(trs[i].getAttribute("index")!=null){
	        if(bg==bg2) bg=bg1; else bg = bg2;
	        trs[i].style.backgroundColor =bg;
	    }
	}
	document.body.style.backgroundImage="url(http://img.zso8.com/live/bg" +color+".gif)";
}

function ShowTeamOrder(){
	if(document.getElementById("TeamOrderCheck").checked){
		for(var i=1;i<=matchcount;i++){
			if(A[i][22]!="") document.getElementById("horder_" + A[i][0]).innerHTML="<sup><font style='font-size:12px;' color=#666666>["+ A[i][22] +"]</font></sup>";
			if(A[i][23]!="") document.getElementById("gorder_" + A[i][0]).innerHTML="<sup><font style='font-size:12px;' color=#666666>["+ A[i][23] +"]</font></sup>";
		}
	}
	else{
		for(var i=1;i<=matchcount;i++){
			document.getElementById("horder_" +  A[i][0]).innerHTML="";
			document.getElementById("gorder_" +  A[i][0]).innerHTML="";
		}
	}
}

function hidematch(i){
    document.getElementById("tr1_" +  A[i][0]).style.display="none";
    document.getElementById("tr2_" +  A[i][0]).style.display="none";
	document.getElementById("hiddencount").innerHTML=parseInt(document.getElementById("hiddencount").innerHTML)+1;
	hiddenID+=A[i][0] + "_";
	writeCookie("zsolive_hiddenID", hiddenID);    
}

function hideSelMatch(){
    if(hiddenID=="_") return;
    var hh=0;
    var id=hiddenID.split("_");
    for(var i=1;i<id.length-1;i++){
        if(document.getElementById("tr1_" +  id[i])!=null){
            document.getElementById("tr1_" +  id[i]).style.display="none";
            document.getElementById("tr2_" +  id[i]).style.display="none";
            hh++;
        }
    }
	document.getElementById("hiddencount").innerHTML=hh;
}


function SelectOtherLeague(){
    var inputs=document.getElementById("checkboxleague").getElementsByTagName("input");
    var hh=0;
	for(var i=0;i<inputs.length;i++){
        if(inputs[i].checked){
           inputs[i].checked=false;
           for(var j=1;j<=matchcount;j++){
              if(A[j][2]==B[i+1][0]){
                 document.getElementById("tr1_" +  A[j][0]).style.display="none";
                 if(A[j][30]!="") document.getElementById("tr2_" +  A[j][0]).style.display="none";
			 	 hh=hh+1;
			 	 hiddenID+=A[j][0] + "_";
              }
           }
        } 
        else{
           inputs[i].checked=true;
           for(var j=1;j<=matchcount;j++){
              if(A[j][2]==B[i+1][0]){
                 document.getElementById("tr1_" +  A[j][0]).style.display="";                 
                 if(A[j][30]!="") document.getElementById("tr2_" +  A[j][0]).style.display="";
                 hiddenID=hiddenID.replace("_"+A[j][0] + "_","_")
              }
           }  
        }
    }
    document.getElementById("hiddencount").innerHTML=hh;
	writeCookie("zsolive_hiddenID", hiddenID);    
}

function CheckLeague(i){
	var hh=parseInt(document.getElementById("hiddencount").innerHTML);
    if(document.getElementById("checkboxleague_" +  i).checked){
       for(var j=1;j<=matchcount;j++){
              if(A[j][2]==B[i][0]){
                 document.getElementById("tr1_" +  A[j][0]).style.display="";                 
                 if(A[j][30]!="") document.getElementById("tr2_" +  A[j][0]).style.display="";
                 hh--;
                 hiddenID=hiddenID.replace("_"+A[j][0] + "_","_")
              }
           }
    }
    else{
       for(var j=1;j<=matchcount;j++){
              if(A[j][2]==B[i][0]){
                 document.getElementById("tr1_" +  A[j][0]).style.display="none";
                 if(A[j][30]!="") document.getElementById("tr2_" +  A[j][0]).style.display="none";
			 	 hh++;
			 	 hiddenID+=A[i][0] + "_";
              }
           }
   }
   document.getElementById("hiddencount").innerHTML=hh;
   writeCookie("zsolive_hiddenID", hiddenID);    
}

function ShowHotMatch(){
	for(var i=1;i<=sclasscount;i++)
	{
	    //if(B[i][6]==0) continue;
		if(B[i][5]=="1"){
		
			document.getElementById("checkboxleague_" + i).checked = true;			
		}
		else{
			document.getElementById("checkboxleague_" + i).checked = false;
			CheckLeague(i);
		}		    
	}
}

function MoveToBottom(m,firefoxFlag){
    try{ 
	   if(firefoxFlag==0){	
			document.getElementById("tr1_" +  m).parentElement.insertAdjacentElement("BeforeEnd",document.getElementById("tr1_" +  m));
        	document.getElementById("tr2_" +  m).parentElement.insertAdjacentElement("BeforeEnd",document.getElementById("tr2_" +  m));
        for(var i=1;i<adinfo1.length;i++) //ads
        {
            document.getElementById("table_live").rows(i*5-1).insertAdjacentElement("BeforeBegin",  document.getElementById("tr_ad" + i));
        }
       }else{
       	 document.getElementById("tr1_" +  m).parentNode.appendChild(document.getElementById("tr1_" +  m));
       	 document.getElementById("tr2_" +  m).parentNode.appendChild(document.getElementById("tr2_" +  m));
		 var adstring = "";		
		 for(var i=1;i<adinfo1.length;i++) //ads
        {
            adstring = "<a class='a12' href='" + adinfo1[i] + "' target=_blank style='color:blue'><b>" + adinfo2[i] + "</b></a>";
            document.getElementById("table_live").rows[i*5-1].parentNode.removeChild(document.getElementById("tr_ad" + i));//move
            document.getElementById("table_live").insertRow(i*5-2); //insert
            document.getElementById("table_live").rows[i*5-2].insertCell(0);
            document.getElementById("table_live").rows[i*5-2].id = "tr_ad"+i; 
            document.getElementById("table_live").rows[i*5-2].cells[0].colSpan = 9;
            document.getElementById("table_live").rows[i*5-2].cells[0].bgColor = "#ffffe8";
            document.getElementById("table_live").rows[i*5-2].cells[0].align = "center";
            document.getElementById("table_live").rows[i*5-2].cells[0].innerHTML = adstring;
        }
      }
    }catch(e){}
}

//更新比赛进行的时间
function setMatchTime(){	
	for(var i=1;i<=matchcount;i++){
	    if(A[i][13]=="1"){  //上半场			
	        var t = A[i][12].split(",");
			var t2 = new Date(t[0],t[1],t[2],t[3],t[4],t[5]);
			goTime = Math.floor((new Date()-t2-difftime)/60000);

			if(goTime>45) goTime = "45+";
			if(goTime<1)  goTime = "1";
			document.getElementById("time_" +  A[i][0]).innerHTML = goTime +  "<img src='http://img.zso8.com/live/in.gif' border=0>";
		}
		if(A[i][13]=="3"){  //下半场		
	        var t = A[i][12].split(",");
			var t2 = new Date(t[0],t[1],t[2],t[3],t[4],t[5]);
			goTime = Math.floor((new Date()-t2-difftime)/60000)+46;
			if(goTime>90) goTime = "90+";
			if(goTime<46) goTime = "46";
			document.getElementById("time_" +  A[i][0]).innerHTML = goTime +  "<img src='http://img.zso8.com/live/in.gif' border=0>";
		}
	}
	window.setTimeout("setMatchTime()" , 30000);
}

function check(){
	if (oldUpdateTime == lastUpdateTime && oldUpdateTime !=""){
		if (confirm("提示:由於程式忙，或其他網路問題，你已經和伺服器斷開連接超過 2 分鐘，是否要重新連接觀看比分？")) window.location.reload();
    }
	oldUpdateTime = lastUpdateTime;
	window.setTimeout("check()" , 120000);
}

function LoadLiveFile()
{	
    document.getElementById("allDate").src="http://api.zso8.com/xml/livedata.js?" + Math.floor(Math.random()*1000);
    window.setTimeout("LoadLiveFile()",3600*1000);
}
LoadLiveFile();
//window.setTimeout("gettime()",2000);
window.setTimeout("getxml()",2000);
window.setTimeout("getxml2()",5000);
//window.setTimeout("check()" , 120000);

//////////////////////////

function TeamPanlu_10(ID){
	var theURL
	theURL="r/?type=panlu&id=" + ID;
	window.open(theURL,"","width=980,,height=698,top=10,left=100,resizable=yes,scrollbars=yes");
}

var OffSetY = 0;
window.document.onmousemove = function getOffSetY(e)
{  
	e = e || window.event; 
	OffSetY = e.clientY;
}   
function showdetail(n)
{
  
  if(A[n][13]=="0") return; 
  try{
    if(Math.floor((new Date()-loadDetailFileTime)/600)>60) LoadDetailFile();
	
    var R=new Array();
    var html="<table width=350 bgcolor=#E1E1E1 cellpadding=0 cellspacing=1 border=0 style='border:solid 1px #666;'>";
    
    html+="<tr><td height=20 colspan=5 bgcolor=#0054a8 align=center><font color=white><b>初盘参考：" +Goal2GoalCn(A[n][29]) +"</b></font></td></tr>";

    html+="<tr bgcolor=#D5F2B7 align=center><td height=20 colspan=2 width=44%><font color=#006600><b>" + A[n][5+m_language]+ "</b></font></td><td width=12% bgcolor=#CCE8B5>时间</td><td colspan=2 width=44%><font color=#006600><b>" + A[n][8+m_language]+"</b></font></td></tr>";
     
    for(var i=0; i<rq.length;i++){ 
        R=rq[i].split('^');
        if(R[0]!=A[n][0]) continue;
        if(R[1]=="1")
            html+="<tr bgcolor=white align=center><td width=6% height=18><img src='http://img.zso8.com/live/" + R[2]+ ".gif'></td><td width=38%>" + R[4]+ "</td><td width=12% bgcolor=#EFF4EA>" + R[3]+ "'</td><td width=38%></td><td width=6%></td></tr>";
        else
            html+="<tr bgcolor=white align=center><td width=6% height=18></td><td width=38%></td><td width=12% bgcolor=#EFF4EA>" + R[3]+ "'</td><td width=38%>" + R[4]+ "</td><td width=6%><img src='http://img.zso8.com/live/" + R[2]+ ".gif'></td></tr>";
	}
	html+="</table>";
	
    document.getElementById('winScore').style.left =document.body.clientWidth/2-175;
	document.getElementById('winScore').style.top = document.body.scrollTop + OffSetY + 15;// + event.clientY+15;
	document.getElementById("winScore").innerHTML=html;
    document.getElementById("winScore").style.display="";    
  }catch(e){}
}
function hiddendetail()
{
	document.getElementById("winScore").innerHTML="";
    document.getElementById("winScore").style.display="none";
}
function LoadDetailFile()
{
    document.getElementById("ScriptDetail").src="http://api.zso8.com/xml/detail.js?" +Math.floor(Math.random()*1000);
    loadDetailFileTime=new Date();
}
