/*
 * MosP - Mind Open Source Project         http://www.mosp.jp/
 * Copyright (C) 1987-2009 MIND Co., Ltd.  http://www.e-mind.co.jp/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
// タブ毎フィールドリスト
var aryTab0FieldList;
var aryTab2FieldList;
var aryTab3FieldList;
var aryTab4FieldList;
var aryTab5FieldList;
var aryTab6FieldList;
// コピーペースト用データ格納定数
var DATA_PLT_CO_BANK_CODE     = "";
var DATA_LBL_PAID_BANK_NAME   = "";
var DATA_LBL_PAID_BRANCH_NAME = "";
var DATA_TXT_PAID_BANK_CODE   = "";
var DATA_TXT_PAID_BRANCH_CODE = "";
var DATA_PLT_ACCOUNT_TYPE     = "";
var DATA_TXT_ACCOUNT_NO       = "";
var DATA_PLT_PAYMENT_MEANS    = "";
var DATA_PLT_AMOUNT_TYPE      = "";
var DATA_TXT_FIXED_AMOUNT     = "";
var DATA_BEF_TARGET_INDEX     = "";
var DATA_TXT_HOLDER_NAME      = "";
var DATA_TXT_HOLDER_KANA      = "";

var objBankCode;
var objBankName;
var objBranchCode;
var objBranchName;

// 入力チェック用変数
var objError    = null;

// 扶養等の数ラベルID
var LBL_COUNT_DEPENDENT = "lblCountDependent";

/**
 * 画面読込時追加処理
 * @param 無し
 * @return 無し
 * @throws 実行時例外
 */
