﻿
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function getCookie(name)
{
	var cname = name + "=";
	var dc = document.cookie;
	if (dc.length > 0) 
	{
		begin = dc.indexOf(cname);
		if (begin != -1) 
		{
			begin += cname.length;
			end = dc.indexOf(";", begin);
			if (end == -1) end = dc.length;
			return dc.substring(begin, end);
		}
	}
	return null;
}
function writeCookie(name, value)
{ 
	var expire = ""; 
	var hours = 365;
	expire = new Date((new Date()).getTime() + hours * 3600000); 
	expire = ";path=/;expires=" + expire.toGMTString(); 
	document.cookie = name + "=" + value + expire; 
}

function SetCompany(id)
{
    document.getElementById("company"+ Config.companyID).className="";
    document.getElementById("company"+ id).className="selected";    
   	Config.companyID=id;
	LoadLiveFile();
	Config.writeCookie();
}


//显示进球窗口
var startani_C,startani_A,startani_B,pop_TC;
var oPopup;
try{ oPopup=window.createPopup();}
catch(e){}

function ShowCHWindow(str,matchnum)
{
imagewidth=452;
imageheight=33+33*matchnum ;

var st='<div style="width:450px;background:#fff;font-size:12px;line-height:20px; border:1px solid #4b8590; " ><span style="width:448px;background: #4b8590 url(../Mo_img/nav.gif) no-repeat 0 0;color:#fff;margin:1px;padding-left:5px;">【球盘体育】</span><div style="width:448px;margin:1px;padding:4px;">';
st=st +'					<table border=0 cellpadding=0 cellspacing=0 style="width:440px;">';
st=st +str
st=st +'					</table>';
st=st +'	</div>';
st=st +'</div>';
st=st + "<style type='text/css'>"
st=st + ".colYd{ text-align:center; color:#008000; width:100px; font-family:宋体, sans-serif; font-size:14px;}"
st=st + ".colYd em{ color:#ff0000; font-style:normal}"
st=st + "</style>"

x=280;
y=1;
switch(Config.winLocation)
{			
    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 = oPopup.document.body;
oPopupBody.innerHTML = st;
oPopupBody.style.cursor="pointer";
oPopupBody.title = "点击关闭";
oPopupBody.onclick=dismisspopup;
oPopupBody.oncontextmenu=dismisspopup;
pop_TC=50;
pop();
}

function pop(){
  try{
	oPopup.show(x,y,imagewidth, imageheight);
	startani_A=setTimeout("pop()",300);  //显示15秒
	if(pop_TC<0){dismisspopup();};
	pop_TC=pop_TC-1;
  }catch(e){}
}
function dismisspopup()
{	clearTimeout(startani_A);
	oPopup.hide();
}

function showgoallist(ID)
{
	window.open("http://data.qiupan.com/detail/" + ID +".html", "","scrollbars=yes,resizable=yes,width=668, height=720");
}
function  analysis(ID)
{
	var theURL="http://data.qiupan.com/analysis/" + ID +".html";
	window.open(theURL);
}
function AsianOdds(ID)
{
	if(ID.length>6){
		if(ID.indexOf("&")>0){
			ID = ID.substring(0,ID.indexOf("&"))
		}
	}
	var theURL="http://data.qiupan.com/odds/" + ID + ".html";
	window.open(theURL);
}

function EuropeOdds(ID)
{
	var theURL="http://data.qiupan.com/1x2/" + ID + ".htm";
	window.open(theURL);
}

function TeamPanlu_10(ID)
{
    var	theURL="http://data.qiupan.com/panlu/" + ID + ".html";
	window.open(theURL,"","width=640,height=700,top=10,left=100,resizable=yes,scrollbars=yes");
}
function oddsDetail(ID,cId)
{
	window.open("/odds/detail.asp?scheduleID=" + ID +"&companyID="+ cId, "","");
}
function ScoreDetail(ID)
{
	window.open("http://data.qiupan.com/detail/" + ID +".html", "","scrollbars=yes,resizable=yes,width=668, height=720");
}
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.useXmlHttp)  return new XMLHttpRequest(); 
    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);
    } 
    alert("对不起，您的电脑不支持 XML 插件，请安装好或升级浏览器。");
};

