var bfRefreshTime = 2000;
var pkRefreshTime = 8000;
var setRefreshValue = false;
var reflag = 0;
var oldxml = "";
var EndGamebh = "";
var GoalSound = false;
var RedSound = false;
var ErrorGoalSound = false;
var SelectGoalSound = true;
var SelectGoalTips = true;
var chkpksound = false;
var chkswsound = false;
var ObjArr = new Array();
var jqsy = "<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://bf.7m.cn/sound/default.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://bf.7m.cn/sound/default.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='1' height='1'></embed></object>";
var redsy = "<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://bf.7m.cn/sound/red.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://bf.7m.cn/sound/red.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='1' height='1'></embed></object>";
var errjqsy = "<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://bf.7m.cn/sound/error.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://bf.7m.cn/sound/error.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='1' height='1'></embed></object>";
var rqsound = "<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://bf.7m.cn/sound/s1.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://bf.7m.cn/sound/s1.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='1' height='1'></embed></object>";
var swsound = "<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://bf.7m.cn/sound/s2.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://bf.7m.cn/sound/s2.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='1' height='1'></embed></object>";
var hideCount = 0;
var laT1 = new Array(), lbT1 = new Array(), lbT2 = new Array();
var sPopupS;
var TipsPopupS;
var GoalTips = "", GoalTips_Count = 0;
var tipswidth = 0, tipsheight = 0;
var loader = false;
var voi_lng = m_index;
var speak_away = 0;
var speak_red = 0;
var speak_all = 0;
var order_type = "";
var default_speak = "sound noS";
if (m_index == 0 || m_index == 1) //big,gb
{
	if (document.cookie.indexOf("speak_all=") != -1)
	{
		speak_all = getCookie("speak_all");
		if (speak_all == 1)
		{
			default_speak = "sound onS";
		}
	}
}

function $(obj)
{
	return document.getElementById(obj);
}

function set_Attribute(bh, obj, attribute, val)
{
	if (typeof(ObjArr) == "object" && typeof(ObjArr[bh]) == "object")
		eval("if (ObjArr[" + bh + "]." + obj + " != null){ObjArr[" + bh + "]." + obj + "." + attribute + " = '" + val + "';}");
}

function getCookie(Name)
{
	var search = Name + "=";
	if(document.cookie.length > 0)
	{
		offset = document.cookie.indexOf(search);
		if(offset != -1)
		{
			offset += search.length;
			end = document.cookie.indexOf(";", offset);
			if(end == -1)
				end = document.cookie.length;
			return unescape(document.cookie.substring(offset, end));
		}
		else
		{
			return "";
		}
   }
   return "";
}

function GetWeather(wi)
{
	if (!isNaN(wi) && wi > 0 && wi < 30)
	{
		return WEATHER_ARR[wi];
	}
	return;
}

function SetSoundCookie(v)
{
	var exp = new Date();
	exp.setTime(exp.getTime() + (30*24*60*60*1000));
	document.cookie = "7mSound=" + v + "{7mSound};expires=" + exp.toGMTString();
	jqsy = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'><param name='movie' value='http://bf.7m.cn/sound/" + v + ".swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://bf.7m.cn/sound/" + v + ".swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='1' height='1'></embed></object>";
	PlaySound();
}

function ApplySound()
{
	var v = $("select_sound").value;
	if (v != "none")
	{
		SetSoundCookie(v);
		SelectGoalSound = (v != 'no');
		resetSound2($("sound"));
	}
}

function ApplyOddsSound()
{
	var v = $("select_Odds_sound").value;
	if (v != "none")
	{
		var exp = new Date();
		exp.setTime(exp.getTime() + (30*24*60*60*1000));
		document.cookie = "7mOddsSound=" + v + "{7mOddsSound};expires=" + exp.toGMTString();
		swsound = "<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://bf.7m.cn/sound/" + v + ".swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://bf.7m.cn/sound/" + v + ".swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='1' height='1'></embed></object>";
		$("sw").innerHTML = swsound;
	}
}

function resetSound()
{
	if ($("select_sound").value == "no")
	{
		$("select_sound").value='default';
		SetSoundCookie($("select_sound").value);
	}
	else
	{
		$("select_sound").value='no';
		SetSoundCookie($("select_sound").value);
	}
}

function resetSound2(obj)
{
	if(SelectGoalSound)
	{
		obj.title = SOUND_CT;
		obj.className = "soundo";
		SetCookie('7mSoundCheckBox', '1{7mSoundCheckBox}');
	}
	else
	{
		obj.title = SOUND_OT;
		obj.className = "soundf";
		SetCookie('7mSoundCheckBox', '0{7mSoundCheckBox}');
	}
}

function SoundOnSelect(obj)
{
	if(!SelectGoalSound)
	{
		obj.title = SOUND_CT;
		obj.className = "soundo";
		resetSound();
		SelectGoalSound = true;
		SetCookie('7mSoundCheckBox', '1{7mSoundCheckBox}');
	}
	else
	{
		obj.title = SOUND_OT;
		obj.className = "soundf";
		resetSound();
		SelectGoalSound = false;
		SetCookie('7mSoundCheckBox', '0{7mSoundCheckBox}');
	}
}

function WinOnSelect(obj)
{
	if(!SelectGoalTips)
	{
		obj.title = WIN_CT;
		obj.className = "prompt";
		SelectGoalTips = true;
		SetCookie('7mWinCheckBox', '1{7mWinCheckBox}');
	}
	else
	{
		obj.title = WIN_OT;
		obj.className = "promptf";
		SelectGoalTips = false;
		SetCookie('7mWinCheckBox', '0{7mWinCheckBox}');
	}
}

