﻿function convertGive(give,tg)
{
    var re = "---";
    var a_give = new Array("---","0.0","0 / 0.5","0.5","0.5 / 1","1.0","1 / 1.5","1.5","1.5 / 2","2.0","2 / 2.5","2.5","2.5 / 3","3.0","3 / 3.5","3.5","3.5 / 4","4.0","4 / 4.5","4.5","4.5 / 5","5.0");
    if (give!="-1"){
       re = a_give[give];
       re = re.replace("../../../default.htm","../../../default.htm"+tg);
    }
    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_footer_width(w){

        RowsScript = "<table style='border-bottom-style: none;' border='1' cellspacing='0' cellpadding='0' width="+w+">";
        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 color1 = "0000CC";
	var color2 = "F12f44";
	var color3 = "009900";
	var color4 = "E300ab";
	var color5 = "000000";

	var aTV = new Array(new Array("")
,new Array("27","cable_62.gif","香港有線體育台(62台)","C62",color2)
,new Array("28","cable_2.gif","香港有線電視體育二台","C2",color2)
,new Array("29","ESPN_logo_ess_3d.gif","澳門有線ESPN台","E",color2)
,new Array("30","GDTV_logo.gif","廣東衛視台","G",color4)
,new Array("31","star_logo.gif","香港衛視體育台","ST",color2)
,new Array("32","TDM_C.gif","澳廣視中文台","M1",color3)
,new Array("33","TDM_P.gif","澳廣視葡文台","M2",color3)
,new Array("34","tvb_logo.gif","香港無線電視翡翠台","T1",color2)
,new Array("35","ubc30_logo.gif","泰星UBC30台","U30",color1)
,new Array("36","ubc31_logo.gif","泰星UBC31台","U31",color1)
,new Array("37","ubc26_logo.gif","泰星UBC26台","U26",color1)
,new Array("38","cable_18.gif","香港有線18台","C18",color2)
,new Array("39","Ch5.gif","中央5台","CC5",color4)
,new Array("40","ubc1.gif","泰星UBC1台","U1",color1)
,new Array("41","ubc2.gif","泰星UBC2台","U2",color1)
,new Array("42","ubc3.gif","泰星UBC3台","U3",color1)
,new Array("43","ubc4.gif","泰星UBC4台","U4",color1)
,new Array("44","ubc5.gif","泰星UBC5台","U5",color1)
,new Array("45","ubc6.gif","泰星UBC6台","U6",color1)
,new Array("46","ubc60.gif","泰星UBC60台","U60",color1)
,new Array("47","atv_logo.gif","香港亞洲電視本港台","A1",color2)
,new Array("48","atvworld_logo.gif","香港亞洲電視國際台","A2",color2)
,new Array("49","Ch1.gif","中央1台","CC1",color4)
,new Array("52","Gz.gif","廣東珠江台","GZ",color4)
,new Array("53","TA.gif","台灣年代體育台","TA",color5)
,new Array("54","TA1.gif","台灣年代生活台","TA1",color5)
,new Array("55","Ch2.gif","中央2台","CC2",color4)
,new Array("56","cable_a.gif","香港有線A台","CA",color2)
,new Array("58","cable_ms.gif","澳門有線衛視體育台","CM",color2)
,new Array("59","SSA.gif","澳門衛視體育台(東南亞頻道)","SSA",color2)
,new Array("60","t2.gif","香港無線電視明珠台","T2",color2)
,new Array("61","FE.gif","台灣ESPN台","FE",color5)
,new Array("65","cable_11.gif","香港有線11台","C11",color2)
,new Array("66","ubc32_logo.gif","泰星UBC32台","U32",color1)
,new Array("67","ubc33_logo.gif","泰星UBC33台","U33",color1)
,new Array("68","SA.gif","澳門衛視體育台(亞洲頻道)","SA",color2)
,new Array("70","tv5.gif","法國TV5台","TV5",color2)
,new Array("72","GT.gif","廣東電視體育頻道","GT",color4)
,new Array("74","nhk.gif","日本NHK台","NHK",color2)
,new Array("75","cable_99.gif","香港有線99台","C99",color2)
,new Array("76","cable_61.gif","香港有線足球台(61台)","C61",color2)
,new Array("95","now_89.gif","香港NOW89台","N89",color2)
,new Array("115","now_90.gif","香港NOW90台","N90",color2)
,new Array("135","now_91.gif","香港NOW91台","N91",color2)
,new Array("155","now_92.gif","香港NOW92台","N92",color2)
,new Array("175","cable_166.gif","香港有線166台","C166",color2)
,new Array("176","dragon.gif","東方衛視","D",color4)
,new Array("195","mc34.gif","澳門有線球王台(34台)","MC34",color3)
,new Array("196","mc35.gif","澳門有線球迷台(35台)","MC35",color3)
,new Array("215","cable_63.gif","香港有線英超台(63台)","C63",color2)
,new Array("216","cable_64.gif","香港有線球彩台(64台)","C64",color2)
,new Array("235","now_84.gif","香港NOW84台","N84",color2)
,new Array("236","now_85.gif","香港NOW85台","N85",color2)
,new Array("255","mc36.gif","澳門有線GOAL1台(36台)","MC36",color3)
,new Array("256","mc37.gif","澳門有線GOAL2台(37台)","MC37",color3)
,new Array("275","now_86.gif","香港NOW86台","N86",color2)
,new Array("276","now_87.gif","香港NOW87台","N87",color2)
,new Array("295","ubc35_logo.gif","泰星UBC35台","U35",color1)
,new Array("296","ubc36_logo.gif","泰星UBC36台","U36",color1)
,new Array("297","ubc37_logo.gif","泰星UBC37台","U37",color1)
,new Array("298","ubc38_logo.gif","泰星UBC38台","U38",color1)
,new Array("299","ubc39_logo.gif","泰星UBC39台","U39",color1)
,new Array("300","ubc40_logo.gif","泰星UBC40台","U40",color1)
,new Array("315","sun_51.gif","新電視GOAL1台(25台)","S25",color2)
,new Array("316","sun_52.gif","新電視GOAL2台(26台)","S26",color2)
,new Array("335","RTPi.gif","葡國RTPi台(港澳有線)","R",color2)
,new Array("355","cable_60.gif","香港有線60台","C60",color2)
,new Array("356","sun_998.gif","新電視998台","S998",color2)
,new Array("375","tv_5F25.gif","無線收費電視GOAL1台(25台)","T25",color2)
,new Array("376","tv_26.gif","無線收費電視GOAL2台(26台)","T26",color2)
,new Array("377","tv_998.gif","無線收費電視998台","T998",color2)
,new Array("395","now_684.gif","香港NOW684台","N684",color2)
,new Array("396","now_685.gif","香港NOW685台","N685",color2)
,new Array("397","now_686.gif","香港NOW686台","N686",color2)
,new Array("398","now_687.gif","香港NOW687台","N687",color2)
,new Array("398","now_687.gif","香港NOW687台","N687",color2)
,new Array("415","now_825.gif","香港NOW825台","N825",color2)
,new Array("416","now_826.gif","香港NOW826台","N826",color2)
,new Array("435","now_898.gif","香港NOW898台","N898",color2)
);
    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=\"../../images/tv/"+aTV[y][1]+"\" height=\"20\" width=\"30\" alt=\""+aTV[y][2]+"\">";
				sOutput += "&nbsp;<font title=\""+aTV[y][2]+"\" face=\"Arial, Helvetica, sans-serif\" size=\"1\" color=\""+aTV[y][4]+"\"><b>"+aTV[y][3]+"</b></font>";
				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=../../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>';
//         res+= '<option value="5">下 週 初 盤</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_3Anone;z-index_3A100;FILTER_3A 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 -------------------------// 