function onLoadExtra() {
	// タブ毎フィールドリスト設定
	aryTab0FieldList = new Array(
		PRM_PLT_PENSION_TYPE       ,
		PRM_PLT_PARTTIME_TYPE      ,
		PRM_PLT_EMPLOYEE_TYPE      ,
		PRM_PLT_CALC_INS_TYPE      ,
		PRM_PLT_NURSING_INS_TYPE   ,
		PRM_PLT_CALC_UNEMPLOY_TYPE ,
		PRM_PLT_BONUS_HEALTH_TYPE  ,
		PRM_PLT_BONUS_PENSION_TYPE ,
		PRM_TXT_HEALTH_NO          ,
		PRM_TXT_HEALTH_PAYMENT     ,
		PRM_PLT_HEALTH_GET_ERA     ,
		PRM_PLT_HEALTH_GET_YEAR    ,
		PRM_PLT_HEALTH_GET_MONTH   ,
		PRM_PLT_HEALTH_GET_DAY     ,
		PRM_PLT_HEALTH_LOST_TYPE   ,
		PRM_PLT_HEALTH_LOST_ERA    ,
		PRM_PLT_HEALTH_LOST_YEAR   ,
		PRM_PLT_HEALTH_LOST_MONTH  ,
		PRM_PLT_HEALTH_LOST_DAY    ,
		PRM_TXT_PENSION_NO         ,
		PRM_TXT_PENSION_PAYMENT    ,
		PRM_PLT_PENSION_GET_ERA    ,
		PRM_PLT_PENSION_GET_YEAR   ,
		PRM_PLT_PENSION_GET_MONTH  ,
		PRM_PLT_PENSION_GET_DAY    ,
		PRM_PLT_PENSION_LOST_TYPE  ,
		PRM_PLT_PENSION_LOST_ERA   ,
		PRM_PLT_PENSION_LOST_YEAR  ,
		PRM_PLT_PENSION_LOST_MONTH ,
		PRM_PLT_PENSION_LOST_DAY   ,
		PRM_TXT_FUND_NO            ,
		PRM_PLT_FUND_GET_ERA       ,
		PRM_PLT_FUND_GET_YEAR      ,
		PRM_PLT_FUND_GET_MONTH     ,
		PRM_PLT_FUND_GET_DAY       ,
		PRM_TXT_UNEMPLOY_NO        ,
		PRM_PLT_UNEMPLOY_GET_ERA   ,
		PRM_PLT_UNEMPLOY_GET_YEAR  ,
		PRM_PLT_UNEMPLOY_GET_MONTH ,
		PRM_PLT_UNEMPLOY_GET_DAY   ,
		PRM_PLT_UNEMPLOY_LOST_TYPE ,
		PRM_PLT_UNEMPLOY_LOST_ERA  ,
		PRM_PLT_UNEMPLOY_LOST_YEAR ,
		PRM_PLT_UNEMPLOY_LOST_MONTH,
		PRM_PLT_UNEMPLOY_LOST_DAY
	);
	aryTab2FieldList = new Array(
		PRM_TXT_PAYMENT_CITY_CODE,
		PRM_TXT_SUBMIT_CITY_CODE ,
		PRM_TXT_JUNE_AMOUNT      ,
		PRM_TXT_JULY_AMOUNT      ,
		PRM_TXT_AUGUST_AMOUNT    ,
		PRM_TXT_SEPTEMBER_AMOUNT ,
		PRM_TXT_OCTOBER_AMOUNT   ,
		PRM_TXT_NOVEMBER_AMOUNT  ,
		PRM_TXT_DECEMBER_AMOUNT  ,
		PRM_TXT_JANUARY_AMOUNT   ,
		PRM_TXT_FEBRUARY_AMOUNT  ,
		PRM_TXT_MARCH_AMOUNT     ,
		PRM_TXT_APRIL_AMOUNT     ,
		PRM_TXT_MAY_AMOUNT
	);
	aryTab3FieldList = new Array(
		PRM_PLT_INCOME_TAX_TYPE   ,
		PRM_PLT_ADJUSTMENT_TYPE   ,
		PRM_PLT_SELF_WIDOW_TYPE   ,
		PRM_PLT_SELF_HANDICAP_TYPE,
		PRM_PLT_SELF_STUDENT_TYPE ,
		PRM_PLT_SPOUSE_INTEND_TYPE,
		PRM_TXT_GENERAL_DEPENDENT ,
		PRM_TXT_SPECIFIC_DEPENDENT,
		PRM_TXT_ELDERLY_DEPENDENT ,
		PRM_TXT_LIVE_WITH_ELD_REL ,
		PRM_TXT_LIVE_WITH_HANDI_GE,
		PRM_TXT_LIVE_WITH_HANDI_SP,
		PRM_TXT_LIVE_WITH_HANDI_EL,
		PRM_TXT_LIVE_WITH_HANDI_ER,
		PRM_TXT_GENERAL_HANDICAP  ,
		PRM_TXT_SPECIFIC_HANDICAP ,
		PRM_HID_DEPENDENT_COUNT
	);
	aryTab4FieldList = new Array(
		PRM_PLT_PAYMENT_INTERVAL ,
		PRM_PLT_LUMP_MONTHLY_TYPE,
		PRM_PLT_PAY_START_MONTH  ,
		PRM_TXT_COMMUTE_DISTANCE ,
		PRM_TXT_COMMUTE_AMOUNT   ,
		PRM_TXT_COMMUTE_TAXED    
	);
	aryTab5FieldList = new Array(
		PRM_PLT_CO_BANK_CODE    ,
		PRM_TXT_PAID_BANK_CODE  ,
		PRM_TXT_PAID_BRANCH_CODE,
		PRM_PLT_ACCOUNT_TYPE    ,
		PRM_TXT_ACCOUNT_NO      ,
		PRM_TXT_HOLDER_NAME     ,
		PRM_TXT_HOLDER_KANA     ,
		PRM_PLT_PAYMENT_MEANS   ,
		PRM_PLT_AMOUNT_TYPE     ,
		PRM_TXT_FIXED_AMOUNT    
	);
	aryTab6FieldList = new Array(
		PRM_TXT_UNIT_AMOUNT
	);
	
	// 項目背景色設定
	setDetailsBgColorAll(aryTab0FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab2FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab3FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab4FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab5FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab6FieldList, COLOR_FIELD_NORMAL);
	setFieldsBgColor(ARY_FIELDS_ID,     COLOR_FIELD_NORMAL);
	setFieldsBgColor(ARY_ERR_FIELDS_ID, COLOR_FIELD_ERROR);
	setDetailsBgColor(ARY_ERR_DETAILS, COLOR_FIELD_ERROR);
	// 項目長設定
	// 社会保険
	setMaxLength(PRM_TXT_HEALTH_NO         , LEN_HEALTH_NO       );
	setMaxLength(PRM_TXT_HEALTH_PAYMENT    , LEN_MONEY_AMOUNT - 3);
	setMaxLength(PRM_TXT_PENSION_NO        , LEN_PENSION_NO      );
	setMaxLength(PRM_TXT_PENSION_PAYMENT   , LEN_MONEY_AMOUNT - 3);
	setMaxLength(PRM_TXT_FUND_NO           , LEN_FUND_NO         );
	setMaxLength(PRM_TXT_UNEMPLOY_NO       , LEN_UNEMPLOY_NO     );
	// 住民税
	setMaxLength(PRM_TXT_PAYMENT_CITY_CODE , LEN_CITY_CODE      );
	setMaxLength(PRM_TXT_SUBMIT_CITY_CODE  , LEN_CITY_CODE      );
	setMaxLength(PRM_TXT_JUNE_AMOUNT       , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_JULY_AMOUNT       , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_AUGUST_AMOUNT     , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_SEPTEMBER_AMOUNT  , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_OCTOBER_AMOUNT    , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_NOVEMBER_AMOUNT   , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_DECEMBER_AMOUNT   , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_JANUARY_AMOUNT    , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_FEBRUARY_AMOUNT   , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_MARCH_AMOUNT      , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_APRIL_AMOUNT      , LEN_MONEY_AMOUNT   );
	setMaxLength(PRM_TXT_MAY_AMOUNT        , LEN_MONEY_AMOUNT   );
	// 所得税
	setMaxLength(PRM_TXT_GENERAL_DEPENDENT , LEN_DEPENDENT_COUNT);
	setMaxLength(PRM_TXT_SPECIFIC_DEPENDENT, LEN_DEPENDENT_COUNT);
	setMaxLength(PRM_TXT_ELDERLY_DEPENDENT , LEN_DEPENDENT_COUNT);
	setMaxLength(PRM_TXT_LIVE_WITH_ELD_REL , LEN_DEPENDENT_COUNT);
	setMaxLength(PRM_TXT_LIVE_WITH_HANDI_GE, LEN_DEPENDENT_COUNT);
	setMaxLength(PRM_TXT_LIVE_WITH_HANDI_SP, LEN_DEPENDENT_COUNT);
	setMaxLength(PRM_TXT_LIVE_WITH_HANDI_EL, LEN_DEPENDENT_COUNT);
	setMaxLength(PRM_TXT_LIVE_WITH_HANDI_ER, LEN_DEPENDENT_COUNT);
	setMaxLength(PRM_TXT_GENERAL_HANDICAP  , LEN_DEPENDENT_COUNT);
	setMaxLength(PRM_TXT_SPECIFIC_HANDICAP , LEN_DEPENDENT_COUNT);
	// 支給方法
	for (var i = 0; i < LEN_PAYMENT_MEANS_COUNT; i++) {
		setMaxLength(getObjectDetails(PRM_TXT_PAID_BANK_CODE  , i), LEN_BANK_CODE   );
		setMaxLength(getObjectDetails(PRM_TXT_PAID_BRANCH_CODE, i), LEN_BRANCH_CODE );
		setMaxLength(getObjectDetails(PRM_TXT_ACCOUNT_NO      , i), LEN_ACCOUNT_NO  );
		setMaxLength(getObjectDetails(PRM_TXT_HOLDER_NAME     , i), LEN_K_NAME      );
		setMaxLength(getObjectDetails(PRM_TXT_HOLDER_KANA     , i), LEN_K_NAME      );
		setMaxLength(getObjectDetails(PRM_TXT_FIXED_AMOUNT    , i), LEN_MONEY_AMOUNT);
	}
	// 通勤手当
	for (var i = 0; i < LEN_COMMUTATION_COUNT; i++) {
		setMaxLength(getObjectDetails(PRM_TXT_COMMUTE_DISTANCE, i),
				LEN_COMMUTE_DISTANCE_INT + LEN_COMMUTE_DISTANCE_DEC + 1
		);
		setMaxLength(getObjectDetails(PRM_TXT_COMMUTE_AMOUNT  , i), LEN_MONEY_AMOUNT    );
		setMaxLength(getObjectDetails(PRM_TXT_COMMUTE_TAXED   , i), LEN_MONEY_AMOUNT    );
	}
	// 計算単価
	for (var i = 0; i < LEN_UNIT_AMOUNT_COUNT; i++) {
		setMaxLength(
			getObjectDetails(PRM_TXT_UNIT_AMOUNT, i),
			LEN_UNIT_AMOUNT_INT + LEN_UNIT_AMOUNT_DEC + 1
		);
	}
	// 初期設定
	if (ARY_ERR_FIELDS_ID.length > 0) {
		setFocus(ARY_ERR_FIELDS_ID[0]);
	} else if (ARY_ERR_DETAILS.length > 0) {
		setFocus(getObjectDetails(ARY_ERR_DETAILS[0][0], ARY_ERR_DETAILS[0][1]));
	}
	// チェンジイベントハンドラ設定
	setOnChangeHandler(PRM_PLT_SELF_WIDOW_TYPE   ,setDependents);
	setOnChangeHandler(PRM_PLT_SELF_HANDICAP_TYPE,setDependents);
	setOnChangeHandler(PRM_PLT_SELF_STUDENT_TYPE ,setDependents);
	setOnChangeHandler(PRM_PLT_SPOUSE_INTEND_TYPE,setDependents);
	setOnChangeHandler(PRM_TXT_GENERAL_DEPENDENT ,setDependents);
	setOnChangeHandler(PRM_TXT_SPECIFIC_DEPENDENT,setDependents);
	setOnChangeHandler(PRM_TXT_ELDERLY_DEPENDENT ,setDependents);
	setOnChangeHandler(PRM_TXT_LIVE_WITH_ELD_REL ,setDependents);
	setOnChangeHandler(PRM_TXT_LIVE_WITH_HANDI_GE,setDependents);
	setOnChangeHandler(PRM_TXT_LIVE_WITH_HANDI_SP,setDependents);
	setOnChangeHandler(PRM_TXT_LIVE_WITH_HANDI_EL,setDependents);
	setOnChangeHandler(PRM_TXT_LIVE_WITH_HANDI_ER,setDependents);
	setOnChangeHandler(PRM_TXT_GENERAL_HANDICAP  ,setDependents);
	setOnChangeHandler(PRM_TXT_SPECIFIC_HANDICAP ,setDependents);

	for (var i = 0; i < LEN_PAYMENT_MEANS_COUNT; i++) {
		setOnChangeHandler(getObjectDetails(PRM_TXT_ACCOUNT_NO      , i), onChangeAccountNo);
		setOnChangeHandler(getObjectDetails(PRM_TXT_PAID_BANK_CODE  , i), setBankName      );
		setOnChangeHandler(getObjectDetails(PRM_TXT_PAID_BRANCH_CODE, i), setBranchName    );
	}
	// ボタン利用可否
	setVisibility("btnNewData", false);
}

