﻿//檢查Cookie
function get_cookie(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) {
			offset=j;
   
			//沒有資料	
			if (document.cookie.substring(offset+1, 1) == ";") 
				return null;
			if (offset+1>clen) 
				return null;
		
			var endstr = document.cookie.indexOf (";", offset);
			if (endstr == -1) endstr = document.cookie.length;
			return unescape (document.cookie.substring(offset, endstr));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}


//解碼程式 , 在unescape後解碼還原中文
function decodecookie(str)
{
	var strArr;
	var strRtn="";
	strArr=str.split("a");
	for (var i=strArr.length-1;i>=0;i--) {
		strRtn+=String.fromCharCode(eval(strArr[i]));
	}
	
	return strRtn;
}




function get_cookie2(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) {
			offset=j;

			//沒有資料
			if (document.cookie.substring(offset+1, 1) == ";")
				return null;
			if (offset+1>clen)
				return null;

			var endstr = document.cookie.indexOf (";", offset);
			if (endstr == -1) endstr = document.cookie.length;

			return decodecookie(unescape(document.cookie.substring(offset, endstr)));

		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}



//login.js專用
function check1()
{
	var f = document.form2;
	var y = '';
	if (f.dfpcard.value == '') {y+='会員番号が入力されていません。\n';}
	if (f.pincode.value == '') {y+='パスワードが入力されていません。\n';}
	
	if (y=='') {return true;}
	else 
	{
		//y = '項目前有「*」號者，表示為必要填寫欄位喔!\n\n' + y
		alert(y);
		return false;
	}
}



document.write('						<div id="SideMenu">');
document.write('<a href="'+mainIndexURL+'"><img src="/jp/imgs/logo.gif" width="182" height="46" border="0"></a>');

document.write('			<div id="memberArea">');
document.write('						<!--- 如果未登入跑這段 開始 --->');
document.write('				<div style="background:url(/jp/imgs/membg.gif) no-repeat; width:182px; height:125px;">');
document.write('					<table width="170" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top: 40px">');
document.write('						<tr>');

var loginyn = get_cookie('clubid');  

if ((loginyn == null) || (loginyn == "")) {  
document.write('							<td valign="top" width="4" align="left">');
document.write('							<form name="form2" method="post" action="https://calec.china-airlines.com/e_club/jp/login_j.asp" autocomplete="off" onsubmit="return check1();">');
document.write('									<table border="0" cellspacing="2" cellpadding="0">');
document.write('										<tr>');
document.write('											<td>');
document.write('												<input name="dfpcard" type="text" size="8" maxlength="9"  onblur="if(this.value==\'\'){this.value=\'Card No.\'}else{this.value=this.value.toUpperCase();}" onfocus="if(this.value==\'Card No.\') this.value=\'\'" value="Card No.">');
document.write('											</td>');
document.write('										</tr>');
document.write('										<tr>');
document.write('											<td>');
document.write('												<input name="pincode" type="password" size="8" maxlength="9"  autocomplete="off">');
document.write('												<input class="menu1" border="0" type="image" name="sss" src="/jp/imgs/btn-login.gif" width="66" height="21"></td>');
document.write('										</tr>');
document.write('								</table>');
document.write('							</form>');
document.write('				</td>');
document.write('				<td align="center">');
document.write('					<table border="0" cellspacing="1" cellpadding="0" class="mem">');
document.write('						<tr>');
document.write('							<td width="6" valign="top"><img src="/jp/imgs/arrow.gif" alt="" /></td>');
document.write('							<td valign="middle" align="left"><p><a href="http://www.china-airlines.co.jp/dfp/index.html">マイレージ<br />プログラム</a></p></td>');
document.write('						</tr>');
document.write('						<tr>');
document.write('							<td valign="top"><img src="/jp/imgs/arrow.gif" alt="" /></td>');
document.write('							<td valign="middle" align="left"><p><!--<a href="http://www.china-airlines.co.jp/dfp/index.html#form">--><a href="https://calec.china-airlines.com/club/jp/clubjo_j.asp">入会申請</a></p></td>');
document.write('						</tr>');
document.write('						<tr>');
document.write('							<td valign="top"><img src="/jp/imgs/arrow.gif" alt="" /></td>');
document.write('							<td valign="middle" align="left"><p><a href="https://calec.china-airlines.com/e_club/jp/club.asp">会員専用ページ</a></p></td>');
document.write('						</tr>');
document.write('						<tr>');
document.write('							<td valign="top"><img src="/jp/imgs/arrow.gif" alt="" /></td>');
document.write('							<td valign="middle" align="left"><p><a href="http://www.china-airlines.co.jp/dfp/dfp11.html">プレミアム<br />プログラム</a></p></td>');
document.write('						</tr>');
document.write('					</table><br />');
document.write('				</td>');


document.write('						<!--- 如果未登入跑這段 結束 --->');
} else {       
document.write('						<!--- 如果已登入跑這段 開始 --->');
document.write('				<td valign="top">');
document.write('					<table width="100%" border="0" cellspacing="2" cellpadding="0" class="mem">');
document.write('						<tr>');
document.write('							<td><img src="/jp/imgs/empty.gif" width="1" height="1"></td>');
document.write('							<td class="memberInfo"><span>' + get_cookie2("infoname") + '</span><br>');
document.write('										会員番号： ' + get_cookie("clubid") + '<br>');
document.write('										交換可能マイル： <br><div align="right" style="margin-right:5px">' + get_cookie("infomileage") + ' miles</div></td>');
document.write('							<td><img src="/jp/imgs/empty.gif" width="1" height="1"></td>');
document.write('						</tr>');
document.write('						<tr align="center">');
document.write('							<td colspan="3"><a href="https://calec.china-airlines.com/e_club/jp/logout_j.asp"><img name="Image40" border="0" src="/jp/imgs/btn_logout.gif"  width="45" height="20"><input type="hidden" id="menu9"></a></td>');
document.write('						</tr>');
document.write('					</table>');
document.write('				</td>');

document.write('						<!--- 如果已登入跑這段 結束 --->');
}
document.write('			</tr>');
document.write('		</table>');
document.write('				</div>');
document.write('	</div>');
document.write('						</div>');