/* =================================================================================
	FileName : class.js
	Author : ChrisXP
	Description : 자바스크립트 클래스
	Date : 2006-08-18
==================================================================================*/

/* =================================================================================
	Class: CData
	Return : void
	Parameter : aData = 2차원 배열
	Description : 해당 데이터를 객체화 한다.
==================================================================================*/

function CData(vData) {
	//Member
	this.aVars = new Array();
	this.size = 0;
	this.position = -1;

	//Method
	this.next = CDataNext;
	this.getRowItem = CDataGetRowItem;
	this.getItem = CDataGetItem;
	this.getNames = CDataGetNames;
	this.contains = CDataContains;
	this.toString = CDataToString;
	this.getData = CDataGetData;
	this.reset = CDataReset;
	this.setItem = CDataSetItem;
	this.add = CDataAdd;
	this.getItemByValue = CDataGetItemByValue;
	this.getColItem = CDataGetColItem;
	this.remove = CDataRemove;
	this.removeItem = CDataRemoveItem;

	var aData;

	if(typeof(vData) == 'string') {
		var aKey = new Array();
		var aValue = new Array();
		var aTmp = vData.split('&');

		for(var i = 0; i < aTmp.length; i++) {
			var aTmp2 = aTmp[i].split('=');

			aKey.push(aTmp2[0]);
			aValue.push(aTmp2[1]);
		}

		aData = new Array(aKey, aValue);
	} else {
		aData = vData;
	}

	if(aData == undefined) {
		return ;
	}

	this.aVars = aData[0];
	this.size = aData.length - 1;

	for(var i = 0; i < this.aVars.length; i++) {
		eval("this." + this.aVars[i] + " = new Array();");
	}

	for(var i = 1; i < aData.length; i++) {
		for(var j = 0; j < this.aVars.length; j++) {
			eval("this." + this.aVars[j]).push(aData[i][j]);
		}
	}

	this.aVars = this.aVars.removeOverlap();
	this.size = eval("this." + this.aVars[0]).length;
}

function CDataRemove(nIndex)
{
	if(nIndex == undefined) {
		nIndex = this.position;
	}

	for(var j = 0; j < this.aVars.length; j++) {
		eval("this." + this.aVars[j] + " = this." + this.aVars[j] + ".remove(nIndex)");
	}

	this.size = eval("this." + this.aVars[0]).length;
}

function CDataAdd(strName, vValue) {
	if(!this.aVars.contains(strName)) {
		this.size++;
		this.aVars.push(strName);

		eval("this." + strName + " = new Array();");
	}

	eval("this." + strName).push(vValue);
}

function CDataRemoveItem(strName) {
	if(!this.contains(strName)) {
		return;
	}

	this.size--;
	this.aVars = this.aVars.remove(strName);

	eval("delete this." + strName);
}

function CDataToString()
{
	var strResult = "";

	for(var i = 0; i < this.aVars.length; i++) {
		strResult += "[" + this.aVars[i] + "]\n";
		strResult += eval("this." + this.aVars[i]) + "\n";
	}

	return strResult;
}

function CDataGetData()
{
	if(this.position == -1)
		return;

	return new CData(new Array(this.getNames(), this.getRowItem()));
}

function CDataGetNames()
{
	return this.aVars;
}

function CDataNext()
{
	this.position++;

	if(this.position > this.size - 1) {
		this.position = -1;

		return false;
	}
	
	return true;
}

function CDataGetRowItem()
{
	var oArray = new Array();

	if(this.position == -1) {
		return new Array();
	}

	for(var i = 0; i < this.aVars.length; i++) {
		eval("oArray.push(this." + this.aVars[i] + "[this.position]);");
	}

	return oArray;
}

function CDataGetColItem(strColName)
{
	if(strColName == undefined || strColName == '') {
		return new Array();
	}

	return eval("this." + strColName);
}

function CDataGetItem(strVarName, nIndex)
{
	if(nIndex == undefined)
		nIndex = this.position;

	if(nIndex == -1)
		nIndex = 0;

	if(!this.contains(strVarName))
		return '';

	strData = eval("this." + strVarName)[nIndex];

	if(strData == undefined) {
		strData = '';
	}

	return strData;
}

function CDataSetItem(strVarName, strValue, nIndex)
{
	if(nIndex == undefined)
		nIndex = this.position;

	if(nIndex == -1)
		nIndex = 0;

	if(!this.contains(strVarName))
		return ;

	eval("this." + strVarName)[nIndex] = strValue;
}

function CDataContains(strKey)
{
	return this.aVars.contains(strKey);
}

function CDataReset()
{
	this.position = -1;
}

function CDataGetItemByValue(strKey, strValue, strTargetKey)
{
	if(!(this.contains(strKey) && this.contains(strTargetKey))) {
		return "";
	}

	var aData = this.getColItem(strKey);

	for(var i = 0; i < aData.length; i++) {
		if(aData[i] == strValue) {
			return this.getItem(strTargetKey, i);
		}
	}
}

/* =================================================================================f
	Class : CURL
	Description : URL을 제어하는 클래스
==================================================================================*/

function CURL()
{
	this.url = document.URL;			//URL
	this.doc;									//ScriptName
	this.newDoc;							//new ScriptName
	this.newUrl;							//new Url

	this.keys = new Array();			//원본 GET키
	this.values = new Array();			//원본 VALUE
	this.rKeys = new Array();			//변형된 GET키
	this.rValues = new Array();		//변형된 VALUE

	//Initialize.........
	var aryURL = this.url.split("?");

	this.url = aryURL[0];
	var nIndex = this.url.lastIndexOf("/");
	this.doc = this.url.substr(nIndex + 1);
	this.url = this.url.substr(0, nIndex + 1);

	var tmp = "";

	if(aryURL[1])
		tmp = aryURL[1].split("&");
	
	for(var i = 0; i < tmp.length; i++)
	{
		var tmp2 = tmp[i].split("=");

		this.keys.push(tmp2[0]);
		this.values.push(tmp2[1]);
	}

	this.getVal = CURLGetVal;
	this.setVal = CURLSetVal;
	this.setDoc = CURLSetDoc;
	this.getDoc = CURLGetDoc;
	this.clear = CURLClear;
	this.toString = CURLToString;
	this.hiddenSend = CURLHiddenSend;
	this.makeData = CURLMakeData;
	this.setURL = CURLSetURL;
}

var CURL = new CURL();

/* ==================================================================================
	Name : URLClear
	Return :
	Description :
==================================================================================== */

function CURLClear()
{
	this.keys = new Array();
	this.values = new Array();
}

function CURLSetURL(sURL)
{
	this.newUrl = sURL;
}

/* ==================================================================================
	Name : setURLDoc
	Return :
	Description : url을 변경
==================================================================================== */

function CURLSetDoc(sDoc)
{
	if(sDoc.indexOf("/") != -1) {
		var aData = this.url.split("/");

		this.setURL("http://" + aData[2]);
	} 
	
	this.newDoc = sDoc;
}

/* ==================================================================================
	Name : getURLDoc
	Return :
	Description : ScriptName을 얻음
==================================================================================== */

function CURLGetDoc()
{
	return this.doc;
}

/* ==================================================================================
	Name : getURLVal(key)
	Return :
	Description : key에 해당하는 GET변수 값을 리턴한다.
==================================================================================== */

function CURLGetVal(key)
{
	for(var i = 0; i < this.keys.length; i++)
	{
		if(this.keys[i] == key)
			return this.values[i];
	}

	return "";
}

/* ==================================================================================
	Name : setURLVal(key, value)
	Return :
	Description : URL중 GET변수에 값을 세팅하여 저장한다.
==================================================================================== */

function CURLSetVal(key, value)
{
	var sValue;

	if(typeof(key) != "object") {
		if(typeof(key) == 'number') {
			key = new Array(key + '');
		} else {
			key = new Array(key);
		}
	}

	if(typeof(value) != "object") {
		if(typeof(value) == 'number') {
			value = new Array(value + '');
		} else {
			value = new Array(value);
		}
	}

	for(var i = 0; i < key.length; i++)
	{
		this.rKeys.push(key[i]);
		this.rValues.push(value[i]);
	}
}

/* ==================================================================================
	Name : URLtoString()
	Return :
	Description : URL을 돌려준다.
==================================================================================== */

function CURLToString()
{
	var aData = this.makeData();

	return aData[0] + aData[1] + '?' + aData[2].join('&');
}

function CURLHiddenSend(strAction, strTarget)
{
	var aData = this.makeData();
	var oForm = document.createElement("FORM");

	oForm.method = 'post';
	oForm.action = strAction;
	oForm.target = strTarget;

	for(var i = 0; i < aData[2].length; i++) {
		var aParam = aData[2][i].split('=');
		var oHidden = document.createElement("INPUT");

		oHidden.type = 'hidden';
		oHidden.name = aParam[0];
		oHidden.value = aParam[1];

		oForm.appendChild(oHidden);
	}

	document.appendChild(oForm);

	oForm.submit();
}

