<!--
function Add_EPaper(fo){
	var cu=root + '/' + cs_add_epaper;
	if(!check_email(fo.el_email.value)){
		fo.el_email.focus();
		return;
	}
	ct='_new';
	cu=cu + "?el_email=" + fo.el_email.value;
	l=0; 
	t=0;
	w='1';
	h='1';
	rv=showDialog_0(cu, ct, l, t, w, h);
	fo.el_email.value='';
	//fo.submit();
}
function UpdateShopingBag(fo){
	fo.submit();
}
function UpdateReserveBag(fo){
	//list_form(fo);
	fo.submit();
}

function PurchaseOrderSubmit(fo){
	

	if(!check_radio(fo.po_pay_type, 3)){
		alert('請選擇付款方式');
		fo.po_pay_type[0].focus();
		return false
	}
	
	if(!ChkID(fo.mb_lid.value)){
		fo.mb_lid.focus();
		return false;
	}
	
	if(!check_string(fo.po_name.value, 1)){
		alert('請輸入收件人!!');
		fo.po_name.focus();
		return false;
	}
	
	if(!CheckBig5(fo.po_name.value) ){
		alert('收件人必需為中文!!');
		fo.po_name.focus();
		return false;
	}
	
	
	/*
	if(!check_phone_zone(fo.po_tel_zone.value)){
		fo.po_tel_zone.focus();
		return false;
	}
	
	if(!check_phone_number(fo.po_tel_number.value)){
		fo.po_tel_number.focus();
		return false;
	}
	*/
	
	
	if(!check_mobile(fo.po_mobile.value, 1)){
		fo.po_mobile.focus();
		return false;
	}
			
	if(!check_email(fo.po_email.value, 1)){
		fo.po_email.focus();
		return false;
	}		

	if(!check_string(fo.po_addr.value, 8)){
		alert('請輸入詳細地址，至少8個字!!');
		fo.po_addr.focus();
		return false;
	}	
	if(!check_radio(fo.po_invoice_type, 2)){
		alert('請選擇發票類型');
		fo.po_invoice_type[0].focus();
		return false
	}

	if(fo.po_invoice_type[0].checked){
		if(!check_string(fo.po_invoice_buyer.value, 1)){
			alert('請輸入買受人姓名!!');
			fo.po_invoice_buyer.focus();
			return false;
		}		
	}
	else
	{
		if(!check_bno(fo.po_invoice_bno.value)){
			fo.po_invoice_bno.focus();
			return false;
		}		
		if(!check_string(fo.po_invoice_title.value, 1)){
			alert('請輸入發票抬頭!!');
			fo.po_invoice_title.focus();
			return false;
		}		
	}

	//結合電話的區碼及號碼
	//fo.po_tel.value = fo.po_tel_zone.value + '-' + fo.po_tel_number.value;
	
	//alert(fo.action);
	fo.submit();
	return false;
}

function CheckUpdatePassword(fo){
	if(!check_string(fo.mb_pwd.value, 4)){
		alert('密碼至少需要4個字元');
		fo.mb_pwd.focus();
		return false;
	}
	else{
		if(fo.mb_pwd.value != fo.mb_pwd1.value){
			alert('密碼與確認密碼不相符，請重新輸入');
			fo.mb_pwd1.focus();
			return false;
		}
	}
	fo.submit();
	return false;
}


function CancelPO(obj){
	var fo = obj.form
	var confirmMsg="請問是否要取消此筆訂單?";
	if(confirmDelete(confirmMsg)) {
		obj.disabled=true;
		fo.submit();
	}
}
function login_submit(obj){
	if(!check_string(obj.us_acc.value, 1)){
		obj.us_acc.focus();
		alert('請輸入帳號!!');
		return false;
	}
	
	if(!check_string(obj.us_pwd.value, 1)){
		obj.us_pwd.focus();
		alert('請輸入密碼!!');
		return false;
	}
	//obj.next_url.value=window.location.href;
	obj.submit();
	
	return false;

}
function logout_submit(obj){
	obj.submit();
	return false;
}