var flash_sound=Array(5);
flash_sound[0] = "<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' id='image1'><param name='movie' value='images/sound.swf'><param name='quality' value='high'><param name='wmode' value='transparent'></object>";
flash_sound[1] = "<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' id='image1'><param name='movie' value='images/notice.swf'><param name='quality' value='high'><param name='wmode' value='transparent'></object>";
flash_sound[2] = "<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' id='image1'><param name='movie' value='images/base.swf'><param name='quality' value='high'><param name='wmode' value='transparent'></object>";
flash_sound[3] = "<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' id='image1'><param name='movie' value='images/deep.swf'><param name='quality' value='high'><param name='wmode' value='transparent'></object>";
flash_sound[4] = "<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' id='image1'><param name='movie' value='images/oddsSound.swf'><param name='quality' value='high'><param name='wmode' value='transparent'></object>";

var state_ch=Array(18);
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[4]="取消,取消,Cancel";
state_ch[13]="<b>完</b>,<b>完</b>,<b>Ft</b>";
state_ch[14]="<font color=red>未</font>,<font color=red>未</font>,<font color=red>W</font>";
state_ch[15]="上,上,Part1";
state_ch[16]="<font color=blue>中</font>,<font color=blue>中</font>,<font color=blue>Half</font>";
state_ch[17]="下,下,Part2";
state_ch[18]="加,加,Ot";


var GoalCn="平手,平/半,半球,半/一,一球,一/球半,球半,球半/两,两球,两/两球半,两球半,两球半/三,三球,三/三球半,三球半,三球半/四球,四球,四球/四球半,四球半,四球半/五球,五球,五球/五球半,五球半,五球半/六球,六球,六球/六球半,六球半,六球半/七球,七球,七球/七球半,七球半,七球半/八球,八球,八球/八球半,八球半,八球半/九球,九球,九球/九球半,九球半,九球半/十球,十球".split(",");
function Goal2GoalCn(goal){ //数字盘口转汉汉字	
    if (goal==null || goal +""=="")
        return "";
    else{
	    if(goal>=0)  return GoalCn[parseInt(goal*4)];
	    else return "受"+ GoalCn[Math.abs(parseInt(goal*4))];
	}
}
var GoalCn2 = ["0", "0/0.5", "0.5", "0.5/1", "1", "1/1.5", "1.5", "1.5/2", "2", "2/2.5", "2.5", "2.5/3", "3", "3/3.5", "3.5", "3.5/4", "4", "4/4.5", "4.5", "4.5/5", "5", "5/5.5", "5.5", "5.5/6", "6", "6/6.5", "6.5", "6.5/7", "7", "7/7.5", "7.5", "7.5/8", "8", "8/8.5", "8.5", "8.5/9", "9", "9/9.5", "9.5", "9.5/10", "10", "10/10.5", "10.5", "10.5/11", "11", "11/11.5", "11.5", "11.5/12", "12", "12/12.5", "12.5", "12.5/13", "13", "13/13.5", "13.5", "13.5/14", "14" ];
function Goal2GoalCn2(goal){
	if (goal=="")
		return "";
	else{
		return GoalCn2[parseInt(goal*4)];
	}
}



//定义Config
var Config = new Object();
Config.language = 1;
Config.matchType = 0;
Config.oddsSound = 0;
Config.fontsize = 12;
Config.rank= 0;
Config.explain = 1;
Config.redcard = 1;
Config.detail = 1;
Config.vs = 1;
Config.odds = 1;
Config.yp = 1;
Config.op = 0;
Config.dx = 1;
Config.sound = 0;
Config.winLocation = 0;
Config.companyID=3;
Config.cCount=0;

