// Trim ÇÔ¼ö ##################################################
// Ex) str = "    Å× ½ºÆ®   ".trim(); => str = "Å× ½ºÆ®";
String.prototype.trim = function() {
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

// ¹®ÀÚ¿­ °ø¹éÁ¦°Å ÇÔ¼ö ##################################################
// Ex) str = "    Å× ½º   Æ®   ".stripspace(); => str = "Å×½ºÆ®";
String.prototype.stripspace = function() {
	return this.replace(/ /g, "");
}

// ÀüÃ¼ ¹®ÀÚ¿­ ¹Ù²Ù±â ÇÔ¼ö ##################################################
// Ex) str = "aÅ×½ºÆ®bcdÅ×½ºÆ®efg".replaceAll("Å×½ºÆ®", ""); => str = "abcdefg";
String.prototype.replaceAll = function(a, b) {
	var s = this;
	var n1, n2, s1, s2;

	while (true) {
		if ( s=="" || a=="" ) break;
		n1 = s.indexOf(a);
		if ( n1 < 0 ) break;
		n2 = n1 + a.length;
		if ( n1==0 ) {
			s1 = b;
		}
		else {
			s1 = s.substring(0, n1) + b;
		}
		if ( n2 >= s.length ) {
			s2 = "";
		}
		else {
			s2 = s.substring(n2, s.length);
		}
		s = s1 + s2;
	}
	return s;
}

// Event Ãß°¡ ##################################################
function addEvent(obj, evt, exec) {
	if (window.attachEvent) obj.attachEvent('on'+evt, exec);
	else if (window.addEventListener) obj.addEventListener(evt, exec, false);
	else obj['on'+evt] = exec;
}

// ÆË¾÷ ##################################################
function MM_openBrWindow(theURL, winName, features) { //v2.0
	if (features && features.indexOf("status") < 0) features += features+",status=yes";
	var popup = window.open(theURL, winName, features);
	popup.focus();
}

// ÆË¾÷ - ÆË¾÷Ã¢ È­¸éÁß¾Ó ¿ÀÇÂ ##################################################
function openPopupCenter(theURL, winName, width, height, remFeatures) {
	var left = (screen.width/2) - (width/2);
	var top = (screen.availHeight/2) - (height/2);
	var features = "left="+left+",top="+top+",width="+width+",height="+height;
	if (remFeatures) features += ","+remFeatures;

	MM_openBrWindow(theURL, winName, features);
}

// ÆË¾÷ - ÆË¾÷Ã¢ »çÀÌÁî Á¶Á¤ ##################################################
function resizePopupWindow(width, height) {
	window.resizeTo(width+12, height+49);
}

// ÆË¾÷ - ÆË¾÷Ã¢ À§Ä¡ Á¶Á¤ ##################################################
function movePopupWindow(left, top) {
	window.moveTo(left, top);
}

// ¸ð´Þ ##################################################
function MM_openModal(theURL, obj, features) {
	window.showModalDialog(theURL, obj, features);
}

// Å° °ü·Ã ÇÔ¼ö ##################################################
function blockKey() {
	event.returnValue = false;
}

function blockEnter() {
	if (event.keyCode == 13) event.keyCode = 0;
}

function blockNotNumber() {
	if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;
}

function onEnter(nextItem) {
	if (event.keyCode == 13) {
		if (nextItem) nextItem.focus();
	}
}

// À§Ä¡ °ü·Ã ÇÔ¼ö ##################################################
function getOffsetLeft(obj) {
	var offset = obj.offsetLeft;
	var objOffsetParent = obj.offsetParent;
	while (objOffsetParent) {
		offset += objOffsetParent.offsetLeft;
		objOffsetParent = objOffsetParent.offsetParent;
	}
	return offset;
}

function getOffsetTop(obj) {
	var offset = obj.offsetTop;
	var objOffsetParent = obj.offsetParent;
	while (objOffsetParent) {
		offset += objOffsetParent.offsetTop;
		objOffsetParent = objOffsetParent.offsetParent;
	}
	return offset;
}

// ÆäÀÌÁö ÀÌµ¿ ##################################################
function gotoUrl(url) {
	if (url.stripspace() != "") {
		location.href = url;
	}
}

// ÆäÀÌÁö ÃÖ»ó´ÜÀ¸·Î ##################################################
function goTop() {
	window.scrollTo(0, 0);
}

// ÆäÀÌÁö ºÎºÐ ÀÎ¼â ##################################################
function printPage(scriptId) {
	MM_openBrWindow("/common/pop_printPage.php?scriptId="+scriptId, "PAGE_PRINT", "width=650, height=500, menubar=yes, scrollbars=yes");
}

// ÀÌ¹ÌÁö ¹Ì¸®º¸±â ##################################################
function previewImage(item, scriptId) {
	var img = document.getElementById(scriptId);

	if (item.value.stripspace() == "") return;

	var ext = getFileExt(item.value).toUpperCase();

	if (ext == 'JPG' || ext == 'GIF' || ext == 'BMP' || ext == 'PNG') img.src = item.value;
}

// ÀÌ¹ÌÁö »çÀÌÁî ÁÙÀÌ±â ##################################################
function resizeImage(scriptId, type, size) { // scriptId(ÀÌ¹ÌÁö Id), type(Á¦ÇÑ ´ë»ó: W-°¡·Î, H-¼¼·Î), size(Á¦ÇÑ »çÀÌÁî)
	var img = document.getElementById(scriptId);

	if (img.complete == false)	{
		setTimeout("resizeImage('"+scriptId+"', '"+type+"', "+size+")", 200);
		return;
	}

	if (type == "W") {
		if (img.width > size) img.width = size;
	}
	else {
		if (img.height > size) img.height = size;
	}
}

// ÀÌ¹ÌÁö »çÀÌÁî ÁÙÀÌ±â (Editor) ##################################################
function resizeImageEditor(no) {
	var objImg = document.getElementById('editor_img'+no);
	var width = parseInt(objImg.width, 10);
	if (width > EDITOR_IMG_WIDTH) objImg.width = EDITOR_IMG_WIDTH;
}

// IFRAME RESIZE ÇÔ¼ö ##################################################
function resizeFrame(iframeWindow, minWidth, minHeight, fixWidth, fixHeight) {
	var iframeElement = document.getElementById(iframeWindow.name);
	var resizeWidth, resizeHeight;

	minWidth = (minWidth) ? parseInt(minWidth, 10) : 0;
	minHeight = (minHeight) ? parseInt(minHeight, 10) : 0;
	fixWidth = (fixWidth) ? parseInt(fixWidth, 10) : 0;
	fixHeight = (fixHeight) ? parseInt(fixHeight, 10) : 0;

	if (navigator.appName.indexOf("Netscape") == -1) { // ie
		if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') {
			resizeWidth = iframeWindow.document.documentElement.scrollWidth;
			resizeHeight = iframeWindow.document.documentElement.scrollHeight;
		}
		else {
			resizeWidth = iframeWindow.document.body.scrollWidth;
			resizeHeight = iframeWindow.document.body.scrollHeight;
		}
	}
	else {
		resizeWidth = iframeWindow.document.body.scrollWidth;
		resizeHeight = iframeWindow.document.body.scrollHeight;
	}

	if (minWidth > 0 && resizeWidth < minWidth) resizeWidth = minWidth;			// ÃÖ¼Ò Æø
	if (minHeight > 0 && resizeHeight < minHeight) resizeHeight = minHeight;		// ÃÖ¼Ò ³ôÀÌ

	if (fixWidth > 0) resizeWidth = fixWidth;		// °íÁ¤ Æø
	if (fixHeight > 0) resizeHeight = fixHeight;	// °íÁ¤ ³ôÀÌ

	if (fixWidth > -1) iframeElement.style.width = resizeWidth + 'px';
	if (fixHeight > -1) iframeElement.style.height = resizeHeight + 'px';
}