function CURLMakeData()
{
	var bExist;
	var aReturn = new Array();

	//기존의 있는 변수가 있다면 값만 변경.(값이 없으면 삭제)
	//없다면 변수 추가..
	for(var i = 0; i < this.keys.length; i++)
	{
		bExist = false;

		for(var j = 0; j < this.rKeys.length; j++)
		{
			if(this.rKeys[j] == this.keys[i])			//키값이 존재할 경우
			{
				bExist = true;

				if(this.rValues[j])		//값이 존재할 경우에만 형성
					aReturn.push(this.rKeys[j] + "=" + this.rValues[j]);

				this.rValues[j] = '';
			}
		}

		if(!bExist)
			aReturn.push(this.keys[i] + "=" + this.values[i]);
	}

	for(var i = 0; i < this.rKeys.length; i++)			//새롭게 추가된 변수를 저장
	{
		if(this.rValues[i])
			aReturn.push(this.rKeys[i] + "=" + this.rValues[i]);
	}

	if(!this.newDoc)
		this.newDoc = this.doc;

	if(!this.newUrl)
		this.newUrl = this.url;

	var aData = new Array(this.newUrl, this.newDoc, aReturn);

	this.newDoc = '';
	this.newUrl = '';
	this.rKeys = new Array();
	this.rValues = new Array();
	
	return aData;
}

/* =================================================================================
	Class : CListTable
	Description : List를 표현할 수 있는 클래스
==================================================================================*/

function CListTable(oCData, nTotal, nLimit)
{
	//Variables
	this.oData = oCData;
	this.nTotal = nTotal;
	this.nLimit = nLimit;
	this.oColumn;
	this.oRefData = new CData();

	//Method
	this.printList = CListTablePrintList;
	this.parseColumn = CListTableParseColumn;
	this.addRefData = CListTableAddRefData;
}

function CListTableAddRefData(strValue, oData)
{
	this.oRefData.add(strValue, oData);
}

function CListTableParseColumn(oColumnCData)
{
	var aColumn = oColumnCData.getNames();
	var aResult = new Array();

	for(var i = 0; i < aColumn.length; i++) {
		var aData = oColumnCData.getItem(aColumn[i], 0);

		var oResult = new CData(aData);

		aResult.push(oResult);
	}

	this.oColumn = new CData(new Array(aColumn, aResult));
}

/* =================================================================================
	Name : CListTablePrintList
	Param : oTable - 리스트가 들어갈 테이블 노드
			   aTR - 리스트 한행의 배열(0번째 항목은 데이터가 표시될 항목)
			   oColumnCData - 리스트 데이터가 표현될 컬럼 인덱스 CData(Type => Index)
			   (
					1 : 각 데이터의 타입(no, title, file...)
					2 : 해당 데이터의 컬럼명
					3 : 속성 - index : 데이터가 들어갈 TD의 인덱스
					              newImg : 1^false = 1은 해당 TD의 이미지에 해당하는 인덱스, false는 이미지의 표시여부
								  secureImg : 2^false = 동일
								  boolean : 해당 값과 매치되면 참을 의미하고, 해당 데이터를 표시함
								  ref : 링크가 되는 컬럼을 가리킴
			   )
	Description : List Print Method
==================================================================================*/

function CListTablePrintList(oTable, aTR, oColumnCData, strNodeType, aClassName)
{
	if(this.nTotal == 0) {	//리스트 갯수가 없을 경우.
		var oTD = document.createElement("TD");
		oTD.align = 'center';
		oTD.colSpan = 40;
		oTD.height = 30;
		oTD.width = '10%';
		oTD.style.backgroundColor = '#ffffff';

		oTD.appendChild(document.createTextNode('등록된 자료가 없습니다.'));

		aTR[0].removeNode();
		aTR[0].appendChild(oTD);

		for(var i = 0; i < aTR.length; i++) {
			aTR[i].style.display = 'inline';
			oTable.appendChild(aTR[i]);
		}

		return;
	}

	if(strNodeType == undefined) {
		strNodeType = '';
	}

	//컬럼 정보 파싱
	this.parseColumn(oColumnCData);

	while(this.oData.next()) {
		//Clone Node
		if(strNodeType == 'table') {
			var oCloneTable = oTable.parentNode.cloneNode(true);
		}

		var aCloneTR = new Array();

		for(var i = 0; i < aTR.length; i++) {
			aCloneTR.push(aTR[i].cloneNode(true));
		}

		//Data Mapping
		var aColumn = this.oColumn.getNames();

		//TD객체 구하기
		var aTDName = new Array();
		var aTDObject = new Array();

		for(var i = 0; i < aColumn.length; i++) {
			var oData = this.oColumn.getItem(aColumn[i], 0);

			if(oData.contains("index")) {
				var strIndex = oData.getItem('index', 0);
				var nTRIndex = 0;
				var nTDIndex = 0;

				if(strIndex.indexOf('^') != -1) {
					var aTmp = strIndex.split('^');

					nTRIndex = parseInt(aTmp[0]);
					nTDIndex = parseInt(aTmp[1]);
				} else {
					nTDIndex = parseInt(strIndex);
				}

				aTDName.push(aColumn[i]);
				aTDObject.push(aCloneTR[nTRIndex].children[nTDIndex]);
			}
		}

		var oTD = new CData(new Array(aTDName, aTDObject));

		//화면 구성
		aTDName = oTD.getNames();

		for(var i = 0; i < aTDName.length; i++) {
			var oTDContainer = oTD.getItem(aTDName[i], 0);

			for(var j = 0; j < aColumn.length; j++) {
				var oData = this.oColumn.getItem(aColumn[j], 0);
				var strSourceName = oData.getItem("sourceName", 0);
				var strData;

				if(strSourceName.indexOf('^') != -1) {		//dataSource가 여러개일 경우
					var aTmp = strSourceName.split("^");
					var aTmp1 = new Array();

					for(var x = 0; x < aTmp.length; x++) {
						var strTmp = '';

						if(aTmp[x].indexOf('!') == 0) {
							strTmp = aTmp[x].substr(1);
						} else {
							strTmp = this.oData.getItem(aTmp[x]);
						}

						if(strTmp == '') {
							continue;
						}

						aTmp1.push(strTmp);
					}

					strData = aTmp1.join("^");
				} else {
					if(strSourceName.indexOf('!') == 0) {
						strData = strSourceName.substr(1);
					} else {
						strData = this.oData.getItem(strSourceName);
					}
				}

				if(oData.contains("ref") && oData.getItem("ref", 0) == aTDName[i]) {
					var oObject = oTDContainer.children[oData.getItem("refindex", 0)];

					if(oObject == undefined) {
						continue;
					}

					if(oData.contains("enable") && oData.getItem("enable", 0) == 'false') {
						oObject.style.display = 'none';
					}

					if(oData.contains("boolean")) {
						var strBooleanValue = oData.getItem("boolean", 0);

						if(strBooleanValue.indexOf("!") == 0) {
							strBooleanValue = strBooleanValue.substr(1);

							if(strData == strBooleanValue) {
								oObject.style.display = 'none';
							}
						} else {
							if(strData != strBooleanValue) {
								oObject.style.display = 'none';
							}
						}
					}

					if(oData.contains("value")) {
						var strValue = oData.getItem("value");
						var aValue = strValue.split('^');
						var aTmp = new Array();

						for(var z = 0; z < aValue.length; z++) {
							aTmp.push(this.oData.getItem(aValue[z]));
						}
						
						oObject.value = aTmp.join(',');
					}

					if(oData.contains("doc")) {
						var strDoc = oData.getItem("doc", 0);

						if(strDoc.indexOf('javascript:') == -1) {
							CURL.setDoc(strDoc);
						}

						if(oData.contains("val")) {
							var aVars = oData.getItem("val", 0).split('^');
							var lSourceName;

							if(oData.contains("lSourceName")) {
								lSourceName = oData.getItem("lSourceName", 0);
							} else {
								lSourceName = oData.getItem("sourceName", 0);
							}

							var aValues = lSourceName.split('^');
							var aRealValues = new Array();

							for(var x = 0; x < aVars.length; x++) {
								if(aValues[x].indexOf("!") == 0) {
									aRealValues.push(aValues[x].substr(1));
								} else {
									aRealValues.push(this.oData.getItem(aValues[x]));
								}
							}

							if(strDoc.indexOf('javascript:') == -1) {
								CURL.setVal(aVars, aRealValues);
							}
						}

						if(strDoc.indexOf('javascript:') == -1) {
							var strURL = CURL;
						} else {
							aRealValues = aRealValues.addBoth('\'');
							var strURL = 'javascript:' + strDoc.substr(11) + '(' + aRealValues.join(', ') + ', ' + this.oData.position + ')';
						}

						if(oObject.tagName == 'A') {
							oObject.href = strURL;
						} else {
							var oA = document.createElement("A");

							oA.href = strURL;
							oA.appendChild(oObject);
							oTDContainer.appendChild(oA);
						}
					}
				}

				if(aTDName[i] == aColumn[j]) {
					if(oData.contains("limit")) {
						var limit = oData.getItem("limit", 0).split('^');
						var bLimit = (limit[1] == undefined) ? true : false;
						limit = limit[0];
					} else {
						var limit = 0;
					}

					if(limit > 0) {
						strData = cut(strData, limit, bLimit);
					}

					if(oData.contains("type")) {		//사용자 타입
						var aTmp = new Array();
						var aTmp1 = strData.split("^");
						var strType = oData.getItem("type");

						for(var z = 0; z < aTmp1.length; z++) {
							aTmp.push(new String(new CFormat(eval(strType), aTmp1[z])));
						}

						strData = aTmp.join('^');
					}

					if(oData.contains("oper")) {
						var aTmp1 = strData.split("^");
						var strOper = oData.getItem("oper");

						switch(strOper) {
							case "+" :
								strData = aTmp1.sum();
								break;
							default :
								strData = aTmp1.join(strOper);
						}
					}

					if(oData.contains("custom")) {		//사용자 정의함수 호출
						var strCustom = oData.getItem("custom");

						strData = eval(strCustom);

						if(strData == undefined) {
							continue;
						}
					}

					if(oData.contains("refData")) {		//연관된 데이터
						var strRefData = oData.getItem("refData");
						var oRefData = this.oRefData.getItem(strRefData);
						var strRefKey = oData.getItem("refKey");
						var strRefSource = oData.getItem("refSourceName");

						if(strData.indexOf("^")) {
							var aTmp = strData.split("^");
						} else {
							var aTmp = new Array(strData);
						}

						var aTmp1 = new Array();

						for(var x = 0; x < aTmp.length; x++) {
							oRefData.reset();

							while(oRefData.next()) {
								if(aTmp[x] == oRefData.getItem(strRefKey)) {
									aTmp1.push(oRefData.getItem(strRefSource));

									break;
								}
							}
						}

						strData = aTmp1.join(",");
					} else {
						if(typeof(strData) == 'string') {
							strData = strData.replace(/\^/g, ",");
						}
					}

					if(oData.contains("number")) {
						var number = oData.getItem("number");

						if(number.indexOf('+') == -1) {
							var tmp = parseInt(number);

							strData = tmp--;
							number = tmp.toString();
						} else {
							var tmp = parseInt(number.substr(1));

							strData = tmp++;
							number = '+' + tmp;
						}

						oData.setItem("number", number);
					}

					if(oData.contains("boolean")) {
						if(strData != oData.getItem("boolean", 0)) {
							oTDContainer.style.display = 'none';
						}
					}

					if(oTDContainer.children.length > 0) {
						for(var x = 0; x < oTDContainer.children.length; x++) {
							var strTagName = oTDContainer.children[x].tagName;

							if(strTagName == 'A' || strTagName == 'SPAN' || strTagName == 'DIV') {
									oTDContainer.children[x].innerHTML = strData;

								break;
							}
						}
					} else {
							oTDContainer.innerHTML = strData;
					}
				}
			}
		}

		if(aClassName != undefined) {
			var nPosition = this.oData.position % aClassName.length;

			aCloneTR[0].className = aClassName[nPosition];
		}

		for(var x = 0; x < aCloneTR.length; x++)  {
			aCloneTR[x].style.display = 'inline';

			if(strNodeType == '') {
				oTable.insertBefore(aCloneTR[x]);
			} else {
				var oTmp = oCloneTable.childNodes(0);
				oTmp.replaceChild(aCloneTR[x], oTmp.childNodes(x));
			}
		}

		if(strNodeType == 'table') {
			oCloneTable.style.display = 'inline';
			oTable.parentNode.parentNode.insertBefore(oCloneTable);
		}
	}
}