function ReadSetting()
{
	if (typeof(select_sound) == "object")
	{
		if (document.cookie.indexOf("7mSound=") != -1)
		{
			var CookieValue = document.cookie.substring(document.cookie.indexOf("7mSound=")+8,document.cookie.indexOf("{7mSound}"));
			jqsy = "<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://bf.7m.cn/sound/" + CookieValue + ".swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://bf.7m.cn/sound/" + CookieValue + ".swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='1' height='1'></embed></object>";
			$("select_sound").value = CookieValue;
		}
		else
		{
			$("select_sound").value = "default";		
		}
	}
	if (typeof(select_Odds_sound) == "object")
	{
		if (document.cookie.indexOf("7mOddsSound=") != -1)
		{
			var CookieValue = document.cookie.substring(document.cookie.indexOf("7mOddsSound=")+12,document.cookie.indexOf("{7mOddsSound}"));
			swsound = "<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='sound/" + CookieValue + ".swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='http://bf.7m.cn/sound/" + CookieValue + ".swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='1' height='1'></embed></object>";
			$("select_Odds_sound").value = CookieValue;
		}
		else
		{
			$("select_Odds_sound").value = "s2";		
		}
	}
	if (document.cookie.indexOf("7mSoundCheckBox=") != -1)
	{
		var sound_v = document.cookie.substring(document.cookie.indexOf("7mSoundCheckBox=")+16, document.cookie.indexOf("{7mSoundCheckBox}"));
		if (sound_v == "1")
		{
			$("sound").title = SOUND_CT;
			$("sound").className = "soundo";
			SelectGoalSound = true;
		}
		else
		{
			$("sound").title = SOUND_OT;
			$("sound").className = "soundf";
			SelectGoalSound = false;
		}
	}
	else
	{
		$("sound").title = SOUND_CT;
		$("sound").className = "soundo";
		SelectGoalSound = true;
	}
	if (document.cookie.indexOf("7mWinCheckBox=") != -1)
	{
		var win_v = document.cookie.substring(document.cookie.indexOf("7mWinCheckBox=")+14, document.cookie.indexOf("{7mWinCheckBox}"));
		if (win_v == "1")
		{
			$("win").title = WIN_CT;
			$("win").className = "prompt";
			SelectGoalTips = true;
		}
		else
		{
			$("win").title = WIN_OT;
			$("win").className = "promptf";
			SelectGoalTips = false;
		}
	}
	else
	{
		$("win").title = WIN_CT;
		$("win").className = "prompt";
		SelectGoalTips = true;
	}
	if (typeof(pkChangeTips) == "object")
	{
		if (document.cookie.indexOf("7mPkWinCheckBox=") != -1)
			pkChangeTips.checked = (document.cookie.substring(document.cookie.indexOf("7mPkWinCheckBox=")+16, document.cookie.indexOf("{7mPkWinCheckBox}")) == "1") ? true : false;
	}
	if (m_index == 0 && document.cookie.indexOf("voi_lng=") != -1)
		voi_lng = getCookie("voi_lng");
	if (document.cookie.indexOf("speak_away=") != -1)
		speak_away = getCookie("speak_away");
	if (document.cookie.indexOf("speak_red=") != -1)
		speak_red = getCookie("speak_red");
		
	if (m_index == 0 || m_index == 1) //big,gb
	{
		if (getCookie("lsfont") != "")
			setFONT(getCookie("lsfont"));
	}
	else
	{
		if (getCookie("lsfont_en") != "")
			setFONT(getCookie("lsfont_en"));
	}
	if (m_index == 5)
	{
		$("etn").value = (getCookie("7mEtn") == "1") ? CONVERT2KR : CONVERT2EN;
	}
}

function ChangePkData(i)
{
	if (i > RQ_ARR.length)
		return "";
	return RQ_ARR[i];
}

function SetCookie(n,v)
{
	var exp = new Date();
	exp.setTime(exp.getTime() + (365*24*60*60*1000));
	document.cookie = n + "=" + v + ";expires=" + exp.toGMTString();
}


function ChangeState(startIndex)
{
	if (startIndex < 0 || startIndex > 18)
		startIndex = 0;
	return start_arr[startIndex];
}

function updateRowColor()
{
	var obj = $("live_Table");
	if (obj != null)
	{
		var rowId = 0;
		for (var i=0;i<obj.rows.length;++i)
		{
			if (obj.rows[i].style.display == "" && obj.rows[i].id.substring(0, 2) == "bh")
			{
				obj.rows[i].className = (rowId % 2) ? "bg1" : "bg2";
				rowId++;
			}
		}
	}
	if (typeof(updateRowColor_Timer) == "number")
		clearTimeout(updateRowColor_Timer);
	updateRowColor_Timer = setTimeout("updateRowColor()", 1800000);
}