/**
 * サーバー通信処理
 * @param 無し
 * @return 無し
 * @throws 実行時例外
 */
function submitForm(objForm) {
	// 入力チェック
	if (validate()) {
		// サーバー通信(入力エラー無の場合)
		if (MODE == 0) {
			doSubmitMessage(objForm, 'U4151', 'QC0001', '');
		} else if (MODE == 1) {
			doSubmitMessage(objForm, 'U4152', 'QC0001', '');
		}
	}
}

/**
 * 入力チェック
 * @param 無し
 * @return チェック結果(true：OK、false：NG)
 * @throws 実行時例外
 */
function validate() {
	// フィールド背景色設定
	setFieldsBgColor(ARY_FIELDS_ID, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab0FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab2FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab3FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab4FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab5FieldList, COLOR_FIELD_NORMAL);
	setDetailsBgColorAll(aryTab6FieldList, COLOR_FIELD_NORMAL);
	// 入力チェック
	var aryMessage = new Array();
	// 社会保険
	checkNumberForCalc(PRM_TXT_HEALTH_NO      , NAM_HEALTH_NO      , aryMessage);
	checkNumberForCalc(PRM_TXT_HEALTH_PAYMENT , NAM_HEALTH_PAYMENT , aryMessage);
	checkNumberForCalc(PRM_TXT_PENSION_NO     , NAM_PENSION_NO     , aryMessage);
	checkNumberForCalc(PRM_TXT_PENSION_PAYMENT, NAM_PENSION_PAYMENT, aryMessage);
	checkNumberForCalc(PRM_TXT_FUND_NO        , NAM_FUND_NO        , aryMessage);
	checkPhoneForCalc (PRM_TXT_UNEMPLOY_NO    , NAM_UNEMPLOY_NO    , aryMessage);
	// 住民税
	checkNumberForCalc (PRM_TXT_PAYMENT_CITY_CODE, NAM_PAYMENT_CITY_CODE, aryMessage);
	checkNumberForCalc (PRM_TXT_SUBMIT_CITY_CODE , NAM_SUBMIT_CITY_CODE , aryMessage);
	checkIntegerForCalc(PRM_TXT_JUNE_AMOUNT      , NAM_JUNE_AMOUNT      , aryMessage);
	checkIntegerForCalc(PRM_TXT_JULY_AMOUNT      , NAM_JULY_AMOUNT      , aryMessage);
	checkIntegerForCalc(PRM_TXT_AUGUST_AMOUNT    , NAM_AUGUST_AMOUNT    , aryMessage);
	checkIntegerForCalc(PRM_TXT_SEPTEMBER_AMOUNT , NAM_SEPTEMBER_AMOUNT , aryMessage);
	checkIntegerForCalc(PRM_TXT_OCTOBER_AMOUNT   , NAM_OCTOBER_AMOUNT   , aryMessage);
	checkIntegerForCalc(PRM_TXT_NOVEMBER_AMOUNT  , NAM_NOVEMBER_AMOUNT  , aryMessage);
	checkIntegerForCalc(PRM_TXT_DECEMBER_AMOUNT  , NAM_DECEMBER_AMOUNT  , aryMessage);
	checkIntegerForCalc(PRM_TXT_JANUARY_AMOUNT   , NAM_JANUARY_AMOUNT   , aryMessage);
	checkIntegerForCalc(PRM_TXT_FEBRUARY_AMOUNT  , NAM_FEBRUARY_AMOUNT  , aryMessage);
	checkIntegerForCalc(PRM_TXT_MARCH_AMOUNT     , NAM_MARCH_AMOUNT     , aryMessage);
	checkIntegerForCalc(PRM_TXT_APRIL_AMOUNT     , NAM_APRIL_AMOUNT     , aryMessage);
	checkIntegerForCalc(PRM_TXT_MAY_AMOUNT       , NAM_MAY_AMOUNT       , aryMessage);
	// 所得税
	checkNumberForCalc(PRM_TXT_GENERAL_DEPENDENT , NAM_GENERAL_DEPENDENT , aryMessage);
	checkNumberForCalc(PRM_TXT_SPECIFIC_DEPENDENT, NAM_SPECIFIC_DEPENDENT, aryMessage);
	checkNumberForCalc(PRM_TXT_ELDERLY_DEPENDENT , NAM_ELDERLY_DEPENDENT , aryMessage);
	checkNumberForCalc(PRM_TXT_LIVE_WITH_ELD_REL , NAM_LIVE_WITH_ELD_REL , aryMessage);
	checkNumberForCalc(PRM_TXT_LIVE_WITH_HANDI_GE, NAM_LIVE_WITH_HANDI_GE, aryMessage);
	checkNumberForCalc(PRM_TXT_LIVE_WITH_HANDI_SP, NAM_LIVE_WITH_HANDI_SP, aryMessage);
	checkNumberForCalc(PRM_TXT_LIVE_WITH_HANDI_EL, NAM_LIVE_WITH_HANDI_EL, aryMessage);
	checkNumberForCalc(PRM_TXT_LIVE_WITH_HANDI_ER, NAM_LIVE_WITH_HANDI_ER, aryMessage);
	checkNumberForCalc(PRM_TXT_GENERAL_HANDICAP  , NAM_GENERAL_HANDICAP  , aryMessage);
	checkNumberForCalc(PRM_TXT_SPECIFIC_HANDICAP , NAM_SPECIFIC_HANDICAP , aryMessage);
	// 通勤手当
	for (var i = 0; i < LEN_COMMUTATION_COUNT; i++) {
		checkDecimalForCalc(
				getObjectDetails(PRM_TXT_COMMUTE_DISTANCE, i),
				LEN_COMMUTE_DISTANCE_INT,
				LEN_COMMUTE_DISTANCE_DEC,
				NAM_COMMUTE_DISTANCE,
				aryMessage
		);
	}
	// 支給方法
	for (var i = 0; i < LEN_PAYMENT_MEANS_COUNT; i++) {
		// 半角変換
		convSbSpace(getObjectDetails(PRM_TXT_HOLDER_NAME, i));
		convSbSpace(getObjectDetails(PRM_TXT_HOLDER_KANA, i));
		convSbKana (getObjectDetails(PRM_TXT_HOLDER_KANA, i));
		// 確認
		checkNumberForCalc(getObjectDetails(PRM_TXT_PAID_BANK_CODE  , i), NAM_PAID_BANK_CODE  , aryMessage);
		checkNumberForCalc(getObjectDetails(PRM_TXT_PAID_BRANCH_CODE, i), NAM_PAID_BRANCH_CODE, aryMessage);
		checkNumberForCalc(getObjectDetails(PRM_TXT_ACCOUNT_NO      , i), NAM_ACCOUNT_NO      , aryMessage);
		checkKanaForCalc  (getObjectDetails(PRM_TXT_HOLDER_KANA     , i), NAM_HOLDER_KANA     , aryMessage);
		checkNumberForCalc(getObjectDetails(PRM_TXT_FIXED_AMOUNT    , i), NAM_FIXED_AMOUNT     , aryMessage);
	}
	// 計算単価
	for (var i = 0; i < LEN_UNIT_AMOUNT_COUNT; i++) {
		checkDecimalForCalc(
				getObjectDetails(PRM_TXT_UNIT_AMOUNT, i),
				LEN_UNIT_AMOUNT_INT,
				LEN_UNIT_AMOUNT_DEC,
				NAM_UNIT_AMOUNT,
				aryMessage
		);
	}
	if (aryMessage.length == 0) {
		return true;
	} else {
		setFocus(objError);
		showMessage(aryMessage);
		return false;
	}
}