/* =================================================================================
	Class : CDomUtil 
	Description : HTML Dom Util Class
==================================================================================*/

function CDomUtil()
{
	this.htmlPrint = CDomUtilHtmlPrint;
	this.innerHTML = CDomUtilInnerHTML;
	this.check = CDomUtilCheck;
	this.setData = CDomUtilSetData;
	this.getCheckValue = CDomUtilGetCheckValue;
	this.setDataAll = CDomUtilSetDataAll;
	this.initData = CDomUtilInitData;
	this.init = CDomUtilInit;
}

CDomUtil = new CDomUtil();

/* =================================================================================
	Name : CDomUtilInitData
	Param : oNode - 객체
			   oData - CData 객체
			   aInfo - CData의 값의 정보를 가지는 배열(들어가는 요소에 순차적)
	Description : 객체에 해당 데이터를 세팅하는 역활.. 폼에 종속적이지 않는 폼요소들을 위해...(-__-?)
==================================================================================*/

function CDomUtilInitData(oNode, oData, aInfo)
{
	if(oData == "") {
		return ;
	}

	var strType = oNode.type;

	if(strType == "select-one") {
		if(aInfo == null) {
			aInfo = oData.getNames();
		}

		while(oData.next()) {
			var strValue = oData.getItem(aInfo[0]);
			var strText = oData.getItem(aInfo[1]);

			if(strValue == '' && strText == '') {
				continue;
			}

			var oOption = document.createElement("OPTION");
			oOption.value = strValue;
			oOption.text = strText;

			oNode.add(oOption);
		}
	}
}

function CDomUtilInit(oNode, data)
{
	var strType = oNode.type;
	oNode.innerHTML = "";

	if(strType == "select-one") {
		if(data != undefined) {
			oNode.options.add(data);
		}
	}
}

function CDomUtilSetDataAll(cNode, oData)
{
	if(cNode == undefined) {
		return ;
	}

	var oChildren = cNode.childNodes(0).children;

	for(var i = 0; i < oChildren.length; i++) { //TR
		var aTD = oChildren[i].children;

		for(var j = 0; j < aTD.length; j++) {		//TD
			var strSourceName = aTD[j].getAttribute("data");
			var strCustom = aTD[j].getAttribute("custom");
			var strOper = aTD[j].getAttribute("oper");

			if(aTD[j] == undefined || aTD[j].tagName != 'TD') {
				continue;
			}

			if(aTD[j].children[0] != null) {
				if(aTD[j].children[0].tagName == 'TABLE') {
					this.setDataAll(aTD[j].childNodes(0), oData);
				}
			}

			//해당 TR안의 TD를 검색함.
			if(strSourceName == null) {
				continue;
			}

			var aData = new Array();
			var strData = '';
			var aResultData = new Array();
			aData = strSourceName.split('^');

			for(var x = 0; x < aData.length; x++) {
				if(aData[x].indexOf('!') == 0) {
					aResultData.push(aData[x].substr(1));
				} else {
					var strTmp = oData.getItem(aData[x]);

					if(strTmp != '' && strTmp != undefined) {
						aResultData.push(strTmp);
					}
				}
			}

			if(strOper == null) {
				strOper = '';
			}

			strData = aResultData.join(strOper);

			if(strCustom != null) {
				strData = eval(strCustom);

				if(strData == null) {
					continue;
				}
			}

			if(strData == undefined) {
				strData = '';
			}

			var strLink = aTD[j].getAttribute("link");

			if(strLink != undefined) {
				var oLinkData = new CData(strLink);
				var strDoc = oLinkData.getItem("doc");

				if(strDoc.indexOf("javascript:") != -1) {
					var aTmp = oLinkData.getItem("sourceName").split("^");
					var aTmp1 = new Array();

					for(var x = 0; x < aTmp.length; x++) {
						var strTmp = oData.getItem(aTmp[x]);
						aTmp1.push(strTmp.addBoth("'"));
					}

					strLink = strDoc + "(" + aTmp1.join(", ") + ")";
				} else {
					strLink = strDoc + "?" + oLinkData.getItem("val") + "=" + oData.getItem(oLinkData.getItem("sourceName"));
				}

				strData = "<a href=\"" + strLink + "\">" + strData + "</a>";
			}

			this.innerHTML(aTD[j], strData);
		}
	}
}

/* =================================================================================
	Name : CDomUtilHtmlPrint
	Param : oCData - CData객체
			   oNode - 표시할 태그객체
	           nLimit - 줄바꿀 카운터
			   strTag - 대체할 태그 스트링 - _KEY : 1의 데이터, _VALUE : 2의 데이터
			   strKey - _KEY에 대체될 배열이름
			   strValue - _VALUE에 대체될 배열이름
			   nDefault - 체크할 디폴트 객체 인덱스
			   strType
	Description : print함수이다. (Deprecated >> CForm.init : initData)
==================================================================================*/