function ChangeRsmEncode(str, bh)
{
	if (str == "")
	{
		return "";
	}
	if (str == "[delmc]")
	{
		if ($("mc_" + bh) != null)
			$("mc_" + bh).style.display = "none";
		return "";
	}
	else if (str == "[showmc]")
	{
		if ($("mc_" + bh) != null)
			$("mc_" + bh).style.display = "";
		return "";
	}
	var rltstr = "";
	var tmpstr = new Array();
	var i=0;

	if (lan != "big" && lan != "gb" && str.substring(0, 1) == "*")
	{
		str = str.substring(1, str.length);
		if (str.indexOf("{") != -1 && str.indexOf("}") != -1)
		{
			str = str.substring(str.indexOf("{")+1, str.indexOf("}"));
			var tmpsource = str.split("|");
			if (lan == "en")
				str = tmpsource[0];
			else if (lan == "vn")
				str = (tmpsource.length > 1) ? tmpsource[1] : tmpsource[0];
			else if (lan == "th")
				str = (tmpsource.length > 2) ? tmpsource[2] : tmpsource[0];
			else if (lan == "kr")
				str = (tmpsource.length > 3) ? tmpsource[3] : tmpsource[0];
		}
		else
		{
			str = "";
		}
	}
	else
	{
		if (str.substring(0,1) == "*")
			str = str.substring(1, str.length);
		if (str.indexOf("{") != -1 && str.indexOf("}") != -1)
			str = str.replace(str.substring(str.indexOf("{"), str.indexOf("}")+1), "");
		var tmpsource = str.split("|");
		if (lan == "big")
			str = tmpsource[0];
		else if (lan == "gb")
			str = (tmpsource.length > 1) ? tmpsource[1] : tmpsource[0];
	}
	if (str == "" || str == "^")
		return "";
	tmpstr = str.split(",");
	for (i=0;i<tmpstr.length;i++)
	{
		if (tmpstr[i].substring(1,2) == "[" && tmpstr[i].indexOf("]") != -1)
		{
			var idx = tmpstr[i].substring(0,1);
			if (typeof(RESUME_ARR[idx]) != "undefined")
			{
				if (idx == "8")
				{
					var strLinks = "";
					//if (lan != "en")
					//{
						var Links = tmpstr[i].substring(2, tmpstr[i].indexOf("]")).split(';');
						for (var j = 0; j < Links.length; ++j)
						{
							if (j > 0)
								strLinks += ', ';
							var resumeStr = RESUME_ARR[idx];
							if (Links[j].indexOf("pptv.com") != -1)
							{
								if (lan == "big")
								 	resumeStr = 'PPTV視頻' + resumeStr;
								else if (lan == "gb")
									resumeStr = 'PPTV视频' + resumeStr;
							}
							strLinks += '<a href="' + Links[j] + '" target="_blank">' + resumeStr + (Links.length > 1  ? (j + 1) : '') + '</a>';
						}
					//}
					tmpstr[i] = strLinks + tmpstr[i].substring(tmpstr[i].indexOf("]") + 1);
				}
				else
				{
					tmpstr[i] = RESUME_ARR[idx] + tmpstr[i].substring(1);
				}
			}
		}
		if (i > 0)
			rltstr += ',';
		rltstr += tmpstr[i];
	}
	if (rltstr != "")
		rltstr = "<font color=blue>" + rltstr.substring(0,rltstr.length).replace("^", "") + "</font>";
	
	return rltstr
}

function hiderow(bh)
{
	var row = $("bh" + bh);
	if (row != null)
	{
		row.style.display = "none";
		$("resume_" + bh).style.display = "none";
		hideCount++;
		$("hider").innerHTML = hideCount;
	}
}

function HideMatch(obj)
{
	var Matchbody = obj.parentNode.parentNode.parentNode;
	for (var i = 0; i < Matchbody.childNodes.length; ++i)
	{
		if (Matchbody.childNodes[i].nodeName == "TR")
		{
			var row_id = Matchbody.childNodes[i].id;
			if (row_id.substring(0, 2) == "bh")
				hiderow(row_id.substring(2));
		}
	}
	obj.parentNode.parentNode.style.display = "none";
}

function CheckTR(bh)
{
	var Matchbody = $("bh" + bh).parentNode;
	var rowindex = 0;
	for (var i = 0; i < Matchbody.childNodes.length; ++i)
	{
		if (Matchbody.childNodes[i].nodeName == "TR")
		{
			if (Matchbody.childNodes[i].id.indexOf("bh") != -1)
			{
				if (Matchbody.childNodes[i].style.display == "")
				{
					return;
				}
			}
			else if (Matchbody.childNodes[i].id == "")
			{
				if (rowindex == 0)
					rowindex = i;
			}
		}
	}
	Matchbody.childNodes[rowindex].style.display = "none";
}

function ProcessTime()
{
	if (typeof(c_bf) == "object")
	{
		var AmountTime = 0;
		var objBssj = null;
		for (var i in c_bf)
		{
			var p_ssj = c_bf[i][8].split(",");
			var p_sj = new Date(p_ssj[0], parseFloat(p_ssj[1])-1, p_ssj[2], p_ssj[3], p_ssj[4], p_ssj[5]);
			if (c_bf[i][0] == 1)
			{
				AmountTime = parseInt((new Date() - Date.parse(p_sj)) / 1000 /60 + Timegap);
				if (AmountTime < 0) AmountTime = 0;
				if (AmountTime > 45) AmountTime = 45;
				objBssj = (typeof(ObjArr[i]) == "object" && ObjArr[i].row != null) ? ObjArr[i].ptime : $("bssj" + i);
				if (objBssj != null && objBssj.innerHTML != AmountTime + "'")
				{
					objBssj.innerHTML = AmountTime + "'";
				}
			}
			else if (c_bf[i][0] == 3)
			{
				AmountTime = parseInt((new Date() - Date.parse(p_sj)) / 1000 /60 + Timegap) + 45;
				if (AmountTime < 46) AmountTime = 46;
				if (AmountTime > 90) AmountTime = 90;
				objBssj = (typeof(ObjArr[i]) == "object" && ObjArr[i].row != null) ? ObjArr[i].ptime : $("bssj" + i);
				if (objBssj != null && objBssj.innerHTML != AmountTime + "'")
				{
					objBssj.innerHTML = AmountTime + "'";
				}
			}
		}
	}
	if (typeof(ProcessTime_Timer) == "number")
		clearTimeout(ProcessTime_Timer);
	ProcessTime_Timer = setTimeout("ProcessTime()", 30000);
}