/**
 * 文字列タイプ確認(コード)
 * @param target      確認対象(StringあるいはObject)
 * @param rep         変換文字列
 * @param aryMessage  エラーメッセージ格納配列
 * @return 無し
 * @throws 実行時例外
 */
function checkPhoneForCalc(target, rep, aryMessage) {
	var needSetErrorInfo = aryMessage.length == 0;
	checkPhone(target, rep, aryMessage);
	if (needSetErrorInfo && aryMessage.length > 0) {
		numErrorTab = getFormValue(PRM_HID_CALC_CURRENT_TAB);
		objError    = getObject(target);
	}
}

/**
 * 文字列タイプ確認(半角数字)
 * @param target      確認対象(StringあるいはObject)
 * @param rep         変換文字列
 * @param aryMessage  エラーメッセージ格納配列
 * @return 無し
 * @throws 実行時例外
 */
function checkNumberForCalc(target, rep, aryMessage) {
	var needSetErrorInfo = aryMessage.length == 0;
	checkNumber(target, rep, aryMessage);
	if (needSetErrorInfo && aryMessage.length > 0) {
		objError    = getObject(target);
	}
}

/**
 * 文字列タイプ確認(半角数字)
 * @param target      確認対象(StringあるいはObject)
 * @param rep         変換文字列
 * @param aryMessage  エラーメッセージ格納配列
 * @return 無し
 * @throws 実行時例外
 */