function CheckMbAcc(fo){
	if(!check_string(fo.mb_acc.value, 4)){
		alert('帳號至少需要4個字元');
		fo.mb_acc.focus();
		return false;
	}
	if(fo.mb_acc.value.length >12){
		alert('帳號不能超過12個字元');
		fo.mb_acc.focus();
		return false;
	}	

	var cu= root + "/" + cs_member + '?Action=CheckMbAcc&mb_acc=' + fo.mb_acc.value;
	ct='_new';
	l=t=w=h=1;
	rv=showDialog_0(cu, ct, l, t, w, h);
	return false;
}



function mb_reg_1(fo){
	//return true;
	if(!check_string(fo.mb_acc.value, 4)){
		alert('帳號至少需要4個字元');
		fo.mb_acc.focus();
		return false;
	}
	if(fo.mb_acc.value.length >12){
		alert('帳號不能超過12個字元');
		fo.mb_acc.focus();
		return false;
	}	

	if(!check_string(fo.mb_pwd.value, 4)){
		alert('密碼至少需要4個字元');
		fo.mb_pwd.focus();
		return false;
	}
	else{
		if(fo.mb_pwd.value != fo.mb_pwd1.value){
			alert('密碼與確認密碼不相符，請重新輸入');
			fo.mb_pwd1.focus();
			return false;
		}
	}
	
	if(!check_email(fo.mb_email.value)){
		fo.mb_email.focus();
		return false;
	}
	
	fo.submit();
	return false;
}
function cm_refer(obj){
	if(cs_has_send==1){
		alert('傳送中，請稍候!!');
		return false;
	}
	if(!check_string(obj.cs_subject.value, 1)){
		obj.cs_subject.focus();
		alert('請輸入主旨!!');
		return false;
	}
	if(!check_string(obj.cs_from_name.value, 1)){
		obj.cs_from_name.focus();
		alert('請輸入寄件人名稱');
		return false;
	}
	if(!check_email(obj.cs_from_email.value)){
		obj.cs_from_email.focus();
		return false;
	}
		
	if(!check_email(obj.cs_to_email_1.value)){
		obj.cs_to_email_1.focus();
		return false;
	}
	
	cs_has_send=1;
	
	obj.submit();
	return false;
}

function mb_reg_2(fo){
	//return true;
	
	if(!ChkID(fo.mb_lid.value)){
		fo.mb_lid.focus();
		return false;
	}
	
	if(!check_string(fo.mb_name.value, 1)){
		alert('請輸入姓名!!');
		fo.mb_name.focus();
		return false;
	}
	if(!CheckBig5(fo.mb_name.value)){
		alert('姓名必需為中文(Name should be Chinese character)!!');
		fo.mb_name.focus();
		return false;
	}	

	if(!check_string(fo.mb_nick.value, 1)){
		alert('請輸入暱稱!!');
		fo.mb_name.focus();
		return false;
	}
		
	if(!check_radio(fo.mb_sex, 2)){
		alert('請選擇性別!!');
		fo.mb_sex.focus();
		return false;
	}


	if(!check_string(fo.mb_birth_yy.value, 1)){
		alert('請輸入出生年!!');
		fo.mb_birth_yy.focus();
		return false;
	}
	
	if(!check_string(fo.mb_birth_mm.value, 1)){
		alert('請輸入出生月!!');
		fo.mb_birth_mm.focus();
		return false;
	}
	
	if(!check_string(fo.mb_birth_dd.value, 1)){
		alert('請輸入出生日!!');
		fo.mb_birth_dd.focus();
		return false;
	}

	if(!check_string(fo.mb_addr.value, 6)){
		alert('請輸入詳細地址!!');
		fo.mb_addr.focus();
		return false;
	}

	if(!check_zipcode(fo.mb_zip.value)){
		return false;
	}

	if(!check_phone_zone(fo.mb_tel_zone.value)){
		fo.mb_tel_zone.focus();
		return false;
	}
	
	if(!check_phone_number(fo.mb_tel_number.value)){
		fo.mb_tel_number.focus();
		return false;
	}
	
	if(!check_mobile(fo.mb_mobile.value)){
		fo.mb_mobile.focus();
		return false;
	}
	
	
	//if(!check_string(fo.mb_friend_name.value, 1)){
	//	alert('請輸入對方姓名!!');
	//	fo.mb_friend_name.focus();
	//	return false;
	//}

	//if(!check_radio(fo.mb_friend_type, 4)){
	//	alert('請選擇關係!!');
	//	fo.mb_friend_type.focus();
	//	return false;
	//}

	//if(!check_email(fo.mb_friend_email.value)){
	//	fo.mb_friend_email.focus();
	//	return false;
	//}


 	if(!check_radio(fo.mb_get_info,6)){
 		fo.mb_get_info[0].focus();
 		alert('請選擇如何得知我們!!');
 		return false;
 	}
 	
 	if(get_obj_value('mb_get_info')==6){
 		if(fo.mb_get_info_text.value.length<1){
 			fo.mb_get_info_text.focus();
  			alert('請輸入說明!!');
 			return false;			
 		}
 	}else{
 		//fo.mb_get_info_text.value='';
 	}
		
	
	//結合電話的區碼及號碼
	fo.mb_tel.value = fo.mb_tel_zone.value + '-' + fo.mb_tel_number.value;
	
	//submit
	fo.submit();
	return false;
}