// ÇöÀç ÀÌº¥Æ®°´Ã¼ Index °¡Á®¿À±â ##################################################
function getDisObjIdx(item) {
	var i = 0;
	var result = 0;

	var arrTag = document.getElementsByTagName('*');

	if (item.sourceIndex) {
		while (arrTag[i].sourceIndex < item.sourceIndex) {
			if (arrTag[i].id == item.id) ++result;
			++i;
		}
	}
	else if (item.compareDocumentPosition) {
		while ((arrTag[i].compareDocumentPosition(item) & 6) - 3 > 0) {
			if (arrTag[i].id == item.id) ++result;
			++i;
		}
	}

	return result;
}

// Ã¼Å©¹Ú½º ÀüÃ¼¼±ÅÃ ##################################################
function checkCbAll(cbList, isChecked) {
	if (cbList) {
		if (typeof(cbList.length) == "undefined") {
			if (!cbList.disabled) cbList.checked = isChecked;
		}
		else {
			for (var i=0; i<cbList.length; i++) {
				if (cbList[i].type.toUpperCase() == 'CHECKBOX') {
					if (cbList[i].value.stripspace() != "" && !cbList[i].disabled) {
						cbList[i].checked = isChecked;
					}
				}
			}
		}
	}
}

// ÅØ½ºÆ® ±æÀÌ È®ÀÎ (ÀÏ¹Ý) ##################################################
function checkTextLen(item, mLen) {
	if (item.value.length > mLen){
		alert("1~"+mLen+"ÀÚ±îÁö ÀÔ·ÂÀÌ °¡´ÉÇÕ´Ï´Ù.");
		item.value = item.value.substring(0, mLen);
		item.focus();
		return false;
	}

	return true;
}

