if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
	try { document.execCommand('BackgroundImageCache', false, true); } catch(e) {}
}

function bluring() {
	if (event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG") document.body.focus();
}
document.onfocusin = bluring;

// Trim ÇÔ¼ö ##################################################
// Ex) str = "    Å× ½ºÆ®   ".trim(); => str = "Å× ½ºÆ®";
String.prototype.trim = function() {
	return this.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/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;
}

// ÀÌº¥Æ® Ãß°¡ ##################################################
function addEvent(obj, type, listener) {
	if (window.addEventListener) obj.addEventListener(type, listener, false);
	else obj.attachEvent('on'+type, listener);
}

// ÀÌº¥Æ® Ãß°¡ ##################################################
function removeEvent(obj, type, listener) {
	if (window.removeEventListener) obj.removeEventListener(type, listener, false);
	else obj.detachEvent('on'+type, listener);
}

// ÆË¾÷ ##################################################
function openPopup(theURL, winName, width, height, remFeatures) {
	var features = "";
	if (typeof winName == "undefined") winName = "";
	if (typeof width != "undefined") features += ((features) ? "," : "")+"width="+width;
	if (typeof height != "undefined") features += ((features) ? "," : "")+"height="+height;
	if (typeof remFeatures != "undefined") features += ((features) ? "," : "")+remFeatures;
	if (features.indexOf("status") < 0) features += ",status=yes";

	var popup = window.open(theURL, winName, features);
	popup.focus();

	return popup;
}

// ÆË¾÷ - ÆË¾÷Ã¢ È­¸éÁß¾Ó ¿ÀÇÂ ##################################################
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 (typeof winName == "undefined") winName = "";
	if (typeof remFeatures != "undefined") features += ","+remFeatures;
	if (features.indexOf("status") < 0) features += ",status=yes";

	var popup = window.open(theURL, winName, features);
	popup.focus();

	return popup;
}

// ÆË¾÷ - ÆË¾÷Ã¢ »çÀÌÁî Á¶Á¤ ##################################################
function resizePopupWindow(width, height) {
	var userAgent = navigator.userAgent.toLowerCase();
	var isMSIE = (userAgent.indexOf('msie') != -1);
	var agentVer = 0;
	if (isMSIE) {
		var pos_msie = userAgent.indexOf('msie ');
		agentVer = parseInt(userAgent.substring(pos_msie+5, userAgent.indexOf(".", pos_msie)), 10);
	}
	var isMoz = (userAgent.indexOf('gecko') != -1);
	window.resizeTo(width+10, height+((isMSIE && agentVer>6) ? 75 : (isMoz ? 81 : 49)));
 
}

// ÆË¾÷ - ÆË¾÷Ã¢ À§Ä¡ Á¶Á¤ ##################################################
function movePopupWindow(left, top) {
	window.moveTo(left, top);
}

// ¸ð´Þ ##################################################
function MM_openModal(theURL, obj, features) {
	window.showModalDialog(theURL, obj, features);
}

// Å° °ü·Ã ÇÔ¼ö ##################################################
function blockKey(e) {
	var e = window.event || e;
	if (window.event) {
		e.returnValue = false;
	}
	else {
		if (e.which != 8) e.preventDefault(); // 8 : Back Space
	}
}

function blockEnter(e) {
	var e = window.event || e;
	if (window.event) {
		if (e.keyCode == 13) e.returnValue = false;
	}
	else {
		if (e.which == 13) e.preventDefault();
	}
}

function blockNotNumber(e) {
	var e = window.event || e;
	if (window.event) {
		if (e.keyCode < 48 || e.keyCode > 57) e.returnValue = false;
	}
	else {
		if (e.which != 8 && (e.which < 48 || e.which > 57)) e.preventDefault(); // 8 : Back Space
	}
}

function onEnter(e, exec) {
	var e = window.event || e;
	var keyCode = (window.event) ? e.keyCode : e.which;
	if (keyCode == 13) eval(exec);
}

