<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>會員註冊</title>
<script src='../jQuery/jquery-1.2.6.js' type='text/javascript'></script>
<SCRIPT LANGUAGE="JavaScript" src="../jQuery/TbxLenLimit.js"></SCRIPT>
<script type="text/javascript">
	

function send_msg() {

				
	
	
	
	$.ajax({
   type: "POST",
   url: "../register_act.php",
   data: {mAccount:$('#account').val(),password:$('#pwd').val(),cellphone:$('#phone').val(),email:$('#mail').val()},
   beforeSend:function(){
   $('#reg_form').fadeOut(200);
   $('.message-loading').fadeIn(200);

		var message = '';
		if (!$('#account').val()) {
			message += '帳號 is required. ';
		}
		if ($('#pwd').val()=='') {
			message += '密碼 is required.';
		}
		if ($('#pwd2').val()=='') {
			message += '請再輸入確認密碼';
		}
	if ($('#pwd').val()!=$('#pwd2').val()) {
			message += '密碼與確認密碼不符 請重新輸入 .';
		}
		if ($('#mail').val()=='') {
			message += 'MAIL is required.';
		}
		
		

		if (message.length > 0) {
		$('#msgg').html(message);
    	$('#msgg').fadeIn();
		  $('#reg_form').fadeIn(200);
   $('.message-loading').fadeOut(200);
			return false;
		}
		else {
			return true;
		}
	}/*,
  success: function(response) {
         if (response.responseText!='') {
	    $('#msg').html(response.responseText);
    	$('#msg').fadeIn();
	
  		}else{
		//location.href="../member/index.php";
		}
  }*/,
  complete: function (xhr) {
  	//alert(xhr.responseText);
								$('#msgg').html(xhr.responseText);
							$('#msgg').fadeIn();
								  $('.message-loading').fadeOut(200);
							}


   });	return false;
  	
 }
	
	var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) 
{
  XMLHttpRequestObject = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
  XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp");
}

function getData(dataSource, mAccount)
{
  if(XMLHttpRequestObject)
  {
    XMLHttpRequestObject.open("GET", dataSource);
    XMLHttpRequestObject.onreadystatechange = function()
    {
      if (XMLHttpRequestObject.readyState == 4 &&
          XMLHttpRequestObject.status == 200)
      {
		  eval("var response=("+XMLHttpRequestObject.responseText+")");
		  
		  if(response[0].check!='NULL'){
		  	
		  	
        var objDiv = document.getElementById(mAccount);
        objDiv.innerHTML =response[0].content;
        check='OK';
      
		
		
		  }else{
			  var objDiv = document.getElementById(mAccount);
        objDiv.innerHTML =response[0].content;
		check='NO';
		
			  }
      }
    }
    XMLHttpRequestObject.send(null);
  }
}

function checkUsername(keyEvent, mAccount)
{
  keyEvent = (keyEvent) ? keyEvent: window.event;
  input = (keyEvent.target) ? keyEvent.target : keyEvent.srcElement;
  if (keyEvent.type == "keyup")
  {
	
    var objDiv = document.getElementById(mAccount);
    objDiv.innerHTML = "<span></span>";
    if (input.value)
    {
      getData("../member/login_check.php?qry="+input.value, mAccount);
    }
  } 

  
}
		</script>
</head>

<body>

<form action="register_act.php" method="post" id="reg_form" name="restauForm" onsubmit="return send_msg();">
	<table width="63%" border="0" id="temp">
      <tr>
        <th width="32%" height="40" valign="top">帳號 (Account) </th>
        <td><input name="account" type="text" id="account" size="20" maxlength="20" onkeyup="checkUsername(event,'showDiv');"/><br><span id="showDiv" maxlength='5'></span></td>
      </tr>
	  <tr>
        <th height="40" valign="top">密碼(password)</th>
        <td><input name="password" type="password" id="pwd" size="22" maxlength="22"/></td>
      </tr>		
	    <tr>
        <th height="40" valign="top">確認密碼(password)</th>
        <td><input name="password" type="password" id="pwd2" size="22" maxlength="22"/></td>
      </tr>	
      <tr>
        <th height="40" valign="top">手機(cellphone)</th>
        <td><input name="cellphone" type="text" id="phone" size="20" maxlength="20"/></td>
      </tr>
	  <tr>
        <th height="40" valign="top">E-mail</th>
        <td><input name="email" type="text" id="mail" size="30" maxlength="50"/></td>
      </tr>
    </table>
    <input type="Submit" name="Submit"  value="Send"/>
</form>
<div class='message-loading' style='display:none'><img src="images/loadingAnimation.gif" /> Sending.....
	</div>
 <div id="msgg" style='display:none;'>
 	</div>

</body>

</html>
