/*'*****************************************************************************
*【システム名  】WTC JAPAN 貿易引合掲示板
*【プログラムID】
*【画面名】
*【概 要】 各プログラムでの共通処理JAVASCRIPT（英語版）
*-------------------------------------------------------------------------------
*【開 発 日】2003/04/15  【開発ﾒ名】森R 慶彦
*【改 訂 日】			 【改訂ﾒ名】
******************************************************************************'*/

/*'*************************************************************************
*【概要】
* fnc_ChkMemberAdd(会員登録)
*--------------------------------------------------------
*【引 数 名】	[データ型]	[I/O]  [説明]
* なし
*--------------------------------------------------------
*【戻 り 値】	[データ型]	[I/O]  [説明]
* return		boolean		O		true:正常 false:エラー
**************************************************************************'*/
function fnc_ChkMemberAdd(){
	var intByte = 0;
	
	//会社名のチェック
	if(Chk_Hissu(document.forms[0].txt_corp_name.value) == false ) {
		alert(MESS_M001);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_corp_name.value) > 200){
		alert(MESS_M002);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_corp_name.value) == false){
		alert(MESS_M003);
		return false;
	}
	
	//住所１のチェック
	if(document.forms[0].txt_address1.value != "" ) {
		if (Chk_ByteNum(document.forms[0].txt_address1.value) > 100){
			alert(MESS_M011);
			return false;
		} else if (Chk_hankaku(document.forms[0].txt_address1.value) == false){
			alert(MESS_M012);
			return false;
		}
	}
	
	//住所２のチェック
	if(Chk_Hissu(document.forms[0].txt_address2.value) == false ) {
		alert(MESS_M014);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_address2.value) > 100){
		alert(MESS_M015);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_address2.value) == false){
		alert(MESS_M016);
		return false;
	}

	//住所3のチェック
	if(Chk_Hissu(document.forms[0].txt_address3.value) == false ) {
		alert(MESS_M017);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_address3.value) > 100){
		alert(MESS_M018);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_address3.value) == false){
		alert(MESS_M019);
		return false;
	}


	//郵便番号のチェック
	if(Chk_Hissu(document.forms[0].txt_zip.value) == false ) {
		alert(MESS_M020);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_zip.value) > 10){
		alert(MESS_M022);
		return false;
	} else if (Chk_Yubin(document.forms[0].txt_zip.value) == false){
		alert(MESS_M021);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_zip.value) == false){
		alert(MESS_M023);
		return false;
	}
	
	//国のチェック
	if(Chk_Hissu(document.forms[0].sel_country.value) == false ) {
		alert(MESS_M180);
		return false;
	}
	
	//電話番号のチェック
	if(Chk_Hissu(document.forms[0].txt_tel.value) == false ) {
		alert(MESS_M030);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_tel.value) > 30){
		alert(MESS_M032);
		return false;
	} else if(Chk_Tel(document.forms[0].txt_tel.value) == false){
		alert(MESS_M031);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_tel.value) == false){
		alert(MESS_M033);
		return false;
	}
	
	//faxのチェック
	if(Chk_Hissu(document.forms[0].txt_fax.value) == false ) {
		alert(MESS_M040);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_fax.value) > 30){
		alert(MESS_M042);
		return false;
	} else if(Chk_Fax(document.forms[0].txt_fax.value) == false){
		alert(MESS_M041);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_fax.value) == false){
		alert(MESS_M042);
		return false;
	}

	
	//URLチェック
	if(document.forms[0].txt_fax.value != ""){
		if(Chk_Url(document.forms[0].txt_fax.value) == false){
			alert(MESS_M051);
			return false;
		}
	}
	
	//設立年のチェック
	if(document.forms[0].txt_est_year.value != "" ) {
		if(Chk_hankakuNum(document.forms[0].txt_est_year.value) == false ) {
			alert(MESS_M061);
			return false;
		}

		intByte = Chk_ByteNum(document.forms[0].txt_est_year.value);
		
		if(intByte != 4 ) {
			alert(MESS_M061);
			return false;
		}
	}

	//従業員数のチェック
	if(Chk_Hissu(document.forms[0].sel_emp_count.value) == false ) {
		alert(MESS_M070);
		return false;
	}
	
	//資本金のチェック
	if(Chk_Hissu(document.forms[0].sel_capital.value) == false ) {
		alert(MESS_M080);
		return false;
	}
	
	//業種のチェック
	if(Chk_Hissu(document.forms[0].sel_category.value) == false ) {
		alert(MESS_M090);
		return false;
	}

	//会社概要のチェック
	if(Chk_Hissu(document.forms[0].txt_corp_desc.value) == false ) {
		alert(MESS_M100);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_corp_desc.value) > 3000){
		alert(MESS_M101);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_corp_desc.value) == false){
		alert(MESS_M102);
		return false;
	}
	
	//担当者名のチェック
	if(Chk_Hissu(document.forms[0].txt_contact_name.value) == false ) {
		alert(MESS_M110);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_contact_name.value) > 100){
		alert(MESS_M111);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_contact_name.value) == false){
		alert(MESS_M112);
		return false;
	}
	
	//役職のチェック
	if(document.forms[0].txt_official_title.value != "" ) {
		if (Chk_ByteNum(document.forms[0].txt_official_title.value) > 100){
			alert(MESS_M121);
			return false;
		} else if (Chk_hankaku(document.forms[0].txt_official_title.value) == false){
			alert(MESS_M122);
			return false;
		}
	}
	
	//mailのチェック
	if(Chk_Hissu(document.forms[0].txt_mail.value) == false ) {
		alert(MESS_M130);
		return false;
	} else if(Chk_Mail(document.forms[0].txt_mail.value) == false ) {
		alert(MESS_M131);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_mail.value) > 40){
		alert(MESS_M132);
		return false;
	}
	
	//会員IDのチェック
	if(Chk_Hissu(document.forms[0].txt_login_id.value) == false ) {
		alert(MESS_M140);
		return false;
	} else if(Chk_hankakuEisu2(document.forms[0].txt_login_id.value) == false ) {
		alert(MESS_M141);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_login_id.value) > 15){
		alert(MESS_M142);
		return false;
	}
	
	//パスワードのチェック
	if(Chk_Hissu(document.forms[0].txt_password.value) == false ) {
		alert(MESS_M150);
		return false;
	} else if (Chk_hankakuEisu2(document.forms[0].txt_password.value) == false){
		alert(MESS_M151);
		return false;
	}
	
	//パスワードの再入力のチェック
	if(Chk_Hissu(document.forms[0].txt_password2.value) == false ) {
		alert(MESS_M155);
		return false;
	} else if (document.forms[0].txt_password.value != document.forms[0].txt_password2.value){
		alert(MESS_M152);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_password.value) > 15){
		alert(MESS_M153);
		return false;
	}
	
	
	intByte = 0;
	//パスワードの文字数チェック
	intByte = Chk_ByteNum(document.forms[0].txt_password.value);
	if ((4 > intByte) || (intByte > 15)){
		alert(MESS_M154);
		return false;
	}
	
	//パスワードのヒントのチェック
	if(Chk_Hissu(document.forms[0].txt_question.value) == false ) {
		alert(MESS_M160);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_question.value) > 100){
		alert(MESS_M161);
		return false;
	}
	
	//ヒントに対する答えのチェック
	if(Chk_Hissu(document.forms[0].txt_answer.value) == false ) {
		alert(MESS_M170);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_address1.value) > 100){
		alert(MESS_M171);
		return false;
	}
	
	//会員内容確認画面に遷移する。
	document.forms[0].submit();
	
}


