<!--
var ajax = null;
function Ajax(sendElement, async, progressImage, nullImage) {
	this.xmlHttp = null;
	this.elapsTime = 0;
	this.timeoutId = null;
	this.sendElement = sendElement;
	this.async = async;
	this.progressImage = progressImage;
	this.nullImage = nullImage;
	this.createXmlHttp = function() {
		var xmlHttp = null;
		if (Browser.type == Browser.MSIE7 || Browser.type == Browser.FIREFOX) {
			xmlHttp = new XMLHttpRequest(); 
		} else if (Browser.type == Browser.MSIE6 || Browser.type == Browser.MSIE) {
			/*@cc_on @*/
			/*@if (@_jscript_version >= 5)
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); 
			} catch (e) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");	
				} catch (E) {
					xmlHttp = null;
				}
			}
			@end @*/
		}
		if ((xmlHttp == null) && typeof XMLHttpRequest != 'undefined') {
			xmlHttp = new XMLHttpRequest();
		}
		this.xmlHttp = xmlHttp;
	}
	this.getXmlHttp = function() {
		return this.xmlHttp;
	}
	this.startTimeoutCheck = function() {
		this.elapsTime = 0;
		this.timeoutId = setInterval('ajax.checkAjaxTimeout()', 1000);
	}
	this.clearTimeoutId = function() {
		if (this.timeoutId != null) {
			clearInterval(this.timeoutId);
			this.timeoutId = null;
		}
	}
	this.postAfterFunc = function() {
		this.clearTimeoutId();
		setMouseCursor(this.sendElement, 'default');
		if (this.progressImage != null) {
			this.progressImage.style.display = 'none';
			this.progressImage.style.visibility = 'hidden';
		}
		if (this.nullImage != null) {
			this.nullImage.style.display = 'none';
			this.nullImage.style.visibility = 'hidden';
		}
		this.xmlHttp.onreadystatechange=function(){}; 
		LockAjaxRequest.unlock();
	}
	this.checkAjaxTimeout = function() {
		this.elapsTime++;
		if (this.elapsTime >= CONST.AJAX_TIMEOUT) {
			// Timeout
			this.postAfterFunc();
			this.getXmlHttp().abort();
			alert(MSG.JS_AJAX_REQUEST_TIMEOUT);
			return false;
		}
	}
	this.open = function(url) {
		var _xmlHttp = this.xmlHttp;
		_xmlHttp.open('POST', url, this.async);
		_xmlHttp.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
		_xmlHttp.setRequestHeader("If-Modified-Since", "0"); 
		_xmlHttp.setRequestHeader("Accept-Charset", "UTF-8");
		_xmlHttp.setRequestHeader("X-Client", CONST.VERSION);
		if (CONST.AJAX_CONNECTION_CLOSE) {
			_xmlHttp.setRequestHeader("Connection", "close");
		}
	}
	this.send = function(params) {
		if (this.async) {
	  	this.startTimeoutCheck();
		} else {
			this.timeoutId = null;
		}
		this.xmlHttp.send(params);
	}
	this.showProgressBar = function() {
		if (this.progressImage != null && this.timeoutId != null) {
			var pos = getWindowOffset();
			var windowSize = getWindowSize();
			this.progressImage.style.left = (windowSize.width - 148)/ 2 + pos.x;
			this.progressImage.style.top  = (windowSize.height - 27)/ 2 + pos.y;
			this.progressImage.style.display = 'block';
			this.progressImage.style.visibility = 'visible';
		}
	}
	this.setupCallBackFunction = function(callBackFunc, chainCallBackFunc, chainCallBackFuncArgs) {
		var xmlHttp = this.getXmlHttp();
		if (this.async) {
			if (callBackFunc == null) {
				xmlHttp.onreadystatechange=function(){
					try {
						if (xmlHttp.readyState == 4) {
							ajax.clearTimeoutId();
							if (xmlHttp.status != 200) {
								if (CONST.DEBUG) {
									alert(MSG.JS_SERVER_CONNECTION_ERROR2.replace(/\{0\}/, xmlHttp.status).replace(/\{1\}/, xmlHttp.responseText));
								} else {
									alert(MSG.JS_SERVER_CONNECTION_ERROR1);
								}
								ajax.postAfterFunc();
								return;
							}
							ajax.postAfterFunc();
						}
					} catch (e) {
						if (CONST.DEBUG) {
							alert(MSG.JS_SERVER_CONNECTION_ERROR3.replace(/\{0\}/, errorDescription(e)));
						} else {
							alert(MSG.JS_SERVER_CONNECTION_ERROR1);
						}
						ajax.postAfterFunc();
						return;
					}
				}
			} else {
				xmlHttp.onreadystatechange=function(){
					try {
						if (xmlHttp.readyState == 4) {
							ajax.clearTimeoutId();
							if (xmlHttp.status != 200) {
								if (CONST.DEBUG) {
									alert(MSG.JS_SERVER_CONNECTION_ERROR2.replace(/\{0\}/, xmlHttp.status).replace(/\{1\}/, xmlHttp.responseText));
								} else {
									alert(MSG.JS_SERVER_CONNECTION_ERROR1);
								}
								ajax.postAfterFunc();
								return;
							}
							ajax.postAfterFunc();
							callBackFunc(xmlHttp.responseText, chainCallBackFunc, chainCallBackFuncArgs);
						}
					} catch (e) {
						if (CONST.DEBUG) {
							alert(MSG.JS_SERVER_CONNECTION_ERROR3.replace(/\{0\}/, errorDescription(e)));
						} else {
							alert(MSG.JS_SERVER_CONNECTION_ERROR1);
						}
						ajax.postAfterFunc();
						return;
					}
				}
			}
		} else {
			// sync mode: set empty function
			xmlHttp.onreadystatechange=function(){};
		}
	}
	this.createXmlHttp();
	return this;
}
function AjaxRequest(sendElement, url, submitValue, params, values, encode, async) {
	this.sendElement = sendElement;
	this.url = url;
	this.submitValue = submitValue;
	this.params = params;
	this.values = values;
	this.encode = null;
	this.async = async;
	this.getSendElement = function() {
		return this.sendElement;
	}
	this.getURL = function() {
		var _questionIdx = this.url.indexOf('?');
		if (_questionIdx > 0) {
			return this.url.substring(0, _questionIdx);
		} else {
			return this.url;
		}
	}
	this.getSubmitValue = function() {
		return this.submitValue;
	}
	this.getParams = function() {
		return this.params;
	}
	this.getValues = function() {
		return this.values;
	}
	this.setEncode = function(encode) {
		if (encode == null) {
			this.encode = '';
		} else {
			this.encode = encode.toLowerCase();
		}
	}
	this.getEncode = function() {
		return this.encode;
	}
	this.isAsync = function() {
		return this.async;
	}
	this.getQueryParams = function(dmy) {
		var _params = '_SUB=' + this.submitValue;
		if (this.params != null) {
			var _paramLength = this.params.length;
			if (_paramLength > 0) {
				var _valueLength = 0;
				if (this.values != null) {
					_valueLength = this.values.length;
				}
				for (var i=0; i<_paramLength; i++) {
					_params += '&' + this.params[i] + '=';
					if (_valueLength > i && isNotNullString(this.values[i])) {
						_params += escapeUTF8(values[i]);
					}
				}
			}
		}
		if (isNullString(dmy)) {
			dmy = new Date().getTime();
		}
		_params += '&_DMY=' + dmy;
		return _params;
	}
	this.setEncode(encode);
	return this;
}
var LockAjaxRequest = {
	locked : false,	
	lock : function() {
		if (this.locked) {
			return false;
		}
		this.locked = true;
		return true;
	},
	unlock : function() {
		this.locked = false;
	}
}
function sendAjaxRequest(ajaxRequest, callBackFunc, chainCallBackFunc, chainCallBackFuncArgs) {
	if (CONST.DEBUG) logger.writeHTML('getServerResponse is called. url=' + ajaxRequest.getURL() + ', submitValue=' + ajaxRequest.getSubmitValue());
	if (!LockAjaxRequest.lock()) {
		alert(MSG.JS_AJAX_NOW_EXECUTING);
		return; // now executing.
	}
	setMouseCursor(ajaxRequest.getSendElement(), 'wait');
	var progressImage = document.getElementById("NINJAVA_PROGRESS_IMG_DIV");
	var nullImage = document.getElementById("NINJAVA_NULL_IMG_DIV");
	if (nullImage != null) {
		var _frameSize = getScrollSize();
		nullImage.firstChild.width  = _frameSize.width;
		nullImage.firstChild.height = _frameSize.height;
		nullImage.style.display = 'block';
		nullImage.style.visibility = 'visible';
	}
	var _params = ajaxRequest.getQueryParams(null);
	if (CONST.DEBUG) {
		logger.writeHTML('getServerResponse:_url', ajaxRequest.getURL());
		logger.writeHTML('getServerResponse:_params', _params);
	}
	ajax = new Ajax(ajaxRequest.getSendElement(), ajaxRequest.isAsync(), progressImage, nullImage);
	ajax.setupCallBackFunction(callBackFunc, chainCallBackFunc, chainCallBackFuncArgs);
	ajax.open(ajaxRequest.getURL());
	ajax.send(_params);
	setTimeout('ajax.showProgressBar()', CONST.AJAX_PROGRESSBAR_SHOW_DELAY);
	if (!ajaxRequest.isAsync()) {
		ajax.postAfterFunc();
		callBackFunc(ajax.getXmlHttp().responseText, chainCallBackFunc, chainCallBackFuncArgs);
	}
}
function doNinjavaAjaxAction(submitInfo, chainCallBackFunc, chainCallBackFuncArgs) {
	var paramCount = 0;
	var _params = new Array();
	var _values = new Array();
	var _inf = submitInfo.getInf();
	if (isNotNullString(_inf)) {
		_params[0] = '_INF';
		_values[0] = _inf;
		paramCount = 1;
	}
	//_params[paramCount] = "_NJ_AJX";
	//_values[paramCount] = "true";
	//paramCount++;
	var _sendElement = submitInfo.getSendElement();
	if (_sendElement != null) {
		if (isNotNullString(submitInfo.getEventValue())) {
			_params[paramCount] = '_EVT_VAL';
			_values[paramCount] = submitInfo.getEventValue();
			paramCount++;
		}
		if (isNotNullString(submitInfo.getEventId())) {
			_params[paramCount] = '_EVT_ID';
			_values[paramCount] = submitInfo.getEventId();
			paramCount++;
			if (CONST.DEBUG) logger.write('_EVT_ID='+submitInfo.getEventId());
		}
	}
	// CID,WID,WSQ,CHK
	if (isNotNullString(submitInfo.getCid())) {
		_params[paramCount] = '_CID';
		_values[paramCount] = submitInfo.getCid();
		paramCount++;
		_params[paramCount] = '_WID';
		_values[paramCount] = submitInfo.getWid();
		paramCount++;
		_params[paramCount] = '_WSQ';
		_values[paramCount] = submitInfo.getWsq();
		paramCount++;
		if (isNotNullString(submitInfo.getChk())) {
			_params[paramCount] = '_CHK';
			_values[paramCount] = submitInfo.getChk();
			paramCount++;
		}
	}
	var _hdvSpanTag = null;
	var _tabs = null;
	if (submitInfo.isSendParams()) {
		_hdvSpanTag = getParentTag(_sendElement, 'SPAN', 'nj:htmlDataView');
		if (CONST.DEBUG) {
			logger.write('_hdvSpanTag = '+_hdvSpanTag);
			logger.write('sendTab =  '+submitInfo.getSendTab());
			logger.write('submitInfo.isSendParams() = '+submitInfo.isSendParams());
		}
	}
	if (submitInfo.getSendTab() == null && submitInfo.isSendParams()) {
		if (CONST.DEBUG) logger.write('tab0 in <form> = ' + getChildTag(_hdvSpanTag, 'SPAN', 'nj:tab', false));
		_tabs = getChildTags(_hdvSpanTag, 'SPAN', 'nj:tab', false);
		if (CONST.DEBUG) logger.write('tabs in <form> = ' + _tabs);
	}
	var _swoName = submitInfo.getSWO();
	if (isNotNullString(_swoName)) {
		_params[paramCount] = CONST.HTML_SWO;
		_values[paramCount] = _swoName;
		paramCount++;
		if (CONST.DEBUG) logger.write('swoName = '+_swoName);
	}
	if (CONST.DEBUG) logger.write('paramCount = ' + paramCount);
	if (submitInfo.isSendParams()) {
		var _formTag = getParentTag(_hdvSpanTag, 'FORM', null);
		if (CONST.DEBUG) logger.write('_formTag = ' + _formTag);
		if (_formTag != null) {
			var _parentTab = null;
			if (submitInfo.getSendTab() != null) {
				_parentTab = getParentTag(submitInfo.getSendTab(), 'SPAN', 'nj:tab');
			}
			findSendParams(_formTag, _hdvSpanTag, _parentTab, _tabs, _params, _values);
			if (CONST.DEBUG) logger.write('_params.length = ' + _params.length);
		}
	}
	if (CONST.DEBUG) logger.write('create AjaxRequest');
	var ajaxRequest = new AjaxRequest(_sendElement, Swo.SelfLinkURL, submitInfo.getSubmitValue(),	_params, _values, CONST.ENCODE2, true);
	sendAjaxRequest(ajaxRequest, updateHTMLField, chainCallBackFunc, chainCallBackFuncArgs);
}
function findSendParams(formTag, parentTag, sendTab, tabs, _params, _values) {
	if (CONST.DEBUG) logger.write('findSendParams is called. _params.length = ' + _params.length + ', parentTag = ' + parentTag);
	var _children = formTag.elements;
	if (CONST.DEBUG) {
		logger.write('sendTab = ' + sendTab);
		logger.write('tabs = ' + tabs);
		logger.write('_children.length = ' + _children.length);
	}
	var _addedRadioBottunNames = new Array();
	for (var i=0; i<_children.length; i++) {
		var _el = _children[i];
		if (CONST.DEBUG) logger.write('i = ' + i + ', _el = ' + _el);
		if (sendTab == null) {
			if (tabs != null && isChildOfParents(_el, tabs)) {
				if (CONST.DEBUG) logger.write('This element is not sent, because this element is inside of tab : ' + _el);
				continue;
			}
		} else if (!isChild(_el, sendTab)) {
			if (CONST.DEBUG) logger.write('This element is not sent, because this element is outside of tab : ' + _el.name);
			continue;
		}
		//if (!isChild(_el, parentTag)) {
		//	
		//	continue;
		//}
		var _inputName = _el.name;
		if (CONST.DEBUG) logger.write('inputName = ' + _inputName);
		if (isNullString(_inputName) ||
			(_inputName.length == 4 && (_inputName == '_SUB' || _inputName == '_CID'
				|| _inputName == '_WID' || _inputName == '_WSQ' || _inputName == '_DMY'
				|| _inputName == '_INF'))) continue;
		var _type = _el.type;
		if (isNullString(_type)) continue;
		if (CONST.DEBUG) logger.write('tag = ' + _el.tagName + ', _type = ' + _type);
		var disabled = false;
		try {
			disabled = _el.disabled;
		} catch (e) {
		}				
		if (disabled) continue;
		var _value = '';
		if (CONST.DEBUG) logger.write('_inputName = ' + _inputName);
		try {
			_value = _el.value;
			if (CONST.DEBUG) logger.write('value = ' + _value);
		} catch (e) {
		}
		var paramCount = _values.length;
		if (_type == 'text' || _el.type == 'password' || _el.type == 'textarea' || _el.type == 'hidden') {
			_params[paramCount] = _inputName;
			_values[paramCount] = _value;
		} else if (_type == 'select-one') {
			if (_el.selectedIndex >= 0) {
				_value = _el.options[_el.selectedIndex].value
			}
			_params[paramCount] = _inputName;
			_values[paramCount] = _value;
			if (CONST.DEBUG) logger.write('SelectionList Value = ' + _value);
		} else if (_type == 'radio') {
			if (contains(_addedRadioBottunNames, _inputName)) continue;
			var _els = getElementByName(formTag, _inputName);
			if (CONST.DEBUG) logger.write('_els = ' + _els);
			_value = '';
			if (_els.length > 0) {
				for (var j=0; j<_els.length; j++) {
					if (_els[j].checked) {
						_value = _els[j].value;
						break;
					}
				}
			} else {
				if (_els.checked) {
					_value = _els.value;
				}
			}
			_params[paramCount] = _inputName;
			_values[paramCount] = _value;
			_addedRadioBottunNames.push(_inputName);
			if (CONST.DEBUG) logger.write('radio value = ' + _value);
		} else if (_type == 'checkbox') {
			if (_el.checked == true) {
				_params[paramCount] = _inputName;
				_values[paramCount] = _value;
			} else {
				_params[paramCount] = _inputName;
				_values[paramCount] = '';
			}
		} else {
		  if (CONST.DEBUG) logger.write('Other type = ' + _type);
		}
	}
}
function updateHTMLField(_resultString, chainCallBackFunc, chainCallBackFuncArgs) {
	var _sendElementPos;
	if (ajax.sendElement != null) {
		_sendElementPos = getElementPos(ajax.sendElement);
	}
	if (CONST.DEBUG) logger.writeHTML('updateHTMLField is called. :' + _resultString);
	if (isNullString(_resultString) || _resultString.substring(0,8) != '{\'code\':') {
		if (_resultString != null) {
			var _findStrings = new Array();
			_findStrings[0] = '<!-- ########## This is InitialWebObject ##########:';
			_findStrings[1] = '<!-- ########## Logout ##########:';
			for (var i=0; i<_findStrings.length; i++) {
				var _startIdx = _resultString.indexOf(_findStrings[i]);
				if (_startIdx >= 0) {
					_startIdx += _findStrings[i].length;
					var _endIdx = _resultString.indexOf(' ', _startIdx);
					if (_endIdx > 0) {
						document.location = _resultString.substring(_startIdx, _endIdx);
						return;
					}
				}
			}
			var _errorStartString = '<!-- ########## Error Message Start ########## -->';
			var _errorStartIdx = _resultString.indexOf(_errorStartString);
			if (_errorStartIdx >= 0) {
			  var _errorMessage = _resultString.substring(_errorStartIdx + _errorStartString.length);
			  var _errorEndString = '<!-- ########## Error Message End ########## -->';
			  var _errorEndIdx = _errorMessage.indexOf(_errorEndString);
			  if (_errorEndIdx >= 0) {
			    _errorMessage = _errorMessage.substring(0, _errorEndIdx);
			  }
			  alert(_errorMessage);
			}
			var _exceptionString = '<!-- ########## Exception has occurred. ########## -->';
			var _exceptionIdx = _resultString.indexOf(_exceptionString);
			if (_exceptionIdx >= 0) {
				alert(_resultString.substring(_exceptionIdx + _exceptionString.length));
			}
		}
		return;
	}
	try {
		eval('_result = ' + _resultString);
	} catch (e) {
		alert('error occurred. :' + errorDescription(e));
		return;
	}
	var _resultCode = _result['code'];
	if (CONST.DEBUG) logger.write('_resultCode = ' + _resultCode);
	var _htmls = _result['htmls'];
	if (CONST.DEBUG) logger.writeHTML('refreshSelectList:html = ' + _htmls);
	if (isNotNullString(_htmls)) {
		for (var i=0; i<_htmls.length; i++) {
			var _h = _htmls[i];
			var _html = _h['html'];
			if (CONST.DEBUG) logger.writeHTML('html = ' + _html);
			var _el = document.getElementById(_h['id']);
			if (CONST.DEBUG) logger.writeHTML('_el = ' + _el);
			if (_el != null) {
				var _scrollDiv = null;
				var _scrollLeft = 0;
				var _scrollTop = 0;
				var _parent = _el;
				while (_parent != null) {
					if (_parent.tagName == 'DIV' && (_parent.scrollLeft != 0 || _parent.scrollTop != 0)) {
						_scrollDiv = _parent;
						_scrollLeft = _parent.scrollLeft;
						_scrollTop = _parent.scrollTop;
						break;
					}
					_parent = _parent.parentNode;
				}
			  _el.innerHTML = _html;			  
			  if (isNullString(_html)) {
					if (_h['id'] == Popup.ID) {
						Popup.show(false);
					}			  	
			  } else {
			  	if (_html.indexOf('nj:tab')>0) {
						initTabs(_el);
					}
					if (_html.indexOf('nj:scrollPane')>0) {
						initScrollPanes(_el);
					}
					if (_html.indexOf('nj:tree')>0) {
						initTrees(_el);
					}
					if (_h['id'] == Popup.ID) {
						Popup.show(true, _sendElementPos);
					}
					if (_scrollDiv != null) {
						_scrollDiv.scrollLeft = _scrollLeft;
						_scrollDiv.scrollTop  = _scrollTop;
					}
				}
			} else {
			  logger.writeHTML('id is invalid.', _h['id']);
			}
		}
	}
	Popup.showTransparentGif();
	var _msg = _result['msg'];
	if (isNotNullString(_msg)) {
		alert(_msg);
	}
	var _confirmMsg = _result['confirm_msg'];
	if (isNotNullString(_confirmMsg)) {
		if (confirm(_confirmMsg)) {
			_resultCode = 0;
		} else {
			_resultCode = 1;
		}
	}
	if (_resultCode == null || _resultCode == 0) {
		var _redirectURL = _result['redirect_url'];
		if (isNotNullString(_redirectURL)) {
			if (_redirectURL.indexOf(':') >= 0 || startsWith(_redirectURL, "http")) {
				alert('Can not redirect to : ' + _redirectURL);
			} else {
				if (CONST.DEBUG) logger.write('_redirectURL = ' + _redirectURL);
				document.location = _redirectURL;
			}
			return;
		}
	}
  var _focusInputName = _result['focus'];
	if (CONST.DEBUG) logger.write('_focusInputName = ' + _focusInputName);
  if (isNotNullString(_focusInputName)) {
  	setFocus(_focusInputName, true);
  }
  
  // call chained-CallBack-Function
  if ((_resultCode == null || _resultCode == 0) && chainCallBackFunc != null) {
  if (CONST.DEBUG) logger.write('call chainCallBackFunc');
    chainCallBackFunc(chainCallBackFuncArgs);
    return;
  }
  
  
  var _afterCallBackFunc = _result['afterCallBackFunc'];
  if (_afterCallBackFunc) {
    try {
      for (var i=0; i<_afterCallBackFunc.length; i++) {
        eval(_afterCallBackFunc[i]);
      }
    }
    catch (ex) {}
  }
  
}

//-->

