/** Copyright (c) 2000 - 2003 华体网 版权所有 */

// 调试开关
var g_bDebug = false;

/** 页面版本 'GB':简体;'BIG5':繁体;'MACO':澳门;'EN':英文*/
var g_sPageFormat = 'GB';
//var g_sPageFormat = 'BIG5';
//var g_sPageFormat = 'MACO';
//var g_sPageFormat = 'EN';

/** 共享模块根目录*/
var g_sModRoot = './mod/';

/** js所属目录设置 */
var g_sJSRoot = '';

/** 信息变化是否显示提示小窗口 */
var g_bPopupInfoTips = true;

if(typeof(g_sInitData) != "undefined"){
	// 加载文字编码信息
	loadPageFormatInfo();

	g_sJSRoot = './js/';
	/** 载入数据资源 */
	document.writeln('<script language="Javascript" src='+g_sJSRoot+'oddsResource_'+g_sPageFormat+'.js'+'></'+'script>');

	/** 赛事看板实例 */
	var g_pMatchBoard = new CMatchBoard();

	// 初始化进球声音的方法2
	document.writeln('<div style="position:absolute;top:-100;left:-100;width=0;height=0;"><OBJECT ID="oddsGoalMusic" width=0 height=0 classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"><PARAM NAME="AutoStart" VALUE="False"><PARAM NAME="FileName" VALUE=""><PARAM NAME="ShowControls" VALUE="false"><PARAM NAME="ShowStatusBar" VALUE="False"><PARAM NAME="Volume" VALUE="0"><PARAM NAME="Mute" VALUE="FALSE"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/" filename src autostart="false" enablecontextmenu="false" clicktoplay="false" enablepositioncontrols="false" showcontrols="0" showstatusbar="0" showdisplay="0"></embed></OBJECT></div>');
}

var g_arrOddsLinksList = new Array(
	new Array("spm_tvdetail","ico_tv","电视转播"),
	new Array("spm_weatherdetail","ico_tq","赛事天气"),
	new Array("spm_placedetail","ico_cd","比赛场地"),
	new Array("spm_panludetails","ico_pl_a","盘路列表"),
	new Array("spm_oddsdetail","ico_zst","走势图"),
	new Array("spm_predictions","ico_pre","心水推荐"),
	new Array("spm_saidetail","ico_sj","两队数据"),
	new Array("spm_zongdetail","ico_qz","赛事前瞻"),
	new Array("spm_spdetail","ico_tx","特别提醒")
);

function getOddsLinksStr(matchid,typeid,macid){
	try{
		var vTmp = g_arrOddsLinksList[typeid];
		return "<a href=javascript:"+vTmp[0]+"("+matchid+","+macid+")><img src=http://image.sportscn.com/live/p_l/ico/"+vTmp[1]+".gif alt="+vTmp[2]+" title="+vTmp[2]+" border=0 width=16 height=16></a>";
	}
	catch(e){
		return "";
	}
}

/**********************************************************************************************/
// begin of 比赛信息类
function CMatch(){
	/** 本场比赛的全局变量接口,也就是能够通过这个名字访问到比赛实例本身！(比如'g_pMatchBoard.getOneMatch(1234)'就能访问到比赛1234) */
	this.s_globalName = "";
	/** 本场比赛的生成者 */
	this.s_parentName = "g_pMatchBoard";

	/** 赛事最近更新时间戳 */
	this.n_modifyTimestamp = Number(0);
	/** 赛事初始位置（编辑排定的比赛显示顺序） */
	this.n_initPos = 0;

	/** 赛事ID */
	this.n_matchID = 0;
	this.n_macmatchID = 0;
	/** 比赛系列号 */
	this.n_seryID = 0;

	/** 比赛开始时间 */
	this.d_matchTime = new Date();

	/** 最后变盘时间 */
	this.d_changeTime = null;

	/** 主队id */
	this.n_team1ID = 0;
	/** 主队名 */
	this.s_team1Name = "";

	/** 客队id */
	this.n_team2ID = 0;
	/** 客队名 */
	this.s_team2Name = "";

	/** 主队当前水位 */
	this.n_agio1 = '';
	/** 客队当前水位 */
	this.n_agio2 = '';
	
	/** 主队排名 */
	this.n_order1 = '';
	/** 客队排名 */
	this.n_order2 = '';

	/** 当前让球 */
	this.n_vsNow = -1;
	/** 上次让球 */
	this.n_vsLast = -1;
	
	/** 场地性质（1:主场 2:客场 3:中立场） */
	this.n_fieldType = 0;
	
	/** 主客队顺序可以看成两位2进制,前面一位表示当前受让顺序,后面一位表示上次变化的受让顺序,0是主队在前,1是客队在前 */
	this.n_handicap = 0;

	/** 关联赔率页面 */
	this.b_oddsLink = 0;

	// 以下变量由程序自动设置。

	/** 让球变化 */
	this.b_isVsChange = 0;

	/** 主队水位变化标志（0:无变化 1:升 -1:降） */
	this.n_agioChange1 = 0;
	/** 客队水位变化标志（0:无变化 1:升 -1:降） */
	this.n_agioChange2 = 0;
	
	/** 比赛是否可见 */
	this.b_isVisible = true;

	/** 标志是否到了另一天的比赛了（初始化的时候要设置） */
	this.b_isNextDay = false;

	/** 标志是否需要变换主客队显示顺序（如果需要的话）*/
	this.b_needExchange = true;

	/** 定时器句柄 */
	this.p_vsShowTimer = null;
	/** 定时器句柄1 */
	this.p_goalShowTimer1 = null;
	/** 定时器句柄2 */
	this.p_goalShowTimer2 = null;
	// ...

	this.setVS = _CMatch_setVS;
	this.setAgios = _CMatch_setAgios;
	this.setChangeTime = _CMatch_setChangeTime;
	this.setMatchTime = _CMatch_setMatchTime;
	this.showIt = _CMatch_showIt;
	this.hideIt = _CMatch_hideIt;
	this.showRemark = _CMatch_showRemark;
	this.hideRemark = _CMatch_hideRemark;
	this.canBeShown = _CMatch_canBeShown;

	this.showSery = _CMatch_showSery;
	this.showTeam = _CMatch_showTeam;
	this.showVS = _CMatch_showVS;
	this.openDetail = _CMatch_openDetail;
	this.showOthers = _CMatch_showOthers;
	this.show = _CMatch_show;
	
	this.refresh = _CMatch_refresh;
	this.getRowDiv = _CMatch_getRowDiv;
	this.getRowTarget = _CMatch_getRowTarget;
	this.getItemTarget = _CMatch_getItemTarget;

	this.isMatchNotStarted = _CMatch_isMatchNotStarted;
	this.isMatchEnd = _CMatch_isMatchEnd;

	this.isMatchChanged = _CMatch_isMatchChanged;

	this.showAgioPic = _CMatch_showAgioPic;
	this.hideAgioPic = _CMatch_hideAgioPic;
	this.hideVSPic = _CMatch_hideVSPic;
}

function _CMatch_setVS(vsnow,vslast,handicap){
	if((vsnow != null && this.n_vsNow >= 0 && this.n_vsNow != vsnow) || (vslast != null && vsnow != null && handicap != null && this.n_handicap != handicap && (handicap == 1 || handicap == 2))){
		this.b_isVsChange = Number(1);
	}
	if(vsnow != null){
		this.n_vsNow = vsnow;
	}
	if(vslast != null){
		this.n_vsLast = vslast;
	}
	if(handicap != null){
		this.n_handicap = handicap;
	}
}

function _CMatch_setAgios(agio1,agio2){
	// 水位变化了!
	if(agio1 != null){
		if(this.n_agio1 == ''){
			this.n_agioChange1 = Number(0);
		}
		else if(this.n_agio1 < agio1){
			this.n_agioChange1 = Number(1);
		}
		else if(this.n_agio1 > agio1){
			this.n_agioChange1 = Number(-1);
		}
		else{
			this.n_agioChange1 = Number(0);
		}
		this.n_agio1 = agio1;
	}

	if(agio2 != null){
		if(this.n_agio2 == ''){
			this.n_agioChange2 = Number(0);
		}
		else if(this.n_agio2 < agio2){
			this.n_agioChange2 = Number(1);
		}
		else if(this.n_agio2 > agio2){
			this.n_agioChange2 = Number(-1);
		}
		else{
			this.n_agioChange2 = Number(0);
		}
		this.n_agio2 = agio2;
	}
}

function _CMatch_setChangeTime(timer){
	if(null == timer || timer.length < 4)
		return;

	var dTmp = null;
	try{
		dTmp = parseDate(timer);
	}catch(e){
		return;
	}

	if(isNaN(dTmp)){
		return;
	}
	else{
		this.d_changeTime = new Date();
		this.d_changeTime.setTime(dTmp);
	}
}

function _CMatch_setMatchTime(matchtime){
	var dTmp = parseDate(matchtime);
	if(isNaN(dTmp)){
		this.d_matchTime = null;
	}
	else{
		this.d_matchTime.setTime(dTmp);
	}
}

function _CMatch_showIt(){
	var pTag = this.getRowTarget();
	if(typeof(pTag) == "object"){
		this.b_isVisible = true;
		pTag.style.display = "";
		this.getItemTarget('chkFlag').checked = true;
		this.showRemark();

		pTag = null;
	}
}

function _CMatch_hideIt(){
	var pTag = this.getRowTarget();
	if(typeof(pTag) == "object"){
		this.b_isVisible = false;
		pTag.style.display = "none";
		this.hideRemark();
		pTag = null;
	}
}

function _CMatch_showRemark(){
	if(this.b_isNextDay == true){
		this.show(formatNumber(this.d_matchTime.getYear(),2)+STR_YEAR+formatNumber(this.d_matchTime.getMonth()+1,2)+STR_MONTH+formatNumber(this.d_matchTime.getDate(),2)+STR_DAY+'  '+weekArrList[this.d_matchTime.getDay()],'remark');
		this.getItemTarget('remarkdiv').style.display = "";
	}
	else{
		this.getItemTarget('remarkdiv').style.display = "none";
	}
}

function _CMatch_hideRemark(){
	this.getItemTarget('remarkdiv').style.display = "none";
}

// 在比赛看板初始化的时候调用
function _CMatch_canBeShown(){
	// 根据用户定制信息决定是否可以显示这场比赛
	this.b_isVisible = checkCustomizeSery(this.n_seryID);
	return this.b_isVisible;
}

function _CMatch_showSery(){
	var retStr = '';
	var vTmp;
	var vTmpArr;
	eval('try{vTmpArr = g_arrSeryMapList[g_arrSeryPos_'+this.n_seryID+'];}catch(e){vTmpArr = null;}');
	if(vTmpArr == null)
		vTmp = this.n_seryID;
	else{
		vTmp = vTmpArr[2];
	}

	retStr = vTmp;

	this.show(retStr+'<br>'+formatNumber(this.d_matchTime.getHours(),2)+':'+formatNumber(this.d_matchTime.getMinutes(),2),'sery');
}