/*'*************************************************************************
*【概要】
* 引数のURLに、SUBMITする。
*--------------------------------------------------------
*【引 数 名】	[データ型]	[I/O]  [説明]
* $BackUrl		string		I		戻りたい場所
*--------------------------------------------------------
*【戻 り 値】	[データ型]	[I/O]  [説明]
* なし
**************************************************************************'*/
function fnc_JumpUrl(BackUrl){
	
	//submit先を設定。
	document.forms[0].action = BackUrl;
	//submitする。
	document.forms[0].submit();
}

// =================ebl=================
/*'*************************************************************************
*【概要】
* 引数値により指定されたURLに、SUBMITする。
*--------------------------------------------------------
*【引 数 名】	[データ型]	[I/O]  [説明]
* $Flg			string		I		表価値
* $BackUrl1		string		I		表価値に入力がある場合のURL
* $BackUrl2		string		I		表価値が空の場合のURL
*--------------------------------------------------------
*【戻 り 値】	[データ型]	[I/O]  [説明]
* なし
**************************************************************************'*/
function fnc_JumpUrl2(Flg, BackUrl1, BackUrl2){
	
	//submit先を設定。
	if(Flg != ""){
		document.forms[0].action = BackUrl1;
	}else{
		document.forms[0].action = BackUrl2;
	}
	//submitする。
	document.forms[0].submit();
}
// =================ebl=================

/*'*************************************************************************
*【概要】
* fnc_Check()
*--------------------------------------------------------
*【引 数 名】	[データ型]	[I/O]  [説明]
* sFlag			string		I		メッセージ選択 1:終了 3:削除
*--------------------------------------------------------
*【戻 り 値】	[データ型]	[I/O]  [説明]
* なし
**************************************************************************'*/
function fnc_Check(sFlag){
	
	var msg = "";
	
	// メッセージ選択
	if(sFlag == 1){
		// 終了時
		msg = MESS_001;
	} else {
		// 削除時
		msg = MESS_002;
	}
	
	// 確認メッセージ
	if(confirm(msg)){
		//submitする。
		document.forms[0].submit();
	} else {
		return false;
	}
}

