function setHBH(flg){
	if (flg && document.onclick == null) document.onclick=hideBH;
	else document.onclick=null;
}

function hideBH(){
	window.setTimeout("hideB()", 100);	
}

function hideB(){
	try{
		GEBI("FunctionBoard").style.display = "none";
		DPFB = false;
		GEBI("LeagueBoard").style.display = "none";
		DPLB = false;
	}catch (e){}
}

function shFB(){
	var adjWidth=(document.body.clientWidth - 556)/2;
	if (adjWidth<0) adjWidth = 0;
	GEBI("FunctionBoard").style.left = adjWidth + 390;
	if (DPFB){
		GEBI("FunctionBoard").style.display = "none";
		DPFB = false;
	}else{
		GEBI("FunctionBoard").style.display = "";
		DPFB = true;	
	}
}

function shLB(){
	var adjWidth=(document.body.clientWidth - 556)/2;
	if (adjWidth<0) adjWidth = 0;
	GEBI("LeagueBoard").style.left = adjWidth + 490;
	if (DPLB){
		GEBI("LeagueBoard").style.display = "none";
		DPLB = false;
	}else{
		GEBI("LeagueBoard").style.display = "";
		DPLB = true;	
	}
}

function setSound(s){
	sound = s;
	var goalSound_flash = "<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='" + aSS[sound] + "'><param name='quality' value='high'><param name='wmode' value='transparent'></object>";
	GEBI("goalsound").innerHTML = goalSound_flash;
}

var infoWin = false;
var lockInfoWin = false;

function setInfoWin(b){
	infoWin = b;
	lockInfoWin = true;
	GEBI("goaltext").style.display = b?"":"none";
}

function setColor(c){
	color = c;
	if (c==0) document.body.style.backgroundImage = "url(bg.gif)";
	else document.body.style.background = aCS[c][2];
	GEBI("scoreTable").borderColor = aCS[c][3];
	GEBI("scoreTools").style.background = aCS[c][0];
	replaceColorTask();
}

function showEvent(fid, sports, htr, atr){
	if (sports==1) window.open("data/event.aspx?fid=" + fid + "&lang=" + lang + "&htr=" + htr + "&atr=" + atr, "hg"+fid, "width=400, height=220,top=100,left=100, status=0,toolbar=no,menubar=no, scrollbars=1");
	else window.open("data/zb.aspx?fid=" + fid + "&lang=" + lang, fid, "width=796, height=400, status=0, toolbar=no, menubar=no, scrollbars=1, resizable=1");	
}

function showzst(fid, sports, bid, htn, atn, mdt, hm, htr, atr){
	if (sports==1) window.open("data/oddsall.aspx?fid=" + fid, fid, "width=490, height=300, status=0, toolbar=no, menubar=no, scrollbars=1, resizable=1");
}

function op2(url){
	window.open(url, "", "width=490, height=300, location=yes, status=0, toolbar=no, menubar=no, scrollbars=1, resizable=1");
}

function op1(url){
	window.open(url, "", "width=618, height=500, location=yes, status=0, toolbar=no, menubar=no, scrollbars=1, resizable=1");
}

function op(url){
	window.open(url, "", "width=796, height=400, location=yes, status=0, toolbar=no, menubar=no, scrollbars=1, resizable=1");
}

function loadLiveData(){
	try{
		xSD.onreadystatechange=init;
		if (simple) xSD.load("xmlaspx/liveSimple.aspx");
		else xSD.load("xmlaspx/lives2.aspx");
	}catch(e){}
}

function setSimple(){
	simple = true;
	GEBI("HideMatchCount").innerText = "0";
	loadLiveData();
}

function setFull(){
	simple = false;
	GEBI("HideMatchCount").innerText = "0";
	loadLiveData();
}

function setTB(){
	try{
		var tmp = "";
		tmp += "<table border=0 id=scoreTools width=100% cellspacing=0>";
		tmp += "<tr bgcolor=#D8EDF9 width=198 height=22><td align=left><A HREF='freefuturef.aspx?future=-1'><img border=0 src=images/end.gif width=68 height=20></A><A HREF='freefuturef.aspx?future=1'><img border=0 src=images/next.gif width=68 height=20></A></td>";
		tmp += "<td align=center><img alt=简体版 src=images/gb.gif border=0 width=31 height=20 onclick=setLang(2); style=cursor:hand; align=absmiddle> <img alt=繁体版 src=images/big5.gif border=0 width=31 height=20 onclick=setLang(1); style=cursor:hand; align=absmiddle> <img alt=English src=images/en.gif border=0 width=31 height=20 onclick=setLang(3); style=cursor:hand; align=absmiddle></td>";
		tmp += "<td align=center width=100><span style=cursor:hand onclick=selectAllLeague();><a href=#><font color=#000000>[隐<b><font color=#FF0000 id=HideMatchCount>0</font></b>场赛事]</a></span></td>";
		tmp += "<td width=120 align=right><img border=0 src=images/x01.gif width=58 height=20 align=absmiddle style=cursor:hand; onclick=shFB(); onmouseover=setHBH(false) onmouseout=setHBH(true)><img border=0 src=images/x02.gif width=58 height=20 align=absmiddle style=cursor:hand; onclick=shLB(); onmouseover=setHBH(false) onmouseout=setHBH(true)></td></tr></table>";
		GEBI("ToolsBar").innerHTML = tmp;
	}catch(e){}
}