Config.getCookie = function(type) {
    var Cookie=getCookie("Cookie");
    if(Cookie==null) Cookie=""; 
    var Cookie=Cookie.split("^");
    if(Cookie.length<=14) 	writeCookie("Cookie",null);
    else{
        this.language =parseInt(Cookie[0]);
        this.matchType =parseInt(Cookie[1]);
        this.oddsSound = parseInt(Cookie[2]);
        this.fontsize =parseInt(Cookie[3]);
        this.rank=parseInt(Cookie[4]);
        this.explain =parseInt(Cookie[5]);
        this.redcard =parseInt(Cookie[6]);
        this.detail =parseInt(Cookie[7]);
        this.vs =parseInt(Cookie[8]);
        this.yp =parseInt(Cookie[9]);
        this.op =parseInt(Cookie[10]);
        this.dx = parseInt(Cookie[11]);
        this.sound = parseInt(Cookie[12]);
        this.winLocation =parseInt(Cookie[13]);
		this.cCount =parseInt(Cookie[14]);
    }
    if(Cookie.length==15) 	this.companyID =parseInt(Cookie[14]);
    try{
        document.getElementById("Language"+ Config.language).style.color="#FF0000";
        if(this.rank==1)  document.getElementById("rank").checked=true;
        if(this.explain==0)  document.getElementById("explain").checked=false;
        if(this.redcard==0)  document.getElementById("redcard").checked=false;
        if(this.detail==0)  document.getElementById("detail").checked=false;
        if(this.vs==0)  document.getElementById("vs").checked=false;
        if(this.sound==-1)  document.getElementById("soundCheck").checked=false;
        if(this.sound>0)  document.getElementById("sound").value=this.sound;
        if(this.oddsSound==1)  document.getElementById("oddsSound").checked=true;
        if(this.winLocation==-1)  document.getElementById("windowCheck").checked=false;
        if(this.winLocation>0)  document.getElementById("winLocation").value=this.winLocation;
        if(type=="index2in1"){
            if(this.yp==1)  document.getElementById("yp").checked=true;
            if(this.op==1)  document.getElementById("op").checked=true;
            if(this.dx==1)  document.getElementById("dx").checked=true;
	    if(this.matchType==0)  document.getElementById("MatchType0").checked=true;
        }
        //else
            //document.getElementById("MatchType"+ Config.matchType).className="selected";
    }
    catch(e){}
}

Config.writeCookie = function() {
    var value=this.language+"^" + this.matchType+"^" +this.oddsSound +"^" + this.fontsize +"^" +  this.rank+"^" + this.explain +"^" + this.redcard +"^" + this.detail+"^" + this.vs+"^" + this.yp +"^" + this.op +"^" + this.dx +"^" +this.sound +"^" + this.winLocation +"^" +this.cCount +"^" + this.companyID;    
    writeCookie("Cookie",value);
}