// ÅØ½ºÆ® ±æÀÌ È®ÀÎ (Byte) ##################################################
function checkTextLenByte(item, mLen) {
	var i, len;
	var byteLen = 0;
	var value = item.value;

	for (i=0, len=value.length; i<len; i++) {
		++byteLen;

		if ((value.charCodeAt(i) < 0) || (value.charCodeAt(i) > 127)) ++byteLen;

		if (byteLen > mLen) {
			alert("1~"+(mLen / 2)+"ÀÚÀÇ ÇÑ±Û, ¶Ç´Â 2~"+mLen+"ÀÚÀÇ ¿µ¹®, ¼ýÀÚ, ¹®Àå±âÈ£·Î ÀÔ·ÂÀÌ °¡´ÉÇÕ´Ï´Ù.");
			item.value = value.substring(0, i);
			item.focus();
			return false;
		}
	}

	return true;
}

// ÅØ½ºÆ® Byte ±æÀÌ °¡Á®¿À±â ##################################################
function getTextByte(value) {
	var i, len;
	var byteLen = 0;

	for (i=0, len=value.length; i<len; i++) {
		if (escape(value.charAt(i)).length >= 4) {
			byteLen += 2;
		}
		else if (escape(value.charAt(i)) != "%0D") {
			++byteLen;
		}
	}

	return byteLen;
}

// ÀÔ·Â ¹®ÀÚ±æÀÌ È®ÀÎÈÄ ´ÙÀ½Ç×¸ñÀ¸·Î Æ÷Ä¿½º ¿Å±â±â ##################################################
function goNextFocusChk(item, len, next_item) {
	if (item.value.stripspace().length == len){
		next_item.focus();
	}
}

// ¿µ¹® È®ÀÎ ##################################################
function checkEng(value){
	var i;

	for(i=0;i<value.length-1;i++){
		// ÇÑ±Û Ã¼Å© (ÇÑ±Û ASCIIÄÚµå : 12593ºÎÅÍ)
		if (value.charCodeAt(i) > 12592) return false;
		// °ø¹é Ã¼Å©
		if (value.charAt(i) == " ") return false;
	}
	return true;
}

// ¿µ¹® ´ë¹®ÀÚ È®ÀÎ ##################################################
function checkEngBig(value) {
	var RegExp = /^[A-Z]*$/;
	return RegExp.test(value) ? true : false;
}

// ¿µ¹®/¼ýÀÚ È¥¿ë È®ÀÎ ##################################################
function checkEngNum(value) {
	var RegExpE = /[a-zA-Z]/i;
	var RegExpN = /[0-9]/;

	return (RegExpE.test(value) && RegExpN.test(value)) ? true : false;
}

