function do_login(type){
if (type == "login")
{
	if ( document.fm1.username.value == "" ) {
    		alert ("請填入您的帳號");
    		document.fm1.username.focus();
    		return false;
  	}
  	if ( document.fm1.pwd.value == "" ) {
    		alert ("請填入您的密碼");
    		document.fm1.pwd.focus();
    		return false;
  	}
	fm1.type.value = type;
	fm1.action = "login.php";
	fm1.target = "_self";
	fm1.method = "POST";
	fm1.submit();
	return false;
}
else if (type == "logout")
{
		if (confirm('確定要登出嗎??')) {			
			fm1.type.value = type;
			fm1.method = "POST";
			fm1.action = "login.php";
			fm1.target = "_self";
			fm1.submit();
			return false;
		}
	}
}
function in_game(){
	fm1.action = "ingame.php";
	fm1.target = "_self";
	fm1.method = "POST";
	fm1.submit();	
}

function do_mu(st){
	if (st == "yes")
	{
		location='./?act=reg';	
	}else
	{
		location='./';	
	}
	return false;
}

function do_reg(){
	if ( document.fm1.reg_user.value.length > 12 || document.fm1.reg_user.value.length < 4) {
    		alert ("帳號長度不能超過12個字或少於4個字！");
    		document.fm1.reg_user.focus();
    		return false;
  	}
  	
   	if(document.fm1.reg_user.value.match(/\W/)){
	   		alert("帳號不能含有非字母或數字的字元，請重新輸入")
	   		document.fm1.reg_user.focus()
	   		return false; 
	  }
  	if ( document.fm1.reg_pw.value.length > 12 || document.fm1.reg_pw.value.length < 4) {
    		alert ("密碼長度不能超過12個字或少於4個字！");
    		document.fm1.reg_pw.focus();
    		return false;
  	}
  	if(document.fm1.reg_pw.value.match(/\W/)){
	   		alert("密碼不能含有特殊的字元，請重新輸入")
	   		document.fm1.reg_pw.focus()
	   		return false; 
	  }
  	if ( document.fm1.reg_pw.value != document.fm1.reg_re_pw.value ) {
    		alert ("您的確認密碼不符");
    		document.fm1.reg_re_pw.focus();
    		return false;
  	}
  	
  	if(document.fm1.reg_mail.value == ""){
			   alert('email沒填哦!')
			   document.fm1.reg_mail.focus()
			   return false;
		 }
	if ( document.fm1.reg_mail.value.length < 10) {
    		alert ("email格式錯誤！");
    		document.fm1.reg_mail.focus();
    		return false;
  	}
  	var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|tv|TV|tw|TW|in|IN)$"
	var re = new RegExp(regu);
	if (document.fm1.reg_mail.value.search(re) == -1) {
		alert ("請輸入合法的mail ！");
		document.fm1.reg_mail.focus();
		return false;
	}
	
	
	fm1.type.value = "reg";
	fm1.action = "sub_result.php";
	fm1.method = "POST";
	fm1.submit();
	return false;	
}
function do_faq(){
	if (document.fm1.mail.value.length==0){
		alert("mail尚未輸入!!");
		fm1.mail.focus();
		return false;
	}
	
	if ( document.fm1.mail.value.length < 10) {
    		alert ("mail格式錯誤！");
    		document.fm1.mail.focus();
    		return false;
  	}
  	var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|tv|TV|tw|TW|in|IN)$"
	var re = new RegExp(regu);
	if (document.fm1.mail.value.search(re) == -1) {
		alert ("請輸入合法的mail ！");
		document.fm1.mail.focus();
		return false;
	}
	
	
	
	if (fm1.tel.value.length==0){
		alert("電話尚未輸入!");
		fm1.tel.focus();
		return false;
	}
		
	if ( document.fm1.tel.value.length > 30 || document.fm1.tel.value.length < 6) {
    		alert ("電話長度不能少於6個字！");
    		document.fm1.tel.focus();
    		return false;	
	}

	if (fm1.content.value.length==0){
		alert("內容尚未輸入!!");
		fm1.content.focus();
		return false;
	
	}
	fm1.type.value = "faq";
	fm1.action = "sub_result.php";
	fm1.method = "POST";
	fm1.submit();
	return false;
}		
function do_change(){
	if (document.fm1.password.value.length==0){
		alert("密碼尚未輸入!!");
		fm1.password.focus();
		return false;
	}
	if (document.fm1.password.value.length > 12 || document.fm1.password.value.length < 4) {
    		alert ("密碼長度不能超過12個字或少於4個字！");
    		document.fm1.password.focus();
    		return false;
  	}
  	if(document.fm1.password.value.match(/\W/)){
	   		alert("密碼不能含有特殊的字元，請重新輸入")
	   		document.fm1.password.focus()
	   		return false; 
	  }
	  if (document.fm1.re_password.value.length==0){
		alert("確認密碼尚未輸入!!");
		fm1.re_password.focus();
		return false;
	}
	
  	if ( document.fm1.password.value != document.fm1.re_password.value ) {
    		alert ("您的確認密碼不符");
    		document.fm1.re_password.focus();
    		return false;
    	}
    	fm1.type.value = "change";
	fm1.action = "sub_result.php";
	fm1.method = "POST";
	fm1.submit();
	return false;		
}


function do_forget(){
	if (document.fm1.forget_mail.value.length==0){
		alert("mail尚未輸入!!");
		fm1.forget_mail.focus();
		return false;
	}
	
	if ( document.fm1.forget_mail.value.length < 10) {
    		alert ("mail格式錯誤！");
    		document.fm1.forget_mail.focus();
    		return false;
  	}
  	var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT|tv|TV|tw|TW|in|IN)$"
	var re = new RegExp(regu);
	if (document.fm1.forget_mail.value.search(re) == -1) {
		alert ("請輸入合法的mail ！");
		document.fm1.forget_mail.focus();
		return false;
	}
	
	
	
	
	fm1.type.value = "forget";
	fm1.action = "sub_result.php";
	fm1.method = "POST";
	fm1.submit();
	return false;
}

function do_vgo()
{
  	if ( document.fm1.vgo.value == "" )
  	{
    		alert ("請輸入您想申請的v-go儲值碼");
    		document.fm1.vgo.focus();
    		return false;
  	}	
	
	
	var mem_value = fm1.vgo.value;
		
		for(var i=0; i<mem_value.length; i++)
		{
			if(mem_value.charAt(i)<'0' || mem_value.charAt(i)>'9')
			{
				alert("V-GO碼只能是數字");
				document.fm1.vgo.focus();
				return false;						
			}
						
		}	
	if (document.fm1.vgo.value.length !=7) 
	{
    		alert ("V-GO碼不能超過7個字或少於7個字！");
    		document.fm1.vgo.focus();
    		return false;
  	}	
	
	
	fm1.type.value = "vgo";
	fm1.action = "sub_result.php";
	fm1.method = "POST";
	fm1.submit();
	return false;
}