//////////////////////////////////////////////////////////////////////////////
function addConcern(matchIndex, num) {
	
    var cCount = document.getElementById("concernCount").innerHTML;
	
    if (concernId.indexOf("_" + A[matchIndex][0] + "_") == -1) concernId += A[matchIndex][0] + "_";
    else return;
	
	
    writeCookie("Bet007live_concernId", concernId);
    cCount++;
	Config.cCount=parseInt(cCount);
    var tr = document.getElementById("tr1_" + A[matchIndex][0]);
    tr.cells[num].innerHTML = tr.cells[num].innerHTML.replace("addConcern", "deleteConcern").replace("+", "－").replace("添加", "取消").replace("Coll_up","Coll_down").replace("Coll_close","dis");
	
    var TTime = new Date();
    var isChange = false;
    var nt = A[matchIndex][10].split(":");
    var nd = A[matchIndex][11].split(",");
    var nt2 = new Date(TTime.getYear(), nd[1]+1, nd[2], nt[0], nt[1], 0);
    for (var i = 0; i < matchcount; i++) {
        if (concernId.indexOf("_" + A[i][0] + "_") != -1) {
			
            if (A[i][12] > 0) {
                var ot = A[i][10].split(":");
                var od = A[i][11].split(",");
                var ot2 = new Date(TTime.getYear(), od[1]+1, od[2], ot[0], ot[1], 0);
                if (ot2 > nt2) {
                    isChange = true;

                    MovePlace(A[i][0], A[matchIndex][0]);
                    break;
                }
            }
        }
    }
    if (!isChange || temp.length == 0) {
		MovePlace(0, A[matchIndex][0]);
	}
    document.getElementById("concernCount").innerHTML = cCount;
	Config.writeCookie();
}
function addMoreConcern(num) {
    var searchStr = document.getElementById("searchCorcen").value;
    if (searchStr == "") {
        alert("请输入搜索内容!");
        return;
    }
   
        for (var i = 0; i < matchcount; i++) {
            try {
				
                //if (A[i][2].indexOf(searchStr) != -1 || A[i][3].indexOf(searchStr) != -1 || A[i][4].indexOf(searchStr) != -1 || A[i][5].indexOf(searchStr) != -1 || A[i][6].indexOf(searchStr) != -1 || A[i][7].indexOf(searchStr) != -1 || A[i][8].indexOf(searchStr) != -1 || A[i][9].indexOf(searchStr) != -1 || A[i][10].indexOf(searchStr) != -1){
                    //addConcern(i, num);
				//}
				if(B[A[i][1]][1].indexOf(searchStr) != -1 || B[A[i][1]][2].indexOf(searchStr) != -1 || A[i][4].indexOf(searchStr) != -1 || A[i][5].indexOf(searchStr) != -1 || A[i][6].indexOf(searchStr) != -1 || A[i][7].indexOf(searchStr) != -1 || A[i][8].indexOf(searchStr) != -1 || A[i][9].indexOf(searchStr) != -1 || A[i][10].indexOf(searchStr) != -1){
					addConcern(i, num);
				}
            }
            catch (e) { }
			document.getElementById("searchCorcen").value="输入当天赛事中您关注的赛事或球队,例如：西甲、曼联";
        }   
}
function Collkeydown(e){
	var str=e.value.replace(/\s+/g,"");
	var FilterHtml=new Array();
	var as=document.getElementById("filters").getElementsByTagName("a");
	if(str!=""){
		for(var i=0;i<as.length;i++){
			if(as[i].innerHTML.indexOf(str) != -1){
				FilterHtml.push('<a href="#" onClick="selFilter(this.innerHTML)">'+as[i].innerHTML.replace(str,"<span style='font-weight:bold; color:#FF0000;'>"+str+"</span>")+'</a>');
			}
		}
		document.getElementById("Filter").innerHTML=FilterHtml.join("");
	}else{
		for(var i=0;i<as.length;i++){
			FilterHtml.push('<a href="#" onClick="selFilter(this.innerHTML)">'+as[i].innerHTML+'</a>');
		}
		document.getElementById("Filter").innerHTML=FilterHtml.join("");	
	}
	document.getElementById("Filter").style.visibility='visible';
}
function selFilter(v){
	document.getElementById("searchCorcen").value=v.replace(/<[^>].*?>/g,"");
	document.getElementById("Filter").style.visibility="hidden";
}
function deleteConcern(matchIndex, count) {
    if (concernId.indexOf("_" + A[matchIndex][0] + "_") == -1) return;
    var tr = document.getElementById("tr1_" + A[matchIndex][0]);
    tr.cells[count].innerHTML = tr.cells[count].innerHTML.replace("deleteConcern", "addConcern").replace("－", "+").replace("取消", "添加").replace("Coll_down","Coll_up").replace("dis","Coll_close");
    var TTime = new Date();
    var isChange = false;
    var nt = A[matchIndex][10].split(":");
    var nd = A[matchIndex][11].split(",");
    var nt2 = new Date(TTime.getYear(), nd[1]+1, nd[2], nt[0], nt[1], 0);
    for (var i = 0; i < matchcount; i++) {
        if (concernId.indexOf("_" + A[i][0] + "_") == -1) {
            if (A[matchIndex][12] == -1) {
                if (A[i][12] == -1) {
                    if (A[i][0] > 0) {
                        var ot = A[i][10].split(":");
                        var od = A[i][11].split(",");
                        var ot2 = new Date(TTime.getYear(), od[1]+1, od[2], ot[0], ot[1], 0);
                        if (ot2 > nt2) {
                            isChange = true;
                            MovePlace(A[i][0], A[matchIndex][0]);
                            break;
                        }
                    }
                }
            }
            else {
                if (A[i][0] > 0) {
                    var ot = A[i][10].split(":");
                    var od = A[i][11].split(",");
                    var ot2 = new Date(TTime.getYear(), od[1]+1, od[2], ot[0], ot[1], 0);
                    if (ot2 > nt2) {
                        isChange = true;
                        MovePlace(A[i][0], A[matchIndex][0]);
                        break;
                    }
                }
            }
        }
    }
    if (!isChange) {
        if (count > 10) {
            var list = new Array();
            list = oddsLastIndex.split(',');
            if (matchIndex > 10) {
                var num = matchIndex;
                var num2 = 0;
                for (var i = list.length - 2; i >= 0; i--) {
                    if (concernId.indexOf("_" + A[list[i]][0] + "_") != -1) {
                        num2 = i;
                    }
                }
                MovePlace(A[list[num2 - 1]][0], A[matchIndex][0]);
            }
            else {
                var num = list.length - 1;
                MovePlace(A[list[num - 1]][0], A[matchIndex][0]);
            }
        }
        else {
            if (matchIndex > 10) {
                var num2 = 0;
                for (var i = A.length - 1; i > 0; i--) {
                    if (concernId.indexOf("_" + A[i][0] + "_") != -1) {
                        num2 = i;
                    }
                }
                MovePlace(A[num2 - 1][0], A[matchIndex][0]);
            }
            else {
                var num = A.length - 1;
                MovePlace(A[num - 1][0], A[matchIndex][0]);
            }
        }
    } 
    concernId = concernId.replace("_" + A[matchIndex][0] + "_", "_");
    var cCount = document.getElementById("concernCount").innerHTML;
    writeCookie("Bet007live_concernId", concernId);
    cCount--;
    document.getElementById("concernCount").innerHTML = cCount;
	Config.cCount=parseInt(cCount);
	locod_ad(cCount,1);//变化广告位置
	Config.writeCookie();
}

