/// @title   : CMS °øÅë js
/// @author  : 2009.02.04 ÃÖÃÊ - Áö¼º¸ñ (xenes@nate.com)
/// @amender :



function ifu(obj, value) {
	return (obj == undefined) ? value : obj;
}




/************************************************
	Selector Function...
************************************************/

function $N(param1, param2) {
	if (param2 == undefined) {
		return document.getElementsByName(param1);
	}
	else {
		return document.getElementById(param1).getElementsByName(param2);
	}
}

function $TN(param1, param2) {
	if (param2 == undefined) {
		return document.getElementsByTagName(param1);
	}
	else {
		return document.getElementById(param1).getElementsByTagName(param2);
	}
}

function $VB(param, value) {

	if (value == undefined) { value = false; }

	if (param == undefined) {
		return value;
	}
	else if (param == "") {
		return value;
	}
	else if (typeof (param) == "boolean") {
		return param;
	}
	else if (param.toLowerCase() == "t" || param == "1") {
		return true;
	}
	else if (param.toLowerCase() == "f" || param == "0") {
		return false;
	}
	else {
		return value;
	}
}

function $V(param, isVisible) {

	var obj;

	if (typeof (param) == "object") {
		obj = param;
	}
	else {
		obj = $(param);
	}

	if (isVisible == undefined) {
		return obj.style.visibility;
	}
	else {
		isVisible = $VB(isVisible, false);
		obj.style.visibility = isVisible ? "visible" : "hidden";
		obj.style.position = isVisible ? "static" : "absolute";
	}
}

function $D(param, isVisible) {

	var obj;

	if (typeof (param) == "object") {
		obj = param;
	}
	else {
		obj = $(param);
	}

	if (isVisible == undefined) {
		return obj.style.display;
	}
	else {
		isVisible = $VB(isVisible, false);
		obj.style.display = isVisible ? "block" : "none";
	}
}



/************************************************
	String Override Function
************************************************/

// [2005-03-28 : Áö¼º¸ñ] trim
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
}

// [2005-03-28 : Áö¼º¸ñ] Right
String.prototype.right = function(intRight) {
	return this.substring(this.length - intRight, this.length);
}

// [2009-02-10 : Áö¼º¸ñ] Padding Left
String.prototype.padLeft = function(totalWidth, charValue) {
	var sPadding = "";
	for (var i = 0; i < totalWidth; i++) {
		sPadding += charValue.toString();
	}
	return (sPadding + this).toString().right(totalWidth);
}

// [2009-05-12 : Áö¼º¸ñ] Length Byte
String.prototype.len = function(isInitial) {
	var str = this;
	var intLen = 0;

	isInitial = (isInitial == undefined) ? false : isInitial;

	for (j = 0; j < str.length; j++) {
		var chr = str.charAt(j);

		if (chr.charCodeAt() > 128) {
			intLen += 2;
		}
		else if (65 <= chr.charCodeAt() && chr.charCodeAt() <= 90) {
			intLen += isInitial ? 2 : 1;
		}
		else {
			intLen++;
		}
	}

	return intLen;
}

// Byte ¸¸Å­ ÀÚ¸¥´Ù.
function leftByte(strObj, lenByte, boolDot, isInitial) {

	var str = strObj;
	var intLen = 0;
	var intSize = 0;
	var boolLen = false;
	var boolDot = (boolDot == undefined) ? true : boolDot;

	isInitial = (isInitial == undefined) ? false : isInitial;

	for (j = 0; j < str.length; j++) {
		var chr = str.charAt(j);

		//intLen += (chr.charCodeAt() > 128) ? 2 : 1;

		if (chr.charCodeAt() > 128) {
			intLen += 2;
		}
		else if (65 <= chr.charCodeAt() && chr.charCodeAt() <= 90) {
			intLen += isInitial ? 2 : 1;
		}
		else {
			intLen++;
		}

		if (intLen <= lenByte) {
			intSize++;
		}
		else {
			boolLen = true;
		}
	}

	var word = str.substring(0, intSize)

	if (boolDot) {
		if (boolLen) {
			word = word + "...";
		}
	}

	return word;
}