function _CMatch_showTeam(num){
	var sRet = '';
	var tonum = num;
	if(true == this.b_needExchange && this.n_vsNow >= 0 && (this.n_handicap == 2 || this.n_handicap == 3)){
		if(num == 1)
			tonum = 2;
		else
			tonum = 1;
	}

	eval('sRet = sRet + this.s_team'+num+'Name;');
	
	var fieldStr = '';
	if(num == this.n_fieldType){
		fieldStr = ' <font class=1_font03>(<font class=1_font02>' + FIELDTYPE_STR_HOST + '</font>)</font>';
	}
	else if(this.n_fieldType > 2 && num == 1){
		fieldStr = ' <font class=1_font03>(<font class=1_font02>' + FIELDTYPE_STR_MIDDLE + '</font>)</font>';
	}

	var sOrderField = '';
	eval('var sOrderNum = this.n_order'+num+';');
	if(sOrderNum != ''){
		sOrderField = '<font class=1_font03>["+this.n_order'+num+'+"]</font>';
	}

	var sSecondStr = '';
	if(tonum == 1){
		eval('sSecondStr = "'+sOrderField+'&nbsp;&nbsp;<font class=1_font04><b>"+this.n_agio'+num+'+"</b></font>";');
	}
	else{
		eval('sSecondStr = "<font class=1_font04><b>"+this.n_agio'+num+'+"</b></font>&nbsp;&nbsp;'+sOrderField+'";');
	}

	eval('sRet = "<font class=1_dm01><a href=javascript:spm_teamdetail("+this.n_team'+num+'ID+")>"+sRet+"</a></font>'+fieldStr+'<br>'+sSecondStr+'";');

	eval('this.show(sRet,"team'+tonum+'");');
}

function _CMatch_showVS(){
	var sRet = '';
	var vGiveNow = '';
	var vGiveLast = '';
	eval('try{vGiveNow = ODDS_TVS_NAME_'+this.n_vsNow+';}catch(e){vGiveNow = "";}');
	eval('try{vGiveLast = ODDS_TVS_NAME_'+this.n_vsLast+';}catch(e){vGiveLast = "";}');
	var vPopGiveNow = '';
	var vPopGiveLast = '';
	if(vGiveNow != ""){
		if(false == this.b_needExchange && this.n_vsNow >= 0 && (this.n_handicap == 2 || this.n_handicap == 3)){
			vGiveNow = MATCH_GIVE_BALL + ' ' + vGiveNow;
		}

		vPopGiveNow = '<font color=blue><b>'+vGiveNow+'</b></font>';
		vGiveNow = '<a href="javascript:spm_oddsdetail('+this.n_matchID+')"><font class="1_font05"><B>'+vGiveNow+'</B></font></a>';
	}
	else{
		vGiveNow = '<font class="1_font05"><B>VS</b></font>';
		vPopGiveNow = vGiveNow;
	}

	if(this.b_isVsChange){
		eval(this.s_parentName+'.goalSound();');
		
		eval('var isOK = typeof('+this.s_parentName+'.p_vsImage) == "object" ? true : false;');
		if(isOK){
			vGiveNow += '<img name=vsImage_ROW'+this.n_matchID+' border=0 align=absmiddle>';
		}
	}

	if(vGiveLast != '' || this.d_changeTime != null){
		if(vGiveLast != ''){
			if(true == this.b_needExchange && this.n_vsLast >= 0 && (this.n_handicap == 1 || this.n_handicap == 2)){
				vGiveLast = MATCH_GIVE_BALL + ' ' + vGiveLast;
			}
			else if(false == this.b_needExchange && this.n_vsLast >= 0 && (this.n_handicap == 1 || this.n_handicap == 3)){
				vGiveLast = MATCH_GIVE_BALL + ' ' + vGiveLast;
			}
			vGiveLast = ' [' + vGiveLast + ']';
		}
		
		vPopGiveLast = '<br>' + vGiveLast;

		vGiveLast = '<br><font class="1_font03">' + vGiveLast;
		if(this.d_changeTime != null && typeof(this.d_changeTime) == "object"){
			vGiveLast += ' ' + formatNumber(this.d_changeTime.getDate(),2) + '日 ' + formatNumber(this.d_changeTime.getHours(),2) + ':' + formatNumber(this.d_changeTime.getMinutes(),2);
		}
		vGiveLast += '</font>';
	}

	sRet = vGiveNow+vGiveLast;
	this.show(sRet,'vs');

	if(this.b_isVsChange){
		eval("try{vsImage_ROW"+this.n_matchID+".src = "+this.s_parentName+".p_vsImage.src;}catch(e){}");		
		this.p_vsShowTimer = setTimeout('try{'+this.s_globalName+'.hideVSPic();}catch(e){}',g_nGoalFlashTimeOut);

		try{
			if(true == g_bPopupInfoTips){
				// pop up win for vs change!!!
				var vPopTeam1 = this.s_team1Name;
				var vPopTeam2 = this.s_team2Name;
				var vPopAgio1 = this.n_agio1;
				var vPopAgio2 = this.n_agio2;
				var vPopTonum = 1;
				if(true == this.b_needExchange && this.n_vsNow >= 0 && (this.n_handicap == 2 || this.n_handicap == 3)){
					vPopTeam1 = this.s_team2Name;
					vPopTeam2 = this.s_team1Name;
					vPopAgio1 = this.n_agio2;
					vPopAgio2 = this.n_agio1;
					vPopTonum = 2;
				}
				vPopTeam1 = '<font color=red><b>'+vPopTeam1+'</b></font>';
				vPopTeam2 = '<font color=red><b>'+vPopTeam2+'</b></font>';
				
				vPopAgio1 = '<font color=#000080><b>'+vPopAgio1+'</b></font>';
				vPopAgio2 = '<font color=#000080><b>'+vPopAgio2+'</b></font>';
				
				if(this.n_fieldType < 2 && this.n_fieldType >0){
					eval('vPopTeam'+vPopTonum+' += " (<font color=red>' + FIELDTYPE_STR_HOST + '</font>)";');
				}
				else if(this.n_fieldType > 2){
					eval('vPopTeam'+vPopTonum+' += " (<font color=red>' + FIELDTYPE_STR_MIDDLE + '</font>)";');
				}
				var vTmpSeryBgcolor = "#3A794E";
				var vTmpSeryName = "Unkown Sery";
				var vTmpArr;
				eval('try{vTmpArr = g_arrSeryMapList[g_arrSeryPos_'+this.n_seryID+'];}catch(e){vTmpArr = null;}');
				if(vTmpArr != null){
					vTmpSeryName = vTmpArr[2];
					vTmpSeryBgcolor = vTmpArr[4];
				}
				
				if(!g_isMinIE55)
					spcnVSWin("encode="+g_sPageFormat+"&id="+this.n_matchID+"&team1="+escape(vPopTeam1)+"&team2="+escape(vPopTeam2)+"&vsnow="+escape(vPopGiveNow)+"&vslast="+escape(vPopGiveLast)+"&agio1="+escape(vPopAgio1)+"&agio2="+escape(vPopAgio2)+"&sery="+escape(vTmpSeryName)+"&scolor="+escape(vTmpSeryBgcolor)+"&seryid="+this.n_seryID);
				else
					spcnVSWin2(this.n_matchID,vPopTeam1,vPopTeam2,vPopGiveNow,vPopGiveLast,vPopAgio1,vPopAgio2,vTmpSeryName,vTmpSeryBgcolor,this.n_seryID);
			}
		}
		catch(e){}
	}
}

function _CMatch_openDetail(){
	spm_oddsdetail(this.n_matchID);
}

function _CMatch_showOthers(){
	this.show('<font class="1_font03">'+this.b_oddsLink+'</font>','other');
	try{
		// clear last time timer.
		clearTimeout(this.p_goalShowTimer1);
		clearTimeout(this.p_goalShowTimer2);
	}
	catch(e){
	}
	if(this.b_isVsChange > 0){
		this.b_isVsChange = Number(0);
	}

	if(this.n_agioChange1 != 0){
		this.showAgioPic(1);
		this.n_agioChange1 = Number(0);
	}
	if(this.n_agioChange2 != 0){
		this.showAgioPic(2);
		this.n_agioChange1 = Number(0);
	}
}

function _CMatch_showAgioPic(num){
	var tonum = num;
	if(true == this.b_needExchange && (this.n_handicap == 2 || this.n_handicap == 3)){
		if(num == 1)
			tonum = 2;
		else
			tonum = 1;
	}
	eval('var toLevel = this.n_agioChange'+num+';');
	if(toLevel == 0){
		return;
	}

	var strLevel = 'up';
	if(toLevel == -1){
		strLevel = 'down';
	}
	eval('var isOK = typeof('+this.s_parentName+'.p_agioImage'+strLevel+') == "object" ? true : false;');
	if(isOK){
		if(true == this.show('<img name=agioPic'+tonum+'_ROW'+this.n_matchID+' border=0>','agio'+tonum)){
			eval("agioPic"+tonum+"_ROW"+this.n_matchID+".src = "+this.s_parentName+".p_agioImage"+strLevel+".src;");
			
			eval("this.p_goalShowTimer"+tonum+" = setTimeout('try{'+this.s_globalName+'.hideAgioPic("+tonum+");}catch(e){}',g_nGoalFlashTimeOut);");
		}
	}
}

function _CMatch_hideAgioPic(num){
	this.getItemTarget('agio'+num).style.display = 'none';
}

function _CMatch_hideVSPic(){
	this.b_isVsChange = Number(0);
	this.showVS();
}

function _CMatch_show(content,targetspan){
	var spanItem = this.getItemTarget(targetspan);
	if(spanItem != null){
		spanItem.innerHTML = content;
		//spanItem.insertAdjacentHTML('beforeEnd',content);
		spanItem.style.display = '';
		spanItem = null;
		return true;
	}
	else{
		return false;
	}
}

function _CMatch_refresh(){
	try{
		var rowDiv = this.getRowTarget();
		if(typeof(rowDiv) != "undefined"){
			this.showSery();
			this.showTeam(1);
			this.showTeam(2);
			this.showVS();
			this.showOthers();
		}
		
		if(true == this.b_isVisible){
			this.showIt();
		}
		else{
			this.hideIt();
		}
	}
	catch(e){debug("Exception in _CMatch_refresh():",e);}
}

function _CMatch_getRowTarget(){
	try{
		return document.all['rowdiv_'+this.n_matchID];
	}catch(e){debug("_CMatch_getRowTarget Failed:",e);}
}

function _CMatch_getItemTarget(itemname){
	try{
		return document.all[itemname+'_ROW'+this.n_matchID];
	}
	catch(e){
		debug("_CMatch_getRemarkTarget Failed:",e);
		return null;
	}
}

