
var MAX_VALUE = 4294967296;

var g_htDBNameModuleKey = new Hashtable();
var g_arDBNameOwner = new Array();
var g_arDBName = new Array();
var g_nDBKind = -1;

function StdCore()
{
}
StdCore._INIT_WVALUE = -1;
StdCore.S_OK = 0;
StdCore.E_NOT_EXE_SERVER = 1;
StdCore.E_DEVIDE_ERROR = 2;
StdCore.E_NOT_DEF_PROPERTY = 3;
StdCore.E_STACK_OVERFLOW = 4;
StdCore.E_MUST_ARRAY_DATA = 5;
StdCore.E_NO_IMPL_FUNC = 6;
StdCore.E_FAIL = 7;
StdCore.E_OVERFLOW_ROW = 8;
StdCore.E_NOT_MATCH_PARAM_CNT = 9;
StdCore.E_INVALID_TOTAL_ROWS = 10;
StdCore.E_NOT_EXE_DB_INFORMATION = 11;
StdCore.E_INVALID_DATETIME = 12;
StdCore.E_NOT_SUPPORT_PROPERTY = 13;
StdCore.E_NOT_SUPPORT_FUNCTION = 14;


function EVS_TYPE ()
{
}
EVS_TYPE.EVS_G_LOAD = 30; // 전역_열림
EVS_TYPE.EVS_F_LOAD = 34; // 폼_열림
EVS_TYPE.EVS_F_CLOSE = 35; // 폼_닫힘
EVS_TYPE.EVS_F_CALL = 36; // 폼_호출
EVS_TYPE.EVS_F_SAVE_RESULT = 40; // 폼_저장결과
EVS_TYPE.EVS_F_SAVE_END = 41; // 폼_저장완료
EVS_TYPE.EVS_F_SEARCH_END = 42; // 폼_검색완료
EVS_TYPE.EVS_A_MENU_SELECT = 51; // _메뉴선택
EVS_TYPE.EVS_A_SEL_CHANGE = 52; // _선택변경
EVS_TYPE.EVS_A_CLICK = 53; // _누름
EVS_TYPE.EVS_A_DBL_CLICK = 54; // _두번누름
EVS_TYPE.EVS_A_SET_FOCUS = 55; // _초점얻음
EVS_TYPE.EVS_A_KILL_FOCUS = 56; // _초점상실
EVS_TYPE.EVS_A_MOUSE_OVER = 57; // _마우스위
EVS_TYPE.EVS_A_MOUSE_OUT = 58; // _마우스외
EVS_TYPE.EVS_A_KEY_DOWN = 60; // _키누름
EVS_TYPE.EVS_A_ENDLABELEDIT = 63; // _입력마침
EVS_TYPE.EVS_A_MOVE_TAB = 64; // _탭이동
EVS_TYPE.EVS_A_MOVE_SCROLL = 65; // _스크롤내이동
EVS_TYPE.EVS_A_CHANGE_TAB = 67; // _탭뷰전환
EVS_TYPE.EVS_A_BROWSE_END = 80; // _검색완료
EVS_TYPE.EVS_A_SEL_CHANGE_END = 83; // _선택변경완료
EVS_TYPE.EVS_G_SERVER_DISCON = 84; // 전역_접속종료
EVS_TYPE.EVS_A_LOCADDR_UPDATE = 95; // _위치갱신

function SQL_RECORD_TYPE ()
{
}
SQL_RECORD_TYPE.EQUAL_RECORD	= 0; // Load Data
SQL_RECORD_TYPE.PREV_RECORD		= 1; // Load Data
SQL_RECORD_TYPE.NEXT_RECORD		= 2; // Load Data
SQL_RECORD_TYPE.DELETE_RECORD	= 3; // Delete Data
SQL_RECORD_TYPE.UPDATE_RECORD	= 4; // Clear Screan After Update Data 
SQL_RECORD_TYPE.UPDATE_RECORD_EX	= 5; // Don't Clear Screan After Update Data
SQL_RECORD_TYPE.LOCK_RECORD		= 6; // Select for lock..

function DB_KIND ()
{
}
DB_KIND._dbNull = -1; 
DB_KIND._dbSQL = 0;
DB_KIND._dbOracle = 1; 