// Cut String
//  - Áö¼º¸ñ (¿øº» ¼Ò½º - by ziecle 07.02.06)
function __getText(elem) {
	if (elem.innerText) return elem.innerText;
	if (elem.textContent) return elem.textContent;
	return elem.innerHTML.replace(/<\/?[^>]+>/gi, "");
}

function __setText(elem, text) {
	if (elem.innerText) { elem.innerText = text; return; }
	if (elem.textContent) { elem.textContent = text; return; }
	while (elem.firstChild) elem.removeChild(elem.firstChild);
	elem.appendChild(document.createTextNode(text), elem.childNodes[0]);
}

function stringCut(elem, cutWidth, suffix) {
	var str = __getText(elem);

	var len;
	if (!str || !(len = str.length))
		return;

	elem.style.whiteSpace = "nowrap";
	elem.style.textOverflow = "ellipsis";
	elem.style.overflow = "hidden";

	var width = elem.offsetWidth;

	if (!width || width < cutWidth - 8)
		return;

	var temp = cutWidth;

	if (suffix) {
		elem.innerHTML += suffix;

		cutWidth -= (elem.offsetWidth - width + 4);

		if (cutWidth < 0)
			return;
	}
	else {
		suffix = "";
	}

	elem.title = str;
	var cut = parseInt(cutWidth / (width / len)) + 1;
	
	__setText(elem, str.substr(0, cut));

	if (elem.offsetWidth > cutWidth) {
		while (--cut) {
			__setText(elem, str.substr(0, cut).replace(/(\s*$)/g, ""));

			if (elem.offsetWidth < cutWidth) {
				break;
			}
		}
	}
	else {
		while (cut++ < len) {
			__setText(elem, str.substr(0, cut));

			if (elem.offsetWidth > cutWidth) {
				__setText(elem, str.substr(0, cut - 1).replace(/(\s*$)/g, ""));
				break;
			}
		}
	}

	elem.innerHTML += suffix;
}




/************************************************
	String Function
************************************************/

var xString = {
}






/************************************************
	DateTime Function
************************************************/

