/**
 * 画面読込時追加処理
 * @param 無し
 * @return 無し
 * @throws 実行時例外
 */
function onLoadExtra() {
	// 項目背景色設定
	setFieldsBgColor(ARY_FIELDS_ID    , COLOR_FIELD_NORMAL);
	setFieldsBgColor(ARY_ERR_FIELDS_ID, COLOR_FIELD_ERROR );
	// 項目長設定
	setMaxLength(PRM_TXT_STATUTORY_HOUR 		, LEN_STATUTORY);
	setMaxLength(PRM_TXT_STATUTORY_WEEK 		, LEN_STATUTORY);
	setMaxLength(PRM_TXT_STATUTORY_MONTH_HOURS	, LEN_STATUTORY);
	setMaxLength(PRM_TXT_STATUTORY_MONTH_DAYS 	, LEN_STATUTORY);
	setMaxLength(PRM_TXT_CALCULATION_DAYS 		, LEN_DAYS);
	setMaxLength(PRM_TXT_PROVIDED_DAYS 			, LEN_DAYS);
	setMaxLength(PRM_TXT_INPUT_UNIT_TIMES 		, LEN_TIME);
	setMaxLength(PRM_TXT_ALL_HOLIDAY_HOUR 		, LEN_TIME);
	setMaxLength(PRM_TXT_ALL_HOLIDAY_MIN 		, LEN_TIME);
	setMaxLength(PRM_TXT_HALF_HOLIDAY_HOUR 		, LEN_TIME);
	setMaxLength(PRM_TXT_HALF_HOLIDAY_MIN 		, LEN_TIME);
	setMaxLength(PRM_TXT_LATE_NIGHT_START_HOUR 	, LEN_TIME);
	setMaxLength(PRM_TXT_LATE_NIGHT_START_MIN 	, LEN_TIME);
	setMaxLength(PRM_TXT_LATE_NIGHT_TIME_HOUR 	, LEN_TIME);
	setMaxLength(PRM_TXT_LATE_NIGHT_TIME_MIN 	, LEN_TIME);
	
	setMaxLength(PRM_TXT_PASSWORD_TERM 	, LEN_DAYS);
	// フォーカス設定
	setFocus(PRM_TXT_STATUTORY_HOUR);
}

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

/**
 * 入力チェック
 * @param 無し
 * @return チェック結果(true：OK、false：NG)
 * @throws 実行時例外
 */