function deleteAllConcern() {
    //    for (var i = 1; i <= matchcount; i++) {
    //        if (concernId.indexOf("_" + A[i][0] + "_") == -1) break;
    //        if (concernId.indexOf("_" + A[matchIndex][0] + "_") != -1) concernId = concernId.replace("_" + A[matchIndex][0] + "_", "_");
    //    }
    if (concernId == "_" || concernId == "")
        return;
    concernId = "_";
    document.getElementById("concernCount").innerHTML = 0;
    writeCookie("Bet007live_concernId", concernId);
    var allDate = document.getElementById("allDate");
    var s = document.createElement("script");
    s.type = "text/javascript";
    s.src = "xml/bf.js?" + Date.parse(new Date());
    allDate.removeChild(allDate.firstChild);
    allDate.appendChild(s, "script");
	Config.cCount=0;
	get_Concern();
    MakeTable();
	Config.writeCookie();
}
function locod_ad(cCount,tn){
	try {
		if(Config.cCount>0)
			document.getElementById('tr_0').style.display='block';
		else
			document.getElementById('tr_0').style.display='none';
		cCount+=1;

		for (var i = 1; i <= adinfo1.length; i++) {
			if(i==1 && tn==1)
				tn+=1;
			document.getElementById("table_live").rows(i*3+1).insertAdjacentElement("BeforeBegin",  document.getElementById("tr_ad" + i));
			//document.getElementById("table_live").rows(cCount + (i * 3 + 1) - tn).insertAdjacentElement("BeforeEnd", document.getElementById("tr_ad" + i));
		}
	}catch(e){}
}