var xDateTime = {

	// [2009-02-04 : Áö¼º¸ñ] ³¯Â¥ °´Ã¼ - °£´ÜÇÏ°Ô ³¯Â¥¸¦ ¼¼ÆÃÇÏ·Á¸é (2009/05/05) ÇüÅÂ
	DateTime: function(str) {

		var objDate;

		if (xObject.isNone(str)) {
			objDate = new Date();
		}
		else if (this.isDate(str)) {
			objDate = new Date(str);
		}
		else {
			return null;
		}

		this.Year = objDate.getYear();
		this.Month = (objDate.getMonth() + 1).toString().padLeft(2, '0');
		this.Day = objDate.getDate().toString().padLeft(2, '0');
		this.Hour = objDate.getHours().toString().padLeft(2, '0');
		this.Min = objDate.getMinutes().toString().padLeft(2, '0');
		this.Sec = objDate.getSeconds().toString().padLeft(2, '0');

		return this;
	},


	// [2009-02-04 : Áö¼º¸ñ] ³¯Â¥ÀÎÁö ¿©ºÎ È®ÀÎ
	isDate: function(str) {
		//return (!(Date.parse(obj).toString() == "NaN"));

		if (Date.parse(str)) {
			return true;
		}

		var arrDate = this.isSpliteDate(str);

		if (arrDate[0]) {
			return this.isValidDate(arrDate[1], arrDate[2], arrDate[3]);
		}
		else {
			return false;
		}
	},


	// [2009-02-04 : Áö¼º¸ñ] Çã¿ë FormatÀÎÁö È®ÀÎ
	isValidFormat: function(str) {
		return (this.isSpliteDate(str)[0]);
	},


	// [2005-03-23 : Áö¼º¸ñ] ³¯Â¥ Ã¼Å©
	isValidDate: function(iYear, iMonth, iDay) {

		if (iYear == undefined || iMonth == undefined || iDay == undefined) {
			return false;
		}

		iYear = iYear.toString().padLeft(4, '0');
		iMonth = iMonth.toString().padLeft(2, '0');

		var monthDays = this.getLastDay(iYear.toString() + iMonth.toString());

		var arrDateChk = new Array();
		arrDateChk[0] = (iYear < 1750) ? false : true;
		arrDateChk[1] = (iYear > 2045) ? false : true;
		arrDateChk[2] = (iMonth > 12) ? false : true;
		arrDateChk[3] = (((iDay * 1) < 1) || (iDay > monthDays)) ? false : true;

		return arrDateChk[0] && arrDateChk[1] && arrDateChk[2] && arrDateChk[3];
	},


	// [2009-02-05 : Áö¼º¸ñ] ¹®ÀÚ¸¦ ÀÚ¸¥´Ù.
	//  - Çã¿ë ÇüÅÂ : 20090101, 2009.01.01, 2009-01-01, 2009/01/01
	isSpliteDate: function(str) {

		if (str == undefined) {
			return false;
		}

		var pattern;
		var isValid = true;
		var arrDate = new Array();

		if (str.length == 8) {
			pattern = /^([0-9]{4})([0-9]{2})([0-9]{2})+$/;
		}
		else if (str.length == 10) {
			pattern = /^([0-9]{4})[-.\/]([0-9]{2})[-.\/]([0-9]{2})+$/;
		}
		else {
			isValid = false;
		}

		if (isValid) {
			isValid = (pattern.test(str));

		}

		if (isValid) {
			arrDate[1] = RegExp.$1;
			arrDate[2] = RegExp.$2;
			arrDate[3] = RegExp.$3;
		}

		arrDate[0] = isValid;

		return arrDate;
	},


	// [2006-05-03 : Áö¼º¸ñ] Date Init
	DateInit: function(sDate) {

		var strDate = sDate;

		try {
			// strDate°¡ object·Î ³Ñ¾î¿ÔÀ¸¸é value°ªÀ» ¹Þ°Ô Ã³¸®ÇÑ´Ù.
			if (typeof (strDate) == "object") {
				strDate = strDate.value;
			}

			//  strDate°¡ ºó°ªÀÌ¸é ¿À´Ã ³¯Â¥·Î Ã³¸®ÇÑ´Ù.
			if (strDate == "") {
				strDate = new Date();
			}
			else if (strDate.length == 8) {
				strDate = this.FormatDate("yyyy/MM/dd", strDate);
			}
			else if (strDate.length == 10) {
				strDate = strDate.replace("-", "/");
			}
		}
		catch (e) {
			strDate = sDate;
		}

		if (typeof (strDate) == "object") {
			var objDate = strDate;
		}
		else {
			var objDate = new Date(strDate);
		}

		return objDate;
	},


	// [2005-03-28 : Áö¼º¸ñ] ³¯Â¥ ÇüÅÂ
	FormatDate: function(strFormat, strDate) {

		// strDate°¡ object·Î ³Ñ¾î¿ÔÀ¸¸é value°ªÀ» ¹Þ°Ô Ã³¸®ÇÑ´Ù.
		if (typeof (strDate) == "object") {
			if (!this.isDate(strDate)) {
				strDate = strDate.value;
			}
		}

		//  strDate°¡ ºó°ªÀÌ¸é ¿À´Ã ³¯Â¥·Î Ã³¸®ÇÑ´Ù.
		if (xObject.isNone(strDate)) {
			strDate = new Date();
		}

		// yyyy : ¿¬µµ
		// MM : ¿ù
		// dd : ÀÏ
		// tt : AM/PM
		// hh : ½Ã°£
		// mm : ºÐ
		// ss : ÃÊ

		var m_Date;
		var m_Year;
		var m_Month;
		var m_Day;
		var m_Hour;
		var m_Min;
		var m_Sec;
		var m_tt;

		if (strDate.length == 8) {
			// 20050101
			m_Year = strDate.substring(0, 4);
			m_Month = strDate.substring(4, 6);
			m_Day = strDate.substring(6, 8);
			m_Hour = "00";
			m_Min = "00";
		}
		else if (strDate.length == 10) {
			// 2005-01-01
			m_Year = strDate.substring(0, 4);
			m_Month = strDate.substring(5, 7);
			m_Day = strDate.substring(8, 10);
			m_Hour = "00";
			m_Min = "00";
		}
		else if (strDate.length == 6) {
			// 050101
			m_Year = "20" + strDate.substring(0, 2);
			m_Month = strDate.substring(2, 4);
			m_Day = strDate.substring(4, 6);
			m_Hour = "00";
			m_Min = "00";
		}
		else {
			var objDate = new Date(strDate);
			m_Year = objDate.getYear();
			m_Month = objDate.getMonth() + 1;
			m_Day = objDate.getDate();
			m_Hour = objDate.getHours();
			m_Min = objDate.getMinutes();
			m_Sec = objDate.getSeconds();
		}

		// 1) ¿¬µµ (yyyy or yy)
		if (strFormat.indexOf("yy") > -1) {
			if (!(strFormat.indexOf("yyyy") > -1)) {
				m_Year = m_Year.toString().right(2);
				strFormat = strFormat.replace("yy", "yyyy");
			}
		}

		// 2) ¿ù (MM or M)
		if (strFormat.indexOf("MM") > -1) {
			m_Month = m_Month.toString().padLeft(2, '0');
		}
		else {
			strFormat = strFormat.replace("M", "MM");
		}

		// 3) ÀÏ (dd or d)
		if (strFormat.indexOf("dd") > -1) {
			m_Day = m_Day.toString().padLeft(2, '0');
		}
		else {
			strFormat = strFormat.replace("d", "dd");
		}

		// 4) tt
		if (strFormat.indexOf("tt") > -1) {
			if (m_Hour > 12) {
				m_Hour = m_Hour - 12;
				m_tt = "PM";
			}
			else {
				m_tt = "AM";
			}
		}

		// 5) ½Ã (hh or h)
		if (strFormat.indexOf("HH") > -1) {
			m_Hour = m_Hour.toString().padLeft(2, '0');
		}
		else {
			strFormat = strFormat.replace("H", "HH");
		}

		if (strFormat.indexOf("hh") > -1) {
			m_Hour = m_Hour.toString().padLeft(2, '0');
		}
		else {
			strFormat = strFormat.replace("h", "hh");
		}

		// 6) ºÐ (dd or d)
		if (strFormat.indexOf("mm") > -1) {
			m_Min = m_Min.toString().padLeft(2, '0');
		}
		else {
			strFormat = strFormat.replace("m", "mm");
		}

		// 7) ÃÊ (ss or s)
		if (strFormat.indexOf("ss") > -1) {
			m_Sec = m_Sec.toString().padLeft(2, '0');
		}
		else {
			strFormat = strFormat.replace("s", "ss");
		}

		m_Date = strFormat;
		m_Date = m_Date.replace("yyyy", m_Year);
		m_Date = m_Date.replace("MM", m_Month);
		m_Date = m_Date.replace("dd", m_Day);
		m_Date = m_Date.replace("tt", m_tt);
		m_Date = m_Date.replace("HH", m_Hour);
		m_Date = m_Date.replace("hh", m_Hour);
		m_Date = m_Date.replace("mm", m_Min);
		m_Date = m_Date.replace("ss", m_Sec);

		return m_Date;
	},


	// [2006-05-03 : Áö¼º¸ñ] ÁÖ¾îÁø ³¯Â¥ÀÇ ÁöÁ¤µÈ ºÎºÐÀ» ¹ÝÈ¯ÇÕ´Ï´Ù.
	DatePart: function(interval, sDate) {

		var objDate = this.DateInit(sDate);

		// yyyy ³â
		// q	ºÐ±â
		// m	¿ù
		// d	ÀÏ
		// w	¿äÀÏ
		// ww	ÁÖ (ÀÏ³â±âÁØ)
		// h	½Ã
		// n	ºÐ
		// s	ÃÊ

		var m_Rtn = "";

		if (interval == "ww") {
			// ÁÖ °è»êÀº ÀÏ¿äÀÏ ~ Åä¿äÀÏ ±âÁØÀÌ´Ù.
			var betweenDay = new Number(this.DateDiff("d", "2006-01-01", objDate));
			var beginDay = new Number(this.DatePart("w", "2006-01-01"));
			var m_Rtn = Math.floor((betweenDay + beginDay) / 7);
		}
		else {
			switch (interval) {
				case "yyyy": m_Rtn = objDate.getYear(); break;
				case "m": m_Rtn = objDate.getMonth() + 1; break;
				case "d": m_Rtn = objDate.getDate(); break;
				case "h": m_Rtn = objDate.getHours(); break;
				case "n": m_Rtn = objDate.getMinutes(); break;
				case "s": m_Rtn = objDate.getSeconds(); break;
				case "w":
					m_Rtn = objDate.getDay();
					if (m_Rtn == "0") { m_Rtn = "7"; }
					break;
			}
		}

		return m_Rtn;
	},


	// [2005-03-23 : Áö¼º¸ñ] DateDiff (date2 - date1)
	DateDiff: function(interval, date1, date2) {

		var s, t;
		var ds, dt;
		var MinMilli = 1000 * 60;
		var HrMilli = MinMilli * 60;
		var DyMilli = HrMilli * 24;

		// date1 ¶Ç´Â date2°¡ ºó°ªÀÌ¸é ¿À´Ã³¯Â¥·Î Ã³¸®ÇÑ´Ù.
		if (date1 == "") {
			date1 = new Date();
		}
		else {
			date1 = date1.toString();
			date1 = date1.replace("-", "/", "ig");
		}

		if (date2 == "" || date2 == undefined) {
			date2 = new Date();
		}
		else {
			date2 = date2.toString();
			date2 = date2.replace("-", "/", "ig");
		}

		s = Date.parse(date1);
		t = Date.parse(date2);

		switch (interval) {
			case "d":
				ds = Math.floor(Math.abs(s / DyMilli));
				dt = Math.floor(Math.abs(t / DyMilli));
				break;

			case "h":
				ds = Math.floor(Math.abs(s / HrMilli));
				dt = Math.floor(Math.abs(t / HrMilli));
				break;

			case "m":
				ds = Math.floor(Math.abs(s / MinMilli));
				dt = Math.floor(Math.abs(t / MinMilli));
				break;
		}

		return dt - ds;
	},


	// [2006-01-23 : Áö¼º¸ñ] DateAdd - DateAdd("d", 1, "2005-01-01")
	//  - yyyy ³â / q ºÐ±â / m ¿ù / d ÀÏ / h ½Ã / n ºÐ / s ÃÊ //
	DateAdd: function(interval, number, date) {

		var ds, dt;
		var MinMilli = 1000 * 60;
		var HrMilli = MinMilli * 60;
		var DyMilli = HrMilli * 24;

		// date°¡ ºó°ªÀÌ¸é ¿À´Ã ³¯Â¥·Î Ã³¸®
		ds = (xObject.isNone(date)) ? new Date() : date;
		ds = ds.toString().replace("-", "/");
		dt = Date.parse(ds);

		switch (interval) {
			case "d": dt += (number * DyMilli); break;
			case "h": dt += (number * HrMilli); break;
			case "n": dt += (number * MinMilli); break;
		}

		var da = new Date(dt);
		return da;
	},


	// [2005-11-11 : Áö¼º¸ñ] ¿¬µµ¿Í ¿ùÀ» ¹Þ¾Æ¼­ ±× ´ÞÀÇ ¸¶Áö¸· ³¯Â¥¸¦ ¹ÝÈ¯ÇÑ´Ù.
	getLastDay: function(strYyMm) {
		var lastDay = 0;
		var pattern = new RegExp("^(\\d{4})(0[1-9]{1}||1[0-2]{1})$");
		if (pattern.test(strYyMm) && strYyMm.length == 6) {
			var l_iYear = (RegExp.$1);
			var l_iMonth = (RegExp.$2) * 1;

			if (l_iMonth == 1 || l_iMonth == 3 || l_iMonth == 5 || l_iMonth == 7 || l_iMonth == 8 || l_iMonth == 10 || l_iMonth == 12) {
				lastDay = 31;
			}
			else {
				if (l_iMonth == 2) {
					lastDay = (((l_iYear % 4 == 0) && (l_iYear % 100 != 0)) || (l_iYear % 400 == 0)) ? 29 : 28;
				}
				else {
					lastDay = 30;
				}
			}
		}
		return lastDay;
	},


	// [2009-07-06 : Áö¼º¸ñ] Æ¯Á¤ ³¯Â¥°¡ ÁÖ¾îÁø ¹üÀ§ ¾È¿¡ Æ÷ÇÔµÇ¾î ÀÖ´ÂÁö È®ÀÎ
	isBetween: function(interval, beginDate, endDate, selectDate) {
		if (selectDate == undefined) { selectDate = ""; }

		var _diffA = xDateTime.DateDiff(interval, beginDate, selectDate);
		var _diffB = xDateTime.DateDiff(interval, endDate, selectDate);

		return (0 <= _diffA && _diffB <= 0);
	}
}