function CDomUtilHtmlPrint(oCData, oNode, nLimit, strTag, strKey, strValue, nDefault, strType)
{
	var strData = "";

	oNode.style.display = 'none';

	if(strType == 'table') {
		var strWidth = Math.ceil(100 / nLimit) + "%";

		strData += "<table border='0' cellpadding='0' cellspacing='0' width='100%'>";
		strTag = "<td width='" + strWidth + "'>" + strTag + "</td>";
	}

	for(var i = 0; oCData.next(); i++) {
		var strTmp = strTag;
		var strChecked = '';

		if(oCData.getItem(strKey) == '00') {
			i--;
			continue;
		}

		if(nDefault != null && nDefault == i) {
			strChecked = 'checked';
		}

		if(i % nLimit == 0 && strType == 'table') {
			strData += "<tr>";
		}

		strTmp = strTmp.replace(/_KEY/g, oCData.getItem(strKey));
		strTmp = strTmp.replace(/_VALUE/g, oCData.getItem(strValue));
		strTmp = strTmp.replace(/_CHECKED/g, strChecked);

		strData += strTmp;

		if((i + 1) % nLimit == 0) {
			if(strType == 'table') {
				strData += '</tr>';
			} else {
				strData += "<br />";
			}
		}
	}

	if(strType == 'table') {
		strData += "</table>";
	}

	oNode.innerHTML += strData;
	oNode.style.display = 'block';
}

function CDomUtilInnerHTML(oNode, strTag, nType)
{
	var oFormat = new CFormat(nType, strTag);
	strTag = oFormat;

	oNode.innerHTML = strTag;
}

function CDomUtilCheck(oNode, oValue) {
	var aData;
	var aCollection;
	var aTypeData;

	if(oValue == undefined) {
		oValue = "";
	}

	if(oNode.tagName == 'SELECT') {
		aCollection = oNode.options;
	} else {
		aCollection = oNode;
	}

	if(typeof(oValue) == 'string' || typeof(oValue) == "number") {
		if(oValue.indexOf("|") > -1) {
			aData = oValue.split("|");
		} else {
			oValue = new String(oValue);
			aData = new Array(oValue);
		}
	} else {
		aData = oValue;
	}

	for(var i = 0; i < aData.length; i++) {
		var strValue = aData[i];

		if(aCollection.length != undefined) {
			for(var j = 0; j < aCollection.length; j++) {
				if(strValue == aCollection[j].value) {
					aCollection[j].checked = true;
					aCollection[j].selected = true;

					if(aCollection[j].onclick) {
						aCollection[j].onclick.call(aCollection[j]);
					}
				}
			}
		} else {
			if(strValue == aCollection.value) {
				aCollection.checked = true;
				aCollection.selected = true;

				if(aCollection.onclick) {
					aCollection.onclick.call(aCollection);
				}
			}
		}
	}

	if(aCollection.onchange) {
		aCollection.onchange.call(aCollection);
	}
}

function CDomUtilGetCheckValue(oCollection)
{
	var aData = new Array();

	if(oCollection.type == 'select-one') {
		aData.push(oCollection.value);
	} else {
		if(oCollection.length == undefined) {
			aData.push(oCollection.value);
		} else {
			for(var i = 0; i < oCollection.length; i++) {
				if(oCollection[i].checked == true) {
					aData.push(oCollection[i].value);
				}
			}
		}
	}



	if(aData.length == null || aData.length == 0) {
		return '';
	} else if(aData.length == 1) {
		return aData[0];
	} else {
		return aData;
	}
}

function CDomUtilSetData(oNode, oValue)
{
	var strType = oNode.type;

	if(strType == null) {
		return ;
	}

	if(strType == 'radio' || strType == 'checkbox' || strType == 'select-one') {
		if(oNode.form != undefined) {
			oNode = oNode.form[oNode.name];
		}

		this.check(oNode, oValue);
	} else {
		if(strType == 'textarea') {
			oValue = oValue.replace(/<br \/>/gi, "\n");
		}

		if(strType == 'select-multiple') {	//파일첨부
			var aTmp = oValue.split("|");

			if(aTmp[2] == '') {
				return ;
			}

			var oOption = document.createElement("OPTION");

			oNode.options.add(oOption);
			oOption.value = oValue;
			oOption.innerText = aTmp[2];
		}

		oNode.value = oValue;

		if(strType == "text" && oNode.onchange) {
			oNode.onchange.call(oNode);
		}
	}
}

/* =================================================================================
	Class : CPage
	Param : nTotal - 게시물 총 갯수
	           nLimit - 한 페이지에 표현할 갯수
	Description : Page Class
==================================================================================*/

function CPage(nTotal, nLimit)
{
	this.nPage = CURL.getVal("page");
	this.nLimit = nLimit;
	this.nTotalPage = Math.ceil(nTotal / this.nLimit);

	if(this.nPage == "")
		this.nPage = 1;
	else
		this.nPage = parseInt(this.nPage);

	this.nStartPage = Math.ceil(this.nPage / this.nLimit);
	this.nEndPage = this.nStartPage + this.nLimit;

	if(this.nTotalPage < this.nEndPage)
		this.nEndPage = this.nTotalPage;

	this.print = CPagePrint;
	this.getPage = CPageGetPage;
}

function CPageGetPage()
{
	return this.nPage;
}

/* =================================================================================
	Name : CPage.print
	Param : oTD - 페이징을 표시할 TD객체
	Description : 페이지 프린트
==================================================================================*/

function CPagePrint(oTD)
{
	var oPrevBlockImg = oTD.children[0];
	var oPrevPageImg = oTD.children[1];
	var oA = oTD.children[2];
	var oText = oTD.children[3];
	var oNextPageImg = oTD.children[4];
	var oNextBlockImg = oTD.children[5];

	oTD.innerHTML = '';

	if(this.nPage - this.nLimit >= 1) {
		oPrevBlockImg.style.cursor = 'hand';
		var page1 = this.nPage - this.nLimit;

		oPrevBlockImg.onclick = function() { 
			CURL.setVal("page", page1);
			location.href = CURL.toString();
		}
	}

	if(this.nPage > 1) {
		oPrevPageImg.style.cursor = 'hand';
		var page2 = this.nPage - 1;

		oPrevPageImg.onclick = function() {
			CURL.setVal("page", page2);
			location.href = CURL.toString();
		}
	}

	oTD.appendChild(oPrevBlockImg);
	oTD.appendChild(oPrevPageImg);

	for(i = this.nStartPage; i <= this.nEndPage; i++)
	{
		var oObject;

		if(i == this.nPage) {
			oObject = oText.cloneNode(true);
		}
		else
		{
			oObject = oA.cloneNode(true);

			CURL.setVal("page", i);
			oObject.href = CURL.toString();
		}

		oObject.innerHTML = i;

		oTD.appendChild(oObject);

		if(i != this.nEndPage) {
			oTD.appendChild(document.createTextNode(" "));
		}
	}

	if(this.nPage < this.nTotalPage) {
		oNextPageImg.style.cursor = 'hand';
		var page3 = this.nPage + 1;

		oNextPageImg.onclick = function() {
			CURL.setVal("page", page3);
			location.href = CURL.toString();
		}
	}

	if(this.nPage + this.nLimit <= this.nTotalPage) {
		oNextBlockImg.style.cursor = 'hand';
		var page4 = this.nPage + this.nLmit;

		oNextBlockImg.onclick = function() { 
			CURL.setVal("page", page4);
			location.href = CURL.toString();
		}
	}

	oTD.appendChild(oNextPageImg);
	oTD.appendChild(oNextBlockImg);

	oA.style.display = 'none';
	oText.style.display = 'none';
	oTD.style.display = 'inline';
}

/* =================================================================================
	Class : CFile
	Description : File Class
==================================================================================*/

function CFile()
{
	this.download = CFileDownload;
	this.upload = CFileUpload;
	this.erase = CFileDelete;
	this.createDownload = CFileCreateDownload;
	this.preview = CFilePreview;
}

var CFile = new CFile();

function CFileDelete(oNode, strSaveKey)
{
	if(oNode.length == 1) {
		alert(JS_MSG_FILE_104);
		return;
	}

	if(oNode.selectedIndex <= 0) {
		alert(JS_MSG_FILE_101);
		return;
	}

	var nSelected = oNode.selectedIndex;		// select box에서 선택한 위치

	if(confirm(oNode.options[nSelected].text + "-" + JS_MSG_FILE_100) == false) {
		return;
	}

	//폼정보
	var aNames = new Array("pSaveKey", "pDelName");
	var aValues = new Array(strSaveKey, oNode.options[nSelected].value);
	var oForm = document.createElement("FORM");

	document.appendChild(oForm);

	for(var i = 0; i < aNames.length; i++) {
		var oHidden = document.createElement("INPUT");

		oHidden.type = 'hidden';
		oHidden.name = aNames[i];
		oHidden.value = aValues[i];

		oForm.appendChild(oHidden);
	}
	
	oForm.target = 'hiddenIFrame';
	oForm.action = '/hrdict/front/upload/uplDeleteFile.jsp';
	oForm.submit();

	// 리스트의 위치를 한칸씩 위로 올린다.
	for(i = nSelected; i < oNode.length - 1; i++) {
		oNode.options[i].value = oNode.options[i + 1].value;
		oNode.options[i].text = oNode.options[i + 1].text;
	}

	oNode.length--;		// 길이를 줄여준다.
}

