﻿
// Global 변수선언
var GLB_MONTH_IN_YEAR       = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var GLB_SHORT_MONTH_IN_YEAR = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var GLB_DAY_IN_WEEK         = ["Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday"];
var GLB_SHORT_DAY_IN_WEEK   = ["Sun", "Mon", "Tue", "Wed","Thu", "Fri", "Sat"];
var GLB_DAYS_IN_MONTH       = [31,28,31,30,31,30,31,31,30,31,30,31];

/* ********************************************************************************
 *                              Prototype 함수
 * *******************************************************************************/

/**
 * @type   : prototype_function
 * @access : public
 * @desc   : 자바스크립트의 내장 객체인 String 객체에 simpleReplace 메소드를 추가한다. simpleReplace 메소드는
 *           스트링 내에 있는 특정 스트링을 다른 스트링으로 모두 변환한다. String 객체의 replace 메소드와 동일한
 *           기능을 하지만 간단한 스트링의 치환시에 보다 유용하게 사용할 수 있다.
 * <pre>
 *     var str = "abcde"
 *     str = str.simpleReplace("cd", "xx");
 * </pre>
 * 위의 예에서 str는 "abxxe"가 된다.
 * @sig    : oldStr, newStr
 * @param  : oldStr required 바뀌어야 될 기존의 스트링
 * @param  : newStr required 바뀌어질 새로운 스트링
 * @return : replaced String.
 * @author : 임재현
 */
String.prototype.simpleReplace = function(oldStr, newStr) {
	var rStr = oldStr;

	rStr = rStr.replace(/\\/g, "\\\\");
	rStr = rStr.replace(/\^/g, "\\^");
	rStr = rStr.replace(/\$/g, "\\$");
	rStr = rStr.replace(/\*/g, "\\*");
	rStr = rStr.replace(/\+/g, "\\+");
	rStr = rStr.replace(/\?/g, "\\?");
	rStr = rStr.replace(/\./g, "\\.");
	rStr = rStr.replace(/\(/g, "\\(");
	rStr = rStr.replace(/\)/g, "\\)");
	rStr = rStr.replace(/\|/g, "\\|");
	rStr = rStr.replace(/\,/g, "\\,");
	rStr = rStr.replace(/\{/g, "\\{");
	rStr = rStr.replace(/\}/g, "\\}");
	rStr = rStr.replace(/\[/g, "\\[");
	rStr = rStr.replace(/\]/g, "\\]");
	rStr = rStr.replace(/\-/g, "\\-");

  	var re = new RegExp(rStr, "g");
    return this.replace(re, newStr);
}

/**
 * @type   : prototype_function
 * @access : public
 * @desc   : 자바스크립트의 내장 객체인 String 객체에 trim 메소드를 추가한다. trim 메소드는 스트링의 앞과 뒤에
 *           있는 white space 를 제거한다.
 * <pre>
 *     var str = " abcde "
 *     str = str.trim();
 * </pre>
 * 위의 예에서 str는 "abede"가 된다.
 * @return : trimed String.
 * @author : 임재현
 */
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

/**
 * @type   : prototype_function
 * @access : public
 * @desc   : 자바스크립트의 내장 객체인 String 객체에 trimAll 메소드를 추가한다. trim 메소드는 스트링 내에
 *           있는 white space 를 모두 제거한다.
 * <pre>
 *     var str = " abc de "
 *     str = str.trimAll();
 * </pre>
 * 위의 예에서 str는 "abcde"가 된다.
 * @return : trimed String.
 * @author : 임재현
 */
String.prototype.trimAll = function() {
    return this.replace(/\s*/g, "");
}

// alert(" a b  d ".trimAll());

