//檢查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;
}


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+='You forget to keyin the [Card No.]!\n';}  
  if (f.pincode.value == '') {y+='You forget to keyin the [Password]!\n';}
  
  if (y=='')
    {return true;}
  else 
  {
      //y = '項目前有「*」號者，表示為必要填寫欄位喔!\n\n' + y
      alert(y);
      return false;
  }
}

document.write('			<div id="memberArea">');
document.write('				<!--- 如果未登入跑這段 開始 --->');
document.write('				<div style="background:url(imgs_revamp/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">');
document.write('								<form name="form2" method="post" action="https://calec.china-airlines.com/e_club/us/login_e.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" class="inputTextmem" size="7" 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" class="inputTextmem" size="7" maxlength="9" autocomplete="off">');
document.write('												<input type="image" src="imgs_revamp/btn-login.gif" alt="" border="0" align="absmiddle"></td>');
document.write('										</tr>');
document.write('								</table>');
document.write('					</form>');
document.write('				</td>');
document.write('				<td>');
document.write('					<table border="0" cellspacing="1" cellpadding="0" class="mem">');
document.write('						<tr>');
document.write('							<td width="6" valign="middle"><img src="imgs_revamp/arrow.gif" alt="" /></td>');

expdate = new Date("Jun 24,2008");
	if (expdate >= new Date()){
		hyperLinkStr = 'http://www.china-airlines.com/en/dfpen/dfpen000144.htm'
	}
	else{
		hyperLinkStr = 'https://calec.china-airlines.com/club/us/clubjo_e.asp'
	}

document.write('							<td valign="middle"><a href="' + hyperLinkStr + '">Apply Now</a></td>');
document.write('						</tr>');
document.write('						<tr>');
document.write('							<td valign="middle"><img src="imgs_revamp/arrow.gif" alt="" /></td>');
document.write('							<td valign="middle"><a href="https://calec.china-airlines.com/club/us/emlreq_e.asp">Apply for Password</a></td>');
document.write('						</tr>');
document.write('						<tr>');
document.write('							<td valign="middle"><img src="imgs_revamp/arrow.gif" alt="" /></td>');
document.write('							<td valign="middle"><a href="https://calec.china-airlines.com/club/us/crdqry_e.asp">Inquiry Card No.</a></td>');
document.write('						</tr>');
document.write('						<tr>');
document.write('							<td valign="middle"><img src="imgs_revamp/arrow.gif" alt="" /></td>');
document.write('							<td valign="middle"><a href="https://calec.china-airlines.com/club/us/pwdqry_e.asp">Inquiry Password</a></td>');
document.write('						</tr>');
document.write('					</table>');
document.write('				</td>');
} 
else {  
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="/ch/imgs/empty.gif" width="1" height="1"></td>');
document.write('							<td class="memberInfo">' + get_cookie2("infoname") + '<br>');
document.write('										Card No. : ' + get_cookie("clubid") + '<br>');
document.write('										Balanced miles : ' + get_cookie("infomileage") + 'miles</td>');
document.write('							<td><img src="/ch/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/us/logout_e.asp"><img src="imgs_revamp/btnBlue.gif" alt="" border="0" align="absmiddle"></a></td>');
document.write('						</tr>');
document.write('					</table>');
document.write('				</td>');
}
document.write('			</tr>');
document.write('		</table>');
document.write('	</div>');