function CFileUpload(strFormName, strFieldName, strSaveKey, strSizeKey, strType, nLimitSize, strMessage)
{
	var oForm = document.createElement("FORM");
	var strAllowType = '';
	var strAtchType = '02';
	var strAction = '/hrdict/front/upload/uplSubmitFileFrm.jsp';

	if(nLimitSize != undefined && nLimitSize != 0) {
		var oNode = eval("document." + strFormName + "." + strFieldName);

		if(oNode.length >= nLimitSize + 1) {
			alert("첨부파일은 " + nLimitSize + "개만 올리실 수 있습니다.");

			return ;
		}
	}

	if(strType == 'image') {
		strAllowType = 'jpg,gif,jpeg';
		strAtchType = '01';
	}

	if(strMessage == undefined) {
		strMessage = '';
	}

	var aNames = new Array("pFormName", "pFieldName", "pSaveKey", "pMaxSize", "pAllowType", "pAtchType", "pMessage");
	var aValues = new Array(strFormName, strFieldName, strSaveKey, strSizeKey, strAllowType, strAtchType, strMessage);

	for(var i = 0; i < aNames.length; i++) {
		var oHidden = document.createElement("INPUT");

		oHidden.type = 'hidden';
		oHidden.name = aNames[i];
		oHidden.value = aValues[i];

		oForm.appendChild(oHidden);
	}

	document.appendChild(oForm);
	
	var nWidth = screen.availWidth;
	var nHeight = screen.availHeight;

	window.open("", "SUBMIT", "status=0,menubar=0,scrollbar=0,resizable=0,width=279,height=179,align=left,left="+(nWidth-279)/2+",top="+(nHeight-159)/2);

	oForm.target = "SUBMIT";
	oForm.action = strAction;
	oForm.submit();
}

function CFilePreview(strType, vVariable, strSaveKey, nWidth, nHeight)		// vVariable = String || Form.Element
{
	var aDownloadKey = new Array();

	if(typeof(vVariable) == 'string') {		//Full Path
		var nIndex = vVariable.lastIndexOf("/");
		var strPath = vVariable.substr(0, nIndex + 1);
		var strFileName = vVariable.substr(nIndex + 1);

		if(nIndex == -1) {
			aDownloadKey.push("pSaveKey=" + strSaveKey);
		}

		aDownloadKey.push("pSavePath=" + strPath);
		aDownloadKey.push("pFileName=" + strFileName);
		aDownloadKey.push("pRealName=" + strFileName);
	} else {
		var nIndex = vVariable.selectedIndex;

		if(vVariable.length < 2) {
			alert("미리보기할 파일이 없습니다.");
			return;
		}

		if(nIndex <= 0) {
			alert("미리보기할 파일을 선택하셔야 합니다.");
			return;
		}

		var strValue = vVariable.value;
		var aTmp = strValue.split("|");

		aDownloadKey.push("pSaveKey=" + strSaveKey);
		aDownloadKey.push("pFileName=" + aTmp[2]);
		aDownloadKey.push("pRealName=" + aTmp[3]);
	}

	if(strType.indexOf('image') != -1) {
		var strURL = '/hrdict/front/upload/uplImageView.jsp?' + aDownloadKey.join("&");

		if(strType == 'image') {
			var oWindow = window.open('', '', 'left=' + event.x + ', top=' + event.y + ', width=' + nWidth + ', height=' + nHeight);
		} else {
			return strURL;
		}

		var strHTML = "<html><head></head><body style='margin:0px'>";
		strHTML += "<center><img src='" + strURL + "' width='" + nWidth + "' height='" + nHeight + "' style='cursor:hand' onclick='self.close()'></center>";
		strHTML += "</body></html>";

		oWindow.document.open();
		oWindow.document.write(strHTML);
		oWindow.document.close();
	} else {
		this.download(aDownloadKey.join("&"));
	}
}

function CFileDownload(strDownloadKey)		//strDownloadKey = pSaveKey=.....&pFileName=.....&pRealName
{
	var strDownURL = "/servlet/hrd.front.upload.UplDownloadFile";

	location.href = strDownURL + '?' + strDownloadKey;
}

function CFileCreateDownload(oData, oFile, pSaveKey)
{
	var pFileName;
	var pRealName;
	var oImg = oFile.children[0];

	pSaveKey = "pSaveKey=" + pSaveKey;

	var sendData = new Array(pSaveKey, pFileName, pRealName);

	oFile.innerHTML = '';

	while(oData.next()) {
		var oA = document.createElement("A");
		var oImgClone = oImg.cloneNode(true);
		var oBR = document.createElement("BR");

		pFileName = oData.getItem("ATCH_FILE_NAME");
		pRealName = oData.getItem("ATCH_SAVE_FILE_NAME");

		sendData[1] = "pFileName=" + pFileName;
		sendData[2] = "pRealName=" + pRealName;

		oA.href = "javascript:CFile.download('" + sendData.join('&') + "')";
		oA.appendChild(oImgClone);
		oA.appendChild(document.createTextNode(pFileName));

		oFile.appendChild(oA);
		oFile.appendChild(oBR);
	}
	
	oFile.style.display = 'block';
}

/* =================================================================================
	Class : CForm
	Description : Form에 관한 기본적인 일을 한다.
==================================================================================*/

function CForm(oNode)
{
	this.oForm = oNode;

	this.check = CFormCheck;
	this.fCheck = CFormFCheck;
	this.chkEmpty = CFormChkEmpty;
	this.chkCustom = CFormChkCustom;
	this.replace = CFormReplace;
	this.init = CFormInit;
	this.concat = CFormConCat;
	this.chkLimit = CFormChkLimit;
	this.setData = CFormSetData;
	this.getForm = CFormGetForm;
	this.setRealData = CFormSetRealData;
	this.fileCheck = CFormFileCheck;
	this.makeViewer = CFormMakeViewer;
	this.parseCData = CFormParseCData;
	this.alertElement = CFormAlertElement;
	this.createTarget = CFormCreateTarget;
	this.reset = CFormReset;
}

function CFormGetForm() {
	return this.oForm;
}

function CFormParseCData() {
	var aData = new Array();

	for(var i = 0; i < this.oForm.length; i++) {
		aData.push(this.oForm[i].name + "=" + this.oForm[i].value);
	}

	return new CData(aData.join("&"));
}

function CFormFCheck() {
	countOption(this.oForm.pAtchFile, this.oForm.pAtchYn);

	return this.check();
}

function CFormReset() {
	for(var i = 0; i < this.oForm.length; i++) {
		var strData = this.oForm[i].getAttribute("reset");

		if(strData != null) {
			var strTagName = this.oForm[i].tagName;

			if(strTagName == "SELECT") {
				for(var j = this.oForm[i].options.length; j > parseInt(strData); j--) {
					this.oForm[i].options.remove(j - 1);
				}
			} else {
				this.oForm[i].value = "";
			}
		}
	}
}

/* =================================================================================
	Method : CForm.init
	Return : void
	Description : Init
==================================================================================*/

function CFormInit(bFlag) {
	if(bFlag == null) {
		bFlag = true;
	}

	if(document.all == undefined) {
		var aElement = this.oForm;
	} else {
		var aElement = this.oForm.all;
	}

	for(var i = 0; i < aElement.length; i++) {
		var oNode = aElement[i];

		if(oNode.getAttribute('initFocus') != null) {		//첫 포커스
			oNode.focus();
		}

		var strData = oNode.getAttribute("init");

		if(strData != null) {
			if(strData == "year") {
				var nYear = new Date().getFullYear();
				var initData = oNode.getAttribute("initData");
				
				if(initData == null) {
					initData = new Array(nLimitYear, 0);
				} else {
					initData = initData.split("^");
					initData[0] = parseInt(initData[0]);
					initData[1] = parseInt(initData[1]);
				}

				for(var j = nYear - initData[0]; j <= nYear + initData[1]; j++) {
					var oOption = document.createElement("option");
					oOption.value = j;
					oOption.text = j + "년";

					if(j == nYear) {
						oOption.selected = true;
					}

					oNode.options.add(oOption);
				}
			} else if(strData == "month") {
				var nMonth = new Date().getMonth() + 1;

				for(var j = 1; j <= 12; j++) {
					var oOption = document.createElement("option");

					if(j < 10) {
						oOption.value = "0" + j;
					} else {
						oOption.value = j;
					}

					oOption.text = j + "월";

					if(nMonth == j) {
						oOption.selected = true;
					}

					oNode.options.add(oOption);
				}
			} else if(strData == "date") {
				var nDate = new Date().getDate();

				for(var j = 1; j <= 31; j++) {
					var oOption = document.createElement("option");

					if(j < 10) {
						oOption.value = "0" + j;
					} else {
						oOption.value = j;
					}

					oOption.text = j + "일";

					if(nDate == j) {
						oOption.selected = true;
					}

					oNode.options.add(oOption);
				}
			} else if(strData == "view") {
				var strViewType = oNode.getAttribute("viewType");
				var oContainer = oNode.parentElement;
				var strInput = "";

				if(bFlag) {
					strInput = "<input type='hidden' name='" + oNode.name + "' value='" + oNode.value + "'>";
				}

				if(strViewType == "select") {
					oContainer.innerHTML = oNode.options[oNode.selectedIndex].text + strInput;
				} else {
					oContainer.innerHTML = oNode.value + strInput;
				}
			} else if(strData == "today") {
				if(oNode.value == "") {
					var oDate = new Date();
					var strMonth = oDate.getMonth() + 1;
					var strDate = oDate.getDate();

					if(strMonth < 10) {
						strMonth = "0" + strMonth;
					}

					if(strDate < 10) {
						strDate = "0" + strDate;
					}
					
					oNode.value = oDate.getYear() + "/" + strMonth + "/" + strDate;
				}
			}
		}
	}
}