/**
 * @type   : prototype_function
 * @access : public
 * @desc   : 자바스크립트의 내장 객체인 String 객체에 cut 메소드를 추가한다. cut 메소드는 스트링의 특정 영역을
 *           잘라낸다.
 * <pre>
 *     var str = "abcde"
 *     str = str.cut(2, 2);
 * </pre>
 * 위의 예에서 str는 "abe"가 된다.
 * @sig    : start, length
 * @param  : start  required start index to cut
 * @param  : length required length to cut
 * @return : cutted String.
 * @author : 임재현
 */
String.prototype.cut = function(start, length) {
    return this.substring(0, start) + this.substr(start + length);
}

/**
 * @type   : prototype_function
 * @access : public
 * @desc   : 자바스크립트의 내장 객체인 String 객체에 insert 메소드를 추가한다. insert 메소드는 스트링의 특정 영역에
 *           주어진 스트링을 삽입한다.
 * <pre>
 *     var str = "abcde"
 *     str = str.insert(3, "xyz");
 * </pre>
 * 위의 예에서 str는 "abcxyzde"가 된다.
 * @sig    : start, length
 * @param  : index required 삽입할 위치. 해당 스트링의 index 바로 앞에 삽입된다. index는 0부터 시작.
 * @param  : str   required 삽입할 스트링.
 * @return : inserted String.
 * @author : 임재현
 */
String.prototype.insert = function(index, str) {
    return this.substring(0, index) + str + this.substr(index);
}

/**
 * @type   : prototype_function
 * @access : public
 * @desc   : String.split() 와 같지만 여러가지 옵션을 줄 수 있다.
 * <pre>
 *     option list
 *
 *     - i : ignored split
 *         구분자 문자 앞에 "\" 가 붙어있을 때는 구분자로 인식하지 않는다. ('\' 문자를 string으로 표현할 때는 "\\" 로 해야함)
 *             var str = "abc,de\\,fg"
 *             var strArr = str.advancedSplit(",", "i");
 *         위의 예에서 strArr[0]는 "abc", strArr[1]는 "de,fg"가 된다.
 *
 *     - t : trimed split
 *         split 후에 splited string 들을 trim 시킨다.
 *             var str = "abc,  de,fg"
 *             var strArr = str.advancedSplit(",", "t");
 *         위의 예에서 strArr[0]는 "abc", strArr[1]는 "de", strArr[2]는 "fg"가 된다.
 * </pre>
 * 옵션들은 복합적으로 사용될 수 있다.
 * <pre>
 *     var str = "abc,  de\\,fg"
 *     var strArr = str.advancedSplit(",", "it");
 * </pre>
 * 위의 예에서 strArr[0]는 "abc", strArr[1]는 "de,fg"가 된다.
 * @sig    : delim, options
 * @param  : delim   required delimenator
 * @param  : options required 옵션을 나타내는 문자들을 나열한 스트링
 * @return : splited string array.
 * @author : 임재현
 */
String.prototype.advancedSplit = function(delim, options) {
	if (options == null || options.trim() == "") {
		return this.split(delim);
	}

	var optionI = false;
	var optionT = false;

	options = options.trim().toUpperCase();

	for (var i = 0; i < options.length; i++) {
		if (options.charAt(i) == 'I') {
			optionI = true;
		} else if (options.charAt(i) == 'T') {
			optionT = true;
		}
	}

	var arr = new Array();
	var cnt = 0;
	var startIdx = 0;
	var delimIdx = -1;
	var str = this;
	var temp = 0;

	while ( (delimIdx = (str == null) ?
	         -1 : str.indexOf(delim, startIdx)
	        ) != -1
	      ) {

		if (optionI && str.substr(delimIdx - 1, 2) == '\\' + delim) {
			str = str.cut(delimIdx - 1, 1);
			startIdx = delimIdx;
			continue;
		}

		arr[cnt++] = optionT ? str.substring(0, delimIdx).trim() :
		                       str.substring(0, delimIdx);
		str = str.substr(delimIdx + 1);
		startIdx = 0;
	}

	arr[cnt] = (str == null) ? "" : str;

	return arr;
}


