function checkExisted() {
	var fobj = document.frmRegister;	
	if ( fobj.f_account.value == "" ) {
		alert("帳號請勿空白！");
		fobj.f_account.focus();
		return;
	}
	var formparameters = "account=" + fobj.f_account.value;
	var myAjax = new Ajax.Request(
		'/member/check_account.jsp',
		{
			method: 'post',
			parameters: formparameters,
			onComplete: function(transport) {
				if ( Trim(transport.responseText) != "" ) {
					alert( transport.responseText );
				}
			}
		}
	);
}

function checkEmailExisted() {
	var fobj = document.frmRegister;	
	if ( fobj.f_email.value == "" ) {
		alert("E-mail 不可空白！");
		fobj.f_email.focus();
		return;
	}
	var formparameters = "email=" + fobj.f_email.value;
	var myAjax = new Ajax.Request(
		'/member/check_email.jsp',
		{
			method: 'post',
			parameters: formparameters,
			onComplete: function(transport) {
				if ( Trim(transport.responseText) != "" ) {
					alert(transport.responseText);
				}
			}
		}
	);
}

function formValid() {
	var fobj = document.frmRegister;	
	if(fobj.f_account.value == "") {
		alert("帳號請勿空白！");
		fobj.f_account.focus();
		return false;
	}
	if(fobj.f_account.value.length < 6) {
		alert("帳號請勿少於 6 個字！");
		fobj.f_password.focus();
		return false;
	}
	if(fobj.f_password.value == "") {
		alert("密碼請勿空白！");
		fobj.f_password.focus();
		return false;
	}
	if(fobj.f_password.value.length < 6) {
		alert("密碼請勿少於 6 個字！");
		fobj.f_password.focus();
		return false;
	}
	if(fobj.f_re_password.value == "") {
		alert("確認密碼請勿空白！");
		fobj.f_re_password.focus();
		return false;
	}
	if( fobj.f_password.value != fobj.f_re_password.value ) {
		alert("密碼與確認密碼必須一模一樣！");
		fobj.f_password.focus();
		return false;
	}	
	if(fobj.f_email.value == "") {
		alert("email不可空白！");
		fobj.f_email.focus();
		return false;
	}

	if ( valudData() != true ) return;

	if(fobj.f_AUTH_KEY.value == "") {
		alert("檢核確認碼請勿空白！");
		fobj.f_AUTH_KEY.focus();
		return false;
	}
	if ( fobj.f_confirm.checked != true ) {
		alert("請先點選閱讀會員服務條款！");
		return;
	}
	var objForm = document.getElementById("frmRegister");
	var formparameters = Form.serialize(objForm);
	var myAjax = new Ajax.Request(
		'/act_center/do_act_add.jsp',
		{
			method: 'post',
			parameters: formparameters,
			onComplete: showMsg
		}
	);
}