/* =================================================================================
	Method : CForm.empty
	Return : boolean - 해당 폼을 Submit을 할지의 여부
	Description : 해당 폼의 비어있는 값을 체크한다.
						해당 Element에 속성이 존재해야 한다.
	Example : <input type="text" name="ex" emptyMessage="예문을 입력하세요">
==================================================================================*/

function CFormCreateTarget() {
	var strTarget = this.oForm.target;

	if(strTarget != "") {
		var oTarget = document.getElementsByName(strTarget);

		if(oTarget.length == 0) {
			document.body.insertAdjacentHTML("beforeEnd", "<iframe name='" + strTarget + "' style='display:none' title='빈프레임'></iframe>");
		}
	}
}

function CFormCheck() {
	var aElements = this.oForm;
	var bFlag = true;

	this.createTarget();

	for(var i = 0; i < aElements.length; i++) {
		var oNode = aElements[i];

		if(oNode.disabled) {
			continue;
		}

		var nodeRealName = oNode.getAttribute("realName");

		bFlag = this.chkEmpty(oNode, nodeRealName) && this.chkLimit(oNode, nodeRealName) && this.chkCustom(oNode) &&  this.concat(oNode);

		if(!bFlag) {
			return bFlag;
		}

		this.replace(oNode);
	}

	for(var i = 0; i < aElements.length; i++) {
		var oNode = aElements[i];
		var strData = oNode.getAttribute("submit");

		if(strData != null) {
			if(strData == "select") {
				for(var j = 0; j < oNode.length; j++) {
					oNode.options[j].selected = true;
				}
			}
		}
	}

	return bFlag;
}

/* =================================================================================
	Method : CForm.chkEmpty
	Return : boolean
	Param : oNode
	Description : 비어있는지 체크 - emptyMessage 속성값으로 판단
==================================================================================*/

function CFormChkEmpty(oNode, nodeRealName)
{
	var strAttribute = 'emptyMessage';
	var strMsg = oNode.getAttribute(strAttribute);
	var require = oNode.getAttribute("notnull");
	var bFlag = false;

	if(require != null && nodeRealName != null) {
		strMsg = nodeRealName + " 항목은 필수항목입니다.";
	}

	if(strMsg == null || strMsg == '') {
		return true;
	}

	strMsg = strMsg.replace("<br>", "\n");

	if((oNode.type == 'text' || oNode.type == 'hidden' || oNode.type == 'password' || oNode.tagName == 'TEXTAREA' || oNode.type == 'select-one') && oNode.value.trim() == '') {
		bFlag = true;
	} else if(oNode.type == 'radio' || oNode.type == "checkbox") {
		var aRadio = this.oForm[oNode.name];
		aRadio = CUtil.validate(aRadio);

		bFlag = true;

		for(var i = 0; i < aRadio.length; i++) {
			if(aRadio[i].checked) {
				bFlag = false;
				break;
			}
		}
	}

	if(bFlag) {
		alert(strMsg);
		this.alertElement(oNode);

		var strFalseFunc = oNode.getAttribute("falseFunc");

		if(strFalseFunc != null && strFalseFunc != '') {
			eval(strFalseFunc);
		}

		return false;
	}

	return true;
}

function CFormChkCustom(oNode)
{
	var strAttribute = 'custom';
	var strValue = oNode.getAttribute(strAttribute);

	if(strValue == null || strValue == '') {
		return true;
	}

	return eval(strValue);
}

function CFormChkLimit(oNode, nodeRealName)
{
	var strAttribute = 'limit';
	var strValue = oNode.getAttribute(strAttribute);

	if(strValue == null || strValue == '') {
		return true;
	}

	if(oNode.value.getByte() > parseInt(strValue)) {
		var strMsg = "허용한 글자수가 초과되었습니다\n허용한 글자수는 " + strValue + "Bytes 입니다";

		if(nodeRealName != null) {
			strMsg = nodeRealName + " 항목의 " + strMsg;
		}

		alert(strMsg);

		if(oNode.type == 'text' || oNode.type == 'password') {
			oNode.select();
			oNode.focus();
		}

		return false;
	}

	return true;
}

function CFormReplace(oNode) {
	var strAttribute = 'replaceS';
	var strAttribute1 = 'replaceT';
	var strValue = oNode.getAttribute(strAttribute);
	var strReplaceValue = oNode.getAttribute(strAttribute1);

	if(strValue == null || strValue == '') {
		return ;
	}

	if(strReplaceValue == null) {
		strReplaceValue = "''";
	}

	oNode.value = oNode.value.replace(strValue, strReplaceValue);
}

function CFormFileCheck(aData) {
	var aElements = this.oForm;

	for(var i = 0; i < aElements.length; i++) {
		if(aElements[i].type == "file") {
			if(aElements[i].value == "") {
				continue;
			}

			var index = aElements[i].value.lastIndexOf(".");
			var strExt = aElements[i].value.substring(index + 1);

			if(!aData.contains(strExt.toLowerCase())) {
				alert("허용되지 않는 파일입니다.");

				return false;
			}
		}
	}

	return true;
}

/* =================================================================================
	Method : CForm.concat
	Description : 해당 Element에 붙은 concat속성을 조사한다. 
	해당 이름과 접두어가 같은 Hidden 폼을 생성해 낸다.
	Ex) <input type="text" name="pMngFaxNo2">- 
		<input type="text" name="pMngFaxNo3" concat="-">
	이런 폼내용이 있다고 했을때...  <input type="hidden" name="pMngFax" value=".43-3453">
	해당 태그를 생성한다..  이때 value부분은 pMngFax1부터 현재 번호까지 concat의 문자로 연결한다.
==================================================================================*/

function CFormConCat(oNode)
{
	var strSeparator = oNode.getAttribute("concat");

	if(strSeparator == null) {
		return true;
	}

	var strNodeName = oNode.name;
	var aData = new Array();
	var aNodes = new Array();
	var oReg = /\d$/;
	oReg.exec(strNodeName);

	var nLast = parseInt(RegExp.lastMatch);
	var strName = RegExp.leftContext;
	var oHidden;

	for(var i = 1; i <= nLast; i++) {
		oSubNode = this.oForm[strName + i];
		var strValue = oSubNode.value;

		if(oSubNode == undefined) {
			continue;
		} else if(oSubNode.type == 'checkbox' || oSubNode.type == 'radio') {
			if(!oSubNode.checked) {
				strValue = '';
			}
		}

		if(strValue == '') {
			aNodes.push(oSubNode);
			continue;
		}

		aData.push(strValue);
	}

	if(aData.length != 0 && aData.length != nLast) {
		alert("입력을 완전하게 해주세요.");
		this.alertElement(aNodes);

		return false;
	}

	//새로 추가된 Hidden요소를 못찾는다.. Form자체의 사이즈는 늘어가는데.. 왜 찾지 못할까?
	//할 수 없이 또 루프를 돈다..ㅡ.ㅡ;;
	for(var i = 0; i < this.oForm.length; i++) {
		if(strName == this.oForm[i].name) {
			oHidden = this.oForm[i];
		}
	}

	//현재 Concat Hidden 요소가 없을때는 생성
	if(oHidden == undefined) {
		oHidden = document.createElement("INPUT");

		oHidden.type = 'hidden';
		oHidden.name = strName;

		this.oForm.appendChild(oHidden);
	}

	oHidden.value = aData.join(strSeparator);

	return true;
}

function CFormAlertElement(oNodes) {
	alertElement(oNodes);
}