function FORMQUERY_KIND ()
{
} 
FORMQUERY_KIND.MAX = 0;
FORMQUERY_KIND.NORMAL = 1;
FORMQUERY_KIND.PREV = 2;
FORMQUERY_KIND.NEXT = 3;
FORMQUERY_KIND.INSERT = 4;
FORMQUERY_KIND.UPDATE = 5;
FORMQUERY_KIND.DELETE = 6;
FORMQUERY_KIND.SELECTVAR = 7;
FORMQUERY_KIND.INSERTVAR = 8;
FORMQUERY_KIND.UPDATEVAR = 9;
FORMQUERY_KIND.DELETEVAR = 10;

function AtomDefine ()
{
}
AtomDefine._DB_SUCCESS_	= 1;
AtomDefine._DB_ERR_NOT_EXIST_RECORD_ = 0;
AtomDefine._DB_ERR_FAILURE_	= -1;

function ScriptDefine ()
{
}

ScriptDefine._exeCore = 0;
ScriptDefine._exeBlock = 1;
ScriptDefine._exeForm = 2;
ScriptDefine._exeDeclVar	= 3;
ScriptDefine._exeFunc = 4;
ScriptDefine._exeCond = 5;
ScriptDefine._exeIf = 6;
ScriptDefine._exeWhile = 7;
ScriptDefine._exeAssign = 8;
ScriptDefine._exeExpr = 9;
ScriptDefine._exeControl = 10;
ScriptDefine._exeBreak = 11;
ScriptDefine._exeContinue = 12;
ScriptDefine._exeReturn = 13;
ScriptDefine._exeEnd = 14;
ScriptDefine._exeEndFunc	= 15;
ScriptDefine._exeEndIf = 16;
ScriptDefine._exeEndWhile = 17;

ScriptDefine._SYMBOL = 0;
ScriptDefine._CONSTANT = 1;
ScriptDefine._FUNCTION = 2;
ScriptDefine._TEMP_SYMBOL = 3;
ScriptDefine._FIELD_SYMBOL = 4;

ScriptDefine._READ = 1010; // #읽기
ScriptDefine._WRITE = 1011; // #쓰기

ScriptDefine.FUNC_SERVER = 0;
ScriptDefine.GLOBAL_SERVER = 1;
ScriptDefine.FORM_SERVER = 2;
ScriptDefine.PARENT_FORM_SERVER	= 3;


function PMDefine ()
{
}
PMDefine.AndOrType_None = 0;
PMDefine.AndOrType_Delete = 1;
PMDefine.AndOrType_And = 2;
PMDefine.AndOrType_Or = 3;

PMDefine.ConditionType_Equal = 0;
PMDefine.ConditionType_Greater = 1;
PMDefine.ConditionType_GreaterThan = 2;
PMDefine.ConditionType_Less = 3;
PMDefine.ConditionType_LessThan = 4;
PMDefine.ConditionType_NotEqual = 5;

PMDefine.ExecuteObjectType_None = 0;
PMDefine.ExecuteObjectType_Global = 1;
PMDefine.ExecuteObjectType_Atom = 2;
PMDefine.ExecuteObjectType_DBObject = 3;
PMDefine.ExecuteObjectType_Script = 4;
PMDefine.ExecuteObjectType_SP = 5;

var g_htBosKey = new Hashtable ();
function initBosKey ()
{
	g_htBosKey["함수"] = 0;
}


function CCallStackInfo (pFuncExe)
{
	this.m_pFuncExe = pFuncExe;
	this.m_poaSymbols;
	
	//this.backupSymbols();		 // 심볼을 백업하는 이유를 모르겟으므로, 일단은 구현 안함
}

CCallStackInfo.prototype.backupSymbols = function ()
{
	var bResult = true;
	try
	{
		if (null == this.m_poaSymbols)
			this.m_poaSymbols = new Array ();

		// Backup Symbols..
		if (false == this.m_pFuncExe.backupSymbols (this.m_poaSymbols))
			throw "CCallStackInfo.backupSymbols";
	}
	catch (e)
	{
		this.m_poaSymbols.removeAll ();
		bResult = false;
	}
	
	return bResult;
}

CCallStackInfo.prototype.returnSymbols = function ()
{
	var bResult = true;
	if (null != this.m_poaSymbols && 0 < this.m_poaSymbols.size())
		bResult = this.m_pFuncExe.returnSymbols (this.m_poaSymbols);
	
	this.m_poaSymbols.removeAll ();

	return bResult;
}

/**
 * 스크립트 엔진 변수형 기본 클래스
 */
function CVarArrayX ()
{
	this.m_array = new Array();
}

CVarArrayX.prototype.getSize = function ()
{
	return this.m_array.length;
}

