﻿function convertGive(give)
{
    var re = "---";
    var a_give = new Array("---","平手","平手/半球","半球","半球/一球","一球","一球/球半","球半","球半/兩球","兩球","兩球/兩球半","兩球半","兩球半/三球","三球","三球/三球半","三球半","三球半/四球","四球","四球/四球半","四球半","四球半/五球","五球");
    if (give!="-1"){
       re = a_give[give];
    }
    return re; 
}

function convertWeather(wea,no)
{
	var weather = new Array('&nbsp;','&nbsp;');

	if (wea.indexOf('Mostly Sunny')>=0)		{weather = new Array('大致天晴',	'partlysunny.gif');}
	else if (wea.indexOf('Sunny')>=0)		{weather = new Array('天晴',		'sunny.gif');}
	else if (wea.indexOf('clear')>=0 ||
	         wea.indexOf('Clear')>=0)		{weather = new Array('天晴',		'sunny.gif');}
	else if (wea.indexOf('Partly Cloudy')>=0 ||
	         wea.indexOf('AM Clouds / PM Sun')>=0)	{weather = new Array('間中有雲',	'partlycloudy.gif');}
	else if (wea.indexOf('Mostly Cloudy')>=0)	{weather = new Array('多雲',		'cloudy.gif');}
	else if (wea.indexOf('Cloudy')>=0)		{weather = new Array('有雲',		'cloudy.gif');}
	else if (wea.indexOf('Scattered T-Storms')>=0)	{weather = new Array('雷暴',		'storm.gif');}
	else if (wea.indexOf('Isolated T-Storms')>=0)	{weather = new Array('地區性雷暴',	'storm.gif');}
	else if (wea.indexOf('T-Storms')>=0)		{weather = new Array('雷暴',		'storm.gif');}
	else if (wea.indexOf('Scattered Showers')>=0)	{weather = new Array('有雨',		'heavyrain.gif');}
	else if (wea.indexOf('Light Rain')>=0)		{weather = new Array('微雨',		'lightrain.gif');}
	else if (wea.indexOf('Rain')>=0 ||
	         wea.indexOf('Showers')>=0)		{weather = new Array('大雨',		'heavyrain.gif');}
	else if (wea.indexOf('snow')>=0 ||
	         wea.indexOf('Snow')>=0)		{weather = new Array('下雪',		'snow.gif');}
	else if (wea.indexOf('fog')>=0 ||
	         wea.indexOf('Fog')>=0)			{weather = new Array('有霧',		'foggy.gif');}
	else {weather=new Array('','dummy.gif')}

	if (no=='0') {re = weather[0];} else {re=weather[1];}

	return re;
}


// start Redirect the URL option function
function leapto_odds_option(obj,no){
	   var url= "#";
	   var titleText = "澳門彩票有限公司";
	   var default_v = "2";
	  
	    if (obj.value==1) {url = "ch-winodds.html";titleText="亞 洲 讓 球 盤 ";}
	    if (obj.value==2) {url = "ch-overandunder.html";titleText="上 / 下 盤";}
	    if (obj.value==3) {url = "ch-halffullt_frameset.html";titleText=" 半 全 場";}
	    if (obj.value==4) {url = "ch-allup.html";titleText="標 準 盤 ";}
	    if (obj.value==15) {url = "ch-windrawwinfirsthalf.html";titleText="上 半 場 標 準 盤";}
	    if (obj.value==5) {url = "ch-cor_scores_frameset.html";titleText="波 膽  ";}
	    if (obj.value==6) {url = "ch-mu_cor_scores.html";titleText="波 膽  組 合 ";}
	    if (obj.value==7) {url = "ch-totalscore.html";titleText="全 場 入 球 總 數 ";}
	    if (obj.value==8) {url = "ch-oddeven.html";titleText="入 球 單/雙 數 ";}
	    if (obj.value==9) {url = "ch-firstscorer.html";titleText="首 名 入 球 球 員 ";}
	    if (obj.value==10) {url = "ch-championmenu.html";titleText=" 冠 軍 賠 率 ";}
	    if (obj.value==11) {url = "ch-numberofgoals.html";titleText=" 球 隊 入 球 數";}
	    if (obj.value==12) {url = "ch-halffulltotalscore.html";titleText="上/下 半 場 入 球 較 多";}
	    if (obj.value==13) {url = "ch-firstgoalteam.html";titleText="最 先 入 球 球 隊";}
	    if (obj.value==14) {url = "ch-teamcompare.html";titleText="球 隊 入 球 比 拼";}
	   
	    
	    if (no=='H') { window.location.href=url+"?"+default_v;}
	   	if (no=='C') { window.location.href=url+"?"+default_v;}
	   	if (no=='M') { parent.document.location.href=url;}

	}
	
	function leapto(url,obj) {
	   //window.location.href=url+"?"+obj.value
	    window.location.search="?"+obj.value;OddsArea();
	}
	
	function leaptoM(url,obj) {
		parent.frames["halfmainFrame"].location.href =  url + "?" + obj.value
		if (obj.value=="1") {parent.frames["topFrame"].subtitle.innerHTML = " 已 開 賽 指 数";}
		if (obj.value=="2") {parent.frames["topFrame"].subtitle.innerHTML = "";} 
        if (obj.value=="4") {parent.frames["topFrame"].subtitle.innerHTML = " 初 步 參 考 指 数";} 
		
	}

