///////////////////////////////////////////////////////////////
// ±Ý¾× Æ÷¸Ë : commonNoNumKey, commonNoKorean¿Í °°ÀÌ »ç¿ë
// »ç¿ë¹ý :
// <input type="text" onkeypress='commonNoNumKey();' onKeyUp='commonMoneyFormat(this.value, this);commonNoKorean(this)'>
///////////////////////////////////////////////////////////////
function commonMoneyFormat(varValue, obj) {
    if (varValue.substring(0,1) == '0' ||  varValue== '') {
        varValue = varValue.substring(1, varValue.length);
        obj.value = '';
        return;
    }
    varValue = varValue.replace(/,/g , "");

    if(!isInteger(varValue)){
		alert("¼ýÀÚ¸¸ »ç¿ë°¡´ÉÇÕ´Ï´Ù.");
        obj.value = '';
        obj.focus();
		return ;
	}

    if (varValue.length <= 3) {
        obj.value = varValue.replace(/,/g , "");
        return;
    }else{
        var mod = varValue.length%3;
        var output = (mod == 0 ? '' : (varValue.substring(0,mod)));

        for (z=0 ; z < Math.floor(varValue.length/3) ; z++) {
            if ((mod ==0) && (z ==0)){
                output+= varValue.substring(mod+3*z,mod+3*z+3);
            }else{
                output+= ',' + varValue.substring(mod+3*z,mod+3*z+3);
            }
        }
       obj.value = output;
     }
}

///////////////////////////////////////////////////////////////
// Á¤¼öÀÎÁö ¾Æ´ÑÁö Ã¼Å©
///////////////////////////////////////////////////////////////
function isInteger(s) {
	if (s.length > 0) {
		sNum = s;
		for (i=0; i<sNum.length; i++) {
			if (sNum.charAt(i) < '0' || sNum.charAt(i) > '9') {
				return false;
			}
		}
		return true;
	} else {
		return false;
	}
}

///////////////////////////////////////////////////////////////
// ¼ýÀÚÅ°¸¦Á¦¿ÜÇÑ ³ª¸ÓÁö ¸ðµÎ false½ÃÅ²´Ù
///////////////////////////////////////////////////////////////
function commonNoNumKey(){
    var evCode = ( window.netscape ) ? ev.which : event.keyCode;
    if(evCode < 48 || evCode >57 ){
        event.returnValue=false;
        return ;
    }
}

///////////////////////////////////////////////////////////////
// ÇÑ±ÛÀÔ·Â¸·´Â½ºÅ©¸³
///////////////////////////////////////////////////////////////
function commonNoKorean( obj ){
    var i;
    var ch;
    var str = obj.value ;
    for (i=0;i<str.length;i++) {
	    ch = escape(str.charAt(i));
        if (common_strCharByte(ch) == 2) {
            alert("ÇÑ±ÛÀº ÀÔ·ÂÇÒ ¼ö ¾ø½À´Ï´Ù.");
            obj.value = "";
            obj.focus();
            return false;
        }
    }
}

///////////////////////////////////////////////////////////////
// ÇÑ±Û°Ë»ç
// Return   : 1-¿µ¹® 2-ÇÑ±Û
///////////////////////////////////////////////////////////////
function common_strCharByte(obj) {
    var y = "%u";
    var z = "%";

    if (obj == null)
        obj = "";

        if (obj.indexOf(y) != -1) {
            if (obj.substring(2,4) == '00') {
			    return 1;
            }else{
                return 2;        //ÇÑ±Û
            }
        }else if (obj.indexOf(z) != -1) {
            if (parseInt(obj.substring(1,3), 16) > 127) {
                return 2;        //ÇÑ±Û
        }else {
            return 1;
        }
    } else {
        return 1;
    }
}

///////////////////////////////////////////////////////////////
// µ·Çü½Ä ÀÚµ¿ ÇØÁ¦
///////////////////////////////////////////////////////////////
function commonDeleteComma(varValue)
{
	var str = varValue;
	var i;
	for(i = 0 ; i < str.length; i++){
		if( str.indexOf(",")!=-1){
			str = str.replace(',','')
		}
	}
	return str
}

///////////////////////////////////////////////////////////////
// ÇÑ±Û, ¿µ¹® byte°è»ê
///////////////////////////////////////////////////////////////
function getByteLength(s){
   var len = 0;
   if ( s == null ) return 0;
   for(var i=0;i<s.length;i++){
      var c = escape(s.charAt(i));
      if ( c.length == 1 ) len ++;
      else if ( c.indexOf("%u") != -1 ) len += 2;
      else if ( c.indexOf("%") != -1 ) len += c.length/3;
   }
   return len;
}


///////////////////////////////////////////////////////////////
// °¢ Row º° »ö±ò ¹ÝÀü
///////////////////////////////////////////////////////////////
function onRepOver(obj) {
    obj.style.backgroundColor="#ECF7FF";
}

function onRepOut(obj) {
    obj.style.backgroundColor="#FFFFFF";
}

////////////////////////////// ÆË¾÷Ã¢ ¶§¹®¿¡ Ãß°¡ÇÑ Æã¼Ç
// ÄíÅ°°¡ ÀÖ³ª Ã£½À´Ï´Ù
function getCookie( 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 "";
}

function setCookie( name, value, expiredays ) {
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// ÅÛÇÃ¸´ ³»ÀÇ ´Þ·ÂÃ¢ ³ª¿À´Â Æã¼Ç
//
function popCalendar(obj) {
    popFrame.fPopCalendar(obj,obj,obj,popCal,'2','DN');
    return false;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// ÅÛÇÃ¸´ ³»ÀÇ ´Þ·ÂÃ¢ ³ª¿À´Â Æã¼Ç
//
function onPicture(PAGE_SET, varImageUrl) {
    winopts ="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes,width=10,height=10,left=150,top=50";
    popWindow = window.open( '','SearchUserDelivery', winopts );
    popWindow.location = PAGE_SET + "/user/include/pop_image.jsp?strImageUrl="+escape(encodeURIComponent(varImageUrl));
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// textarea°ª <br>·Î ¸¸µå´Â Æã¼Ç
//
function enterMake(value) {
    var valueTemp = value.replace(/(\r\n)/g,"<BR>");
    return valueTemp;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// ´Ù¿î·ÎµåÇÏ´Â Æã¼Ç
//
function onDownLoad(PAGE_SET, varFileName, varPath) {
	location.href= PAGE_SET + "/user/include/download.jsp?fileName=" + escape(encodeURIComponent(varFileName)) + "&fileAttachPath=" + varPath;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Å×ÀÌºí ¸ðµç ROW »èÁ¦
//
function deleteAllRow(TAB) {
    //·Î¿ì °¹¼ö°¡ ÇÏ³ªÀÏ °æ¿ì
    if(TAB.rows.length == 1) {
      TAB.deleteRow();
    }else {
        var varRowCnt = TAB.rows.length;
        for(i=0;i<varRowCnt;i++) {
            TAB.deleteRow(TAB.rows.length-1);
        }
    }
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// Cross Browsing ¿£ÅÍ Ã¼Å©
//
function EnterCheck(ev) {
    var evCode = ( window.netscape ) ? ev.which : ev.keyCode;

    if(evCode ==13) {
        return true;
    }
    return false;
}