CVarArrayX.prototype.setSize = function (nSize) 
{
	var nArrayListSize = this.m_array.length;
	if (0 == nSize)
	{
		this.m_array = new Array();
	}
	else if (nSize < nArrayListSize)
	{
		this.m_array.splice(nSize, nArrayListSize - nSize);
	}
	else if (nSize > nArrayListSize)
	{
		for (var nIndex = nArrayListSize ; nIndex < nSize ; nIndex++ )
		{
			this.m_array.push(null);
		}
	}
}

/**
 * @param	objVariant  : CVariantX 형태의 변수이어야 한다.  
 */
CVarArrayX.prototype.setAtGrow = function (nIndex, objVariant)
{
	if (nIndex < this.m_array.length)
	{
		this.m_array.splice(nIndex, this.m_array.length - nIndex);
	}
	
	this.m_array.push(objVariant);
}

CVarArrayX.prototype.insertAt = function (nIndex, objVariant)
{
	if (nIndex < this.m_array.length)
	{
		this.m_array.splice(nIndex, 0, objVariant);
	}
	else
	{
		this.m_array.push(objVariant);
	}
}

CVarArrayX.prototype.add = function (objVariant)
{
	this.m_array.push(objVariant);
	
	return this.m_array.length;
}

CVarArrayX.prototype.getAt = function (nIndex)
{
	return this.m_array[nIndex];
}

CVarArrayX.prototype.removeAll = function (nIndex)
{
	this.m_array = null;
	this.m_array = new Array();
}

CVarArrayX.prototype.copy = function (pvaSource, bCopyData)
{
	if (null == pvaSource)
		return false;

	var pva = null;
	var nCount = 0;
	
	this.setSize(pvaSource.getSize());
	nCount = this.getSize();
	for (var nIndex = 0; nIndex < nCount; nIndex += 1)
	{
		pva = pvaSource.getAt(nIndex);
		var nType = pva.getType();
		
		if (bCopyData)
		{
			this.setAtGrow(nIndex, new CVariantX(nType, pva.getValue()));
		} 
		else
		{
			this.setAtGrow(nIndex, pva);
		}
	}
	return true;
}

/**
 * 디비처리 결과 데이터 테이블
 */
function DataTable (strTableName, arRows, arColName, arColType)
{
	this.m_strTableName = strTableName;
	this.m_arRows = arRows;
	this.m_arColName = arColName;
	this.m_arColType = arColType;
	this.m_arParam = null;
}

DataTable.prototype.getRowData = function ()
{
	return this.m_arRows;
}

DataTable.prototype.getRowCount = function ()
{
	return this.m_arRows.length;
}

DataTable.prototype.getColCount = function ()
{
	if (null != this.m_arRows && 0 < this.m_arRows.length)
	{
		return this.m_arRows[0].length;
	}
	return 0;
}

DataTable.prototype.getValue = function (nRow, nCol)
{
	var objRow = this.m_arRows[nRow];
	if (null != objRow)
	{
		return objRow[nCol];
	}
	return null;
}

DataTable.prototype.getRows = function ()
{
	return this.m_arRows;
}

DataTable.prototype.setRows = function (arRows)
{
	this.m_arRows = arRows;
}

DataTable.prototype.isValidRowIndex = function (nRowIndex)
{
	return -1 < nRowIndex && nRowIndex < this.m_arRows.length
		&& null != this.m_arRows[nRowIndex] && 0 < this.m_arRows[nRowIndex].length;
}

DataTable.prototype.isValidColumnIndex = function (nColumnIndex)
{
	return -1 < nColumnIndex && nColumnIndex < this.getColCount();
}

DataTable.prototype.setReturnValueColName = function (objRetVal, nRowIndex, strColName)
{
	var nColumnIndex = -1;
	
	for (var i = 0; i < this.m_arColName.length; i++)
	{
		if (strColName == this.m_arColName[i])
		{
			nColumnIndex = i;
			break;
		}
	}
	
	if (-1 < nColumnIndex)
	{
		this.setReturnValue(objRetVal, nRowIndex, nColumnIndex);
	}
}

DataTable.prototype.setReturnValue = function (objRetVal, nRowIndex, nColumnIndex)
{
	if (this.isValidRowIndex(nRowIndex) && this.isValidColumnIndex(nColumnIndex))
	{
		var strValue = this.m_arRows[nRowIndex][nColumnIndex];
		var strColType = this.m_arColType[nColumnIndex];

		if (strColType == "int")
		{
			objRetVal.setValueType(CVariantX._vtInt, Utils.parseInt(strValue));
		}
		else if (strColType == "float" || strColType == "double" || strColType == "numeric")
		{
			objRetVal.setValueType(CVariantX._vtReal, parseFloat(strValue));
		}
		else
		{
			objRetVal.setValueType(CVariantX._vtString, strValue);
		}
	}
}