// Æ¯¼ö¹®ÀÚ È®ÀÎ ##################################################
function checkSpecialChar(value) {
	var specialChar = "`~!@#$%^&*_+=|\\[]{}:;,<.>/?'\"";
	for (var i=0, len=specialChar.length; i<len; i++) {
		if (value.indexOf(specialChar.substr(i, 1)) != -1) return true;
	}
	return false;
}

// ÇÑ±Û È®ÀÎ ##################################################
function checkKor(value) {
	for (var i=0, len=value.length; i<len; i++) {
		if (value.charCodeAt(i) != 32 && (value.charCodeAt(i) < 44032 || value.charCodeAt(i) > 55203)) return false;
	}
	return true;
}

// ¾ÆÀÌµð È®ÀÎ ##################################################
function checkID(value, min, max) {
	var RegExp = /^[a-zA-Z0-9_]*$/i;
	var returnVal = RegExp.test(value) ? true : false;
	if (typeof(min) != "undefined" && value.length < min) returnVal = false;
	if (typeof(max) != "undefined" && value.length > max) returnVal = false;
	return returnVal;
}

// ºñ¹Ð¹øÈ£ È®ÀÎ ##################################################
function checkPW(value, min, max) {
	var RegExp = /^[a-zA-Z0-9]*$/i;
	var returnVal = RegExp.test(value) ? true : false;
	if (typeof(min) != "undefined" && value.length < min) returnVal = false;
	if (typeof(max) != "undefined" && value.length > max) returnVal = false;
	return returnVal;
}

// ÆÄÀÏ¸í È®ÀÎ ##################################################
function checkFileName(item) {
	var result = false;

	if (item.value.stripspace() != "") {
		var fidx = item.value.lastIndexOf("\\")+1;
		var filename = item.value.substr(fidx, item.value.length);
		result = checkEng(filename);
	}

	if (!result) {
		alert("ÆÄÀÏ¸íÀ» ¹Ýµå½Ã ¿µ¹® ¶Ç´Â ¼ýÀÚ·Î ÇØÁÖ¼¼¿ä.");
		item.focus();
		return false;
	}
	return true;
}

// ÆÄÀÏ È®ÀåÀÚ ##################################################
function getFileExt(value) {
	if (value != "") {
		var fidx = value.lastIndexOf("\\")+1;
		var filename = value.substr(fidx, value.length);
		var eidx = filename.lastIndexOf(".")+1;

		return filename.substr(eidx, filename.length);
	}
}

// ÆÄÀÏÈ®ÀåÀÚ È®ÀÎ ##################################################
function checkFileExt(item, exts, errMsg) {
	var arrExt = exts.toLowerCase().split(",");
	var result = false;

	if (item.value.stripspace() != "") {
		var ext = getFileExt(item.value).toLowerCase();

		for (var i=0; i<arrExt.length; i++) {
			if (arrExt[i].trim() == ext) result = true;
		}
	}

	if (!result) {
		alert(errMsg);
		item.focus();
		return false;
	}
	return true;
}

// ¼ýÀÚ È®ÀÎ ##################################################
function checkNum(value, isDec) {
	var RegExp;

	if (!isDec) isDec = false;

	if (isDec) RegExp = /^-?[\d\.]*$/;
	else RegExp = /^-?[\d]*$/;

	return RegExp.test(value)? true : false;
}

// ÀÌ¸ÞÀÏ È®ÀÎ ##################################################
function checkEmail(email) {
	if (email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
		return true;
	}
	else {
		return false;
	}
}

// URL È®ÀÎ ##################################################
function checkUrl(url) {
	var exp = new RegExp("^(http|HTTP)\:\/\/");
	if (exp.test(url)) {
		return true;
	}
	else {
		return false;
	}
}

// °ø¹é È®ÀÎ ##################################################
function checkEmpty(item) {
	if (item.value.stripspace() == "") {
		return true;
	}
	else {
		return false;
	}
}

