/*
 * MosP - Mind Open Source Project    http://www.mosp.jp/
 * Copyright (C) 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 KEY_SEPARATOR      = ",";

/**
 * 画面読込時追加処理
 * @param 無し
 * @return 無し
 * @throws 実行時例外
 */
function onLoadExtra() {
	// 項目背景色設定
	setFieldsBgColor(ARY_FIELDS_ID,     COLOR_FIELD_NORMAL);
	setFieldsBgColor(ARY_ERR_FIELDS_ID, COLOR_FIELD_ERROR);
	// 項目長設定
	setMaxLength(PRM_TXT_HOLIDAY_COMMENT	, LEN_COMMENT);
	// フォーカス設定(EDITの場合)
	setFocus(PRM_PLT_HOLIDAY_REASON);
	// モードタイトル
	setModeLabel();
/*	switch (MODE) {
		case 0:
			setInnerHtml('spnMode', NAM_MODE_INSERT);
			break;
		case 1:
			setInnerHtml('spnMode', NAM_MODE_EDIT);
			break;
		case 2:
			setInnerHtml('spnMode', NAM_MODE_APPROVED);
			setColor('spnMode', COLOR_MSG_WARNING);
			break;		
		default:
	}
 */
	// 登録ボタン利用可否
	if (MODE == 2) {
		setVisibility("btnRegist", false);
		setWidth("btnRegist", 0);
		setVisibility("btnReflect", false);
	}
	// 削除ボタン利用可否
	if (MODE != 1) {
		setVisibility("btnDelete", false);
		setWidth("btnDelete", 0);
	}
	// 入力ボタン利用可否
	if (MODE == 0) {
		setVisibility("btnHoliday", false);
		setVisibility("btnQuit", false);	
		setVisibility("btnCheck", false);
	} else {
		setVisibility("btnStart", false);
		setVisibility("btnQuit", false);	
		setVisibility("btnCheck", false);
	}
	// 下書き
	if (!isDraft) {
		setVisibility("btnDraft", false);
	}
}

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

/**
 * 入力チェック
 * @param 無し
 * @return チェック結果(true：OK、false：NG)
 * @throws 実行時例外
 */
function validate() {
	// フィールド背景色設定
	setFieldsBgColor(ARY_FIELDS_ID, COLOR_FIELD_NORMAL);
	// 入力チェック
	var aryMessage = new Array();
	if (getFormValue(PRM_PLT_SUBSTITUTE_YEAR) != "" 
			|| getFormValue(PRM_PLT_SUBSTITUTE_MONTH) != "" 
			|| getFormValue(PRM_PLT_SUBSTITUTE_DAY) != ""
	) {
		checkDate(PRM_PLT_SUBSTITUTE_YEAR, PRM_PLT_SUBSTITUTE_MONTH, PRM_PLT_SUBSTITUTE_DAY, NAM_SUBSTITUTE_HOLIDAY, aryMessage);
	}
	if (aryMessage.length == 0) {
		return true;
	} else {
		showMessage(aryMessage);
		return false;
	}
}