/************************************************
	Html Element Function
************************************************/

var xHtmlElement = {
	// [2009-02-18 : Áö¼º¸ñ] Unchecked, Disabled
	None: function(objs) {
		if (xObject.isUndefined(objs.length)) {
			objs.checked = false;
			objs.disabled = true;
		}
		else {
			for (var i = 0; i < objs.length; i++) {
				objs[i].checked = false;
				objs[i].disabled = true;
			}
		}
	},

	// [2009-02-18 : Áö¼º¸ñ] Unchecked, Disabled
	Disabled: function(objs, value) {
		if (xObject.isUndefined(value)) {
			value = true;
		}

		if (xObject.isUndefined(objs.length)) {
			objs.disabled = value;
		}
		else {
			for (var i = 0; i < objs.length; i++) {
				objs[i].disabled = value;
			}
		}
	}
}



var xSelect = {

	// [2009-02-04 : Áö¼º¸ñ] optionÀ» Ãß°¡ÇÑ´Ù
	addOption: function(obj, text, value) {
		var oOption = document.createElement("OPTION");
		obj.add(oOption);
		oOption.innerText = text;
		oOption.value = value;
	},


	// [2009-02-04 : Áö¼º¸ñ] optionÀ» ÁöÁ¤µÈ ¹üÀ§¿¡ ÇØ´çÇÏ´Â °ÍÀ» Ãß°¡ÇÑ´Ù
	addOptionBetween: function(obj, beginValue, endValue, preChar, tailChar) {
		if (preChar == undefined) {
			preChar = "";
		}

		if (tailChar == undefined) {
			tailChar = "";
		}

		for (var i = beginValue; i <= endValue; i++) {
			var text = preChar + i.toString() + tailChar;
			this.addOption(obj, text, i);
		}
	},


	// [2009-02-04 : Áö¼º¸ñ] optionÀ» Á¦°ÅÇÑ´Ù
	removeOption: function(obj, idx) {
		if (idx != null || idx != undefined) {
			obj.remove(idx);
		}
	},


	// [2009-02-04 : Áö¼º¸ñ] optionÀ» °ªÀ» ±âÁØÀ¸·Î Á¦°ÅÇÑ´Ù
	removeOptionValue: function(obj, value) {
		if (value != null || value != undefined) {
			for (var i = 0; i < obj.length; i++) {
				if (obj[i].value == value) {
					this.removeOption(obj, i);
					break;
				}
			}
		}
	},


	// [2009-02-04 : Áö¼º¸ñ] optionÀ» °ª ¹üÀ§·Î Á¦°ÅÇÑ´Ù
	removeOptionBetweenValue: function(obj, beginValue, endValue) {
		var fix = 0;
		for (var i = 0; i < obj.length; i++) {
			if (beginValue <= obj[i].value && obj[i].value <= endValue) {
				this.removeOption(obj, i);
				i--;
			}
		}
	}

}