function setFB(){
	var tmp="";
	tmp += "<table border=0 width=100% cellspacing=0 cellpadding=0 bgcolor=#FAFAFA style='border-collapse:collapse; border: 1px solid #000000;' align=center onmouseover=setHBH(false) onmouseout=setHBH(true)><tr><td>";
	tmp += "<table width=100% cellspacing=0 cellpadding=0><tr height=16><td align=center bgcolor=#185F9C><font color=#FFFFFF>功能选择</font></td></tr></table>";
	tmp += "<table border=0 width=100% cellspacing=0 cellpadding=5 bgcolor=#FAFAFA align=center><tr><td>";
	tmp += "弹出窗口：<INPUT TYPE=checkbox checked style='width:16;height:16;' onclick=tipsWin=this.checked;><br>";
	tmp += "信息窗口：<INPUT TYPE=checkbox style='width:16;height:16;' id=InfoWinControl onclick=setInfoWin(this.checked);" + (infoWin?" checked":"") + "><br>";
	tmp += "声音风格：<br>";
	tmp += "&nbsp;&nbsp;<INPUT TYPE=radio name=ss id=ss0 style='width:16;height:16;' onclick=setSound(0)><label for=ss0>无声</label><br>";
	tmp += "&nbsp;&nbsp;<INPUT TYPE=radio name=ss id=ss1 checked style='width:16;height:16;' onclick=setSound(1)><label for=ss1>声音一</label><br>";
	tmp += "&nbsp;&nbsp;<INPUT TYPE=radio name=ss id=ss2 style='width:16;height:16;' onclick=setSound(2)><label for=ss2>声音二</label><br>";
	tmp += "&nbsp;&nbsp;<INPUT TYPE=radio name=ss id=ss3 style='width:16;height:16;' onclick=setSound(3)><label for=ss3>声音三</label><br>";
	tmp += "背景风格：<br>";
	tmp += "&nbsp;&nbsp;<INPUT TYPE=radio name=cs id=cs0 checked style='width:16;height:16;' onclick=setColor(0)><label for=cs0>默认</label><br>";
	tmp += "&nbsp;&nbsp;<INPUT TYPE=radio name=cs id=cs1 style='width:16;height:16;' onclick=setColor(1)><label for=cs1 style=background:#E0D4C7>颜色一</label><br>";
	tmp += "&nbsp;&nbsp;<INPUT TYPE=radio name=cs id=cs2 style='width:16;height:16;' onclick=setColor(2)><label for=cs2 style=background:#FCDDDA>颜色二</label><br>";
	tmp += "&nbsp;&nbsp;<INPUT TYPE=radio name=cs id=cs3 style='width:16;height:16;' onclick=setColor(3)><label for=cs3 style=background:#CDF8C7>颜色三</label><br>";
	tmp += "&nbsp;&nbsp;<INPUT TYPE=radio name=cs id=cs4 style='width:16;height:16;' onclick=setColor(4)><label for=cs4 style=background:#FFF2BD>颜色四</label>";
	tmp += "</td></tr><tr><td align=center><input type=button value=' 确定 ' onclick=shFB();></td></tr></table></td></tr></table>";
	GEBI("FunctionBoard").innerHTML = tmp;
}