/*'*************************************************************************
*【概要】
* 問合せ時の内容入力時のデータチェック関数
*--------------------------------------------------------
*【引 数 名】	[データ型]	[I/O]  [説明]
* なし
*--------------------------------------------------------
*【戻 り 値】	[データ型]	[I/O]  [説明]
* 				boolean		O		true  :正常時
*									false :エラー時
**************************************************************************'*/
function fnc_SendMail(){
	var intByte = 0;
	
	//お名前のチェック(バイト数、妥当性、必須)
	if(Chk_Hissu(document.forms[0].txt_name.value) == false ) {
		alert(MESS_S01);
		return false;
	}
	
	//MAILのチェック(妥当性、必須)
	if(Chk_Hissu(document.forms[0].txt_mail.value) == false ) {
		alert(MESS_S11);
		return false;
	} else if(Chk_Mail(document.forms[0].txt_mail.value) == false ){
		alert(MESS_S12);
		return false;
	}
	
	//会社名のチェック(必須)
	if(Chk_Hissu(document.forms[0].txt_corp_name.value) == false ) {
		alert(MESS_S21);
		return false;
	}
	
	//電話のチェック(必須,妥当性)
	if(Chk_Hissu(document.forms[0].txt_tel.value) == false ) {
		alert(MESS_S31);
		return false;
	} else if(Chk_Tel(document.forms[0].txt_tel.value) == false){
		alert(MESS_S32);
		return false;
	}
	
	//faxのチェック(必須，妥当性)
	if(document.forms[0].txt_fax.value != "" ) {
		if(Chk_Fax(document.forms[0].txt_fax.value) == false){
			alert(MESS_S42);
			return false;
		}
	}
	
	//役職のチェック(必須)
	if(Chk_Hissu(document.forms[0].txt_official_title.value) == false ) {
		alert(MESS_S51);
		return false;
	}

	//国名のチェック(必須)
	if(Chk_Hissu(document.forms[0].txt_country.value) == false ) {
		alert(MESS_S61);
		return false;
	}
	
	//会社名のチェック(必須)
	if(Chk_Hissu(document.forms[0].txt_subject.value) == false ) {
		alert(MESS_S71);
		return false;
	}
	
	//本文のチェック(バイト数、必須)
	if(Chk_Hissu(document.forms[0].txt_body.value) == false ) {
		alert(MESS_S81);
		return false;
	} else if (Chk_ByteNum(document.forms[0].txt_body.value) > 3000){
		alert(MESS_S82);
		return false;
	}
	
	// 確認メッセージ
	if(confirm(MESS_003)){
		//内容をメール送信する
		document.forms[0].submit();
	} else {
		return false;
	}
	
}

/*'*************************************************************************
*【概要】
* 引合情報掲載、更新、再掲載時での、データチェック
*--------------------------------------------------------
*【引 数 名】	[データ型]	[I/O]  [説明]
* なし
*--------------------------------------------------------
*【戻 り 値】	[データ型]	[I/O]  [説明]
* 				boolean		O		true  :正常時
*									false :エラー時
**************************************************************************'*/
function fnc_PostOffer(){
	var intByte = 0;
	
	//引合種別のチェック
	if(Chk_Hissu(document.forms[0].sel_offer_type.value) == false ) {
		alert(MESS_H01);
		return false;
	}
	
	//商品名のチェック(バイト数、妥当性、必須)
	if(Chk_Hissu(document.forms[0].txt_product_name.value) == false ) {
		alert(MESS_H11);
		return false;
	} else if(Chk_ByteNum(document.forms[0].txt_product_name.value) > 200){
		alert(MESS_H12);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_product_name.value) == false){
		alert(MESS_H13);
		return false;
	}
	
	//カテゴリー(大）のチェック
	if(Chk_Hissu(document.forms[0].sel_bitem.value) == false ) {
		alert(MESS_H31);
		return false;
	}

	//カテゴリー(中）のチェック
	if(Chk_Hissu(document.forms[0].sel_mitem.value) == false ) {
		alert(MESS_H41);
		return false;
	}
	
	//有効期限のチェック
	if(Chk_Hissu(document.forms[0].sel_valid_date.value) == false ) {
		alert(MESS_H51);
		return false;
	}

	//商品の説明のチェック(バイト数、必須)
	if(Chk_Hissu(document.forms[0].txt_product_desc.value) == false ) {
		alert(MESS_H61);
		return false;
	} else if(Chk_ByteNum(document.forms[0].txt_product_desc.value) > 3000){
		alert(MESS_H62);
		return false;
	} else if (Chk_hankaku(document.forms[0].txt_product_desc.value) == false){
		alert(MESS_H63);
		return false;
	}

	//画像の拡張子チェック
	if(document.forms[0].fname.value != ""){
		if(Chk_File(document.forms[0].fname.value,"jpg") == -1 && Chk_File(document.forms[0].fname.value,"jpeg") == -1){
			alert(MESS_H21);
			return false;
		}
	}

	// =================ebl=================
	// キャプチャ画像の存在チェック
	if(document.forms[0].img_name){
		if(document.forms[0].img_name.value == ""){
			alert(MESS_H71);
			return false;
		} else if( document.forms[0].md5.value != MD5_hexhash(document.forms[0].img_name.value) ) {
			alert(MESS_H72);
			return false;
		}
	}
	// =================ebl=================
	
	//引合情報入力確認画面に遷移する。
	document.forms[0].submit();
}