var xRadio = {
	None: function(objs) {
		xHtmlElement.None(objs);
	},

	Disabled: function(objs, value) {
		xHtmlElement.Disabled(objs, value);
	},

	// [2009-02-18 : Áö¼º¸ñ] ÀÎµ¦½º ±âÁØÀ¸·Î ¼±ÅÃÇÑ´Ù
	Checked: function(objs, idx) {
		try {
			if (xObject.isNullOrEmpty(objs)) {
				return;
			}

			if (xObject.isUndefined(idx)) {
				idx = 0;
			}

			if (xObject.isUndefined(objs.length)) {
				objs.checked = true;
			}
			else {
				if (idx > objs.length || idx == "Last") {
					idx = objs.length - 1;
				}

				objs[idx].checked = true;
			}
		}
		catch (e) { }
	},

	// [2009-02-18 : Áö¼º¸ñ] °¡Àå ¸¶Áö¸· °ÍÀ» ¼±ÅÃÇÑ´Ù.
	CheckedLast: function(objs) {
		this.Checked(objs, "Last");
	}
}



var xCheckbox = {
	None: function(objs) {
		xHtmlElement.None(objs);
	},

	Disabled: function(objs, value) {
		xHtmlElement.Disabled(objs, value);
	}
}


function ToggleObject(obj, boolVisible) {
	obj.style.visibility = (boolVisible) ? "visible" : "hidden";
	obj.style.position = (boolVisible) ? "static" : "absolute";
}