function _CMatch_getRowDiv(){
	var vTmpSeryBgcolor;
	var vTmpArr;
	eval('try{vTmpArr = g_arrSeryMapList[g_arrSeryPos_'+this.n_seryID+'];}catch(e){vTmpArr = null;}');
	if(vTmpArr == null)
		vTmpSeryBgcolor = " bgcolor=#3A794E";
	else{
		if(vTmpArr[4].charAt(0) != '#')
			vTmpSeryBgcolor = " class="+vTmpArr[4];
		else
			vTmpSeryBgcolor = " bgcolor="+vTmpArr[4];
	}

	return '<tr valign=middle height=20 style="display:none" align="center" class=1_head_bg id=remarkdiv_ROW'+this.n_matchID+'><td class="title" id=remark_ROW'+this.n_matchID+' colspan=20></td></tr><tr height="32" align="center" id=rowdiv_'+this.n_matchID+' class="1_bg03"><td class="1_bg" style="display:none" id=selbox_ROW'+this.n_matchID+'><INPUT TYPE="checkbox" VALUE="1" checked onclick="'+this.s_parentName+'.showExceptThis('+this.n_matchID+');" class="1_bg" id=chkFlag_ROW'+this.n_matchID+'></td><td id=pos_ROW'+this.n_matchID+' class="1_font03" style="display:none"></td><td'+vTmpSeryBgcolor+' id=sery_ROW'+this.n_matchID+' class="1_font01"></td><td class=1_bg03 align=center><table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td align="center" id=team1_ROW'+this.n_matchID+'></td><td align="center" id=agio1_ROW'+this.n_matchID+' style="display:none"></td></tr></table></td><td nowrap id=vs_ROW'+this.n_matchID+'></td><td class=1_bg03 align=center><table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td align="center" id=agio2_ROW'+this.n_matchID+' style="display:none"></td><td align="center" id=team2_ROW'+this.n_matchID+'></td></tr></table></td><td align="center" valign=middle id=other_ROW'+this.n_matchID+' class="1_font03"></td></tr><tr valign=middle height=20 style="display:none" align="center" class="1_bg03" id=remark_ADROW'+this.n_initPos+'><td id=remark_AD'+this.n_initPos+' colspan=20></td></tr>';   
}

function _CMatch_isMatchNotStarted(statusid){
	return (statusid == STATUS_NOT_START || statusid == STATUS_NOT_PUBLISH || statusid == STATUS_INTERRUPT || statusid == STATUS_CANCEL || statusid == STATUS_DELAY) ? true : false;

}

function _CMatch_isMatchEnd(statusid){
	return statusid == STATUS_GAME_OVER ? true : false;
}

function _CMatch_isMatchChanged(){
	return (this.n_agioChange1 != 0 || this.n_agioChange2 != 0 || this.b_isVsChange != 0) ? true: false;
}

// end of 比赛信息类


/**********************************************************************************************/
// begin of 比赛看板类

function CMatchBoard(){
	/** 比赛看板的全局变量接口,也就是能够通过这个名字访问到比赛看板实例本身！(比如'g_pMatchBoard') */
	this.s_globalName = "g_pMatchBoard";

	this.p_targetDoc = null;
	this.arr_matchList = new Array();

	/** 进球声音 */
	//this.p_goalVoice = null;
	/** 盘口小图标 */
	this.p_vsImage = null;
	/** 水位小图标 */
	this.p_agioImageup = null;
	this.p_agioImagedown = null;
	
	/** 是否静音 */
	this.b_isMute = false;
	this.s_voiceURL = "";

	/** 内容过滤参数 */
	this.n_filterFlag = 0;

	/** 赛事下载标志位 */
	this.b_isDownloading = false;

	/** 是否是首页 */
	this.b_isIndexPage = false;
	/** 是否是足彩页面 */
	this.b_isLotteryPage = false;

	/** 被隐藏的比赛总数 */
	this.n_hideCount = 0;

	/** 数据抓取实例 */
	this.p_pageInitData = new CPageData();
	this.p_pageChangeData = new CPageData();

	this.init = _CMatchBoard_init;
	this.getInitInnerHTML = _CMatchBoard_getInitInnerHTML;
	this.clearAll = _CMatchBoard_clearAll;
	this.getOneMatch = _CMatchBoard_getOneMatch;
	this.indexOfMatch = _CMatchBoard_indexOfMatch;
	this.initOneMatchToBoard = _CMatchBoard_initOneMatchToBoard;
	this.showBoard = _CMatchBoard_showBoard;

	this.refreshHideRow = _CMatchBoard_refreshHideRow;

	this.showAll = _CMatchBoard_showAll;
	this.showOnlyCustomize = _CMatchBoard_showOnlyCustomize;
	this.showExceptThis = _CMatchBoard_showExceptThis;
	this.showFiltered = _CMatchBoard_showFiltered;
	this.showAboutThisSery = _CMatchBoard_showAboutThisSery;
	
	this.setMute = _CMatchBoard_setMute;
	this.goalSound = _CMatchBoard_goalSound;

	this.setCSS = _CMatchBoard_setCSS;

	this.startLoop = _CMatchBoard_startLoop;
	this.dealWithInit = _CMatchBoard_dealWithInit;
	this.dealWithChange = _CMatchBoard_dealWithChange;
	this.dealWithMarquee = _CMatchBoard_dealWithMarquee;
}

/** 初始化赛事看板 */
function _CMatchBoard_init(targetDoc,selfName){
	if(typeof(targetDoc) != "undefined"){
		this.p_targetDoc = targetDoc;
	}
	else{
		this.p_targetDoc = document;
	}

	this.s_globalName = selfName;

	if(sVoice == null){
		this.b_isMute = true;
	}
	else{
		this.b_isMute = false;
		// 设置新的声音文件
		this.s_voiceURL = sVoice;
	}

	// 初始化进球声音系统,供方法1使用
	try{
		// method 1
		var oddsGoalMusic = document.getElementById("oddsGoalMusic");
		oddsGoalMusic.FileName = this.s_voiceURL;
	}catch(e){debug("Exception in init oddsGoalMusice media player:",e);}

	/** 载入CSS资源 */
		var pageCSS = document.getElementById("pageCSS");
	pageCSS.href=getCustomizeCSS();

	// 初始化盘口变化图片
	this.p_vsImage = new Image();
	this.p_vsImage.src = VS_ICON_URL;

	// 初始化水位图片
	this.p_agioImageup = new Image();
	this.p_agioImageup.src = UP_ICON_URL;
	this.p_agioImagedown = new Image();
	this.p_agioImagedown.src = DOWN_ICON_URL;
var seryFilterDiv = document.getElementById("seryFilterDiv");
	if(typeof(seryFilterDiv) == "object"){
		this.b_isIndexPage = true;
	}
/*var lotteryResultBoard = document.getElementById("lotteryResultBoard");
	if(typeof(lotteryResultBoard) == "object"){
		this.b_isLotteryPage = true;
	}
*/

	this.n_filterFlag = FILTER_ONLY_INTIME;

this.p_pageInitData.init("./data/"+g_sInitData+".xml",g_nInitTimeOut,this.s_globalName+".p_pageInitData",this.s_globalName+".dealWithInit","xmlDoc"+g_sInitData,true,"this.n_repeatTimes > 0");
	
	this.p_pageChangeData.init("./data/"+g_sChangeData+".xml",g_nChangeTimeOut,this.s_globalName+".p_pageChangeData",this.s_globalName+".dealWithChange","xmlDoc"+g_sChangeData,true,this.s_globalName+".b_isDownloading == false");
	
}

/** 得到固定的显示内容 */
function _CMatchBoard_getInitInnerHTML(){
	var retStr = '';
	return retStr;
}

function _CMatchBoard_startLoop(){
	this.p_pageInitData.startRetrieve();
	this.p_pageChangeData.startRetrieve();
}

/** 处理得到的xml 初始化rs数据 */
function _CMatchBoard_dealWithInit(inRS){
	loadPageFormatInfo();
	document.getElementById("txtDownloadBar").innerHTML = MATCH_LOADOK;

	var arrTmpSeries = new Array();
	
	try{
		this.clearAll();
		
		var curYearPos = -1;
		var curMonthPos = -1;
		var curDayPos = -1;

		var vTmpNumber = null;

		for(var rsPos=0; rsPos<inRS.length; rsPos++){
			try{
				var newMatch = new CMatch();
				var tmpRS = inRS.item(rsPos);
				//debug(tmpRS.xml);

				newMatch.n_modifyTimestamp = toNumber(getTagValue(tmpRS,"tp"));
				newMatch.n_matchID = toNumber(getTagValue(tmpRS,"id"));

				newMatch.n_macmatchID = toNumber(getTagValue(tmpRS,"mm"));

				newMatch.n_seryID = toNumber(getTagValue(tmpRS,"sr"));
				newMatch.setMatchTime(getTagValue(tmpRS,"t"));
				newMatch.setChangeTime(getTagValue(tmpRS,"lt"));
				newMatch.n_team1ID = toNumber(getTagValue(tmpRS,"t1d"));
				//newMatch.s_team1Name = getTagValue(tmpRS,"t1n");
				newMatch.s_team1Name = getTagValue(tmpRS,"t1"+g_sPageFormat + "n");
				newMatch.n_team2ID = toNumber(getTagValue(tmpRS,"t2d"));
				//newMatch.s_team2Name = getTagValue(tmpRS,"t2n");
				newMatch.s_team2Name = getTagValue(tmpRS,"t2"+g_sPageFormat + "n");
				
				newMatch.n_order1 = getTagValue(tmpRS,"oh");
				newMatch.n_order2 = getTagValue(tmpRS,"ov");
				vTmpNumber = toNumber(getTagValue(tmpRS,"ah"));
				if(vTmpNumber != null){
					newMatch.n_agio1 = vTmpNumber;
				}
				vTmpNumber = toNumber(getTagValue(tmpRS,"av"));
				if(vTmpNumber != null){
					newMatch.n_agio2 = vTmpNumber;
				}
				vTmpNumber = toNumber(getTagValue(tmpRS,"vn"));
				if(vTmpNumber != null){
					newMatch.n_vsNow = vTmpNumber;
				}
				vTmpNumber = toNumber(getTagValue(tmpRS,"vl"));
				if(vTmpNumber != null){
					newMatch.n_vsLast = vTmpNumber;
				}
				vTmpNumber = toNumber(getTagValue(tmpRS,"hc"));
				if(vTmpNumber != null){
					newMatch.n_handicap = vTmpNumber;
				}
				vTmpNumber = toNumber(getTagValue(tmpRS,"fd"));
				if(vTmpNumber != null){
					newMatch.n_fieldType = vTmpNumber;
				}
				
				var sTmpLink = "";
				var nTmpLinkRet = 0;
				for(lnum=1;lnum<=9;lnum++){
					try{
						nTmpLinkRet = getTagValue(tmpRS,"l"+lnum);
					}
					catch(e){
						nTmpLinkRet = 0;
					}
					if(nTmpLinkRet > 0){
						if(sTmpLink != ""){
							sTmpLink += " ";
						}
						sTmpLink += getOddsLinksStr(newMatch.n_matchID,(lnum-1),newMatch.n_macmatchID);
					}
				}
				newMatch.b_oddsLink = sTmpLink;
				try{
					sTmpLink = getTagValue(tmpRS,"ln");
				}
				catch(e){
					sTmpLink = "";
				}
				if(newMatch.b_oddsLink != ""){
					sTmpLink += " ";
				}
				newMatch.b_oddsLink += sTmpLink;
				
				newMatch.n_initPos = Number(this.arr_matchList.length);

				// 这个一定要设置，否则有些定时的脚本就无法正常执行。
				newMatch.s_globalName = this.s_globalName + ".getOneMatch("+newMatch.n_matchID+")";
				newMatch.s_parentName = this.s_globalName;

				newMatch.b_isVisible = true;
				
				newMatch.b_isNextDay = false;
				if(curDayPos != newMatch.d_matchTime.getDate() || curMonthPos != newMatch.d_matchTime.getMonth() || curYearPos != newMatch.d_matchTime.getYear()){
					newMatch.b_isNextDay = true;
					curYearPos = newMatch.d_matchTime.getYear();
					curMonthPos = newMatch.d_matchTime.getMonth();
					curDayPos = newMatch.d_matchTime.getDate();
				}

				newMatch.b_needExchange = true;
				if(this.b_isLotteryPage){
					newMatch.b_needExchange = false;
				}

				this.initOneMatchToBoard(newMatch);
				
				if(this.b_isIndexPage){
					var ishave = false;
					for(i=0;i<arrTmpSeries.length;i++){
						if(arrTmpSeries[i] == newMatch.n_seryID){
							ishave = true;
							break;
						}
					}
					if(!ishave){
						arrTmpSeries[arrTmpSeries.length] = newMatch.n_seryID;
					}
				}

				if(this.b_isLotteryPage){
					var status = toNumber(getTagValue(tmpRS,"si"));
					document.all['lotteryTeam_'+newMatch.n_initPos].innerHTML = '<font class=1_font03>'+strRowToCol(newMatch.s_team1Name)+'</font>';
					if(!newMatch.isMatchNotStarted(status)){
						var score1 = '?';
						try{
							score1 = toNumber(getTagValue(tmpRS,"sh"));
							if(null == score1){
								score1 = '?';
							}
						}
						catch(e){
							score1 = '?';
						}
						var score2 = '?';
						try{
							score2 = toNumber(getTagValue(tmpRS,"sv"));
							if(null == score2){
								score2 = '?';
							}
						}
						catch(e){
							score2 = '?';
						}
						var half1 = '?';
						try{
							half1 = toNumber(getTagValue(tmpRS,"hf1"));
							if(null == half1){
								half1 = '?';
							}
						}
						catch(e){
							half1 = '?';
						}
						var half2 = '?';
						try{
							half2 = toNumber(getTagValue(tmpRS,"hf2"));
							if(null == half2){
								half2 = '?';
							}
						}
						catch(e){
							half2 = '?';
						}
						document.all['lotteryHalf_'+newMatch.n_initPos].innerHTML = half1 + ":" + half2;
						document.all['lotteryScore_'+newMatch.n_initPos].innerHTML = score1 + ":" + score2;
						var result = score1 > score2 ? 3 : (score1 < score2 ? 0 : 1);
						if(!newMatch.isMatchEnd(status)){
							resulthtml = '<font class=1_font04>'+result+'</font>';
						}
						else{
							resulthtml = result;
						}
						document.all['lotteryResult1_'+newMatch.n_initPos].innerHTML = resulthtml;
					}
				}
			}
			catch(e){
				debug("Exception in dealWithInit->loop:",e);
			}
		}
	}
	catch(e){debug("Exception in dealWithInit->While",e);}
	
	try{
		this.showBoard();
		
		if(this.b_isIndexPage){
			var arrCustomizeSeries = getCustomizeSeryArr();
			var str = '';
			for(i=0;i<arrTmpSeries.length;i++){
				if(arrCustomizeSeries == null || arrCustomizeSeries.length <= 0){
					isSeryCookied = " checked";
				}
				else{
					isSeryCookied = checkCustomizeSery(arrTmpSeries[i]) ? " checked" : "";
				}
				var vTmp;
				var vTmpArr;
				eval('try{vTmpArr = g_arrSeryMapList[g_arrSeryPos_'+arrTmpSeries[i]+'];}catch(e){vTmpArr = null;}');
				if(vTmpArr == null)
					vTmp = arrSeryToList[i];
				else{
					vTmp = vTmpArr[2];
				}
				
				str += '<INPUT onclick="javascript:setSeryFilter(this,'+arrTmpSeries[i]+')" TYPE="checkbox" NAME=headline_Series_'+arrTmpSeries[i]+' VALUE="'+arrTmpSeries[i]+'" class=1_bg03'+isSeryCookied+'>&nbsp;' + vTmp + '<br>';
			}
			
			str += '<hr size=1 width=100%><input type=checkbox onclick="javascript:{g_bPopupInfoTips=this.checked;}"';
			if(true == g_bPopupInfoTips){
				str += ' checked';
			}
			str += '> '+STR_POPUPTIPS;
var headLineSeryList = document.getElementById("headLineSeryList");
			headLineSeryList.innerHTML = str;
		}
	}
	catch(e){debug("Exception in dealWithInit->showBoard",e);}

	this.p_pageChangeData.p_lastModifiedData = null;
	Commercial.IsLoaded=0;
	setTimeout(Commercial.ShowCommercial,1000);
}