function mb_upd(fo){
	//return true;
	
	

	//if(!ChkID(fo.mb_lid.value)){
	//	fo.mb_lid.focus();
	//	return false;
	//}

	if(!check_string(fo.mb_pwd.value, 4)){
		alert('密碼至少需要4個字元');
		fo.mb_pwd.focus();
		return false;
	}
	else{
		if(fo.mb_pwd.value != fo.mb_pwd1.value){
			alert('密碼與確認密碼不相符，請重新輸入');
			fo.mb_pwd1.focus();
			return false;
		}
	}
	
	if(!check_email(fo.mb_email.value)){
		fo.mb_email.focus();
		return false;
	}
		
		
	//if(!check_string(fo.mb_name.value, 1)){
	//	alert('請輸入姓名!!');
	//	fo.mb_name.focus();
	//	return false;
	//}
	
	if(!check_string(fo.mb_nick.value, 1)){
		alert('請輸入暱稱!!');
		fo.mb_nick.focus();
		return false;
	}	
	if(!check_radio(fo.mb_sex, 2)){
		alert('請選擇性別!!');
		fo.mb_sex.focus();
		return false;
	}


	if(!check_string(fo.mb_birth_yy.value, 1)){
		alert('請輸入出生年!!');
		fo.mb_birth_yy.focus();
		return false;
	}
	
	if(!check_string(fo.mb_birth_mm.value, 1)){
		alert('請輸入出生月!!');
		fo.mb_birth_mm.focus();
		return false;
	}
	
	if(!check_string(fo.mb_birth_dd.value, 1)){
		alert('請輸入出生日!!');
		fo.mb_birth_dd.focus();
		return false;
	}

	if(!check_string(fo.mb_addr.value, 6)){
		alert('請輸入詳細地址!!');
		fo.mb_addr.focus();
		return false;
	}

	if(!check_zipcode(fo.mb_zip.value)){
		return false;
	}
	

	if(!check_phone_zone(fo.mb_tel_zone.value)){
		fo.mb_tel_zone.focus();
		return false;
	}
	
	if(!check_phone_number(fo.mb_tel_number.value)){
		fo.mb_tel_number.focus();
		return false;
	}
	
	if(!check_mobile(fo.mb_mobile.value)){
		fo.mb_mobile.focus();
		return false;
	}


	
	//if(!check_string(fo.mb_friend_name.value, 1)){
	//	alert('請輸入對方姓名!!');
	//	fo.mb_friend_name.focus();
	//	return false;
	//}

	//if(!check_radio(fo.mb_friend_type, 4)){
	//	alert('請選擇關係!!');
	//	fo.mb_friend_type.focus();
	//	return false;
	//}

	//if(!check_email(fo.mb_friend_email.value)){
	//	fo.mb_friend_email.focus();
	//	return false;
	//}

 	if(!check_radio(fo.mb_get_info,6)){
 		fo.mb_get_info[0].focus();
 		alert('請選擇如何得知我們!!');
 		return false;
 	}
 	

 	if(get_obj_value('mb_get_info')==6){
 		if(fo.mb_get_info_text.value.length<1){
 			fo.mb_get_info_text.focus();
  			alert('請輸入說明!!');
 			return false;			
 		}
 	}else{
 		//fo.mb_get_info_text.value='';
 	}
	
	//結合電話的區碼及號碼
	fo.mb_tel.value = fo.mb_tel_zone.value + '-' + fo.mb_tel_number.value;
	
	//submit
	fo.submit();
	return false;
}
function check_member(fo){
	//return true;

	if(!check_string(fo.mb_name.value, 1)){
		alert('請輸入姓名!!');
		fo.mb_name.focus();
		return false;
	}
	
	if(!CheckBig5(fo.mb_name.value)){
		alert('姓名必需為中文,否則收貨會有問題!!');
		fo.mb_name.focus();
		return false;
	}
		
	
	if(!check_radio(fo.mb_sex, 2)){
		alert('請選擇性別!!');
		fo.mb_sex.focus();
		return false;
	}

	if(!check_string(fo.mb_acc.value, 4)){
		alert('帳號至少需要4個字元');
		fo.mb_acc.focus();
		return false;
	}

	if(!check_lid(fo.mb_lid.value)){
		fo.mb_lid.focus();
		return false;
	}
	
	if(!check_string(fo.mb_pwd.value, 4)){
		alert('密碼至少需要4個字元');
		fo.mb_pwd.focus();
		return false;
	}
	else{
		if(fo.mb_pwd.value != fo.mb_pwd1.value){
			alert('密碼與確認密碼不相符，請重新輸入');
			fo.mb_pwd1.focus();
			return false;
		}
	}

	
	if(!check_string(fo.mb_birth_yy.value, 1)){
		alert('請輸入出生年!!');
		fo.mb_birth_yy.focus();
		return false;
	}
	
	if(!check_string(fo.mb_birth_mm.value, 1)){
		alert('請輸入出生月!!');
		fo.mb_birth_mm.focus();
		return false;
	}
	
	if(!check_string(fo.mb_birth_dd.value, 1)){
		alert('請輸入出生日!!');
		fo.mb_birth_dd.focus();
		return false;
	}
	
	if(!check_string(fo.mb_addr.value, 8)){
		alert('請輸入詳細地址!!');
		fo.mb_addr.focus();
		return false;
	}


	if(!check_mobile(fo.mb_mobile.value)){
		fo.mb_mobile.focus();
		return false;
	}
	
	if(!check_email(fo.mb_email.value)){
		fo.mb_email.focus();
		return false;
	}

	
	return true;
}