/* =================================================================================
	Name : CForm.setData
	Param : oData - CData형
	Description : 해당 폼의 요소의 속성 data를 참조한다.
	                   주어진 oData의 컬럼명에 맞는 데이터를 value로 매치시킨다.
==================================================================================*/

function CFormSetData(oData)
{
	var oElements = this.oForm;

	if(typeof(oData) != "object" || oData == null) {
		return ;
	}

	for(var i = 0; i < oElements.length; i++) {
		var oNode = oElements[i];

		var strColumn = oNode.getAttribute("data");
		var strSeparator = oNode.getAttribute("split");

		if(strColumn == null) {
			strColumn = oNode.name;
		}

		if(oNode != undefined && oNode.tagName == 'SELECT') {
			while(oData.next()) {
				this.setRealData(strColumn, strSeparator, oData, oNode);
			}
		} else {
			this.setRealData(strColumn, strSeparator, oData, oNode);
		}
	}
}

function CFormSetRealData(strColumn, strSeparator, oData, oNode)
{
	var aData = new Array();
	var strData;
	var nIndex = undefined;

	strColumn = strColumn.replace("[]", "");

	if(new RegExp(/\[\]$/).test(oNode.name)) {
		var aCollection = document.getElementsByName(oNode.name);

		if(aCollection.length != undefined) {
			for(var i = 0; i < aCollection.length; i++) {
				if(aCollection[i] == oNode) {
					nIndex = i;
				}
			}
		}
	}

	if(strColumn == null) {
		return ;
	} else if(strColumn.indexOf("|") != -1) {
		var aTmp = strColumn.split("|");

		for(var j = 0; j < aTmp.length; j++) {
			aData.push(aTmp[j]);
		}
	} else {
		aData.push(strColumn);
	}

	for(var x = 0; x < aData.length; x++) {
		strColumn = aData[x];

		if(strColumn.indexOf('^') != -1) {
			var aTmp = strColumn.split('^');
			var aData1 = new Array();

			for(var j = 0; j < aTmp.length; j++) {
				var strTmp = '';

				if(aTmp[j].indexOf('!') != -1) {
					strTmp = aTmp[j].substr(1);
				} else {
					strTmp = oData.getItem(aTmp[j], nIndex);
				}

				aData1.push(strTmp);
			}

			strData = aData1.join("|");
		} else {
			strData = oData.getItem(strColumn, nIndex);
		}

		if(strSeparator != null) {
			var aTmp = strSeparator.split('^');
			var nIndex = parseInt(aTmp[1]);
			aTmp = strData.split(aTmp[0]);

			if(isNaN(nIndex)) {
				strData = aTmp;
			} else {
				strData = aTmp[nIndex];
			}
		}

		if(strData == '' || strData == undefined)
			return;

		CDomUtil.setData(oNode, strData);
	}
}

function CFormMakeViewer()
{
	var oElements = this.oForm;

	for(var i = 0; i < oElements.length; i++) {
		var oNode = oElements[i];
		var strType = oNode.type;
		var strData = "";

		if(strType == "hidden" || strType == "file") {
			continue;
		}

		if(strType == "select-one") {
			strData = oNode.options[oNode.selectedIndex].text;
		}

		var oContainer = oNode.parentElement;
		oContainer.innerHTML = strData;

		alert(oNode.name + " => " + oContainer.tagName);
	}
}

/* =================================================================================
	Class : CConstant
	Description : 상수모음
==================================================================================*/

function CConstant()
{
	this.Date = 1;
}

var Constant = new CConstant();

/* =================================================================================
	Class : CFormat
	Description : 해당 데이터에 대한 포매팅 실시
==================================================================================*/

function CFormat(nConstant, strData)
{
	this.strData = strData;

	this.date = CFormatDate;
	this.toString = CFormatToString;

	if(nConstant == Constant.Date)
		this.date();
}

function CFormatDate()
{
	this.strData = this.strData.toDate();
}

function CFormatToString()
{
	return this.strData;
}

//******************************************************************************
// CRequest - AJAX
//******************************************************************************

function CRequest()
{
	this.getRequest = CRequestGetRequest;
	this.setReadyStateChange = CRequestSetReadyStateChange;
	this.open = CRequestOpen;

	this.request = this.getRequest();
}

function CRequestGetRequest()
{
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
}

function CRequestSetReadyStateChange(oFunction)
{
	this.request.onreadystatechange = oFunction;
}

function CRequestOpen(url, method, send)
{
	this.request.open(method, url, true);
	this.request.send("DD=11&type=1214");
}

//******************************************************************************
// CImage - 이미지 관련 클래스
//******************************************************************************

function CImage(oImage)
{
	//property
	this.oImage = oImage;

	//method
	this.initRollImage = CImageInitRollImage;
	this.configureRollImage = CImageConfigureRollImage;
	this.createRollImage = CImageCreateRollImage;
	this.changeSrc = CImageChangeSrc;
}

/* =================================================================================
	Class : CImage
	Method : initRollImage
	Description : Image객체를 롤오버의 정보 초기화.
==================================================================================*/

function CImageInitRollImage(fnRollOver)
{
	this.oImage.onmouseover = null;
	this.oImage.onmouseout = null;

	if(fnRollOver == null) {
		this.oImage.onclick = null;
		this.oImage.style.cursor = "default";
	}

	this.changeSrc("rollOutSrc");
}

function CImageConfigureRollImage()
{
	this.oImage.setAttribute("rollOutSrc", this.oImage.src);

	var nData = this.oImage.src.lastIndexOf(".");
	this.oImage.setAttribute("rollOverSrc", this.oImage.src.substring(0, nData) + "on" + this.oImage.src.substring(nData));
}

/* =================================================================================
	Class : CImage
	Method : createRollImage
	Description : Image객체를 롤오버 생성
==================================================================================*/

function CImageCreateRollImage(fnClick, fnRollOver)
{
	this.oImage.onmouseover = function() {
		var src = this.getAttribute("rollOverSrc");

		if(src != null && src != undefined) {
			this.src = src;
		}
	}

	this.oImage.onmouseout = function() {
		var src = this.getAttribute("rollOutSrc");

		if(src != null && src != undefined) {
			this.src = src;
		}
	}

	if(fnClick != null) {
		this.oImage.onclick = fnClick;
	}

	if(fnRollOver != null) {
		this.oImage.onclick = fnRollOver;
	}
	
	this.oImage.style.cursor = "pointer";
	this.oImage.style.cursor = "hand";
}

/* =================================================================================
	Class : CImage
	Method : changeSrc
	Description : Image객체의 상태를 변경한다.
==================================================================================*/

function CImageChangeSrc(strData)
{
	var strSrc = this.oImage.getAttribute(strData);

	if(strSrc == null || strSrc == undefined) {
		return ;
	}

	this.oImage.src = strSrc
}

//******************************************************************************
// CImageGroup - 이미지 그룹 관련 클래스
//******************************************************************************

function CImageGroup(groupID, pointer) {
	if(pointer == undefined) {
		pointer = 0;
	}

	this.aData = new Array();							//이미지 그룹을 저장할 배열
	this.pointer = pointer;										//이미지 포인터
	this.fnClick = null;
	this.fnRollOver = null;

	if(typeof(groupID) == "string") {
		var aImages = document.getElementsByName(groupID);
	} else {
		var aImages = groupID;
	}

	for(var i = 0; i < aImages.length; i++) {
		this.aData.push(new CImage(aImages[i]));
	}

	this.createTab = CImageGroupCreateTab;
	this.updateTab = CImageGroupUpdateTab;

	this.createMenu = CImageGroupCreateMenu;
	this.openMenu = CImageGroupOpenMenu;
	this.closeMenu = CImageGroupCloseMenu;

	this.setPointer = CImageGroupSetPointer;
	this.getPointer = CImageGroupGetPointer;
	this.getImage = CImageGroupGetImage;
}

/* =================================================================================
	Class : CImageGroup
	Method : createTab
	Description : Image그룹을 탭이미지로 생성한다.
==================================================================================*/

function CImageGroupCreateTab(fnClick, fnRollOver)
{
	for(var i = 0; i < this.aData.length; i++) {
		if(this.fnClick == null) {
			this.aData[i].configureRollImage();
		}

		this.aData[i].initRollImage(fnRollOver);
	
		if(this.pointer == i) {
			this.aData[i].changeSrc("rollOverSrc");

			if(fnRollOver != null) {
				this.aData[i].createRollImage(fnClick, fnRollOver);
			}
		} else {
			this.aData[i].createRollImage(fnClick, fnRollOver);
		}
	}

	if(this.fnClick == null) {
		this.fnClick = fnClick;
	}

	if(this.fnRollOver == null) {
		this.fnRollOver = fnRollOver;
	}
}

function CImageGroupGetImage(index)
{
	return this.aData[index];
}

function CImageGroupUpdateTab(oNode)
{
	var i = this.getPointer(oNode);

	this.setPointer(i);
	this.createTab(this.fnClick, this.fnRollOver);
}