/**
 * @type   : prototype_function
 * @access : public
 * @desc   : 자바스크립트의 내장 객체인 String 객체에 toDate 메소드를 추가한다. toDate 메소드는 날짜를 표현하는
 *           스트링 값을 자바스크립트의 내장 객체인 Date 객체로 변환한다.
 * <pre>
 *     var date = "2002-03-05".toDate("YYYY-MM-DD")
 * </pre>
 * 위의 예에서 date 변수는 실제로 2002년 3월 5일을 표현하는 Date 오브젝트를 가르킨다.
 * @sig    : [pattern]
 * @param  : pattern optional Date를 표현하고 있는 현재의 String을 pattern으로 표현한다. (default : YYYYMMDD)
 * <pre>
 *     # syntex
 *
 *       YYYY : year(4자리)
 *       YY   : year(2자리)
 *       MM   : month in year(number)
 *       DD   : day in month
 *       HH   : hour in day (0~23)
 *       mm   : minute in hour
 *       ss   : second in minute
 *       SS   : millisecond in second
 *
 *     <font color=red>주의)</font> YYYY(YY)는 반드시 있어야 한다. YYYY(YY) 만 사용할 경우는 1월 1일을 기준으로
 *     하고 YYYY와 MM 만사용할 경우는 1일을 기준으로 한다.
 * </pre>
 * @return : 변환된 Date Object.
 * @author : 임재현
 */
String.prototype.toDate = function(pattern) {
	var index = -1;
	var year;
	var month;
	var day;
	var hour = 0;
	var min  = 0;
	var sec  = 0;
	var ms   = 0;
	var newDate;

	if (pattern == null) {
		pattern = "YYYYMMDD";
	}

	if ((index = pattern.indexOf("YYYY")) == -1 ) {
		index = pattern.indexOf("YY");
		year = "20" + this.substr(index, 2);
	} else {
		year = this.substr(index, 4);
	}

	if ((index = pattern.indexOf("MM")) != -1 ) {
		month = this.substr(index, 2);
	} else {
		month = 1;
	}

	if ((index = pattern.indexOf("DD")) != -1 ) {
		day = this.substr(index, 2);
	} else {
		day = 1;
	}

	if ((index = pattern.indexOf("HH")) != -1 ) {
		hour = this.substr(index, 2);
	}

	if ((index = pattern.indexOf("mm")) != -1 ) {
		min = this.substr(index, 2);
	}

	if ((index = pattern.indexOf("ss")) != -1 ) {
		sec = this.substr(index, 2);
	}

	if ((index = pattern.indexOf("SS")) != -1 ) {
		ms = this.substr(index, 2);
	}

	newDate = new Date(year, month - 1, day, hour, min, sec, ms);
	if (month > 12) {
		newDate.setFullYear(year + 1);
	} else {
		newDate.setFullYear(year);
	}

	return newDate;
}

/**
 * @type   : prototype_function
 * @object : Date
 * @access : public
 * @desc   : 자바스크립트의 내장 객체인 Date 객체에 format 메소드를 추가한다. format 메소드는 Date 객체가 가진 날짜를
 *           지정된 포멧의 스트링으로 변환한다.
 * <pre>
 *     var dateStr = new Date().format("YYYYMMDD");
 *
 *     참고 : Date 오브젝트 생성자들 - dateObj = new Date()
 *                                   - dateObj = new Date(dateVal)
 *                                   - dateObj = new Date(year, month, date[, hours[, minutes[, seconds[,ms]]]])
 * </pre>
 * 위의 예에서 오늘날짜가 2002년 3월 5일이라면 dateStr의 값은 "20020305"가 된다.
 * default pattern은 "YYYYMMDD"이다.
 * @sig    : [pattern]
 * @param  : pattern optional 변환하고자 하는 패턴 스트링. (default : YYYYMMDD)
 * <pre>
 *     # syntex
 *
 *       YYYY : hour in am/pm (1~12)
 *       MM   : month in year(number)
 *       MON  : month in year(text)  예) "January"
 *       mon  : short month in year(text)  예) "Jan"
 *       DD   : day in month
 *       DAY  : day in week  예) "Sunday"
 *       day  : short day in week  예) "Sun"
 *       hh   : hour in am/pm (1~12)
 *       HH   : hour in day (0~23)
 *       mm   : minute in hour
 *       ss   : second in minute
 *       SS   : millisecond in second
 *       a    : am/pm  예) "AM"
 * </pre>
 * @return : Date를 표현하는 변환된 String.
 * @author : 임재현
 */