function checkIntegerForCalc(target, rep, aryMessage) {
	var needSetErrorInfo = aryMessage.length == 0;
	checkInteger(target, rep, aryMessage);
	if (needSetErrorInfo && aryMessage.length > 0) {
		numErrorTab = getFormValue(PRM_HID_CALC_CURRENT_TAB);
		objError    = getObject(target);
	}
}

/**
 * 文字列タイプ確認(半角カナ+半角英数字記号)
 * @param target     確認対象(StringあるいはObject)
 * @param rep        変換文字列
 * @param aryMessage エラーメッセージ格納配列
 * @return 無し
 * @throws 実行時例外
 */
function checkKanaForCalc(target, rep, aryMessage) {
	var needSetErrorInfo = aryMessage.length == 0;
	checkKana(target, rep, aryMessage);
	if (needSetErrorInfo && aryMessage.length > 0) {
		numErrorTab = getFormValue(PRM_HID_CALC_CURRENT_TAB);
		objError    = getObject(target);
	}
}

/**
 * 文字列タイプ確認(少数)
 * @param target     確認対象(StringあるいはObject)
 * @param rep        変換文字列
 * @param aryMessage エラーメッセージ格納配列
 * @return 無し
 * @throws 実行時例外
 */
function checkDecimalForCalc(target, integer, decimal, rep, aryMessage) {
	var needSetErrorInfo = aryMessage.length == 0;
	checkDecimal(target, integer, decimal, rep, aryMessage);
	if (needSetErrorInfo && aryMessage.length > 0) {
		numErrorTab = getFormValue(PRM_HID_CALC_CURRENT_TAB);
		objError    = getObject(target);
	}
}

/**
 * 数値項目取得(数字以外なら0)
 * @param target 取得対象
 * @return 対象項目数値
 * @throws 実行時例外
 */
function getNumeric(target) {
	if (checkNumericNoMsg(target)) {
		return new Number(getFormValue(target));
	}
	return 0;
}

/**
 * 控除対象配偶者数取得
 * @param 無し
 * @return 控除対象配偶者数
 * @throws 実行時例外
 */
function countDeductibleSpouse() {
	// 配偶者区分が一般配偶、老人配偶、同居特障、同特老人で1
	// 配偶者区分取得
	var spouseIntendType = getFormValue(PRM_PLT_SPOUSE_INTEND_TYPE);
	if (spouseIntendType != null && spouseIntendType != "") {
		return 1;
	}
	return 0;
}

/**
 * 扶養親族数取得
 * @param 無し
 * @return 扶養親族数
 * @throws 実行時例外
 */