function showMsg(originalRequest) {
	var member_area = document.getElementById("member_field");
	if ( member_area == null ) alert(originalRequest.responseText);
	else {
		member_area.innerHTML = originalRequest.responseText;
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function valudData() {
	var fobj = document.frmRegister;	
	if(fobj.f_name.value == "") {
		alert("姓名請勿空白！");
		fobj.f_name.focus();
		return false;
	}
	if(fobj.f_nickname.value == "") {
		alert("暱稱請勿空白！");
		fobj.f_nickname.focus();
		return false;
	}
	if (checkEmail( fobj.f_email.value ) != true ) {
		fobj.f_email.focus();
		return false;
	}
	if(fobj.f_phone.value == "") {
		alert("聯絡電話請勿空白！");
		fobj.f_phone.focus();
		return false;
	}

	if( fobj.f_company != null ) {
		if ( fobj.f_company.value == "") {
			alert("公司請勿空白！");
			fobj.f_company.focus();
			return false;
		}
	}

	if( fobj.f_en_name != null ) {
		if ( fobj.f_en_name.value == "") {
			alert("英文姓名請勿空白！");
			fobj.f_en_name.focus();
			return false;
		}
	}

	if( fobj.f_phone2 != null ) {
		if ( fobj.f_phone2.value == "") {
			alert("聯絡電話 2請勿空白！");
			fobj.f_phone2.focus();
			return false;
		}
	}

	if( fobj.f_id_number != null ) {
		if ( fobj.f_id_number.value == "") {
			alert("身分證字號請勿空白！");
			fobj.f_id_number.focus();
			return false;
		}
	}

	if( fobj.f_birthday != null ) {
		if ( setDate(fobj.f_birthday,"birthday") != true ) {
			alert( "生日日期格式錯誤 !" );
			return false;
		}
	}

	if( fobj.f_children != null ) {
		if ( fobj.f_children.value == "") {
			alert("子女數請勿空白！");
			fobj.f_children.focus();
			return false;
		}
	}

	if( fobj.f_department != null ) {
		if ( fobj.f_department.value == "") {
			alert("單位部門請勿空白！");
			fobj.f_department.focus();
			return false;
		}
	}

	if( fobj.f_position != null ) {
		if ( fobj.f_position.value == "") {
			alert("職稱請勿空白！");
			fobj.f_position.focus();
			return false;
		}
	}

	if( fobj.f_contact_man != null ) {
		if ( fobj.f_contact_man.value == "") {
			alert("公司連絡人請勿空白！");
			fobj.f_contact_man.focus();
			return false;
		}
	}

	if( fobj.f_company_tel != null ) {
		if ( fobj.f_company_tel.value == "") {
			alert("公司電話號碼請勿空白！");
			fobj.f_company_tel.focus();
			return false;
		}
	}

	if( fobj.f_company_fex != null ) {
		if ( fobj.f_company_fex.value == "") {
			alert("公司傳真號碼請勿空白！");
			fobj.f_company_fex.focus();
			return false;
		}
	}

	if( fobj.f_cellphone != null ) {
		if ( fobj.f_cellphone.value == "") {
			alert("連絡人手機請勿空白！");
			fobj.f_cellphone.focus();
			return false;
		}
	}

	if( fobj.f_company_email != null ) {
		if ( fobj.f_company_email.value == "") {
			alert("公司 email請勿空白！");
			fobj.f_company_email.focus();
			return false;
		}
	}

	if( fobj.f_company_city != null ) {
		if ( fobj.f_company_city.value == "") {
			alert("公司所在城市請勿空白！");
			fobj.f_company_city.focus();
			return false;
		}
	}

	if( fobj.f_company_addr != null ) {
		if ( fobj.f_company_addr.value == "") {
			alert("公司地址請勿空白！");
			fobj.f_company_addr.focus();
			return false;
		}
	}

	if( fobj.f_industry != null ) {
		if ( fobj.f_industry.value == "") {
			alert("公司產業別請勿空白！");
			fobj.f_industry.focus();
			return false;
		}
	}

	if( fobj.f_ubl_number != null ) {
		if ( fobj.f_ubl_number.value == "") {
			alert("公司統編請勿空白！");
			fobj.f_ubl_number.focus();
			return false;
		}
	}

	if( fobj.f_city != null ) {
		if ( fobj.f_city.options[fobj.f_city.selectedIndex].value == "") {
			alert("請選擇縣市！");
			fobj.f_city.focus();
			return false;
		}
	}
	if( fobj.f_town != null ) {
		if ( fobj.f_town.options[fobj.f_town.selectedIndex].value == "") {
			alert("請選擇鄉鎮市區！");
			fobj.f_town.focus();
			return false;
		}
	}
	if( fobj.f_zip_code != null ) {
		if ( fobj.f_zip_code.value == "") {
			alert("郵遞區號請勿空白！");
			fobj.f_zip_code.focus();
			return false;
		}
	}
	if( fobj.f_address != null ) {
		if ( fobj.f_address.value == "") {
			alert("街道/門牌請勿空白！");
			fobj.f_address.focus();
			return false;
		}
	}

	if( fobj.f_reg_city != null ) {
		if ( fobj.f_reg_city.options[fobj.f_reg_city.selectedIndex].value == "") {
			alert("請選擇縣市！");
			fobj.f_reg_city.focus();
			return false;
		}
	}
	if( fobj.f_reg_town != null ) {
		if ( fobj.f_reg_town.options[fobj.f_reg_town.selectedIndex].value == "") {
			alert("請選擇鄉鎮市區！");
			fobj.f_reg_town.focus();
			return false;
		}
	}
	if( fobj.f_reg_zip_code != null ) {
		if ( fobj.f_reg_zip_code.value == "") {
			alert("郵遞區號請勿空白！");
			fobj.f_reg_zip_code.focus();
			return false;
		}
	}
	if( fobj.f_register_addr != null ) {
		if ( fobj.f_register_addr.value == "") {
			alert("街道/門牌請勿空白！");
			fobj.f_register_addr.focus();
			return false;
		}
	}
	
	if ( fobj.f_education != null ) {
		if ( fobj.f_education.options[fobj.f_education.selectedIndex].value == null 
	 		|| fobj.f_education.options[fobj.f_education.selectedIndex].value == "" 
	 		|| fobj.f_education.options[fobj.f_education.selectedIndex].value == "0") {
			alert("請選擇您的教育程度！");
			fobj.f_education.focus();
			return false;
		}
	}
	if ( fobj.f_income != null ) {
	 	if ( fobj.f_income.options[fobj.f_income.selectedIndex].value == null 
	 		|| fobj.f_income.options[fobj.f_income.selectedIndex].value == "" 
	 		|| fobj.f_income.options[fobj.f_income.selectedIndex].value == "0") {
			alert("請選擇您的年收入！");
			fobj.f_income.focus();
			return false;
		}
	}
	if ( fobj.f_job_level != null ) {
	 	if ( fobj.f_job_level.options[fobj.f_job_level.selectedIndex].value == null 
	 		|| fobj.f_job_level.options[fobj.f_job_level.selectedIndex].value == "" 
	 		|| fobj.f_job_level.options[fobj.f_job_level.selectedIndex].value == "0") {
			alert("請選擇您的職務！");
			fobj.f_job_level.focus();
			return false;
		}
	}
	if ( fobj.f_job != null ) {
	 	if ( fobj.f_job.options[fobj.f_job.selectedIndex].value == null 
	 		|| fobj.f_job.options[fobj.f_job.selectedIndex].value == "" 
	 		|| fobj.f_job.options[fobj.f_job.selectedIndex].value == "0") {
			alert("請選擇您的職業別！");
			fobj.f_job.focus();
			return false;
		}
	}
	return true;
}

function updateFormValid() {
	var fobj = document.frmRegister;	
	
	if ( valudData() != true ) return;

	var objForm = document.getElementById("frmRegister");
	var formparameters = Form.serialize(objForm);
	var myAjax = new Ajax.Request(
		'/act_center/do_member_update.jsp',
		{
			method: 'post',
			parameters: formparameters,
			onComplete: showMsg
		}
	);
}