function getURLValue(val) {
	
    var a = new Array(10);
    if (val.length>0) {
        a = token(val.substring(1,val.length),",");
    } else {
        a[0] = 2;
    }
     
    return a;
}
// end Redirect URL function


// start Format of time 
function s_time(sDate){
 var get_time = "";
     get_time = sDate.substr(9,5);
 
 return get_time;
}

function s_day(sDate){
 var get_time = "";
 var get_date = new Date(sDate.substr(0,4),sDate.substr(4,2)-1,sDate.substr(6,2),sDate.substr(9,2),sDate.substr(12,2));
 var get_day  = get_date.getDay();
 var dayNameBig5 = new Array("日","一","二","三","四","五","六");
 
 mo = Number(sDate.substr(4,2));
 dy = Number(sDate.substr(6,2));
 get_time =  sDate.substr(0,4) + " 年 " + mo + " 月 " + dy + " 日 (星期" +dayNameBig5[get_day]+")";
 return get_time;
}
// end Format of time

// start Format number
function ftnumber(no) {
	var re = no;
	if (no.length==1) {re = no+".00";}
	if (no.length==3) {re = no+"0";}
	
	return re;
}
// end Format number

// start Display of the title and footer
function s_footer(){

        RowsScript = "<table style='border-bottom-style: none;' border='1' cellspacing='0' cellpadding='0' width='600'>";
        RowsScript += "<tr bgcolor=#000099><td colspan=5 height=80 align=center><font color=#FFFFFF><b>暫時沒有指数</b></font></td></tr>";
        return RowsScript;	
}

function s_title(a) {
    document.all.subtitle.innerHTML = "";
    if (a=="1") {document.all.subtitle.innerHTML = " 已 開 賽 指 数";}
    if (a=="4") {document.all.subtitle.innerHTML = " 初 步 參 考 指 数";} 
}
// end Display of the title and footer

// string token function
function token(str,tk) {
   var re = new Array();
   var index = 0;
   var count = 0;
   for (i=0;i<str.length;i++) {
      if (str.substring(i,i+1)==tk) {
         re[count++] = str.substring(index,i);
         index = i+1;            
      }   
   }
   
   if (index>0) {re[count++] = str.substring(index,str.length);}
   if (index==0) {re[0]=str;}
   
   return re; 
}