function PlaySound()
{
	$("bs").innerHTML = jqsy;
}

var xmlhttp = null;
var xmlhttp2 = null;
var isIE = true;
var parser = null;
var oSerializer = null;
var XmlDoc = null;
var XmlDoc2 = null;

if(window.ActiveXObject)
{
	try
	{
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch(e)
	{ 
		xmlhttp = new ActiveXObject("MsXml2.XMLHTTP");
		xmlhttp2 = new ActiveXObject("MsXml2.XMLHTTP");
	}
}
else
{
	xmlhttp = new XMLHttpRequest();
	xmlhttp2 = new XMLHttpRequest();
	parser = new DOMParser();
	oSerializer = new XMLSerializer();
	isIE = false;
}

function OpenXml()
{
	try
	{
		xmlhttp.open("get", "/live/sXl.xml?" + Date.parse(new Date()), true);
		xmlhttp.onreadystatechange = livexmlonreadystatechange;
		xmlhttp.send(null);
	}
	catch(e)
	{
	}
	if (typeof(OpenXml_Timer) == "number")
		clearTimeout(OpenXml_Timer);
	OpenXml_Timer = setTimeout("OpenXml()", bfRefreshTime);
}

function livexmlonreadystatechange()
{
	if (xmlhttp.readyState != 4 || (xmlhttp.status != 200 && xmlhttp.status != 0))
		return;
	var newxml = "";
	if(isIE)
	{
		XmlDoc = xmlhttp.responseXML;
		newxml = XmlDoc.xml;
		if(newxml == "" || newxml == oldxml)
			return;
	}
	else
	{
		XmlDoc = parser.parseFromString(xmlhttp.responseText, "text/xml");
		if(XmlDoc.documentElement.tagName == "parsererror")
			return;
		newxml= oSerializer.serializeToString(XmlDoc.documentElement);
		if(newxml == "" || newxml == oldxml)
			return;
	}
	GoalTips = "";
	GoalTips_Count = 0;
	var root = XmlDoc.documentElement;
	var ResetPage = root.getElementsByTagName("Rst")[0].firstChild.nodeValue;
	if (!setRefreshValue)
	{
		reflag = ResetPage;
		setRefreshValue = true;
	}
	if (reflag != ResetPage)
	{
		setRefreshValue = false;
		var Rnd = Math.round(Math.random()*19000)+1000;
		setTimeout("location.reload()", Rnd);
		return;
	}
	var nextfn = parseInt(root.getElementsByTagName("fn")[0].firstChild.nodeValue);
	if ((nextfn - 1) > GetFlagNum)
	{
		OpenXml2();
		return;
	}
	var cNode = root.getElementsByTagName("C");
	for(var i=0;i<cNode.length;++i)
		eval('Update_Live(' + cNode[i].firstChild.nodeValue +')');
	oldxml = newxml;
	GetFlagNum++;
	if (SelectGoalSound)
	{
		if(GoalSound)
		{
			PlaySound();
			GoalSound = false;
		}
		if(ErrorGoalSound)
		{
			$("bs4").innerHTML = errjqsy;
			ErrorGoalSound = false;
		}
		if(RedSound)
		{
			$("bs3").innerHTML = redsy;
			RedSound = false;
		}
	}
	if (GoalTips_Count > 0)
	{
		ShowGoalTips();
	}
}

function OpenXml2()
{
	try
	{
		xmlhttp2.open("Get", "/live/sxl_" + GetFlagNum + ".xml?" + Date.parse(new Date()), true);
		xmlhttp2.onreadystatechange = livexmlonreadystatechange2;
		xmlhttp2.send(null);
	}
	catch(e)
	{
	}
}

function livexmlonreadystatechange2()
{
	if (xmlhttp2.readyState != 4 || (xmlhttp2.status != 200 && xmlhttp2.status != 0))
		return;
	if(isIE)
	{
		XmlDoc2 = xmlhttp2.responseXML;
		if(XmlDoc2.xml == "")
			return;
	}
	else
	{
		XmlDoc2 = parser.parseFromString(xmlhttp2.responseText, "text/xml");
		if(XmlDoc2.documentElement.tagName == "parsererror")
			return;
		
	}
	GoalTips = "";
	GoalTips_Count = 0;
	var root = XmlDoc2.documentElement;
	var cNode = root.getElementsByTagName("C");
	for(var i=0;i<cNode.length;++i)
		eval('Update_Live(' + cNode[i].firstChild.nodeValue +')');
	GetFlagNum =	parseInt(root.getElementsByTagName("fn")[0].firstChild.nodeValue);
	if (SelectGoalSound)
	{
		if(GoalSound)
		{
			PlaySound();
			GoalSound = false;
		}
		if(ErrorGoalSound)
		{
			$("bs4").innerHTML = errjqsy;
			ErrorGoalSound = false;
		}
		if(RedSound)
		{
			$("bs3").innerHTML = redsy;
			RedSound = false;
		}
	}
	if (GoalTips_Count > 0)
	{
		ShowGoalTips();
	}
}

function Update_Live(bh, IsStart, live_a, live_b, a_r, b_r, TStart_Time, Banc, resume, Start_Time, sf, lbsf, csf)
{
	if (typeof(c_m) != "object" || typeof(c_m) != "object") return;
	if (typeof(c_m[bh]) != "object" || typeof(c_m[bh]) != "object") return;
	if (typeof(ObjArr) != "object") return;
	
	if (typeof(ObjArr[bh]) != "object")
	{
		ObjArr[bh] = new ElementObj(bh);
	}
	if (ObjArr[bh].row == null || ObjArr[bh].row.style.display == "none") return;
	
	
	//try
//	{
		var speakgoal = false, speakst = false, speakht = false, speakft = false, speakAred = false, speakBred = false, speakAinefficacy = false, speakBinefficacy = false;
		var resume_v = (resume != "") ? ChangeRsmEncode(resume, bh) : "";
		
		if (resume_v != "")
		{
			if (resume_v != c_bf[bh][7])
			{
				c_bf[bh][7] = resume_v;
				ObjArr[bh].resume.style.display = "";
				ObjArr[bh].resume_td.innerHTML = resume_v;
			}
		}
		else
		{
			c_bf[bh][7] = "";
			ObjArr[bh].resume.style.display = "none";
			ObjArr[bh].resume_td.innerHTML = "";
		}

		if (c_bf[bh][0] != IsStart)
		{
			c_bf[bh][0] = IsStart;
			var State = ChangeState(IsStart);
			ObjArr[bh].pstatus.innerHTML = State;
			if (IsStart == 4 || IsStart == 10 || IsStart == 12 || IsStart == 16)
			{
				ObjArr[bh].pstatus.style.color = "#FF0000";
				ObjArr[bh].score.style.color = "#FF0000";
				speakft = true;
			}
			else if (IsStart == 5 || IsStart == 6 || IsStart == 13 || IsStart == 14)
			{
				ObjArr[bh].pstatus.style.color = "#364DA3";
				if (IsStart != 5)
				{
					ObjArr[bh].lA.innerHTML = "";
					ObjArr[bh].lB.innerHTML = "";
					ObjArr[bh].ptime.style.display = "none";
					ObjArr[bh].score.style.display = "none";
					ObjArr[bh].rA.style.display = "none";
					ObjArr[bh].rB.style.display = "none";
					ObjArr[bh].hscore.innerHTML = "";
					setTimeout("MoveGame(" + bh + ")", 60000);
				}
			}
			else
			{
				ObjArr[bh].pstatus.style.color = "#000000";
				if (IsStart == 1)
					speakst = true;
				else if (IsStart == 2)
					speakht = true;
			}
				
			if (IsStart != 17)
			{
				InsertInfo(State,
						   Replace_Team_name(c_m[bh][0]),
						   c_bf[bh][1] + "-" + c_bf[bh][2],
						   Replace_Team_name(c_m[bh][1]) + "&nbsp;");
				
			}
			if (IsStart == 6 || IsStart == 13 || IsStart == 14)
			{
				return;
			}
		}
	
		if (Start_Time != "")
		{
			c_bf[bh][8] = Start_Time;
			if (timezone_TZ != "+0800")
				Start_Time = AmountTimeDiff(Start_Time, 0);
			var TmpValue = Start_Time.split(",");
			if (TmpValue.length == 6)
			{
				if(lan == "gb" || lan == "big" || lan == "kr")
				ObjArr[bh].stime.innerHTML = TmpValue[1] + "-" + TmpValue[2] + "<br>" + TmpValue[3] + ":" + TmpValue[4];
				else
				ObjArr[bh].stime.innerHTML = TmpValue[3] + ":" + TmpValue[4] + "<br>" + TmpValue[2] + "/" + TmpValue[1];
			}
		}
			
		if (IsStart == 17)
		{
			ObjArr[bh].lA.innerHTML = "";
			ObjArr[bh].lB.innerHTML = "";
			if (c_bf[bh][3].indexOf("-") != -1)
			{
				ObjArr[bh].hscore.innerHTML = "";
				c_bf[bh][3] = "";
			}
			ObjArr[bh].rA.style.display = "none";
			ObjArr[bh].rB.style.display = "none";
			ObjArr[bh].ptime.style.display = "none";
			ObjArr[bh].ptime.innerHTML = "0'";
			ObjArr[bh].score.style.display = "";
		}
		else
		{
			if ((IsStart >= 1 && IsStart <= 4) || IsStart == 15)
			{
				if (IsStart == 1 || IsStart == 3)
				{
					if (TStart_Time != "")
					{
						c_bf[bh][8] = TStart_Time;
					}
					ObjArr[bh].ptime.style.display = "";
				}
				else
				{
					ObjArr[bh].ptime.style.display = "none";
				}
				if (ObjArr[bh].lA.innerHTML == "")
				{
					c_bf[bh][1] = 0;
					ObjArr[bh].lA.innerHTML = "0";
				}
				if (ObjArr[bh].lB.innerHTML == "")
				{ 
					c_bf[bh][2] = 0;
					ObjArr[bh].lB.innerHTML = "0";
				}
			}
			else
			{
				ObjArr[bh].ptime.style.display = "none";
			}
			
			if (live_a != c_bf[bh][1])
			{
				var goalimg = "goal";
				if (live_a < c_bf[bh][1])
				{
					goalimg = "gerr";
					ErrorGoalSound = true;
					speakAinefficacy = true;
				}
				else
				{
					GoalSound = true;
				}
				c_bf[bh][1] = live_a;
				ObjArr[bh].lA.style.color = "#FF0000";
				ObjArr[bh].lA.innerHTML = live_a;
				//ObjArr[bh].teamA.className = "home goal";
				clearTimeout(laT1[bh]);
				laT1[bh] = setTimeout("set_Attribute(" + bh + ", 'lA', 'style.color', '')", 180000);
				//clearTimeout(laT2[bh]);
				//laT2[bh] = setTimeout("set_Attribute(" + bh + ", 'teamA', 'className', 'home')", 180000);
				if (SelectGoalTips)
				{
					Gold(0,
						"<font color=#FF0000>" + c_bf[bh][1] + "</font>-" + c_bf[bh][2], 
						"<font color=#FF0000>" + Replace_Team_name(c_m[bh][0]) + "</font>", 
						Replace_Team_name(c_m[bh][1]),
						matches_name + (ObjArr[bh].ptime.style.display == "" ? "[" + ObjArr[bh].ptime.innerHTML + "]": ""), 
						"#" + color);
				}
				InsertInfo("<img src=http://img.7m.cn/icon/" + goalimg + ".gif>&nbsp;",
							 "<font color=#FF0000>" + Replace_Team_name(c_m[bh][0]) + "</font>",
							 "<font color=#FF0000>" + c_bf[bh][1] + "</font>-" + c_bf[bh][2],
							 Replace_Team_name(c_m[bh][1]) + "&nbsp;");
				
				speakgoal = true;
			}
	
			if (live_b != c_bf[bh][2])
			{
				var goalimg = "goal";
				if (live_b < c_bf[bh][2])
				{
					goalimg = "gerr";
					ErrorGoalSound = true;
					speakBinefficacy = true;
				}
				else
				{
					GoalSound = true;
				}  
				c_bf[bh][2] = live_b;
				ObjArr[bh].lB.style.color = "#FF0000";
				ObjArr[bh].lB.innerHTML = live_b;
				//ObjArr[bh].teamB.className = "away goal";
				clearTimeout(lbT1[bh]);
				lbT1[bh] = setTimeout("set_Attribute(" + bh + ", 'lB', 'style.color', '')", 180000);
				//clearTimeout(lbT2[bh]);
				//lbT2[bh] = setTimeout("set_Attribute(" + bh + ", 'teamB', 'className', 'away')", 180000);
				if (SelectGoalTips)
				{
					Gold(1,
						c_bf[bh][1] + "-<font color=#FF0000>" + c_bf[bh][2] + "</font>", 
						Replace_Team_name(c_m[bh][0]), 
						"<font color=#FF0000>" + Replace_Team_name(c_m[bh][1]) + "</font>", 
						matches_name + (ObjArr[bh].ptime.style.display == "" ? "[" + ObjArr[bh].ptime.innerHTML + "]": ""), 
						"#" + color);	
				}
				InsertInfo("<img src=http://img.7m.cn/icon/" + goalimg + ".gif>&nbsp;",
						   Replace_Team_name(c_m[bh][0]),
						   c_bf[bh][1] + "-<font color=#FF0000>" + c_bf[bh][2] + "</font>",
						   "<font color=#FF0000>" + Replace_Team_name(c_m[bh][1]) + "</font>&nbsp;");
				
				speakgoal = true;
			}
			
			if ((IsStart >= 1 && IsStart <= 3) || IsStart == 5 || (IsStart >=7 && IsStart <= 9) || IsStart == 11)
			{
				ObjArr[bh].rA.style.display = "";
				ObjArr[bh].rB.style.display = "";
				ObjArr[bh].score.style.display = "";
				if (IsStart == 2)
				{
					ObjArr[bh].ptime.innerHTML = "46'";
					ObjArr[bh].hscore.innerHTML = c_bf[bh][1] + "-" + c_bf[bh][2];
					c_bf[bh][3] = c_bf[bh][1] + "-" + c_bf[bh][2];
				}
			}
			else if (IsStart == 4 || IsStart == 12 || IsStart == 15)
			{
				ObjArr[bh].ptime.style.display = "none";
				ObjArr[bh].score.style.display = "";
			}
			if (IsStart == 4 || IsStart == 6 || IsStart == 10 || (IsStart >= 12 && IsStart <= 15))
				setTimeout("MoveGame(" + bh + ")", 60000);
			
			if (a_r > 0)
			{
				if (c_bf[bh][4] != a_r)
				{
					c_bf[bh][4] = a_r;
					ObjArr[bh].rA.innerHTML = "<img src=http://img.7m.cn/s_img/" + a_r + ".gif>&nbsp;";
					if (SelectGoalTips)
					{
						Gold(0,
							c_bf[bh][1] + "-" + c_bf[bh][2], 
							"<font color=#FF0000>" + Replace_Team_name(c_m[bh][0]) + "</font>&nbsp;<img src=http://img.7m.cn/s_img/" + a_r + ".gif>", 
							Replace_Team_name(c_m[bh][1]), 
							matches_name + (ObjArr[bh].ptime.style.display == "" ? "[" + ObjArr[bh].ptime.innerHTML + "]": ""), 
							"#" + color);
					}
					InsertInfo("<img src=http://img.7m.cn/s_img/" + a_r + ".gif>&nbsp;",
							   "<font color=#FF0000>" + Replace_Team_name(c_m[bh][0]) + "</font>",
							   c_bf[bh][1] + "-" + c_bf[bh][2],
							   Replace_Team_name(c_m[bh][1]) + "&nbsp;");
					
					speakAred = true;
					RedSound = true;
				}
			}
			else
			{
				c_bf[bh][4] = a_r;
				ObjArr[bh].rA.innerHTML = "";
			}
			
			if (b_r > 0)
			{
				if (c_bf[bh][5] != b_r)
				{
					c_bf[bh][5] = b_r;
					ObjArr[bh].rB.innerHTML = "&nbsp;<img src=http://img.7m.cn/s_img/" + b_r + ".gif>";
					if (SelectGoalTips)
					{
						Gold(1,
							c_bf[bh][1] + "-" + c_bf[bh][2], 
							Replace_Team_name(c_m[bh][0]), 
							"<img src=http://img.7m.cn/s_img/" + b_r + ".gif>&nbsp;<font color=#FF0000>" + Replace_Team_name(c_m[bh][1]) + "</font>", 
							matches_name + (ObjArr[bh].ptime.style.display == "" ? "[" + ObjArr[bh].ptime.innerHTML + "]": ""), 
							"#" + color);
					}
					InsertInfo("<img src=http://img.7m.cn/s_img/" + b_r + ".gif>&nbsp;",
							   Replace_Team_name(c_m[bh][0]),
							   c_bf[bh][1] + "-" + c_bf[bh][2],
							   "<font color=#FF0000>" + Replace_Team_name(c_m[bh][1]) + "</font>&nbsp;");
					
					speakBred = true;
					RedSound = true;
				}
			}
			else
			{
				c_bf[bh][5] = b_r;
				ObjArr[bh].rB.innerHTML = "";
			}
			
			if (Banc != "")
			{
				if (Banc == "-")
					Banc = "";
				c_bf[bh][3] = Banc;
				ObjArr[bh].hscore.innerHTML = Banc;
			}
		}
		if (typeof(voiArr[bh]) == "number")
		{
			if (speakgoal || speakst || speakht || speakft)
			{
				if (speakAinefficacy || !speakBinefficacy)
					SetVoiLs(c_m[bh][2]);
				
				if (speakAinefficacy)
					SetVoiLs("#WX");
					
				if (speakBinefficacy)
				{
					SetVoiLs(c_m[bh][3]);
					SetVoiLs("#WX");
				}
				else
				{
					if (!speakAinefficacy && speak_away == 1)
					{
						SetVoiLs("#VS");
						SetVoiLs(c_m[bh][3]);
					}
				}
			}
				
			if (speakgoal || speakht || speakft)
				SetVoiLs("#" + c_bf[bh][1] + "-" + c_bf[bh][2]);
				
			if (speakst)
				SetVoiLs("#ST");
			else if (speakht)
				SetVoiLs("#HT");
			else if (speakft)
				SetVoiLs("#FT");
			
			if (speakAred)
			{
				SetVoiLs(c_m[bh][2]);
				SetVoiLs("#" + c_bf[bh][4] + "r");
			}
			if (speakBred)
			{
				SetVoiLs(c_m[bh][3]);
				SetVoiLs("#" + c_bf[bh][5] + "r");
			}
		}
//	}
//	catch(e){}
}

function InsertInfo(c0,c1,c2,c3)
{
	$("goallog00").style.display = "block";
	$("last_info").insertRow(0);
	$("last_info").rows[0].insertCell(0);
	$("last_info").rows[0].cells[0].colSpan = 4;
	$("last_info").rows[0].cells[0].align = "center";
	$("last_info").rows[0].cells[0].innerHTML = "<img src=http://img.7m.cn/icon/shade.gif width=100% height=1>"
	$("last_info").insertRow(0);
	$("last_info").rows[0].insertCell(0);
	$("last_info").rows[0].insertCell(0);
	$("last_info").rows[0].insertCell(0);
	$("last_info").rows[0].insertCell(0);
	$("last_info").rows[0].cells[0].innerHTML = c0;
	$("last_info").rows[0].cells[1].innerHTML = c1;
	$("last_info").rows[0].cells[2].align = "center";
	$("last_info").rows[0].cells[2].innerHTML = c2;
	$("last_info").rows[0].cells[3].align = "right";
	$("last_info").rows[0].cells[3].innerHTML = c3;
	$("last_info").rows[0].cells[0].width = "9%";
	$("last_info").rows[0].cells[1].width = "38%";
	$("last_info").rows[0].cells[2].width = "15%";
	$("last_info").rows[0].cells[3].width = "38%";
	if ($("last_info").rows.length >= 70)
	{
		for(var i=0;i<4;i++)
			$("last_info").deleteRow($("last_info").rows.length - 1);
	}
}

function Replace_Team_name(str)
{
	var rltstr = str;
	if (lan == "en" || lan == "vn" || lan == "th")
	{
		if (rltstr.length > 21)
			rltstr = rltstr.substring(0, 21);
	}
	else
	{
		if (rltstr.length > 8)
			rltstr = rltstr.substring(0, 8);
	}	
	return rltstr.replace("(中)", "").replace("(H)", "");
}

function MoveGame(bh)
{
	if(time_type == 0)
	{
		return;
	}
	if ($("gameover") != null)
	{
		if ($("gameover").style.display == "none")
			$("gameover").style.display = "";
	}
	if (EndGamebh.indexOf("[" + bh + "]") == -1)
	{
		var row1 = $("bh" + bh);
		if (row1 == null)
			return;
		var row2 = $("resume_" + bh);
		row1.parentNode.appendChild(row1);
		row2.parentNode.appendChild(row2);
		EndGamebh += "[" + bh + "]";
		if (($("live_Table").rows[1].id == "" && $("live_Table").rows[2].id == "") || ($("live_Table").rows[1].id == "" && $("live_Table").rows[2].id == "gameover"))
			$("live_Table").deleteRow(1);
		updateRowColor()
	}
}

function ChkIe()
{
	var isMinIE4 = (document.all) ? 1 : 0;
	var verDetail = 0;
	try{
		verDetail = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+4));
	}
	catch(e){
		verDetail = 0;
	}
	var isMinIE55 = (isMinIE4 && verDetail > 5) ? 1 : 0;
	var bcontinue = true;
	if(!isMinIE55){
		bcontinue = false;
	}
	return bcontinue;
}