// Radio(CheckBox) ¼³Á¤°ª °¡Á®¿À±â ##################################################
function getRadioVal(item) {
	var i, value = "";

	if (item) {
		if (typeof(item.length) == "undefined") {
			if (item.checked) {
				value = item.value;
			}
		}
		else {
			for (i=0; i<item.length; i++) {
				if (item[i].checked) {
					value = item[i].value;
					break;
				}
			}
		}
	}
	return value;
}

// Radio ¼³Á¤ÇÏ±â ##################################################
function setRadioVal(item, value) {
	var i;

	if (item) {
		if (typeof(item.length) == "undefined") {
			if (item.value == value) {
				item.checked = true;
			}
		}
		else {
			for(i=0; i<item.length; i++) {
				if (item[i].value == value) {
					item[i].checked = true;
					break;
				}
			}
		}
	}
}

// Radio Disabled ¼³Á¤ÇÏ±â ##################################################
function setRadioDisabled(item, value, disabled) {
	var i;

	if (item) {
		if (typeof(item.length) == "undefined") {
			if (item.value == value) {
				item.disabled = disabled;
			}
		}
		else {
			for(i=0; i<item.length; i++) {
				if (item[i].value == value) {
					item[i].disabled = disabled;
					break;
				}
			}
		}
	}
}

// Form Disabled ÀüÃ¼ ¼³Á¤ÇÏ±â ##################################################
function setRadioDisabledAll(item, disabled) {
	var i;

	if (item) {
		if (typeof(item.length) == "undefined") {
			item.disabled = disabled;
		}
		else {
			for(i=0; i<item.length; i++) {
				item[i].disabled = disabled;
			}
		}
	}
}

// Select ¼³Á¤°ª °¡Á®¿À±â ##################################################
function getSelectVal(item) {
	var value = "";
	var idx = item.selectedIndex;

	if (idx >= 0){
		value = item.options[idx].value;
	}

	return value;
}

// Select Option Ãß°¡ ##################################################
function selectAddList(item, text, value) {
	var newOpt = document.createElement("option");
	newOpt.text = text;
	newOpt.value = value;
	item.options.add(newOpt);
}

// Select Option ÀüÃ¼»èÁ¦ ##################################################
function selectRemoveAll(item) {
	for (var i=item.length-1; i>=0; i--) {
		selectRemoveList(item, i);
	}
}

// Select Option »èÁ¦ ##################################################
function selectRemoveList(item, i) {
	item.remove(i);
}

// Hidden Ãß°¡ ##################################################
function addHidden(form, name, value) {
	var input = document.createElement('input');
	input.type = 'hidden';
	input.name = name;
	input.value = value;
	form.appendChild(input);
}

// ¼ýÀÚ ¹®ÀÚ¿­¿¡¼­ ¹®ÀÚ¿­ Á¦°Å ##################################################
function stripCharFromNum(value, isDec) {
	var i;
	var minus = "-";
	var nums = "1234567890"+((isDec) ? "." : "");
	var result = "";

	for(i=0; i<value.length; i++) {
		numChk = value.charAt(i);
		if (i == 0 && numChk == minus) {
			result += minus;
		}
		else {
			for(j=0; j<nums.length; j++) {
				if (numChk == nums.charAt(j)) {
					result += nums.charAt(j);
					break;
				}
			}
		}
	}
	return result;
}

// ÄÞ¸¶(,) Á¦°Å ##################################################
function stripComma(value) {
    var re = /,/g;
    return value.replace(re, "");
}

// ¼ýÀÚ 3ÀÚ¸®¼ö¸¶´Ù ÄÞ¸¶(,) Âï±â ##################################################
function formatComma(num, pos) {
	if (!pos) pos = 0;  //¼Ò¼ýÁ¡ ÀÌÇÏ ÀÚ¸®¼ö
	var re = /(-?\d+)(\d{3}[,.])/;

	var strNum = stripComma(num.toString());
	var arrNum = strNum.split(".");

	arrNum[0] += ".";

    while (re.test(arrNum[0])) {
        arrNum[0] = arrNum[0].replace(re, "$1,$2");
    }

	if (arrNum.length > 1) {
		if (arrNum[1].length > pos) {
			arrNum[1] = arrNum[1].substr(0, pos);
		}
		return arrNum.join("");
	}
	else {
		return arrNum[0].split(".")[0];
	}
}