//start  for TV Logo
function reTV() {
	var aTV = new Array(new Array("")
,new Array("27","cable_62.gif","香港有線體育台(62台)")
,new Array("28","cable_2.gif","香港有線電視體育二台")
,new Array("29","ESPN_logo_ess_3d.gif","澳門有線ESPN台")
,new Array("30","GDTV_logo.gif","廣東衛視台")
,new Array("31","star_logo.gif","香港衛視體育台")
,new Array("32","TDM_C.gif","澳廣視中文台")
,new Array("33","TDM_P.gif","澳廣視葡文台")
,new Array("34","tvb_logo.gif","香港無線電視翡翠台")
,new Array("35","ubc30_logo.gif","泰星UBC30台")
,new Array("36","ubc31_logo.gif","泰星UBC31台")
,new Array("37","ubc26_logo.gif","泰星UBC26台")
,new Array("38","cable_18.gif","香港有線18台")
,new Array("39","Ch5.gif","中央5台")
,new Array("40","ubc1.gif","泰星UBC1台")
,new Array("41","ubc2.gif","泰星UBC2台")
,new Array("42","ubc3.gif","泰星UBC3台")
,new Array("43","ubc4.gif","泰星UBC4台")
,new Array("44","ubc5.gif","泰星UBC5台")
,new Array("45","ubc6.gif","泰星UBC6台")
,new Array("46","ubc60.gif","泰星UBC60台")
,new Array("47","atv_logo.gif","香港亞洲電視本港台")
,new Array("48","atvworld_logo.gif","香港亞洲電視國際台")
,new Array("49","Ch1.gif","中央1台")
,new Array("52","Gz.gif","廣東珠江台")
,new Array("53","TA.gif","台灣年代體育台")
,new Array("54","TA1.gif","台灣年代生活台")
,new Array("55","Ch2.gif","中央2台")
,new Array("56","cable_a.gif","香港有線A台")
,new Array("58","cable_ms.gif","澳門有線衛視體育台")
,new Array("59","SSA.gif","澳門衛視體育台(東南亞頻道)")
,new Array("60","t2.gif","香港無線電視明珠台")
,new Array("61","FE.gif","台灣ESPN台")
,new Array("65","cable_11.gif","香港有線11台")
,new Array("66","ubc32_logo.gif","泰星UBC32台 ")
,new Array("67","ubc33_logo.gif","泰星UBC33台")
,new Array("68","SA.gif","澳門衛視體育台(亞洲頻道)")
,new Array("70","tv5.gif","法國TV5台")
,new Array("72","GT.gif","廣東電視體育頻道")
,new Array("74","nhk.gif","日本NHK台")
,new Array("75","cable_99.gif","香港有線99台")
,new Array("76","cable_61.gif","香港有線足球台(61台)")
,new Array("95","now_89.gif","香港NOW89台")
,new Array("115","now_90.gif","香港NOW90台")
,new Array("135","now_91.gif","香港NOW91台")
,new Array("155","now_92.gif","香港NOW92台")
,new Array("175","cable_166.gif","香港有線166台")
,new Array("176","dragon.gif","東方衛視")
,new Array("195","mc34.gif","澳門有線球王台(34台)")
,new Array("196","mc35.gif","澳門有線球迷台(35台)")
,new Array("215","cable_63.gif","香港有線英超台(63台)")
,new Array("216","cable_64.gif","香港有線球彩台(64台)")
,new Array("235","now_84.gif","香港NOW84台")
,new Array("236","now_85.gif","香港NOW85台")
,new Array("255","mc36.gif","澳門有線GOAL1台(36台)")
,new Array("256","mc37.gif","澳門有線GOAL2台(37台)")
,new Array("275","now_86.gif","香港NOW86台")
,new Array("276","now_87.gif","香港NOW87台")
,new Array("295","ubc35_logo.gif","泰星UBC35台")
,new Array("296","ubc36_logo.gif","泰星UBC36台")
,new Array("297","ubc37_logo.gif","泰星UBC37台")
,new Array("298","ubc38_logo.gif","泰星UBC38台")
,new Array("299","ubc39_logo.gif","泰星UBC39台")
,new Array("300","ubc40_logo.gif","泰星UBC40台")

);
    return aTV;
}
function getTVLogo(sValue, sDelimiter,aTV) {
	arrayString = sValue.split(sDelimiter);
	var sOutput = "";
        var iCount = 0;	
	if (sValue!="null"){ 
	for (var i=0; i<arrayString.length; i++) {
		for (y=1; y<aTV.length; y++) {
			if (aTV[y][0]==arrayString[i]) {
				sOutput += "<img src=\"http://odd2.88ball.com/soccer/images/tv/"+aTV[y][1]+"\" height=\"20\" width=\"30\" alt=\""+aTV[y][2]+"\">";
				iCount++;
				if (iCount==2) {
				          sOutput += "<br>";
				          iCount=0;
				          break;
			    }
			}
		}
	}
	}
	return ((sOutput=="")?"&nbsp;":sOutput);
}

function genTV(tv,fixture) {
    var re = "";
    var tva = token(tv,",");
    
    for (i=0;i<tva.length;i++) {
        tt = Number(tva[i]);
        re += "<img src=/soccer/images/tv/"+fixture[tt][4]+" height=20 width=30 ALT="+fixture[tt][1]+"> ";           
    }
    
    return re;
}
//end for TV Logo


// start gen select Option 
function genMenu() {
         res= '<option value="1">請 選 擇 指 数　</option>';
         res+= '<option value="1">亞 洲 讓 球 盤 </option>';
         res+= '<option value="2">上 / 下 盤</option>';
         res+= '<option value="3"> 半 全 場</option>';
         res+= '<option value="4">標 準 盤 </option>';
         res+= '<option value="15">上 半 場 標 準 盤</option>';
         res+= '<option value="5">波 膽  </option>';
         res+= '<option value="6">波 膽  組 合 </option>'
         res+= '<option value="7">全 場 入 球 總 數 </option>';
         res+= '<option value="8">入 球 單/雙 數 </option>';
         res+= '<option value="9">首 名 入 球 球 員 </option>';
         res+= '<option value="10">    冠 軍 賠 率 </option>';
         res+= '<option value="11">球 隊 入 球 數</option>';
         res+= '<option value="12">上/下 半 場 入 球 較 多</option>';
         res+= '<option value="13">最 先 入 球 球 隊</option>';
         res+= '<option value="14">球 隊 入 球 比 拼</option>';
        
	      document.write(res);
}