Date.prototype.format = function(pattern) {
    var year      = this.getFullYear();
    var month     = this.getMonth() + 1;
    var day       = this.getDate();
    var dayInWeek = this.getDay();
    var hour24    = this.getHours();
    var ampm      = (hour24 < 12) ? "AM" : "PM";
    var hour12    = (hour24 > 12) ? (hour24 - 12) : hour24;
    var min       = this.getMinutes();
    var sec       = this.getSeconds();

    var YYYY = "" + year;
    var YY   = YYYY.substr(2);
    var MM   = (("" + month).length == 1) ? "0" + month : "" + month;
    var MON  = GLB_MONTH_IN_YEAR[month-1];
    var mon  = GLB_SHORT_MONTH_IN_YEAR[month-1];
    var DD   = (("" + day).length == 1) ? "0" + day : "" + day;
    var DAY  = GLB_DAY_IN_WEEK[dayInWeek];
    var day  = GLB_SHORT_DAY_IN_WEEK[dayInWeek];
    var HH   = (("" + hour24).length == 1) ? "0" + hour24 : "" + hour24;
    var hh   = (("" + hour12).length == 1) ? "0" + hour12 : "" + hour12;
    var mm   = (("" + min).length == 1) ? "0" + min : "" + min;
    var ss   = (("" + sec).length == 1) ? "0" + sec : "" + sec;
    var SS   = "" + this.getMilliseconds();

    var dateStr;
    var index = -1;

    if (typeof(pattern) == "undefined") {
    	dateStr = "YYYYMMDD";
    } else {
    	dateStr = pattern;
    }

	dateStr = dateStr.replace(/YYYY/g, YYYY);
	dateStr = dateStr.replace(/YY/g,   YY);
	dateStr = dateStr.replace(/MM/g,   MM);
	dateStr = dateStr.replace(/MON/g,  MON);
	dateStr = dateStr.replace(/mon/g,  mon);
	dateStr = dateStr.replace(/DD/g,   DD);
	dateStr = dateStr.replace(/DAY/g,  DAY);
	dateStr = dateStr.replace(/day/g,  day);
	dateStr = dateStr.replace(/hh/g,   hh);
	dateStr = dateStr.replace(/HH/g,   HH);
	dateStr = dateStr.replace(/mm/g,   mm);
	dateStr = dateStr.replace(/ss/g,   ss);
	dateStr = dateStr.replace(/(\s+)a/g, "$1" + ampm);

	return dateStr;
}

/**
 * @type   : prototype_function
 * @object : Date
 * @access : public
 * @desc   : 현재 Date 객체의 날짜보다 이후날짜를 가진 Date 객체를 리턴한다.
 *           예를 들어 내일 날짜를 얻으려면 다음과 같이 하면 된다.
 * <pre>
 *     var oneDayAfter = new Date.after(0, 0, 1);
 * </pre>
 * @sig    : [years[, months[, dates[, hours[, minutes[, seconds[, mss]]]]]]]
 * @param  : years   optional 이후 년수
 * @param  : months  optional 이후 월수
 * @param  : dates   optional 이후 일수
 * @param  : hours   optional 이후 시간수
 * @param  : minutes optional 이후 분수
 * @param  : seconds optional 이후 초수
 * @param  : mss     optional 이후 밀리초수
 * @return : 이후날짜를 표현하는 Date 객체
 * @author : 임재현
 */