/************************************************
	Object Function
************************************************/

var xObject = {

	// [2009-02-10 : Áö¼º¸ñ] Undefine Is Blank
	UndefineIsBlank: function(obj) {
		return (obj == undefined || obj == "") ? "" : obj;
	},

	// [2009-02-10 : Áö¼º¸ñ] Is Undefined
	isUndefined: function(obj) {
		return (obj == undefined);
	},

	// [2009-02-10 : Áö¼º¸ñ]
	isNullOrEmpty: function(obj) {
		return (obj == null || obj == "");
	},


	// [2009-02-10 : Áö¼º¸ñ] Undefined or Null or Empty
	isNone: function(obj) {
		return (obj == undefined || obj == null || obj == "");
	}
}





/************************************************
	Math Function
************************************************/

var xMath = {

	// [2005-03-23 : Áö¼º¸ñ] ¼ýÀÚÀÎÁö È®ÀÎ
	IsNumeric: function(obj) {
		var _value = (typeof (obj) == "object") ? obj.value : obj;
		var pattern = /^[0-9]+$/;
		return (pattern.test(_value)) ? true : false;
	},
	
	// ³­¼ö¸¦ °¡Á®¿Â´Ù (¸ðµç ¼ö°¡ ±ÕµîÇÏ°Ô ÇÏ±â À§ÇØ¼­ ³»¸²À¸·Î Ã³¸®)
	getRnd: function(Max, Begin) {
		if (Begin == undefined) { Begin = 0; }
		var _rndNum = Math.floor(Math.random() * (((Max - Begin) + 1) * 0.9999)) + Begin;

		if (_rndNum > Max  ) { _rndNum = Max;   }
		if (_rndNum < Begin) { _rndNum = Begin; }

		return _rndNum;
	},

	// Unique
	getUnique: function() { 
		var theUniqueID1 = (new Date()).getTime() % 1000000000; 
		var theUniqueID2 = Math.round(10000000 * Math.random()); 
		theUniqueID2 = (theUniqueID2 + "0000000").slice(0, 7); 
		return theUniqueID1 + theUniqueID2 
	} 
}