/** 处理得到的xml 初始化rs数据 */
function _CMatchBoard_dealWithChange(inRS){
	try{
		var bChanged = false;

		for(var rsPos=0; rsPos<inRS.length; rsPos++){
			try{
				tmpRS = inRS.item(rsPos);
				var idx = this.indexOfMatch(toNumber(getTagValue(tmpRS,"id")));
				if(idx < 0 || toNumber(getTagValue(tmpRS,"tp")) <= this.arr_matchList[idx].n_modifyTimestamp){
					// 在列表中不存在这场比赛，或者时间戳过老，直接略过。
					try{
					if(idx < 0) debug(toNumber(getTagValue(tmpRS,"id")) + "在列表中不存在");
					else debug(toNumber(getTagValue(tmpRS,"id")) + " "+this.arr_matchList[idx].s_team1Name+"vs"+this.arr_matchList[idx].s_team2Name+" 时间戳过老，直接略过["+toNumber(getTagValue(tmpRS,"tp"))+" <= "+this.arr_matchList[idx].n_modifyTimestamp+"]");
					}catch(e){debug(e);}
					continue;
				}
				else{
					debug(toNumber(getTagValue(tmpRS,"id")) + " "+this.arr_matchList[idx].s_team1Name+"vs"+this.arr_matchList[idx].s_team2Name+" 时间戳更新为"+toNumber(getTagValue(tmpRS,"tp")));
				}
				
				
				this.arr_matchList[idx].setChangeTime(getTagValue(tmpRS,"lt"));
				this.arr_matchList[idx].setAgios(toNumber(getTagValue(tmpRS,"ah")),toNumber(getTagValue(tmpRS,"av")));
				this.arr_matchList[idx].setVS(toNumber(getTagValue(tmpRS,"vn")),toNumber(getTagValue(tmpRS,"vl")),toNumber(getTagValue(tmpRS,"hc")));
				
				this.arr_matchList[idx].n_modifyTimestamp = toNumber(getTagValue(tmpRS,"tp"));
				
				if(this.b_isIndexPage){
					// index page board.
					if(this.arr_matchList[idx].isMatchChanged()){
						g_pScrollMatchBoard.updateMatch(this.arr_matchList[idx]);
						bChanged = true;
					}
				}

				this.arr_matchList[idx].refresh();
			}
			catch(e){
				debug("Exception in dealWithChange->loop:",e);
			}
		}

		if(bChanged == true && typeof(g_pScrollMatchBoard) == "object"){
			// index page board.
			g_pScrollMatchBoard.sortBoard();
		}
	}
	catch(e){
		debug("Exception in dealWithChange->while:",e);
	}
}

/** 处理得到的xml 初始化rs数据 */
function _CMatchBoard_dealWithMarquee(inRS){
	try{
		for(var rsPos=0; rsPos<inRS.length; rsPos++){
			try{
				tmpRS = inRS.item(rsPos);
				indexMarquee.innerHTML += getTagValue(tmpRS,"oddsmarquee");
			}
			catch(e){
				debug("Exception in dealWithMarquee->loop:",e);
			}
		}

		if(this.b_isIndexPage){
			try{
				g_pScrollMatchBoard.s_defaultBanner = indexMarquee.innerHTML;
			}catch(e){}
		}
	}
	catch(e){
		debug("Exception in dealWithMarquee->while:",e);
	}
}

/** 清除所有比赛 */
function _CMatchBoard_clearAll(){
	this.arr_matchList = new Array();
}

/** 刷新显示比赛列表 */
function _CMatchBoard_showBoard(){

	var sTmp = '';
	var sHead = '<table width="100%" border="0" cellspacing="1" cellpadding="0"  class="1_bg01">';
	var sTail = '<tr align=center valign=middle height=30 class="1_bg03"><td colspan=30 class="1_font03" id="rowHIDEList" style="display:none;"></td></tr></table>';
	var nVisibleCount = 0;
	try{
		//this.p_targetDoc.style.display = "none";

		var arrTmp = new Array();
		arrTmp[0] = sHead;

		var len = this.arr_matchList.length;

		var nHided = 0;
		for(i=0;i<len;i++){
			//sTmp = sTmp + this.arr_matchList[i].getRowDiv();
			arrTmp[i+1] = this.arr_matchList[i].getRowDiv();
		}
		
		//sTmp = sHead + sTmp + this.getInitInnerHTML() + sTail;
		arrTmp[i+2] = this.getInitInnerHTML();
		arrTmp[i+3] = sTail;
		
		// method 1
		//this.p_targetDoc.innerHTML = sTmp;
		//this.p_targetDoc.innerHTML = arrTmp.join("");

		// method 2
		//this.p_targetDoc.innerHTML = '';

		//this.p_targetDoc.insertAdjacentHTML('beforeEnd',arrTmp.join(""));
		this.p_targetDoc.innerHTML = arrTmp.join("");
		arrTmp = null;

		var stepS = 100;
		var stepFunc = "";
		//var bbb = Number((new Date()).getTime());

		for(i=0;i<len;i++){
			if(this.arr_matchList[i].b_isVisible == true){
				nVisibleCount++;
			}
			
			if(this.b_isLotteryPage){
				this.arr_matchList[i].show(formatNumber(this.arr_matchList[i].n_initPos+1,2),'pos');
			}

			if(false == this.b_isDownloading){
				this.arr_matchList[i].refresh();
				if(i == (len - 1)){
					if(nVisibleCount <= 0 && typeof(g_sNeedIndicated) != "undefined" && g_sNeedIndicated != ""){
						rowHIDEList.style.display = "";
						rowHIDEList.innerHTML = '<b>'+g_sNeedIndicated+'</b> ';
					}
				}
			}
			else{
				stepFunc = this.s_globalName+".arr_matchList["+i+"].refresh();";
				if(i == (len - 1)){
					if(nVisibleCount <= 0 && typeof(g_sNeedIndicated) != "undefined" && g_sNeedIndicated != ""){
						stepFunc += "rowHIDEList.style.display = '';rowHIDEList.innerHTML = '<b>"+g_sNeedIndicated+"</b> ';";
					}
					stepFunc += this.s_globalName+".b_isDownloading = false;";
				}
				setTimeout(stepFunc,i*stepS);
				//eval(stepFunc);
			}
		}

		if(len <= 0){
			if(typeof(g_sNeedIndicated) != "undefined" && g_sNeedIndicated != ""){
				rowHIDEList.style.display = "";
				rowHIDEList.innerHTML = '<b>'+g_sNeedIndicated+'</b> ';
			}
			this.b_isDownloading = false;
		}
/*
		for(i=0;i<len;i++){
			if(this.arr_matchList[i].b_isVisible == true){
				nVisibleCount++;
			}

			if(this.b_isLotteryPage){
				this.arr_matchList[i].show(formatNumber(this.arr_matchList[i].n_initPos+1,2),'pos');
			}
			
			this.arr_matchList[i].refresh();
		}

		if(nVisibleCount <= 0 && typeof(g_sNeedIndicated) != "undefined" && g_sNeedIndicated != ""){
			rowHIDEList.style.display = "";
			rowHIDEList.innerHTML = '<b>'+g_sNeedIndicated+'</b> ';
		}
*/
		//this.p_targetDoc.style.display = "";
	}
	catch(e){debug("Exception in _CMatchBoard_showBoard:",e);}
}