Date.prototype.after = function(years, months, dates, hours, miniutes, seconds, mss) {
    if (years == null)    years    = 0;
    if (months == null)   months   = 0;
    if (dates == null)    dates    = 0;
    if (hours == null)    hours    = 0;
    if (miniutes == null) miniutes = 0;
    if (seconds == null)  seconds  = 0;
    if (mss == null)      mss      = 0;

	return new Date(this.getFullYear() + years,
	                this.getMonth() + months,
	                this.getDate() + dates,
	                this.getHours() + hours,
	                this.getMinutes() + miniutes,
	                this.getSeconds() + seconds,
	                this.getMilliseconds() + mss
	               );
}
// alert(new Date().after(1, 1, 1, 1, 1, 1).format("YYYYMMDD HHmmss"));

/**
 * @type   : prototype_function
 * @object : Date
 * @access : public
 * @desc   : 현재 Date 객체의 날짜보다 이전날짜를 가진 Date 객체를 리턴한다.
 *           예를 들어 어제 날짜를 얻으려면 다음과 같이 하면 된다.
 * <pre>
 *     var oneDayBefore = new Date.before(0, 0, 1);
 * </pre>
 * @sig    : [years[, months[, dates[, hours[, minutes[, seconds[, mss]]]]]]]
 * @param  : years   optional 이전으로 돌아갈 년수
 * @param  : months  optional 이전으로 돌아갈 월수
 * @param  : dates   optional 이전으로 돌아갈 일수
 * @param  : hours   optional 이전으로 돌아갈 시간수
 * @param  : minutes optional 이전으로 돌아갈 분수
 * @param  : seconds optional 이전으로 돌아갈 초수
 * @param  : mss     optional 이전으로 돌아갈 밀리초수
 * @return : 이전날짜를 표현하는 Date 객체
 * @author : 임재현
 */
Date.prototype.before = function(years, months, dates, hours, miniutes, seconds, mss) {
    if (years == null)    years    = 0;
    if (months == null)   months   = 0;
    if (dates == null)    dates    = 0;
    if (hours == null)    hours    = 0;
    if (miniutes == null) miniutes = 0;
    if (seconds == null)  seconds  = 0;
    if (mss == null)      mss      = 0;

	return new Date(this.getFullYear() - years,
	                this.getMonth() - months,
	                this.getDate() - dates,
	                this.getHours() - hours,
	                this.getMinutes() - miniutes,
	                this.getSeconds() - seconds,
	                this.getMilliseconds() - mss
	               );
}


/**
 * @type   : prototype_function
 * @object : Date
 * @access : public
 * @desc   : 다음달 1일 날짜를 가진 Date 객체를 리턴한다.
 * <pre>
 *     var newDate = new Date.nextFirstDate();
 * </pre>
 * @return : 다음달 1일 날짜를 표현하는 Date 객체
 * @author : 송동혁
 */
Date.prototype.nextFirstDate = function() {
	this.setMonth(this.getMonth()+1);
	this.setDate(1);

	return this;
}


/**
 * @type   : prototype_function
 * @object : Date
 * @access : public
 * @desc   : 이번달의 마지막 날짜를 가진 Date 객체를 리턴한다.
 * <pre>
 *     var newDate = new Date.lastDate();
 * </pre>
 * @return : 이번달의 마지막 날짜를 표현하는 Date 객체
 * @author : 송동혁
 */
Date.prototype.lastDate = function() {
	this.setMonth(this.getMonth()+1);
	this.setDate(1);
	this.setDate(this.getDate() - 1);

	return this;
}