function genOption() {
         res= '<option value="2">澳門彩票有限公司 ─ 請選擇　</option>';
         res+= '<option value="2">賠 率</option>';
         res+= '<option value="4">初 步 參 考 指 数</option>';
         res+= '<option value="1">已 開 賽 指 数</option>'
          document.write(res);
}
// end gen select Option


function delineate2(str) {
    point = str.lastIndexOf("=");
    return(str.substring(point+1,str.length));
}

function delineate(str) {
     point = str.lastIndexOf("?");
     return(str.substring(0,point));
}



// -------------------- Package Downloading Bar -------------------------// 
var b_isDownloading = true;
var termin = false;
function onDownloadingBar() {


document.write("<div id=onLoadingBar style='position:absolute;display:none;z-index:100;FILTER: revealTrans(transition=23,duration=0.5) blendTrans(duration=0.5);'>");
document.write("<table width='200' border='1' cellspacing='0' cellpadding='0' bgcolor='#ffffcc' id=loadingBarHolder>");
document.write("<tr height=100 valign=middle>");
document.write("<td width=100% align=center style='padding-left:20px;padding-right:20px;font-size:12px;font-family:Courier New;' id=txtDownloadBar name=txtDownloadBar>");
document.write("</td>");
document.write("</tr>");
document.write("<tr valign=middle>");
document.write("<td width=100% bgcolor='#ff6600'><img src='bar.gif' width=1 height=12 id=imgDownloadBar name=imgDownloadBar border=0></td>");
document.write("</tr>");
document.write("</table>");
document.write("</div>");	

this.doDownloadingBar = downloadingBar;
this.setLoadBar = myload_setLoadBar;
this.dohideLoadingBar = hideLoadingBar;


var loadingBarStep = Number(1);
var reFreshTimeOut = Number(8000);
var retryTimes = 0;
var maxRetryTimes = 2;
var alertmsg = "Please try again later";
if (Number(delineate2(document.URL))>0)
retryTimes = Number(delineate2(document.URL));

if (retryTimes > maxRetryTimes){
	b_isDownloading = false;
	termin = true;
		//if (confirm("線路繁忙中，重試否?")) location = delineate(document.URL);
}	


loadingBarWidth = loadingBarHolder.width - 4;
txtDownloadBar.innerHTML = "資料下載中，請稍候......";

function myload_setLoadBar(){
	onLoadingBar.style.top=document.body.scrollTop+(document.body.offsetHeight/3)+30;
	onLoadingBar.style.left=Math.floor((document.body.offsetWidth - loadingBarWidth)/2);
}

this.setLoadBar();

var waitTimes = Math.round(loadingBarWidth / loadingBarStep);
var sleepTime = Math.ceil(reFreshTimeOut / waitTimes);

var timerCount = 0;
function downloadingBar(){
	var tp = onLoadingBar;
	try{
		if(b_isDownloading == true){
			//matchBoard.innerHTML = MATCH_ONLOADING;
			if(timerCount++ >= waitTimes){
				txtDownloadBar.innerHTML = "賠率下載............";
				retryTimes ++;
				location = delineate(document.URL) +"?l="+retryTimes;
			}
			else{
				tp.style.display = "";
				if(Number(imgDownloadBar.width) == loadingBarWidth)
					imgDownloadBar.width = 1;
				else if(Number(imgDownloadBar.width) + loadingBarStep > loadingBarWidth)
					imgDownloadBar.width = loadingBarWidth;
				else
					imgDownloadBar.width= imgDownloadBar.width + loadingBarStep;
				setTimeout("this.doDownloadingBar();",sleepTime);
			}
		}
		else{
//			txtDownloadBar.innerHTML = "下載成功。";
//			imgDownloadBar.width = loadingBarWidth;
//			setTimeout(this.dohideLoadingBar,500);
			this.dohideLoadingBar();
//			tp.style.display = "none";
		}
	}
	catch(e){
		tp = null;
		alert('Error on downloading Bar!',e);
	}
	tp = null;
}
function hideLoadingBar(){
//	onLoadingBar.filters.revealTrans.apply();
	onLoadingBar.style.visibility = "hidden";
//	onLoadingBar.filters.revealTrans.play();
}
this.doDownloadingBar();
}

// -------------------- Package Downloading Bar -------------------------// 