/**
 * 프로그램 진행 관리자의 처리를 담당한다 - 신버전 
 */
function ProcessEventInformation (bIsPreEvent, 			//1
                                  bOldIsPreEvent, 		//2
                                  bIsFormEvent, 		//3
                                  strProcessEvent, 		//4
                                  strOldProcessEvent, 	//5
                                  arCondition,			//6
								  arPMObjects, 			//7
								  bIsEventContinue, 	//8
								  nPosition, 			//9
								  strOwnerName, 		//10
								  bIsAddMode, 			//11
								  bIsEditable)			//12
{
	this.m_bIsPreEvent = bIsPreEvent;
	this.m_bOldIsPreEvent = bOldIsPreEvent;
	this.m_bIsFormEvent = bIsFormEvent;
	this.m_strProcessEvent = strProcessEvent;
	this.m_strOldProcessEvent = strOldProcessEvent;
	this.m_arCondition = arCondition;
	this.m_arPMObjects = arPMObjects;
	this.m_bIsEventContinue = bIsEventContinue;
	this.m_nPosition = nPosition;
	this.m_strOwnerName = strOwnerName;
	this.m_bIsAddMode = bIsAddMode;
	this.m_bIsEditable = bIsEditable;
}
ProcessEventInformation.prototype.isContinue = function ()
{
	return this.m_bIsEventContinue;
}
ProcessEventInformation.prototype.compare = function ()
{
	var nResult = 1;
	var arResult = new Array();
	var nSize = this.m_arCondition.length;

	var nArResultIndex = -1;
	for (var i = 0; i < nSize; i++)
	{
		var pCondition = this.m_arCondition[i];
		var bResult = pCondition.compare ();
		nArResultIndex = nArResultIndex + 1;
		arResult[nArResultIndex] = (true == bResult) ? "1" : "0";
		
		var strAddtionalType = "";
		switch (pCondition.getAndOrType())
		{
			case PMDefine.AndOrType_And : 
				strAddtionalType = "*";
				break;
			case PMDefine.AndOrType_Or :
				strAddtionalType = "+";
				break;
		}
		
		nArResultIndex = nArResultIndex + 1;
		arResult[nArResultIndex] = strAddtionalType;
	}
	
	var bPlus = false;
	
	for (var i = 0; i < arResult.length ; i++)
	{
		var strResult = arResult[i];
		if (Utils.isEmpty(strResult))
			break;
		
		if (strResult == "*")
		{
			bPlus = false;	
		}
		else if (strResult == "+")
		{
			bPlus = true;	
		}
		else
		{
			if (bPlus == true)
			{
				nResult += (strResult == "1") ? 1 : 0;	
			}
			else 
			{
				nResult *= (strResult =="1") ? 1 : 0;
			}
		}
	}
	
	return (nResult == 0) ? false : true;
}
ProcessEventInformation.prototype.execute = function ()
{
	var pRetVal = new CVariantX ();
	var nSize = this.m_arPMObjects.length;
	for (var i = 0; i < nSize ; i++)
	{
		var objPMInfo = this.m_arPMObjects[i];
		pRetVal = objPMInfo.execute();
	}
	
	return pRetVal;
}
function ProcessEventCondition (strSource, 
                                strConvertSource, 
                                strValue, 
                                strConverValue, 
                                nConditionType,
                                nAndOrType )
{
	this.m_strSource = strSource;
	this.m_strConvertSource = strConvertSource; 
    this.m_strValue = strValue; 
    this.m_strConverValue = strConverValue;
    this.m_nConditionType = nConditionType;
    this.m_nAndOrType = nAndOrType;
}
ProcessEventCondition.prototype.getAndOrType = function ()
{
	return this.m_nAndOrType;
}
ProcessEventCondition.prototype.compare = function ()
{
	var bResult = true;
	if (0 != this.m_strSource.length || 0 != this.m_strValue.length)
	{
		var strLValue = this.getRealValue (this.m_strSource);
		var strRValue = this.getRealValue (this.m_strValue);
		
		if (null == strLValue || "" == strLValue)
		{
			strLValue = "0";					
		}
		
		if (null == strRValue || "" == strRValue)
		{
			strRValue = "0";
		}
		
		var nResult = 0;
		
		//try
		//{
		var dLValue = parseFloat(strLValue);
		
		var dRValue = parseFloat(strRValue);
		
		if (isNaN(dLValue) || isNaN(dRValue))
		{
			nResult = Utils.compare(strLValue, strRValue);
		}
		else
		{
			nResult = Utils.compare(dLValue, dRValue);	
		}
			
		//}
		//catch (e)
		//{
			//nResult = (strLValue == strRValue);
		//}
		
		switch (this.m_nConditionType)
		{
			case PMDefine.ConditionType_Equal : //=
				bResult = (0 == nResult);
				break;
			case PMDefine.ConditionType_Greater : // >
				bResult = (0 < nResult);
				break;
			case PMDefine.ConditionType_Less : // <
				bResult = (0 > nResult);
				break;
			case PMDefine.ConditionType_GreaterThan : // >=
				bResult = (0 <= nResult);
				break;
			case PMDefine.ConditionType_LessThan : // <=
				bResult = (0 >= nResult);
				break;
			case PMDefine.ConditionType_NotEqual : // <>
				bResult = (0 != nResult);
				break;
		}
	}
	return bResult;
}
ProcessEventCondition.prototype.getRealValue = function (strValue)
{
		if (-1 != strValue.indexOf("\""))
	{
		if (0 == strValue.indexOf("\"") && strValue.length - 1 == strValue.lastIndexOf("\""))
		{
			strValue = strValue.substring(1, strValue.length - 1);
		}
	}
	else if (PQService.containsGlobalInfo(strValue))
	{
		strValue = g_objDoc.getVariableToPMVariable(strValue);
	}
	else
	{
		var strLValueResult = Model.getAtomValue(strValue);
		
		if (null != strLValueResult)
		{
			strValue = strLValueResult;
		}
	}
	return strValue;
}
/**
 * 프로그램 진행 관리자의 공통적인 처리를 담당한다. - 구버전
 */