/**
 * @type   : prototype_function
 * @object : Date
 * @access : public
 * @desc   : 이번달의 1일 날짜를 가진 Date 객체를 리턴한다.
 * <pre>
 *     var newDate = new Date.firstDate();
 * </pre>
 * @return : 이번달의 1일 날짜를 표현하는 Date 객체
 * @author : 송동혁
 */
Date.prototype.firstDate = function() {
	this.setDate(1);

	return this;
}


/**
 * @type   : prototype_function
 * @object : Date
 * @access : public
 * @desc   : 현재 날짜 이후에 가장 가까운 특정 요일의 날짜를 얻는 함수
 * <pre>
 *     var newDate = new Date().nextDay(3);
 * </pre>
 * 인자 : 0-일, 1-월, 2-화, 3-수, 4-목, 5-금, 6-토
 * @param  : tDay 알고자 하는 요일
 * @return : 특정 요일의 날짜를 가진 Date 객체
 * @author : 송동혁
 */
Date.prototype.nextDay = function(tDay) {
	var dayDiff = tDay - this.getDay();

	if (dayDiff <= 0)
		dayDiff += 7;

	this.setDate(this.getDate() + dayDiff);

	return this;
}



/**
 * @type   : function
 * @access : public
 * @desc   : 공통 Calendar(달력) 팝업 호출
 * input type=text와 EMEdit는 id만 인자로 넘기면 되고,
 * Grid는 id와 함께, onPopup 이벤트에서 인자로 받은 row와 colid를 넘기면 그 셀에 날짜가 들어간다.<br>
 * <pre>
 *     input type=text, EMEdit : lcfOpenCalendar(ed_birthDate);
 *     Grid : lcfOpenCalendar(gr_birthDate, row, colid);
 * </pre>
 * @sig    : position[, row, colid]
 * @param  : position  required  객체 object(input type=text, gauce EMEdit, gauce Grid 모두 가능)
 * @param  : row    optional  (Grid일 경우에만 입력하며, 날짜가 들어갈 Grid의 row)
 * @param  : colid  optional  (Grid일 경우에만 입력하며, 날짜가 들어갈 Grid의 colid)
 * @author : 송동혁
 * @ 수정 : 2006년 7월 20일 윤기영
 */
function lcfOpenCalendar(position, row, colid){
  var returnValue = window.showModalDialog("/sys/jsp/calendarFrame.jsp", "winCalendar", "scroll:no;status:no;help:no;dialogWidth:275px;dialogHeight:335px;");
  if(returnValue != null){
  	 //input type=text 형일경우
	if(position.tagName.toUpperCase() == "INPUT" && position.type.toUpperCase() == "TEXT" && position.readOnly == false) {
	    position.value = returnValue;
	}else if(position.tagName.toUpperCase() == "OBJECT" ) {
	  if (position.classid.toUpperCase() == CLSID_EMEDIT && position.ReadOnly == false){
	    position.Text = returnValue;
	 } else if (position.classid.toUpperCase() == CLSID_GRID){
	    document.all(position.DataID).NameValue(row, colid) = returnValue;
	  }
	}
  }
}

/**
 * @type   : function
 * @access : public
 * @desc   : 값이 null 이거나 white space 문자로만 이루어진 경우 true를 리턴한다.
 * <pre>
 *     lcfIsNull("  ");
 * </pre>
 * 위와같이 사용했을 경우 true를 리턴한다.
 * @sig    : value
 * @param  : value required 입력값
 * @return : boolean. null(혹은 white space) 여부
 * @author : 임재현
 */
function lcfIsNull(value) {
	if (value == null ||
	    (typeof(value) == "string" && value.trim() == "")
	   ) {
		return true;
	}

	return false;
}

/**
 * @type   : function
 * @access : public
 * @desc   : Object를 status 변수에 따라 enable하거나 disable 상태로 변경한다.
 * <pre>
 *     lcfEnableObj(txt_empNo, true);
 * </pre>
 * 위와같이 사용했을 경우 txt_empNo라는 오브젝트를 enable 상태로 변경한다.
 * @sig    : ObjectItem, Status
 * @param  : ObjectItem required 상태변경 대상 오브젝트
 * @param  : Status required 목표상태
 * @author :
 */