function validate() {
	// フィールド背景色設定
	setFieldsBgColor(ARY_FIELDS_ID, COLOR_FIELD_NORMAL);
	// 入力チェック
	var aryMessage = new Array();
	checkRequired(PRM_TXT_STATUTORY_HOUR		, NAM_STATUTORY_HOUR			, aryMessage);
	checkRequired(PRM_TXT_STATUTORY_WEEK		, NAM_STATUTORY_WEEK			, aryMessage);
	checkRequired(PRM_TXT_STATUTORY_MONTH_HOURS	, NAM_STATUTORY_MONTH_HOURS		, aryMessage);
	checkRequired(PRM_TXT_STATUTORY_MONTH_DAYS	, NAM_STATUTORY_MONTH_DAYS		, aryMessage);
	checkRequired(PRM_TXT_CALCULATION_DAYS		, NAM_CALCULATION				, aryMessage);
	checkRequired(PRM_TXT_PROVIDED_DAYS			, NAM_PROVIDED					, aryMessage);
	checkRequired(PRM_TXT_INPUT_UNIT_TIMES		, NAM_INPUT_UNIT_TIMES			, aryMessage);
	checkRequired(PRM_TXT_ALL_HOLIDAY_HOUR		, NAM_HOLIDAY_HOURS_ALL_HOUR	, aryMessage);
	checkRequired(PRM_TXT_ALL_HOLIDAY_MIN		, NAM_HOLIDAY_HOURS_ALL_MIN		, aryMessage);
	checkRequired(PRM_TXT_HALF_HOLIDAY_HOUR		, NAM_HOLIDAY_HOURS_HALF_HOUR	, aryMessage);
	checkRequired(PRM_TXT_HALF_HOLIDAY_MIN		, NAM_HOLIDAY_HOURS_HALF_MIN	, aryMessage);
	checkRequired(PRM_TXT_LATE_NIGHT_START_HOUR	, NAM_LATE_NIGHT_START_HOUR		, aryMessage);
	checkRequired(PRM_TXT_LATE_NIGHT_START_MIN	, NAM_LATE_NIGHT_START_MIN		, aryMessage);
	checkRequired(PRM_TXT_LATE_NIGHT_TIME_HOUR	, NAM_LATE_NIGHT_HOURS_HOUR		, aryMessage);
	checkRequired(PRM_TXT_LATE_NIGHT_TIME_MIN	, NAM_LATE_NIGHT_HOURS_MIN		, aryMessage);

	checkDecimal(PRM_TXT_STATUTORY_HOUR 		, LEN_INTEGER2 , LEN_DECIMAL , NAM_STATUTORY_HOUR 			, aryMessage);
	checkDecimal(PRM_TXT_STATUTORY_WEEK 		, LEN_INTEGER3 , LEN_DECIMAL , NAM_STATUTORY_WEEK 			, aryMessage);
	checkDecimal(PRM_TXT_STATUTORY_MONTH_HOURS 	, LEN_INTEGER3 , LEN_DECIMAL , NAM_STATUTORY_MONTH_HOURS 	, aryMessage);
	checkDecimal(PRM_TXT_STATUTORY_MONTH_DAYS 	, LEN_INTEGER2 , LEN_DECIMAL , NAM_STATUTORY_MONTH_DAYS 	, aryMessage);
	
	checkNumber(PRM_TXT_CALCULATION_DAYS		, NAM_CALCULATION				, aryMessage);
	checkNumber(PRM_TXT_PROVIDED_DAYS			, NAM_PROVIDED					, aryMessage);
	checkNumber(PRM_TXT_INPUT_UNIT_TIMES		, NAM_INPUT_UNIT_TIMES			, aryMessage);
	checkNumber(PRM_TXT_ALL_HOLIDAY_HOUR		, NAM_HOLIDAY_HOURS_ALL_HOUR	, aryMessage);
	checkNumber(PRM_TXT_ALL_HOLIDAY_MIN			, NAM_HOLIDAY_HOURS_ALL_MIN		, aryMessage);
	checkNumber(PRM_TXT_HALF_HOLIDAY_HOUR		, NAM_HOLIDAY_HOURS_HALF_HOUR	, aryMessage);
	checkNumber(PRM_TXT_HALF_HOLIDAY_MIN		, NAM_HOLIDAY_HOURS_HALF_MIN	, aryMessage);
	checkNumber(PRM_TXT_LATE_NIGHT_START_HOUR	, NAM_LATE_NIGHT_START_HOUR		, aryMessage);
	checkNumber(PRM_TXT_LATE_NIGHT_START_MIN	, NAM_LATE_NIGHT_START_MIN		, aryMessage);
	checkNumber(PRM_TXT_LATE_NIGHT_TIME_HOUR	, NAM_LATE_NIGHT_HOURS_HOUR		, aryMessage);
	checkNumber(PRM_TXT_LATE_NIGHT_TIME_MIN		, NAM_LATE_NIGHT_HOURS_MIN		, aryMessage);
	//時間、分の合計値チェック
	checkTimeValue(PRM_TXT_ALL_HOLIDAY_HOUR		,PRM_TXT_ALL_HOLIDAY_MIN		, 24 , NAM_HOLIDAY_HOURS_ALL	,aryMessage);
	checkTimeValue(PRM_TXT_HALF_HOLIDAY_HOUR	,PRM_TXT_HALF_HOLIDAY_MIN		, 24 , NAM_HOLIDAY_HOURS_HALF	,aryMessage);
	checkTimeValue(PRM_TXT_LATE_NIGHT_START_HOUR,PRM_TXT_LATE_NIGHT_START_MIN	, 36 , NAM_LATE_NIGHT_START		,aryMessage);
	checkTimeValue(PRM_TXT_LATE_NIGHT_TIME_HOUR	,PRM_TXT_LATE_NIGHT_TIME_MIN	, 24 , NAM_LATE_NIGHT_HOURS		,aryMessage);

	//勤怠締日
	var calcDay = getFormValue(PRM_TXT_CALCULATION_DAYS);
	if ((calcDay > 31) || (calcDay < 0)) {
		setBgColor(PRM_TXT_CALCULATION_DAYS, COLOR_FIELD_ERROR);
		aryMessage.push(getMessage("WC0006", NAM_CALCULATION));
	}
	
	//給与支給日
	var provide = getFormValue(PRM_TXT_PROVIDED_DAYS);
	if ((provide > 31) || (provide < 1)) {
		setBgColor(PRM_TXT_PROVIDED_DAYS, COLOR_FIELD_ERROR);
		aryMessage.push(getMessage("WC0006", NAM_PROVIDED));
	}
	
	//入力単位
	var unit = getFormValue(PRM_TXT_INPUT_UNIT_TIMES);
	if ((unit > 60) || (unit < 1)) {
		setBgColor(PRM_TXT_INPUT_UNIT_TIMES, COLOR_FIELD_ERROR);
		aryMessage.push(getMessage("WC2029", NAM_INPUT_UNIT_TIMES));
	}

	//一日所定労働時間
	var statutoryHour = getFormValue(PRM_TXT_STATUTORY_HOUR);
	if ((statutoryHour > 24) || (statutoryHour < 0.5)) {
		setBgColor(PRM_TXT_STATUTORY_HOUR, COLOR_FIELD_ERROR);
		aryMessage.push(getMessage("WC0007", NAM_STATUTORY_HOUR));
	}

	//週間所定労働時間
	var statutoryWeek = getFormValue(PRM_TXT_STATUTORY_WEEK);
	if ((statutoryWeek > 168) || (statutoryWeek < 0.5)) {
		setBgColor(PRM_TXT_STATUTORY_WEEK, COLOR_FIELD_ERROR);
		aryMessage.push(getMessage("WC0007", NAM_STATUTORY_WEEK));
	}
	
	//月間所定労働時間
	var statutoryMonth = getFormValue(PRM_TXT_STATUTORY_MONTH_HOURS);
	if ((statutoryMonth > 744) || (statutoryMonth < 0.5)) {
		setBgColor(PRM_TXT_STATUTORY_MONTH_HOURS, COLOR_FIELD_ERROR);
		aryMessage.push(getMessage("WC0007", NAM_STATUTORY_MONTH_HOURS));
	}

	//月間所定労働日数
	var statutoryDays = getFormValue(PRM_TXT_STATUTORY_MONTH_DAYS);
	if ((statutoryDays > 31) || (statutoryDays < 1)) {
		setBgColor(PRM_TXT_STATUTORY_MONTH_DAYS, COLOR_FIELD_ERROR);
		aryMessage.push(getMessage("WC0005", NAM_STATUTORY_MONTH_DAYS));
	}

	//全休・半休比較チェック
	var allHoliday = (getFormValue(PRM_TXT_ALL_HOLIDAY_HOUR) * 60 ) + eval(getFormValue(PRM_TXT_ALL_HOLIDAY_MIN));
	var halfHoliday = (getFormValue(PRM_TXT_HALF_HOLIDAY_HOUR) * 60 ) + eval(getFormValue(PRM_TXT_HALF_HOLIDAY_MIN));
	if (halfHoliday > allHoliday) {
		aryMessage.push("半休は全休時間数を超えないでください。");
	}

	checkRegLength(PRM_TXT_INPUT_UNIT_TIMES, LEN_TIME, NAM_INPUT_UNIT_TIMES, aryMessage);

	checkRequired(PRM_TXT_PASSWORD_TERM	, NAM_PASSWORD_TERM		, aryMessage);
	checkNumber(PRM_TXT_PASSWORD_TERM	, NAM_PASSWORD_TERM		, aryMessage);

	if (aryMessage.length == 0) {
		return true;
	} else {
		showMessage(aryMessage);
		return false;
	}
}