function PMInfo (strEvent, arStrCond, strOutput, bCondValue)
{
	this.m_strEvt = strEvent;
	
	// 실행조건	0:변형된LValue, 1:변형된RValue, 2:조건(=,>=,<), 3:실제LValue, 4:실제RValue
	this.m_arStrCond = arStrCond;	 
	this.m_strOutput = strOutput;		// 출력결과
	this.m_bCondValue = bCondValue;		// 진행여부
}

PMInfo.prototype.PMInfo = function (strEvent, arStrCond, strOutput, bCondValue)
{
	this.m_strEvt = strEvent;
	this.m_arStrCond = arStrCond;
	this.m_strOutput = strOutput;
	this.m_bCondValue = bCondValue;
}

PMInfo.prototype.isContinue = function ()
{
	return this.m_bCondValue;
}
	
/**
 * 진행관리자의 실행 조건을 검사한다.
 */
PMInfo.prototype.checkCondition = function ()
{
	var bResult = true;

	if (null != this.m_arStrCond && 5 == this.m_arStrCond.length)
	{
		var strLValue = this.m_arStrCond[3];
		var strRValue = this.m_arStrCond[4];

		if (0 != strLValue.length || 0 != strRValue.length)
		{
			strLValue = this.getConditionValue(strLValue);
			strRValue = this.getConditionValue(strRValue);
			
			if (null == strLValue)
			{
				strLValue = "";					
			}
			
			if (null == strRValue)
			{
				strRValue = "";
			}
			
			var nResult = 0;	
			
			try
			{
				var dLValue = parseFloat(strLValue);
				
				var dRValue = parseFloat(strRValue);
				
				if (isNaN(dRValue))
				{
					dRValue = 0;
				}
				
				nResult = (dLValue - dRValue);
			}
			catch (e)
			{
				nResult = (strLValue == strRValue);
			}
			
			var strOp = this.m_arStrCond[1];
			if (strOp == "=")
			{
				bResult = (0 == nResult);
			}
			else if (strOp == ">")
			{
				bResult = (0 < nResult);
			}
			else if (strOp == "<")
			{
				bResult = (0 > nResult);
			}
			else if (strOp == ">=")
			{
				bResult = (0 <= nResult);
			}
			else if (strOp == "<=")
			{
				bResult = (0 >= nResult);
			}
			else if (strOp == "<>")
			{
				bResult = (0 != nResult);
			}
		}
	}
	
	return bResult;
}