function check_choice(obj, num){
	f=0;
	for(i=0;i<num;i++) {
		if(obj[i].checked ){
			f=1;
			break;
		}
	}
	
	if(f==0){
		obj[0].focus();
		alert('請選擇!!');
		obj[0].focus();
		return false;
	}
	else
		return true;
}


function ev_step2_check(fo){
	//list_form(fo);
		if(!check_choice(fo.q1, 5)) return false;
		if(!check_choice(fo.q2, 5)) return false;
		if(!check_choice(fo.q3, 5)) return false;
		if(!check_choice(fo.q4, 5)) return false;
		if(!check_choice(fo.q5, 5)) return false;

	fo.submit();
}


function change_ymd(obj){
  var obj_name=obj.name;
  var obj_date=obj_name.substring(0,obj_name.length-3);
  var yy=document.all[obj_date+'_yy'].value;
  var mm=document.all[obj_date+'_mm'].value;
  var dd=document.all[obj_date+'_dd'].value
  var val_date= yy +"-"+mm+"-"+dd;
  
  document.all[obj_date].value=val_date;	
  var chk_flag=check_date(val_date);
  if (true!=chk_flag){
     var err_msg="Invalid Date: "+ val_date +"\r";	
     val_date=document.all[obj_date+'_yy'].value + "-" + document.all[obj_date+'_mm'].value + "-" + chk_flag;
     //alert(err_msg + "It will be changed to " + val_date+".") ;
     document.all[obj_date+'_dd'].value=chk_flag;
     document.all[obj_date].value=val_date;	
  }
}
function check_date(strDate){
    var nYear;
    var nMonth;
    var nDay;
    var nFact;
    var arrDay = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    // 
    nYear = eval (strDate.substring (0, 4));
    nMonth = eval (strDate.substring (5, 7));
    nDay = eval (strDate.substring (8, 10));
    nFact = arrDay[nMonth - 1];
    if (nMonth == 2)
    {
        if ((nYear % 4 == 0 && nYear %100 != 0) || (nYear % 400 == 0))
            nFact ++;
    }
    if (nDay > nFact)
        return (nFact);
    return (true);	  
}