function setLeagueBoard(){
	try{
		var leagueList = "";
		var nodes = xSD.selectNodes("/_hgoal/f");
		for(var i=0; i<nodes.length; i++){
			var arro = nodes[i].text.split("*");
			if (arro[12]=="8" || arro[12]=="9" || arro[12]=="10" || arro[12]=="16") continue;
			var arr = aSD[arro[0]].split("*");
			if (("," + leagueList).indexOf("," + getLN2(arr) + "|")==-1)
				leagueList += getLN2(arr) + "|" + arr[14] + ",";
		}
		for(var i=0; i<nodes.length; i++){
			var arro = nodes[i].text.split("*");
			if (arro[12]!="8") continue;
			var arr = aSD[arro[0]].split("*");
			if (("," + leagueList).indexOf("," + getLN2(arr) + "|")==-1)
				leagueList += getLN2(arr) + "|" + arr[14] + ",";
		}
		for(var i=0; i<nodes.length; i++){
			var arro = nodes[i].text.split("*");
			if (arro[12]!="9" && arro[12]!="10" && arro[12]!="16") continue;
			var arr = aSD[arro[0]].split("*");
			if (("," + leagueList).indexOf("," + getLN2(arr) + "|")==-1)
				leagueList += getLN2(arr) + "|" + arr[14] + ",";
		}
		leagueList = leagueList.substring(0,leagueList.length-1)
		var arrLeague = leagueList.split(",");
		var tmp = "";
		for (var i=0; i<arrLeague.length; i++)
		{
			var arrs = arrLeague[i].split("|");
			tmp += "<INPUT TYPE=checkbox checked name=League id=League" + i + " value='" + arrs[0] + "' style='width:16;height:16;' onclick=\"setLeague('" + arrs[0] + "',this.checked);\"><label for=League" + i + ">" + arrs[0] + "</label><br>";
		}
		var str = "<table border=1 width=100% cellspacing=0 cellpadding=0 bgcolor=#FAFAFA style='border-collapse:collapse; border: 1px solid #000000;' align=center onmouseover=setHBH(false) onmouseout=setHBH(true)><tr><td><table width=100% cellspacing=0 cellpadding=0><tr height=16><td align=center bgcolor=#185F9C><font color=#FFFFFF>" + (lang==3?"SELECTB":"赛事选择") + "</font></td></tr></table><table border=0 width=100% cellspacing=0 cellpadding=5 bgcolor=#FAFAFA><tr><td>";
		str = str + tmp + "</td></tr><tr><td align=center><input type=button value=" + (lang==3?"All":"全选") + " onclick=selectAllLeague(); style='border:1px solid #000000;'> <input type=button value=" + (lang==3?"Other":"反选") + " onclick=selectInvertLeague(); style='border: 1px solid #000000;'></td></tr><tr><td align=center><input type=button value=' " + (lang==3?"OK":"确定") + " ' onclick=shLB();></td></tr></table></td></tr></table>";
		GEBI("LeagueBoard").innerHTML = str;
	}catch(e){}
}

function selectAllLeague(){
	var nodes = xSD.selectNodes("/_hgoal/f");
	for(var j=0; j<nodes.length; j++){
		var arro = nodes[j].text.split("*");
		var arr = aSD[arro[0]].split("*");
		aDP[arr[0]] = true;
	}
	loadLiveData();
}

function selectInvertLeague(){
	try{
		var nodes = xSD.selectNodes("/_hgoal/f");
		var leagues = document.getElementsByName("League");
		var lns1 = new Array();
		var lns2 = new Array();
		for (var i=0; i<leagues.length; i++){
			var league = leagues[i];
			var ln = league.value;
			var display = !league.checked;
			league.checked = display;
			if (display) lns1[i] = ln;
			else lns2[i] = ln;
		}
		var l1 = "|" + lns1.join("|") + "|";
		var l2 = "|" + lns2.join("|") + "|";
		for(var j=0; j<nodes.length; j++){
			var arro = nodes[j].text.split("*");
			var arr = aSD[arro[0]].split("*");
			var ln = "|" + getLN2(arr) + "|";
			var display = null;
			if (l1.indexOf(ln)>-1) display = true;
			if (l2.indexOf(ln)>-1) display = false;
			if (display!=null)
			{
				GEBI("f"+arr[0]).style.display = display?"":"none";
				if (arr[22]!="") GEBI("r"+arr[0]).style.display = display?"":"none";
				aDP[arr[0]] = display;
			}
		}
		GEBI("HideMatchCount").innerText = getHideMatchCount();
		replaceColorTask();
	}catch(e){}
}

function setLeague(ln, display){
	try{
		var nodes = xSD.selectNodes("/_hgoal/f");
		for(var i=0; i<nodes.length; i++){
			var arro = nodes[i].text.split("*");
			var arr = aSD[arro[0]].split("*");
			if (getLN2(arr)==ln){
				GEBI("f"+arr[0]).style.display = display?"":"none";
				if (arr[22]!="") GEBI("r"+arr[0]).style.display = display?"":"none";
				aDP[arr[0]] = display;
			}
		}
		GEBI("HideMatchCount").innerText = getHideMatchCount();
		replaceColorTask();
	}catch(e){}
}

function setLang(languang){
	lang = languang;
	setTB();
	setFB();
	GEBI("liveScore").innerHTML = "<br>正在加载数据...";
	GEBI("goaltext").innerHTML = "";
	loadLiveData();
}

function setSports(s){
	sports = s;
	GEBI("liveScore").innerHTML = "<br>正在加载数据...";
	GEBI("goaltext").innerHTML = "";
	loadLiveData();
	if (s==1) GEBI("simplefull").style.display = "";
	else GEBI("simplefull").style.display = "none";
}

function reloadPage(){
	oldxml="";
	loadLiveData()
	window.setTimeout("reloadPage()", 600000);
}
window.setTimeout("reloadPage()", 600000);