/*
 * 진행관리자 전처리 연산식 CS와 같게 수정
 * 첫번째 "" 묶였을때 "만제거 
 * 두번째 전연 확인
 * 세번째 아톰 확인
 */
PMInfo.prototype.getConditionValue = function (strValue)
{
	if (-1 != strValue.indexOf("\""))
	{
		if (0 == strValue.indexOf("\"") && strValue.length - 1 == strValue.lastIndexOf("\""))
		{
			strValue = strValue.substring(1, strValue.length - 1);
		}
	}
	else if (PQService.containsGlobalInfo(strValue))
	{
		strValue = g_objDoc.getVariableToPMVariable(strValue);
	}
	else
	{
		var strLValueResult = Model.getAtomValue(strValue);
		
		if (null != strLValueResult)
		{
			strValue = strLValueResult;
		}
	}
	return strValue;
}

/**
 * 인자를 값으로 치환한다. 
 */
PMInfo.prototype.remakeValue = function (arValue)
{
	var arResult = new Array();

	for (var i=0 ; i < arValue.length; i++)			
	{
		var strName = arValue[i];
		if (0 < strName.length)
		{
			arResult.push(this.remakeValueStr(strName));
		}
	}
	
	return arResult;
}

PMInfo.prototype.remakeValueStr = function (strName)
{
	var strValue = Utils.trim(strName);
	
	if (-1 < strValue.indexOf("\""))
	{
		if (0 == strValue.indexOf("\"") && strValue.length - 1 == strValue.lastIndexOf("\""))
		{
			strValue = strValue.substring(1, strValue.length - 1);
		}
	}
	else if (0 == strName.toUpperCase().indexOf("@PATH"))
	{
		return strName;
	}
	else if (PQService.containsGlobalInfo(strValue))
	{
		strValue = g_objDoc.getVariableToPMVariable(strValue);
	}
	else
	{
		var strLValueResult = Model.getAtomValue(strValue);
		
		if (null != strLValueResult)
		{
			strValue = strLValueResult;
		}
	}
	return strValue;
}

PMInfo.prototype.makeParameter = function (arParams)
{
	var arArgs = null;
	
	if (null != arParams)
	{
		var nParamCount = arParams.length;
		
		arArgs = Array(nParamCount + 1);
		
		arArgs[0] = new CVariantX (CVariantX._vtInt, nParamCount);
	
		for (var i = 0; i < nParamCount; i+=1) 
		{
			var nValue = Utils.parseInt(arParams[i]);
			
			if (isNaN(nValue))
			{
				arArgs [i+1] = new CVariantX(CVariantX._vtString, arParams[i])
			}
			else
			{
				arArgs [i+1] = new CVariantX (CVariantX._vtInt, nValue);
			}
		}
	}	

	return arArgs;
}

/**
 * 결과를 출력 대상에 저장한다.
 */
PMInfo.prototype.setOutputValue = function (objRetVal)
{
	var strProperVar = this.m_strOutput;

	if (0 == strProperVar.indexOf("#"))
	{
		strProperVar = strProperVar.substring(1);
		
		var objAtom = Model.getAtom(strProperVar);
		if (null != objAtom)
		{
			var objValue = objRetVal.getValue();
			if (null != objValue)
			{
				objAtom.setValue(objValue);
			}
		}
	}
	else if (0 == strProperVar.indexOf("@"))
	{
		var objValue = objRetVal.getValue();
		if (null != objValue)
		{
			g_objDoc.setVariableToPMVariable(strProperVar, objValue.toStringX());
		}
	}
}

/**
 * 프로그램 진행 관리자 SQL 객체 실행
 */
function PMSQLInstance (strEvent, arStrCond, strOutput, bCondValue, strSQLName)
{
	this.PMInfo(strEvent, arStrCond, strOutput, bCondValue);
	
	this.m_strSQLName = strSQLName;
}

PMSQLInstance.prototype = new PMInfo ()
PMSQLInstance.prototype.constructor = PMSQLInstance;

PMSQLInstance.prototype.execute = function ()
{
	var objRetVal = new CVariantX ();
	
	var arParameter  = new Array(3);
	arParameter[0] = new CVariantX(CVariantX._vtInt, 2);
	arParameter[1] = new CVariantX(CVariantX._vtString, this.m_strSQLName);			
	arParameter[2] = new CVariantX(CVariantX._vtString, "");				
	
	g_objDoc.action(-1, 11, arParameter ,objRetVal);			
	
	return objRetVal;
}