function lcfEnableObj(ObjectItem, Status) {

    switch (ObjectItem.tagName) {
        case "INPUT":
        	var type = ObjectItem.type.toUpperCase();
            if(type == "CHECKBOX" || type == "IMAGE" || type == "RADIO" || type == "FILE"){
               ObjectItem.disabled = (!Status);
               break;
            } else if (type == "BUTTON" || type == "RESET" || type == "SUBMIT") {
               ObjectItem.disabled = (!Status);
              break;
            } else if (type == "PASSWORD" || type == "TEXT") {
              ObjectItem.disabled = (!Status);
              break;
            }
        case "SELECT":
            ObjectItem.disabled = (!Status);
            break;
        case "TEXTAREA":
            ObjectItem.disabled = (!Status);
            break;
        case "A":
            ObjectItem.disabled = (!Status);
            break;
        case "IMG":
            ObjectItem.disabled = (!Status);
            break;
        case "TABLE":
            ObjectItem.disabled = (!Status);
            break;
        case "TR":
            ObjectItem.disabled = (!Status);
            break;
        case "TD":
            ObjectItem.disabled = (!Status);
            break;
    }
}



/**
 * @type   : function
 * @access : public
 * @desc   : element를 enable 시킨다.
 * <pre>
 *     lcfDisableObjects([btn_register, img_popup]);
 * </pre>
 * @sig    : objArr
 * @param  : objArr required enable 하고자 하는 오브젝트 배열
 * @author : 송동혁
 */
function lcfEnableObjects(obj) {
	if (lcfIsNull(obj)) {
		return;
	}

	// 오브젝트 배열
	if (obj.length != null) {
		for (var i = 0; i < obj.length; i++) {
			if (obj[i].tagName == "TABLE" || obj[i].tagName == "DIV" || obj[i].tagName == "FORM") {
				lcfEnableObjects(obj[i].all);
			}
			else
				lcfEnableObj(obj[i], true);
		}
	}
	// 오브젝트 하나
	else {
		if (obj.tagName == "TABLE") {
			lcfEnableObjects(obj.all);
		}
		else
			lcfEnableObj(obj, true);
	}
}


/**
 * @type   : function
 * @access : public
 * @desc   : element를 disable 시킨다.
 * <pre>
 *     lcfDisableObjects([btn_register, img_popup]);
 * </pre>
 * @sig    : objArr
 * @param  : objArr required disable 하고자 하는 오브젝트 배열
 * @author : 송동혁
 */
function lcfDisableObjects(obj) {
	if (lcfIsNull(obj)) {
		return;
	}

	// 오브젝트 배열
	if (obj.length != null) {
		for (var i = 0; i < obj.length; i++) {
			if (obj[i].tagName == "TABLE" || obj[i].tagName == "DIV" || obj[i].tagName == "FORM") {
				// 특정 오브젝트(tr, td)를 제외할 경우, all에서 tagName을 읽어 이를 기준으로 배열 생성한 후 호출해야 함.
				for (j = 0; j < obj[i].all.length; j++) {
					if (obj[i].all[j].tagName.toUpperCase() != "TR" && obj[i].all[j].tagName.toUpperCase() != "TD")
						lcfEnableObj(obj[i].all[j], false);
				}
			}
			else {
				lcfEnableObj(obj[i], false);
			}
		}
	}
	// 오브젝트 하나
	else {
		if (obj.tagName == "TABLE") {
			for (j = 0; j < obj.all.length; j++) {
				if (obj.all[j].tagName.toUpperCase() != "TR" && obj.all[j].tagName.toUpperCase() != "TD")
					lcfEnableObj(obj.all[j], false);
			}
		}
		else
			lcfEnableObj(obj, false);
	}
}



