var Encode = 'vn';
var fn = 0;
var match_list = "", select_match_str = "";
var xmlhttp=null;
var isIE=true;
var parser=null;
var oSerializer=null;
var oldxml="";
if(window.ActiveXObject)
{
xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.3.0");
}
else
{
xmlhttp = new XMLHttpRequest();
parser = new DOMParser();
oSerializer = new XMLSerializer();
isIE=false;
}
var Ecoding;
switch(Encode)
{
case "gb":
Ecoding = new Array("一","二","三","四","加","全场","上/下","分差","总分","半","全","赛事选择","","","","","赛事","状态","球队","让","","单/双","单","双");
break;
case "en":
Ecoding= new Array("1","2","3","4","OT","FT","1/2","SD","T","H","F","Select match","OverTime","FullTime","Score difference","Total","League","Status","Team","+/-","Handicap","odd/even","odd","even");
break;
case "th":
Ecoding= new Array("1","2","3","4","OT","FT","1/2","SD","T","H","F","เลือกลีก","OverTime","FullTime","Score difference","Total","ลีก","สถานะ","ทีม","+/-","แฮนดีแคพ","คี่/คู่","คี่","คู่");
break;
case "vn":
Ecoding= new Array("1","2","3","4","OT","FT","H1/H2","SD","T","H","F","Chọn giải đấu","Chọn giải đấu","Bù giờ","Cả trận","Hiệu số bàn thắng/ thua","Tổng tỷ số","Giải đấu","Chi tiết","Đội bóng","+/-","chẵn lẻ","lẻ","chẵn");
break;
case "kr":
Ecoding= new Array("1","2","3","4","OT","FT","1/2","SD","T","H","F","경기선택","경기선택","연장전","풀타임","점수차","시간","상태","팀","","+/-","홀짝","홀","짝");
break;
default:
Ecoding= new Array("一","二","三","四","加","全場","上/下","分差","總分","半","全","賽事選擇","","","","","賽事","狀態","球隊","让","","單/双","單","双");
break;
}
function InitializeData()
{
xmlhttp.open("get", "Data/" + Encode + ".xml?" + Number(new Date()).toString().substring(0,10), true);
xmlhttp.onreadystatechange = InitializeReady;
xmlhttp.send(null);
}
function Decimal_point(tmpior,show){
var sign="";
sign =((tmpior < 0)?"Y":"N");
tmpior = (Math.floor(Math.abs(tmpior) * show + 1 / show )) / show;
return (tmpior * ((sign =="Y")? -1:1)) ;
}
function get_HK_ior( H_ratio, C_ratio){
var out_ior=new Array();
var line,lowRatio,nowRatio,highRatio;
var nowType="";
if (H_ratio <= 1000 && C_ratio <= 1000){
out_ior[0]=H_ratio;
out_ior[1]=C_ratio;
return out_ior;
}
line=2000 - ( H_ratio + C_ratio );
if (H_ratio > C_ratio){
lowRatio=C_ratio;
nowType = "C";
}else{
lowRatio = H_ratio;
nowType = "H";
}
if (((2000 - line) - lowRatio) > 1000){
//對盤馬來盤
nowRatio = (lowRatio + line) * (-1);
}else{
//對盤香港盤
nowRatio=(2000 - line) - lowRatio;
}
if (nowRatio < 0){
highRatio = Math.floor(Math.abs(1000 / nowRatio) * 1000) ;
}else{
highRatio = (2000 - line - nowRatio) ;
}
if (nowType == "H"){
out_ior[0]=lowRatio;
out_ior[1]=highRatio;
}else{
out_ior[0]=highRatio;
out_ior[1]=lowRatio;
}
return out_ior;
}
function history(id,param)
{
var lang_index;
if(lang == "big")
{
lang_index = "0";
}
else if(lang == "gb")
{
lang_index = "1";
}
else
{
lang_index = "2";
}
if(param == "3")
{
window.open( "chart.htm?ecd=" + lang_index + "&id=" + id);
}
else
{
window.open( "log_" + lang + ".shtml?id="+id, "", "height=450px,width=480px,toolbar=no,scrollbars=yes,menubar=no");
}
}
function InitializeReady()
{
if(xmlhttp.readyState!=4)return;
var XmlDoc;
if(isIE)
{
XmlDoc = xmlhttp.responseXML;
if(XmlDoc.xml=="")return;
}
else
{
XmlDoc = parser.parseFromString(xmlhttp.responseText,"text/xml");
if(XmlDoc.documentElement.tagName=="parsererror")return;
var xml= oSerializer.serializeToString(XmlDoc.documentElement);
if(xml=="")return;
}
var root = XmlDoc.documentElement;
root =root.getElementsByTagName("c");
if(root.length>1)
{
fn = parseInt(root[0].firstChild.nodeValue);
if(root.length>1)
{
var tmp_rows="";
for (var i=1;i" +
"" +
" " + Ecoding[11] + ":"+ select_match_str + "" +
"" +
"" +
" " + Ecoding[16] + "" +
" " + Ecoding[17] + "" +
" " + Ecoding[18] + "" +
""+Ecoding[19]+"" +
" " + Ecoding[0] + "" +
" " + Ecoding[1] + "" +
" " + Ecoding[2] + "" +
" " + Ecoding[3] + "" +
" " + Ecoding[4] + "" +
" " + Ecoding[5] + "" +
" " + Ecoding[6] + "" +
" " + Ecoding[7] + "" +
" " + Ecoding[8] + "" +
""+Ecoding[21]+"" +
"" +
"" +
tmp_rows +
"";
lv.innerHTML = liveTable;
ReadData();
}
else
{
lv.innerHTML = "
";
}
}
function BuilderHtml(tr_style, bh, state, s_name, match_color, match_type, start_time,h_name, a_name,
set_h1, set_h2, set_h3, set_h4, set_h5,set_h, set_a1, set_a2, set_a3, set_a4, set_a5, set_a, odds)
{
if (match_list.indexOf("{" + s_name + "}") == -1)
{
match_list += "{" + s_name + "}";
select_match_str += " " + s_name + " ";
}
var hda_home, hda_away, ah_home, ah_away, ah_handicap1,ah_handicap2;
var hda_onclick = '', ah_onclick = '',ah_onclick1 = '', ah_onclick2 = '';
var run_str = '';
var dan_str = '', shuang_str='';
if(typeof(odds) != "undefined" && odds != "")
{
var oddsParams = odds.split(',');
if(oddsParams[1] == "True")
{
run_str = "
";
}
if(typeof(oddsParams[4]) == "undefined" || oddsParams[3] == "")
{
hda_home = "";
hda_away = "";
}
else
{
dan_str = '[' + Ecoding[22] + ']';
shuang_str = '[' + Ecoding[23] + ']';
hda_home = parseFloat(oddsParams[3].split('/')[0]);
hda_away = parseFloat(oddsParams[3].split('/')[1]);
hda_onclick = "onClick=\"history("+oddsParams[0]+", 2)\" style=\"cursor:pointer\"";
}
if(typeof(oddsParams[4]) == "undefined" || oddsParams[4] == "")
{
ah_home = "";
ah_away = "";
ah_handicap1 = "";
ah_handicap2 = "";
}
else
{
var ior=new Array();
var iorH = oddsParams[4].split('/')[0];
var iorC = oddsParams[4].split('/')[1];
if(iorH < 3) iorH *=1000;
if(iorC < 3) iorC *=1000;
iorH=parseFloat(iorH);
iorC=parseFloat(iorC);
ior = get_HK_ior(iorH, iorC);
ior[0]/=1000;
ior[1]/=1000;
ah_home = "[" + Decimal_point(ior[0],100)+"]";
ah_away = "[" + Decimal_point(ior[1],100)+"]";
if(oddsParams[4].split('/')[4] == "1" )
{
ah_handicap1 = parseFloat(oddsParams[4].split('/')[2])
ah_handicap2 = "";
ah_onclick1 = "onClick=\"history("+oddsParams[0]+", 3)\" style=\"cursor:pointer\"";
ah_onclick2 = "";
}
else
{
ah_handicap1 = "";
ah_handicap2 = parseFloat(oddsParams[4].split('/')[2]);
ah_onclick1 = "";
ah_onclick2 = "onClick=\"history("+oddsParams[0]+", 3)\" style=\"cursor:pointer\"";
}
ah_onclick = "onClick=\"history("+oddsParams[0]+", 3)\" style=\"cursor:pointer\"";
}
}
else
{
hda_home = "";
hda_away = "";
ah_home = "";
ah_away = "";
ah_handicap1 = "";
ah_handicap2 = "";
}
var set_result = AmountResult(match_type,state,set_h1,set_h2,set_h3,set_h4,set_h5,set_h,set_a1,set_a2,set_a3,set_a4,set_a5,set_a);
var live_game1='', live_game2='', live_game_class1='', live_game_class2='';
var lang_index;
if(lang == "big")
{
lang_index = 0;
}
else if(lang == "gb")
{
lang_index = 1;
}
else if(lang == "en")
{
lang_index = 2;
}
else if(lang == "vn")
{
lang_index = 3;
}
else if(lang == "th")
{
lang_index = 4;
}
else
{
lang_index = 5;
}
if (state >= 7 && state <= 12)
{
if(set_h > set_a)
{
live_game1 = "赢|贏|win|Thắng kèo|ชนะ|승".split('|')[lang_index];
live_game2 = "輸|输|lose|Thua kèo|แพ้|패".split('|')[lang_index];
live_game_class1 = "bf_win";
live_game_class2 = "bf_lose";
}
else
{
live_game1 = "輸|输|lose|Thua kèo|แพ้|패".split('|')[lang_index];
live_game2 = "赢|贏|win|Thắng kèo|ชนะ|승".split('|')[lang_index];
live_game_class1 = "bf_lose";
live_game_class2 = "bf_win";
}
}
var str = "" +
" "
+ s_name + "
" + AmountTimeDiff(start_time, 4) + run_str + "" +
"" + StateToStr(state) + "" +
"" + h_name + "" + ah_home + "" +
"" + ah_handicap1 + "" +
" " + set_result[0] + "" +
" " + set_result[1] + "" +
" " + set_result[2] + "" +
" " + set_result[3] + "" +
" " + set_result[4] + "" +
" " + set_result[5] + "" +
" " + set_result[6] + "" +
" " + set_result[14] + "" +
" " + set_result[16] + "" +
"" + dan_str + "" + hda_home + "" +
"" + live_game1 + "" +
"" +
"" +
"" + a_name + "" + ah_away + "" + "" +
"" + ah_handicap2 + "" +
" " + set_result[7] + "" +
" " + set_result[8] + "" +
" " + set_result[9] + "" +
" " + set_result[10] + "" +
" " + set_result[11] + "" +
" " + set_result[12] + "" +
" " + set_result[13] + "" +
" " + set_result[15] + "" +
" " + set_result[17] + "" +
"" + shuang_str + "" + hda_away + "" +
"" + live_game2 + "" +
"";
return str;
}
function StateToStr(i)
{
//var StateStr_gb = new Array("未开始", "第1节", "第2节", "第3节", "第4节", "加时", "休息", "完场", "加时
结束", "廷迟", "推迟", "腰斩", "取消", "中断", "中断", "中断", "中断", "中断");
//var StateStr_big = new Array("未開始", "第1節", "第2節", "第3節", "第4節", "加時", "休息", "完場", "加时
結束", "廷遲", "推遲", "腰斬", "取消", "中斷", "中断", "中断", "中断", "中断");
var StateStr_gb = new Array("未开始", "第1节", "第2节", "第3节", "第4节", "加时", "休息", "完场", "加时
结束", "廷迟", "中断", "推迟", "腰斩", "取消", "待定");
var StateStr_big = new Array("未開始", "第1節", "第2節", "第3節", "第4節", "加時", "休息", "完場", "加時
結束", "廷遲", "中断", "推遲", "腰斬", "取消", "待定");
var StateStr_en = new Array("NSY", "1st Set", "2nd Set", "3rd Set", "4th Set", "ET", "HT", "FT", "ETO", "Postpone", "Pause", "Delay", "Cut", "Canc.", "Undecided");
var StateStr_th = new Array("NSY", "1st Set", "2nd Set", "3rd Set", "4th Set", "ET", "HT", "FT", "ETO", "Postpone", "Pause", "Delay", "Cut", "Canc.", "Undecided");
var StateStr_vn = new Array("NSY", "1st Set", "2nd Set", "3rd Set", "4th Set", "ET", "HT", "FT", "ETO", "Postpone", "Pause", "Delay", "Cut", "Canc.", "Undecided");
var StateStr_kr = new Array("NSY", "1st Set", "2nd Set", "3rd Set", "4th Set", "ET", "HT", "FT", "ETO", "Postpone", "Pause", "Delay", "Cut", "Canc.", "Undecided");
var rltstr = "";
switch(Encode)
{
case "gb":
rltstr = StateStr_gb[i];
break;
case "en":
rltstr = StateStr_en[i];
break;
case "th":
rltstr = StateStr_th[i];
break;
case "vn":
rltstr = StateStr_vn[i];
break;
case "kr":
rltstr = StateStr_kr[i];
break;
default:
rltstr = StateStr_big[i];
break;
}
return rltstr;
}
function ReadData()
{
try
{
xmlhttp.open("get", "ChangeData/change.xml?" + Number(new Date()).toString().substring(0,10), true);
xmlhttp.onreadystatechange = ReadReady;
xmlhttp.send(null);
}
catch(e){}
if (typeof(ReadXml_Time) != "undefined")
clearTimeout(ReadXml_Time);
ReadXml_Time = setTimeout("ReadData()", 2000);
}
function ReadReady()
{
if (xmlhttp.readyState != 4) return;
var XmlDoc,xml;
if(isIE)
{
XmlDoc = xmlhttp.responseXML;
xml=XmlDoc.xml;
if(xml==""||oldxml==xml)return;
}
else
{
XmlDoc = parser.parseFromString(xmlhttp.responseText,"text/xml");
if(XmlDoc.documentElement.tagName=="parsererror")return;
xml= oSerializer.serializeToString(XmlDoc.documentElement);
if(xml==""||oldxml==xml)return;
}
var root=XmlDoc.documentElement.getElementsByTagName("c");
if (root.length > 0)
{
var nextFn = parseInt(root[root.length-1].firstChild.nodeValue);
//alert(nextFn + " " + fn)
if (nextFn > fn)
{
ReadData2();
}
else
{
var Refresh = root[0].firstChild.nodeValue;
if (document.cookie.indexOf("AmFootBall_Rst=") < 0 )
{
document.cookie = "AmFootBall_Rst=" + Refresh;
}
var getOldRefresh = document.cookie.substring(document.cookie.indexOf("AmFootBall_Rst=")+15,document.cookie.indexOf("AmFootBall_Rst=")+16);
if (getOldRefresh != Refresh)
{
var Rnd = Math.round(Math.random()*9000)+1000;
document.cookie = "AmFootBall_Rst=" + Refresh;
if (document.cookie !="")
{
setTimeout("location.reload()", Rnd);
return;
}
}
for (var i=1;i 0)
{
var Refresh = root[0].firstChild.nodeValue;
if (document.cookie.indexOf("AmFootBall_Rst=") < 0 ){document.cookie = "AmFootBall_Rst=" + Refresh;}
var getOldRefresh = document.cookie.substring(document.cookie.indexOf("AmFootBall_Rst=")+15,document.cookie.indexOf("AmFootBall_Rst=")+16);
if (getOldRefresh != Refresh)
{
var Rnd = Math.round(Math.random()*9000)+1000;
document.cookie = "AmFootBall_Rst=" + Refresh;
if (document.cookie !="")
{
setTimeout("location.reload()", Rnd);
return;
}
}
for (var i=1;i 12)
{
eval("Update_Live(" + root[i].firstChild.nodeValue + ")");
}
else
{
//eval("Update_Odds(" + root[i].firstChild.nodeValue + ")");
}
}
fn = parseInt(root[root.length-1].firstChild.nodeValue);
}
}
function Update_Odds(bh, type,id,odds1,odds2,odds3,flag,oper,shangpan)
{
if(document.getElementById("r1_" + bh) == null)
{
return;
}
var obj;
if(type == 2) //ah
{
var ior=new Array();
var iorH = odds1;
var iorC = odds2;
if(iorH < 3) iorH *=1000;
if(iorC < 3) iorC *=1000;
iorH=parseFloat(iorH);
iorC=parseFloat(iorC);
ior = get_HK_ior(iorH, iorC);
ior[0]/=1000;
ior[1]/=1000;
odds1 = Decimal_point(ior[0],100);
odds2 = Decimal_point(ior[1],100);
var tmp;
var obj_h = document.getElementById("h_ah_" + bh);
var odds1_old = obj_h.innerHTML.replace("[","").replace("]","").replace(" ","");
if(odds1_old == '' || parseFloat(odds1) != parseFloat(odds1_old))
{
obj_h.innerHTML = "[" + parseFloat(odds1)+"]";
if(odds1_old != '')
{
//alert(obj.innerHTML)
if(parseFloat(odds1) < parseFloat(odds1_old))
{
obj_h.style.color = "#00FF00";
setTimeout("SetBuleColor('" + obj_h.id + "')", 10000);
}
else
{
obj_h.style.color = "#FF0000";
setTimeout("SetBuleColor('" + obj_h.id + "')", 10000);
}
}
}
var obj_a = document.getElementById("a_ah_" + bh);
var odds2_old = obj_a.innerHTML.replace("[","").replace("]","").replace(" ","");
//alert(odds2_old + ' ' + odds2);
if(odds2_old == '' || parseFloat(odds2) != parseFloat(odds2_old))
{
obj_a.innerHTML = "[" + parseFloat(odds2)+"]";
if(odds2_old != '')
{
if(parseFloat(odds2) < parseFloat(odds2_old))
{
obj_a.style.color = "#00FF00";
setTimeout("SetBuleColor('" + obj_a.id + "')", 10000);
}
else
{
obj_a.style.color = "#FF0000";
setTimeout("SetBuleColor('" + obj_a.id + "')", 10000);
}
}
}
if(shangpan == "1" )
{
document.getElementById("ah_1_" + bh).innerHTML = parseFloat(odds3);
document.getElementById("ah_2_" + bh).innerHTML = "";
}
else
{
document.getElementById("ah_1_" + bh).innerHTML = "";
document.getElementById("ah_2_" + bh).innerHTML = parseFloat(odds3);
}
}
else if(type == 3) //hda
{
obj = document.getElementById("h_hda_" + bh);
var odds1_old = obj.innerHTML.replace(" ","");
if(odds1_old == '' || parseFloat(odds1) != parseFloat(odds1_old))
{
obj.innerHTML = parseFloat(odds1);
if(odds1_old != '')
{
if(parseFloat(odds1) < parseFloat(odds1_old))
{
obj.style.color = "#00FF00";
setTimeout("SetBuleColor('" + obj.id + "')", 10000);
}
else
{
obj.style.color = "#FF0000";
setTimeout("SetBuleColor('" + obj.id + "')", 10000);
}
}
}
obj = document.getElementById("a_hda_" + bh);
var odds2_old = obj.innerHTML.replace(" ","");
if(odds2_old == '' || parseFloat(odds2) != parseFloat(odds2_old))
{
obj.innerHTML = parseFloat(odds2);
if(odds2_old != '')
{
if(parseFloat(odds2) < parseFloat(odds2_old))
{
obj.style.color = "#00FF00";
setTimeout("SetBuleColor('" + obj.id + "')", 10000);
}
else
{
obj.style.color = "#FF0000";
setTimeout("SetBuleColor('" + obj.id + "')", 10000);
}
}
}
}
}
function Update_Live(bh, match_type,state, set_h1, set_h2, set_h3, set_h4, set_h5,set_h, set_a1, set_a2, set_a3, set_a4, set_a5,set_a)
{
if (document.getElementById("r1_" + bh) == null) return;
var set_result = AmountResult(match_type,state,set_h1,set_h2,set_h3,set_h4,set_h5,set_h,set_a1,set_a2,set_a3,set_a4,set_a5,set_a);
SetElementHtmlValue("state_" + bh, StateToStr(state), false);
SetElementHtmlValue("h1_" + bh, set_result[0], true);
SetElementHtmlValue("h2_" + bh, set_result[1], true);
SetElementHtmlValue("h3_" + bh, set_result[2], true);
SetElementHtmlValue("h4_" + bh, set_result[3], true);
SetElementHtmlValue("h5_" + bh, set_result[4], true);
SetElementHtmlValue("h6_" + bh, set_result[5], false);
SetElementHtmlValue("h7_" + bh, set_result[6], false);
SetElementHtmlValue("h8_" + bh, set_result[14], false);
SetElementHtmlValue("a1_" + bh, set_result[7], true);
SetElementHtmlValue("a2_" + bh, set_result[8], true);
SetElementHtmlValue("a3_" + bh, set_result[9], true);
SetElementHtmlValue("a4_" + bh, set_result[10], true);
SetElementHtmlValue("a5_" + bh, set_result[11], true);
SetElementHtmlValue("a6_" + bh, set_result[12], false);
SetElementHtmlValue("a7_" + bh, set_result[13], false);
SetElementHtmlValue("a8_" + bh, set_result[15], false);
SetElementHtmlValue("h_" + bh, set_result[16], false);
SetElementHtmlValue("a_" + bh, set_result[17], false);
if (state >= 7 && state <= 12)
setTimeout("MoveFinalGame(" + bh + ")", 10000);
}
function AmountResult(match_type,state,set_h1,set_h2,set_h3,set_h4,set_h5,seth,set_a1,set_a2,set_a3,set_a4,set_a5,seta)
{
var set_result = new Array("","","","","","","",
"","","","","","","","","","","");
var set_h = new Array(set_h1,set_h2,set_h3,set_h4,set_h5);
var set_a = new Array(set_a1,set_a2,set_a3,set_a4,set_a5);
if ((state > 0 && state <= 8) || (state >=13 && state <= 17))
{
var state_step = state;
//alert(state_step);
if(state == 6)
{
state_step = 2
}
else if(state == 7 || state == 8)
{
state_step = state - 3;
}
else if(state >= 13 && state <= 17)
{
state_step = state - 12;
}
for (var i=0;i 0 && state != 13 && state != 14)
{
set_result[6] = set_h1 + set_h2;
set_result[13] = set_a1 + set_a2;
set_result[14] = Ecoding[9] + ":" + (set_result[6] - set_result[13]);
set_result[16] = Ecoding[9] + ":" + (set_h[0] + set_h[1] + set_a[0] + set_a[1]);
if(state == 3 || state == 4 || state == 5 || state == 7 || state == 8 || state ==17)
{
set_result[15] = Ecoding[10] + ":" + (seth - seta);
set_result[17] = Ecoding[10] + ":" + (seth + seta);
}
if(state == 5 || state == 7 || state == 8 || state ==17)
{
set_result[6] = (set_h1 + set_h2) + "/" + (set_h3 + set_h4);
set_result[13] = (set_a1 + set_a2) + "/" + (set_a3 + set_a4);
}
}
}
return set_result;
}
function SetElementHtmlValue(ElementName, HtmlValue, ChangeColor)
{
var obj = document.getElementById(ElementName);
if (obj != null)
{
var objText = obj.innerHTML;
if (objText != "x" && objText != HtmlValue.toString())
{
obj.innerHTML = HtmlValue;
if (ChangeColor)
{
obj.style.color = "#FF0000";
setTimeout("SetNorColor('" + obj.id + "')", 10000);
}
}
}
}
function SetNorColor(ElementName)
{
var obj = document.getElementById(ElementName);
if (obj != null)
obj.style.color = "#000000";
}
function SetBuleColor(ElementName)
{
var obj = document.getElementById(ElementName);
if (obj != null)
obj.style.color = "#0000FF";
}
function MoveFinalGame(bh)
{
var obj = document.getElementById("r1_" + bh);
var obj2 = document.getElementById("r2_" + bh);
if (obj != null && obj2 != null)
{
LiveTable.tBodies[0].appendChild(obj);
LiveTable.tBodies[0].appendChild(obj2);
}
}