/** 更新隐藏行统计 */
function _CMatchBoard_refreshHideRow(){
	this.n_hideCount = 0;
	
	for(i=0;i<this.arr_matchList.length;i++){
		if(this.arr_matchList[i].b_isVisible == false){
			this.n_hideCount++;
		}
	}

	if(this.n_hideCount > 0){
		rowHIDEList.style.display = "";
		rowHIDEList.innerHTML = '<b>'+this.n_hideCount+'</b> '+MATCH_STILL_HIDDEN+' <a href="javascript:{'+this.s_globalName+'.showAll();}"><font class=1_font03>&gt;&gt;&gt;</font></a>';
	}
	else{
		rowHIDEList.style.display = "none";
	}
}

// 显示所有除终盘之外的比赛（用户定制用）
function _CMatchBoard_showAll(){
	this.showFiltered(FILTER_NONE);
}

function _CMatchBoard_showOnlyCustomize(){
	this.showFiltered(FILTER_ONLY_CUSTOMIZE);
}

function _CMatchBoard_showExceptThis(matchid){
	this.showFiltered(FILTER_ONLY_THISONE,matchid);
}

function _CMatchBoard_showAboutThisSery(seryid,bShow){
	this.showFiltered(FILTER_ABOUT_THIS_SERY,seryid,bShow);
}

function _CMatchBoard_showFiltered(filterFlag){
	var bResult = false;
	var filterStr = '';
	var argv = _CMatchBoard_showFiltered.arguments;
	var bNeedCustomizeOption = false;
	var nVisibleCount = Number(0);

	switch(filterFlag){
		case FILTER_NONE:
			filterStr = 'bResult = true;';
			bNeedCustomizeOption = true;
		break;
		case FILTER_ONLY_CUSTOMIZE:
			filterStr = 'bResult = (checkCustomizeSery(nTmpMatch.n_seryID));';
			bNeedCustomizeOption = true;
		break;
		case FILTER_ONLY_THISONE:
			filterStr = 'bResult = (nTmpMatch.n_matchID == '+argv[1]+') ? false : nTmpMatch.b_isVisible;';
			bNeedCustomizeOption = true;
		break;
		case FILTER_ABOUT_THIS_SERY:
			if(argv[2]){
				filterStr = 'try{bResult = ((Number(argv[1]) == nTmpMatch.n_seryID)) ? true : nTmpMatch.b_isVisible;}catch(e){bResult = nTmpMatch.b_isVisible;}';
			}	
			else{
				filterStr = 'try{bResult = ((Number(argv[1]) == nTmpMatch.n_seryID)) ? false : nTmpMatch.b_isVisible;}catch(e){bResult = nTmpMatch.b_isVisible;}';
			}
			bNeedCustomizeOption = true;
		break;
		default:
			return;
	}

	var len = this.arr_matchList.length;
	var nTmpStatus = 0;
	var nTmpMatch = null;
	this.n_hideCount = 0;

	var curYearPos = -1;
	var curMonthPos = -1;
	var curDayPos = -1;

	for(i=0;i<len;i++){
		nTmpMatch = this.arr_matchList[i];
		nTmpStatus = nTmpMatch.n_statusID;
		eval(filterStr);
		
		this.arr_matchList[i].b_isNextDay = false;
		if(bResult){
			if(curDayPos != this.arr_matchList[i].d_matchTime.getDate() || curMonthPos != this.arr_matchList[i].d_matchTime.getMonth() || curYearPos != this.arr_matchList[i].d_matchTime.getYear()){
				this.arr_matchList[i].b_isNextDay = true;
				curYearPos = this.arr_matchList[i].d_matchTime.getYear();
				curMonthPos = this.arr_matchList[i].d_matchTime.getMonth();
				curDayPos = this.arr_matchList[i].d_matchTime.getDate();
			}

			if(this.b_isLotteryPage == true){
				this.arr_matchList[i].show(formatNumber(this.arr_matchList[i].n_initPos+1,2),'pos');
			}
			
			if(bNeedCustomizeOption == true){
				document.all['selbox_ROW'+this.arr_matchList[i].n_matchID].style.display = "";
			}
			else{
				document.all['selbox_ROW'+this.arr_matchList[i].n_matchID].style.display = "none";
			}
			this.arr_matchList[i].showIt();

			nVisibleCount++;
		}
		else{
			this.arr_matchList[i].hideIt();
		}
	}
	var seryFilterDiv = document.getElementById("seryFilterDiv");
	if(this.b_isIndexPage){
		if(bNeedCustomizeOption == true){

			seryFilterDiv.style.display = "";
		}
		else{
			seryFilterDiv.style.display = "none";
		}
	}

	if(bNeedCustomizeOption == true){
		this.refreshHideRow();
	}
	else{
		rowHIDEList.style.display = "none";
	}

	if(typeof(g_sNeedIndicated) != "undefined" && g_sNeedIndicated != "" && nVisibleCount <= 0){
		rowHIDEList.style.display = "";
		rowHIDEList.innerHTML = '<b>'+g_sNeedIndicated+'</b> ';
	}
}

/** 播放进球声音 */
function _CMatchBoard_goalSound(){
	if(!this.b_isMute){
		try{
			// method 1
			oddsGoalMusic.Play();
		}catch(e){debug("Exception in _CMatchBoard_goalSound:",e);}
	}
}

/** 设置静音开关 */
function _CMatchBoard_setMute(isMute,isDoCookie){
	this.b_isMute = isMute;
	if(isDoCookie){
		if(myConfirm(CONFIRM_SET_OPTION_TO_COOKIE)){
			if(this.b_isMute == false)
				setCustomizeVoice(this.s_voiceURL);
			else
				setCustomizeVoiceMute();
		}
	}
}

/** 设置CSS资源 */
function _CMatchBoard_setCSS(newCSS,isDoCookie){
	var pageCSS = document.getElementById("pageCSS");
	pageCSS.href = newCSS;
	if(isDoCookie){
		if(myConfirm(CONFIRM_SET_OPTION_TO_COOKIE)){
			setCustomizeCSS(newCSS);
		}
	}
}

/** 得到指定id的比赛信息 */
function _CMatchBoard_getOneMatch(id){
	var len = this.arr_matchList.length;
	for(i=0;i<len;i++){
		if(this.arr_matchList[i].n_matchID == id)
			return this.arr_matchList[i];
	}
	return null;
}

/** 得到id的比赛的索引 */
function _CMatchBoard_indexOfMatch(id){
	var len = this.arr_matchList.length;
	for(i=0;i<len;i++){
		if(this.arr_matchList[i].n_matchID == id)
			return i;
	}
	return -1;
}

/** 把一场比赛初始化到列表中去,只有在初始化的时候才可以调用这个方法 */
function _CMatchBoard_initOneMatchToBoard(newMatch){
	this.arr_matchList[this.arr_matchList.length] = newMatch;
}

function CaseInsensitiveString(s){
	return String(s).toUpperCase();
}

function parseDate(s){
	return Date.parse(s.replace(/\-/g, '/'));
}

/* alternative to number function */
function toNumber(s){
	if(s == null || s == ""){
		return null;
	}
	try{
	    return Number(s);
	}
	catch(e){
		return null;
	}
}

// end of 比赛看板类


/**********************************************************************************************/
// begin of 滚动公告板赛事类

function CScrollMatch(){
	/** 本场比赛的全局变量接口,也就是能够通过这个名字访问到比赛实例本身！(比如'g_pMatchBoard.getOneMatch(1234)'就能访问到比赛1234) */
	this.s_globalName = "";
	/** 本场比赛的生成者 */
	this.s_parentName = "g_pSrollMatchBoard";
	/** 显示次序 */
	this.n_showPos = Number(0);

	/** 赛事最近更新时间戳 */
	this.n_modifyTimestamp = Number(0);
	
	/** 赛事ID */
	this.n_matchID = 0;
	this.n_macmatchID = 0;

	/** 主队id */
	this.n_team1ID = 0;
	/** 主队名 */
	this.s_team1Name = "";

	/** 客队id */
	this.n_team2ID = 0;
	/** 客队名 */
	this.s_team2Name = "";

	/** 主队当前水位 */
	this.n_agio1 = 0;
	/** 客队当前水位 */
	this.n_agio2 = 0;

	/** 当前让球 */
	this.n_vsNow = -1;
	/** 上次让球 */
	this.n_vsLast = -2;

	/** 主客队顺序可以看成两位2进制,前面一位表示当前受让顺序,后面一位表示上次变化的受让顺序,0是主队在前,1是客队在前 */
	this.n_handicap = 0;

	this.cloneMatchInfo = _CScrollMatch_cloneMatchInfo;
	this.toString = _CScrollMatch_toString;
}

function _CScrollMatch_cloneMatchInfo(inInfo){
	this.n_modifyTimestamp = inInfo.n_modifyTimestamp;
	this.n_matchID = inInfo.n_matchID;
	this.n_macmatchID = inInfo.n_macmatchID;
	this.n_team1ID = inInfo.n_team1ID;
	this.s_team1Name = inInfo.s_team1Name;
	this.n_team2ID = inInfo.n_team2ID;
	this.s_team2Name = inInfo.s_team2Name;
	this.n_agio1 = inInfo.n_agio1;
	this.n_agio2 = inInfo.n_agio2;
	this.n_vsNow = inInfo.n_vsNow;
	this.n_vsLast = inInfo.n_vsLast;
	this.n_handicap = inInfo.n_handicap;
}

function _CScrollMatch_toString(){

	var vGiveNow = '';
	var vGiveLast = '';
	eval('try{vGiveNow = ODDS_TVS_NAME_'+this.n_vsNow+';}catch(e){vGiveNow = "";}');
	eval('try{vGiveLast = ODDS_TVS_NAME_'+this.n_vsLast+';}catch(e){vGiveLast = "";}');

	if(vGiveLast != '' && ((this.n_vsNow != this.n_vsLast) || (this.n_handicap == 1 || this.n_handicap == 2))){
		if(this.n_vsLast >= 0 && (this.n_handicap == 1 || this.n_handicap == 2)){
			vGiveLast = MATCH_GIVE_BALL + ' ' + vGiveLast;
		}
		vGiveLast = '(' + vGiveLast + ')';
	}
	else{
		vGiveLast = '';
	}

	var tname1 = 1;
	var tname2 = 2;
	if(this.n_vsNow >= 0 && (this.n_handicap == 2 || this.n_handicap == 3)){
		tname1 = 2;
		tname2 = 1;
	}
	
	eval('var retStr = "&nbsp;"+this.s_team'+tname1+'Name+"&nbsp;"+this.n_agio'+tname1+'+"&nbsp;'+vGiveNow+vGiveLast+'&nbsp;"+this.s_team'+tname2+'Name+"&nbsp;"+this.n_agio'+tname2+'+"&nbsp;&nbsp;";');

	return retStr;
}

// end of 滚动公告板赛事类


/**********************************************************************************************/
// begin of 比赛滚动看板类