function countRelativeDependents() {
	// 一般扶養親族(No.7)〜同居特障老親(No.14)の合計
	var relativeDependents = 0;
	relativeDependents += getNumeric(PRM_TXT_GENERAL_DEPENDENT );
	relativeDependents += getNumeric(PRM_TXT_SPECIFIC_DEPENDENT);
	relativeDependents += getNumeric(PRM_TXT_ELDERLY_DEPENDENT );
	relativeDependents += getNumeric(PRM_TXT_LIVE_WITH_ELD_REL );
	relativeDependents += getNumeric(PRM_TXT_LIVE_WITH_HANDI_GE);
	relativeDependents += getNumeric(PRM_TXT_LIVE_WITH_HANDI_SP);
	relativeDependents += getNumeric(PRM_TXT_LIVE_WITH_HANDI_EL);
	relativeDependents += getNumeric(PRM_TXT_LIVE_WITH_HANDI_ER);
	return relativeDependents;
}

/**
 * 本人関連数取得
 * @param 無し
 * @return 本人関連数
 * @throws 実行時例外
 */
function countSelfTypes() {
	var selfTypes = 0;
	// 本人区分2が一般障害、特別障害なら1
	var selfHandicapType = getFormValue(PRM_PLT_SELF_HANDICAP_TYPE);
	if (selfHandicapType != null && selfHandicapType != "") {
		selfTypes += 1;
	}
	// 本人区分1が寡婦(夫)、特別寡婦なら1
	var selfWidowType = getFormValue(PRM_PLT_SELF_WIDOW_TYPE);
	if (selfWidowType != null && selfWidowType != "") {
		selfTypes += 1;
	}
	// 本人区分3が勤労学生なら1
	var selfStudentType = getFormValue(PRM_PLT_SELF_STUDENT_TYPE);
	if (selfStudentType != null && selfStudentType != "") {
		selfTypes += 1;
	}
	return selfTypes;
}

/**
 * 障害者数取得
 * @param 無し
 * @return 障害者数
 * @throws 実行時例外
 */
function countHandicaps() {
	var handicaps = 0;
	// 控除対象配偶者(配偶者区分が同居特障、同特老人で1)
	var spouseIntendType = getFormValue(PRM_PLT_SPOUSE_INTEND_TYPE);
	if (spouseIntendType == REG_SPOUSE_INTEND_LWSH ||
			spouseIntendType == REG_SPOUSE_INTEND_LWSH_EL) {
		handicaps += 1;
	}
	// 一般障害者
	handicaps += getNumeric(PRM_TXT_GENERAL_HANDICAP);
	// 特別障害者
	handicaps += getNumeric(PRM_TXT_SPECIFIC_HANDICAP);
	// 同居特障一般〜同居特障老親の合計
	handicaps += getNumeric(PRM_TXT_LIVE_WITH_HANDI_GE);
	handicaps += getNumeric(PRM_TXT_LIVE_WITH_HANDI_SP);
	handicaps += getNumeric(PRM_TXT_LIVE_WITH_HANDI_EL);
	handicaps += getNumeric(PRM_TXT_LIVE_WITH_HANDI_ER);
	return handicaps;
}

/**
 * 扶養等の数計算
 * @param 無し
 * @return 扶養等の数
 * @throws 実行時例外
 */
function countDependents() {
	var dependents = 0;
	// 控除対象配偶者
	dependents += countDeductibleSpouse();
	// 扶養親族
	dependents += countRelativeDependents();
	// 本人が障害者 + 寡婦 + 勤労学生
	dependents += countSelfTypes();
	// 控除対象配偶者や扶養親族が障害者又は同居特別障害者
	dependents += countHandicaps();
	return dependents;
}

/**
 * 扶養等の数設定
 * @param 無し
 * @return 無し
 * @throws 実行時例外
 */
function setDependents() {
	var dependents = countDependents();
	setInnerHtml(LBL_COUNT_DEPENDENT, dependents);
	setFormValue(PRM_HID_DEPENDENT_COUNT, dependents);
}

/**
 * コピー機能
 * @param copyIndex  コピー元インデックス
 * @param targetIndex 対象インデックス
 * @return 無し
 * @throws 実行時例外
 */