function MemberForgetPwdSubmit(fo){
	
	if(!ChkID(fo.mb_lid.value)){
		fo.mb_lid.focus();
		return false;
	}
		
	if(!check_email(fo.mb_email.value)){
		fo.mb_email.focus();
		return false;
	}
	fo.submit();
}

function message_reply(obj){
	if(!login_check()){
		alert("閒置時間過長，請重新登入!!");
		return false;
	}
		
	/*
	if(!check_string(obj.bm_msg.value, 0)){
		obj.bm_msg.focus();
		alert('請輸入文章內容');
		return false;
	}
	*/
	
	obj.Action.value=obj.Action.value + 'Do';
	
	
	ta_submit();
	return false;
}
function message_new(obj){
	//list_form(obj);
	if(!login_check()){
		alert("閒置時間過長，請重新登入!!");
		return false;
	}
	
	if(!check_string(obj.bs_subj.value, 1)){
		obj.bs_subj.focus();
		alert('請輸入主題!!');
		return false;
	}
	
	/*
	if(!check_string(obj.bm_msg.value, 0)){
		obj.bm_msg.focus();
		alert('請輸入文章內容');
		return false;
	}
	*/
	
	obj.Action.value=obj.Action.value + 'Do';
	
	ta_submit();
	return false;
}
function message_reply_ajax(rc){
	//alert("message_reply:rc=" + rc);
	if(rc != '1'){
		alert("閒置時間過長，請重新登入!!");
		return false;
	}
	
	obj=window.form1;
	/*
	if(!check_string(obj.bm_msg.value, 0)){
		obj.bm_msg.focus();
		alert('請輸入文章內容');
		return false;
	}
	*/
	
	obj.Action.value=obj.Action.value + 'Do';
	
	
	ta_submit();
	return false;
}
function message_new_ajax(rc){
	//alert("message_new:rc=" + rc);
	if(rc != '1'){
		alert("閒置時間過長，請重新登入!!");
		return false;
	}
		
	obj=document.form1;
	if(!check_string(obj.bs_subj.value, 1)){
		obj.bs_subj.focus();
		alert('請輸入主題!!');
		return false;
	}

	obj.Action.value=obj.Action.value + 'Do';
	ta_submit();
}

function ta_submit(){
	// document.edit.save.value = "yes";
	document.form1.onsubmit(); // workaround browser bugs.
	document.form1.submit();
}

function SearchBoard(fo){
	//alert(fo.name);
	fo.submit();
}