function CScrollMatchBoard(){
	/** 比赛滚动看板的全局变量接口,也就是能够通过这个名字访问到比赛看板实例本身！(比如'g_pMatchBoard') */
	this.s_globalName = "g_pSrollMatchBoard";

	this.p_targetDoc = null;
	this.arr_matchList = new Array();

	/** 最多允许进行滚动的赛事场数 */
	this.n_maxSize = Number(10);

	this.s_defaultBanner = '';
	
	this.init = _CScrollMatchBoard_init;
	this.clearAll = _CScrollMatchBoard_clearAll;
	this.sortBoard = _CScrollMatchBoard_sortBoard;
	this.updateMatch = _CScrollMatchBoard_updateMatch;
}

/** 初始化赛事看板 */
function _CScrollMatchBoard_init(targetDoc,selfName){
	if(typeof(targetDoc) != "undefined"){
		this.p_targetDoc = targetDoc;
	}
	else{
		this.p_targetDoc = document;
	}

	this.s_globalName = selfName;
	this.s_defaultBanner = this.p_targetDoc.innerHTML;
}

/** 清除所有比赛 */
function _CScrollMatchBoard_clearAll(){
	this.arr_matchList = new Array();
}

/** 对比赛信息进行排序 */
function _CScrollMatchBoard_sortBoard(){
	try{
		this.arr_matchList.sort(ScrollCompareByTimestamp());
	
		var sTmp = '';
		var sHead = '&nbsp;&nbsp;<font color=white><b>' + SCROLL_HEADER_STR + '</b>';
		var sTail = '</font>';

		var len = this.arr_matchList.length;
		var nHided = 0;
		if(len > 0){
			for(i=0;i<len;i++){
				this.arr_matchList[i].n_showPos = Number(i);
				sTmp = sTmp + this.arr_matchList[i].toString();
			}
			if(sTmp != ''){
				sTmp = sHead + sTmp + sTail;
			}
		}
		
		sTmp = this.s_defaultBanner + sTmp;

		this.p_targetDoc.innerHTML = sTmp;
	//	this.p_targetDoc.insertAdjacentHTML('beforeEnd',sTmp);

	}
	catch(e){debug("Exception in _CScrollMatchBoard_sortBoard:",e);}
}

function _CScrollMatchBoard_updateMatch(inMatch){
	var len = this.arr_matchList.length;
	var oldestPos = -1;
	var oldestTime = -1;
	for(i=0;i<len;i++){
		if(this.arr_matchList[i].n_matchID == inMatch.n_matchID){
			if(this.arr_matchList[i].n_modifyTimestamp >= inMatch.n_modifyTimestamp){
				// 时间戳过老，不允许进行更新,直接返回
				return;
			}
			this.arr_matchList[i].cloneMatchInfo(inMatch);
			return;
		}
		else{
			if(this.arr_matchList[i].n_modifyTimestamp <= inMatch.n_modifyTimestamp){
				if(oldestTime < 0 || this.arr_matchList[i].n_modifyTimestamp < oldestTime){
					oldestPos = i;
					oldestTime = this.arr_matchList[i].n_modifyTimestamp;
				}
			}
		}
	}

	if(len >= this.n_maxSize){
		if(oldestPos < 0){
			return;
		}
	}
	else{
		oldestPos = len;
	}

	// 如果没有找到，则插入一条纪录。
	this.arr_matchList[oldestPos] = new CScrollMatch();
	this.arr_matchList[oldestPos].s_parentName = this.s_globalName;
	this.arr_matchList[oldestPos].cloneMatchInfo(inMatch);
}

function ScrollCompareByTimestamp(){
	return function (n1, n2){	
		if (n1.n_modifyTimestamp < n2.n_modifyTimestamp)
			return +1;
		else if (n1.n_modifyTimestamp > n2.n_modifyTimestamp)
			return -1;
		else
			return 0;
	};
}

// end of 比赛滚动看板类


/**********************************************************************************************/
// begin of 数据抓取类
//Possible prefixes ActiveX strings for DOM DOcument
var ARR_ACTIVEX = ["MSXML4.DOMDocument", "MSXML3.DOMDocument", "MSXML2.DOMDocument", "MSXML.DOMDocument", "Microsoft.XmlDom"];

//When the proper prefix is found, store it here
var STR_ACTIVEX = "";

function CPageData(){
	/** xml数据处理对象 */
	this.p_catcherMan = null;
	/** 比对对象 */
	this.p_lastModifiedData = null;

   this.transport = null;
	/** 实例的名字 */
	this.s_globalName = null;
	/** 回调函数，用来处理rs */
	this.f_callbackFunc = null;
	/** 处理xml元素的tag名 */
	this.s_xmlTagID = null;

	/** 数据文件地址*/
	this.s_dataURL = null;
	/** 定时抓取时间 */
	this.n_timeOut = 5000;
	/** 是否异步抓取 */
	this.b_isAsync = true;
	/** 锁定等待条件 */
	this.s_waitCondition = null;

	/** 是否是url读取 */
	this.b_isFromURL = true;

	/** 统计次数 */
	this.n_repeatTimes = 0;

	/** 定时器句柄，防止内存泄漏 */
	this.p_timerHandler = null;

	this.init = _CPageData_init;
	this.setDataURL = _CPageData_setDataURL;
	this.setTimeOut = _CPageData_setTimeOut;

	this.startRetrieve = _CPageData_startRetrieve;
	this.onRetrieveOK = _CPageData_onRetrieveOK;
	this.retrieveOK = _CPageData_retrieveOK;

	this.loadXML = _CPageData_loadXML;
}

function _CPageData_init(inURL,inTimeOut,varName,callBackFunc,xmlTagID,basync,waitCondition){
	this.s_dataURL = inURL;
	this.n_timeOut = Number(inTimeOut);
	this.s_globalName = varName;
	this.f_callbackFunc = callBackFunc;
	this.s_xmlTagID = xmlTagID;
	this.b_isAsync = basync;
	this.s_waitCondition = waitCondition;

	var bFound = false;

	if(inURL.substring(0,5).toUpperCase() == "<?XML"){
		this.p_catcherMan = loadXMLString(inURL);
		this.p_catcherMan.async = false;
		this.b_isFromURL = false;
	}
	else {
var self = this;
 this.transport = $.ajax({
	url: inURL,
type: "Get", 
dataType: "xml", 
encoding: 'UTF-8',
data: "t=" + Math.random(),
complete:self.retrieveOK()
});
		//this.p_catcherMan = this.transport.responseXML;
		//this.p_catcherMan.async = this.b_isAsync;
		//this.retrieveOK();
	}

	//this.p_catcherMan.resolveExternals = false;
	//this.p_catcherMan.validateOnParse = false;

}

function _CPageData_setDataURL(inURL){
	this.s_dataURL = inURL;
}

function _CPageData_setTimeOut(inTimeOut){
	this.n_timeOut = (isNaN(Number(inTimeOut)) && Number(inTimeOut) > 0) ? Number(inTimeOut) : Number(0);
}

function _CPageData_startRetrieve(){
	try{
		if(this.n_timeOut > 0){
			// 如果定时时间大于0则循环执行,否则只抓取一次数据。
			if(this.p_timerHandler == null){
				this.p_timerHandler = new Array();
			}
		this.p_timerHandler.push(setTimeout(this.s_globalName+".startRetrieve()", this.n_timeOut));

			if(this.p_timerHandler.length > 5){
				clearTimeout(this.p_timerHandler[0]);
				this.p_timerHandler.shift();
			}
		}
		var bCanGet = true;
		if(this.s_waitCondition != null){
			eval("var bCanGet = (" + this.s_waitCondition + ");");
		}

		if(this.n_repeatTimes < 999999){
			this.n_repeatTimes++;
		}
		else{
			this.n_repeatTimes = 1;
		}
		if(bCanGet){
			this.loadXML();
		}
	}
	catch(e){
		debug("Exception in _CPageData_startRetrieve:",e);
	}
}

function _CPageData_onRetrieveOK(){
	// 0 Object is not initialized
	// 1 Loading object is loading data
	// 2 Loaded object has loaded data
	// 3 Data from object can be worked with
	// 4 Object completely initialized
	
	/*var state = this.p_catcherMan.readyState;
	if(state != 4)
		return;*/
	this.retrieveOK();
}

function _CPageData_retrieveOK(){

	try{
		var tp = null;
		var tpxml = null;

		if (!this.transport)
		{
			tp = this.p_catcherMan;
			 tpxml = this.s_dataURL;
		}
		else {
			this.p_catcherMan = this.transport.responseXML;
			tp = loadXMLString(this.transport.responseText);
			 tpxml = this.transport.responseText;
		}

		if(this.p_lastModifiedData != null){
			if( this.p_catcherMan == null || 
				tpxml == null || 
				tpxml == "" || 
				this.p_lastModifiedData == tpxml ){
				// no change!
				debug("no change.just return.");
				return;
			}
		}
		var rs = tp.documentElement.childNodes;

		if(this.p_lastModifiedData != null && (rs == null || rs.length <= 0)){
			debug("no result set got!just return.");
			return;
		}

		this.p_lastModifiedData = tpxml;

		eval(this.f_callbackFunc+"(rs);");
		
		rs = null;
	}
	catch(e){
		debug("Exception in _CPageData_retrieveOK:",e);
	}

	if(this.n_timeOut <= 0){
		this.p_catcherMan = null;
		this.p_lastModifiedData = null;
	}
}

function _CPageData_loadXML(){
	if(true == this.b_isFromURL){
		var self = this;
	 this.transport = $.ajax({
			url: this.s_dataURL,
			type: "Get", 
			dataType: "xml", 
			encoding: 'UTF-8',
			data: "t=" + Math.random(),
			complete: function(xml) {
				self.p_catcherMan = xml.responseXML;
				self.retrieveOK();
		}
		});
		//this.p_catcherMan.load(this.s_dataURL);
	}
	else{
		//this.p_catcherMan.loadXML(this.s_dataURL.substring(this.s_dataURL.indexOf("?>")+2));
	}
	if(this.p_catcherMan.async == false){
		this.retrieveOK();
	}
}

// end of 数据抓取类

/** 得到xml数据 */
function getTagValue(inRS,tagName){

	try{
		var tp = inRS.getElementsByTagName(tagName).item(0);
		if (tp.textContent)
		{
			return tp.textContent;
		}
		else {
			return tp.text;
		}

	}
	catch(e){
		debug("Element ["+tagName+"] get Failed",e);
		return "";
	}
}

/**********************************************************************************************/
// begin of 用户定制信息

/** 检查指定的赛事系列是否在用户定制当中 */
function checkCustomizeSery(seryid){
	var sSeries = getOddsCookie("SPCN_ODDS_SERIES");
	if(sSeries != null && sSeries.length > 2 &&  sSeries.indexOf("_"+seryid+"_") < 0){
		// 只有当用户进行过定制并且赛事不在定制列表中才返回false
		return false;
	}
	else{
		return true;
	}
}

/** 得到用户定制的赛事，返回数组 */
function getCustomizeSeryArr(){
	var sSeries = getOddsCookie("SPCN_ODDS_SERIES");
	//debug(sSeries);
	var retArr = new Array();
	if(sSeries != null && sSeries.length > 0){
		var bStart = false;
		var startpos = 0;
		var arrCnt = 0;
		for(i=0;i<sSeries.length;i++){
			if(sSeries.charAt(i) == '_'){
				if(true == bStart){
					bStart = false;
					var tmpSery = sSeries.substring(startpos+1,i);
					if(tmpSery != null && tmpSery.length > 0){
						retArr[arrCnt] = tmpSery;
						arrCnt++;
					}
				}
				else{
					startpos = i;
					bStart = true;
				}
			}
		}
	}
	return retArr;
}