// °­Á¦ ¼Ò¼öÁ¡ ÀÌÇÏ 0Ã¤¿ì±â ##################################################
// num: ´ë»ó¼ýÀÚ, pos: Ãâ·ÂÀ» ¿øÇÏ´Â ¼Ò¼öÁ¡ÀÚ¸®¼ö
function setRoundZero(num, pos) {
	var strNum = stripComma(num.toString());
	var arrNum = strNum.split(".");

	if (arrNum.length <= 1) {
		num = arrNum[0]+".";
		for (var i=0; i<pos; i++) {
			num += "0";
		}
	}
	else {
		num = setRound(num, pos);
	}
	return num;
}

// ¼Ò¼öÁ¡ ÀÌÇÏ ¹Ý¿Ã¸² ##################################################
// num: ´ë»ó¼ýÀÚ, pos:Ãâ·ÂÀ» ¿øÇÏ´Â ¼Ò¼öÁ¡ÀÚ¸®¼ö
function setRound(num, pos) {
	if (!pos) pos = 0;
	return (Math.round(num*(Math.pow(10,pos))))/(Math.pow(10, pos));
}

// ¼Ò¼öÁ¡ ÀÌÇÏ ÀÚ¸®¼ö È®ÀÎ ##################################################
// num: ´ë»ó¼ýÀÚ, pos: Èñ¸Á ¼Ò¼öÁ¡ ÀÌÇÏÀÚ¸®¼ö
function checkRound(num, len) {
	var strNum = stripComma(num.toString());
	var arrNum = strNum.split(".");

	if (arrNum.length > 1 && arrNum[1].length > len) return false;
	else return true;
}

// ¼ýÀÚ ¹®ÀÚ¿­¿¡¼­ "0" ½ÃÀÛ¹®ÀÚ Á¦°Å ##################################################
function removePreZero(value) {
	var i, result;

	for (i = 0; i<value.length; i++) {
		if (value.substr(i,1) != "0") break;
	}

	result = value.substr(i, value.length-i);
	//if (result == "") result = "0";
	return result;
}