function setDataCopy(copyIndex, targetIndex) {
	// コピー元オブジェクト取得
	var obj1  = getObjectDetails(PRM_PLT_CO_BANK_CODE    , copyIndex);
	var obj4  = getObjectDetails(PRM_TXT_PAID_BANK_CODE  , copyIndex);
	var obj5  = getObjectDetails(PRM_TXT_PAID_BRANCH_CODE, copyIndex);
	var obj6  = getObjectDetails(PRM_PLT_ACCOUNT_TYPE    , copyIndex);
	var obj7  = getObjectDetails(PRM_TXT_ACCOUNT_NO      , copyIndex);
//	var obj8  = getObjectDetails(PRM_PLT_PAYMENT_MEANS   , copyIndex);
//	var obj9  = getObjectDetails(PRM_PLT_AMOUNT_TYPE     , copyIndex);
//	var obj10 = getObjectDetails(PRM_TXT_FIXED_AMOUNT    , copyIndex);
	var obj11 = getObjectDetails(PRM_TXT_HOLDER_KANA     , copyIndex);
	var obj12 = getObjectDetails(PRM_TXT_HOLDER_NAME     , copyIndex);
	// 銀行名取得
	var bankName    = getInnerHtml(PRM_LBL_PAID_BANK_NAME + copyIndex);
	// 支店名取得
	var branchName  = getInnerHtml(PRM_LBL_PAID_BRANCH_NAME + copyIndex);
	

	// 値を設定
	DATA_PLT_CO_BANK_CODE     = getFormValue(obj1 );
	DATA_LBL_PAID_BANK_NAME   = bankName;
	DATA_LBL_PAID_BRANCH_NAME = branchName;
	DATA_TXT_PAID_BANK_CODE   = getFormValue(obj4 );
	DATA_TXT_PAID_BRANCH_CODE = getFormValue(obj5 );
	DATA_PLT_ACCOUNT_TYPE     = getFormValue(obj6 );
	DATA_TXT_ACCOUNT_NO       = getFormValue(obj7 );
//	DATA_PLT_PAYMENT_MEANS    = getFormValue(obj8 );
//	DATA_PLT_AMOUNT_TYPE      = getFormValue(obj9 );
//	DATA_TXT_FIXED_AMOUNT     = getFormValue(obj10);
	DATA_TXT_HOLDER_KANA      = getFormValue(obj11);
	DATA_TXT_HOLDER_NAME      = getFormValue(obj12);
	DATA_BEF_TARGET_INDEX     = copyIndex;
	// コピー元のIDXが支給方法1なら支給方法2へのコピーは全て残額
	if (DATA_BEF_TARGET_INDEX == "0") {
		if (targetIndex == "3") {
			DATA_PLT_AMOUNT_TYPE = "4";
		}
	}
	// コピー先オブジェクト取得
	var targetObj1  = getObjectDetails(PRM_PLT_CO_BANK_CODE    , targetIndex);
	var targetObj4  = getObjectDetails(PRM_TXT_PAID_BANK_CODE  , targetIndex);
	var targetObj5  = getObjectDetails(PRM_TXT_PAID_BRANCH_CODE, targetIndex);
	var targetObj6  = getObjectDetails(PRM_PLT_ACCOUNT_TYPE    , targetIndex);
	var targetObj7  = getObjectDetails(PRM_TXT_ACCOUNT_NO      , targetIndex);
//	var targetObj8  = getObjectDetails(PRM_PLT_PAYMENT_MEANS   , targetIndex);
//	var targetObj9  = getObjectDetails(PRM_PLT_AMOUNT_TYPE     , targetIndex);
//	var targetObj10 = getObjectDetails(PRM_TXT_FIXED_AMOUNT    , targetIndex);
	var targetObj11 = getObjectDetails(PRM_TXT_HOLDER_KANA     , targetIndex);
	var targetObj12 = getObjectDetails(PRM_TXT_HOLDER_NAME     , targetIndex);
	// 値を設定
	setFormValue(targetObj1 , DATA_PLT_CO_BANK_CODE    );
	setFormValue(targetObj4 , DATA_TXT_PAID_BANK_CODE  );
	setFormValue(targetObj5 , DATA_TXT_PAID_BRANCH_CODE);
	setFormValue(targetObj6 , DATA_PLT_ACCOUNT_TYPE    );
	setFormValue(targetObj7 , DATA_TXT_ACCOUNT_NO      );
//	setFormValue(targetObj8 , DATA_PLT_PAYMENT_MEANS   );
//	setFormValue(targetObj9 , DATA_PLT_AMOUNT_TYPE     );
//	setFormValue(targetObj10, DATA_TXT_FIXED_AMOUNT    );
	setFormValue(targetObj11, DATA_TXT_HOLDER_KANA     );
	setFormValue(targetObj12, DATA_TXT_HOLDER_NAME     );
	// 銀行名、支店名設定
	setInnerHtml(PRM_LBL_PAID_BANK_NAME   + targetIndex, DATA_LBL_PAID_BANK_NAME  );
	setInnerHtml(PRM_LBL_PAID_BRANCH_NAME + targetIndex, DATA_LBL_PAID_BRANCH_NAME);
	
	
	// 初期化
	DATA_PLT_CO_BANK_CODE     = "";
	DATA_LBL_PAID_BANK_NAME   = "";
	DATA_LBL_PAID_BRANCH_NAME = "";
	DATA_TXT_PAID_BANK_CODE   = "";
	DATA_TXT_PAID_BRANCH_CODE = "";
	DATA_PLT_ACCOUNT_TYPE     = "";
	DATA_TXT_ACCOUNT_NO       = "";
//	DATA_PLT_PAYMENT_MEANS    = "";
//	DATA_PLT_AMOUNT_TYPE      = "";
//	DATA_TXT_FIXED_AMOUNT     = "";
	DATA_BEF_TARGET_INDEX     = "";
	DATA_TXT_HOLDER_KANA      = "";
	DATA_TXT_HOLDER_NAME      = "";
}

/**
 * 銀行名設定
 * @param e
 * @return なし
 * @throws 実行時例外
 */
function setBankName(e) {
	// オブジェクト取得準備
	objBankCode   = null;
	objBankName   = null;
	objBranchCode = null;
	objBranchName = null;
	// 前ゼロ付与	
	setBeforeZeroObject(e, LEN_BANK_CODE)
	// オブジェクトの設定
	setFainanceObject(e);
	// 銀行名取得
	getBankName(objBankCode, objBankName);
	// 支店名取得
	getBranchName(objBankCode, objBranchCode, objBranchName);
}

/**
 * 支店名設定
 * @param e
 * @return なし
 * @throws 実行時例外
 */
function setBranchName(e) {
	// オブジェクト取得準備
	objBankCode   = null;
	objBankName   = null;
	objBranchCode = null;
	objBranchName = null;	
	// 前ゼロ付与	
	setBeforeZeroObject(e, LEN_BRANCH_CODE)
	// オブジェクトの設定
	setFainanceObject(e);
	// 支店名取得
	getBranchName(objBankCode, objBranchCode, objBranchName);
}

/**
 * 口座番号変更時
 * @param e
 * @return なし
 * @throws 実行時例外
 */
