function memberRegisterPage(theform){
	error = "";
	is_number=true;		
		
	if (isblank(theform.email.value)) {		
		error += "請輸入電郵<br>";
	}
	if (!isblank(theform.email.value)) {
		str = theform.email.value;
		pos = str.indexOf(".") 
		pos2 = str.indexOf("@") 
		if (pos <= 0 || pos2 <= 0) {
			error += "請輸入正確的電郵<br>";
		}
	}

	if (isblank(theform.password.value)) {		
		error += "請輸入密碼<br>";
	}
	if (!isblank(theform.password.value)) {		
		if (theform.password.value.length < 6 || theform.password.value.length>10) {		
			error += "密碼必須超過6個位，但不可超過10個位<br>";
		}
	}
	
	if (!isWord(theform.password.value)) {		
		error += "密碼只可由英文字母及/或數字組成<br>";
	}

	if (theform.password.value!=theform.confirm_password.value) {		
		error += "請重新輸入確認密碼<br>";
	}
	if (theform.tnc.checked == false) {
		error += "請先閱讀並同意登記條款及私隱聲明<br>";
	}
	
	if (error) {        
		outError  = '<table width="500" border="0" align="center">';
		outError += '	<tr>';
		outError += '		<td class="errfont">';
		outError += '			<font color="red">' + error + '</font>';
		outError += '		</td>';
		outError += '	</tr>';
		outError += '</table>';
		document.getElementById('ermsg').innerHTML = outError;
		document.location = "#err";
		return false;               
	}	else {	
		return true;
  }
}