/** 设定赛事系列到用户定制当中(此方法并不会清除以前所作的定制，要完全重新定制请先调用clearCustomizeSery()方法) */
function setCustomizeSeryArr(seryArr){
	var sSeries = getOddsCookie("SPCN_ODDS_SERIES");
	if(sSeries == null)
		sSeries = "";
	for(i=0;i<seryArr.length;i++){
		if(sSeries.indexOf("_"+seryArr[i]+"_") < 0){
			sSeries = sSeries + "_"+seryArr[i]+"_";
		}
	}
	setOddsCookie("SPCN_ODDS_SERIES",sSeries);
}

/** 从用户定制中删除赛事系列 */
function deleteCustomizeSery(seryid){
	var sSeries = getOddsCookie("SPCN_ODDS_SERIES");
	if(sSeries == null)
		return;
	var pos = sSeries.indexOf("_"+seryid+"_");
	if(pos < 0)
		return;
	sSeries = sSeries.substring(0,pos) + sSeries.substring(pos+(("_"+seryid+"_").length),sSeries.length);
	setOddsCookie("SPCN_ODDS_SERIES",sSeries);
}

/** 清除用户赛事系列定制*/
function clearCustomizeSery(){
	deleteOddsCookie("SPCN_ODDS_SERIES");
}

/** 设置用户声音设定 */
function setCustomizeVoice(newVoice){
	setOddsCookie("SPCN_ODDS_VOICE",newVoice);
}

/** 设置静音 */
function setCustomizeVoiceMute(){
	setCustomizeVoice("MUTE");
}

/** 读取用户声音设定 */
function getCustomizeVoice(){
	var sVoice = getOddsCookie("SPCN_ODDS_VOICE");
	if(sVoice != null && sVoice == "MUTE"){
		sVoice = null;
	}
	else{
		if(sVoice == null || sVoice.length <= 3){
			sVoice = DEFAULT_VOICE_URL;
		}
	}
	return sVoice;
}

/** 设置用户CSS面板设定 */
function setCustomizeCSS(newCSS){
	setOddsCookie("SPCN_ODDS_CSSPANEL",newCSS);
}

/** 读取用户CSS面板设定 */
function getCustomizeCSS(){
	var sTmp = getOddsCookie("SPCN_ODDS_CSSPANEL");
	return (sTmp != null && sTmp.length > 0) ? sTmp : DEFAULT_CSS_URL;
}

/** 直播cookie设置的接口函数，当移植到sportscn.com之后要修改具体调用的函数。*/
function getOddsCookie(name){
	return getCookie(name);
}
function setOddsCookie(name,value){
	setSportscnForeverCookie(name,value);
}
function deleteOddsCookie(name){
	deleteSportscnCookie(name);
}



/** 得到cookie的值 */
function getCookie(name){ 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 
	var i = 0; 
	while (i < clen) { 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
			return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; 
	} 
	return null;
}


function setSportscnForeverCookie(name,value){
	setForeverCookie(name,value,'/','.sportscn.com');
}
function setSportscnCookie(name,value){
	var argv = setSportscnCookie.arguments;
	var argc = setSportscnCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	setCookie(name,value,expires,'/','.sportscn.com');
}
function deleteSportscnCookie(name){
	deleteCookie(name,'/','.sportscn.com');
}


// name,value,path,domain.secure
function setForeverCookie (name,value) {
	var expDays = 20*365;
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
	var argv = setForeverCookie.arguments;
	var argc = setForeverCookie.arguments.length;
	var path = (argc > 2) ? argv[2] : null;
	var domain = (argc > 3) ? argv[3] : null;
	var secure = (argc > 4) ? argv[4] : false;

	setCookie(name,value,exp,path,domain,secure);
}

// name,value,expires,path,domain.secure
function setCookie (name, value) {
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
					((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
					((path == null) ? "" : ("; path=" + path)) +
					((domain == null) ? "" : ("; domain=" + domain)) +
					((secure == true) ? "; secure" : "");
}

// 删除cookie.注意如果在setCookie的时候设置了path/domain，则在删除的时候需要同时提供相应的参数。
function deleteCookie (name) { 
	var argv = deleteCookie.arguments;
	var argc = deleteCookie.arguments.length;
	var path = (argc > 1) ? argv[1] : null;
	var domain = (argc > 2) ? argv[2] : null;
	var secure = (argc > 3) ? argv[3] : false;
	var exp = new Date(); 
	exp.setTime (exp.getTime() - 1000); 
	document.cookie = name + "=; expires=" + exp.toGMTString() +
					((path == null) ? "" : ("; path=" + path)) +
					((domain == null) ? "" : ("; domain=" + domain)) +
					((secure == true) ? "; secure" : "");
}

function getCookieVal (offset) { 
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) 
		endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr));
}

// end of 用户定制信息

/**********************************************************************************************/

// 格式化数字
function formatNumber(inNum,nSize){
	var sTmp= "" + inNum;
	var nLen = Number(sTmp.length);

	nSize = Number(nSize);
	
	if(nLen < nSize){
		var i = nLen;
		for(;i<nSize;i++){
			sTmp = "0" + sTmp;
		}
	}
	return sTmp;
}

function getPageFormatInfo(){
	var sTmpFormat = getOddsCookie('SPCN_ODDS_PAGEFORMAT');
	if(sTmpFormat == null || sTmpFormat.length < 2){
		return 'GB';
	}
	else{
		return sTmpFormat;
	}
}

// 加载文字编码信息
function loadPageFormatInfo(){
	var bReset = false;
	var sSearch = location.href.toUpperCase();

	var sNeedNavi = '';

	if(sSearch.indexOf("DEBUG=1") >= 0){
		openDebug();
	}

	if(sSearch.indexOf("BIG5") >= 0){
		g_sPageFormat = 'BIG5';
		bReset = true;
	}
	else if(sSearch.indexOf("GB") >= 0){
		g_sPageFormat = 'GB';
		bReset = true;
	}
	//else if(sSearch.indexOf("MACO") >= 0){
	//	g_sPageFormat = 'MACO';
	//	bReset = true;
	//}
	else if(sSearch.indexOf("EN") >= 0){
		g_sPageFormat = 'EN';
		bReset = true;
	}
	
	if(bReset == true){
		setOddsCookie('SPCN_ODDS_PAGEFORMAT',g_sPageFormat);
		if(sNeedNavi){
			location.replace(sNeedNavi);
		}
	}
	else{
		g_sPageFormat = getPageFormatInfo();
	}

	if(g_sPageFormat == 'BIG5'){
		// big5码
		document.charset="BIG5";
	}
	else{
		// 其他都用gb2312
		document.charset="GB2312";
	}
}

function myConfirm(str){
	return true;
}
// 输出调试信息
function debug(str,e){
	if(g_bDebug == true){
		if(typeof(divSPcnDebugShowerZ) == "undefined"){
			//document.body.insertAdjacentHTML('afterBegin',"<div id=divSPcnDebugShowerZ name=divSPcnDebugShowerZ style='position:absolute;top:1px;left:1px;overflow:auto;width:300px;height:400px;border:1px solid #ff0000;padding:2 2 2 2;background-color:#eeeeee;color:black;'>DEBUG INFO-&gt;</div>");
		}
		var tt = divSPcnDebugShowerZ.innerText;
		if(tt.length > 4000) divSPcnDebugShowerZ.innerHTML = 'DEBUG INFO-&gt;';
		divSPcnDebugShowerZ.innerHTML += '<br>' + str;
		if(debug.arguments.length == 2){
			divSPcnDebugShowerZ.innerHTML += "<br>[" + e.name + "]<br>" + e.message;
		}
		try{
			var lastpos = 0;
			do{
				lastpos = divSPcnDebugShowerZ.scrollTop;
				divSPcnDebugShowerZ.scrollTop+=1;
			}while(divSPcnDebugShowerZ.scrollTop != lastpos);
		}catch(e){}
	}
}

function openDebug(){
	g_bDebug = true;
}

function closeDebug(){
	g_bDebug = false;
}



// 其他公用数据

// 一个字一行
function strRowToCol(inStr){	
	var retStr = '';
	for(i=0;i<inStr.length;i++){
		if(i>0) retStr += '<br>';
		retStr += inStr.charAt(i);
	}
	return retStr;
}

function spm_scoredetail(mi){
	try{
		p=window.open('','SPM_SCOREDETAIL_'+mi,'left=20,top=20,width=800,height=600,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');
		p.focus();
		
		p.document.location.href='http://scripts.sportscn.com/live/detail.php3?encode='+g_sPageFormat+'&matchid='+mi;
	}
	catch(e){}
}

function spm_oddsdetail(mi){
	try{
		p=window.open('','_blank');
		p.focus();
		p.document.location.href='http://scripts.sportscn.com/odds/odds_aomen.php3?encode='+g_sPageFormat+'&matchid='+mi;
	}
	catch(e){}
}
function spm_asianeuropedetail(mi){
	try{
		p=window.open('','_blank');
		p.focus();
		p.document.location.href='http://scripts.sportscn.com/odds/odds_asianeurope.php?encode='+g_sPageFormat+'&matchid='+mi;
	}
	catch(e){}
}
function spm_oddsindexs(pname){
	var arglis = "";
	if(spm_oddsindexs.arguments.length > 1){
		for(var i=1;i<spm_oddsindexs.arguments.length;i+=2)
		arglis += "&"+spm_oddsindexs.arguments[i]+"="+spm_oddsindexs.arguments[i+1];
	}
	p=window.open('','_blank');
	p.document.location.href='http://scripts.sportscn.com/odds/'+pname+'.php?encode='+g_sPageFormat+arglis;
}

function spm_saidetail(id){
	var p=window.open("http://scripts.sportscn.com/odds/odds_detail.php?encode="+g_sPageFormat+"&matchid="+id);
	p.focus();
	testad();
}

function spm_panludetail(id,ctype,cid){
	window.open("http://scripts.sportscn.com/odds/odds_ju.php3?encode="+g_sPageFormat+"&matchid="+id+"&otype="+ctype+"&vid="+cid,'_blank','width=600,height=400,scrollbars=yes');
		testad();
}

function spm_panludetails(id){
	spm_panludetail(id,1,1);
}

function spm_tvdetail(id){
	window.open("http://scripts.sportscn.com/odds/odds_tv.php?encode="+g_sPageFormat+"&matchid="+id,'_blank','width=400,height=200,scrollbars=yes');
}

function spm_placedetail(id){
	window.open("http://scripts.sportscn.com/odds/odds_place.php?encode="+g_sPageFormat+"&matchid="+id,'_blank','width=440,height=200,scrollbars=yes');
}

function spm_spdetail(id){
	window.open("http://scripts.sportscn.com/odds/odds_sp.php?encode="+g_sPageFormat+"&matchid="+id,'_blank','width=400,height=200,scrollbars=yes');
}

function spm_zongdetail(id){
	window.open("http://scripts.sportscn.com/odds/odds_zonghui.php?encode="+g_sPageFormat+"&matchid="+id,'_blank','width=480,height=400,scrollbars=yes');
}