function ShowPersonalInfo(link){
	window.location.href=link;
	return false;
	//return showDialog(link, 'ShowPersonalInfo', 400, 100, '480px', '480px');
}
function ListMsgDetail(bs_id){
	var link=root +"/cs_board/board.php?Action=MessageList&bs_id=" + bs_id;
	window.location.href=link;
	return false;
	//return showDialog(link, 'ShowPersonalInfo', 400, 100, '480px', '480px');
}
function ShowProductStory(link){
	showDialog(link, 'ShowProductStory', 10, 10, '900px', '700px');
	return false;
}
function ShowProductBigImg(link){
	showDialog(link, 'ShowProductBigImg', 400, 100, '450px', '400px');
	return false;
}

function ContactUsCheck(fo){
	if(!check_string(fo.cs_name.value, 1)){
		alert('請輸入姓名!!');
		fo.cs_name.focus();
		return false;
	}
	
	if(!check_radio(fo.cs_sex, 2)){
		alert('請選擇性別!!');
		fo.cs_sex.focus();
		return false;
	}

	if(!check_phone_zone(fo.cs_phone_zone.value)){
		fo.cs_phone_zone.focus();
		return false;
	}
	
	if(!check_phone_number(fo.cs_phone_number.value)){
		fo.cs_phone_number.focus();
		return false;
	}

	if(!check_mobile(fo.cs_mobile.value)){
		fo.cs_mobile.focus();
		return false;
	}
	
	if(!check_email(fo.cs_email.value)){
		fo.cs_email.focus();
		return false;
	}
	
	if(!check_string(fo.cs_content.value, 10)){
		alert('請輸入詳細的問題內容!!');
		fo.cs_content.focus();
		return false;
	}
	
	fo.cs_phone.value = fo.cs_phone_zone.value + '-' + fo.cs_phone_number.value;
	fo.submit();
	return false;
}

function AllianceCheck(fo){
	if(!check_string(fo.cs_company.value, 1)){
		alert('請輸入廠商名稱!!');
		fo.cs_company.focus();
		return false;
	}
	if(!check_string(fo.cs_keyman.value, 1)){
		alert('請輸入聯絡人!!');
		fo.cs_keyman.focus();
		return false;
	}	
	if(!check_radio(fo.cs_sex, 2)){
		alert('請選擇性別!!');
		fo.cs_sex.focus();
		return false;
	}

	if(!check_phone_zone(fo.cs_phone_zone.value)){
		fo.cs_phone_zone.focus();
		return false;
	}
	
	if(!check_phone_number(fo.cs_phone_number.value)){
		fo.cs_phone_number.focus();
		return false;
	}

	if(!check_mobile(fo.cs_mobile.value)){
		fo.cs_mobile.focus();
		return false;
	}
	
	if(!check_email(fo.cs_email.value)){
		fo.cs_email.focus();
		return false;
	}
	
	if(!check_string(fo.cs_content.value, 10)){
		alert('請輸入詳細的問題內容!!');
		fo.cs_content.focus();
		return false;
	}
	
	fo.cs_phone.value = fo.cs_phone_zone.value + '-' + fo.cs_phone_number.value;
	fo.submit();
	return false;
}
function mb2po(fo){
	fo.po_name.value	= fo.mb_name.value;
	fo.po_tel.value		= fo.mb_tel.value;
	fo.po_mobile.value	= fo.mb_mobile.value;
	fo.po_email.value	= fo.mb_email.value;
	fo.po_addr.value	= fo.mb_addr.value;
	fo.po_zip.value		= fo.mb_zip.value;
	
}
function SumitConsult(fo){
	if(!check_string(fo.mb_acc.value, 1)){
		alert('請輸入您的帳號!!');
		fo.mb_acc.focus();
		return false;
	}
	
	if(!check_email(fo.email.value)){
		fo.email.focus();
		return false;
	}
	
	if(!check_string(fo.content.value, 10)){
		alert('請詳述您的諮詢問題!!');
		fo.content.focus();
		return false;
	}
	fo.submit();
	
	
	//clean data;
	fo.mb_acc.value="";
	fo.email.value="";
	fo.content.value="";

	return false;
}
// --> 