function PMInfoAtomFunc (strEvent, arStrCond, strOutput, bCondValue, strAtomName, nProperty, bIsProperty, arParam, arInputValue)
{
	this.PMInfo(strEvent, arStrCond, strOutput, bCondValue);
	
	this.m_strAtomName = strAtomName;
	this.m_nProperty = nProperty;
	this.m_bIsProperty = bIsProperty;
	this.m_arParam = arParam;
	this.arInputValue = arInputValue;
}

PMInfoAtomFunc.prototype = new PMInfo ()
PMInfoAtomFunc.prototype.constructor = PMInfoAtomFunc;

PMInfoAtomFunc.prototype.execute = function ()
{
	var objRetVal = new CVariantX();
	var arValue = null;
	if (null != this.m_arParam && 0 < this.m_arParam.length)
	{
		arValue = this.remakeValue(this.m_arParam);
	}
	
	var strValue = this.arInputValue[1];
	
	var strTempValue = Utils.trim(strValue);
	if (0 == strTempValue.indexOf ("\"") && strTempValue.length - 1 == strTempValue.lastIndexOf("\""))
	{
		strTempValue = strTempValue.substring(1, strTempValue.length - 1);
	}
	
	if (strValue == "참")
	{
		objRetVal.setValueType(CVariantX._vtInt, 1);
	}
	else if (strValue == "거짓")
	{
		objRetVal.setValueType(CVariantX._vtInt, 0);
	}
	else
	{
		var strParse = Utils.parseInt(strValue);
		
		if (isNaN(strParse))
		{
			objRetVal.setValueType(CVariantX._vtString, this.remakeValueStr(strValue));
		}
		else
		{
			objRetVal.setValueType(CVariantX._vtInt, Utils.parseInt(strValue));
		}
	}

	if (GetModelName() == this.m_strAtomName)
	{
		var nPropID = this.m_nProperty;
		
		if (this.m_bIsProperty)
		{
			if (0 < this.m_strOutput.length)
			{
				if (null == arValue)
				{
					g_objDoc.getProperty(-1, nPropID, objRetVal);
				}
				else
				{
					g_objDoc.action(-1, nPropID, this.makeParameter(arValue), objRetVal);
				}
			}
			else
			{
				g_objDoc.setProperty(-1, nPropID, this.makeParameter(arValue), objRetVal);
			}
		}
		else
		{
			g_objDoc.action(-1, nPropID, this.makeParameter(arValue), objRetVal);
		}
	}
	else
	{
		if (this.m_bIsProperty)
		{
			if (0 < this.m_strOutput.length)
			{
				if (null == arValue)
				{
					g_objDoc.getPropertyS(this.m_strAtomName, this.m_nProperty, objRetVal);
				}
				else
				{
					g_objDoc.actionS(this.m_strAtomName, this.m_nProperty, this.makeParameter(arValue), objRetVal);
				}
			}
			else
			{
				g_objDoc.setPropertyS(this.m_strAtomName, this.m_nProperty, this.makeParameter(arValue), objRetVal);
			}
		}
		else
		{
			g_objDoc.actionS(this.m_strAtomName, this.m_nProperty, this.makeParameter(arValue), objRetVal);
		}
	}
	
	this.setOutputValue(g_objDoc, objRetVal);

	return objRetVal;
}

function PMInfoInnerFunc (strEvent, arStrCond, strOutput, bCondValue, nFuncName, arParam)
{
	this.PMInfo(strEvent, arStrCond, strOutput, bCondValue);
	
	this.m_nFuncID = nFuncName;
	this.m_arParam = arParam;
}

PMInfoInnerFunc.prototype = new PMInfo ()
PMInfoInnerFunc.prototype.constructor = PMInfoInnerFunc;

/**
 * 내장함수를 실행한다.
 */
PMInfoInnerFunc.prototype.execute = function ()
{
	var pFuncServer = new CFuncServer();
	pFuncServer.setDocument(g_objDoc);

	var objRetVal = new CVariantX ();
	var arValue = null;
	
	if (null != this.m_arParam && 0 < this.m_arParam.length)
	{
		arValue = this.remakeValue(this.m_arParam);
	}
	
	pFuncServer.actionL(this.m_nFuncID, this.makeParameter(arValue), objRetVal);
	
	this.setOutputValue(objRetVal);

	return objRetVal;
}

function PMInfoScriptFunc (strEvent, arStrCond, strOutput, bCondValue, strFuncName, strParam, arParam)
{
	this.PMInfo(strEvent, arStrCond, strOutput, bCondValue);
	
	this.m_strFuncName = strFuncName;
	this.m_strParam = strParam;
	this.m_arParam = arParam;
}