function Gold(live,bf,an,bn,Class,glColor)
{
	GoalTips += '<div style="float: left; width: 100%; margin-top: 6px; font-size: 14px; background: #FFF;">'
				+ '<div style="float: left; height: 20px; line-height: 150%; width: 26%; font-family: Tahoma;color: #FFFFFF; text-align: center; font-weight: bold; background: ' + glColor + ';">' + Class + '</div>'
				+ '<div style="float: left; height: 20px; line-height: 150%; width: 31%; font-family: Tahoma;font-weight: bold; padding-left: 3px;text-align: right; word-break: break-all;overflow: hidden;">' + an + '</div>'
				+ '<div style="float: left; height: 20px; line-height: 20px; width: 9%; font-weight: bold; font-size: 16px; text-align: center; word-break: break-all;">' + bf + '</div>'
				+ '<div style="float: left; height: 20px; line-height: 150%; width: 31%; font-family: Tahoma;font-weight: bold; padding-left: 3px;text-align: left; word-break: break-all;overflow: hidden;">' + bn + '</div>'
				+ '</div>';
	GoalTips_Count++;
}

var TipsC = 30;
function ShowGoalTips()
{
	if (isIE)
	{
		tipswidth = GOAL_TIPS_WIDTH;
		tipsheight = GoalTips_Count * 27;
		var tips_ad = "";
		if (typeof(TipsAd) != "undefined" && TipsAd != "")
		{
			tipsheight += 26;
			tips_ad = '<div style="width: 100%; line-height: 21px; background-color: #FFE; text-align: center; color: #00F; font-weight: 700; margin-top: 5px;">' + TipsAd + '</div>';
		}
		GoalTips =	 '<div style="border: 1px solid #999999;width: ' + tipswidth + 'px;background: #FFFFFF;">'
					+ '<div style="float: left; border: 1px solid #FFFFFF;font-size: 12px;background: #EFEFEF;padding: 2px;">'
					+ '<div style="float: left; color: #FFFFFF;font-size: 12px;background: #006633;font-family: Tahoma;font-weight: bold;text-align: right;padding-top: 2px;padding-bottom: 2px;padding-right: 6px;width: 100%;height: 19px;">www.7m.cn</div>'
					+ GoalTips
					+ tips_ad
					+ '</div>'
					+ '</div>';
		sPopup = window.createPopup();
		sPopupBody = sPopup.document.body;
		sPopupBody.style.cursor="pointer";
		sPopupBody.innerHTML = GoalTips;
		sPopup.document.body.onmouseover = new Function("clearTimeout(topMost)");
		sPopup.document.body.onmouseout = PopupSoccerShow;
		sPopup.document.body.oncontextmenu = PopupSoccerClose;
		sPopup.document.body.onclick = PopupSoccerClose;
		TipsC = 30;
		PopupSoccerShow();
	}
}