function CImageGroupSetPointer(pointer)
{
	this.pointer = pointer;
}

function CImageGroupGetPointer(oNode)
{
	if(oNode == null || oNode == undefined) {
		return this.pointer;
	}

	for(var i = 0; i < this.aData.length; i++) {
		if(oNode == this.aData[i].oImage) {
			return i;
		}
	}
}

function CImageGroupCreateMenu(subMenuID, fnClick)
{
	this.aMenus = document.getElementsByName(subMenuID);

	for(var i = 0; i < this.aData.length; i++) {
		this.aData[i].oImage.style.cursor = "hand";
		this.aData[i].oImage.setAttribute("position", i);
		this.aData[i].oImage.onclick = fnClick;
	}

	this.openMenu();
}

function CImageGroupOpenMenu(node)
{
	this.closeMenu(this.getPointer());

	if(node == undefined) {
		pointer = this.getPointer();
	} else {
		pointer = this.getPointer(node);
	}

	this.setPointer(pointer);
	this.aMenus[pointer].style.display = "block";
}

function CImageGroupCloseMenu(pointer)
{
	this.aMenus[pointer].style.display = "none";
}

/* =================================================================================
	Class : CUtil 
	Description : Util
==================================================================================*/

function CUtil()
{
	this.validate = CUtilValidate;
}

function CUtilValidate(object)
{
	if(object == undefined) {
		return false;
	}

	if(object[0] == undefined) {
		return new Array(object);
	}

	return object;
}

var CUtil = new CUtil();

/* =================================================================================
	Description : 기존 자바스크립트 클래스에 메소드 추가
==================================================================================*/

/* =================================================================================
	Class : Array 
	Method : contains
	Description : 현재 배열에 해당 하는 값이 있는지 확인한다.
==================================================================================*/

Array.prototype.contains = function(oObject)
{
	for(var i = 0; i < this.length; i++) {
		if(this[i] == oObject) {
			return true;
		}
	}

	return false;
}

Array.prototype.sum = function()
{
	var nResult = 0;

	for(var i = 0; i < this.length; i++) {
		if(typeof(this[i]) == 'string') {
			nResult += parseInt(this[i]);
		} else {
			nResult += this[i];
		}
	}

	return nResult;
}

Array.prototype.remove = function(nIndex)
{
	if(nIndex == undefined) {
		return false;
	}

	var aNewArray = new Array();

	for(var i = 0; i < this.length; i++) {
		if(typeof(nIndex) == "string") {
			var strKey = this[i];
		} else {
			var strKey = i;
		}

		if(strKey != nIndex) {
			aNewArray.push(this[i]);
		}
	}

	return aNewArray;
}

Array.prototype.addBoth = function(strData)
{
	if(strData == undefined) {
		return false;
	}

	var aNewArray = new Array();

	for(var i = 0; i < this.length; i++) {
		aNewArray.push(this[i].addBoth(strData));
	}

	return aNewArray;
}

Array.prototype.removeOverlap = function()
{
	var aData = new Array();

	for(var i = 0; i < this.length; i++) {
		if(!aData.contains(this[i])) {
			aData.push(this[i]);
		}
	}

	return aData;
}

String.prototype.addBoth = function(strData)
{
	var strResult = strData + this + strData;

	return strResult;
}

String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, ""); 
}

String.prototype.toMoney = function()
{
	var strData = this.replace(/,/g, "");
	var nLength = strData.length;
	var newString = new String();

	if(isNaN(strData)) {
		return "";
	}

	for(var i = nLength - 1, j = 1; i > -1; i--, j++) {
		newString = strData.charAt(i) + newString;

		if(newString.length != 1 && i != 0 && j % 3 == 0) {
			newString = "," + newString;
		}
	}

	return newString;
}

String.prototype.toDate = function(strFormat)
{
	var oRegExp;
	var strDate = '';

	if(this == '') {
		return '';
	}

	if(strFormat == undefined) {
		strFormat = 'YYYY.MM.DD';
	}

	oRegExp = /(\d{4})?[-.\/]?(\d{2})?[-.\/]?(\d{2})?/g;

	if(oRegExp != undefined) {
		oRegExp.exec(this);

		var strYear = RegExp.$1;
		var strMonth = RegExp.$2;
		var strDay = RegExp.$3;

		strDate = strFormat.replace(/Y+/g, strYear);
		strDate = strDate.replace(/M+/g, strMonth);
		strDate = strDate.replace(/D+/g, strDay);
	} else {
		strDate = cut(this, 10);
		strDate = strDate.replace(/-/g, '.');
	}

	return strDate;
}

String.prototype.getByte = function() {
	var nBytes = 0;
	
	for(var i = 0; i < this.length; i++) {
		nBytes += (this.charCodeAt(i) > 128) ? 3 : 1;
	}

	return nBytes;
}

String.prototype.cut = function(nLimit)
{
	var str = this;
	var l = 0;

	for (var i = 0; i < str.length; i++) {
		l += (str.charCodeAt(i) > 128) ? 2 : 1;

		if (l > nLimit) {
			return str.substring(0, i);
		}
	}
	
	return str;
}

String.prototype.validate = function()
{
	if(this == "" || this == null) {
		return false;
	} else {
		return true;
	}
}

String.prototype.right = function(index)
{
	return this.substring(this.length - index);
}

//******************************************************************************
// strFormat : #는 숫자
// White List's History
// 법인번호 : ######-#######
//******************************************************************************

String.prototype.format = function(strFormat) {
	var strData = "";

	for(var i = 0, j = 0; i < this.length; j++) {
		var charFormat = strFormat.charAt(j);

		if(charFormat == "#" || charFormat == "") {
			strData += this.charAt(i);
			i++;
		} else {
			strData += charFormat;
		}
	}

	return strData;
}

String.prototype.telFormat = function(strFormat) {
	var strData = this.replace(/-/g, '')
	var strFormat = "###-###-####";

	if(strData.indexOf("02") == 0) {
		strFormat = "##-###-####";

		if(strData.length > 8) {
			strFormat = "##-####-####";
		}
	} else {
		if(strData.length >= 10) {
			strFormat = "###-####-####";
		}
	}

	strData = strData.format(strFormat);

	return strData;
}

String.prototype.parseNR = function()
{
	var strData = this.replace(/\[:n\]/g, "\n");
	strData = strData.replace(/\[:r\]/g, "\r");

	return strData;
}

String.prototype.getCount = function(strType) {
	var strValue = this;
	var oReg;
	var nCount = 0;

	if(strType == "number") {
		oReg = new RegExp("[a-zA-Z]");
	} else {
		oReg = new RegExp("[0-9]");
	}

	for(var i = 0; i < strValue.length; i++) {
		if(oReg.test(strValue.charAt(i))) {
			nCount++;
		}
	}

	return nCount;
}

//******************************************************************************
// LHTC
//******************************************************************************

function HCSelect(name, width, height, def, max, min)
{
	this.name = name;
	this.width = width;
	this.height = height;
	this.def = def;
	this.max = max;
	this.min = min;

	this.makeSelect = HCSelectMakeSelect;

	this.makeSelect();
}

function HCSelectMakeSelect()
{
	var html = "<input type='hidden' name='" + this.name + "'>";
	html += "<div style='position:absolute; width:" + this.width + "; ' id='HCSelectDiv_" + this.name + "'>";
	html += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"100%\" height=\"" + this.height + "\" bgcolor=\"040462\" class=\"c_hand\">";
	html += "	<tr>";
	html += "		<td bgcolor=\"fffffff\" style=\"color:000000; font-weight:bold;padding-right:5\" align=\"right\">" + this.def + "</td>";
	html += "		<td width=\"10\" bgcolor=\"fffffff\" style=\"color:0000000; font-weight:bold\">▼</td>";
	html += "	</tr>";
	html += "</table>";
	html += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" id='SHCSelectDiv_" + this.name + "'>";
	html += "	<tr><td height='20' bgcolor=\"FFFFFFF\" style=\"color:000000; font-weight:bold;padding-right:5\" align=\"right\"><a href='javascript:'>-</a></td></tr>";
	html += "	<tr><td height='20' bgcolor=\"FFFFFFF\" style=\"color:000000; font-weight:bold;padding-right:5\" align=\"right\"><a href=''>+</a></td></tr>";
	html += "</table>";
	html += "</div>";

	document.writeln(html);

	document.all["HCSelectDiv_" + this.name].onclick = function() {
		document.all["S" + this.id].style.display = "block";
	}
}

function getColNameForXML(oNode, strColName) {
	var strData = "";

	oNode = oNode.getElementsByTagName(strColName)[0].firstChild;

	if(oNode != null) {
		strData = oNode.nodeValue;
	}

	return strData;
}

function getChar2Byte(nNumber) {
	if(nNumber < 10) {
		return "0" + nNumber;
	} else {
		return nNumber;
	}
}