PMInfoScriptFunc.prototype = new PMInfo ()
PMInfoScriptFunc.prototype.constructor = PMInfoScriptFunc;

PMInfoScriptFunc.prototype.execute = function ()
{
	var objRetVal = new CVariantX ();
	objRetVal.setValueType(CVariantX._vtInt, 0);

	var arValue = null;
	if (null != this.m_arParam && 0 < this.m_arParam.length)
	{
		arValue = this.remakeValue(this.m_arParam);
	}

	if (null != g_objDoc && !Utils.isEmpty(this.m_strFuncName))
	{
		g_objDoc.callMessagHandler(this.m_strFuncName, this.makeParameter(arValue), objRetVal);
	}

	this.setOutputValue(objRetVal);
	
	return objRetVal;
}


function PMStoredProcedure (strEvent, arStrCond, strOutput, bCondValue, strSPName, nDBName, arParam)
{
	this.PMInfo(strEvent, arStrCond, strOutput, bCondValue);
	
	this.m_strSPName = strSPName;
	this.m_nDBName = nDBName;
	
	var nCount = arParam.length;
	this.m_arParam = new Array(nCount);
	
	for (var i = 0; i < nCount ; i+=1)
	{
		var strParam = arParam[i];
		var arInfos = strParam.split("$;");
		
		this.m_arParam[i] = arInfos;
	}
	
}

PMStoredProcedure.prototype = new PMInfo ()
PMStoredProcedure.prototype.constructor = PMStoredProcedure;

PMStoredProcedure.prototype.execute = function ()
{
	var objVarArrayX = new CVarArrayX();

	if (null != this.m_arParam)
	{
		for (var i = 0, nLen = this.m_arParam.length; i != nLen; i++)
		{
			var arProperty = this.m_arParam[i];
			
			var arTemp = new CVarArrayX ();
			arTemp.add(new CVariantX(CVariantX._vtString, arProperty[1]));
			arTemp.add(new CVariantX(CVariantX._vtInt, arProperty[2]));
			arTemp.add(new CVariantX(CVariantX._vtInt, arProperty[3]));
			arTemp.add(new CVariantX(CVariantX._vtString, this.remakeValueStr(arProperty[0])));
			arTemp.add(new CVariantX(CVariantX._vtInt, arProperty[4]));

			objVarArrayX.add(new CVariantX(CVariantX._vtArray, arTemp));
		}
	}

	var arArgs  = new Array(3);
	arArgs[0] = new CVariantX(CVariantX._vtInt, 2);
	arArgs[1] = new CVariantX(CVariantX._vtString, this.m_strSPName);
	arArgs[2] = new CVariantX(CVariantX._vtArray, objVarArrayX);

	var objRetVal = new CVariantX();
	
	var objDbServer = new CDBServer(this.m_nDBName);

	objDbServer.executeProcedure(arArgs, objRetVal);
	
	for (var i = 0, nCount = this.m_arParam.length; i != nCount; i+=1)
	{
		var arProperty  = this.m_arParam[i];

		if (null != arProperty && 1328 == Utils.parseInt(arProperty[4]))
		{
			var strName = arProperty[0];
			if (0 == strName.indexOf("#"))
			{
				strName = strName.substring(1);

				var objTempVariantX = arArgs[2];
				var strValue = objTempVariantX.getAt(3);
				
				var objAtom = Model.getAtom(strName);
				if (null != objAtom)
				{
					objAtom.setValue(strValue);
				}
			}
		}
	}

	this.setOutputValue(objRetVal);

	return objRetVal;
}


function DBIOParam (nDBIndex)
{
	this.m_nDbIndex = nDBIndex;
	this.m_strQuery = "";
	
	this.m_arResult;
	this.m_arParam;
}

DBIOParam.prototype.getDBIndex = function ()
{
	return this.m_nDbIndex;
}

DBIOParam.prototype.getQuery = function()
{
	return this.m_strQuery;
}

DBIOParam.prototype.setQuery = function (strQuery)
{
	this.m_strQuery = strQuery;
}

DBIOParam.prototype.getParam = function ()
{
	return this.m_arParam;
}

DBIOParam.prototype.setParam = function (arParam)
{
	this.m_arParam = arParam;		
}

DBIOParam.prototype.getResult = function ()
{
	return this.m_arResult;
}

DBIOParam.prototype.setResult = function (arResult)
{
	this.m_arResult = arResult;
}