// ÅëÈ­ÇüÅÂ·Î º¯È¯ ##################################################
function toCurrency(item) {
	if (isDirectionKey(event.keyCode)) return false;
	if (item.disabled) return false;

	var num = item.value.stripspace();
	if (num == "") return false;

	if (!checkNum(stripComma(num))) {
		alert ("¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
		num = stripCharFromNum(num, false);
	}
	num = stripCharFromNum(stripComma(num), false);
	num = removePreZero(num);
	item.value = formatComma(num);
}

// ¼ýÀÚÀÔ·Â È®ÀÎ ##################################################
function numberOnly(item, isDec) {
	if (!isDec) isDec = false;
	if (isDirectionKey(event.keyCode)) return false;
	if (item.disabled) return false;

	var num = item.value.stripspace();
	if (num == "") return false;

	if (!checkNum(num, isDec)) {
		alert ("¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
		num = stripCharFromNum(num, isDec);
	}
	num = stripCharFromNum(stripComma(num), isDec);

	var arrNum = num.split(".");
	if (arrNum.length > 1) {
		item.value = arrNum[0]+"."+arrNum[1];
	}
	else {
		item.value = arrNum[0];
	}
}

// ¹æÇâÅ° Key Event È®ÀÎ ##################################################
function isDirectionKey(code) {
	switch(code){
		case 39: // ¿À¸¥ÂÊ
		case 37: // ¿ÞÂÊ
		case 38: // À§
		case 40: // ¾Æ·¡
		case 9: // tab
			return true;
			break;
		default:
			return false;
			break;
	}
}

// ¼ýÀÚ Áõ°¨ Ã³¸® ##################################################
function controllNum(item, mode, isminus) {
	var num = item.value;
	if (!isminus) isminus = 0;

	num = (num.stripspace() == "") ? 0 : num;
	num = (isNaN(num)) ? 0 : parseInt(num, 10);

	if (mode == '+') ++num;
	else --num;

	if (isminus != 1 && num < 0) num = 0;

	item.value = num;
}

// ³¯ÀÚ À¯È¿¼º È®ÀÎ ##################################################
function isDate(strDate){
	var tmpArr;
	var tmpYear, tmpMon, tmpDay;

	if (strDate.length != 10) return false;

	tmpArr = strDate.split("-");

	if (tmpArr.length != 3 ) return false;

	tmpYear = tmpArr[0];
	tmpMon = tmpArr[1];
	tmpDay = tmpArr[2];

	var tDateString = tmpYear+'/'+tmpMon+'/'+tmpDay+' 8:0:0';
	var tmpDate = new Date(tDateString);

	if (isNaN(tmpDate)) return false;

	if (((tmpDate.getFullYear()).toString() == tmpYear) && (tmpDate.getMonth() == parseInt(tmpMon, 10)-1) && (tmpDate.getDate() == parseInt(tmpDay, 10))) {
		return true;
	}
	else {
		return false;
	}
}

// # ³¯Â¥ ±â°£ °è»ê ##################################################
function inputDate(svrdate, sdate, edate, type, term) {
	today = new Date(svrdate);
	now_year = today.getYear();
	now_month = today.getMonth()+1;
	now_day = today.getDate();

	if (isNaN(term)) term = 0;

	month_temp = now_month-1;
	day_temp = getLastDay(now_year, month_temp);

	the_day = now_day;
	the_month = now_month;
	the_year = now_year;

	if (type == 'T') {
		opt_day = now_day-term;
		if(opt_day>0) {
			the_day = opt_day;
		}
		else {
			opt_month = now_month-1;
			the_day = day_temp+opt_day;
			if(opt_month>0) {
				the_month = opt_month;
			}
			else {
				the_year = now_year-1;
				the_month = 12;
			}
		}
	}
	else if (type=='D') {
		opt_day = now_day-term;
		if(opt_day>0) {
			the_day = opt_day;
		}
		else {
			opt_month = now_month-1;
			the_day = day_temp+opt_day;
			if(opt_month>0) {
				the_month = opt_month;
			}
			else {
				the_year = now_year-1;
				the_month = 12;
			}
		}
	}
	else if (type == 'M') {
		opt_month = now_month-term;
		if(opt_month>0) {
			the_month = opt_month;
		}
		else {
			the_year = now_year-1;
			the_month = 12+opt_month;
		}
	}
	else if (type=='Y'){
		the_year = now_year-term;
	}

	the_ymLastDay = getLastDay(the_year, the_month);
	if (the_ymLastDay < the_day) the_day = the_ymLastDay;

	if(the_month<10) the_month='0'+the_month;
	if(the_day<10) the_day = '0'+the_day;

	the_date = the_year+'-'+the_month+'-'+the_day;
	sdate.value = the_date;

	if(now_month<10) now_month = '0'+now_month;
	if(now_day<10) now_day = '0'+now_day;

	if (type == 'W') {
		sdate.value='';
		if (edate) edate.value='';
	}
	else if (type == 'T' && term > 0) {
		if (edate) edate.value = the_date;
	}
	else {
		now_date = now_year+'-'+now_month+'-'+now_day;
		if (edate) edate.value = now_date;
	}
}

// # ¿ùº° ÀÏÀÚ¼ö ÃßÃâ ##################################################
function getLastDay(year, month) {
	var last_day = 31;

	switch(month) {
		case(1): last_day=31; break;
		case(2):
			// À±³â È®ÀÎ
			if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
				last_day=29;
			}
			else{
				last_day=28;
			}
			break;
		case(3): last_day=31; break;
		case(4): last_day=30; break;
		case(5): last_day=31; break;
		case(6): last_day=30; break;
		case(7): last_day=31; break;
		case(8): last_day=31; break;
		case(9): last_day=30; break;
		case(10): last_day=31; break;
		case(11): last_day=30; break;
		case(12): last_day=31; break;
		default: last_day=31; break;
	}

	return last_day;
}