// Áñ°ÜÃ£±â Ãß°¡ ##################################################
// ¿¹) <a href="javascript:;" onClick="addFavorites('È¨ÆäÀÌÁö', 'http://www.homepage.com');">Áñ°ÜÃ£±â µî·Ï</a>
function addFavorites(title, url) {
	if (document.all) { // IE
		window.external.AddFavorite(url, title);
	}
	else if (window.sidebar) { // Firefox
		window.sidebar.addPanel(title, url, "");
	}
	else { // Opera, Safari ...
		alert("ÇöÀç ºê¶ó¿ìÁ®¿¡¼­´Â ÀÌ¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
		return;
	}
}

// ½ÃÀÛÆäÀÌÁö ¼³Á¤ ##################################################
// ¿¹) <a href="javascript:;" onClick="setStartPage(this, 'http://www.homepage.com');">½ÃÀÛÆäÀÌÁö·Î</a>
function setStartPage(obj, url) {
	if (document.all && window.external) { // IE
		obj.style.behavior = "url(#default#homepage)";
		obj.setHomePage(url);
	}
	else { // Firefox, Opera, Safari ...
		alert("ÇöÀç ºê¶ó¿ìÁ®¿¡¼­´Â ÀÌ¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
		return;
    }
}

// ÆäÀÌÁö ÀÌµ¿ ##################################################
function gotoUrl(url) {
	if (url.stripspace() != "") {
		location.href = url;
	}
}

// ÆäÀÌÁö ÃÖ»ó´ÜÀ¸·Î ##################################################
function goTop() {
	window.scrollTo(0, 0);
}

// ÀÌ¹ÌÁö ¹Ì¸®º¸±â ##################################################
function previewImage(obj, imgId) {
	var objImg = document.getElementById(imgId);

	if (obj.value.stripspace() == "") return;

	var ext = getFileExt(obj.value).toUpperCase();

	if (ext == 'JPG' || ext == 'GIF' || ext == 'BMP' || ext == 'PNG') objImg.src = obj.value;
}

// ÀÌ¹ÌÁö »çÀÌÁî ÁÙÀÌ±â ##################################################
function resizeImage(objImg, limitId) {
	if (typeof (objImg) != "object") objImg = document.getElementById(objImg);
	var objParent = objImg.parentNode;
	var imgWidth = parseInt(objImg.width, 10);
	var fixWidth = imgWidth;

	if (typeof limitId == 'undefined') return;

	while (objParent) {
		if (objParent && objParent.id == limitId) {
			fixWidth = objParent.clientWidth;
			break;
		}
		objParent = objParent.offsetParent;
	}

	if (imgWidth > fixWidth) {
		objImg.width = fixWidth;
	}
}

function resizeImageAll(limitId) {
	var objLimit = document.getElementById(limitId);
	if (objLimit) {
		var fixWidth = objLimit.clientWidth;
		var arrImgs = objLimit.getElementsByTagName("IMG");
		for (var i=0, len=arrImgs.length; i<len; i++) {
			if (parseInt(arrImgs[i].width, 10) > fixWidth) {
				arrImgs[i].width = fixWidth;
			}
		}
	}
}

// IFRAME RESIZE ÇÔ¼ö ##################################################
function resizeFrame(iframeWindow, minWidth, minHeight, fixWidth, fixHeight) {
	if (!iframeWindow.name) return false;

	var iframeElement = document.getElementById(iframeWindow.name);
	var resizeWidth = 0;
	var resizeHeight = 0;

	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 (document.all) { // 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(obj) {
	var i = 0;
	var result = 0;

	var arrTag = document.getElementsByTagName(obj.tagName);

	if (obj.sourceIndex) {
		while (arrTag[i].sourceIndex < obj.sourceIndex) {
			if (arrTag[i].id == obj.id) ++result;
			++i;
		}
	}
	else if (obj.compareDocumentPosition) {
		while ((arrTag[i].compareDocumentPosition(obj) & 6) - 3 > 0) {
			if (arrTag[i].id == obj.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(obj, mLen) {
	if (obj.value.length > mLen){
		alert("1~"+mLen+"ÀÚ±îÁö ÀÔ·ÂÀÌ °¡´ÉÇÕ´Ï´Ù.");
		obj.value = obj.value.substring(0, mLen);
		obj.focus();
		return false;
	}

	return true;
}

// ÅØ½ºÆ® ±æÀÌ È®ÀÎ (Byte) ##################################################
function checkTextLenByte(obj, mLen) {
	var i, len;
	var byteLen = 0;
	var value = obj.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+"ÀÚÀÇ ¿µ¹®, ¼ýÀÚ, ¹®Àå±âÈ£·Î ÀÔ·ÂÀÌ °¡´ÉÇÕ´Ï´Ù.");
			obj.value = value.substring(0, i);
			obj.focus();
			return false;
		}
	}

	return true;
}

// °´Ã¼ Offset °¡Á®¿À±â ##################################################
function getOffset(obj) {
	var offset = { left : 0, top : 0 };
	var parent = obj.offsetParent;

	offset.left = parseInt(obj.offsetLeft, 10);
	offset.top = parseInt(obj.offsetTop, 10);

     while (parent) { 
        if (navigator.userAgent.toLowerCase().indexOf("msie") != -1) { 
            offset.left += parseInt(parent.offsetLeft, 10)+(isNaN(parseInt(parent.currentStyle.borderLeftWidth, 10))?0:parseInt(parent.currentStyle.borderLeftWidth, 10)); 
            offset.top += parseInt(parent.offsetTop, 10)+(isNaN(parseInt(parent.currentStyle.borderTopWidth, 10))?0:parseInt(parent.currentStyle.borderTopWidth, 10)); 
        } 
        else { 
            offset.left += parseInt(parent.offsetLeft, 10); 
            offset.top += parseInt(parent.offsetTop, 10); 
        } 
        parent = parent.offsetParent; 
    } 
    return offset; 
}

// ÅØ½ºÆ® 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 goNextFocus(obj, len, next_item) {
	if (obj.value.stripspace().length == len){
		next_item.focus();
	}
}

// ¿µ¹® ¹®ÀÚ¿­ È®ÀÎ ##################################################
function strEngCheck(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 checkFileName(obj) {
	var result = false;

	if (obj.value.stripspace() != "") {
		var fidx = obj.value.lastIndexOf("\\")+1;
		var filename = obj.value.substr(fidx, obj.value.length);
		result = strEngCheck(filename);
	}

	if (!result) {
		alert("ÆÄÀÏ¸íÀ» ¹Ýµå½Ã ¿µ¹® ¶Ç´Â ¼ýÀÚ·Î ÇØÁÖ¼¼¿ä.");
		obj.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(obj, exts, errMsg) {
	var arrExt = exts.toLowerCase().split(",");
	var result = false;

	if (obj.value.stripspace() != "") {
		var ext = getFileExt(obj.value).toLowerCase();

		for (var i=0; i<arrExt.length; i++) {
			if (arrExt[i].trim() == ext) result = true;
		}
	}

	if (!result) {
		alert(errMsg);
		obj.focus();
		return false;
	}
	return true;
}

// ¿µ¹®/¼ýÀÚ È¥¿ë È®ÀÎ ##################################################
function checkEngNum(str) {
	var RegExpE = /[a-zA-Z]/i;
	var RegExpN = /[0-9]/;

	return (RegExpE.test(str) && RegExpN.test(str)) ? 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 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 checkPass(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 checkNum(value, isDec) {
	var RegExp;

	if (!isDec) isDec = false;
	RegExp = (isDec) ? /^-?[\d\.]*$/ : /^-?[\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|https)\:\/\/");
	if (exp.test(url.toLowerCase())) {
		return true;
	}
	else {
		return false;
	}
}

// °ø¹é È®ÀÎ ##################################################
function checkEmpty(obj) {
	if (obj.value.stripspace() == "") {
		return true;
	}
	else {
		return false;
	}
}

// Radio(CheckBox) ¼³Á¤°ª °¡Á®¿À±â ##################################################
function getRadioVal(obj) {
	var i, value = "";

	if (obj) {
		if (typeof(obj.length) == "undefined") {
			if (obj.checked) {
				value = obj.value;
			}
		}
		else {
			for (i=0; i<obj.length; i++) {
				if (obj[i].checked) {
					value = obj[i].value;
					break;
				}
			}
		}
	}
	return value;
}

// Radio ¼³Á¤ÇÏ±â ##################################################
function setRadioVal(obj, value) {
	var i;

	if (obj) {
		if (typeof(obj.length) == "undefined") {
			if (obj.value == value) {
				obj.checked = true;
			}
		}
		else {
			for(i=0; i<obj.length; i++) {
				if (obj[i].value == value) {
					obj[i].checked = true;
					break;
				}
			}
		}
	}
}

// Radio Disabled ¼³Á¤ÇÏ±â ##################################################
function setRadioDisabled(obj, value, disabled) {
	var i;

	if (obj) {
		if (typeof(obj.length) == "undefined") {
			if (obj.value == value) {
				obj.disabled = disabled;
			}
		}
		else {
			for(i=0; i<obj.length; i++) {
				if (obj[i].value == value) {
					obj[i].disabled = disabled;
					break;
				}
			}
		}
	}
}

// Form Disabled ÀüÃ¼ ¼³Á¤ÇÏ±â ##################################################
function setRadioDisabledAll(obj, disabled) {
	var i;

	if (obj) {
		if (typeof(obj.length) == "undefined") {
			obj.disabled = disabled;
		}
		else {
			for(i=0; i<obj.length; i++) {
				obj[i].disabled = disabled;
			}
		}
	}
}

// Select ¼³Á¤°ª °¡Á®¿À±â ##################################################
function getSelectVal(obj) {
	var value = "";
	var idx = obj.selectedIndex;

	if (idx >= 0){
		value = obj.options[idx].value;
	}

	return value;
}

// Select Option Ãß°¡ ##################################################
function selectAddList(obj, text, value) {
	var newOpt = document.createElement("OPTION");
	newOpt.text = text;
	newOpt.value = value;
	obj.options.add(newOpt);
}

// Select Option ÀüÃ¼»èÁ¦ ##################################################
function selectRemoveAll(obj) {
	for (var i=obj.length-1; i>=0; i--) {
		selectRemoveList(obj, i);
	}
}

// Select Option »èÁ¦ ##################################################
function selectRemoveList(obj, i) {
	obj.remove(i);
}

// Hidden Ãß°¡ ##################################################
function addHidden(f, name, value) {
	var input = document.createElement('INPUT');
	input.type = 'HIDDEN';
	input.name = name;
	input.value = value;
	f.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(str) {
    var re = /,/g;
    return str.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];
	}
}

// ³»¸² ##################################################
// num: ´ë»ó ¼ýÀÚ, pos: ´ë»ó ÀÚ¸®¼ö
function setFloor(num, pos) {
	if(!pos) pos = 0;
	return Math.floor(num * Math.pow(10, pos)) / Math.pow(10, pos);
}

// ¹Ý¿Ã¸² ##################################################
// 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 setCeil(num, pos) {
	if(!pos) pos = 0;
	return Math.ceil(num * Math.pow(10, pos)) / Math.pow(10, pos);
}

// °­Á¦ ¼Ò¼öÁ¡ ÀÌÇÏ 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 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(str) {
	var i, result;

	if (str == "0") return str;

	for (i = 0; i<str.length; i++) {
		if (str.substr(i,1) != "0") break;
	}

	result = str.substr(i, str.length-i);
	return result;
}

// ÅëÈ­ÇüÅÂ·Î º¯È¯ ##################################################
function toCurrency(obj) {
	if (obj.disabled) return false;

	var num = obj.value.stripspace();
	if (num == "") return false;

	if (!checkNum(stripComma(num))) {
		//alert ("¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
		num = stripCharFromNum(num, false);
		obj.blur(); obj.focus();
	}
	num = stripCharFromNum(stripComma(num), false);
	num = removePreZero(num);
	obj.value = formatComma(num);
}

// ¼ýÀÚÀÔ·Â È®ÀÎ ##################################################
function numberOnly(obj, isDec) {
	if (!isDec) isDec = false;
	if (obj.disabled) return false;

	var num = obj.value.stripspace();
	if (num == "") return false;

	if (!checkNum(num, isDec)) {
		//alert ("¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
		num = stripCharFromNum(num, isDec);
		obj.blur(); obj.focus();
	}
	num = stripCharFromNum(stripComma(num), isDec);

	var arrNum = num.split(".");
	if (arrNum.length > 1) {
		obj.value = arrNum[0]+"."+arrNum[1];
	}
	else {
		obj.value = arrNum[0];
	}
}

// ¼ýÀÚ Áõ°¨ Ã³¸® ##################################################
function controlNum(obj, mode, isminus) {
	var num = obj.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;

	obj.value = num;
}


// º£³Êµî·Ï ÀÌµ¿ ##################################################
function bannerorder(userid,dealkerid,bannerurl) {
	if (userid == "") {
		alert("·Î±×ÀÎ ÈÄ µî·Ï½ÅÃ»ÀÌ °¡´ÉÇÕ´Ï´Ù.");
        return false;
        }
    else if (dealkerid == "") {
		alert("ÀÔÁ¡½ÅÃ» ÈÄ µî·Ï½ÅÃ»ÀÌ °¡´ÉÇÕ´Ï´Ù.");
		return false;
		}
		location.href = '/mallinmall/ad/'+bannerurl;
	}

function popupmsg() {
	alert(" ÇöÀç´Â µî·Ï½ÅÃ»À» ÇÒ¼ö ¾ø½À´Ï´Ù \n\n µî·Ï½ÅÃ»Àº ¸¶ÄÉÆÃÆÀ°ú »ó´ãÇÏ½Ã±â ¹Ù¶ø´Ï´Ù. \n\n ´ã´ç : ¼ÛÁø¼® ÆÀÀå \n\n ¿¬¶ô : 1544-3375");
    return false;
}


// ¼¿·ºÆ®¹Ú½º ÀÌµ¿ ##################################################
function selectBoxView1(id)	{

	document.getElementById(id+'Sub').style.display = "block";
}

function selectBoxView(id)	{
	document.getElementById(id+'Sub').style.display = "block";
}


function setSelectInfo(key, name, value) {

		$(key+"_hd").value = value;
		$(key+"_span").innerText = name;
		$(key+"Sub").style.display = "none"
	}

function selectBoxHide(id)	{
	document.getElementById(id+'Sub').style.display = "none";
}	

function selectBoxHide1(id)	{
	document.getElementById(id+'Sub').style.display = "none";
}

 
function selboxResize(max, size, style) {

		max = Number(max)+6;  
		if (max > 10){
			if (max > 40) {
				$(style+"_span").style.width = 270+"px";
				$(style+"Sub").style.width = 280+"px";
			} else {
				$(style+"_span").style.width = (max*7)+20+"px";
				$(style+"Sub").style.width = (max*7)+20+"px";
			}
		}
	}


/**
 * ¼³¸í : °¡°ÝÇÊµå ÀÔ·Â°ªcheck [0-9][.][-]
 * @return boolean
 */
function isMNumber(){
	var lkeycode = window.event.keyCode;
	var sOrg = String.fromCharCode(lkeycode);
	
	if(!sOrg.match(/^[\d|\.\-]/))			// New Code
		window.event.keyCode = 0;
}


// ÄíÅ° ¼³Á¤ÇÏ±â ##################################################
function setCookie(name, value, expiredays) {
	var value = name+"="+escape(value)+"; path=/;";
	if (typeof(expiredays) != "undefined") {
		var todayDate = new Date();
		todayDate.setDate(todayDate.getDate()+expiredays);
		value += " expires="+todayDate.toGMTString()+";";
	}
	document.cookie = value;
}

// ÄíÅ° °¡Á®¿À±â ##################################################
function getCookie(name) {
	var strArg = new String(name + "=");
	var nArgLen, nCookieLen, nEnd;
	var i = 0, j;

	nArgLen = strArg.length;
	nCookieLen = document.cookie.length;

	if (nCookieLen > 0) {
		while (i < nCookieLen) {
			j = i + nArgLen;
			if (document.cookie.substring(i, j) == strArg) {
				nEnd = document.cookie.indexOf (";", j);
				if (nEnd == -1) nEnd = document.cookie.length;
				return unescape(document.cookie.substring(j, nEnd));
			}

			i = document.cookie.indexOf(" ", i) + 1;
			if (i == 0) break;
		}
	}
	return("");
}