function spm_b_other(mid,cid){
	try{
		window.open('http://scripts.sportscn.com/odds/odds_bas_other.php3?matchid='+mid+'&companyid='+cid+'&encode='+g_sPageFormat,'_blank','left=20,top=20,width=500,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');
	}
	catch(e){}
}

function spm_b_ju(mid,cid){
	try{
		window.open('http://scripts.sportscn.com/odds/odds_bas_ju.php3?matchid='+mid+'&companyid='+cid+'&encode='+g_sPageFormat,'_blank','left=20,top=20,width=500,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');
	}
	catch(e){}
}

function spm_weatherdetail(id){
	window.open("http://scripts.sportscn.com/odds/odds_weather.php?encode="+g_sPageFormat+"&matchid="+id,'_blank','width=400,height=200,scrollbars=yes');
}

function spm_predictions(id,macid){
	window.open("http://odds.sportscn.com/predictions.html?id="+macid,'_blank','width=600,height=350,scrollbars=yes');
		testad();
}

function spm_mandetail(id){var p=window.open("http://scripts.sportscn.com/center/program/man.php?id="+id);p.focus();}
function spm_teamdetail(id){var p=window.open("http://scripts.sportscn.com/center/program/team.php?id="+id);p.focus();}
function spm_newsdetail(id){var t=parseInt(id/1000);var p=window.open("http://news.sportscn.com/c/"+t+"/"+id+".htm");p.focus();}
function dailyMatch(y,m,d){
	var p = window.open('','_blank');
	p.document.location.href="http://scripts.sportscn.com/live/search.php?year="+y+"&month="+m+"&day="+d;
}
function spm_audiodetail(u,mi){p=window.open('','SPM_AUDIODETAIL_'+mi,'left=100,top=50,width=286,height=151,menubar=no,status=no,location=no,toolbar=no,scrollbars=no,resizable=no');p.document.location.href=u;}

function openNewWin(url){
	window.open(url);
}

function open_smwin(url){
	var p = window.open(url,'smssubmitWin','width=440,height=440,statusbar=0,toolbar=0,scrollbars=0');
	p.focus();
}
function check_sms(){
	var tf = document.smsForm;
	
	for(i=0;i<tf.all("services[]").length;i++){
		tf.all("services[]")[i].value = '';
	}
	
    if(tf.zucai.checked == true && tf.saishi.checked == false){
		tf.all("services[]")[0].value = '0';
		tf.action = "http://sms.sportscn.com/item01.htm";
	}
	if(tf.zucai.checked == false && tf.saishi.checked == true){
		tf.all("services[]")[0].value = '0';
		tf.action = "http://sms.sportscn.com/item02.htm";
	}
	if(tf.zucai.checked == true && tf.saishi.checked == true){
		tf.all("services[]")[0].value = '0';
		//tf.action = "http://www.sportscn.com/sms/page02.htm";
		tf.action = "http://sms.sportscn.com/page02.htm";
	}
	var p = window.open('','smssubmitWin','width=440,height=440,statusbar=0,toolbar=0,scrollbars=1');
	p.focus();
	tf.submit();
}

function divPrint(arrDivs){
	var len = arrDivs.length;
	var i = 0;
	var printContent = '';
	for(;i<len;i++){
		printContent += document.all[arrDivs[i]].innerHTML;
	}

	var oldContent = document.body.innerHTML;
	document.body.innerHTML = printContent;
	window.print();
	document.body.innerHTML = oldContent;
	//window.history.go(0);
}

function spcnGolWinSMSAd(seryid){
	try{
		var serySMSAd_1 = "1";
		var serySMSAd_2 = "2";
		var serySMSAd_3 = "3";
		var serySMSAd_4 = "4";
		var serySMSAd_5 = "5";
		var serySMSAd_10 = "10";
		var serySMSAd_11 = "11";
		//var serySMSAd_213 = "213";
		var thisAd = null;
		eval('try{thisAd = serySMSAd_' + seryid + ';}catch(e){thisAd = null;}');
		if(null == thisAd){
			thisAd = "qita";
		}
		return "<img src='http://image.sportscn.com/odds/smspop/" + thisAd + ".gif' border=0 width=170 height=14>";
	}
	catch(e){
		debug(e);
		return "";
	}
}

function spcnVSWin(argu){
	window.showModelessDialog("showVSJump.htm",argu,"dialogLeft:-100;dialogTop:-100;dialogWidth:0px;dialogHeight:0px");
}

var spcnVSWidth = 210;
var spcnVSHeight = 144;
var spcnVSCurStep = 0;
var spcnVSInitTop = (screen.height-spcnVSHeight)/3;
var spcnVSInitLeft = screen.width;
var spcnVSTimer = null;
var spcnVSPopup = null;
var spcnVSPopupBody = null;
var spcnVSMatchId = 0;
function spcnVSWin2(id,team1,team2,vsnow,vslast,agio1,agio2,sery,scolor,seryid){
	if(null == spcnVSPopup){
		spcnVSPopup = window.createPopup();
		spcnVSPopupBody = spcnVSPopup.document.body;
		var poptext = '<div id=VSDiv style="cursor:move;"><table style="border:1px solid #000000;" width='+spcnVSWidth+' height='+spcnVSHeight+' cellpadding=0 cellspacing=0><tr><td><table width=100% height=100% border="0" cellspacing="0" cellpadding="0" style="font-size:12px;"><tr><td><tr style="background-color:#212121;" valign=middle height=16><td nowrap><img src="http://image.sportscn.com/live/r_t/icon0826.gif" align="absmiddle" border=0 width=13 height=12></td><td style="color:#F4F4F4;font-size:12px;font-weight:bold;font-family:Courier New;" align=left width=100%><I>&nbsp;Odds Change!!!</I></td><td valign=top nowrap><img id="VSCloseBtn" src="http://image.sportscn.com/live/r_t/off01.gif" alt="Close Pop VS" width=11 height=11 border=0 align="absmiddle" onmouseover=\'VSDiv.style.cursor="hand";\' onmouseout=\'VSDiv.style.cursor="move";\'></td></tr><tr style="background-color:#ffffff;" valign=middle height=100% width=100%><td nowrap colspan=3><table width=100% height=100% border="0" cellspacing="0" cellpadding="0"><tr style="background-color:#ffffff;" height=3><td align=right valign=middle style="color:#ffffff;" colspan=3></td></tr><tr style="font-size:12px;background-color:#ffffff;" valign=middle><td align=left style="font-size:12px;padding-left:4px;" id=spcnVS_team1></td><td align=right style="padding-right:4px;" id=spcnVS_agio1></td></tr><tr style="background-color:#ffffff;" height=100% valign=middle><td align=center style="font-size:12px;font-family:Courier New;" width=100% colspan=3><span id=spcnVS_vsnow></span><span id=spcnVS_vslast></span></td></tr><tr style="font-size:12px;background-color:#ffffff;" valign=middle><td align=left style="padding-left:4px;" id=spcnVS_team2></td><td align=right style="padding-right:4px;" id=spcnVS_agio2></td></tr><tr style="background-color:#ffffff;" height=3><td align=right valign=middle style="color:#ffffff;" colspan=3></td></tr><tr height=34 id=spcnVS_scolor valign=middle name=spcnVS_scolor><td align=right style="font-size:12px;color:#ffffff;" colspan=3><div id=spcnVS_sery></div><div id=spcnGol_smsad align=center></div></td></tr></table></td></tr></table></td></tr></table></div>';
	
		spcnVSPopupBody.innerHTML = poptext;
		spcnVSPopupBody.all['VSCloseBtn'].onclick = dismissPopVS;
		spcnVSPopupBody.onmouseup=null;
		spcnVSPopupBody.onmousedown=null;
		spcnVSPopupBody.onclick=null;
		spcnVSPopupBody.oncontextmenu=dismissPopVS;
		spcnVSPopupBody.all['spcnVS_vsnow'].onclick = showPopVSDetail;
	}

	spcnVSMatchId = id;
	spcnVSPopupBody.all['spcnVS_sery'].innerHTML = sery+"&nbsp;";
	//spcnVSPopupBody.all['spcnGol_smsad'].innerHTML = spcnGolWinSMSAd(seryid);
	spcnVSPopupBody.all['spcnVS_team1'].innerHTML = team1;
	spcnVSPopupBody.all['spcnVS_team2'].innerHTML = team2;
	spcnVSPopupBody.all['spcnVS_agio1'].innerHTML = agio1;
	spcnVSPopupBody.all['spcnVS_agio2'].innerHTML = agio2;
	spcnVSPopupBody.all['spcnVS_vsnow'].innerHTML = vsnow;
	spcnVSPopupBody.all['spcnVS_vslast'].innerHTML = vslast;
	if(scolor.charAt(0) == '#')
		spcnVSPopupBody.all['spcnVS_scolor'].bgColor = scolor;
	else
		spcnVSPopupBody.all['spcnVS_scolor'].className = scolor;

	timelyClose();
}

function timelyClose(){
	if(spcnVSTimer != null)
		clearTimeout(spcnVSTimer);
	spcnVSTimer = null;
	spcnVSCurStep = 0;
	spcnVSPopup.show(spcnVSInitLeft,spcnVSInitTop,spcnVSCurStep,spcnVSHeight);
	movePopVS();
}
function movePopVS(){
	/*
	// move step by step
	if(spcnVSTimer!=-1 && spcnVSCurStep<=spcnVSWidth){
		spcnVSCurStep++;
		spcnVSPopup.show(spcnVSInitLeft-spcnVSCurStep,spcnVSInitTop,spcnVSCurStep,spcnVSHeight);
		spcnVSTimer=setTimeout("movePopVS();",1);
	}
	else{
		spcnVSTimer=setTimeout("doClose();",15000);
	}
	*/
	// move quickly
	spcnVSPopup.show(spcnVSInitLeft-spcnVSWidth,spcnVSInitTop,spcnVSWidth,spcnVSHeight);
	spcnVSTimer=setTimeout("doClose();",15000);
}
function doClose(){
	spcnVSCurStep = spcnVSWidth;
	spcnVSPopup.show(spcnVSInitLeft,spcnVSInitTop,spcnVSCurStep,spcnVSHeight);
	closePopVS();
}
function closePopVS(){
	/*
	// close step by step
	if(spcnVSTimer!=-1 && spcnVSCurStep>=0){
		spcnVSPopup.show(spcnVSInitLeft-spcnVSCurStep,spcnVSInitTop,spcnVSCurStep--,spcnVSHeight);
		spcnVSTimer=setTimeout("closePopVS()",1);
	}
	else{
		dismissPopVS();
	}
	*/
	// close quickly
	dismissPopVS();
}
function dismissPopVS(){
	clearTimeout(spcnVSTimer);
	spcnVSTimer = -1;
	spcnVSPopup.hide();
	//window.focus();
}
function showPopVSDetail(){
	spm_oddsdetail(spcnVSMatchId);
}

var g_isMinIE4 = (document.all) ? 1 : 0;

var g_verDetail = 0;
try{
	g_verDetail = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+4));
}
catch(e){
	g_verDetail = 0;
}

var g_isMinIE55 = (g_isMinIE4 && g_verDetail >= 5.5) ? true : false;
//var g_isMinIE55 = false;
