PageSourceSearch

https://ec.shop.acure-fun.net/contents/js/eltex.standard.js?var=20260926_y

js acure-fun.net collected 2026-09-26 01:05:15 UTC 113,682 bytes, 3,626 lines download raw bytes

1/**
2 * eltex.standard: WebSystemGenerator用JavaScript定義ファイルです。
3 * standard.jsのfunctionを利用しています。
4 * 著作権 : Copyright (c) 2011 ELTEX, Inc. All Rights Reserved.<br />
5 * 会社名 : ELTEX, Inc.<br />
6 * 履歴   : 2011/02/25, 1.0.0, Jiro Saito, Created
7 * @since 2011/02/25
8 * @version 1.0.0
9 */
10
11/**
12 * リストを初期化し、返却します。
13 * @param form フォーム
14 * @param tableId リストID
15 * @returns 初期化されたリスト
16 */
17function initStandardList(form, tableId, depth) {
18    if (form == null || form == undefined) {
19        return null;
20    }
21
22    var tableElements = new Array();
23    var table = document.getElementById(tableId);
24    if (table != null && table != undefined) {
25    	tableElements[0] = table;
26    } else {
27        tableElements[0] = new Array();
28    	tableElements = getTableElements(tableElements, tableId, 0, depth);
29    }
30
31    // 明細in明細対応
32    if (tableElements != null && tableElements[0] != null && tableElements[0] != undefined) {
33    	var list = new StandardList(tableId, tableElements);
34    	var selectedIndexId = tableId + "SelectedIndex";
35    	var element = form.elements[selectedIndexId];
36    	if (element != null && element != undefined) {
37    		var selectedIndex = parseInt(element.value);
38    		selectListByIndex(form, list, selectedIndex);
39    	} else {
40    		setSelectedIndex(list, tableElements, "", 0, depth);
41    	}
42
43    	// sortIcon
44    	setSortIcon(tableId);
45
46        return list;
47    }
48}
49
50function setSortIcon(tableId) {
51	var sortTypeList = makeSortTypeList(tableId);
52	for (var i = 0; i < sortTypeList.length; i++) {
53		var sortType = sortTypeList[i];
54		var sortLinkThId = tableId + capitalize(sortType.columnName) + "TitleLink";
55		var sortLinkThElement = document.getElementById(sortLinkThId);
56		if (isNullorUndefined(sortLinkThElement)) {
57			continue;
58		}
59
60		if (sortType.sortType == "DESC") {
61			sortLinkThElement.className = "sortIconDesc sortOrderDesc" + i;
62		} else {
63			sortLinkThElement.className = "sortIconAsc sortOrderAsc" + i;
64		}
65	}
66}
67
68/**
69 * 対象テーブルIDのソートカラムのhidden領域を取得し、ソート順にリストでソート状態を取得します。
70 * ソート状態は、
71 *  columnName: カラム名
72 *  sortType: ASC or DESC
73 * で取得できます。
74 * @param tableId 対象テーブルID
75 * @returns ソート状態のリスト
76 */
77function makeSortTypeList(tableId) {
78	var sortTypeList = new Array();
79   	var sortColumnId = tableId + "SortColumn";
80   	var sortColumnElement = document.getElementById(sortColumnId);
81   	if (sortColumnElement == null || sortColumnElement == undefined) {
82   		return sortTypeList;
83   	}
84   	var sortColumnValue = sortColumnElement.value;
85	if (!isNullorUndefinedorEmpty(sortColumnValue)) {
86		var sortColumnAndTypes = sortColumnValue.split(",");
87		for (var i = 0; i < sortColumnAndTypes.length; i++) {
88			var sortColumnAndType = sortColumnAndTypes[i];
89			if (isNullorUndefinedorEmpty(sortColumnAndType)) {
90				continue;
91			}
92
93			// trim
94			sortColumnAndType = sortColumnAndType.replace(/^[\s]+|[\s]+$/g, "");
95
96			var separateSortColumnAndType = sortColumnAndType.split(":");
97			var sortColumnString = separateSortColumnAndType[0];
98			var sortTypeValue = "ASC";
99			if (separateSortColumnAndType.length > 1) {
100				sortTypeValue = separateSortColumnAndType[1];
101			}
102
103			var sortColumnType = new Object();
104			sortColumnType.columnName = sortColumnString;
105			sortColumnType.sortType = sortTypeValue;
106			sortTypeList.push(sortColumnType);
107		}
108	}
109	return sortTypeList;
110}
111
112/**
113 * 該当IDのテーブルエレメントを再帰的に全て取得します。
114 * @param elements テーブルエレメントの多次元配列
115 * @param tableId 基本テーブルID
116 * @param index 探索中インデックス
117 * @param depth 残りの深さ
118 * @returns 渡されたエレメント以下の全てのテーブルエレメントの多次元配列
119 */
120function getTableElements(elements, tableId, index, depth) {
121	if (depth > 0  && !isNullorUndefined(elements)) {
122		elements[index] = getTableElements(elements[index], tableId + "_" + index, 0, depth - 1);
123		if (elements[index] != null && elements[index] != undefined) {
124			if (depth > 1) {
125				elements[index + 1] = new Array();
126			}
127			elements = getTableElements(elements, tableId, index + 1, depth);
128			if (elements == null) {
129				return null;
130			}
131		} else {
132			elements.length = index;
133		}
134		return elements.length > 0 ? elements : null;
135	} else {
136		return document.getElementById(tableId);
137	}
138}
139
140/**
141 * 該当テーブルの選択行を再帰的に全て設定します。
142 * @param list StandardList
143 * @param elements テーブルエレメント配列
144 * @param symbol インデックスシンボル
145 * @param index 現在インデックス
146 * @param depth 現在深さ
147 */
148function setSelectedIndex(list, elements, symbol, index, depth) {
149	if (depth > 0) {
150		var array = elements[index];
151		if (!isNullorUndefined(array)) {
152			var newSymbol = symbol + "_" + index;
153			setSelectedIndex(list, array, newSymbol, 0, depth - 1);
154			setSelectedIndex(list, elements, symbol, index + 1, depth);
155		}
156	} else {
157		var indexElement = document.getElementById(list.tableId + "SelectedIndex" + symbol);
158		if (!isNullorUndefined(indexElement) && !isNullorUndefinedorEmpty(indexElement.value)) {
159			var rowId = list.tableId + "Row" + symbol + "_" + indexElement.value;
160			if (!isNullorUndefined(elements.rows)) {
161				list.selectRow(elements.rows.namedItem(rowId));
162			}
163		}
164	}
165}
166
167/**
168 * Getパラメータに従って、フォーカスを設定します。
169 */
170function initFocus() {
171	var focusParameterName = "focusItemId";
172	var focusIdItem = document.getElementById(focusParameterName);
173	if (isNullorUndefined(focusIdItem) || isNullorUndefinedorEmpty(focusIdItem.value)) {
174		return;
175	}
176	focusToItem(focusIdItem.value);
177}
178
179/**
180 * 指定されたID,Nameを持った画面状態を保存します。
181 * オブジェクトの以下のプロパティに状態が保存さã
181‚Œã¾ã™ã€‚
182 *  texts: テキストの値
183 *  checks: チェックの状態(ラジオボタン、チェックボックスのチェック状態が配列で保存)
184 *  selects: 選択の状態(コンボボックスの選択インデックスの値)
185 * @param form フォーム
186 * @param textIds
187 * @param checkBoxNames
188 * @param comboBoxIds
189 * @param radioNames
190 * @returns 保存されたオブジェクト
191 */
192function saveScreenObject(form, textIds, checkBoxNames, comboBoxIds, radioNames) {
193    if (form == null || form == undefined) {
194        return null;
195    }
196
197    var saveObject = new Object();
198
199    var texts = new Object();
200    var checks = new Object();
201    var selects = new Object();
202
203    saveObject.texts = texts;
204    saveObject.checks = checks;
205    saveObject.selects = selects;
206
207    // text
208    if (textIds != null && textIds != undefined) {
209        for (var i = 0; i < textIds.length; i++) {
210            var textId = textIds[i];
211            var element = document.getElementById(textId);
212            if (element != null && element != undefined) {
213                texts[textId] = element.value;
214            }
215        }
216    }
217
218    // radio
219    if (radioNames != null && radioNames != undefined) {
220        for (var i = 0; i < radioNames.length; i++) {
221            var radioName = radioNames[i];
222            var element = form[radioName];
223            if (element != null && element != undefined) {
224                var radioChecks = new Array();
225                for (var j = 0, e; e = form[radioName][j]; j++) {
226                    radioChecks[j] = e.checked;
227                }
228                checks[radioName] = radioChecks;
229            }
230        }
231    }
232
233    // checkbox
234    if (checkBoxNames != null && checkBoxNames != undefined) {
235        for (var i = 0; i < checkBoxNames.length; i++) {
236            var checkBoxName = checkBoxNames[i];
237            var element = form[checkBoxName];
238            if (element != null && element != undefined) {
239                var checkBoxChecks = new Array();
240                for (var j = 0, e; e = form[checkBoxName][j]; j++) {
241                    checkBoxChecks[j] = e.checked;
242                }
243                checks[checkBoxName] = checkBoxChecks;
244            }
245        }
246    }
247
248    // combobox
249    if (comboBoxIds != null && comboBoxIds != undefined) {
250        for (var i = 0; i < comboBoxIds.length; i++) {
251            var comboBoxId = comboBoxIds[i];
252            var element = document.getElementById(comboBoxId);
253            if (element != null && element != undefined) {
254            	if (!isNullorUndefined(element.multiple) && !element.multiple) {
255	                selects[comboBoxId] = element.selectedIndex;
256	            } else {
257	                var multipleSelects = new Array();
258	                for (var j = 0; j < element.options.length; j++) {
259	                    multipleSelects[j] = element.options[j].selected;
260	                }
261	                selects[comboBoxId] = multipleSelects;
262	            }
263            }
264        }
265    }
266
267    return saveObject;
268}
269
270/**
271 * 指定された画面状態に戻します。
272 * screenObjectには、以下のプロパティで保存されているものとします。
273 * saveScreenObjectで保存されたオブジェクトです。
274 *  texts: テキストの値
275 *  checks: チェックの状態(ラジオボタン、チェックボックスのチェック状態が配列で保存)
276 *  selects: 選択の状態(コンボボックスの選択インデックスの値)
277 * @param form フォーム
278 * @param screenObject 画面状態オブジェクト
279 */
280function resetScreenObject(form, screenObject) {
281    if (isNullorUndefined(form)) {
282        return;
283    }
284
285    if (isNullorUndefined(saveScreenObject)) {
286        return;
287    }
288
289    var texts = screenObject.texts;
290    if (!isNullorUndefined(texts)) {
291        for (var textId in texts) {
292            var element = document.getElementById(textId);
293            if (!isNullorUndefined(element)) {
294                element.value = texts[textId];
295            }
296        }
297    }
298
299    var selects = screenObject.selects;
300    if (!isNullorUndefined(selects)) {
301        for (var selectId in selects) {
302            var element = document.getElementById(selectId);
303           	if (!isNullorUndefined(element.multiple) && !element.multiple) {
304	            if (!isNullorUndefined(elements)) {
305	                element.selectedIndex = selects[selectId];
306	            }
307	        } else {
308                var selectArray = selects[selectId];
309                if (!isNullorUndefined(selectArray)) {
310                	for (var i = 0; i < element.options.length; i++) {
311                		if (selectArray.length > i) {
312		                	element.options[i].selected = selectArray[i];
313		                }
314                	}
315                }
316	        }
317        }
318    }
319
320    var checks = screenObject.checks;
321    if (!isNullorUndefined(checks)) {
322        for (var checkName in checks) {
323            var elements = form[checkName];
324            if (!isNullorUndefined(element)) {
325                var checkArray = checks[checkName];
326	            if (!isNullorUndefined(checkArray)) {
327                    for (var i = 0, e; e = elements[i]; i++) {
328                		if (checkArray.length > i) {
329	                        e.checked = checkArray[i];
330	                    }
331                    }
332                }
333            }
334        }
335    }
336}
337
338/**
339 * 指定されたリストの行をインデックスを指定して選択します。
340 * @param form フォーム
341 * @param list StandardListオブジェクト
342 * @param index 行インデックス
343 * @param indexSymbol インデックスシンボル
344 */
345function selectListByIndex(form, list, index, indexSymbol) {
346    if (form == null || form == undefined) {
347        return;
348    }
349
350    if (list == null || list == undefined) {
351        return;
352    }
353
354    if (index != null && index != undefined) {
355        var selectedIndex = parseInt(index);
356        var selectedRow = null;
357        if (selectedIndex.toString() != "NaN" || indexSymbol != undefined) {
358            var listId = list.tableId;
359        	if (indexSymbol == undefined) {
360	            selectedRow = listId + "Row_" + selectedIndex;
361        	} else {
362        		selectedRow = listId + "Row" + indexSymbol;
363        	}
364            var rowElement = document.getElementById(selectedRow);
365            if (rowElement != null && rowElement != undefined) {
366                list.selectRowById(selectedRow);
367               	var parentIndexSymbol = getParentIndexSymbol(indexSymbol);
368                var selectedIndexId = listId + "SelectedIndex" + parentIndexSymbol;
369                var selected = form.elements[selectedIndexId];
370                if (selected != null && selected != undefined) {
371                    selected.value = index.toString();
372                }
373            }
374        }
375    }
376}
377
378/**
379 * リストの指定されたページへ移動します。
380 * @param form フォーム
381 * @param list StandardListオブジェクト
382 * @param action submitで送信されるアクションの種類
383 * @param page ページ番号
384 * @param indexSymbol インデックスシンボル
385 */
386function changePage(form, list, action, page, indexSymbol) {
387    if (form == null || form == undefined) {
388        return;
389    }
390
391    if (list == null || list == undefined) {
392        return;
393    }
394
395    if (isNullorUndefined(indexSymbol)) {
396    	indexSymbol = "";
397    }
398    var currentPageName = list.tableId + "ShowPageNumber" + indexSymbol;
399    var currentPage = form.elements[currentPageName]
400    if (currentPage == null) {
401        return false;
402    }
403    var pageNumber;
404    Validator.init(currentPage);
405    try {
406        pageNumber = new ExNumber(page);
407    } catch (e) {
408        // 数字以外の文字が入力された場合
409        Validator.output(currentPage, e.message);
410        return false;
411    }
412
413    if (page < 1) {
414        page = 1
415    }
416
417    // Formへの入力値を元に戻す(最後に検索された条件でページング)
418    var preCriteria = list.criteria;
419    if (preCriteria != null && preCriteria != undefined) {
420        resetScreenObject(form, preCriteria);
421    }
422
423    var actionTypeValue = "paging";
424    if (!isNullorUndefined(action)) {
425    	actionTypeValue = action;
426    }
427
428    var actionType = form["a"];
429    if (!isNullorUndefined(actionType)) {
430        actionType.value = actionTypeValue;
431    }
432
433    currentPage.value = pageNumber.toString();
434    form.submit();
435}
436
437var isSubmitWaiting = false;
438
439/**
440 * サブミット処理です。
441 * @param action アクションの種類
442 * @param sender 送信オブジェクト
443 * @param timeout タイムアウト時間(msec)
444 * @param waitDialogValidTime submitからWaitDialog表示までの時間(msec)
445 */
446function submit(action, sender, timeout, waitDialogValidTime) {
447	if (isSubmitWaiting) {
448		return;
449	}
450	isSubmitWaiting = true;
451    var form = document.forms["formMain"];
452    if (form != null && form != undefined) {
453        var actionType = form.elements["a"];
454        if (actionType != null && actionType != undefined) {
455            if (!isNullorUndefined(action)) {
456	            actionType.value = action;
457            }
458
459            if (isNullorUndefined(timeout)) {
460            	// 設定なしの場合30秒
461            	timeout = 30000;
462            }
463
464            // 多重リクエスト防止
465            var changedTargetIdList = changeDisableButton(form, true, null);
466            setTimeout(function() {
467            	changeDisableButton(form, false, changedTargetIdList);
468            	isSubmitWaiting = false;
469            }, timeout);
470
471            form.submit();
472
473            if (isNullorUndefined(waitDialogValidTime)) {
474            	// 設定なければ、0.5秒
475            	waitDialogValidTime = 500;
476            }
477
478            if (waitDialogValidTime >= 0) {
479	            setTimeout(function() {
480	            	// waitDialogValidTime(ms)以上かかる処理があればWaitDialogを表示
481					showWaitDialog();
482	            }, waitDialogValidTime);
483	        }
484        }
485    }
486}
487
488
489/**
490 * ボタンの有効/無効を切り替えます。
491 * @param form フォーム
492 * @param isDisable 無効にするか
493 * @param targetIdList ボタンを有効/無効にする対象エレメントIDのリスト(対象がなければ画面全てのボタンを対象にする)
494 * @return 状態を変更されたエレメントIDのリスト
495 */
496function changeDisableButton(form, isDisable, targetIdList) {
497	if (isNullorUndefined(targetIdList) || targetIdList.length == 0) {
498		// フォームの全てのボタン対象
499		targetIdList = new Array();
500	    for (var i = 0; i < form.length; i++) {
501			var element = form.elements[i];
502			if (element.type == 'button' || element.type == 'submit') {
503				targetIdList.push(element.id);
504			}
505	    }
506	}
507
508	var changedTargetIdList = new Array();
509    for (var i = 0; i < targetIdList.length; i++) {
510    	if (isNullorUndefinedorEmpty(targetIdList[i])) {
511    		continue;
512    	}
513		var element = document.getElementById(targetIdList[i]);
514		if (isNullorUndefined(element)) {
515			continue;
516		}
517		if (element.type == 'button' || element.type == 'submit') {
518            if (element.disabled != undefined) {
519            	if (element.disabled != isDisable) {
520	                element.disabled = isDisable;
521	                changedTargetIdList.push(element.id);
522	            }
523            }
524        }
525    }
526    return changedTargetIdList;
527}
528
529/**
530 * アップロード処理を実行します。
531 * @param action アップロードAction
532 * @param url アップロードURL(省略した場合、現在のform actionのjspをuploadに置換した値でsubmit)
533 */
534function uploadFile(action, url) {
535	changeUploadAction(url);
536	submit(action);
537}
538
539/**
540 * フォームのアクションをアップロード可能な形に変換します。
541 * URLが指定されている場合、対象URLにフォームのアクションを変更します。
542 * @param url URL(指定のない場合は、現状のアクションのjspをuploadに変換して実行)
543 */
544function changeUploadAction(url) {
545    var form = document.forms["formMain"];
546    var multipartConstants = "multipart/form-data";
547    form.encoding = multipartConstants;
548    form.enctype = multipartConstants;
549
550    if (url != null && url != undefined) {
551        form.action = url;
552    } else {
553        var uploadUrl = form.action.replace("\.jsp", "\.upload");
554        form.action = uploadUrl;
555    }
556}
557
558/**
559 * ダウンロード処理を実行します。
560 * @param submitAction ダウンロードAction
561 */
562function downloadFile(submitAction, isNeedUpload) {
563	if (!isNullorUndefined(isNeedUpload) && isNeedUpload) {
564		changeUploadAction();
565	}
566    submit(submitAction, null, 2000, -1);
567    return false;
568}
569
570
571
572/**
573 * 指定されたリストの選択行のインデックスを取得します。
574 * @param list リスト
575 * @returns 選択行のインデックス
576 */
577function getListSelectedIndex(listId, indexSymbol) {
578	if (isNullorUndefined(listId)) {
579		return null;
580	}
581	if (isNullorUndefined(indexSymbol)) {
582		indexSymbol = "";
583	}
584
585    var form = document.forms["formMain"];
586    var selectedIndexName = listId + "SelectedIndex" + indexSymbol;
587    var selected = form.elements[selectedIndexName];
588    if (isNullorUndefined(selected)) {
589    	return null;
590    }
591
592    return selected.value;
593}
594
595/**
596 * 指定されたリストの指定インデックスの行が既に選択されているか返却します。
597 * @param listId 対象テーブルリストのID
598 * @param index 選択するインデックス
599 * @param selectedRowIndexSymbol 選択された行のインデックスシンボル
600 * @returns 指定されたインデックスの行が既に選択されている場合true
601 */
602function isAlreadySelected(listId, index, selectedRowIndexSymbol) {
603	var indexSymbol = getParentIndexSymbol(selectedRowIndexSymbol);
604    var nowIndex = getListSelectedIndex(listId, indexSymbol);
605   	if (isNullorUndefinedorEmpty(nowIndex) || nowIndex != index) {
606   		return false;
607   	} else {
608	   	return true;
609   	}
610}
611
612/**
613 * 指定された一覧が選択されているか確認します。(※ 明細in明細には対応していません)
614 * @return 一覧が選択されている場合true
615 */
616function isListSelected(list) {
617    if (list == null || list == undefined) {
618        return false;
619    }
620    var form = document.forms["formMain"];
621    var selectedIndexName = list.tableId + "SelectedIndex";
622    var selected = form.elements[selectedIndexName];
623    var selectedIndex = parseInt(selected.value);
624    if (selectedIndex.toString() != "NaN") {
625    	// 選択行番号の整合性チェック
626		var selectedDataSizeName = list.tableId + "DataSize";
627		var dataSize = form.elements[selectedDataSizeName];
628		var selectedDataSize = parseInt(dataSize.value);
629		if (selectedDataSize.toString() == "NaN") {
630			return false;
631		} else if (selectedDataSize <= selectedIndex) {
632			// 削除後で明細が減っている
633			return false;
634		}
635        return true;
636    } else {
637        return false;
638    }
639}
640
641/**
642 * 選択されたリストから指定した項目の値を取得します。(※ 明細in明細には対応していません)
643 * @param list リスト
644 * @param id 項目のID
645 * @returns 項目の値
646 */
647function getListSelectedValue(list, id) {
648    var innerObj = getListSelectedObject(list, id, "_innerId");
649    if (innerObj != null && innerObj != undefined) {
650    	return getValueFromElement(innerObj);
651	} else {
652	    var obj = getListSelectedObject(list, id);
653    	return getValueFromElement(obj);
654	}
655}
656
657/**
658 * 選択されたリストから指定した項目を取得します。(※ 明細in明細には対応していません)
659 * @param list リスト
660 * @param id 項目のID
661 * @param suffix IDのサフィックス
662 * @returns 項目の値
663 */
664function getListSelectedObject(list, id, suffix) {
665	if (isNullorUndefined(list)) {
666		return null;
667	}
668
669    var index = getListSelectedIndex(list.tableId, "");
670    if (isNullorUndefinedorEmpty(index)) {
671    	return null;
672    }
673    var idValue = id + "_" + index;
674    if (suffix != null && suffix != undefined) {
675    	idValue = idValue + suffix;
676    }
677    var idElement = document.getElementById(idValue);
678    if (idElement != null && idElement != undefined) {
679	    return idElement;
680	} else {
681		return null;
682	}
683}
684
685/**
686 * 指定されたリストから行とIDを指定し項目を取り出します。(※ 明細in明細には対応していません)
687 * @param list リスト
688 * @param id 項目のID
689 * @param index 行インデックス
690 */
691function getItemFromList(list, id, index) {
692    var form = document.forms["formMain"];
693    return form.elements[id + "_" + index.toString()];
694}
695
696/**
697 * 指定されたリストから行とIDを指定し値を取り出します。(※ 明細in明細には対応していません)
698 * @param list リスト
699 * @param id 項目のID
700 * @param index 行インデックス
701 */
702function getItemValueFromList(list, id, index) {
703	var listId = id + "_" + index.toString();
704	return getElementValue(listId);
705}
706
707/**
708 * ソート処理を実行します。
709 * ソート処理を実施するために、Hidden領域として以下の2つが必要です。
710 *  現在のソート実施カラム名領域: (一覧ID) + SortColumn
711 *  現在のソート実施タイプ(ASC or DESC)領域: (一覧ID) + SortType
712 * 現在のソート実施カラム名と引数指定のソートカラム名が同一の場合、ソートを反転させます。
713 * 同一でない場合は、デフォルトのソート実施タイプでソートを実施します。
714 *  ただし、デフォルトのソート実施タイプが設定されていない場合はASCでソートされます。
715 * @param sortColumn ソートカラム
716 * @param defaultSortType デフォルトのソート実施タイプ(ASC or DESC)
717 * @param form フォーム
718 * @param list StandardListオブジェクト
719 * @param action submitアクション(nullの場合はformのアクションをsubmit)
720 */
721function sort(sortColumn, defaultSortType, form, list, action) {
722    var sortType = judgeSortTypeFromNowSettingAndDefaultSortType(list.tableId, sortColumn, defaultSortType);
723
724    var settingSortColumnName = list.tableId + "SortColumn";
725    var settingSortColumn = form.elements[settingSortColumnName]
726    if (isNullorUndefined(settingSortColumn)) {
727        return;
728    }
729
730    settingSortColumn.value = sortColumn + ":" + sortType;
731    changePage(form, list, action, 1);
732}
733
734/**
735 * ソート状態をデフォルトの状態にし、検索します。
736 * @param form フォーム
737 * @param list StandardListオブジェクト
738 * @param action submitアクション(nullの場合はformのアクションをsubmit)
739 */
740function defaultSort(form, list, action) {
741    clearSortColumn(list.tableId, form);
742    changePage(form, list, action, 1);
743}
744
745/**
746 * ソート状態をデフォルトの状態にします。
747 * @param tableId tableId
748 * @param form フォーム(未設定の場合、formMainを設定)
749 */
750function clearSortColumn(tableId, form) {
751	if (isNullorUndefined(form)) {
752    	form = document.forms["formMain"];
753	}
754    var settingSortColumnName = tableId + "SortColumn";
755
756    var settingSortColumn = form.elements[settingSortColumnName]
757    if (isNullorUndefined(settingSortColumn)) {
758        return;
759    }
760    settingSortColumn.value = "";
761}
762
763/**
764 * 現状の設定と指定されたソートによって、ソートタイプ(ASC or DESC)を判定します。
765 * @param tableId テーブルID
766 * @param sortColumn 指定されたソートカラム名
767 * @param defaultSortType 指定されたソートカラムの初期ソートタイプ(ASC or DESC)
768 * @returns ソートタイプ(ASC or DESC)
769 */
770function judgeSortTypeFromNowSettingAndDefaultSortType(tableId, sortColumn, defaultSortType) {
771    var sortTypeList = makeSortTypeList(tableId);
772    var asc = "ASC";
773    var desc = "DESC";
774
775    if (sortTypeList.length != 1) {
776    	// 画面からは複数ソートカラムを指定できないので、一つのソートカラム指定以外の場合、デフォルトの一つのカラムでソートさせる
777    	return defaultSortType.toUpperCase();
778    } else {
779    	var settingSortColumnValue = sortTypeList[0].columnName;
780    	var settingSortTypeValue = sortTypeList[0].sortType;
781	    if (settingSortColumnValue == sortColumn) {
782	        if (settingSortTypeValue.toUpperCase() == asc) {
783	            sortType = desc;
784	        } else {
785	            sortType = asc;
786	        }
787	    } else {
788	        if (!isNullorUndefined(defaultSortType) && (defaultSortType.toUpperCase() == asc || defaultSortType.toUpperCase() == desc)) {
789	            sortType = defaultSortType;
790	        } else {
791	            sortType = asc;
792	        }
793	    }
794	    return sortType;
795	}
796}
797
798/**
799 * 指定されたラベルに対し、必須ラベルの設定を行います。
800 * @param labelName ラベルID
801 */
802function changeRequiredLabelColor(labelName, isSetting) {
803	changeClassName(labelName, "REQUIRED_LABEL", isSetting)
804}
805
806/**
807 * 指定された要素に対し、disableを解除し、hidden要素が存在すれば削除します。
808 * ラジオボタンは対象外です。
809 * @param id 対象要素のid
810 */
811function changeEnabled(id) {
812	if(id == null || id == undefined) {
813		return;
814	}
815	var elementDisabledHidden = document.getElementById(id + '_disabled_hidden');
816	var element = document.getElementById(id);
817	if(element != null && element != undefined) {
818		if(element.type.toUpperCase() == 'TEXT') {
819			element.readOnly = false;
820		} else {
821			element.disabled = false;
822		}
823		element.className = element.className.replace(/\s?readonly/g, "");
824		if (!isNullorUndefined(element.tabIndex) && element.tabIndex < 0) {
825			element.removeAttribute("tabIndex");
826		}
827
828		if(element.type.toUpperCase() != 'TEXT') {
829			if (elementDisabledHidden != null && elementDisabledHidden != undefined) {
830				element.setAttribute("name", elementDisabledHidden.name);
831				elementDisabledHidden.parentNode.removeChild(elementDisabledHidden);
832			}
833		}
834	} else {
835		var element = document.getElementById(id + "_0");
836		if (element != null && element != undefined && element.type.toUpperCase() == 'RADIO') {
837			// radioの場合
838			changeEnabledRadio(id);
839		} else if (element != null && element != undefined && element.type.toUpperCase() == 'CHECKBOX') {
840			// checkBoxesの場合
841			var checkBoxIndex = 0;
842			while (element != null && element != undefined) {
843				element = document.getElementById(id + "_" + checkBoxIndex++);
844				if (element == null || element == undefined) {
845					break;
846				}
847				changeEnabled(element.id);
848			}
849		}
850	}
851}
852
853/**
854 * 指定されたラジオボタンの要素に対し、disableを解除し、hidden要素が存在すれば削除します。
855 * @param name ラジオボタンのname
856 */
857function changeEnabledRadio(name) {
858	if(name == null || name == undefined) {
859		return;
860	}
861	var elementDisabledHidden = document.getElementById(name + '_disabled_hidden');
862	var elements = document.getElementsByName(name);
863	if (elements != null && elements != undefined) {
864		for(var i = 0; i < elements.length; i++) {
865			elements[i].disabled = false;
866			elements[i].className = elements[i].className.replace(/\s?readonly/g, "");
867		}
868		if (elementDisabledHidden != null && elementDisabledHidden != undefined) {
869			elementDisabledHidden.parentNode.removeChild(elementDisabledHidden);
870		}
871	}
872}
873
874/**
875 * 指定された要素に対し、disableを設定し、hidden要素が存在しなければ追加します。
876 * ラジオボタンは対象外です。
877 * @param targetElement 対象要素のid
878 */
879function changeDisabled(id) {
880	if(id == null || id == undefined) {
881		return;
882	}
883	var elementDisabledHidden = document.getElementById(id + '_disabled_hidden');
884	var element = document.getElementById(id);
885	if(element != null && element != undefined) {
886		if(element.type.toUpperCase() == 'TEXT') {
887			element.readOnly = true;
888		} else {
889			element.disabled = true;
890		}
891		element.className = element.className.indexOf(" readonly") > 0 ? element.className: element.className + " readonly";
892		element.tabIndex='-1';
893
894		if(element.type.toUpperCase() != 'TEXT') {
895			if (elementDisabledHidden == null || elementDisabledHidden == undefined) {
896				elementDisabledHidden = document.createElement('input');
897				elementDisabledHidden.type = 'hidden';
898				elementDisabledHidden.id = id + '_disabled_hidden';
899				elementDisabledHidden.name = element.name;
900
901				if(element.type.toUpperCase() == 'CHECKBOX') {
902					if(element.checked) {
903						elementDisabledHidden.value = element.value;
904					} else {
905						return;
906					}
907				}
908				if(element.tagName.toUpperCase() == 'SELECT') {
909					var elementValue = "";
910					if (element.selectedIndex != -1) {
911						elementValue = element.options[element.selectedIndex].value;
912					}
913					elementDisabledHidden.value = elementValue;
914					element.removeAttribute("name");
915				}
916				element.parentNode.insertBefore(elementDisabledHidden, element);
917			}
918		}
919	} else {
920
921		var element = document.getElementById(id + "_0");
922		if (element != null && element != undefined && element.type.toUpperCase() == 'RADIO') {
923			// radioの場合
924			changeDisabledRadio(id);
925		} else if (element != null && element != undefined && element.type.toUpperCase() == 'CHECKBOX') {
926			// checkBoxesの場合
927			var checkBoxIndex = 0;
928			while (element != null && element != undefined) {
929				element = document.getElementById(id + "_" + checkBoxIndex++);
930				if (element == null || element == undefined) {
931					break;
932				}
933				changeDisabled(element.id);
934			}
935		}
936	}
937}
938
939/**
940 * 指定されたラジオボタン要素に対し、disableを設定し、hidden要素が存在しなければ追加します。
941 * @param name ラジオボタンのname
942 */
943function changeDisabledRadio(name) {
944	if(name == null || name == undefined) {
945		return;
946	}
947	var elementDisabledHidden = document.getElementById(name + '_disabled_hidden');
948	var elements = document.getElementsByName(name);
949
950	if (elements != null && elements != undefined) {
951		for(var i = 0; i < elements.length; i++) {
952			if(elements[i].type != 'hidden') {
953				elements[i].disabled = true;
954				elements[i].className = elements[i].className.indexOf(" readonly") > 0 ? elements[i].className: elements[i].className + " readonly";
955			}
956		}
957		if (elementDisabledHidden == null || elementDisabledHidden == undefined) {
958			elementDisabledHidden = document.createElement('input');
959			elementDisabledHidden.type = 'hidden';
960			elementDisabledHidden.id = name + '_disabled_hidden';
961			elementDisabledHidden.name = elements[0].name;
962			if(elements[0].type.toUpperCase() == 'RADIO') {
963				for(var i = 0; i < elements.length; i++) {
964					if(elements[i].checked) {
965						elementDisabledHidden.value = elements[i].value;
966						break;
967					}
968				}
969			}
970		}
971		elements[0].parentNode.insertBefore(elementDisabledHidden, elements[0]);
972	}
973}
974
975/**
976 * 指定されたURLのサブウィンドウダイアログ(参照選択画面)を表示します。
977 * @param url URL(encodeされます)
978 * @param width ダイアログ幅(px)
979 * @param height ダイアログ高さ(px)
980 * @param parameter 子に渡すGetパラメータ
981 * @param setting  [親ウィンドウID]:[子ウィンドウID](複数の場合は、カンマ区切り)
982 * @param focus 参照選択後、親ウィンドウに戻すフォーカスのID
983 * @param isModeless trueの場合はモードレスでウィンドウを開きます
984 */
985function openRefSelectWindow(url, width, height, parameter, setting, focus, isModeless) {
986	var p = "";
987	if (!isNullorUndefinedorEmpty(parameter)) {
988		p = parameter;
989	}
990
991	if (!isNullorUndefinedorEmpty(setting)) {
992		var settingParameter = "settingParameter=" + setting;
993		if (!isEmpty(p)) {
994			p = p + "&"
995		}
996		p = p + settingParameter;
997	}
998
999	if (!isNullorUndefinedorEmpty(focus)) {
1000		var fucusParameter = "focusParameter=" + focus;
1001		if (!isEmpty(p)) {
1002			p = p + "&"
1003		}
1004		p = p + fucusParameter;
1005	}
1006
1007	if (!isEmpty(p)) {
1008		url = url + "?" + p;
1009	}
1010
1011	if (!isNullorUndefined(isModeless) && isModeless) {
1012		return openModelessWindow(url, width, height);
1013	} else {
1014		return openWindow(url, width, height);
1015	}
1016}
1017
1018/**
1019 * ポップアップのコールバック処理をセットします。
1020 * @param win (必須)モードレスポップアップウィンドウ
1021 * @param callback (必須)コールバックファンクション
1022 * @param timeout 待ち時間(ミリ秒)
1023 */
1024function setPopupCallback(win, callback, timeout) {
1025	if (isNullorUndefined(timeout)) {
1026		timeout = 500;
1027	}
1028    if (isNullorUndefined(win) || win.closed) {
1029    	callback.apply();
1030    } else {
1031    	setTimeout(function(){
1032    		setPopupCallback(win, callback);
1033    		}, timeout);
1034    }
1035}
1036
1037/**
1038 * 親ウィンドウから以下のルールに基づいたパラメータを取得した場合、
1039 * パラメータルールに従って、子ウィンドウのリスト選択値を親ウィンドウに設定します。
1040 * 参照画面から利用します。
1041 * ルール: setting [親ウィンドウID]:[子ウィンドウID]:[上書きするか(t/f)]:[データ型](複数の場合は、カンマ区切り)
1042 * データ型は、親ウインドウの設定値が複数カラムに分かれている項目のみ使用
1043 * z:郵便番号2カラム t:電話番号3カラム
1044 * @param setting 親ウィンドウからのパラメータ設定値
1045 * @param list 子ウィンドウのリスト
1046 */
1047function setSelectedValueToParentWindowItems(setting, list) {
1048	if (setting == null || setting == undefined) {
1049		return;
1050	}
1051
1052	var sp = setting.replace(/ /g, "");
1053	var settings = sp.split(",");
1054	for (var i = 0; i < settings.length; i++) {
1055		var setting = settings[i];
1056		var parentChildId = setting.split(":");
1057		if (parentChildId.length < 2) {
1058			continue;
1059		}
1060
1061		var parentId = parentChildId[0];
1062		var childId = parentChildId[1];
1063
1064		var overwrite = true;
1065		if (parentChildId.length > 2) {
1066			if (parentChildId[2] == "f") {
1067				overwrite = false;
1068			}
1069		}
1070
1071		var parentDataType = "";
1072		if (parentChildId.length > 3 && parentChildId[3] != "") {
1073			parentDataType = parentChildId[3];
1074		}
1075
1076		var targetValue;
1077		if (list == null || list == undefined) {
1078			targetValue = getElementValue(childId);
1079		} else {
1080			targetValue = getListSelectedValue(list, childId);
1081		}
1082		if (targetValue == null || targetValue == undefined) {
1083			continue;
1084		}
1085
1086		if(parentDataType == "z"){
1087			var zip2col = targetValue.split("-");
1088			setValueToParentWindowItem(parentId + "Pre", zip2col[0], overwrite);
1089			setValueToParentWindowItem(parentId + "Pre" + "_innerId", zip2col[0], overwrite);
1090			if(zip2col.length>1){
1091				setValueToParentWindowItem(parentId + "Post", zip2col[1], overwrite);
1092				setValueToParentWindowItem(parentId + "Post" + "_innerId", zip2col[1], overwrite);
1093			}else{
1094				setValueToParentWindowItem(parentId + "Post", "", overwrite);
1095				setValueToParentWindowItem(parentId + "Post" + "_innerId", "", overwrite);
1096			}
1097		}else if(parentDataType == "t"){
1098			var tel3col = targetValue.split("-");
1099			setValueToParentWindowItem(parentId + "Pre", tel3col[0], overwrite);
1100			setValueToParentWindowItem(parentId + "Pre" + "_innerId", tel3col[0], overwrite);
1101			if(tel3col.length>1){
1102				setValueToParentWindowItem(parentId + "Middle", tel3col[1], overwrite);
1103				setValueToParentWindowItem(parentId + "Middle" + "_innerId", tel3col[1], overwrite);
1104			}else{
1105				setValueToParentWindowItem(parentId + "Middle", "", overwrite);
1106				setValueToParentWindowItem(parentId + "Middle" + "_innerId", "", overwrite);
1107			}
1108			if(tel3col.length>2){
1109				setValueToParentWindowItem(parentId + "Post", tel3col[2], overwrite);
1110				setValueToParentWindowItem(parentId + "Post" + "_innerId", tel3col[2], overwrite);
1111			}else{
1112				setValueToParentWindowItem(parentId + "Post", "", overwrite);
1113				setValueToParentWindowItem(parentId + "Post" + "_innerId", "", overwrite);
1114			}
1115		}else{
1116			setValueToParentWindowItem(parentId, targetValue, overwrite);
1117			setValueToParentWindowItem(parentId + "_innerId", targetValue, overwrite);
1118		}
1119
1120	}
1121}
1122
1123/**
1124 * 親ウィンドウに選択行の値とフォーカスを設定し、指定があれば画面を閉じます。
1125 * hidden値として、parameterSetting/parameterFocusが存在することを前提にしたメソッドです。
1126 * @param list リスト
1127 * @param isClose 設定後画面を閉じるか。
1128 */
1129function setSelectedToParentWindowItems(list, isClose) {
1130	var focus = document.getElementById("focusParameter");
1131	var focusId = "";
1132	var focusItem;
1133	var focusedItemPreValue = "";
1134	if (!isNullorUndefined(focus)) {
1135		focusId = focus.value;
1136		focusItem = getParentItem(focusId);
1137		if (!isNullorUndefined(focusItem)) {
1138			focusedItemPreValue = focus.value;
1139		}
1140	}
1141
1142    var settingParameter = document.getElementById("settingParameter");
1143    if (settingParameter != null) {
1144	    setSelectedValueToParentWindowItems(settingParameter.value, list);
1145    }
1146
1147	if (!isNullorUndefined(focusItem)) {
1148		setFocusToParentWindowItem(focusId);
1149		if (focusedItemPreValue != focusItem.value) {
1150			focusItem.isChangeByScript = true;
1151		}
1152	}
1153
1154	if (isClose) {
1155		// ウィンドウを閉じる
1156	    if(window.parent) {
1157			window.parent.close();
1158		}
1159		else {
1160			this.close();
1161		}
1162	}
1163}
1164
1165/**
1166 * objの値を指定した日付フォーマットに変換します。
1167 *
1168 * @param obj オブジェクト(document.getElementByIdで取得)
1169 * @param formatType 日付フォーマットのタイプ(YYYYMMDD/YYMM/YYYYMMDDhhmiss/hhmm)
1170 */
1171function setDateValue(obj, formatType) {
1172	if (formatType == 'YYYYMMDD') {
1173		setFormatDate(target);
1174	} else if (formatType == 'YYMM') {
1175		setFormatDateYYMM(target);
1176	} else if (formatType == 'YYYYMMDDhhmiss') {
1177		setFormatDateTime(target);
1178	} else if (formatType == 'hhmm') {
1179		setFormatTime(target);
1180	} else {
1181		return;
1182	}
1183}
1184
1185/**
1186 * 日付フォーマットされたvalueを取得します。
1187 *
1188 * @param value フォーマットする値
1189 * @param formatType 日付フォーマットのタイプ(YYYYMMDD/YYMM/YYYYMMDDhhmiss/hhmm)
1190 * @returns
1191 */
1192function getFormattedDateValue(value, formatType) {
1193	var formattedValue;
1194	try {
1195		if (formatType == 'YYYYMMDD') {
1196			var date = new ExDateTime().parseDate(value, false);
1197			formattedValue = ExDateTimeUtils.format(date, "Y/m/d");
1198		} else if(formatType == 'YYMM') {
1199			var date = new ExDateTime().parseYM(value);
1200			formattedValue = ExDateTimeUtils.format(date, "Y/m");
1201		} else if(formatType == 'YYYYMMDDhhmi') {
1202			var date = new ExDateTime().parseDate(value, true);
1203			formattedValue = ExDateTimeUtils.format(date, "Y/m/d H:i");
1204		} else if(formatType == 'YYYYMMDDhhmiss') {
1205			var date = new ExDateTime().parseDate(value, true);
1206			formattedValue = ExDateTimeUtils.format(date, "Y/m/d H:i:s");
1207		} else if(formatType == 'hhmm') {
1208			var date = new ExDateTime().parseTime(value);
1209			formattedValue = ExDateTimeUtils.format(date, "H:i");
1210		} else {
1211			return;
1212		}
1213
1214		return formattedValue;
1215	} catch(e) {
1216			throw e;
1217	}
1218}
1219
1220/**
1221 * 読取専用(disable)の項目に値を設定します。hidden値にも値が設定されます。
1222 * @param id ID
1223 * @param value 設定する値
1224 * @param isOverwrite 上書きするか
1225 */
1226function setDisabledValue(id, value, isOverwrite) {
1227	setValue(id, value, isOverwrite);
1228	setValue(id + "_disabled_hidden", value, isOverwrite);
1229}
1230
1231/**
1232 * 数値フォーマットされたvalueを設定します。(text/checkbox/radio/hidden etc.)
1233 * @param id ID
1234 * @param value 設定する値
1235 * @param n 小数点以下桁数
1236 * @param isSeparate カンマ区切りするか
1237 * @param isOverwrite 上書きするか
1238 */
1239function setNumberFormatValue(id, value, n, isSeparate, isOverwrite) {
1240	var formattedNumber = "";
1241	if (!isNullorUndefinedorEmpty(value)) {
1242		formattedNumber = getFormatedNumberString(value, n, isSeparate);
1243	}
1244	setValue(id, formattedNumber, isOverwrite);
1245}
1246
1247/**
1248 * 日付フォーマットされたvalueを設定します。(text/checkbox/radio/hidden etc.)
1249 *
1250 * @param id ID
1251 * @param value 設定する値
1252 * @param isOverwrite 上書きするか
1253 * @param formatType 日付フォーマットのタイプ(YYYYMMDD/YYMM/YYYYMMDDhhmiss/hhmm)
1254 */
1255function setDateFormatValue(id, value, isOverwrite, formatType) {
1256	var formattedDate = getFormattedDateValue(value, formatType);
1257	setValue(id, formattedDate, isOverwrite);
1258}
1259
1260/**
1261 * ラベルに値を設定します。
1262 * ラベルの場合、hidden値にも値を設定します。
1263 *
1264 * @param id ID
1265 * @param value 設定する値
1266 */
1267function setLabelValue(id, value, isOverwrite) {
1268	setInnerTextValue(id, value, "_innerId", isOverwrite);
1269}
1270
1271/**
1272 * ラベルに数値フォーマットされた値を設定します。
1273 *
1274 * @param id ID
1275 * @param value 設定する値
1276 * @param n 小数点以下桁数
1277 * @param isSeparate カンマ区切りするか
1278 * @param isOverwrite 上書きするか
1279 */
1280function setNumberFormatLabelValue(id, value, n, isSeparate, isOverwrite) {
1281	var formatNumber = getFormatedNumberString(value, n, isSeparate);
1282	setLabelValue(id, formatNumber, isOverwrite);
1283}
1284
1285/**
1286 * ラベルに日付フォーマットされた値を設定します。
1287 *
1288 * @param id ID
1289 * @param value 設定する値
1290 * @param isOverwrite 上書きするか
1291 * @param formatType 日付フォーマットのタイプ(YYYYMMDD/YYMM/YYYYMMDDhhmiss/hhmm)
1292 */
1293function setDateFormatLabelValue(id, value, isOverwrite, formatType) {
1294	var formattedDate = getFormattedDateValue(value, formatType);
1295	setLabelValue(id, formattedDate, isOverwrite);
1296}
1297
1298/**
1299 * Spanに値を設定します。
1300 * Spanの場合、hidden値にも値を設定します。
1301 * @param id ID
1302 * @param value 設定する値
1303 */
1304function setSpanValue(id, value, isOverwrite) {
1305	setInnerTextValue(id, value, "_innerId", isOverwrite);
1306}
1307
1308/**
1309 * Spanに数値フォーマットされた値を設定します。
1310 * @param id ID
1311 * @param value 設定する値
1312 * @param n 小数点以下桁数
1313 * @param isSeparate カンマ区切りするか
1314 * @param isOverwrite 上書きするか
1315 */
1316function setNumberFormatSpanValue(id, value, n, isSeparate, isOverwrite) {
1317	var formatNumber = getFormatedNumberString(value, n, isSeparate);
1318	setSpanValue(id, formatNumber, isOverwrite);
1319}
1320
1321/**
1322 * Spanに日付フォーマットされた値を設定します。
1323 *
1324 * @param id ID
1325 * @param value 設定する値
1326 * @param isOverwrite 上書きするか
1327 * @param formatType 日付フォーマットのタイプ(YYYYMMDD/YYMM/YYYYMMDDhhmiss/hhmm)
1328 */
1329function setDateFormatSpanValue(id, value, isOverwrite, formatType) {
1330	var formattedDate = getFormattedDateValue(value, formatType);
1331	setSpanValue(id, formattedDate, isOverwrite);
1332}
1333
1334/**
1335 * Divに値を設定します。
1336 * Divの場合、hidden値にも値を設定します。
1337 * @param id ID
1338 * @param value 設定する値
1339 */
1340function setDivValue(id, value, isOverwrite) {
1341	setInnerTextValue(id, value, "_innerId", isOverwrite);
1342}
1343
1344/**
1345 * Divに数値フォーマットされた値を設定します。
1346 * @param id ID
1347 * @param value 設定する値
1348 * @param n 小数点以下桁数
1349 * @param isSeparate カンマ区切りするか
1350 * @param isOverwrite 上書きするか
1351 */
1352function setNumberFormatDivValue(id, value, n, isSeparate, isOverwrite) {
1353	var formatNumber = getFormatedNumberString(value, n, isSeparate);
1354	setDivValue(id, formatNumber, isOverwrite);
1355}
1356
1357/**
1358 * Divに日付フォーマットされた値を設定します。
1359 *
1360 * @param id ID
1361 * @param value 設定する値
1362 * @param isOverwrite 上書きするか
1363 * @param formatType 日付フォーマットのタイプ(YYYYMMDD/YYMM/YYYYMMDDhhmiss/hhmm)
1364 */
1365function setDateFormatDivValue(id, value, isOverwrite, formatType) {
1366	var formattedDate = getFormattedDateValue(value, formatType);
1367	setDivValue(id, formattedDate, isOverwrite);
1368}
1369
1370/**
1371 * Preに値を設定します。
1372 * Preの場合、hidden値にも値を設定します。
1373 * @param id ID
1374 * @param value 設定する値
1375 */
1376function setPreValue(id, value, isOverwrite) {
1377	setInnerTextValue(id, value, "_innerId", isOverwrite);
1378}
1379
1380/**
1381 * InnerTextに値を設定します。
1382 * hidden値にも同時に値を設定する必要のあるタグ項目(label/span/div/pre)の値を動的に変更するときに
1383 * 利用します。
1384 * ※ このメソッドは直接利用せず、setLabelValue メソッドなどを利用してください。
1385 * @param id ID
1386 * @param value 設定する値
1387 * @param kindId label/span/div/preなどを識別するID(WebSystemGeneratorの仕様に即します)
1388 */
1389function setInnerTextValue(id, value, kindId, isOverwrite) {
1390	setInnerText(id + kindId, value, isOverwrite);
1391	setValue(id, value, isOverwrite);
1392}
1393
1394/**
1395 * ハッシュ値(主にJsonから取得するHashMap)からSelectBoxのOption値を構成します。
1396 * keysに取り出す順番にキーを格納することで順序を保つことができます。
1397 * @param selectbox SelectBox
1398 * @param hash ハッシュ値
1399 * @param defaultValue SelectBoxで設定する初期値
1400 * @param keys 値を取り出す順番のキーリスト
1401 */
1402function setOptionsFromHash(selectbox, hash, defaultValue, keys) {
1403	if (isNullorUndefined(selectbox)) {
1404		return;
1405	}
1406	var inputSpaceMessage = getInputSpaceMessageFromSelectBox(selectbox);
1407	removeChildren(selectbox);
1408
1409	if (hash != null && hash != undefined) {
1410		var optionIndex = 0;
1411		if (inputSpaceMessage != null) {
1412			selectbox.options[0] = new Option(inputSpaceMessage, "");
1413			optionIndex++;
1414		}
1415		if (keys != null && keys != undefined) {
1416			for (var index = 0; index < keys.length; index++) {
1417				selectbox.options[optionIndex] = new Option(hash[keys[index]], keys[index]);
1418
1419				if (defaultValue != null && defaultValue != undefined) {
1420					if (keys[index] == defaultValue) {
1421						selectbox.options[optionIndex].selected = true;
1422					}
1423				}
1424				optionIndex++;
1425			}
1426		} else {
1427			for (var key in hash) {
1428				selectbox.options[optionIndex] = new Option(hash[key], key);
1429
1430				if (defaultValue != null && defaultValue != undefined) {
1431					if (key == defaultValue) {
1432						selectbox.options[optionIndex].selected = true;
1433					}
1434				}
1435				optionIndex++;
1436			}
1437		}
1438	}
1439}
1440
1441/**
1442 * SelectBoxのOption値をクリアします。
1443 * @param id アイテムID
1444 * @param indexSymbol インデックスシンボル
1445 */
1446function removeOptions(id, indexSymbol) {
1447	if (isNullorUndefined(indexSymbol)) {
1448		indexSymbol = "";
1449	}
1450	var itemElement = document.getElementById(id + indexSymbol);
1451	if (isNullorUndefined(itemElement)) {
1452		return;
1453	}
1454
1455	var inputSpaceMessage = getInputSpaceMessageFromSelectBox(itemElement);
1456	removeChildren(itemElement);
1457
1458	if (inputSpaceMessage != null) {
1459		itemElement.options[0] = new Option(inputSpaceMessage, "");
1460	}
1461}
1462
1463/**
1464 * コンボボックスから未選択状態を表現する文字列を取得します。
1465 * 未選択状態を許可しないコンボボックスの場合、nullを返却します。
1466 * @param selectbox コンボボックス
1467 * @returns 未選択状態を表現する文字列。未選択状態を許可しない場合null
1468 */
1469function getInputSpaceMessageFromSelectBox(selectbox) {
1470	var inputSpaceMessage = "";
1471	if (!isNullorUndefined(selectbox) && selectbox.length > 0) {
1472		if (!isNullorUndefined(selectbox[0]) && !isNullorUndefined(selectbox[0].value) && selectbox[0].value == ""){
1473			isInputSpace = true;
1474			if (!isNullorUndefined(selectbox[0].innerText)) {
1475				inputSpaceMessage = selectbox[0].innerText;
1476			} else if (!isNullorUndefined(selectbox[0].textContent)) {
1477				// FireFox
1478				inputSpaceMessage = selectbox[0].textContent;
1479			}
1480			return inputSpaceMessage;
1481		}
1482	}
1483	return null;
1484}
1485
1486/**
1487 * ハッシュ値(主にJsonから取得するHashMap)からRadioの選択値を構成します。
1488 * keysに取り出す順番にキーを格納することで順序を保つことができます。
1489 * @param name Radioのname属性
1490 * @param hash ハッシュ値
1491 * @param keys 値を取り出す順番のキーリスト
1492 * @param indexSymbol インデックスシンボル
1493 */
1494function setRadioSelectionsFromHash(name, hash, keys, indexSymbol) {
1495	setSelectionsFromHash(name, hash, keys, indexSymbol);
1496}
1497
1498/**
1499 * ハッシュ値(主にJsonから取得するHashMap)からcheckboxの選択値を構成します。
1500 * keysに取り出す順番にキーを格納することで順序を保つことができます。
1501 * @param name checkboxのname属性
1502 * @param hash ハッシュ値
1503 * @param keys 値を取り出す順番のキーリスト
1504 * @param indexSymbol インデックスシンボル
1505 */
1506function setCheckboxSelectionsFromHash(name, hash, keys, indexSymbol) {
1507	setSelectionsFromHash(name, hash, keys, indexSymbol);
1508}
1509
1510/**
1511 * ハッシュ値(主にJsonから取得するHashMap)から選択値を構成します。
1512 * keysに取り出す順番にキーを格納することで順序を保つことができます。
1513 * @param name name属性
1514 * @param hash ハッシュ値
1515 * @param keys 値を取り出す順番のキーリスト
1516 * @param indexSymbol インデックスシンボル
1517 */
1518function setSelectionsFromHash(name, hash, keys, indexSymbol) {
1519	var templateElement = document.getElementById(getSelectionsTemplateId(name, indexSymbol));
1520	removeSelectionsWithoutTemplate(name, indexSymbol);
1521
1522	if (isNullorUndefined(hash)) {
1523		return;
1524	}
1525
1526	var addHtml = "";
1527	if (keys != null && keys != undefined) {
1528		for (var index = 0; index < keys.length; index++) {
1529			var key = keys[index];
1530			var partsHtml = makeMultiShowSelectionHtmlFromTemplate(templateElement, name, key, hash[key], indexSymbol, index);
1531			addHtml = addHtml + partsHtml;
1532		}
1533	} else {
1534		var index = 0;
1535		for (var key in hash) {
1536			var partsHtml = makeMultiShowSelectionHtmlFromTemplate(templateElement, name, key, hash[key], indexSymbol, index);
1537			addHtml = addHtml + partsHtml;
1538			index++;
1539		}
1540	}
1541
1542	addHtmlBeforeElement(addHtml, templateElement);
1543}
1544
1545/**
1546 * 複数選択肢がある項目(checkbox/radio)のテンプレートとして出力されるエレメントのIDを取得します。
1547 * @param name name属性
1548 * @param indexSymbol インデックスシンボル
1549 * @returns テンプレートとして出力されるエレメントのID
1550 */
1551function getSelectionsTemplateId(name, indexSymbol) {
1552	return name + indexSymbol + "_template";
1553}
1554
1555/**
1556 * 対象のHTMLを対象エレメントの直前に挿入します。
1557 * @param html HTML
1558 * @param targetElement エレメント
1559 */
1560function addHtmlBeforeElement(html, targetElement) {
1561	if (isNullorUndefined(targetElement)) {
1562		return;
1563	}
1564
1565	var targetElementHtml = targetElement.outerHTML;
1566	var targetParentHtml = targetElement.parentNode.innerHTML;
1567
1568	var replacedHtml = targetParentHtml.replace(targetElementHtml, html + targetElementHtml);
1569	targetElement.parentNode.innerHTML = replacedHtml;
1570}
1571
1572/**
1573 * 指定したname属性を持つradioやcheckboxの選択値をテンプレート以外削除します。
1574 * @param name name属性
1575 * @param indexSymbol インデックスシンボル
1576 */
1577function removeSelectionsWithoutTemplate(name, indexSymbol) {
1578	var elements = document.getElementsByName(name + indexSymbol);
1579	if (isNullorUndefined(elements) || elements.length == 0) {
1580		return;
1581	}
1582	var inputSpaceMessage = getInputSpaceMessageFromSelections(name, indexSymbol);
1583	var elementSize = elements.length;
1584	for (var i = 0; i < elementSize; i++) {
1585		var indexFromLast = elementSize - 1 - i;
1586		var element = elements[indexFromLast];
1587		if (isNullorUndefined(element)) {
1588			continue;
1589		}
1590		var elementId = element.id;
1591		if (isSelectionElementTemplate(elementId)) {
1592			// Templateは削除しない
1593			continue;
1594		}
1595
1596		element.parentNode.removeChild(element);
1597
1598		var elementLabelId = elementId + "_label";
1599		var elementLabel = document.getElementById(elementLabelId);
1600		elementLabel.parentNode.removeChild(elementLabel);
1601	}
1602	if (inputSpaceMessage != null) {
1603		var templateElement = document.getElementById(getSelectionsTemplateId(name, indexSymbol));
1604		var partsHtml = makeMultiShowSelectionHtmlFromTemplate(templateElement, name, "", inputSpaceMessage, indexSymbol, index);
1605		addHtmlBeforeElement(partsHtml, templateElement);
1606	}
1607}
1608
1609/**
1610 * 複数選択肢がある項目(checkbox/radio)のHTMLを作成し、返却します。<br/>
1611 * 選択肢のコピー元となるtemplate(inputとlabelで構成されているもの)がJSPに出力されていることが前提になります。
1612 * @param templateElement テンプレートのエレメント
1613 * @param name input name
1614 * @param key 選択肢のkey値
1615 * @param value 選択肢の表示値
1616 * @param indexSymbol インデックスシンボル
1617 * @param addIndex 追加する選択項目のインデックス番号
1618 */
1619function makeMultiShowSelectionHtmlFromTemplate(templateElement, name, key, value, indexSymbol, addIndex) {
1620	if (isNullorUndefined(templateElement)) {
1621		return "";
1622	}
1623
1624	var cloneTemplateElement = templateElement.cloneNode(true);
1625
1626	var inputElement = cloneTemplateElement.getElementsByTagName("input")[0];
1627	var inputElementId = name + indexSymbol + "_" + addIndex;
1628	inputElement.id = inputElementId;
1629	inputElement.value = key;
1630
1631	var labelElement = cloneTemplateElement.getElementsByTagName("label")[0];
1632	var labelElementId = inputElementId + "_label";
1633	labelElement.id = labelElementId;
1634	labelElement.htmlFor = inputElementId;
1635	labelElement.innerHTML = labelElement.innerHTML + value;
1636
1637	return cloneTemplateElement.innerHTML;
1638}
1639
1640/**
1641 * 指定したname属性を持つradioやcheckboxの選択値から未選択状態を表現する文字列を取得します。
1642 * 未選択状態を許可しない場合、nullを返却します。
1643 * @param name name属性
1644 * @param indexSymbol インデックスシンボル
1645 * @returns 未選択状態を表現する文字列。未選択状態を許可しない場合null
1646 */
1647function getInputSpaceMessageFromSelections(name, indexSymbol) {
1648	var inputSpaceMessage = "";
1649
1650	var elements = document.getElementsByName(name + indexSymbol);
1651	if (isNullorUndefined(elements) || elements.length == 0) {
1652		return null;
1653	}
1654
1655	for (var i = 0; i < elements.length; i++) {
1656		var element = elements[i];
1657		var elementId = element.id;
1658		if (isSelectionElementTemplate(elementId)) {
1659			continue;
1660		}
1661		var elementValue = getValueFromElement(element);
1662		if (elementValue == "") {
1663			var elementLabelId = elementId + "_label";
1664			var elementLabel = document.getElementById(elementLabelId);
1665			if (!isNullorUndefined(elementLabel)) {
1666				return getValueFromElement(elementLabel);
1667			}
1668		}
1669	}
1670	return null;
1671}
1672
1673/**
1674 * Gridsterによる編集モードをONにします。
1675 */
1676function gridEditOn() {
1677	if(gridster != null && gridster != undefined) {
1678		gridster.enable();
1679		$(".gridster > ul").removeClass("grid_edit_off");
1680		$(".gridster > ul").addClass("grid_edit_on");
1681	}
1682}
1683
1684/**
1685 * Gridsterによる編集モードをOFFにします。
1686 */
1687function gridEditOff() {
1688	if(gridster != null && gridster != undefined) {
1689		gridster.disable();
1690		$(".gridster > ul").removeClass("grid_edit_on");
1691		$(".gridster > ul").addClass("grid_edit_off");
1692	}
1693}
1694
1695/**
1696 * Gridレイアウト設定の読込み処理です。
1697 */
1698function initGridster(layoutPath){
1699	var widget_base_dimensions_width,widget_base_dimensions_height,widget_margins_x,widget_margins_y,min_cols,max_size_x;
1700	var s = $.ajaxSettings.async;
1701	$.ajaxSetup({async: false});
1702	$.post(layoutPath, function(json){
1703		if(json.list_item != null){
1704			for(i=0; i<json.list_item.length; i++){
1705				var listItemObj = $("#"+ json.list_item[i].block_name);
1706				listItemObj.attr("data-row",json.list_item[i].row);
1707				listItemObj.attr("data-col",json.list_item[i].col);
1708				listItemObj.attr("data-sizex",json.list_item[i].sizex);
1709				listItemObj.attr("data-sizey",json.list_item[i].sizey);
1710			}
1711		}
1712		widget_base_dimensions_width = json.widget_base_dimensions_width;
1713		widget_base_dimensions_height = json.widget_base_dimensions_height;
1714		widget_margins_x = json.widget_margins_x;
1715		widget_margins_y = json.widget_margins_y;
1716		min_cols = json.min_cols;
1717		max_size_x = json.max_size_x;
1718		gridster = $(".gridster > ul").gridster({
1719			widget_base_dimensions:[widget_base_dimensions_width,widget_base_dimensions_height],
1720			widget_margins:[widget_margins_x,widget_margins_y],
1721			min_cols:min_cols,
1722			max_size_x:max_size_x
1723		}).data('gridster');
1724	}, 'json');
1725	$.ajaxSetup({async: s});
1726}
1727
1728/**
1729 * Gridレイアウト設定の保存処理です。
1730 */
1731function gridLayoutSave(layoutPath) {
1732	var form = document.forms["formMain"];
1733	var gridData = "{";
1734	var s = $.ajaxSettings.async;
1735	$.ajaxSetup({async: false});
1736	$.post(layoutPath, function(json){
1737		gridData += "\"widget_base_dimensions_width\":"+ json.widget_base_dimensions_width +",";
1738		gridData += "\"widget_base_dimensions_height\":"+ json.widget_base_dimensions_height +",";
1739		gridData += "\"widget_margins_x\":"+ json.widget_margins_x +",";
1740		gridData += "\"widget_margins_y\":"+ json.widget_margins_y +",";
1741		gridData += "\"min_cols\":"+ json.min_cols +",";
1742		gridData += "\"max_size_x\":"+ json.max_size_x +",";
1743		gridData += "\"list_item\":[";
1744		$(".gridster > ul > li").each(function(i) {
1745			gridData += (i == 0 ? "" : ",");
1746			gridData += "{";
1747			gridData += "\"block_name\":\""+ this.getAttribute("id") +"\",";
1748			gridData += "\"row\":"+ this.getAttribute("data-row") +",";
1749			gridData += "\"col\":"+ this.getAttribute("data-col") +",";
1750			gridData += "\"sizex\":"+ this.getAttribute("data-sizex") +",";
1751			gridData += "\"sizey\":"+ this.getAttribute("data-sizey") +"";
1752			gridData += "}";
1753		});
1754		gridData += "]";
1755	}, 'json');
1756	gridData += "}";
1757	$.ajaxSetup({async: s});
1758	form.elements["gridData"].value = gridData;
1759	form.submit();
1760}
1761
1762/**
1763 * 明細行数を取得します。
1764 * @param detailsId 明細グループID
1765 * @returns 明細行数
1766 */
1767function getDataSize(detailsId) {
1768	return getIntValue(detailsId + "DataSize");
1769}
1770
1771/**
1772 * 電話番号(3カラム)の入力チェックを実行します。
1773 * @param telId 電話番号(3カラム)の画面ID
1774 * @param isRequired 必須チェックを実施するか
1775 * @param indexSymbol インデックスシンボル
1776 */
1777function checkTel(telId, isRequired, indexSymbol) {
1778	if (isNullorUndefined(indexSymbol)) {
1779		indexSymbol = "";
1780	}
1781	var errorFieldBaseId = telId + indexSymbol;
1782	Validator.initbyId(errorFieldBaseId);
1783
1784	var telNo = getTelValue(telId, indexSymbol);
1785	if (isNullorUndefinedorEmpty(telNo)) {
1786		if (isRequired) {
1787			Validator.outputbyId(errorFieldBaseId, Validator.rule.msg.noinput);
1788			return true;
1789		}
1790		return false;
1791	}
1792
1793	return !Validator.checkTel(errorFieldBaseId, telNo);
1794}
1795
1796/**
1797 * 電話番号(3カラム)の値を取得します。
1798 * @param telId 電話番号(3カラム)の画面ID
1799 * @param indexSymbol インデックスシンボル
1800 */
1801function getTelValue(telId, indexSymbol) {
1802	if (isNullorUndefined(indexSymbol)) {
1803		indexSymbol = "";
1804	}
1805	var idPre = telId + "Pre" + indexSymbol;
1806	var idMiddle = telId + "Middle" + indexSymbol;
1807	var idPost = telId + "Post" + indexSymbol;
1808
1809	var idPreElement = document.getElementById(idPre);
1810	var idMiddleElement = document.getElementById(idMiddle);
1811	var idPostElement = document.getElementById(idPost);
1812
1813	if (isNullorUndefined(idPreElement) && isNullorUndefined(idMiddleElement) && isNullorUndefined(idPostElement)) {
1814		return "";
1815	}
1816
1817	var idPreValue = idPreElement.value;
1818	var idMiddleValue = idMiddleElement.value;
1819	var idPostValue = idPostElement.value;
1820
1821	var isPreIdEmpty = isNullorUndefinedorEmpty(idPreValue);
1822	var isMiddleIdEmpty = isNullorUndefinedorEmpty(idMiddleValue);
1823	var isPostIdEmpty = isNullorUndefinedorEmpty(idPostValue);
1824
1825	if (isPreIdEmpty && isMiddleIdEmpty && isPostIdEmpty) {
1826		return "";
1827	}
1828
1829	var telNo = idPreValue + "-" + idMiddleValue + "-" + idPostValue;
1830	return telNo;
1831}
1832
1833/**
1834 * 電話番号(3カラム)のカラムに値を設定します。
1835 * @param telId 電話番号(3カラム)の画面ID
1836 * @param value 設定値
1837 * @param isOverwrite 上書きするか
1838 * @param indexSymbol インデックスシンボル
1839 */
1840function setTelValue(telId, value, isOverwrite, indexSymbol) {
1841	if (isNullorUndefined(value)) {
1842		value = "";
1843	}
1844
1845	if (isNullorUndefined(indexSymbol)) {
1846		indexSymbol = "";
1847	}
1848
1849	var idPre = telId + "Pre" + indexSymbol;
1850	var idMiddle = telId + "Middle" + indexSymbol;
1851	var idPost = telId + "Post" + indexSymbol;
1852
1853	var idPreElement = document.getElementById(idPre);
1854	var idMiddleElement = document.getElementById(idMiddle);
1855	var idPostElement = document.getElementById(idPost);
1856
1857	if (isNullorUndefined(idPreElement)) {
1858		return false;
1859	}
1860
1861	var idPreValue = idPreElement.value;
1862	var idMiddleValue = idMiddleElement.value;
1863	var idPostValue = idPostElement.value;
1864
1865	var isPreIdEmpty = isNullorUndefinedorEmpty(idPreValue);
1866	var isMiddleIdEmpty = isNullorUndefinedorEmpty(idMiddleValue);
1867	var isPostIdEmpty = isNullorUndefinedorEmpty(idPostValue);
1868
1869	if (!isPreIdEmpty || !isMiddleIdEmpty || !isPostIdEmpty) {
1870		if (!isOverwrite) {
1871			// 一つでも入力があったら上書きしない
1872			return false;
1873		}
1874	}
1875
1876	if (value == "") {
1877		idPreElement.value = "";
1878		idMiddleElement.value = "";
1879		idPostElement.value = "";
1880	} else {
1881		var telValues = value.split("-");
1882		var telElements = new Array(3);
1883		telElements[0] = idPreElement;
1884		telElements[1] = idMiddleElement;
1885		telElements[2] = idPostElement;
1886		for (var i = 0; i < telValues.length; i++) {
1887			if (i > telElements.length - 1) {
1888				break;
1889			}
1890			telElements[i].value = telValues[i];
1891		}
1892	}
1893}
1894
1895/**
1896 * 電話番号(3カラム)の入力が変更されたかを判定します。
1897 * @param telId 電話番号(3カラム)の画面ID
1898 * @param indexSymbol インデックスシンボル
1899 */
1900function isChangeTelObject(telId, indexSymbol) {
1901	if (isNullorUndefined(indexSymbol)) {
1902		indexSymbol = "";
1903	}
1904	var idPre = telId + "Pre" + indexSymbol;
1905	var idMiddle = telId + "Middle" + indexSymbol;
1906	var idPost = telId + "Post" + indexSymbol;
1907
1908	var idPreElement = document.getElementById(idPre);
1909	var idMiddleElement = document.getElementById(idMiddle);
1910	var idPostElement = document.getElementById(idPost);
1911
1912	if (isNullorUndefined(idPreElement)) {
1913		return false;
1914	}
1915
1916	if (isChangeMultiPreAreaChangeFocusOutValue(idPreElement)) {
1917		return true;
1918	}
1919
1920	if (isChangeMultiPreAreaChangeFocusOutValue(idMiddleElement)) {
1921		return true;
1922	}
1923
1924	if (isChangeObject(idPostElement)) {
1925		return true;
1926	}
1927
1928	return false;
1929}
1930
1931/**
1932 * 郵便番号(2カラム)の入力チェックを実行します。
1933 * @param zipId 郵便番号(2カラム)の画面ID
1934 * @param isRequired 必須チェックを実施するか
1935 * @param indexSymbol インデックスシンボル
1936 */
1937function checkZip(zipId, isRequired, indexSymbol) {
1938	if (isNullorUndefined(indexSymbol)) {
1939		indexSymbol = "";
1940	}
1941	var errorFieldBaseId = zipId + indexSymbol;
1942	Validator.initbyId(errorFieldBaseId);
1943
1944	var zipNo = getZipValue(zipId, indexSymbol);
1945
1946	if (isNullorUndefinedorEmpty(zipNo)) {
1947		if (isRequired) {
1948			Validator.outputbyId(errorFieldBaseId, Validator.rule.msg.noinput);
1949			return true;
1950		}
1951		return false;
1952	}
1953
1954	return !Validator.checkZip(errorFieldBaseId, zipNo);
1955}
1956
1957/**
1958 * 郵便番号(2カラム)の値を取得します。
1959 * @param zipId 郵便番号(2カラム)の画面ID
1960 * @param indexSymbol インデックスシンボル
1961 */
1962function getZipValue(zipId, indexSymbol) {
1963	if (isNullorUndefined(indexSymbol)) {
1964		indexSymbol = "";
1965	}
1966
1967	var idPre = zipId + "Pre" + indexSymbol;
1968	var idPost = zipId + "Post" + indexSymbol;
1969
1970	var idPreElement = document.getElementById(idPre);
1971	var idPostElement = document.getElementById(idPost);
1972	if (isNullorUndefined(idPreElement) && isNullorUndefined(idPostElement)) {
1973		return "";
1974	}
1975
1976	var idPreValue = idPreElement.value;
1977	var idPostValue = idPostElement.value;
1978
1979	var isPreIdEmpty = isNullorUndefinedorEmpty(idPreValue);
1980	var isPostIdEmpty = isNullorUndefinedorEmpty(idPostValue);
1981
1982	if (isPreIdEmpty && isPostIdEmpty) {
1983		return "";
1984	}
1985	var zipNo = idPreValue + "-" + idPostValue;
1986	return zipNo;
1987}
1988
1989/**
1990 * 郵便番号(2カラム)のカラムに値を設定します。
1991 * @param zipId 郵便番号(2カラム)の画面ID
1992 * @param value 設定値
1993 * @param isOverwrite 上書きするか
1994 * @param indexSymbol インデックスシンボル
1995 */
1996function setZipValue(zipId, value, isOverwrite, indexSymbol) {
1997	if (isNullorUndefined(value)) {
1998		value = "";
1999	}
2000
2001	if (isNullorUndefined(indexSymbol)) {
2002		indexSymbol = "";
2003	}
2004
2005	var idPre = zipId + "Pre" + indexSymbol;
2006	var idPost = zipId + "Post" + indexSymbol;
2007
2008	var idPreElement = document.getElementById(idPre);
2009	var idPostElement = document.getElementById(idPost);
2010
2011	if (isNullorUndefined(idPreElement)) {
2012		return false;
2013	}
2014
2015	var idPreValue = idPreElement.value;
2016	var idPostValue = idPostElement.value;
2017
2018	var isPreIdEmpty = isNullorUndefinedorEmpty(idPreValue);
2019	var isPostIdEmpty = isNullorUndefinedorEmpty(idPostValue);
2020
2021	if (!isPreIdEmpty || !isPostIdEmpty) {
2022		if (!isOverwrite) {
2023			// 一つでも入力があったら上書きしない
2024			return false;
2025		}
2026	}
2027
2028	if (value == "") {
2029		idPreElement.value = "";
2030		idPostElement.value = "";
2031	} else {
2032		var zipValues = value.split("-");
2033		var zipElements = new Array(2);
2034		zipElements[0] = idPreElement;
2035		zipElements[1] = idPostElement;
2036		for (var i = 0; i < zipValues.length; i++) {
2037			if (i > zipElements.length - 1) {
2038				break;
2039			}
2040			zipElements[i].value = zipValues[i];
2041		}
2042	}
2043}
2044
2045/**
2046 * 郵便番号(2カラム)の入力が変更されたかを判定します。
2047 * @param zipId 郵便番号(2カラム)の画面ID
2048 * @param indexSymbol インデックスシンボル
2049 */
2050function isChangeZipObject(zipId, indexSymbol) {
2051	if (isNullorUndefined(indexSymbol)) {
2052		indexSymbol = "";
2053	}
2054	var idPre = zipId + "Pre" + indexSymbol;
2055	var idPost = zipId + "Post" + indexSymbol;
2056
2057	var idPreElement = document.getElementById(idPre);
2058	var idPostElement = document.getElementById(idPost);
2059
2060	if (isNullorUndefined(idPreElement)) {
2061		return false;
2062	}
2063
2064	if (isChangeMultiPreAreaChangeFocusOutValue(idPreElement)) {
2065		return true;
2066	}
2067
2068	if (isChangeObject(idPostElement)) {
2069		return true;
2070	}
2071
2072	return false;
2073}
2074
2075/**
2076 * 指定されたタブオブジェクトのタブ選択を次のタブに移動します。最後のタブにいる場合は、先頭のタブに移動します。
2077 * @param tab タブオブジェクト
2078 */
2079function changeSelectedTabNext(tab) {
2080	var active = tab.tabs("option", "active");
2081	var next = active + 1;
2082	changeSelectedTab(tab, next, 0);
2083}
2084
2085/**
2086 * 指定されたタブオブジェクトのタブ選択を前のタブに移動します。最初のタブにいる場合は、最後のタブに移動します。
2087 * @param tab タブオブジェクト
2088 */
2089function changeSelectedTabPrev(tab) {
2090	var active = tab.tabs("option", "active");
2091	var prev = active - 1;
2092	changeSelectedTab(tab, prev);
2093}
2094
2095/**
2096 * 指定されたタブオブジェクトのタブ選択を指定された位置に移動します。
2097 * @param tab タブオブジェクト
2098 * @param moveIndex 移動するタブインデックス
2099 * @param moveIfNotMoveIndex 指定されたインデックスに移動できなかった場合に移動するタブインデックス
2100 */
2101function changeSelectedTab(tab, moveIndex, moveIfNotMoveIndex) {
2102	tab.tabs('option', 'active', moveIndex);
2103	var nowActive = tab.tabs("option", "active");
2104	if (!isNullorUndefined(moveIfNotMoveIndex)) {
2105		if (nowActive != moveIndex) {
2106			tab.tabs('option', 'active', moveIfNotMoveIndex);
2107		}
2108	}
2109}
2110
2111/**
2112 * タブをアクティブにした際にTabをタブパネルの先頭のフォーカスに移動します。
2113 * @param e アクティブ時のイベント
2114 * @param ui Panel UserInterface
2115 */
2116function focusEnabledActivateTabFirst(e, ui) {
2117	if (isNullorUndefined(ui) || isNullorUndefined(ui.newPanel)) {
2118		return;
2119	}
2120	if (ui.newPanel.length == 0) {
2121		return;
2122	}
2123
2124	focusEnabledFirst(ui.newPanel[0].getElementsByTagName("*"));
2125}
2126
2127/**
2128 * インデックスシンボルから親明細が存在するかを判断します。
2129 * @param indexSymbol インデックスシンボル
2130 * @returns 親明細が存在するかどうか
2131 */
2132function isExistParentDetails(indexSymbol) {
2133	if (isNullorUndefinedorEmpty(indexSymbol)) {
2134		return false;
2135	}
2136	return indexSymbol.match(/.*_\d+_\d+$/);
2137}
2138
2139/**
2140 * 親明細のインデックスシンボルを取得します。
2141 * @param indexSymbol インデックスシンボル
2142 * @param hierarchy 親をたどる回数(省略可) 1または省略時は、1階層親のインデックスシンボルを返却。2なら2階層親のインデックスシンボルを返却。
2143 * @returns 親明細のインデックスシンボル
2144 */
2145function getParentIndexSymbol(indexSymbol, hierarchy) {
2146	if (isNullorUndefinedorEmpty(indexSymbol)) {
2147		return "";
2148	}
2149
2150	if (isNullorUndefinedorEmpty(hierarchy) || hierarchy == 1) {
2151		// 階層指定なしまたは1階層指定なら1つ親を返す
2152		return indexSymbol.replace(/_\d+$/, "");
2153	} else if (hierarchy < 1) {
2154		// 階層指定が1未満ならそのまま返す
2155		return indexSymbol;
2156	}
2157
2158	// 階層が1になるまで再起呼び出し
2159	return getParentIndexSymbol(indexSymbol.replace(/_\d+$/, ""), hierarchy - 1);
2160}
2161
2162/**
2163 * インデックスシンボルから選択行を取得します。
2164 * @param indexSymbol インデックスシンボル
2165 * @returns 選択行
2166 */
2167function getRowNumberFromIndexSymbol(indexSymbol) {
2168	if (isNullorUndefinedorEmpty(indexSymbol)) {
2169		return "";
2170	}
2171	return indexSymbol.replace(/.*_/, "");
2172}
2173
2174/**
2175 * 指定されたIDのタブに移動します。
2176 * @param tabId 移動先タブのID
2177 * @param isFocusFirstElement タブ選択時に先頭項目にタブを移動するか
2178 */
2179function selectTabById(tabId, isFocusFirstElement) {
2180	var tab = $("#" + tabId + "Link");
2181	if (!tab != null) {
2182		var tabGroup = tab.closest("div");
2183		if (tabGroup != null) {
2184			var index = tab.attr("index");
2185			if (index != null) {
2186				changeSelectedTab(tabGroup, index);
2187				if (isNullorUndefined(isFocusFirstElement) || isFocusFirstElement) {
2188					focusEnabledFirst(document.getElementById(tabId + "Tab").getElementsByTagName("*"));
2189				}
2190			}
2191		}
2192	}
2193}
2194
2195/**
2196 * 子ウィンドウとしての振る舞いをコントロールします。(主にIE対策で利用します)
2197 */
2198function childWindowControl() {
2199	var childWindowName = "_child";
2200    window.name = childWindowName
2201    var form = document.forms["formMain"];
2202    if (!isNullorUndefined(form)) {
2203	    form.target = childWindowName;
2204	}
2205}
2206
2207/**
2208 * 待機表示中のダイアログを表示します。
2209 */
2210function showWaitDialog() {
2211	var waitDialog = getWaitDialog();
2212	if (!isNullorUndefined(waitDialog)) {
2213		waitDialog.style.display = "block";
2214	}
2215}
2216
2217/**
2218 * 待機表示中のダイアログを隠します。
2219 */
2220function hideWaitDialog() {
2221	var waitDialog = getWaitDialog();
2222	if (!isNullorUndefined(waitDialog)) {
2223		waitDialog.style.display = "none";
2224	}
2225}
2226
2227/**
2228 * 待機表示中のダイアログを取得します。
2229 */
2230function getWaitDialog() {
2231	return document.getElementById("wait_dialog");
2232}
2233
2234/**
2235 * datepickerの設定を行います。
2236 * @param itemId 項目ID
2237 * @param isDateYm trueの場合はYYYY/MM形式、falseの場合はYYYY/MM/DD形式
2238 * @returns {Boolean}
2239 */
2240function settingDatepicker(itemId, isDateYm) {
2241	if (itemId.lastIndexOf("TemplateIndexSymbol") > 0) {
2242		return false;
2243	}
2244
2245	var datepickerItem = $("#" + itemId);
2246	if (isNullorUndefined(datepickerItem)) {
2247		return false;
2248	}
2249	if (isNullorUndefined(datepickerItem.datepicker)) {
2250		 return false;
2251	}
2252	datepickerItem.datepicker({
2253		beforeShow: function(selectedDate) {
2254			var obj = document.getElementById(itemId);
2255			obj.datepickerInFocusValue = selectedDate.value;
2256			obj.isChangeScriptLock = true;
2257			obj.isChangeByScript = false;
2258			var readOnly = $("#" + selectedDate.id).attr('readOnly');
2259			if (!isNullorUndefined(readOnly) && 0 < readOnly.length) {
2260				return false;
2261			}
2262		},
2263		onClose : function(value) {
2264			var obj = document.getElementById(itemId);
2265			obj.isChangeScriptLock = false;
2266			obj.focus();
2267			if (obj.datepickerInFocusValue != value) {
2268				obj.isChangeByScript = true;
2269			} else {
2270				obj.isChangeByScript = false;
2271			}
2272		},
2273		showOtherMonths: true,
2274		selectOtherMonths: true,
2275		showButtonPanel: true,
2276		changeMonth: true,
2277		changeYear: true
2278	});
2279	if (isDateYm) {
2280		var initVal = getValue(itemId);
2281		datepickerItem.datepicker("option", "dateFormat", "yy/mm");
2282		setValue(itemId, initVal, true);
2283	}
2284}
2285
2286/**
2287 * datetimepickerの設定を行います。
2288 * @param itemId 項目ID
2289 * @param isTimestamp trueの場合はミリ秒まで出力、falseの場合は秒まで
2290 * @returns {Boolean}
2291 */
2292function settingDatetimepicker(itemId, isTimestamp) {
2293	if (itemId.lastIndexOf("TemplateIndexSymbol") > 0) {
2294		return false;
2295	}
2296
2297	var datepickerItem = $("#" + itemId);
2298	if (isNullorUndefined(datepickerItem)) {
2299		return false;
2300	}
2301	if (isNullorUndefined(datepickerItem.datetimepicker)) {
2302		 return false;
2303	}
2304	if (isTimestamp) {
2305		datepickerItem.datetimepicker({
2306			beforeShow: function(selectedDate) {
2307				var obj = document.getElementById(itemId);
2308				obj.datepickerInFocusValue = selectedDate.value;
2309				obj.isChangeScriptLock = true;
2310				obj.isChangeByScript = false;
2311				var readOnly = $("#" + selectedDate.id).attr('readOnly');
2312				if (!isNullorUndefined(readOnly) && 0 < readOnly.length) {
2313					return false;
2314				}
2315			},
2316			onClose : function(value) {
2317				var obj = document.getElementById(itemId);
2318				obj.isChangeScriptLock = false;
2319				obj.focus();
2320				if (obj.datepickerInFocusValue != value) {
2321					obj.isChangeByScript = true;
2322				} else {
2323					obj.isChangeByScript = false;
2324				}
2325			},
2326			showOtherMonths: true,
2327			selectOtherMonths: true,
2328			showSecond: true,
2329			showMillisec: true,
2330			timeFormat: 'HH:mm:ss l'
2331		});
2332	} else {
2333		datepickerItem.datetimepicker({
2334			beforeShow: function(selectedDate) {
2335				var obj = document.getElementById(itemId);
2336				obj.datepickerInFocusValue = selectedDate.value;
2337				obj.isChangeScriptLock = true;
2338				obj.isChangeByScript = false;
2339				var readOnly = $("#" + selectedDate.id).attr('readOnly');
2340				if (!isNullorUndefined(readOnly) && 0 < readOnly.length) {
2341					return false;
2342				}
2343			},
2344			onClose : function(value) {
2345				var obj = document.getElementById(itemId);
2346				obj.isChangeScriptLock = false;
2347				obj.focus();
2348				if (obj.datepickerInFocusValue != value) {
2349					obj.isChangeByScript = true;
2350				} else {
2351					obj.isChangeByScript = false;
2352				}
2353			},
2354			showOtherMonths: true,
2355			selectOtherMonths: true,
2356			showSecond: true,
2357			timeFormat: 'HH:mm:ss',
2358			changeMonth: true,
2359			changeYear: true
2360		});
2361	}
2362}
2363
2364/**
2365 * datetimepickerの設定を行います。(年月日 時分)
2366 * @param itemId 項目ID
2367 * @returns {Boolean}
2368 */
2369function settingDateHourMinutestimepicker(itemId, isTimestamp) {
2370	if (itemId.lastIndexOf("TemplateIndexSymbol") > 0) {
2371		return false;
2372	}
2373
2374	var datepickerItem = $("#" + itemId);
2375	if (isNullorUndefined(datepickerItem)) {
2376		return false;
2377	}
2378	if (isNullorUndefined(datepickerItem.datetimepicker)) {
2379		 return false;
2380	}
2381	datepickerItem.datetimepicker({
2382		beforeShow: function(selectedDate) {
2383			var obj = document.getElementById(itemId);
2384			obj.datepickerInFocusValue = selectedDate.value;
2385			obj.isChangeScriptLock = true;
2386			obj.isChangeByScript = false;
2387			var readOnly = $("#" + selectedDate.id).attr('readOnly');
2388			if (!isNullorUndefined(readOnly) && 0 < readOnly.length) {
2389				return false;
2390			}
2391		},
2392		onClose : function(value) {
2393			var obj = document.getElementById(itemId);
2394			obj.isChangeScriptLock = false;
2395			obj.focus();
2396			if (obj.datepickerInFocusValue != value) {
2397				obj.isChangeByScript = true;
2398			} else {
2399				obj.isChangeByScript = false;
2400			}
2401		},
2402		showOtherMonths: true,
2403		selectOtherMonths: true,
2404		showSecond: false,
2405		showMillisec: false,
2406		timeFormat: 'HH:mm'
2407	});
2408}
2409
2410/**
2411 * timepickerの設定を行います。
2412 * @param itemId 項目ID
2413 * @returns {Boolean}
2414 */
2415function settingTimepicker(itemId) {
2416	if (itemId.lastIndexOf("TemplateIndexSymbol") > 0) {
2417		return false;
2418	}
2419
2420	var datepickerItem = $("#" + itemId);
2421	if (isNullorUndefined(datepickerItem)) {
2422		return false;
2423	}
2424	if (isNullorUndefined(datepickerItem.timepicker)) {
2425		 return false;
2426	}
2427	datepickerItem.timepicker({
2428		beforeShow: function(selectedDate) {
2429			var obj = document.getElementById(itemId);
2430			obj.datepickerInFocusValue = selectedDate.value;
2431			obj.isChangeScriptLock = true;
2432			obj.isChangeByScript = false;
2433			var readOnly = $("#" + selectedDate.id).attr('readOnly');
2434			if (!isNullorUndefined(readOnly) && 0 < readOnly.length) {
2435				return false;
2436			}
2437		},
2438		onClose : function(value) {
2439			var obj = document.getElementById(itemId);
2440			obj.isChangeScriptLock = false;
2441			obj.focus();
2442			if (obj.datepickerInFocusValue != value) {
2443				obj.isChangeByScript = true;
2444			} else {
2445				obj.isChangeByScript = false;
2446			}
2447		},
2448		showOtherMonths: true,
2449		selectOtherMonths: true,
2450		showSecond: true,
2451		timeFormat: 'HH:mm:ss'
2452	});
2453}
2454
2455/**
2456 * 指定された文字数入力された場合、次のエレメントへフォーカスを移動させます。
2457 * @param obj 対象エレメント
2458 * @param e keyupイベント
2459 * @param maxLength 何文字入れた場合に、次のフォーカスに移動するか
2460 * @param nextFocusId 次のフォーカス先エレメントID
2461 */
2462function onkeyupToNextFocus(obj, e, maxLength, nextFocusId) {
2463	if (isNullorUndefined(obj)) {
2464		return true;
2465	}
2466
2467	if (!isChangeObject(obj)) {
2468		return true;
2469	}
2470
2471	if (obj.value.length == maxLength) {
2472		// フォーカス移動
2473		var nextElement = document.getElementById(nextFocusId);
2474		if (!isNullorUndefined(nextElement)) {
2475			nextElement.focus();
2476		}
2477	}
2478	return true;
2479}
2480
2481/**
2482 * 対象ElementのIDがRadioやcheckbox選択値のテンプレートIDであるか判定します。
2483 * @param elementId ElementのID
2484 * @returns 対象ElementのIDが選択値のテンプレートIDである場合true
2485 */
2486function isSelectionElementTemplate(elementId) {
2487	if (elementId.lastIndexOf("_" + getSelectionElementTemplateIndex())  > 0) {
2488		return true;
2489	} else {
2490		return false;
2491	}
2492}
2493
2494/**
2495 * Radioやcheckbox選択値のテンプレートを示すIndex文字列を返却します。
2496 * @returns Radioやcheckbox選択値のテンプレートを示すIndex文字列
2497 */
2498function getSelectionElementTemplateIndex() {
2499	return "{template}";
2500}
2501
2502/**
2503 * バッチ実行の画面状況を更新します。
2504 * @param batchId バッチID
2505 * @param executeTitle バッチ状況表示の主語(タイトル)
2506 * @param executeResult バッチ実行状況を保持する領域のID
2507 * @param batchExecuteId バッチ実行を特定する実行IDを保持する領域のID
2508 * @param executeStatus バッチ実行ステータスを表示する領域のID
2509 * @param executeProgress バッチ実行進捗度を保持する領域のID
2510 * @param loadingAreaId ロードイメージを表示する領域のID(定義されていない場合、executeStatusの直前に表示)
2511 */
2512function updateBatchExecuteStatus(batchId, executeTitle, executeResult, batchExecuteId, executeStatus, executeProgress, loadingAreaId) {
2513	if (!isNullorUndefinedorEmpty(loadingAreaId)) {
2514		hideLoadingArea(loadingAreaId);
2515	}
2516	var executeResultValue = getElementValue(executeResult);
2517	var progressBarId = executeProgress + "ProgressBarShowArea";
2518	var progress = getElementValue(executeProgress);
2519	changeBatchExecuteStatus(batchId, executeTitle, executeResultValue, progress, executeStatus, loadingAreaId, progressBarId);
2520	if (batchExecuteResultIsInprogress(executeResultValue)) {
2521	    var paramBatchExecuteId = getElementValue(batchExecuteId);
2522		// 状況確認Ajax実行
2523        $.ajaxSetup({ cache: false });
2524		var timerId = setInterval(function() {
2525	        $.getJSON("jp/eltex/afw/eg/batch/frontif/bean/ajax/AjaxBatchExecuteResultConfirmBean.json", {"batchId":batchId, "batchExecuteId":paramBatchExecuteId}, function(info) {
2526	            var nowExecuteResult = info.executeResult;
2527	            var inProgress = batchExecuteResultIsInprogress(nowExecuteResult);
2528	            if (inProgress) {
2529		            if (!isNullorUndefinedorEmpty(info.executeProgress)) {
2530		            	if (progress != info.executeProgress) {
2531			            	progress = info.executeProgress;
2532			            	// 実行中の場合、進捗度更新時のみ更新
2533							changeBatchExecuteStatus(batchId, executeTitle, nowExecuteResult, info.executeProgress, executeStatus, loadingAreaId, progressBarId);
2534						}
2535					}
2536	            } else {
2537					changeBatchExecuteStatus(batchId, executeTitle, nowExecuteResult, info.executeProgress, executeStatus, loadingAreaId, progressBarId);
2538					clearInterval(timerId);
2539					callbackBatchExecuteDone(batchId, executeTitle, nowExecuteResult);
2540					return;
2541	            }
2542			});
2543		}, 2000);
2544	}
2545}
2546
2547/**
2548 * バッチ画面状況をバッチ実行状況によって変更します。
2549 * @param batchId バッチID
2550 * @param executeTitle バッチ状況表示の主語(タイトル)
2551 * @param executeResult バッチ実行状況の値
2552 * @param progress バッチ実行進捗度の値
2553 * @param executeStatus バッチ実行ステータスを表示する領域のID
2554 * @param loadingAreaId ロードイメージを表示する領域のID
2555 * @param progressBarId プログレスバーのID(バッチ実行ステータスを表示する領域の後ろにプログレスバーが表示されます)
2556 */
2557function changeBatchExecuteStatus(batchId, executeTitle, executeResult, progress, executeStatus, loadingAreaId, progressBarId) {
2558	var linkText = "..";
2559	if (batchExecuteResultIsInprogress(executeResult)) {
2560		if (!isNullorUndefinedorEmpty(loadingAreaId)) {
2561			showLoadingArea(loadingAreaId);
2562		} else {
2563			// ロードイメージエリアをexecuteStatusの手前に挿入
2564			createLoadingArea(executeStatus);
2565		}
2566
2567		linkText = executeTitle + "実行中です..";
2568		if (!isNullorUndefinedorEmpty(progress)) {
2569			// プログレスバー表示
2570			createAndUpdateBatchExecuteProgress(executeStatus, progressBarId, Math.floor(progress));
2571		}
2572
2573		callbackBatchStatusInprogress(batchId, executeTitle);
2574	} else {
2575		if (!isNullorUndefinedorEmpty(loadingAreaId)) {
2576			hideLoadingArea(loadingAreaId);
2577		} else {
2578			// 挿入されたロードイメージエリアを削除
2579			removeLoadingArea(executeStatus);
2580		}
2581		if (executeResult == "2") {
2582			linkText = executeTitle + "実行可能です[!前回実行時にエラーが発生しています]";
2583		} else if (executeResult == "3") {
2584			linkText = executeTitle + "バッチメンテナンス中のため実行できません";
2585		} else {
2586			linkText = executeTitle + "実行可能です";
2587		}
2588		// プログレスバー非表示
2589		removeBatchExecuteProgress(progressBarId);
2590
2591		callbackBatchStatusEnd(batchId, executeTitle, executeResult);
2592	}
2593
2594	$("#" + executeStatus).text(linkText);
2595}
2596
2597/**
2598 * 入金確定バッチが実行中か返却します。
2599 * @param executeResult バッチ実行状況
2600 * @returns バッチが実行中の場合true
2601 */
2602function batchExecuteResultIsInprogress(executeResult) {
2603	if (executeResult == "4") {
2604		return true;
2605	} else {
2606		return false;
2607	}
2608}
2609
2610/**
2611 * ローディングイメージを表示します。
2612 * @param loadingAreaId ロードイメージを表示する領域のID
2613 */
2614function showLoadingArea(loadingAreaId) {
2615	showArea(loadingAreaId);
2616}
2617
2618/**
2619 * ローディングイメージを隠します。
2620 * @param loadingAreaId ロードイメージを表示する領域のID
2621 */
2622function hideLoadingArea(loadingAreaId) {
2623	hideArea(loadingAreaId);
2624}
2625
2626/**
2627 * ローディングイメージを実行ステータス表示領域の手前に挿入します。
2628 * @param executeStatus 表示領域のID
2629 */
2630function createLoadingArea(executeStatus) {
2631	var loadingAreaId = makeCreateLoadingAreaId(executeStatus);
2632	var loadingArea = $("#" + loadingAreaId);
2633	if (loadingArea.size() != 0) {
2634		// 既に表示済み
2635		return;
2636	}
2637
2638	var executeStatusArea = $("#" + executeStatus);
2639	if (executeStatusArea.size() == 0) {
2640		// 表示エリアがないので、ローディングイメージも表示させない
2641		return;
2642	}
2643
2644	var loadingAreaId = makeCreateLoadingAreaId(executeStatus);
2645	var loadingAreaDiv = '<div id="' + loadingAreaId +  '" class="loadingImg"></div>';
2646	$(loadingAreaDiv).insertBefore("#" + executeStatus);
2647}
2648
2649/**
2650 * ローディングイメージを実行ステータス表示領域から削除します。
2651 * @param executeStatus 表示領域のID
2652 */
2653function removeLoadingArea(executeStatus) {
2654	var loadingImage = $("#" + makeCreateLoadingAreaId(executeStatus));
2655	if (loadingImage != null) {
2656		loadingImage.remove();
2657	}
2658}
2659
2660/**
2661 * ローディングイメージのIDを実行ステータス表示領域のIDから作成します。
2662 * @param executeStatus 表示領域のID
2663 */
2664function makeCreateLoadingAreaId(executeStatus) {
2665	var executeStatusArea = $("#" + executeStatus);
2666	return executeStatusArea.attr("id") + "LoadingArea";
2667}
2668
2669/**
2670 * プログレスバーを表示します。executeStatus領域の後ろに表示されます。
2671 * @param executeStatus プログレスバーを後ろに表示するステータス領域
2672 * @param progressBarId プログレスバーのID
2673 * @param progress 進捗度
2674 */
2675function createAndUpdateBatchExecuteProgress(executeStatus, progressBarId, progress) {
2676	var executeStatusArea = $("#" + executeStatus);
2677	if (executeStatusArea.size() == 0) {
2678		// 表示エリアがないので、プログレスバーも表示させない
2679		return;
2680	}
2681
2682	var progressTextId = progressBarId + "Text";
2683
2684	var progressBar = $("#" + progressBarId);
2685	if (progressBar.size() == 0) {
2686		// 存在しないので作成
2687		// プログレスバーはdivの入れ子で表現される .. <div id="[progressBarId]"><div id="[progressTextId]"></div></div>
2688		var progressDiv = '<div id="' + progressBarId +  '" class="progressBar">' + '<div id="' + progressTextId +  '" class="progressBarText">' + '</div>' + '</div>'
2689		$(progressDiv).insertAfter("#" + executeStatus);
2690		if (progress == 0) {
2691			progress = false;
2692		} else {
2693			$("#" + progressTextId).text(progress + "%");
2694			progress = parseInt(progress);
2695		}
2696		$("#" + progressBarId).progressbar({
2697			value: progress,
2698			max: 100
2699		});
2700
2701	} else {
2702		// 値の更新
2703		if (progress != 0) {
2704			progressBar.progressbar("value", progress);
2705			$("#" + progressTextId).text(progress + "%");
2706		}
2707	}
2708}
2709
2710/**
2711 * プログレスバーを非表示にします。
2712 * @param progressBarId プログレスバーのID
2713 */
2714function removeBatchExecuteProgress(progressBarId) {
2715	var progressBar = $("#" + progressBarId);
2716	if (progressBar != null) {
2717		progressBar.remove();
2718	}
2719}
2720
2721/**
2722 * バッチ実行のステータスが完了している際に呼ばれるコールバックメソッドです。
2723 * 必要に応じて、各画面でメソッドを上書きしてください。
2724 * @param batchId 実行したBatchID
2725 * @param executeTitle 実行のタイトル
2726 * @param executeResult Batch実行結果(1: 正常終了、2: 異常終了、3: メンテナンス中)
2727 */
2728function callbackBatchStatusEnd(batchId, executeTitle, executeResult) {
2729
2730}
2731
2732/**
2733 * バッチ実行のステータスが実行中の場合に呼ばれるコールバックメソッドです。
2734 * 必要に応じて、各画面でメソッドを上書きしてください。
2735 * @param batchId 実行したBatchID
2736 * @param executeTitle 実行のタイトル
2737 */
2738function callbackBatchStatusInprogress(batchId, executeTitle) {
2739
2740}
2741
2742/**
2743 * バッチ実行完了時に呼ばれるコールバックメソッドです。(バッチが実際に実行されていた場合に呼ばれます)
2744 * 現実装では、空のサブミットを実施しますが、必要に応じて、各画面でメソッドを上書きしてください。
2745 * @param batchId 実行したBatchID
2746 * @param executeTitle 実行のタイトル
2747 * @param executeResult Batch実行結果(1: 正常終了、2: 異常終了、3: メンテナンス中)
2748 */
2749function callbackBatchExecuteDone(batchId, executeTitle, executeResult) {
2750	submit(null);
2751}
2752
2753/**
2754 * キーイベントを無視するかどうかを判定します。
2755 * @param obj イベント発生オブジェクト
2756 * @returns {Boolean} true : 無視する
2757 */
2758function isIgnoreOnkeydownEvent(obj) {
2759	if (obj.type == 'textarea' || obj.type == 'select-one' || obj.type == 'select-multiple') {
2760		return true;
2761	} else {
2762		return false;
2763	}
2764}
2765
2766/**
2767 * 明細でのキーイベント時に次の行の同項目に移動するかどうか判定します。
2768 * @param obj イベント発生オブジェクト
2769 * @returns 明細でのキーイベント時に次の行の同項目に移動する場合true
2770 */
2771function isFocusNextRowOnkeydownEvent(obj) {
2772	if (isObjectInputType(obj) || isObjectButtonType(obj) || isObjectLinkType(obj)) {
2773		return true;
2774	} else {
2775		return false;
2776	}
2777}
2778
2779/**
2780 * 入力チェックエラー時に呼ばれる関数です。
2781 */
2782function existErrorAction() {
2783	Validator.focusToFirstErrorElement();
2784	existErrorActionContents();
2785}
2786
2787/**
2788 * 入力チェックエラー時に呼ばれる関数です。
2789 * 必要に応じて、各画面ないし共通JSで上書きしてください。
2790 */
2791function existErrorActionContents() {
2792
2793}
2794
2795/**
2796 * 明細番号リンクにフォーカスさせます。
2797 * @param listId 明細リストID
2798 * @param rowIndex 行インデックス
2799 * @param indexSymbol インデックスシンボル
2800 * @param isForceFocus 明細内にフォーカスされたエレメントがあったとしても強制的に明細番号にフォーカスを移動させるか
2801 * @returns 移動した場合true
2802 */
2803function focusToListSequence(listId, rowIndex, indexSymbol, isForceFocus) {
2804    var targetSequenceElement = document.getElementById(listId + "Sequence" + indexSymbol);
2805    if (isNullorUndefined(targetSequenceElement)) {
2806    	return false;
2807    }
2808
2809    var isFocus = false;
2810    if (isForceFocus) {
2811    	isFocus = true;
2812    } else {
2813	    var activeElement = document.activeElement;
2814	    if (isNullorUndefined(activeElement)) {
2815	        return false;
2816	    }
2817	    var activeElementId = activeElement.id;
2818	    if (isNullorUndefined(activeElementId)) {
2819	        return false;
2820	    }
2821
2822	    if (isFocusNextRowOnkeydownEvent(activeElement)) {
2823	    	return false;
2824	    }
2825
2826	    if (activeElementId.indexOf(indexSymbol, activeElementId.length - indexSymbol.length) == -1) {
2827		    isFocus = true;
2828	    }
2829    }
2830
2831    if (isFocus) {
2832	    targetSequenceElement.focus();
2833	    return true;
2834	} else {
2835	    return false;
2836	}
2837}
2838
2839
2840/**
2841 * 引数URLにContextPathをつけたURLを返却します。
2842 * @param url 指定URL(先頭の/は削除して渡すこと)
2843 * @param relativePath 相対パス(コンテキストパスが設定されていれば不要)
2844 * @returns 引数URLにContextPathをつけたURL
2845 */
2846function getUrlWithContextPath(url, relativePath) {
2847	var contextPathId = "appContextPath";
2848	var contextPathElement = document.getElementById(contextPathId);
2849	if (isNullorUndefined(contextPathElement)) {
2850		// 設定がないので、相対パスでコンテキストパスを辿る
2851		return relativePath + url;
2852	}
2853
2854 	var contextPath = getElementValue(contextPathId);
2855	var urlWithContextPath;
2856	if (contextPath == "" || contextPath == "/") {
2857		urlWithContextPath = "/" + url;
2858	} else {
2859		urlWithContextPath = contextPath + url;
2860	}
2861	return urlWithContextPath;
2862}
2863
2864/**
2865 * 指定したアイテムへフォーカスを移動します。<br/>
2866 * タブで隠れているアイテムの場合、アイテムが存在するタブを選択します。
2867 * @param itemId 対象アイテムID
2868 * @returns フォーカスしたかどうか
2869 */
2870function focusToItem(itemId) {
2871	var item = document.getElementById(itemId);
2872	if (isNullorUndefined(item)) {
2873		// 電話番号、郵便番号の可能性
2874		var originalItemId = itemId.split("_")[0];
2875		var tempId = itemId.replace(new RegExp("^" + originalItemId), originalItemId + "Pre");
2876		var tempItem = document.getElementById(tempId);
2877		if (!isNullorUndefined(tempItem)) {
2878			itemId = tempId;
2879			item = tempItem;
2880		} else {
2881			// radio/checkboxの可能性
2882			tempId = itemId + "_0";
2883			tempItem = document.getElementById(tempId);
2884			if (!isNullorUndefined(tempItem)) {
2885				var type = tempItem.type;
2886				if (type == 'radio' || type == 'checkbox') {
2887					itemId = tempId;
2888					item = tempItem;
2889				} else {
2890					return false;
2891				}
2892			} else {
2893				// single radioの可能性
2894				var tempItems = document.getElementsByName(itemId);
2895				if (isNullorUndefined(tempItems) || tempItems.length == 0) {
2896					return false;
2897				}
2898				item = tempItems[0];
2899				itemId = item.id;
2900			}
2901		}
2902	}
2903
2904	// 対象アイテムが所属するタブへ移動(タブがあれば)
2905	moveTabToItemExist(itemId, false);
2906
2907	if (isTargetItemVisible(itemId)) {
2908		// フォーカス移動の表現
2909		moveScrollToTargetItem(itemId);
2910
2911		// フォーカス移動
2912		if (item.focus != undefined) {
2913			item.focus();
2914		}
2915		return true;
2916	} else {
2917		focusToItemIfItemInvisible(itemId);
2918	}
2919}
2920
2921/**
2922 * 対象アイテムが存在するタブに移動します。<br/>
2923 * タブが階層化されている場合にも対応しています。
2924 * @param itemId 対象アイテムID
2925 * @param isFocusFirstElement タブ選択時に先頭項目にタブを移動するか
2926 */
2927function moveTabToItemExist(itemId, isFocusFirstElement) {
2928	var item = document.getElementById(itemId);
2929	if (isNullorUndefined(item)) {
2930		return;
2931	}
2932
2933	var parentTabId = getTabIdBelongItem(item);
2934	if (!isNullorUndefinedorEmpty(parentTabId)) {
2935		var moveTabPanelId = parentTabId.replace(/Tab$/, "");
2936		selectTabById(moveTabPanelId, isFocusFirstElement);
2937		var moveTabPanel = document.getElementById(moveTabPanelId);
2938		if (!isNullorUndefined(moveTabPanel) && !isNullorUndefined(moveTabPanel.parentNode)) {
2939			var moveTabPanelParent = moveTabPanel.parentNode.parentNode;
2940			if (!isNullorUndefined(moveTabPanelParent)) {
2941				var moveTabPanelParentId = moveTabPanelParent.id;
2942				if (moveTabPanelParentId == parentTabId) {
2943					if (isNullorUndefined(moveTabPanelParent.parentNode)) {
2944						return;
2945					} else {
2946						moveTabPanelParentId = moveTabPanelParent.parentNode.id;
2947					}
2948				}
2949
2950				moveTabToItemExist(moveTabPanelParentId, isFocusFirstElement);
2951			}
2952		}
2953	}
2954
2955}
2956
2957/**
2958 * 対象アイテムが所属するタブIDを取得します。
2959 * @param itemId アイテムID
2960 * @returns 対象アイテムが所属するタブID
2961 */
2962function getTabIdBelongItem(element) {
2963	if (isNullorUndefined(element)) {
2964		return null;
2965	}
2966
2967	if (isNullorUndefined(element.getAttribute)) {
2968		return null;
2969	}
2970
2971	var attributeRole = element.getAttribute("role");
2972	if (!isNullorUndefined(attributeRole)) {
2973		if (attributeRole == "tabpanel") {
2974			return element.id;
2975		}
2976	} else {
2977		if (isNullorUndefined(element.parentNode)) {
2978			return null;
2979		} else {
2980			return getTabIdBelongItem(element.parentNode);
2981		}
2982	}
2983}
2984
2985/**
2986 * 対象アイテム項目へアイテムIDを指定してスクロールを移動します。
2987 * @param itemId 対象アイテムID
2988 */
2989function moveScrollToTargetItem(itemId) {
2990	var itemPosition = $("#" + itemId).offset().top - 20;
2991	moveScrollToTargetPosition(itemPosition);
2992}
2993
2994/**
2995 * 対象ポジションへスクロールを移動します。
2996 * @param item 対象アイテム(ただしjQueryのオブジェクトであること)
2997 */
2998function moveScrollToTargetPosition(itemPosition) {
2999	if (itemPosition < 0) {
3000		itemPosition = 0;
3001	}
3002	$('html,body').animate({ scrollTop: itemPosition }, 'slow');
3003}
3004
3005/**
3006 * (特殊な状況)指定した表示されていないアイテムへのフォーカス移動指示を制御します。<br/>
3007 * @param itemId 対象アイテムID
3008 * @returns フォーカスしたかどうか
3009 */
3010function focusToItemIfItemInvisible(itemId) {
3011	// 表示されていない項目でどう処理すべきか不明なものは、「エラーがあります」へ移動する
3012	moveScrollToTargetItem("errorGroup");
3013	return false;
3014}
3015
3016/**
3017 * 対象項目IDを持つエレメントの表示状態を取得します。
3018 * @param itemId 対象項目ID
3019 * @returns 表示されている場合true
3020 */
3021function isTargetItemVisible(itemId) {
3022	return $("#" + itemId).is(':visible');
3023}
3024
3025/**
3026 * 対象項目IDを持つエレメントを表示します。
3027 * @param itemId 対象項目ID
3028 */
3029function showArea(itemId) {
3030	$("#" + itemId).show();
3031}
3032
3033/**
3034 * 対象項目IDを持つエレメントを隠します。
3035 * @param itemId 対象項目ID
3036 */
3037function hideArea(itemId) {
3038	$("#" + itemId).hide();
3039}
3040
3041/**
3042 * 指定された明細のチェックボックスを指定されたチェック状態とします。
3043 * @param check チェック状態(true or false)
3044 * @param tableId 明細ID
3045 * @param targetCheckId チェックされる項目のID
3046 * @param indexSymbol (対象明細の)インデックスシンボル
3047 */
3048function checkAll(check, tableId, targetCheckId, indexSymbol) {
3049	if (isNullorUndefined(tableId) || isNullorUndefined(targetCheckId)) {
3050		return;
3051	}
3052	var dataSize = getElementValue(tableId + "DataSize");
3053    for (var i = 0; i < dataSize; i++) {
3054    	var checkElement = document.getElementById(targetCheckId + indexSymbol + "_" + i);
3055    	if (!isNullorUndefined(checkElement)) {
3056    		checkElement.checked = check;
3057    	}
3058    }
3059}
3060
3061/**
3062 * 指定された明細のチェックボックスが少なくとも一つチェックされているか判定します。
3063 * @param tableId 明細ID
3064 * @param targetCheckId チェックされる項目のID
3065 * @param indexSymbol (対象明細の)インデックスシンボル
3066 * @return 一つでもチェックされている場合、true
3067 */
3068function isCheckAtLeastOne(tableId, targetCheckId, indexSymbol) {
3069	if (isNullorUndefined(tableId) || isNullorUndefined(targetCheckId)) {
3070		return false;
3071	}
3072	var dataSize = getElementValue(tableId + "DataSize");
3073    for (var i = 0; i < dataSize; i++) {
3074    	var checkElement = document.getElementById(targetCheckId + indexSymbol + "_" + i);
3075    	if (!isNullorUndefined(checkElement)) {
3076    		if (checkElement.checked) {
3077    			return true;
3078    		}
3079    	}
3080    }
3081    return false;
3082}
3083
3084/**
3085 * 対象のID(とindexSymbol)で定義されたエレメントが存在するか判定します。(_innerIdで出力されているものも対象にします)
3086 * @param id ID
3087 * @param indexSymbol インデックスシンボル
3088 * @returns エレメントが存在する場合true
3089 */
3090function isExistTargetItem(id, indexSymbol) {
3091	if (isNullorUndefined(indexSymbol)) {
3092		indexSymbol = "";
3093	}
3094
3095	var targetId = id + indexSymbol;
3096	if (!isNullorUndefined(document.getElementById(targetId))) {
3097		return true;
3098	}
3099
3100	if (!isNullorUndefined(document.getElementById(targetId + "_innerId"))) {
3101		return true;
3102	}
3103
3104	return false;
3105}
3106
3107/**
3108 * 対象のID(とindexSymbol)で定義されたエレメントの値を取得します。(_innerIdで出力されているものも対象にします)
3109 * @param id ID
3110 * @param indexSymbol インデックスシンボル
3111 * @returns 対象のvalue値
3112 */
3113function getValue(id, indexSymbol) {
3114	if (isNullorUndefined(indexSymbol)) {
3115		indexSymbol = "";
3116	}
3117
3118	var targetId = id + indexSymbol;
3119	var value = getElementValue(targetId);
3120	if (!isNullorUndefined(value)) {
3121		return value;
3122	}
3123
3124	return getElementValue(targetId + "_innerId");
3125}
3126
3127/**
3128 * 対象のID(とindexSymbol)で定義されたエレメントを数値として取得します。(_innerIdで出力されているものも対象にします)
3129 * @param id ID
3130 * @param indexSymbol インデックスシンボル
3131 * @returns 対象のvalue値(数値)
3132 */
3133function getValueNumber(id, indexSymbol) {
3134	var value = getValue(id, indexSymbol);
3135	return toNumber(value);
3136}
3137
3138/**
3139 * 指定したエレメントのvalueを書き換えます。(text/checkbox/radio/hidden etc.)
3140 * @param id エレメントのID
3141 * @param value 設定する値
3142 * @param isOverwrite 上書きするか
3143 */
3144function setValue(id, value, isOverwrite) {
3145	if (isUndefined(value)) {
3146		// undefinedは設定しない
3147		return;
3148	}
3149	var element = document.getElementById(id);
3150
3151	if (!isNullorUndefined(element)) {
3152		if (isNullorUndefined(value)) {
3153			value = "";
3154		}
3155
3156		if (isOverwrite) {
3157			element.value = value;
3158		} else {
3159			if (element.value == null || element.value == "") {
3160				element.value = value;
3161			}
3162		}
3163	} else {
3164		// radioの可能性
3165		var elements = document.getElementsByName(id);
3166		if (!isNullorUndefined(elements) && elements.length > 0) {
3167			if (elements[0].type == "radio") {
3168				checkRadioElement(elements, value);
3169			}
3170		}
3171	}
3172
3173	// innerId
3174	element = document.getElementById(id + '_innerId');
3175	if (!isNullorUndefined(element)) {
3176		if (isNullorUndefined(value)) {
3177			value = "";
3178		}
3179
3180		if (isOverwrite) {
3181			if (isNullorUndefined(element.value)) {
3182				element.innerText = value;
3183			} else {
3184				element.value = value;
3185			}
3186		} else {
3187			if (element.value == null || element.value == "") {
3188				element.value = value;
3189			} else if (element.innerText == null || element.innerText == "") {
3190				element.innerText = value;
3191			}
3192		}
3193	}
3194}
3195
3196
3197/**
3198 * 対象ID(+indexSymbol)のエレメントの値に指定した値をプラスします。(引数がマイナス指定の場合はマイナスされます)
3199 * @param id 対象エレメントID
3200 * @param indexSymbol インデックスシンボル(明細の場合指定)
3201 * @param addCount エレメントに追加される値(数値: マイナス指定可能)
3202 * @param min 最小設定値
3203 * @param max 最大設定値
3204 * @param isSeparate カンマ区切りをするか
3205 */
3206function setAddCount(id, indexSymbol, addCount, min, max, isSeparate) {
3207	var elementId = id + indexSymbol;
3208	var nowValue = getElementValue(elementId);
3209	var nowNumberValue;
3210	try {
3211		nowNumberValue = Number(removeCanma(nowValue));
3212	} catch(e) {
3213		// 数値でない
3214		return;
3215	}
3216
3217	var settingNumberValue = nowNumberValue + addCount;
3218	if (!isNullorUndefined(min) && settingNumberValue < min) {
3219		// 最小より小さい
3220		return;
3221	}
3222
3223	if (!isNullorUndefined(max) && max < settingNumberValue) {
3224		// 最大より大きい
3225		return;
3226	}
3227
3228	if (isSeparate) {
3229		settingNumberValue = getFormatedNumberString(settingNumberValue, 0, isSeparate)
3230	}
3231	setValue(elementId, settingNumberValue, true);
3232
3233	var settingValue = getElementValue(elementId);
3234	if (isNullorUndefinedorEmpty(settingValue)) {
3235		// 元に戻す(コンボなど選択値にないものを設定した可能性を考慮)
3236		setValue(elementId, nowValue, true);
3237	}
3238}
3239
3240/**
3241 * 指定された要素の配下の入力項目にdisableを設定します。
3242 * @param id 対象要素のid
3243 * @param exceptList 除外する項目idの配列
3244 */
3245function changeDisabledAll(id, exceptList) {
3246	if(id == null || id == undefined) {
3247		return;
3248	}
3249	$('#' + id).find('input, select, textarea').each(function(){
3250		if (!isNullorUndefined(exceptList)) {
3251			if (0 <= exceptList.indexOf(this.id) || 0 <= exceptList.indexOf(this.name)) {
3252				return;
3253			}
3254		}
3255
3256		if (this.type == 'hidden') {
3257			return;
3258		} else if (this.type == 'radio'){
3259			changeDisabledRadio(this.name);
3260		} else {
3261			changeDisabled(this.id);
3262		}
3263	});
3264}
3265
3266/**
3267 * 指定された要素の配下の入力項目のdisableを解除します。
3268 * @param id 対象要素のid
3269 * @param exceptList 除外する項目idの配列
3270 */
3271function changeEnabledAll(id, exceptList) {
3272	if(id == null || id == undefined) {
3273		return;
3274	}
3275	$('#' + id).find('input, select, textarea').each(function(){
3276		if (!isNullorUndefined(exceptList)) {
3277			if (0 <= exceptList.indexOf(this.id) || 0 <= exceptList.indexOf(this.name)) {
3278				return;
3279			}
3280		}
3281
3282		if (this.type == 'hidden') {
3283			return;
3284		} else if(this.type == 'radio'){
3285			changeEnabledRadio(this.name);
3286		} else {
3287			changeEnabled(this.id);
3288		}
3289	});
3290}
3291
3292/**
3293 * イベントの初期化処理を追加で設定します。主にjQueryに依存した機能の追加処理です。
3294 * @param obj オブジェクト
3295 */
3296function initEventObjectAdd(obj) {
3297	initDateTimePicker(obj);
3298}
3299
3300/**
3301 * DateTimePickerの初期化処理です。
3302 * @param obj オブジェクト
3303 */
3304function initDateTimePicker(obj) {
3305	if (isNullorUndefined(obj)) {
3306		return;
3307	}
3308	var className = obj.className;
3309	if (isNullorUndefinedorEmpty(className)) {
3310		return;
3311	}
3312
3313	var id = obj.id;
3314	if (isNullorUndefinedorEmpty(id)) {
3315		return;
3316	}
3317
3318	if (className.indexOf("DATE_YYMM") >= 0) {
3319		// YYYY/MM
3320		settingDatepicker(id, true);
3321	} else if (className.indexOf("DATE_TIME") >= 0) {
3322		// YYYY/MM/DD hh:mi:ss
3323		settingDatetimepicker(id, false);
3324	} else if (className.indexOf("DATE_HOUR_MINUTES") >= 0) {
3325		// YYYY/MM/DD hh:mi
3326		settingDateHourMinutestimepicker(id);
3327	} else if (className.indexOf("TIMESTAMP") >= 0) {
3328		// YYYY/MM/DD hh:mi:ss sss
3329		settingDatetimepicker(id, true);
3330	} else if (className.indexOf("BIRTHDAY") >= 0) {
3331		// 生年月日はカレンダー表示対象外
3332	} else if (className.indexOf("DATE") >= 0) {
3333		// YYYY/MM/DD
3334		settingDatepicker(id, false);
3335	} else if (className.indexOf("TIME") >= 0) {
3336		// hh:mi
3337		settingTimepicker(id);
3338	}
3339}
3340
3341function removeEventObjectAdd(obj) {
3342	// jqueryのイベントアンバインド処理
3343	if (isNullorUndefined(obj) || isNullorUndefined(obj.id)) {
3344		return;
3345	}
3346
3347	var itemId = obj.id;
3348	if (itemId.lastIndexOf("}") > 0) {
3349		// jqueryでシンタックスエラーになるため
3350		return;
3351	}
3352
3353	var item = $("#" + itemId);
3354	item.unbind();
3355}
3356
3357function onkeydownList(e, selectedIndexId, indexSymbol, selectedRowReturnedFunction, selectByIndexFunction) {
3358    if (isIgnoreOnkeydownEvent(e.target)) {
3359        // 明細のキーイベントを無視する
3360        return true;
3361    }
3362    var form = document.forms["formMain"];
3363    var selected = form.elements[selectedIndexId + indexSymbol];
3364    var selectedIndex = parseInt(selected.value);
3365    var selectedIndexValid = true;
3366    if (selectedIndex.toString() == "NaN") {
3367	    selectedIndexValid = false;
3368    }
3369
3370    if (e.keyCode == 13) {
3371    	if (selectedIndexValid) {
3372	        // リターンキー押下
3373	        selectedRowReturnedFunction(selectedIndex);
3374	        return false;
3375	    } else {
3376	    	return true;
3377	    }
3378    } else if (e.keyCode == 38) {
3379        // 上
3380    	var nextIndex;
3381        if (isFocusNextRowOnkeydownEvent(e.target)) {
3382            nextIndex = listFocusNextElement(e.target, false);
3383        } else {
3384    		if (selectedIndexValid) {
3385	            nextIndex = selectedIndex - 1;
3386	        } else {
3387	        	return true;
3388	        }
3389        }
3390        if (selectedIndexValid) {
3391	        selectByIndexFunction(nextIndex, indexSymbol + "_" + nextIndex, true);
3392	    }
3393        return false;
3394    } else if (e.keyCode == 40) {
3395        // 下
3396       	var nextIndex;
3397        if (isFocusNextRowOnkeydownEvent(e.target)) {
3398            nextIndex = listFocusNextElement(e.target, true);
3399        } else {
3400    		if (selectedIndexValid) {
3401		        nextIndex = selectedIndex + 1;
3402	        } else {
3403	        	return true;
3404	        }
3405        }
3406        selectByIndexFunction(nextIndex, indexSymbol + "_" + nextIndex, true);
3407        return false;
3408    } else {
3409        // その他のキー
3410        return true;
3411    }
3412}
3413
3414function listFocusNextElement(element, incrementIndex) {
3415	var listObject = new ListObject(element);
3416
3417    if (listObject.nowIndex == null) {
3418    	return null;
3419   	}
3420
3421   	var parentTrElement = getParentTrElement(element);
3422   	if (isNullorUndefined(parentTrElement)) {
3423   		return null;
3424   	}
3425
3426   	var targetTrElement = getNextTrElement(parentTrElement, incrementIndex);
3427   	if (targetTrElement == null) {
3428   		return null;
3429   	}
3430
3431   	var targetJElement = $(targetTrElement).find("[id^=\"" + listObject.parentId + "_\"]");
3432   	if (targetJElement.length != 1) {
3433   		return null;
3434   	}
3435
3436   	var targetElement = targetJElement[0];
3437   	var targetListObject = new ListObject(targetElement);
3438
3439   	targetElement.focus();
3440   	return targetListObject.nowIndex;
3441}
3442
3443function getParentTrElement(element) {
3444	if (isNullorUndefined(element)) {
3445		return null;
3446	}
3447
3448	var parent = element.parentElement;
3449	if (isNullorUndefined(parent)) {
3450		return null;
3451	}
3452
3453	var tagName = parent.tagName;
3454	if (isNullorUndefinedorEmpty(tagName) || tagName.toLowerCase() != "tr") {
3455		return getParentTrElement(parent);
3456	} else {
3457		return parent;
3458	}
3459}
3460
3461function getNextTrElement(trElement, moveToDown) {
3462	if (isNullorUndefined(trElement)) {
3463		return null;
3464	}
3465
3466   	var targetTrElement = trElement;
3467	var targetTrElementIdExist = false;
3468	do {
3469	   	if (moveToDown) {
3470   			targetTrElement = targetTrElement.nextElementSibling;
3471   		} else {
3472	   		targetTrElement = targetTrElement.previousElementSibling;
3473   		}
3474   		if (isNullorUndefined(targetTrElement)) {
3475   			return null;
3476   		}
3477
3478   		if (!isNullorUndefinedorEmpty(targetTrElement.id)) {
3479   			if (targetTrElement.style.display == "none") {
3480   				return getNextTrElement(targetTrElement, moveToDown);
3481   			} else {
3482	   			targetTrElementIdExist = true;
3483	   		}
3484   		}
3485	} while (!targetTrElementIdExist);
3486
3487	return targetTrElement;
3488}
3489
3490var ListObject = function() {
3491	this.initialize.apply(this, arguments);
3492}
3493
3494ListObject.prototype = {
3495	id: null,
3496	parentId: null,
3497	indexSymbol: null,
3498	nowIndex: null,
3499	idTemplate: null,
3500	templateReplaceString: "@@@",
3501	isRadio: false,
3502	isLink: false,
3503
3504    initialize: function(element) {
3505    	this.id = element.id;
3506    	this.isRadio = isObjectRadioType(element);
3507    	this.isLink = isObjectLinkType(element);
3508
3509    	this.analyze(element);
3510	},
3511
3512	analyze: function(element) {
3513		var splitIdArray = this.id.split("_");
3514		var lastIndex = splitIdArray.length - 1;
3515		if (this.isRadio) {
3516			if (lastIndex < 2) {
3517				// listでない
3518				return;
3519			}
3520
3521			this.parentId = splitIdArray[0];
3522			for (var i = 1; i < lastIndex - 1; i++) {
3523				this.parentId = this.parentId + "_" + splitIdArray[i];
3524				this.indexSymbol = "_" + splitIdArray[i];
3525			}
3526			this.nowIndex = splitIdArray[lastIndex - 1];
3527			this.idTemplate = this.parentId + "_" + this.templateReplaceString;
3528		} else if (this.isLink) {
3529			if (lastIndex < 1) {
3530				// listでない
3531				return;
3532			}
3533
3534			var linkSuffix = "link";
3535			this.parentId = splitIdArray[0];
3536
3537			if (splitIdArray[lastIndex] == linkSuffix) {
3538				existLinkSuffix = true;
3539				if (lastIndex < 2) {
3540					// listでない
3541					return;
3542				}
3543				for (var i = 1; i < lastIndex - 1; i++) {
3544					this.parentId = this.parentId + "_" + splitIdArray[i];
3545				}
3546				this.nowIndex = splitIdArray[lastIndex - 1];
3547				this.idTemplate = this.parentId + "_" + this.templateReplaceString + "_" + linkSuffix;
3548			} else {
3549				for (var i = 1; i < lastIndex; i++) {
3550					this.parentId = this.parentId + "_" + splitIdArray[i];
3551				}
3552				this.nowIndex = splitIdArray[lastIndex];
3553				this.idTemplate = this.parentId + "_" + this.templateReplaceString;
3554			}
3555		} else {
3556			if (lastIndex < 1) {
3557				// listでない
3558				return;
3559			}
3560
3561			this.parentId = splitIdArray[0];
3562			for (var i = 1; i < lastIndex; i++) {
3563				this.parentId = this.parentId + "_" + splitIdArray[i];
3564			}
3565			this.nowIndex = splitIdArray[lastIndex];
3566			this.idTemplate = this.parentId + "_" + this.templateReplaceString;
3567		}
3568		var nowIndexNumber = new Number(this.nowIndex);
3569		if(!isNaN(nowIndexNumber)) {
3570			this.nowIndex = nowIndexNumber;
3571		}
3572	},
3573
3574	getIndicateIndexElement: function(indicateIndex) {
3575		var elementId = this.getIndicateIndexId(indicateIndex);
3576		if (!this.isRadio) {
3577			return document.getElementById(elementId);
3578		} else {
3579			// ラジオは先頭項目を取得
3580			var radioFirstId = elementId + "_0";
3581			return document.getElementById(radioFirstId);
3582		}
3583	},
3584
3585	getIndicateIndexId: function(indicateIndex) {
3586		return this.idTemplate.replace(this.templateReplaceString, indicateIndex);
3587	}
3588}
3589
3590function initCleditor(editorId) {
3591	if (isNullorUndefinedorEmpty(editorId)) {
3592		return;
3593	}
3594
3595	var jEditorObject = $("#" + editorId);
3596	if (isNullorUndefined(jEditorObject)) {
3597		return;
3598	}
3599
3600	try {
3601        jEditorObject.cleditor();
3602	} catch (e) {
3603		Validator.outputbyId(editorId, Validator.rule.msg.others.cleditor_init);
3604		try {
3605			var text = jEditorObject.val();
3606			jEditorObject.val("");
3607        	$editor = jEditorObject.cleditor()[0];
3608   	    	$editor.refresh();
3609			jEditorObject.val(text);
3610        } catch (e) {
3611			Validator.outputbyId(editorId, editorId + ":" + e);
3612        }
3613	}
3614
3615}
3616
3617/**
3618 * 数値文字参照(16進数)を文字列に変換します。
3619 * @param {} hexNumRef
3620 * @returns {}
3621 */
3622function hexNumRefToString(hexNumRef) {
3623	return hexNumRef.replace(/&#x([0-9a-f]+);/ig, function(match, $1, idx, all) {
3624		return String.fromCharCode('0x' + $1);
3625	});
3626}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.