function PopupSoccerShow()
{
	sPopup.show(screen.width / 2 - (tipswidth / 2), 0, tipswidth, 28 + tipsheight);
	if (typeof(topMost) == "number")
		clearTimeout(topMost);
	topMost=setTimeout("PopupSoccerShow()", 500);
	sPopupS = true;
	if (TipsC < 0)
		PopupSoccerClose();
	--TipsC;
}

function PopupSoccerClose()
{
	clearTimeout(topMost);
	sPopup.hide();
	sPopupS = false;
}

var jqsy2 = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="1" height="1" id="voi" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/live/voi.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="/live/voi.swf" quality="high" bgcolor="#ffffff" width="1" height="1" name="voi" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';

var voiobj;
function goaltips()
{
	if ($("bs2").innerHTML == "")
	{
		$("bs2").innerHTML = jqsy2;
	}
}
var getcfed = false;
function GetVoiOjb()
{
	if (voiobj == null)
	{
		voiobj = (document.embeds.length > 1) ? document.embeds["voi"] : $("voi");
	}
}
function GetCF()
{
	if (!getcfed)
	{
		GetVoiOjb();
		voiobj.SetServer("ctc.7m.cn");
		voiobj.GCF(voi_lng);
		getcfed = true;
	}
}
function SetVoiLs(v)
{
	if (!getcfed)
	{
		GetCF();
	}
	voiobj.SetList(v);
}
var voiArr = new Array();
function SelectVoi(chkobj, bh)
{
	if (chkobj.className == "sound noS")
	{
		SetVoiLs(c_m[bh][2]);
		SetVoiLs("#VS");
		SetVoiLs(c_m[bh][3]);
		voiArr[bh] = 1;
		chkobj.className = "sound onS";
	}
	else
	{
		voiArr[bh] = null;
		chkobj.className = "sound noS";
	}
}


function SpeakSetting(ecd)
{
	var obj = $("speak_setting");
	if (obj.innerHTML == "")
		obj.innerHTML = '<iframe src="/live/speak_setting_' + ecd + '.htm" frameborder="0" width="220" height="150" scrolling="no"></iframe>';
	with(obj.style)
	{
		left = (window.screen.width-parseInt(width))/2 + "px";
		top = (window.screen.height-parseInt(height))/3 + "px";
		display = "";
	}
}

function CloseSpeakSetting(ecd)
{
	setCookie("speak_away", speak_away);
    setCookie("speak_red", speak_red);
    setCookie("speak_all", speak_all);
	$("speak_setting").style.display = "none";
}

/*function ChangeLine(n)
{
	var re = /http:\/\/(\S+?\.7m\.cn[^\/]*?)\/\S+/i;
	var u = top.location.href;
	if (re.test(u))
	{
		var h = u.replace(re, "$1");
		top.location.href = u.replace(h, "live" + n + ".7m.cn");
	}
}*/