/************************************************
	Request Function
************************************************/

var xRequest = {

	// [2006-02-07 : Áö¼º¸ñ] QueryString°ªÀ» ÀÐ´Â´Ù.
	QueryString: function(key) {
		try {
			key = key + "=";

			var url = unescape(self.document.URL);
			var value = "";
			var arrParam = new Array();

			arrParam = (url.slice(url.indexOf("?") + 1, url.length)).split("&");

			for (var i = 0; i < arrParam.length; i++) {
				if (arrParam[i].indexOf(key) != -1) {
					value = arrParam[i].split("=")[1];
					if (value == null || value == undefined) {
						value = "";
					}
				}
			}
		}
		catch (e) {
			value = null;
		}

		return value
	}
}





/************************************************
	Web Browser Function
************************************************/

var browserType = checkBrowser();

// ºê¶ó¿ìÁ® À¯ÇüÀ» È®ÀÎ
function checkBrowser() { 
	if (navigator.userAgent.toUpperCase().indexOf("MSIE") != -1) return "IE";
	else if (navigator.userAgent.toUpperCase().indexOf("MOZILLA") != -1) return "FF";
	else return null;
}





/************************************************
	Nav Move Function
************************************************/

// ´ÙÀ½ Index°ªÀ» °¡Á®¿Â´Ù
function getIdx(num, add, total, min) {

	if (add == "P") { add = -1; }
	if (add == "N") { add = 1; }
	if (min == undefined) { min = 0; }

	var _max = (min * 1) + (total * 1);
	var _idx = (num * 1) + (add * 1);

	if (_idx == _max) {
		_idx = (add > 0) ? min : 0;
	}
	else if (_idx == (min - 1)) {
		_idx = _max - 1;
	}

	return _idx;
}





/************************************************
	Event Function
************************************************/

//add Onclick ÇÔ¼öÃß°¡
function addOnclick(obj, str) {
	obj.onclick = function() {
		eval(str);
		return false;
	};
}


