/*
 * 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.
 */
/**
 * 画面読込時追加処理
 * @param 無し
 * @return 無し
 * @throws 実行時例外
 */
function onLoadExtra() {
	// 項目背景色設定
	setFieldsBgColor(ARY_FIELDS_ID,     COLOR_FIELD_NORMAL);
	setFieldsBgColor(ARY_ERR_FIELDS_ID, COLOR_FIELD_ERROR);
	// 項目長設定
	setMaxLength(PRM_TXT_OLD_PASSWORD, LEN_PASSWORD);
	setMaxLength(PRM_TXT_NEW_PASSWORD, LEN_PASSWORD);
	setMaxLength(PRM_TXT_CONFIRM_PASS, LEN_PASSWORD);
	// フォーカス設定
	if (ARY_FIELDS_ID.length > 0) {
		setFocus(ARY_FIELDS_ID[0]);
	}
	//強制パスワード変更判定 
	if (MODE == 1) {
		setVisibility("btnMenu", false);
	} 
}

/**
 * サーバー通信時処理
 * @param objForm フォームオブジェクト
 * @param cmd     コマンド
 * @return 無し
 * @throws 実行時例外
 */
function submitForm(objForm, cmd) {
	// フィールド背景色設定
	setFieldsBgColor(ARY_FIELDS_ID, COLOR_FIELD_NORMAL);
	// 入力チェック
	var aryMessage = new Array();
	checkRequired (PRM_TXT_OLD_PASSWORD, NAM_OLD_PASSWORD, aryMessage);
	checkRequired (PRM_TXT_NEW_PASSWORD, NAM_NEW_PASSWORD, aryMessage);
	checkRequired (PRM_TXT_CONFIRM_PASS, NAM_CONFIRM_PASS, aryMessage);
	checkCode     (PRM_TXT_OLD_PASSWORD, NAM_OLD_PASSWORD, aryMessage);

	checkMinLength(PRM_TXT_NEW_PASSWORD, LEN_MIN_PASSWORD, NAM_NEW_PASSWORD, aryMessage)
	checkMinLength(PRM_TXT_CONFIRM_PASS, LEN_MIN_PASSWORD, NAM_CONFIRM_PASS, aryMessage)
	checkCompare  (PRM_TXT_NEW_PASSWORD, PRM_TXT_CONFIRM_PASS, 0, NAM_CONFIRM_PASS, aryMessage);
	
	checkCode     (PRM_TXT_NEW_PASSWORD, NAM_NEW_PASSWORD, aryMessage);
	checkCode     (PRM_TXT_CONFIRM_PASS, NAM_CONFIRM_PASS, aryMessage);

	if (aryMessage.length != 0) {
		showMessage(aryMessage);
		return false;
	}
	// サーバー通信
	setFormValue(PRM_HDN_OLD_PASSWORD, encrypt(getFormValue(PRM_TXT_OLD_PASSWORD)));
	setFormValue(PRM_HDN_NEW_PASSWORD, encrypt(getFormValue(PRM_TXT_NEW_PASSWORD)));
	setFormValue(PRM_HDN_CONFIRM_PASS, encrypt(getFormValue(PRM_TXT_CONFIRM_PASS)));
	setFormValue(PRM_TXT_OLD_PASSWORD, getDummy(getFormValue(PRM_TXT_OLD_PASSWORD)));
	setFormValue(PRM_TXT_NEW_PASSWORD, getDummy(getFormValue(PRM_TXT_NEW_PASSWORD)));
	setFormValue(PRM_TXT_CONFIRM_PASS, getDummy(getFormValue(PRM_TXT_CONFIRM_PASS)));
	doSubmitMessage(objForm, cmd, 'QC0001', '');
}