/**
 * @type   : function
 * @access : public
 * @desc   : lcfDisableObjects와 비슷한 형태로, 오브젝트의 값을 초기화시킨다.
 * <pre>
 *     하나만 초기화할 때,
 *     lcfInitObjects(tbl_search);
 *     두 개 이상을 초기화할 때,
 *     lcfInitObjects([ed_empNm, txt_empNo]);
 * </pre>
 * @sig    : objArr[, exceptArr]
 * @param  : objArr required 초기화하고자 하는 오브젝트 또는 오브젝트 배열
 * @param  : exceptArr optional 초기화 대상에서 제외되는 오브젝트 또는 오브젝트 배열
 * @author : 송동혁
 */
function lcfInitObjects(obj, excpt) {
	if (lcfIsNull(obj)) {
		return;
	}

	// 오브젝트 배열
	if (obj.length != null) {
		for (var i = 0; i < obj.length; i++) {
			if (obj[i].tagName == "TABLE") {
				lcfInitObjects(obj[i].all, excpt);
			}
			else {
				lcfProcessInitObj(obj[i], excpt);
			}
		}
	}
	// 오브젝트 하나
	else {
		if (obj.tagName == "TABLE") {
			lcfInitObjects(obj.all, excpt);
		}
		else {
			lcfProcessInitObj(obj, excpt);
		}
	}
}


/**
 * @type   : function
 * @access : private
 * @desc   : 초기화 대상 제외를 뺀 나머지 오브젝트의 값을 초기화시킨다.
 * @sig    : objArr, exceptArr
 * @param  : objArr required 초기화하고자 하는 오브젝트 또는 오브젝트 배열
 * @param  : exceptArr optional 초기화 대상에서 제외되는 오브젝트 또는 오브젝트 배열
 * @author : 송동혁
 */
function lcfProcessInitObj(obj, excpt) {
	// 제외대상이 있을 경우
	if (excpt != null) {
		// 제외대상이 배열일 경우
		if (excpt.length != null) {
			for (j = 0; j < excpt.length && obj.id != excpt[j].id; j++);
			if (j == excpt.length) lcfInitObj(obj);
		}
		// 제외대상이 하나일 경우
		else {
			if (obj.id != excpt.id) lcfInitObj(obj);
		}
	}
	else {
		lcfInitObj(obj);
	}
}


/**
 * @type   : function
 * @access : private
 * @desc   : Object의 Value를 초기화한다.
 * @sig    : obj[, iniVal]
 * @param  : parentObj required 초기화할 대상 오브젝트
 * @param  : iniVal    optional 초기값
 * @author : 김수호
 */
function lcfInitObj(obj) {
	var	iniVal = "";

	switch (obj.tagName.toUpperCase()) {
		case "INPUT":
			switch (obj.type.toUpperCase()) {
				case "CHECKBOX":
					obj.checked = 0;
					break;
				case "BUTTON" :
					break;
				case "RESET" :
					break;
				case "SUBMIT" :
					break;
				case "IMAGE" :
					break;
				default : // text, password 등
					obj.value = "";
					break;
			}

			break;

		case "SELECT":
			obj.selectedIndex = 0;
			break;
		case "TEXTAREA":
			obj.value = "";
			break;

	}
}


/**
 * @type   : function
 * @access : public
 * @desc   : 입력된 영문 중 소문자를 대문자로 변경해 주는 함수
 * @sig    : inputObj
 * @param  : inputObj required input type=text 또는 textarea 오브젝트
 */
function lcfToUpper(inputObj) {
	if (inputObj.tagName == "INPUT") {
		if (inputObj.type.toUpperCase() == "TEXT") {
			inputObj.value = inputObj.value.toUpperCase();
		}
	}
	else if (inputObj.tagName == "TEXTAREA") {
		inputObj.value = inputObj.value.toUpperCase();
	}
}