// ÀÌº¥Æ® Ãß°¡
function addEvent(obj, objFun) {
	if (browserType == "IE") {
		obj.onclick = objFun;
	}
	else if (obj.addEventListener) {
		obj.addEventListener('click', objFun, false);
	}
	else if (obj.attachEvent) {
		obj.attachEvent('click', objFun);
	}
}


// ÀÌº¥Æ® Á¦°Å
function removeEvent(obj, objFun) {
	if (browserType == "IE") {
		obj.onclick = "";
	}
	else if (obj.addEventListener) {
		obj.removeEventListener('click', objFun, false);
	}
	else if (obj.attachEvent) {
		obj.removeEventListener('click', objFun);
	}
}





/************************************************
	Cookie Function
************************************************/

var xCookie = {

	// ÄíÅ°°ªÀÌ Á¸ÀçÇÏÁö ¾ÊÀ¸¸é undefined¸¦ ¹ÝÈ¯ÇÑ´Ù.
	getCookie: function(name) {
		var nameOfCookie = name + "=";

		var x = 0;

		while (x <= document.cookie.length) {
			var y = (x + nameOfCookie.length);

			if (document.cookie.substring(x, y) == nameOfCookie) {
				if ((endOfCookie = document.cookie.indexOf(";", y)) == -1) endOfCookie = document.cookie.length;
				return unescape(document.cookie.substring(y, endOfCookie));
			}

			x = document.cookie.indexOf(" ", x) + 1;
			if (x == 0) break;
		}
		return undefined;
	},

	getSubCookie: function(name, name2) {
		var CookieValue = this.getCookie(name);

		if (CookieValue == "") {
			return "";
		}
		else if (CookieValue == null && typeof (CookieValue) == "object") {
			return null;
		}
		else if (CookieValue == undefined && typeof (CookieValue) == "undefined") {
			return undefined;
		}

		var x = 0;
		var y = 0;
		while (x <= CookieValue.length && x != -1) {
			if (x != 0) { x = CookieValue.indexOf('&', x) + 1; }
			y = CookieValue.indexOf('=', y + 1);

			if (CookieValue.substring(x, y) == name2) {
				z = CookieValue.indexOf('&', x) + 0;
				if (z <= 0) { z = CookieValue.length; }
				return (CookieValue.substring(y + 1, z));
				break;
			}
			else {
				x = y;
			}
		}
	},

	getCookieStr: function(name) {
		return ifu(this.getCookie(name), "");
	},

	getSubCookieStr: function(name, name2) {
		return ifu(this.getSubCookie(name, name2), "");
	},

	setCookie: function(name, value, isEscape) {

		isEscape = (isEscape == undefined) ? true : false;

		if (isEscape) {
			value = escape(value);
		}

		var todayDate = new Date();
		todayDate.setDate(todayDate.getDate() + 9999);
		document.cookie = name + "=" + value + "; domain=nate.com; path=/; expires=" + todayDate.toGMTString() + ";";
	},

	setSubCookie: function(name, name2, value, isEscape) {

		var _value = this.getCookie(name);
		var _subvalue = this.getSubCookie(name, name2);

		if (_value == undefined || _value == "") {
			_value = name2 + "=" + value;
		}
		else if (_subvalue == undefined) {
			_value += "&" + name2 + "=" + value;
		}
		else {
			var CookieDic = _value.split("&");
			for (var i = 0; i < CookieDic.length; i++) {
				var CookiePair = CookieDic[i].split("=");
				if (CookiePair[0] == name2) {
					CookiePair[1] = escape(value);
				}
				CookieDic[i] = CookiePair.join("=");
			}

			_value = CookieDic.join("&");
		}

		this.setCookie(name, _value, false);
	}
}








/************************************************
	JsonP Function
************************************************/

function callJsonP(url) {
	var script = document.createElement("SCRIPT");
	script.src = url;
	document.body.appendChild(script);

	//var objs = document.createElement('script');
	//document.getElementsByTagName('head')[0].appendChild(objs);
}

function callJsonPDoc(url, isUTF8) {
	if (isUTF8 == undefined) { isUTF8 = false; }

	if (isUTF8) {
		document.write('<script type="text/javascript" src=\"' + url + '" charset="UTF8"><\/script>');
	}
	else {
		document.write('<script type="text/javascript" src=\"' + url + '"><\/script>');
	}
}