function onChangeAccountNo(e) {
	// 前ゼロ設定
	setBeforeZeroObject(e, LEN_ACCOUNT_NO)
}


/**
 * 前ゼロ付与オブジェクト設定
 * @param e
 * @param length
 * @return なし
 * @throws 実行時例外
 */
function setBeforeZeroObject(e, length) {
	// オブジェクトの設定
	var objTarget = getSrcElement(e);
	// 前ゼロ付与
	var befZero = setBeforeZero(objTarget, length);
	// 値の設定
	setFormValue(objTarget, befZero);
}


/**
 * 金融機関情報取得
 * @param e
 * @return なし
 * @throws 実行時例外
 */
function setFainanceObject(e) {
	// 銀行コード取得
	objTarget = getSrcElement(e);
	// 検索文字列設定(大文字小文字文字区別)
	var reg1 = new RegExp(PRM_LBL_PAID_BANK_NAME, "i");
	var reg2 = new RegExp(PRM_LBL_PAID_BRANCH_NAME, "i");
	
	
	// 対象オブジェクトの親ノードを取得
	var nodeParent = objTarget.parentNode;
	// 祖先ノード
	var nodeGrandParent = nodeParent.parentNode;
	// TBODY
	var nodeTbody = nodeGrandParent.parentNode;
	// TBODYのノード
	for (var i in nodeTbody.childNodes) {
		if (
			objBankCode   == null||
			objBankName   == null||
			objBranchCode == null||
			objBranchName == null	) {
			var obj1=nodeTbody.childNodes[i];
			if(obj1!=null && obj1.nodeName == "TR"){
				for (var j in obj1.childNodes) {
					if (
						objBankCode   == null ||
						objBankName   == null ||
						objBranchCode == null ||
						objBranchName == null 
					) {
						var obj2 = obj1.childNodes[j];
						if(obj2!=null && obj2.nodeName == "TD"){
							for (var k in obj2.childNodes) {
								var obj3 = obj2.childNodes[k];

								if(obj3!=null && obj3.name == PRM_TXT_PAID_BANK_CODE){
									// 銀行コードオブジェクトを取得する。
									objBankCode = obj3;
									continue;
								}
								if(obj3!=null && obj3.nodeName == "SPAN"){
									if (obj3.id.search(reg1) != -1) {
										// 銀行名コードオブジェクトを取得する。
										objBankName = obj3;
										continue;
									}
								}
								if(obj3!=null && obj3.name == PRM_LBL_PAID_BANK_NAME){
									// 銀行名コードオブジェクトを取得する。
									objBankName = obj3;
									continue;
								}
								if(obj3!=null && obj3.name == PRM_TXT_PAID_BRANCH_CODE){
									// 支店コードオブジェクトを取得する。
									objBranchCode = obj3;
									continue;
								}
								if(obj3!=null && obj3.nodeName == "SPAN"){
									if (obj3.id.search(reg2) != -1) {
										// 支店支店名オブジェクトを取得する。
										objBranchName = obj3;
										continue;
									}
								}
							}
						}
					}
				}			
			}
		}
	}
}

/**
 * 銀行名取得
 * @param objBankCode
 * @param objBankName
 * @return なし
 * @throws 実行時例外
 */
function getBankName(objBankCode, objBankName) {
	// 銀行名オブジェクト取得
	var bankCode = getFormValue(objBankCode);
	for (var i = 0; i < aryJsBankCode.length; i++) {
		if (bankCode == aryJsBankCode[i]) {
			if (objBankName != null) {
				setInnerHtml(objBankName, aryJsBankName[i]);
			}
			break;
		}
		// 不一致の場合はコード
		if (i == aryJsBankCode.length - 1) {
			setInnerHtml(objBankName, bankCode);
		}
	}
}

/**
 * 支店名取得
 * @param objBankCode
 * @param objBranchCode
 * @param objBranchName
 * @return なし
 * @throws 実行時例外
 */
function getBranchName(objBankCode, objBranchCode, objBranchName) {
	// 対象銀行コード
	var bankCode = getFormValue(objBankCode);
	// 対象支店コード
	var branchCode = getFormValue(objBranchCode);
	for (var i = 0; i < aryJsBranchCode.length; i++) {
		// 銀行コード確認
		if (bankCode == aryJsBraBankCode[i]) {
			// 支店コード確認
			if (branchCode == aryJsBranchCode[i]) {
				setInnerHtml(objBranchName, aryJsBranchName[i]);
				break;
			}
		}
		// 不一致の場合はコード
		if (i == aryJsBranchCode.length - 1) {
			setInnerHtml(objBranchName, branchCode);
		}
	}
}

/**
 * 前ゼロ付与
 * @param targetNo　　対象文字列
 * @param targetLength　項目長
 * @return
 */
function setBeforeZero(targetNo, targetLength) {
	// 設定準備
	var retString = "";
	// 対象が空じゃなければ前ゼロ設定
	if (getFormValue(targetNo) !="") {
		retString = getZero(getFormValue(targetNo), targetLength);
	}
	return retString;
	
}

/**
 * 引数に設定した文字列の先頭に0を挿入する。
 * @param wspace 設定文字列
 * @param i      設定桁数
 * @return       ゼロ挿入後文字列
 */
function getZero(wspace, i) {
	// 設定準備
	var lenString = 0;
	var targetString = "";
	lenString = i - wspace.length;
	if (lenString > 0) {
		for (var w = 0; w < lenString; w++) {
			targetString += "0";
		}
	}
	return targetString + wspace;
}