function memberRegisterPage1(theform, type){
	error = "";
	is_number=true;
	
	if (type == 2)
	{
		if (!isblank(theform.password.value) && isblank(theform.oldpassword.value)) {
			error += "請輸入舊密碼<br>";
		}
		if (!isblank(theform.oldpassword.value) && isblank(theform.password.value)) {
			error += "請輸入新密碼<br>";
		}
		if (!isWord(theform.password.value)) {		
			error += "密碼只可由英文字母及/或數字組成<br>";
		}
		if (!isblank(theform.password.value) && (theform.password.value.length<6 || theform.password.value.length>10)) {		
			error += "密碼必須超過6個位，但不可超過10個位<br>";
		}	     
	}
		
	if (!isChecked(theform.title)) {		
		error += "請選擇稱號<br>";
	}
	
	if (isblank(theform.firstname.value)) {		
		error += "請輸入名字<br>";
	}
	
	if (isblank(theform.lastname.value)) {		
		error += "請輸入姓氏<br>";
	}

	if (!isChecked(theform.gender)) {		
		error += "請選擇性別<br>";
	}
		
	if (!isDateValid(theform.b_yy.value, theform.b_mm.value, theform.b_dd.value)) {		
		error += "出生日期的"+ theform.b_mm.value + "月份只有" + getDateByMonth(theform.b_yy.value, theform.b_mm.value) + "日<br>";
	}	
/*
//	if (isblank(theform.phone.value)) {		
//		error += "請填寫聯絡電話<br>";
//	}
//	else {
//		if (isNaN(theform.phone.value)) {
//			error += "請填寫數字於聯絡電話<br>";
//		}
//	}
*/	
	if (isblank(theform.phone_home.value) && isblank(theform.phone_mobile.value) && isblank(theform.phone_office.value)){
		error += "請填寫數字於聯絡電話<br>";
	}
	if (!isblank(theform.phone_home.value)) {
		if (isNaN(theform.phone_home.value)) {
			error += "請填寫數字於住宅聯絡電話<br>";
		}
	}
	if (!isblank(theform.phone_mobile.value)) {
		if (isNaN(theform.phone_mobile.value)) {
			error += "請填寫數字於流動電話聯絡電話<br>";
		}
	}
	if (!isblank(theform.phone_office.value)) {
		if (isNaN(theform.phone_office.value)) {
			error += "請填寫數字於辦公室聯絡電話<br>";
		}
	}		
	if (isblank(theform.address.value)) {		
		error += "請輸入居住地址<br>";
	}			

	if (theform.edu_level[0].selected) {		
		error += "請選擇教育程度<br>";
	}
			
	if (theform.work_exp[0].selected) {		
		error += "請選擇工作經驗<br>";
	}
	
	if (theform.isParent.checked == true) {
		/*** check child birth dates block ***/
		if (!theform.child_birth_dt_dd[0].selected || !theform.child_birth_dt_mm[0].selected || !theform.child_birth_dt_yy[0].selected) {
			if (theform.child_birth_dt_dd[0].selected || theform.child_birth_dt_mm[0].selected || theform.child_birth_dt_yy[0].selected)
				error += "孩子一出生日期不正確<br>";		
		}
		if (!theform.child_birth_dt_dd2[0].selected || !theform.child_birth_dt_mm2[0].selected || !theform.child_birth_dt_yy2[0].selected) {
			if (theform.child_birth_dt_dd2[0].selected || theform.child_birth_dt_mm2[0].selected || theform.child_birth_dt_yy2[0].selected)
				error += "孩子二出生日期不正確<br>";		
		}
		if (!theform.child_birth_dt_dd3[0].selected || !theform.child_birth_dt_mm3[0].selected || !theform.child_birth_dt_yy3[0].selected) {
			if (theform.child_birth_dt_dd3[0].selected || theform.child_birth_dt_mm3[0].selected || theform.child_birth_dt_yy3[0].selected)
				error += "孩子三出生日期不正確<br>";		
		}
	} 
	/*
	if (!isblank(theform.couple_email.value)) {
		str = theform.couple_email.value;
		pos = str.indexOf(".") 
		pos2 = str.indexOf("@") 
		if (pos <= 0 || pos2 <= 0) {
			error += "請輸入你的另一半的正確的電郵<br>";
		}
		if (theform.couple_email.value.length<6 || theform.couple_email.value.length>100 ) {		
			error += "你的另一半的電郵必須超過6個位，但不可超過100個位<br>";
		}
	}
	*/
	if (isblank(theform.alias.value)) {		
		error += "請填寫別名<br>";
	}

	if (!isblank(theform.alias.value)) {	
		if (theform.alias.value.length>15) {	
			error += "別名不可超過15個位<br>";
		}
	}
		
//	if (theform.industry[0].selected) {		
//		error += "請選擇工作行業<br>";
//	}
			
	if (!isChecked(theform.course_promote)) {		
		error += "請選擇'登記「精選課程速遞」免費電郵服務<br>";
	}

	var isEduChecked = false;
	for (checked_req_edu = 0; checked_req_edu < theform.require_edu_level.length; checked_req_edu++){
	if (theform.require_edu_level[checked_req_edu].checked) {
		isEduChecked = true;
		break;
		}
	}

	var isIntChecked = false;
	for (checked_int_course = 0; checked_int_course < theform.interest_course.length; checked_int_course++){
	if (theform.interest_course[checked_int_course].checked) {
		isIntChecked = true;
		break;
		}
	}

	//if (theform.course_promote[0].checked && (theform.require_edu_level1[0].selected && theform.interest_course1[0].selected && theform.require_edu_level2[0].selected && theform.interest_course2[0].selected && theform.require_edu_level3[0].selected && theform.interest_course3[0].selected) )  {		
	if (theform.course_promote[0].checked && (!isEduChecked && !isIntChecked) )  {			
		error += "請選擇您感興趣的課程<br>";
	}
	//if (theform.course_promote[0].checked && (theform.require_edu_level1[0].selected && theform.interest_course1[0].selected && theform.require_edu_level2[0].selected && theform.interest_course2[0].selected && theform.require_edu_level3[0].selected && theform.interest_course3[0].selected) )  {		
	//if (theform.course_promote[0].checked && (theform.require_edu_level[0].checked && theform.interest_course[0].checked) )  {		
	//	error += "請選擇您感興趣的課程<br>";
	//}
/*	
	if (type == 1) { 
		if (!isChecked(theform.is_jm_member)) {		
			error += "請選擇是否JobMarket會員";
		}	

		if (theform.is_jm_member[0].checked && isblank(theform.jm_login.value)) {		
			error += "請填寫閣下之JobMarket登入名稱<br>";
		}	

		if (theform.is_jm_member[0].checked && isblank(theform.jm_password.value)) {		
			error += "請填寫閣下之JobMarket登入密碼<br>";
		}	
		
		if (theform.join_jm.checked && theform.is_jm_member[0].checked) {
			error += "你已經登記成為JobMarket會員了，請不用選擇 '同時登記成為《求職廣場》會員' ";
		}		
	}
*/
	
	if (error) {        
		outError  = '<table width="500" border="0" align="center">';
		outError += ' <tr>';
		outError += '		<td class="errfont">';
		outError += '			<font color="red">' + error + '</font>';
		outError += '		</td>';
		outError += '	</tr>';
		outError += '</table>';
		document.getElementById('ermsg').innerHTML = outError;
		document.location = "#err";
		return false;               
	}	else {	
		return true;
  }
}
function memberRegisterPage2(theform){
	error = "";
	is_number=true;	
		
	var reg_site = theform.reg_site.value
	reg_site = reg_site.replace(/[\s]*$/gi,"");
	reg_site = reg_site.replace(/^[\s]*/gi,"");

	if (reg_site == 'JM') {

		if (isblank(theform.password_jm.value)) {		
			error += "請輸入密碼<br>";
		}
		if (isblank(theform.password_jm_confirm.value)) {		
			error += "請輸入確認密碼<br>";
		} 
	
		if (theform.password_jm.value!=theform.password_jm_confirm.value) {		
			error += "請重新輸入確認密碼<br>";
		}
	} else {

		if (isblank(theform.password_hlj.value)) {		
			error += "請輸入密碼<br>";
		}
		if (isblank(theform.password_hlj_confirm.value)) {		
			error += "請輸入確認密碼<br>";
		} 
	
		if (theform.password_hlj.value!=theform.password_hlj_confirm.value) {		
			error += "請重新輸入確認密碼<br>";
		}	
	}
	if (error) {        
		outError  = '<table width="500" border="0" align="center">';
		outError += '	<tr>';
		outError += '		<td class="errfont">';
		outError += '			<font color="red">' + error + '</font>';
		outError += '		</td>';
		outError += '	</tr>';
		outError += '</table>';
		document.getElementById('ermsg').innerHTML = outError;
		document.location = "#err";
		return false;               
	} else {	
		return true;
  }
}
function checkformmessage()
{
	
	var error="N";
		if(document.postform.title.value =="")
		{
			error = "Y";
			alert("請輸入你的主題");
			return false;
		}
	if(document.postform.body.value=="")
	{
		error = "Y";
		alert("請輸入你的內容");
		return false;
	}
	if (error == "N") {
		if(!confirm("確定刊登?"))
		{
			return false;
		}
	}
	else 
		return false;

	return true;

}

function ValidAppform(theform)
{
  var error = "N";
  var err = "";
  
	if (theform.fax.value != "" || (theform.contact_method[2].checked && (theform.fax.value == "")))
	{
		if (isNaN(theform.fax.value) || theform.fax.value == "") {
			error = "Y";
			err += "請填寫數字於傳真號碼\n";
			theform.fax.focus();
		}
	}
	
	// 0 - 電話, 1 - 電郵, 2 - 圖文傳真, 3 - 郵遞	
	if (!(theform.contact_method[0].checked|| theform.contact_method[1].checked || theform.contact_method[2].checked || theform.contact_method[3].checked))
	{
		error = "Y";
		err += "請選擇聯絡方法\n";
		theform.contact_method[0].focus();
	}
	if(theform.contact_method[3].checked && theform.address.value == "")
	{
		error = "Y";
		err += "請填寫數字於地址\n";
		theform.address.focus();
	}

	if (error == "N") {
		 theform.submit();
    }
  else
  {
  	alert(err);
  	return false;
	}
}

function confirmAppForm()
{
	if(confirm("是否確認你的個人資料?"))
		return true;
	else
		return false;
}
