/**
 * --------------------------------------------------------------
 * ÀÚ¹Ù½ºÅ©¸³Æ® °øÅëÇÔ¼ö
 * --------------------------------------------------------------
 * ÁÖÀÇ: ¾Æ·¡ÀÇ [1]¹ø ±×·ìÀÇ ¸Þ¼Òµå´Â ÀÔ·ÂÆûÀÇ ÇÊµå(form.field) °´Ã¼¸¦
 *       ÆÄ¶ó¹ÌÅÍ·Î ¹Þ´Â´Ù. ÇÊµåÀÇ °ª(form.field.value)ÀÌ ¾Æ´ÔÀ»
 *       À¯³äÇÒ °Í.
 * --------------------------------------------------------------
 * @version  1.2
 * @date     2002-10-28
 * @author   ¹ÚÁ¾Áø(JongJin Park), ecogeo@dreamwiz.com
 * @modifier ±è±ÇÀÏ(KwonIl Kim), kikim@ubizsystem.com
 * @modifier °­µ¿¿¬(DongYoun Kang), admin@jdevelop.co.kr
 * --------------------------------------------------------------
 * Copyright (c) 2000-2005 by LG-EDS Inc, Ubizsystem Inc, Olis.or.kr
 * All rights reserved.
 */

/****************************************************************
 * " aaaaaa ".trim() : ¹®ÀÚ¿­ °ø¹é Á¦°Å
 *
 * date   : 2007-01-03 by finkle
 ****************************************************************/
String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, "");
}














//Æ÷·³°ú ÀÏ¹Ý°Ô½ÃÆÇ »ó¼¼º¸±â ÀÌµ¿
function goMoveForumAndNormalBbsDetail(bbsId,bbsNum,bbsTypeCd) {
	if(bbsTypeCd=="002") {
		self.location.href= "bFrmDetail.do?bbsId=" + bbsId +"&bbsNum=" + bbsNum ;
	} else if(bbsTypeCd=="001") {
		self.location.href= "bDetail.do?bbsId=" + bbsId +"&bbsNum=" + bbsNum ;
	} else {
		alert("¿Ã¹Ù¸£Áö ¾ÊÀº °æ·ÎÀÔ´Ï´Ù.");
	}
}
//°Ë»öÀ§Á¬ ¹Ù·Î°¡±â
function goSrchUtilList() {
	self.location.href="/srchutl/srchutlWidget.do";//°Ë»öÀ§Á¬
}


//Æ÷·³°³¼³½ÅÃ»°¡±â
function goCreatForumList() {
	self.location.href="/osscomm/bList.do?bbsId=95&parentMenuCd=070000";
}

//³ªÀÇ ºí·Î±× ¹Ù·Î°¡±â .
function goBlog()
{
	var url="/moveBlog.do";
	var wi = "1024";
	var he = "768";
	window.open(url,'_blank','scrollbars=yes,status=yes,toolbar=0,resizable=no,location=0,menu=0,width='+wi+',height='+he);
}
//ºí·Î±×UrlÀÌµ¿ .
function goBlogMove(url)
{
	if(url==null || url=="" || url=="null") return;
	var wi = "1024";
	var he = "768";
	window.open(url,'_blank','scrollbars=yes,status=yes,toolbar=0,resizable=no,location=0,menu=0,width='+wi+',height='+he);
}
//ºí·Î±× »ó¼¼º¸±â ¹Ù·Î°¡±â .
function goBlogEntryView(handle, entryId)
{
	var url="http://blog.olis.or.kr/roller/"+handle;
	var wi = "1024";
	var he = "768";
	window.open(url,'_blank','scrollbars=yes,status=yes,toolbar=0,resizable=no,location=0,menu=0,width='+wi+',height='+he);
}


//Æ÷·³°Ô½Ã¹° ÅÂ±×
function forumBbsTag(key, bbsIdKey, tagName) {
	key = !key ? "" : key;
	bbsIdKey = !bbsIdKey ? "" : bbsIdKey;
	self.location.href="getTagBoardList.do?forumNum=" + key + "&bbsId="+bbsIdKey+ "&tagName="+tagName;
}
//Æ÷·³ ÅÂ±×
function forumTag(key, tagName) {
	key = !key ? "" : key;
	self.location.href="getTagBoardList.do?forumNum=" + key+ "&tagName="+tagName;
}

//Æ÷·³ÇüÀÌ ¾Æ´Ñ ÀÏ¹ÝÇü°Ô½Ã¹° ÅÂ±×
function notForumBbsTag(bbsIdKey, tagName) {
	bbsIdKey = !bbsIdKey ? "" : bbsIdKey;
	self.location.href="getTagBoardListNotForum.do?bbsId="+bbsIdKey+ "&tagName="+tagName;
}


//¹æ¹®±³À°½ÅÃ»°¡±â
function goEdu() {
	self.location.href="/edu/eduInsertForm.do";
}


/*-------------------------------------------------------------------------------
 * [1] ÀÔ·Â°ª Ã¼Å© ÇÔ¼ö
 *-------------------------------------------------------------------------------
 */


/****************************************************************
 * isExceedMax(form.field) : ÀÔ·Â°ªÀÇ ±æÀÌ°¡ ÀÔ·Â°´Ã¼ÀÇ ÃÖ´ë±æÀÌ¸¦ ³Ñ´ÂÁö È®ÀÎ
 * examples  :
 *
 * if( isExceedMax(form.field) ) {
 *     alert('ÀÔ·Â°ªÀ» ÃÊ°úÇß³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ÇØ´ç ÀÔ·Â°´Ã¼ÀÇ ÃÖ´ë±æÀÌ¸¦ ³ÑÀ¸¸é TURE
 * date   : 2002-10-28
 ****************************************************************/
function isExceedMax(input) {
    if(input.value.length <= input.maxLength ) {
        return false;
    }
    return true;
}


/****************************************************************
 * isNull(form.field) : ÀÔ·Â°ªÀÌ NULLÀÎÁö Ã¼Å©
 * examples  :
 *
 * if( isNull(form.field) ) {
 *     alert('ÀÔ·Â°ªÀÌ ¾ø³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ Null or °ªÀÌ ¾øÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isNull(input) {
    if (input.value == null || input.value == "") {
        return true;
    }
    return false;
}


/****************************************************************
 * isEmpty(form.field) : ÀÔ·Â°ªÀÌ ºñ¾îÀÖ´ÂÁö Ã¼Å©
 * examples  :
 *
 * if( isEmpty(form.field) ) {
 *     alert('ÀÔ·Â°ªÀÌ ¾ø³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ª¿¡ ¾Æ¹«°Íµµ ¾øÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isEmpty(input) {
    if (input.value == null || input.value.replace(/ /gi,"") == "") {
        return true;
    }
    return false;
}


/****************************************************************
 * toNotNullString(str) : ¹®ÀÚ¿­À» nullÀÌ ¾ø´Â ¹®ÀÚ¿­·Î ¹ÝÈ¯.
 * examples  :
 *
 * var value = toNotNullString(str);
 *
 * return : nullÀÌ ¾Æ´Ñ°æ¿ì ÇØ´ç °ª, nullÀÎ °æ¿ì ""
 * date   : 2007-05-29
 ****************************************************************/
function toNotNullString(str) {
    if (str == null) {
        return "";
    }
    return str;
}

/****************************************************************
 * containsChars(form.field, chars) :
 * ÀÔ·Â°ª¿¡ Æ¯Á¤ ¹®ÀÚ°¡ ÀÖ´ÂÁö Ã¼Å©
 * Æ¯Á¤ ¹®ÀÚ¸¦ Çã¿ëÇÏÁö ¾ÊÀ¸·Á ÇÒ ¶§ »ç¿ë
 * examples  :
 *
 * if( containsChars(form.field, "!,*&^%$#@~;") ) {
 *     alert('ÀÔ·Â°ª¿¡ Æ¯¼ö¹®ÀÚ°¡ Æ÷ÇÔµÇ¾ú³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ª¿¡ ÁöÁ¤ÇÑ Æ¯Á¤¹®ÀÚ°¡ ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function containsCharsCheck(chars) {

	var str = chars;
	
	for (var i=0; i < str .length; i++) { 
	    ch_char = str .charAt(i);
	    ch = ch_char.charCodeAt();
	        if( (ch >= 33 && ch <= 47) || (ch >= 58 && ch <= 64) || (ch >= 91 && ch <= 96) || (ch >= 123 && ch <= 126) ) {
	            //alert("Æ¯¼ö¹®ÀÚ¸¦ »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù");
	            return true;
	        }
	}
}


/****************************************************************
 * containsChars(form.field, chars) :
 * ÀÔ·Â°ª¿¡ Æ¯Á¤ ¹®ÀÚ°¡ ÀÖ´ÂÁö Ã¼Å©
 * Æ¯Á¤ ¹®ÀÚ¸¦ Çã¿ëÇÏÁö ¾ÊÀ¸·Á ÇÒ ¶§ »ç¿ë
 * examples  :
 *
 * if( containsChars(form.field, "!,*&^%$#@~;") ) {
 *     alert('ÀÔ·Â°ª¿¡ Æ¯¼ö¹®ÀÚ°¡ Æ÷ÇÔµÇ¾ú³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ª¿¡ ÁöÁ¤ÇÑ Æ¯Á¤¹®ÀÚ°¡ ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function containsChars(input, chars) {
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) != -1)
           return true;
    }
    return false;
}



/****************************************************************
 * containsCharsOnly(form.field, chars) :
 * ÀÔ·Â°ªÀÌ Æ¯Á¤ ¹®ÀÚ¸¸À¸·Î µÇ¾îÀÖ´ÂÁö Ã¼Å©
 * examples  :
 *
 * if( containsCharsOnly(form.field, "ABO") ) {
 *     alert('ÀÔ·Â°ªÀÌ A or B or O ¹®ÀÚ·Î¸¸ ±¸¼ºµÇ¾î ÀÖ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ÁöÁ¤ÇÑ Æ¯Á¤¹®ÀÚ·Î¸¸ µÇ¾î ÀÕÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function containsCharsOnly(input,chars) {
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) == -1)
           return false;
    }
    return true;
}


/****************************************************************
 * isAlphabet(form.field) : ÀÔ·Â°ªÀÌ ¾ËÆÄºªÀ¸·Î¸¸ µÇ¾î ÀÖ´ÂÁö Ã¼Å©
 * º» ÇÔ¼ö°¡ ÀÚÁÖ È£ÃâµÉ °æ¿ì¿¡´Â Ä³¸¯ÅÍ Áö¿ªº¯¼ö¸¦ Àü¿ªº¯¼ö·Î
 * »ç¿ëÇØµµ ÁÁ´Ù.
 * examples  :
 *
 * if( isAlphabet(form.field) ) {
 *     alert('ÀÔ·Â°ªÀÌ ¾ËÆÄºªÀ¸·Î¸¸ ±¸¼ºµÇ¾î ÀÖ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ¾ËÆÄºªÀ¸·Î¸¸ ÀÌ·ç¾îÁ® ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isAlphabet(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    return containsCharsOnly(input,chars);
}


/****************************************************************
 * isUpperCase(form.field) : ÀÔ·Â°ªÀÌ ¾ËÆÄºª ´ë¹®ÀÚ·Î¸¸ µÇ¾î ÀÖ´ÂÁö Ã¼Å©
 * º» ÇÔ¼ö°¡ ÀÚÁÖ È£ÃâµÉ °æ¿ì¿¡´Â Ä³¸¯ÅÍ Áö¿ªº¯¼ö¸¦ Àü¿ªº¯¼ö·Î
 * »ç¿ëÇØµµ ÁÁ´Ù.
 * examples  :
 *
 * if( isUpperCase(form.field) ) {
 *     alert('ÀÔ·Â°ªÀÌ ¾ËÆÄºª ´ë¹®ÀÚ·Î¸¸ ±¸¼ºµÇ¾î ÀÖ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ¾ËÆÄºª ´ë¹®ÀÚ·Î¸¸ ÀÌ·ç¾îÁ® ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isUpperCase(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    return containsCharsOnly(input, chars);
}


/****************************************************************
 * isLowerCase(form.field) : ÀÔ·Â°ªÀÌ ¾ËÆÄºª ¼Ò¹®ÀÚ·Î¸¸ µÇ¾î ÀÖ´ÂÁö Ã¼Å©
 * º» ÇÔ¼ö°¡ ÀÚÁÖ È£ÃâµÉ °æ¿ì¿¡´Â Ä³¸¯ÅÍ Áö¿ªº¯¼ö¸¦ Àü¿ªº¯¼ö·Î
 * »ç¿ëÇØµµ ÁÁ´Ù.
 * examples  :
 *
 * if( isLowerCase(form.field) ) {
 *     alert('ÀÔ·Â°ªÀÌ ¾ËÆÄºª ¼Ò¹®ÀÚ·Î¸¸ ±¸¼ºµÇ¾î ÀÖ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ¾ËÆÄºª ¼Ò¹®ÀÚ·Î¸¸ ÀÌ·ç¾îÁ® ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isLowerCase(input) {
    var chars = "abcdefghijklmnopqrstuvwxyz";
    return containsCharsOnly(input,chars);
}


/****************************************************************
 * isNumber(form.field) : ÀÔ·Â°ªÀÌ ¼ýÀÚ·Î¸¸ µÇ¾î ÀÖ´ÂÁö Ã¼Å©
 * º» ÇÔ¼ö°¡ ÀÚÁÖ È£ÃâµÉ °æ¿ì¿¡´Â ¼ýÀÚ Áö¿ªº¯¼ö¸¦ Àü¿ªº¯¼ö·Î
 * »ç¿ëÇØµµ ÁÁ´Ù.
 * examples  :
 *
 * if( isNumber(form.field) ) {
 *     alert('ÀÔ·Â°ªÀÌ ¼ýÀÚ·Î¸¸ ±¸¼ºµÇ¾î ÀÖ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ¼ýÀÚ·Î¸¸ ÀÌ·ç¾îÁ® ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isNumber(input) {
    var chars = "0123456789";
    return containsCharsOnly(input,chars);
}


/****************************************************************
 * isAlphaNum(form.field) : ÀÔ·Â°ªÀÌ ¾ËÆÄºª°ú ¼ýÀÚ·Î¸¸ µÇ¾î ÀÖ´ÂÁö Ã¼Å©
 * º» ÇÔ¼ö°¡ ÀÚÁÖ È£ÃâµÉ °æ¿ì¿¡´Â Ä³¸¯ÅÍ Áö¿ªº¯¼ö¸¦ Àü¿ªº¯¼ö·Î
 * »ç¿ëÇØµµ ÁÁ´Ù.
 * examples  :
 *
 * if( isAlphaNum(form.field) ) {
 *     alert('ÀÔ·Â°ªÀÌ ¾ËÆÄºª°ú ¼ýÀÚ·Î¸¸ ±¸¼ºµÇ¾î ÀÖ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ¾ËÆÄºª°ú ¼ýÀÚ·Î¸¸ ÀÌ·ç¾îÁ® ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isAlphaNum(input) {
    var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
    return containsCharsOnly(input,chars);
}


/****************************************************************
 * hasHangul(form.field) : ¹®ÀÚ¿­¿¡ ÇÑ±ÛÀÌ Æ÷ÇÔµÇ¾î ÀÖ´ÂÁö ¿©ºÎ Ã¼Å©
 * ÇöÀç ´Ü¼øÈ÷ asciiÄÚµå°¡ 255 º¸´Ù Å©¸é ÇÑ±ÛÀÌ Á¸ÀçÇÏ´Â °É·ç ¿©±è.
 * examples  :
 *
 * if( hasHangul(form.field) ) {
 *     alert('ÀÔ·Â°ª¿¡ ÇÑ±ÛÀÌ Æ÷ÇÔµÇ¾î ÀÖ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ª¿¡ ÇÑ±ÛÀÌ Æ÷ÇÔµÇ¾î ÀÖ´Ù¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function hasHangul(input) {
    var strParam = input.value;
    var i;
    for(i=0; i<strParam.length; i++) {
        if(strParam.charCodeAt(i) > 255) return true;
    }
    return false;
}


/****************************************************************
 * isNumDash(form.field) : ÀÔ·Â°ªÀÌ ¼ýÀÚ,´ë½Ã(-)·Î¸¸ µÇ¾îÀÖ´ÂÁö Ã¼Å©
 * º» ÇÔ¼ö°¡ ÀÚÁÖ È£ÃâµÉ °æ¿ì¿¡´Â Ä³¸¯ÅÍ Áö¿ªº¯¼ö¸¦ Àü¿ªº¯¼ö·Î
 * »ç¿ëÇØµµ ÁÁ´Ù.
 * examples  :
 *
 * if( isNumDash(form.field) ) {
 *     alert('ÀÔ·Â°ªÀÌ ¼ýÀÚ¿Í ´ë½Ã·Î¸¸ ±¸¼ºµÇ¾î ÀÖ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ¼ýÀÚ,´ë½Ã(-)·Î¸¸ ÀÌ·ç¾îÁ® ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isNumDash(input) {
    var chars = "-0123456789";
    return containsCharsOnly(input,chars);
}


/****************************************************************
 * isNumComma(form.field) : ÀÔ·Â°ªÀÌ ¼ýÀÚ,ÄÞ¸¶(,)·Î¸¸ µÇ¾îÀÖ´ÂÁö Ã¼Å©
 * º» ÇÔ¼ö°¡ ÀÚÁÖ È£ÃâµÉ °æ¿ì¿¡´Â Ä³¸¯ÅÍ Áö¿ªº¯¼ö¸¦ Àü¿ªº¯¼ö·Î
 * »ç¿ëÇØµµ ÁÁ´Ù.
 * examples  :
 *
 * if( isNumComma(form.field) ) {
 *     alert('ÀÔ·Â°ªÀÌ ¼ýÀÚ¿Í ÄÞ¸¶·Î¸¸ ±¸¼ºµÇ¾î ÀÖ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ¼ýÀÚ,ÄÞ¸¶(,) ÀÌ·ç¾îÁ® ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isNumComma(input) {
    var chars = ",0123456789";
    return containsCharsOnly(input,chars);
}


/****************************************************************
 * isNumComma(form.field) : ÀÔ·Â°ª¿¡¼­ ÄÞ¸¶¸¦ Á¦°ÅÇÑ´Ù.
 * °°Àº ¹æ¹ýÀ¸·Î ´Ù¾çÇÑ Ä³¸¯ÅÍ¿¡ ´ëÇÑ ÀÀ¿ëÀÌ °¡´ÉÇÏ´Ù.
 * examples  :
 *
 * var val = removeComma(form.field) : "2222,2222" -> 22222222
 *
 * return : ÀÔ·Â°ª¿¡¼­ ÄÞ¸¶(,)¸¦ Á¦°ÅÇÑ ¹®ÀÚ¿­.
 * date   : 2002-10-28
 ****************************************************************/
function removeComma(input) {
    return input.value.replace(/,/gi,"");
}



/****************************************************************
 * isNumComma(form.field, format) :
 * ÀÔ·Â°ªÀÌ »ç¿ëÀÚ°¡ Á¤ÀÇÇÑ Æ÷¸Ë Çü½ÄÀÎÁö Ã¼Å©
 * ÀÚ¼¼ÇÑ format Çü½ÄÀº ÀÚ¹Ù½ºÅ©¸³Æ®ÀÇ 'regular expression(Á¤±Ô½Ä)'À» ÂüÁ¶
 * Á¤±Ô½Ä¿¡ ´ëÇÑ ³»¿ëÀº °Ë»ö¿£ÁøÀ» ÅëÇØ Ã£¾Æº¸¸é ³ª¿È.
 * examples  :
 *
 * if (isValidFormat(form.field, "[xyz]")) {
 *        alert('x-z ±îÁöÀÇ ¹®ÀÚ°¡ Á¸ÀçÇÏ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ÁöÁ¤ÇÑ ¿Ã¹Ù¸¥ Æ÷¸ËÀ¸·Î µÇ¾î ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isValidFormat(input, format) {
    if (input.value.search(format) != -1) {
        return true;
    }
    return false;
}
function isValidFormatVal(inputVal, format) {
    if (inputVal.search(format) != -1) {
        return true;
    }
    return false;
}


/****************************************************************
 * isValidEmail(form.field) : ÀÔ·Â°ªÀÌ ÀÌ¸ÞÀÏ Çü½ÄÀÎÁö Ã¼Å©
 * examples  :
 *
 * if (isValidEmail(form.field)) {
 *        alert('ÀÔ·Â°ªÀÌ ÀÌ¸ÞÀÏ Çü½ÄÀÌ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ÀÌ¸ÞÀÏ Çü½ÄÀ¸·Î µÇ¾îÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isValidEmail(input) {
    /*--
    var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/;
    --*/
    var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
    return isValidFormat(input,format);
}
function isValidEmailVal(inputVal) {
    /*--
    var format = /^(\S+)@(\S+)\.([A-Za-z]+)$/;
    --*/
    var format = /^((\w|[\-\.])+)@((\w|[\-\.])+)\.([A-Za-z]+)$/;
    return isValidFormatVal(inputVal,format);
}



/****************************************************************
 * isValidPhone(form.field) : ÀÔ·Â°ªÀÌ ÀüÈ­¹øÈ£ Çü½Ä(¼ýÀÚ-¼ýÀÚ-¼ýÀÚ)ÀÎÁö Ã¼Å©
 * examples  :
 *
 * if (isValidPhone(form.field)) {
 *        alert('ÀÔ·Â°ªÀÌ ÀüÈ­¹øÈ£ Çü½ÄÀÌ³×¿ä.');
 * }
 *
 * return : ÀÔ·Â°ªÀÌ ÀüÈ­¹øÈ£ Çü½Ä(¼ýÀÚ-¼ýÀÚ-¼ýÀÚ)ÀÌ¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function isValidPhone(input) {
    var format = /^(\d+)-(\d+)-(\d+)$/;
    return isValidFormat(input,format);
}


/*-------------------------------------------------------------------------------
 * [2] Æû À¯Æ¿ ÇÔ¼ö
 *-------------------------------------------------------------------------------
 */


/****************************************************************
 * openWindow(url, name, width, height)
 * : ÁÖ¾îÁø °ª¿¡ µû¶ó »õÃ¢À» ¿ÀÇÂÇÑ´Ù. (È­¸é Áß¾Ó¿¡ À§Ä¡ÇÔ)
 *
 * @PARAM URL    WINDOWÀÇ URL
 * @PARAM NAME   WINDOWÀÇ ¸í
 * @PARAM WIDHT  WINDOWÆø (ÇÈ¼¿)
 * @PARAM HEIGHT WINDOW³ôÀÌ (ÇÈ¼¿)
 *
 * examples  :
 *
 * var win = openWindow("http://localhost/", localhost, 300, 300);
 *
 * return : ÇØ´ç À©µµ¿ì °´Ã¼.
 * date   : 2002-10-28
 ****************************************************************/
function openWindow(url, name, width, height)   {

    var top  = screen.height / 2 - height / 2 - 50;

    var left = screen.width / 2 - width / 2 ;

    var win =
        open(url,
            name,
            'width=' + width + ', height=' + height + ', top=' + top +
            ', left=' + left + ', resizable=no, status=yes, toolbar=no, menubar=no, scrollbars=auto');

    win.focus();

    return win;
}


function openWindowOpt(url, name, width, height, etcOpt)   {

    if (etcOpt.length > 0) {
        var top  = screen.height / 2 - height / 2 - 50;

        var left = screen.width / 2 - width / 2 ;

        var win =
            open(url,
                name,
                'width=' + width + ', height=' + height + ', top=' + top +
                ', left=' + left + ', resizable=no, status=yes, toolbar=no, menubar=no, ' + etcOpt);

        win.focus();

        return win;
    } else {
        return openWindow(url, name, width, height);
    }
}

function openWindowNoCenter(url, name, width, height, etcOpt)   {

    var win =
        open(url,
            name,
            'width=' + width + ', height=' + height + ', resizable=no, status=yes, toolbar=no, menubar=no, ' + etcOpt);

    win.focus();

    return win;
}

/****************************************************************
 * setFocusToFirstTextField(form) : ÆûÀÇ Ã¹¹øÂ° ÀÔ·Â ÅØ½ºÆ® ÇÊµå¿¡ Æ÷Ä¿½º¸¦ ÁÜ.
 * examples  :
 *
 * <body onLoad='setFocusToFirstTextField(form);'>
 *
 * return : ÀÇ¹Ì ¾øÀ½.
 * date   : 2002-10-28
 ****************************************************************/
function setFocusToFirstTextField(form) {

    if ( typeof form == 'undefined' ) return;  // if form is invalid, just return.

    var count = form.elements.length;

    for ( var i = 0; i < count; i++ ) {
        if ( form.elements[i].type == "text" || form.elements[i].type == "password" ) {
            form.elements[i].focus();
            return;
        }
    }
}


/****************************************************************
 * alertMsg(form.field) : ÁÖ¾îÁø ¹®ÀÚ¿­·Î °æ°íÃ¢À» ¶ç¿î µÚ ÀÔ·Â°´Ã¼¿¡ Æ÷Ä¿½º µÊ.
 * examples  :
 *
 * if (isValidPhone(form.field)) {
 *        alertMsg(form.field, 'ÀÔ·Â°ªÀÌ ÀüÈ­¹øÈ£ Çü½ÄÀÌ³×¿ä.');
 * }
 *
 * return : Ç×»ó False. -> ÀÇ¹Ì ¾øÀ½.
 * date   : 2002-10-28
 ****************************************************************/
function alertMsg( input, msg ) {
    alert( msg );
    input.focus();
    // input.select();
    return false;
}


/****************************************************************
 * getCheckedValues(form.field) : ¼±ÅÃµÈ Ã¼Å©¹Ú½ºÀÇ °ªÀ» ÁöÁ¤ ±¸ºÐÀÚ·Î ¿¬°áÇÏ¿© ¸®ÅÏ
 * examples  :
 *
 * var value = getCheckedValues(form.field, '|');
 *
 * return : ¼±ÅÃµÈ Ã¼Å©¹Ú½ºÀÇ ¹è¿­ Á¤º¸
 * date   : 2002-10-28
 ****************************************************************/
function getCheckedValues(input, sep) {

    if (sep == "")
        sep = "|";

    var fDels = "";
    if (input.length > 1) {
        for (var inx = 0; inx < input.length; inx++) {
            if (input[inx].checked) {
                fDels += input[inx].value + sep;
            }
        }
    } else {
        if (input.checked)
            fDels += input.value + sep;
    }

    return fDels.substring(0, fDels.length-1);
}

/****************************************************************
 * hasCheckedRadio(form.field) : ¼±ÅÃµÈ ¶óµð¿À¹öÆ°ÀÌ ÀÖ´ÂÁö Ã¼Å©
 * examples  :
 *
 * if (hasCheckedRadio(form.field)) {
 *        alert('¼±ÅÃµÈ ¶óµð¿À ¹öÆ°ÀÌ ÀÖ³×¿ä.');
 * }
 *
 * return : ¼±ÅÃµÈ ¶óµð¿À¹öÆ°ÀÌ ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function hasCheckedRadio(input) {
    if (input.length > 1) {
        for (var inx = 0; inx < input.length; inx++) {
            if (input[inx].checked) return true;
        }
    } else {
        if (input.checked) return true;
    }
    return false;
}


/****************************************************************
 * getCheckedRadio(form.field) : ¼±ÅÃµÈ ¶óµð¿À¹öÆ°ÀÇ °ªÀ» ¸®ÅÏ
 * examples  :
 *
 * var value = getCheckedRadio(form.field);
 *
 * return : ¼±ÅÃµÈ ¶óµð¿À¹öÆ°ÀÇ °ª
 * date   : 2002-10-28
 ****************************************************************/
function getCheckedRadio(input) {

    if (hasCheckedRadio(input)) {
        for (var inx = 0; inx < input.length; inx++) {
            if (input[inx].checked) return input[inx].value;
        }
    }
}


/****************************************************************
 * hasCheckedBox(form.field) : ¼±ÅÃµÈ Ã¼Å©¹Ú½º°¡ ÀÖ´ÂÁö Ã¼Å©
 * examples  :
 *
 * if (hasCheckedBox(form.field)) {
 *        alert('¼±ÅÃµÈ Ã¼Å©¹Ú½º°¡ ÀÖ³×¿ä.');
 * }
 *
 * return : ¼±ÅÃµÈ Ã¼Å©¹Ú½º°¡ ÀÖÀ¸¸é TRUE
 * date   : 2002-10-28
 ****************************************************************/
function hasCheckedBox(input) {
    return hasCheckedRadio(input);
}

/****************************************************************
 * hasSelectedIndex(form.field) : ¼±ÅÃµÈ ¼±ÅÃ¹Ú½ºÀÇ °ªÀÌ ÀÖ´ÂÁö Ã¼Å©
 *
 * return : ¼±ÅÃµÈ ¼±ÅÃ¹Ú½ºÀÇ °ªÀÌ ÀÖÀ¸¸é TRUE
 * date   : 2005-04-04
 ****************************************************************/
function hasSelectedIndex(input) {
    for (i=1 ; i < input.options.length ; i++) {
        if (input.options[i].selected == true) {
            return true;
        }
    }

    return false;
}

/****************************************************************
 * hasSelectedIndex(form.field) : ¼±ÅÃµÈ ¼±ÅÃ¹Ú½ºÀÇ °ªÀÌ ÀÖ´ÂÁö Ã¼Å©
 *
 * return : ¼±ÅÃµÈ ¼±ÅÃ¹Ú½ºÀÇ °ªÀÌ ÀÖÀ¸¸é TRUE
 * date   : 2005-04-04
 ****************************************************************/
function hasSelectedIndexValue(input) {
    if (input.value != '') {
        return true;
    }

    return false;
}

/****************************************************************
 * getSelectedValue(form.field) : ¼±ÅÃµÈ ¼±ÅÃ¹Ú½ºÀÇ °ªÀ» ¾ò´Â´Ù.
 * examples  :
 *
 * var value = getSelectedValue(form.field);
 *
 * return :  ¼±ÅÃµÈ ¼±ÅÃ¹Ú½ºÀÇ °ª.
 * date   : 2002-10-28
 ****************************************************************/
function getSelectedValue(input) {

    if ( input == null )
        return null;

    return input.options[input.selectedIndex].value;
}


/****************************************************************
 * getSelectedValue(form.field) : ¼±ÅÃµÈ ¼±ÅÃ¹Ú½ºÀÇ ÅØ½ºÆ®¸¦ ¾ò´Â´Ù.
 * examples  :
 *
 * var value = getSelectedText(form.field);
 *
 * return :  ¼±ÅÃµÈ ¼±ÅÃ¹Ú½ºÀÇ ÅØ½ºÆ®.
 * date   : 2002-10-28
 ****************************************************************/
function getSelectedText(input) {

    if ( input == null )
        return null;

    return input.options[input.selectedIndex].text;
}


/****************************************************************
 * getIndexByValue(form.field, value)
 *  : ÁöÁ¤ÇÑ °ª°ú ÀÏÄ¡ÇÏ´Â ¼±ÅÃ¹Ú½ºÀÇ ÀÎµ¦½º¸¦ ¾ò´Â´Ù.
 * examples  :
 *
 * var index = getIndexByValue(form.field, "°ª");
 *
 * return : ÁöÁ¤ÇÑ °ª°ú ÀÏÄ¡ÇÏ´Â ¼±ÅÃ¹Ú½ºÀÇ ÀÎµ¦½º. ¾øÀ¸¸é -1 ¸®ÅÏ.
 * date   : 2002-10-28
 ****************************************************************/
function getIndexByValue(input, value) {

    if ( input == null )
        return;

    for ( var i = 0; i < input.options.length; i++ ) {
        if ( input.options[i].value == value )
            return i;
    }
    return -1;  // not found.
}


/****************************************************************
 * removeOptionByValue(form.field, value)
 *  : ÁöÁ¤ÇÑ °ª°ú ÀÏÄ¡ÇÏ´Â ¼±ÅÃ¹Ú½ºÀÇ ÀÎµ¦½º¸¦ »èÁ¦ÇÑ´Ù.
 * examples  :
 *
 * if (removeOptionByValue(form.field, "°ª")) {
 *        alert('ÇØ´ç ÀÎµ¦½º°¡ »èÁ¦µÇ¾ú¾î¿ä.');
 * }
 *
 * return : ÇØ´ç ÀÎµ¦½º°¡ Áö¿öÁö¸é TRUE.
 * date   : 2002-10-28
 ****************************************************************/
function removeOptionByValue(input, value) {

    if ( input == null )
        return false;

    var index = getIndexByValue( input, value );
    var srcC = 0, destC = 0;

    if ( index == -1 ) return false; // not found

    // else value was found, shift all elemenets which are after index

    while ( srcC < input.options.length) {
        input.options[destC] = input.options[srcC];
        if ( srcC == index ) destC--;
        srcC++;
        destC++;
    }

    input.options.length -= 1;

    return true;
}


/****************************************************************
 * makeBlur(form.field)
 *  : °ªÀÌ ÀÔ·Â¾ÈµÇ°Ô ÇÏ±â
 * examples  :
 *
 * <input type=text onfocus = "MakeBlur(input)">
 *
 * return : ÇØ´ç¾øÀ½.
 * date   : 2002-10-28
 ****************************************************************/
function makeBlur(input) {
    input.blur();
}



/*-------------------------------------------------------------------------------
 * [3] ¹®ÀÚ¿­ °ü·Ã ÇÔ¼ö
 *-------------------------------------------------------------------------------
 */


/****************************************************************
 * removeToken(form.field, char) : ÁöÁ¤ÇÑ Ä³¸¯ÅÍ Á¦°ÅÇÏ±â.
 * examples  :
 *
 * form.field = '1111,11'ÀÏ °æ¿ì....
 * removeToken(form.field, ',');
 *        -> 1111,11 -> 111111
 *
 * return : ÀÔ·Â°ª¿¡¼­ ÁöÁ¤ÇÑ Ä³¸¯ÅÍ¸¦ Á¦°ÅÇÑ ¹®ÀÚ¿­.
 * date   : 2002-10-28
 ****************************************************************/
function removeToken(input, _char) {
    val = input.value;
    str = "";
    strr = val.split(_char);
    for (i=0 ; i < strr.length ; i++) {
        str += strr[i];
    }
    input.value = str;
}


/****************************************************************
 * getByteLength(form.field) : ÀÔ·Â°ªÀÇ ¹ÙÀÌÆ® ±æÀÌ¸¦ ¾ò´Â´Ù.
 * examples  :
 *
 * form.field = 'hiÇÑ±Û'ÀÏ °æ¿ì....
 * getByteLength(form.field); -> 6
 *
 * return : ÀÔ·Â°ªÀÇ ¹ÙÀÌÆ® ±æÀÌ (ÇÑ±ÛÀº 2Byte)
 * date   : 2002-10-28
 ****************************************************************/
function getByteLength(input) {
    var byteLength = 0;
    for (var inx = 0; inx < input.value.length; inx++) {
        var oneChar = escape(input.value.charAt(inx));
        if ( oneChar.length == 1 ) {
            byteLength ++;
        } else if (oneChar.indexOf("%u") != -1) {
            byteLength += 2;
        } else if (oneChar.indexOf("%") != -1) {
            byteLength += oneChar.length/3;
        }
    }
    return byteLength;
}


/****************************************************************
 * fillSpace(form.field, len, positionOfSpace)
 *    : ÀÔ·Â°ªÀÇ ¾ÕÀÌ³ª µÚ¿¡ ÃÑ ¹ÙÀÌÆ®°¡ ÁöÁ¤ÇÑ ±æÀÌ°¡ µÇµµ·Ï °ø¹éÀ» Ãß°¡ÇÑ´Ù.
 * examples  :
 *
 * form.field = 'hiÇÑ±Û'ÀÏ °æ¿ì....
 * fillSpace(form.field, 4, 'head') -> '    hiÇÑ±Û'
 * fillSpace(form.field, 4, 'tail') -> 'hiÇÑ±Û    '
 *
 * return : ÁöÁ¤ÇÑ ±æÀÌÀÇ °ø¹éÀÌ Ãß°¡µÈ »õ·Î¿î ¹®ÀÚ¿­
 * date   : 2002-10-28
 ****************************************************************/
function fillSpace(input, len, positionOfSpace) {
    var str = input.value;
    var newStr = input.value;

    if( positionOfSpace == "head" )
        for(var i=0;i<(len-str.length);i++)
            newStr = " " + newStr ;
    else
        for(var i=0;i<(len-str.length);i++)
            newStr = newStr + " ";

    return newStr;
}


/****************************************************************
 * replaceString(form.field, old, new)
 *  : ÀÔ·Â°ªÀÇ ¸ðµç ¹®ÀÚ¿­Áß¿¡¼­ old¸¦ new·Î ´ëÃ¼ÇÔ.
 * examples  :
 *
 * form.field = 'hahohi'ÀÏ °æ¿ì....
 * replaceString(form.field, 'ho','ÇÑ±Û') -> 'haÇÑ±Ûhi'
 *
 * return : ´ëÃ¼µÈ »õ·Î¿î ¹®ÀÚ¿­
 * date   : 2002-10-28
 ****************************************************************/
function replaceString(input, strOld, strNew) {

    var str = input.value;
    var index = 0;
    var oldLen = strOld.length;
    var newLen = strNew.length;
    var strPre = "";

    if( strOld == null || strOld == "") return str;

    while (true) {
        if ((index = str.indexOf(strOld)) != -1) {
            strPre= strPre + str.substring(0, index) + strNew;
            str = str.substring(index + oldLen);
        }
        else
            break;
    }
    return strPre + str;
}


/****************************************************************
 * trim(form.field)
 *  : ¹®ÀÚ¿­ ¾ÕµÚÀÇ °ø¹éÀ» Áö¿ò (' ', '\r', '\n', '\t')
 * examples  :
 *
 * form.field = ' haÇÑ±Û 'ÀÏ °æ¿ì....
 * trim(form.field) -> 'haÇÑ±Û'
 *
 * return : ´ëÃ¼µÈ »õ·Î¿î ¹®ÀÚ¿­
 * date   : 2002-10-28
 ****************************************************************/
function trim(input) {
    var str     = input.value;
    var len     = str.length;
    var iFrom    = 0;
    var iTo        = len;

    for(var i=0 ; i < len ; i++) {
        if( str.charAt(i) == ' ' || str.charAt(i) == '\r' || str.charAt(i) == '\n' || str.charAt(i) == '\t' )
            iFrom = i+1;
        else break;
    }
    for(var i=len-1 ; i > iFrom ; i--) {
        if( str.charAt(i) == ' ' || str.charAt(i) == '\r' || str.charAt(i) == '\n' || str.charAt(i) == '\t' )
            iTo = i;
        else break;
    }
    return str.substring(iFrom, iTo);
}


/****************************************************************
 * formatString(strParam, strFormat, cMark)
 *  : ÁöÁ¤ÇÑ ¹®ÀÚ¿­À» ÁöÁ¤ÇÑ Æ÷¸ËÀ¸·Î º¯È¯ÇÑ´Ù.
 * examples  :
 *
 * formatString("20010305", "4-2-2", '/') -> 2001/03/05
 * formatString("7011011101417", "6-7", '-') -> 701101-1101417
 *
 * return : Æ÷¸ËµÈ »õ·Î¿î ¹®ÀÚ¿­
 * date   : 2002-10-28
 ****************************************************************/
function formatString(strParam, strFormat, cMark) {
    var formatArray, strData, nLength, nCurPos;
    nLength = nCurPos = 0;
    strData = "";

    formatArray = strFormat.split("-");
    for(i=0; i < formatArray.length; i++) {
        nLength = parseInt(formatArray[i]);
        strData += strParam.substr(nCurPos, nLength);
        if(i < (formatArray.length-1)) strData += cMark;
        nCurPos += nLength;
    }
    return strData;
}


/****************************************************************
 * numFormat(form.field)
 *  : ÀÔ·Â°ªÀ» ±Ý¾×Ç¥½Ã·Î ÀüÈ¯
 * examples  :
 *
 * form.field = '99999'ÀÏ °æ¿ì....
 * numFormat(form.field) -> 99,999
 *
 * form.field = '-12345.001'ÀÏ °æ¿ì....
 * numFormat(form.field) -> -123,45.001
 *
 * return : ´ëÃ¼µÈ »õ·Î¿î ±Ý¾× ¹®ÀÚ¿­
 * date   : 2002-10-28
 ****************************************************************/
function numFormat(obj) {

    var str  = String(obj.value);
    var len  = str.length;
    var tmp  = "";
    var tm2  = "";

    /* ¼Ò¼öÁ¡ µÎ°³ ÀÌ»ó ¿¡·¯ Ç¥½Ã */
    count = 0;

    for( j=0 ; j < len ; j++) {
        if( obj.value.charAt(j) == '.') count++;
    }

    if (count > 1) {
        var text = "¼Ò¼öÁ¡ÀÌ µÑ ÀÌ»ó Æ÷ÇÔµÇ¾ú½À´Ï´Ù.";
        alert(text);
        obj.focus();
    }

    if (str.charAt(0) == '-') {
        tmp = '-' ;
        str = str.substring(1,len);
    }

    if (str.indexOf('-',0) != -1) {
        obj.focus();
        return;
    }

    if ((sit=str.indexOf('.',0)) != -1) {
        tm2 = str.substring(sit,len);
        str = str.substring(0,sit);
    }

    var i    = 0;

    while (str.charAt(i) == '0') i++;

    str = str.substring(i,len);
    len = str.length;

    if(len < 3) {
        obj.value = str;
        return;
    }
    else {
        var sit = len % 3;
        if (sit > 0) {
            tmp = tmp + str.substring(0,sit) + ',';
            len = len - sit;
        }

        while (len > 3) {
            tmp = tmp + str.substring(sit,sit+3) + ',';
            len = len - 3;
            sit = sit + 3;
        }

        tmp = tmp + str.substring(sit,sit+3) + tm2;
        obj.value = tmp;
    }
}



/*-------------------------------------------------------------------------------
 * [4] ÄíÅ° °ü·Ã ÇÔ¼ö
 *-------------------------------------------------------------------------------
 */


/****************************************************************
 * setCookie(name, value, expiredays)
 *  : ÁöÁ¤ÇÑ °ªÀ¸·Î ÄíÅ°¸¦ ¼³Á¤ÇÑ´Ù.
 * examples  :
 *
 * setCookie( "is_end", "done" , 1); -> ÄíÅ°º¸°üÀÏ : ÇÏ·ç
 *
 * return : ÇØ´ç ¾øÀ½.
 * date   : 2002-10-28
 ****************************************************************/
function setCookie(name, value, expiredays){
    var todayDate = new Date();
    todayDate.setDate( todayDate.getDate() + expiredays );
    document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}

/****************************************************************
 * getCookie(name)
 *  : ÁöÁ¤ÇÑ °ª¿¡ µû¸¥ ÄíÅ°¸¦ ¾ò´Â´Ù.
 * examples  :
 *
 * if (getCookie( "is_end" ) == "done") {
 *        alert('ÄíÅ°°¡ ¸¸·áµÇ¾ú½À´Ï´Ù.');
 * }
 *
 * examples  :
 * return : ÄíÅ°Á¤º¸ ¹®ÀÚ¿­.
 * date   : 2002-10-28
 ****************************************************************/
function getCookie(uName) {
    var flag = document.cookie.indexOf(uName+'=');
    if (flag != -1) {
        flag += uName.length + 1
        end = document.cookie.indexOf(';', flag)

        if (end == -1) end = document.cookie.length
        return unescape(document.cookie.substring(flag, end))
    }
}


/****************************************************************
 * isImage(name)
 *  : Ã·ºÎÆÄÀÏ Æ÷¸ËÀÌ ÀÌ¹ÌÁö Çü½ÄÀÎÁö È®ÀÎÇÑ´Ù.
 * examples  :
 *
 * if ( !isImage(name) ) {
 *        alert('ÀÌ¹ÌÁö Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.');
 * }
 *
 * examples  :
 * date   : 2004-02-26
 ****************************************************************/
function isImage(input) {

    var file = input.value;

    if (file != '') {
        var idx = file.lastIndexOf('.');
        file = file.substring(idx + 1).toLowerCase();

        if ( file == 'jpg' || file == 'jpeg' || file == 'gif' || file == 'png' || file == 'bmp' ) {
            return true;
        }
        else {
            return false;
        }
    }
    else {
        return true;
    }
}

/****************************************************************
 * checkFile(name)
 *  : Ã·ºÎÆÄÀÏ Æ÷¸ËÀÌ ¾÷·Îµå °¡´ÉÇÑ ÆÄÀÏ Çü½ÄÀÎÁö È®ÀÎÇÑ´Ù.
 * examples  :
 *
 * if ( !checkFile(name) ) {
 *        alert('¾÷·Îµå °¡´ÉÇÑ ÆÄÀÏ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.');
 * }
 *
 * examples  :
 * date   : 2008-09-24
 ****************************************************************/
function checkFile(input) {
    //ÃßÈÄ Ãß°¡ÇÒ È®ÀåÀÚ°¡ ÀÖÀ»°æ¿ì Ãß°¡ ÇÏ»ï!
    var fileExtension = {"jpg":true, "jpeg":true, "gif":true, "png":true, "bmp":true, "txt":true, "hwp":true, "doc":true, "xls":true, "pdf":true, "zip":true, "ppt":true};

    if (input.value != '') {
        var file = input.value;
        var idx = file.lastIndexOf('.');
        file = file.substring(idx + 1).toLowerCase();
        if(fileExtension[file]){
            return true;
        }else {
            return false;
        }
    }
    else {
        return true;
    }
}
/****************************************************************
 * checkFile(name)
 *  : Ã·ºÎÆÄÀÏ Æ÷¸ËÀÌ ¾÷·Îµå °¡´ÉÇÑ ÆÄÀÏ Çü½ÄÀÎÁö È®ÀÎÇÑ´Ù.
 * examples  :
 *
 * if ( !checkFile(name) ) {
 *        alert('¾÷·Îµå °¡´ÉÇÑ ÆÄÀÏ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.');
 * }
 *
 * examples  :
 * date   : 2008-09-24
 ****************************************************************/
function checkFileExe(input) {
    //ÃßÈÄ Ãß°¡ÇÒ È®ÀåÀÚ°¡ ÀÖÀ»°æ¿ì Ãß°¡ ÇÏ»ï! ¾îÇÃ¸®ÄÉÀÌ¼Ç(À§Á¬ ¼³Ä¡ÆÄÀÏ)
    var fileExtension = {"exe":true, "zip":true};

    if (input.value != '') {
        var file = input.value;
        var idx = file.lastIndexOf('.');
        file = file.substring(idx + 1).toLowerCase();
        if(fileExtension[file]){
            return true;
        }else {
            return false;
        }
    }
    else {
        return true;
    }
}
/****************************************************************
 * checkFile(name)
 *  : Ã·ºÎÆÄÀÏ Æ÷¸ËÀÌ ¾÷·Îµå °¡´ÉÇÑ ÆÄÀÏ Çü½ÄÀÎÁö È®ÀÎÇÑ´Ù.
 * examples  :
 *
 * if ( !checkFile(name) ) {
 *        alert('¾÷·Îµå °¡´ÉÇÑ ÆÄÀÏ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.');
 * }
 *
 * examples  :
 * date   : 2008-09-24
 ****************************************************************/
function checkFileImg(input) {
    //ÃßÈÄ Ãß°¡ÇÒ È®ÀåÀÚ°¡ ÀÖÀ»°æ¿ì Ãß°¡ ÇÏ»ï!
    var fileExtension = {"jpg":true, "jpeg":true, "gif":true, "png":true, "bmp":true};

    if (input.value != '') {
        var file = input.value;
        var idx = file.lastIndexOf('.');
        file = file.substring(idx + 1).toLowerCase();
        if(fileExtension[file]){
            return true;
        }else {
            return false;
        }
    }
    else {
        return true;
    }
}
/****************************************************************
 * isFlash(name)
 *  : Ã·ºÎÆÄÀÏ Æ÷¸ËÀÌ ÇÃ·¡½¬ Çü½ÄÀÎÁö È®ÀÎÇÑ´Ù.
 * examples  :
 *
 * if ( !isImage(name) ) {
 *        alert('ÇÃ·¡½¬ Çü½ÄÀÌ ¾Æ´Õ´Ï´Ù.');
 * }
 *
 * examples  :
 * date   : 2004-02-26
 ****************************************************************/
function isFlash(input) {

	var file = input.value;

	if (file != '') {
		var idx = file.lastIndexOf('.');
		file = file.substring(idx + 1).toLowerCase();

		if ( file == 'swf') {
			return true;
		}
		else {
			return false;
		}
	}
	else {
		return true;
	}
}


/****************************************************************
 * getlayer(name)
 *  : ºê¶ó¿ìÁ®¿¡ µû¸¥ ·¹ÀÌ¾î¸¦ ¾ò´Â´Ù.
 *
 * date   : 2005-11-17
 ****************************************************************/
function getlayer(name) {

    if (document.layers) { // NN
        pop = document.layers[name];
        pop_br=1;
    }
    else if(document.all) { // IE
        pop = document.all[name];
        pop_br=2;
    } else { // Standard
        pop = document.getElementById(name);
        pop_br=3;
    }
}

/****************************************************************
 * hiddenLayer(name)
 *  : ºê¶ó¿ìÁ®¿¡ µû¸¥ ·¹ÀÌ¾î¸¦ °¨Ãá´Ù.
 *
 * date   : 2005-11-17
 ****************************************************************/
function hiddenLayer(layers) {

    getlayer(layers);

    if (pop_br == 1) {
        pop.visibility='hidden';
    }
    else if (pop_br == 2) {
        pop.style.display='none';
    }
    else if (pop_br == 3) {
        pop.style.visibility='hidden';
    }
}

/****************************************************************
 * showLayer(name)
 *  : ºê¶ó¿ìÁ®¿¡ µû¸¥ ·¹ÀÌ¾î¸¦ Ç¥½ÃÇÑ´Ù.
 *
 * date   : 2005-11-17
 ****************************************************************/
function showLayer(layers) {

    getlayer(layers);

    if (pop_br == 1) {
        pop.visibility = 'visible';
        pop.left = window.innerWidth/2-pop.width.replace("px","")/2;
        pop.top = window.innerHeight/2-pop.height.replace("px","")/2;
    }
    else if (pop_br == 2) {
        pop.style.visibility = 'visible';
        pop.style.left = document.body.scrollLeft+document.body.offsetWidth/2-pop.style.width.replace("px","")/2;
        pop.style.top = document.body.scrollTop+document.body.offsetHeight/2-pop.style.height.replace("px","")/2;
    }
    else if (pop_br == 3) {
        pop.style.visibility = 'visible';
        pop.style.left=document.body.offsetWidth/2-pop.style.width.replace("px","")/2;
        pop.style.top=document.body.offsetHeight/2-pop.style.height.replace("px","")/2;
    }
}

/****************************************************************
 * jsResize(obj)
 *  : iFrame ¸®»çÀÌÁî
 *
 * date   : 2005-11-21
 ****************************************************************/
function jsResize(obj) {

    // document.getElementById("iFresize").style.height = document.getElementById("foaFrame").offsetHeight;
    // document.getElementById("iFresize").style.width = document.getElementById("foaFrame").offsetWidth;
    // alert(obj.contentWindow);

    var Body;
    var H, Min;
    Min = 100;
    // alert( document.getElementById("iFresize").offsetHeight );
    // alert(obj.contentWindow+'\n'+ obj.contentWindow.document+'\n'+ obj.contentWindow.document.getElementsByTagName('BODY'));
    Body = (obj.contentWindow.document.getElementsByTagName('BODY'))[0];

    H = parseInt(Body.scrollHeight) + 5;
    obj.style.height = (H<Min?Min:H) + 'px';

    // alert(Body.scrollHeight +'\n'+ H +'\n'+ obj.style.height);

    window.scrollTo(1, 1);
}


/****************************************************************
 * jsShowDatePicker(obj)
 *  : ´Þ·Â ³¯Â¥¼±ÅÃ ¸ð´ÞÃ¢
 *
 * date   : 2005-11-21
 ****************************************************************/
function jsShowDatePicker(obj) {
    window.showModalDialog("/v2/inc/commons/datePicker.html", obj,
        "dialogWidth=236px;dialogHeight=224px;resizable=no;status=no;help=no");
}

/****************************************************************
 * hasHangulName(obj)
 *  : ¾÷·Îµå ÆÄÀÏ ÀÌ¸§¿¡ ÇÑ±ÛÀÌ Æ÷ÇÔµÇ¾ú´ÂÁö ¿©ºÎ
 *
 * date   : 2005-11-21
 ****************************************************************/
function hasHangulName(obj) {

    var fileName = obj.value;
    var idx = fileName.lastIndexOf('\\');
    fileName = fileName.substring(idx + 1);

    var i;
    for(i=0; i<fileName.length; i++) {
        if(fileName.charCodeAt(i) > 255) return true;
    }
    return false;
}

/****************************************************************
 * jsToggleMenu(obj)
 *  : xmlMenu.js¸¦ ´ëÃ¼ÇÏ´Â ÀÎÆ®¶ó³Ý ÁÂÃø ¸Þ´º °ü·Ã ½ºÅ©¸³Æ®
 *
 * date   : 2005-11-25
 ****************************************************************/
function jsToggleMenu(currMenu) {
    var subMenu = document.getElementById(currMenu);
    if (subMenu != null) {
        if (subMenu.style.display == 'none') {
            subMenu.style.display = 'block';
        }
        else {
            subMenu.style.display = 'none';
        }
    }
}

/****************************************************************
 * jsProcess()
 *  : ¿äÃ»À» Á¦ÃâÇÏ´Â µ¿¾È ÀÌ¹ÌÁö Ç¥½Ã
 *
 * <span id='upload' style='display:block'>
 * ....
 * <span id='tranimg' style='display:none'>
 *     <img src="$CTX_ROOT/resource/images/processing.gif">
 * ....
 *
 * date   : 2005-11-25
 ****************************************************************/
function jsProcess() {
    try {
        document.getElementById('submitBt').style.display  = 'none';
        document.getElementById('processBt').style.display = 'block';
    }
    catch (Exception) {
    }
}
function jsProcessOpt(hdnVal, shwVal) {
    try {
        document.getElementById(hdnVal).style.display  = 'none';
        document.getElementById(shwVal).style.display = 'block';
    }
    catch (Exception) {
    }
}

/****************************************************************
 * jsTextAreaResize()
 *  : TextAreaÇÊµå ¸®»çÀÌÁî
 *
 * date   : 2006-08-11
 ****************************************************************/
function jsTextAreaResize(que, elementName) {
    var area = document.getElementById(elementName);
    if (que == '-') {
        if ( area.rows != 8 ) {
            area.rows = area.rows - 4;
        }
    }
    else if (que == '+') {
        area.rows = area.rows + 4;
    }
    else {
        area.rows = 8;
    }

    jsResize( this.parent.document.getElementById('detailFrame') );
}

/****************************************************************
 * Browser()
 *  : ºê¶ó¿ìÀú ÆÇ´Ü
 *
 * date   : 2006-12-27
 ****************************************************************/
 function Browser() {

    var ua, s, i;

    this.isIE    = false;
    this.isNS    = false;
    this.version = null;

    ua = navigator.userAgent;

    s = "MSIE";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isIE = true;
        this.version = parseFloat(ua.substr(i + s.length));
        return;
    }

    s = "Netscape6/";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isNS = true;
        this.version = parseFloat(ua.substr(i + s.length));
        return;
    }

    // Treat any other "Gecko" browser as NS 6.1.
    s = "Gecko";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isNS = true;
        this.version = 6.1;
        return;
    }
}
var browser = new Browser();

/****************************************************************
 * getIframeDocument()
 *  : iframeÀÇ document °´Ã¼¸¦ ¹ÝÈ¯
 *
 * date   : 2006-12-27
 ****************************************************************/
function getIframeDocument(iframeId, useTop) {

    var iframe = null;
    if (useTop) {
        iframe = window.top.document.getElementById(iframeId);
    } else {
        iframe = document.getElementById(iframeId);
    }

    var contentDocument = null;

    if (iframe.contentDocument != null) { // FF(NS), W3C Ç¥ÁØÀ¸·Î ÃßÁ¤
        contentDocument = iframe.contentDocument;
    } else if (iframe.contentWindow != null) { // IE
        contentDocument = iframe.contentWindow.document;
    } else if (iframe.document != null) { // ¿¾³¯ IE
        contentDocument = iframe.document;
    }

    return contentDocument;
}







/**
* <pre>
 * ¼ýÀÚ³ª ¹®ÀÚ¿­À» ÅëÈ­(Money) Çü½ÄÀ¸·Î ¸¸µç´Ù.
 * ´Ü, ¾ç¼ö¸¸ Çã¿ëÇÑ´Ù.
 * &lt;input type="text" name="test" value="" onkeyup="this.value=toCurrencyPositive(this.value);"&gt;
 * or
 * var num = toCurrency(document.form[0].text.value);
 * </pre>
 * @param	amount	"1234567"
 * @return	currencyString "1,234,567"
 * @see #toCurrency(amount)
 */
function toCurrencyPositive(amount){
    var firstChar = amount.substr(0,1);
    if(firstChar == "-"){
        amount = amount.substring(1, amount.length);
    }
    return toCurrency(amount);
}


function toCurrency(amount){
var data = amount.split('.');
    var sign = "";

    var firstChar = data[0].substr(0,1);
    if(firstChar == "-"){
        sign = firstChar;
        data[0] = data[0].substring(1, data[0].length);
    }

    data[0] = data[0].replace(/\D/g,"");
    if(data.length > 1){
        data[1] = data[1].replace(/\D/g,"");
    }

    firstChar = data[0].substr(0,1);

    //0À¸·Î ½ÃÀÛÇÏ´Â ¼ýÀÚµé Ã³¸®
    if(firstChar == "0"){
        if(data.length == 1){
            return sign + parseFloat(data[0]);
        }
    }

    var comma = new RegExp('([0-9])([0-9][0-9][0-9][,.])');

    data[0] += '.';
    do {
        data[0] = data[0].replace(comma, '$1,$2');
    } while (comma.test(data[0]));

    if (data.length > 1) {
        return sign + data.join('');
    } else {
        return sign + data[0].split('.')[0];
    }
}


/**
 * ÁÖ¾îÁø °ª(val)À» ¼Ò¼öÁ¡ÀÌÇÏ numÀÚ¸®¼ö¿¡¼­ ¹Ý¿Ã¸²ÇÑ°ªÀ» ¸®ÅÏ
 *
 * @param val ¹Ý¿Ã¸²ÇÒ °ª
 * @param num ¹Ý¿Ã¸²ÇÒ ÀÚ¸®¼ö
 * @return number
 */
function round(val, num){
    val = val * Math.pow(10, num - 1);
    val = Math.round(val);
    val = val / Math.pow(10, num - 1);
    return val;
}

/**
 * ,ÀÌ ÀÖ´Â ¼ýÀÚ¸¦ ¼ø¼öÇÑ ¼ýÀÚ·Î ¹Ù²ãÁØ´Ù. (+), (-) Çã¿ë
 *
 * @param num
 * @return number
 */
function toNormalNum( num ) {
    num = num.replace(/,/g, '');
    var args = Number(num);
    return args;
}


/**
 * ÀÌ¹ÌÁö ÅøÆÁ
 *
 * @param
 * @return
 */

// ÅøÆÁ Ãâ·Â(nn4+, ie4+)
function jsShowImg(sub_id, opt, evt) {
    var plus_left, plus_top;
        plus_left = 9;
        plus_top = 19;

        if(document.all || document.getElementById) {
            if(document.all) {
                obj = document.all[sub_id];
                if(opt == "") {
                    var x_pos = evt.clientX + document.body.scrollLeft + plus_left;
                    x_pos = ((document.body.clientWidth - (x_pos + 240 + plus_left) < 0)) ? (document.body.clientWidth - (240 + plus_left)) : x_pos;
                    obj.style.pixelLeft = event.clientX + 10; //x_pos;
                    obj.style.pixelTop = event.clientY + 0; //evt.clientY + document.body.scrollTop + plus_top;

                }
            }
            else {
                      obj = document.getElementById(sub_id);
                    if(opt == "") {
                        var x_pos = evt.clientX + window.scrollX + plus_left;
                        x_pos = ((self.innerWidth - (x_pos + 240 + plus_left) < 0)) ?
                            (document.body.clientWidth - (240 + plus_left)) : x_pos;
                        obj.style.left = x_pos;
                        obj.style.top = evt.clientY + window.scrollY + plus_top;
                    }
                }
                obj.style.display = "block";
            }
            else{
                obj = document.layers[sub_id];
                obj.display = "block";
                if(opt == "") {
                    obj.left = evt.pageX + plus_left;
                    obj.top = evt.pageY + plus_top;
                }
            }
 }

// ÅøÆÁ ¼û±â±â(nn4+, ie4+)
function jsHideImg(sub_id) {
    if(document.all || document.getElementById) {
        if(document.all) {
            obj = document.all[sub_id];
        }
        else {
            obj = document.getElementById(sub_id);
        }

            obj.style.display = "none";
        }
    else{
         obj = document.layers[sub_id];
         obj.display = "none";
    }
}

/**
 * form ÀÇ elNm¿¡ ÇØ´çÇÏ´Â ±¸¼º¿ä¼Ò¸¦ ¹è¿­·Î ¹ÝÈ¯ÇÑ´Ù.<br />
 * document.forms[formNm].elements[elNm]<br />
 * °°ÀºÀÌ¸§ÀÇ ±¸¼º¿ä¼Ò°¡ ¿©·¯°³ ÀÖÀ»¶© ¿ø·¡ ¹è¿­·Î ¹ÝÈ¯ÇÏÁö¸¸ ÇÏ³ª°¡ ÀÖÀ»¶© ¹è¿­ÀÌ ¾Æ´Ï´Ù.<br />
 * ¸ñ·Ïµî¿¡¼­ ÀÚ·á°¡ ¿©·¯°³ÀÏ¼öµµ ÀÖ°í ÇÏ³ªÀÏ¼öµµ ÀÖ´Â ±×·±°æ¿ì »ç¿ë. ¸ñ·Ï Ã¼Å©¹Ú½ºµî
 *
 * @param formNm (ÇÊ¼ö) document³»ÀÇ form name attribute
 * @param elNm (ÇÊ¼ö) form ³»ÀÇ element name attribute
 * @return Array (not null, empty is length == 0)
 */
function jsGetFormElArray(formNm, elNm) {

    var formElArr = new Array();

    var el = document.forms[formNm].elements[elNm];
    if (el != null) {
        var length = el.length;
        if (typeof length == "number") {
            for (var i = 0; i < length; i++) {
                formElArr[formElArr.length] = el[i];
            }
        } else {
            formElArr[formElArr.length] = el;
        }
    }

    return formElArr;
}

/**
 * ÀÔ·ÂÇÊµåÀÇ ÀÔ·Â°ª ±æÀÌ°¡ ÁöÁ¤ÇÑ ±æÀÌ°¡ µÇ¸é ´ÙÀ½ ÀÔ·ÂÇÊµå·Î Æ÷Ä¿½º¸¦ ÀÌµ¿ÇÑ´Ù.
 *
 * @param num (ÇÊ¼ö) ¹®ÀÚ¿­ ±æÀÌ
 * @param fromform (ÇÊ¼ö) ÀÔ·ÂÇÊµå
 * @param toform (ÇÊ¼ö) ´ÙÀ½ ÀÔ·ÂÇÊµå
 */
function moveFocus(num,fromform,toform)
{
    var str = fromform.value.length;
    if(str == num)
    toform.focus();
}

/**
 * ÄÞº¸¹Ú½º ÇüÅÂÀÇ ³¯Â¥ ÇÊµå¿¡ ¿À´Ã ³¯Â¥·Î ¼¼ÆÃÇÑ´Ù.
 *
 * @param yearObj (ÇÊ¼ö) ³âµµ ÇÊµå
 * @param monthObj (ÇÊ¼ö) ¿ù ÇÊµå
 * @param dayObj (ÇÊ¼ö) ÀÏ ÇÊµå
 */
function setToDaySelectDate(yearObj, monthObj, dayObj) {

        var now = new Date();
        var nowyear  = now.getFullYear();
        var nowmonth = now.getMonth() + 1;
        var nowday   = now.getDate();

        if (yearObj) yearObj.value=nowyear;
        if (monthObj) monthObj.value=nowmonth;
        if (dayObj) dayObj.value=nowday;

}


function showLayer(id) {
    var divObj = document.getElementById(id);

    if (divObj.style.visibility == "hidden")
        divObj.style.visibility="visible" ;
    if (divObj.style.display == "none")
        divObj.style.display = "block";
    return true;
}

function hideLayer(id) {
    var divObj = document.getElementById(id);

    if (divObj.style.visibility == "visible")
        divObj.style.visibility="hidden" ;
    if (divObj.style.display == "" || divObj.style.display == "block")
        divObj.style.display = "none";
    return true;
}
/*
 * ÆË¾÷ ÀÚµ¿ ¸®»çÀÌÂ¡ bokjinet ¿ë¿ø
 *  - À©µµ È¯°æ¿¡ µû¶ó »çÀÌÁî°¡ ´Ù¸¦ ¼ö ÀÖ½À´Ï´Ù.
 *  - ÆË¾÷ÆäÀÌÁöÀÇ ½ºÅ©¸³Æ® ÃÖÇÏ´Ü¿¡¼­ ½ÇÇàÇÏ½Ê½Ã¿À.
*/
function popupAutoResize() {
    var thisX = parseInt(document.body.scrollWidth);
    var thisY = parseInt(document.body.scrollHeight);
    var maxThisX = screen.width - 50;
    var maxThisY = screen.height - 50;
    var marginY = 0;
    //alert(thisX + "===" + thisY);
    //alert("ÀÓ½Ã ºê¶ó¿ìÀú È®ÀÎ : " + navigator.userAgent);
    // ºê¶ó¿ìÀúº° ³ôÀÌ Á¶Àý. (Ç¥ÁØ Ã¢ ÇÏ¿¡¼­ Á¶ÀýÇØ ÁÖ½Ê½Ã¿À.)
    if (navigator.userAgent.indexOf("MSIE 6") > 0) marginY = 45;        // IE 6.x
    else if(navigator.userAgent.indexOf("MSIE 7") > 0) marginY = 75;    // IE 7.x
    else if(navigator.userAgent.indexOf("Firefox") > 0) marginY = 50;   // FF
    else if(navigator.userAgent.indexOf("Opera") > 0) marginY = 30;     // Opera
    else if(navigator.userAgent.indexOf("Netscape") > 0) marginY = -2;  // Netscape

    if (thisX > maxThisX) {
        window.document.body.scroll = "yes";
        thisX = maxThisX;
    }
    if (thisY > maxThisY - marginY) {
        window.document.body.scroll = "yes";
        thisX += 19;
        thisY = maxThisY - marginY;
    }
    window.resizeTo(thisX+10, thisY+marginY);

    // ¼¾ÅÍ Á¤·Ä
    // var windowX = (screen.width - (thisX+10))/2;
    // var windowY = (screen.height - (thisY+marginY))/2 - 20;
    // window.moveTo(windowX,windowY);
}

/****************************************************************
 * isNullObj(form.field) : ÇØ´ç ¿ÀºêÁ§Æ®°¡ NULLÀÎÁö Ã¼Å©
 * return : ÇØ´ç¿ÀºêÁ§Æ®°¡ Null ÀÌ¸é true
 * date   : 2006-02-02
 * author : ±èÁø¿À
 ****************************************************************/
function isNullObj(obj) {
    if (obj == null || obj == "undefined") {
        return true;
    }
    return false;
}

//
/****************************************************************
 * allChkEsentialValue(obj, chkVal, msg1, msg2)
 *  : ÇÊ¼öÇ×¸ñ Ã¼Å©
 * examples  :
 *
 *		if (!allChkEsentialValue(frm.elements["userBean.userId"], '', 'È¸¿ø¾ÆÀÌµð¸¦', '')) {
 *			return false;
 *		}
 *
 * return : true | false
 * date   : 2008-08-01
 ****************************************************************/
function allChkEsentialValue(obj, chkVal, msg1, msg2) {

    if (obj.type == "text" || obj.type == "textarea" || obj.type == "password") {

        obj.value = obj.value.trim();

        if (obj.value == "" || obj.value == chkVal) {
            if (msg1 == "") {
                alert(msg2);
            } else {
                alert(msg1 + " ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
            }
            obj.focus();
            return false;
        }
    } else if (obj.type == "select-one") {
        if (obj.options.value == "" || obj.options.value == chkVal) {
            if (msg1 == "") {
                alert(msg2);
            } else {
                alert(msg1 + " ¼±ÅÃÇØ ÁÖ¼¼¿ä.");
            }
            obj.focus();
            return false;
        }
    } else if (obj.type=="checkbox") {
        if (obj.checked == false || obj.checked == chkVal) {
            if (msg1 == "") {
                alert(msg2);
            } else {
                alert(msg1 + " Ã¼Å©ÇØ ÁÖ¼¼¿ä.");
            }
            obj.focus();
            return false;
        }
    } else if (obj.type="radio") {
        var bChecked = false;
        for (var i = 0; i < obj.length; i++) {
            if (obj[i].checked == true) {
                bChecked = true;
            }
        }
        if (bChecked == false) {
            if (msg1 == "") {
                alert(msg2);
            } else {
                alert(msg1 + " Ã¼Å©ÇØ ÁÖ¼¼¿ä.");
            }
            obj[0].focus();
            return false;
        }
    }

    return true;
}

function checkNumber() {
    var key = String.fromCharCode(event.keyCode);
    var re = new RegExp('[0-9]');

    if(!re.test(key)) {
        event.returnValue = false;
    }
}

function encode_base64( what )
{
      var base64_encodetable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
      var result = "";
      var len = what.length;
      var x, y;
      var ptr = 0;

      while( len-- > 0 )
      {
            x = what.charCodeAt( ptr++ );
            result += base64_encodetable.charAt( ( x >> 2 ) & 63 );

            if( len-- <= 0 )
            {
                  result += base64_encodetable.charAt( ( x << 4 ) & 63 );
                  result += "==";
                  break;
            }

            y = what.charCodeAt( ptr++ );
            result += base64_encodetable.charAt( ( ( x << 4 ) | ( ( y >> 4 ) & 15 ) ) & 63 );

            if ( len-- <= 0 )
            {
                  result += base64_encodetable.charAt( ( y << 2 ) & 63 );
                  result += "=";
                  break;
            }

            x = what.charCodeAt( ptr++ );
            result += base64_encodetable.charAt( ( ( y << 2 ) | ( ( x >> 6 ) & 3 ) ) & 63 );
            result += base64_encodetable.charAt( x & 63 );

      }

      return result;
}


function decode_base64( what )
{
      var base64_decodetable = new Array (
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
            255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,  62, 255, 255, 255,  63,
            52,  53,  54,  55,  56,  57,  58,  59,  60,  61, 255, 255, 255, 255, 255, 255,
            255,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10,  11,  12,  13,  14,
            15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25, 255, 255, 255, 255, 255,
            255,  26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,
            41,  42,  43,  44,  45,  46,  47,  48,  49,  50,  51, 255, 255, 255, 255, 255
      );
      var result = "";
      var len = what.length;
      var x, y;
      var ptr = 0;

      while( !isNaN( x = what.charCodeAt( ptr++ ) ) )
      {
            if( x == 13 || x == 10 )
                  continue;

            if( ( x > 127 ) || (( x = base64_decodetable[x] ) == 255) )
                  return false;
            if( ( isNaN( y = what.charCodeAt( ptr++ ) ) ) || (( y = base64_decodetable[y] ) == 255) )
                  return false;

            result += String.fromCharCode( (x << 2) | (y >> 4) );

            if( (x = what.charCodeAt( ptr++ )) == 61 )
            {
                  if( (what.charCodeAt( ptr++ ) != 61) || (!isNaN(what.charCodeAt( ptr ) ) ) )
                        return false;
            }
            else
            {
                  if( ( x > 127 ) || (( x = base64_decodetable[x] ) == 255) )
                        return false;
                  result += String.fromCharCode( (y << 4) | (x >> 2) );
                  if( (y = what.charCodeAt( ptr++ )) == 61 )
                  {
                        if( !isNaN(what.charCodeAt( ptr ) ) )
                              return false;
                  }
                  else
                  {
                        if( (y > 127) || ((y = base64_decodetable[y]) == 255) )
                              return false;
                        result += String.fromCharCode( (x << 6) | y );
                  }
            }
      }
      return result;
}
//¼ýÀÚ¸¸ ÀÔ·Â
// onkeydown='handlerNum(this)'
//¨ç ÀÔ·ÂÇÊµå¿¡ ¼ýÀÚÅ°, »èÁ¦Å°, ¹æÇâÅ°, ÅÇÅ°, È¨, ¿£µåÅ° ¸¸ ÀÔ·ÂÇÒ¼ö ÀÖÀ½.
function handlerNum( obj ) {
//¼ýÀÚ¸¸ ÀÔ·Â ¹Þ°Ô²û ÇÏ´Â ÇÔ¼ö.
 e = window.event; //À©µµ¿ìÀÇ event¸¦ Àâ´Â°ÍÀÔ´Ï´Ù.
// alert(e.keyCode);

  //ÀÔ·Â Çã¿ë Å°
 if( ( e.keyCode >=  48 && e.keyCode <=  57 ) ||   //¼ýÀÚ¿­ 0 ~ 9 : 48 ~ 57
( e.keyCode >= 96 && e.keyCode <= 105 ) || //Å°ÆÐµå 0 ~ 9 : 96 ~ 105
       e.keyCode ==   8 ||    //BackSpace
       e.keyCode ==  46 ||    //Delete
       e.keyCode == 110 ||    //¼Ò¼öÁ¡(.) : ¹®ÀÚÅ°¹è¿­
       e.keyCode == 190 ||    //¼Ò¼öÁ¡(.) : Å°ÆÐµå
       e.keyCode ==  37 ||    //ÁÂ È­»ìÇ¥
       e.keyCode ==  39 ||    //¿ì È­»ìÇ¥
       e.keyCode ==  35 ||    //End Å°
       e.keyCode ==  36 ||    //Home Å°
       e.keyCode ==   9       //Tab Å°
   ) {

   if(e.keyCode == 48 || e.keyCode == 96) { //0À» ´­·¶À»°æ¿ì
     if ( obj.value == "" || obj.value == '0' ) //¾Æ¹«°Íµµ ¾ø°Å³ª ÇöÀç °ªÀÌ 0ÀÏ °æ¿ì¿¡¼­ 0À» ´­·¶À»°æ¿ì
       e.returnValue=false; //-->ÀÔ·ÂµÇÁö¾Ê´Â´Ù.
     else //´Ù¸¥¼ýÀÚµÚ¿¡¿À´Â 0Àº
       return; //-->ÀÔ·Â½ÃÅ²´Ù.
     }

   else if ( e.keyCode == 110 || e.keyCode == 190 ) { //¼Ò¼öÁ¡À» ´­·¶À» °æ¿ì
     if ( obj.value == "" ) {  //¾Æ¹«°Íµµ ¾ø´Â »óÅÂ¿¡¼­ ¼Ò¼öÁ¡À» ÀÔ·ÂÇßÀ»°æ¿ì "0."À¸·Î Ç¥±â
       obj.value = "0";
       return;
     }

     if ( obj.value.indexOf(".") != -1 ) {  //±âÁ¸¿¡ ¼Ò¼öÁ¡ÀÌ µé¾îÀÖ´Ù¸é
       e.returnValue=false;                 //ÀÔ·Â½ÃÅ°Áö ¾Ê´Â´Ù.
     }
   }
   else //0ÀÌ ¾Æ´Ñ¼ýÀÚ
     return; //-->ÀÔ·Â½ÃÅ²´Ù.
   }
   else //¼ýÀÚ°¡ ¾Æ´Ï¸é ³ÖÀ»¼ö ¾ø´Ù.
 e.returnValue=false;
}

function handlerNumZeroAllow( obj ) {
    //¼ýÀÚ¸¸ ÀÔ·Â ¹Þ°Ô²û ÇÏ´Â ÇÔ¼ö.
     e = window.event; //À©µµ¿ìÀÇ event¸¦ Àâ´Â°ÍÀÔ´Ï´Ù.
    // alert(e.keyCode);

      //ÀÔ·Â Çã¿ë Å°
     if( ( e.keyCode >=  48 && e.keyCode <=  57 ) ||   //¼ýÀÚ¿­ 0 ~ 9 : 48 ~ 57
    ( e.keyCode >= 96 && e.keyCode <= 105 ) || //Å°ÆÐµå 0 ~ 9 : 96 ~ 105
           e.keyCode ==   8 ||    //BackSpace
           e.keyCode ==  46 ||    //Delete
           e.keyCode == 110 ||    //¼Ò¼öÁ¡(.) : ¹®ÀÚÅ°¹è¿­
           e.keyCode == 190 ||    //¼Ò¼öÁ¡(.) : Å°ÆÐµå
           e.keyCode ==  37 ||    //ÁÂ È­»ìÇ¥
           e.keyCode ==  39 ||    //¿ì È­»ìÇ¥
           e.keyCode ==  35 ||    //End Å°
           e.keyCode ==  36 ||    //Home Å°
           e.keyCode ==   9       //Tab Å°
       ) {
         return; //-->ÀÔ·Â½ÃÅ²´Ù.
       }
       else //¼ýÀÚ°¡ ¾Æ´Ï¸é ³ÖÀ»¼ö ¾ø´Ù.
     e.returnValue=false;
    }

// ºê¶ó¿ìÀú7 ¿©ºÎ ¸®ÅÏ
function isBrowserVersion7() {
    var browser_version = new Number(((window.navigator.appVersion.split('; '))[1].split(' '))[1]);
    if (navigator.appName == "Microsoft Internet Explorer" && browser_version == 7) {
        return true;
    }

    return false;
}

/**
 * ÀÔ·ÂÇÊµåÀÇ ÀÔ·Â°ª ±æÀÌ°¡ ÁöÁ¤ÇÑ ±æÀÌ°¡ µÇ¸é ´ÙÀ½ ÀÔ·ÂÇÊµå·Î Æ÷Ä¿½º¸¦ ÀÌµ¿ÇÑ´Ù.
 *
 * @param num (ÇÊ¼ö) ¹®ÀÚ¿­ ±æÀÌ
 * @param fromform (ÇÊ¼ö) ÀÔ·ÂÇÊµå
 * @param toform (ÇÊ¼ö) ´ÙÀ½ ÀÔ·ÂÇÊµå
 */
function moveFocus(num,fromform,toform) {
    var str = fromform.value.length;
    if(str == num)
    toform.focus();
}


/**
 * replaceAll
 *
 * @param str ¿øº»±Û
 * @param searchStr ¿øº»±Û¿¡¼­ Ã£À» ´Ü¾î
 * @param replaceStr º¯È¯ÇÏ°íÇÏ´Â ´Ü¾î
 */

function replaceAll(str, searchStr, replaceStr) {
	str = str.split(searchStr).join(replaceStr);
 return str;
}


function replaceAll2(str, searchStr, replaceStr) {

    while (str.indexOf(searchStr) != -1) {
        str = str.replace(searchStr, replaceStr);
    }

    return str;

}

/**
*¿Â¶óÀÎ ¸íÇÔ
*/
function onlineCardPopup(key){
	window.open("/popup/cardDetail.do?userId="+key, "cardDetail",
	"scrollbars=1,width=650,height=280");
}
























//URLº¹»ç 
function copyURL () {
	var cFile = location.href;

	var IE=(document.all)?true:false;
	if (IE) {
		alert ("                             ±â»çÀÇ URLÀÌ º¹»çµÇ¾ú½À´Ï´Ù.\n±â»ç¸¦ º¸³»´Â ºÐÀÇ ¸Þ½ÅÀú³ª ÀÌ¸ÞÀÏ¿¡ ctrl+V ·Î ºÙ¿©³Ö±â ÇÏ¼¼¿ä.\n\n");
		window.clipboardData.setData("Text", cFile);
	}
	else {
		prompt("ÀÌ ±â»çÀÇ ÁÖ¼ÒÀÔ´Ï´Ù. Ctrl+C¸¦ ´­·¯ Å¬¸³º¸µå·Î º¹»çÇÏ¼¼¿ä", cFile);
	}
}


//±â»çÆùÆ®
function fontSizeCookie( name ) {
        var nameOfCookie = name + "=";
        var x = 0;
	cookieFlg = document.cookie.indexOf(nameOfCookie);
    if (cookieFlg != -1) {

        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 "";
	}
	else{
	 return 15;
	}
}
function getFontSizeCookie() { 
	var cookie = fontSizeCookie("getFontSize"); 
	if ( cookie == null ) 
		return 15; 
	if ( cookie.length ) 
		return cookie; 
	else 
		return 15; 
}
function fontSizeLevel(calcSize) {
	var newsView, lineHeight; 
	newsView = document.getElementById("newsView"); 
	if (calcSize > 0) { 
		if (textSize <= 20) { 
			textSize = textSize + calcSize; 
			lineHeight = textSize+Math.round(1.1*textSize); 
			newsView.style.fontSize = textSize + "px"; 
		} 
	} else { 
		if (textSize > 11) { 
			textSize = textSize + calcSize; 
			lineHeight = textSize+Math.round(1.1*textSize); 
			newsView.style.fontSize = textSize + "px"; 
			} 
	} 
	var fontDate = new Date; 
	fontDate.setDate(fontDate.getDate()+1000); 
	setCookie("getFontSize", textSize, 1)//fontDate); 
}
var textSize = parseInt(getFontSizeCookie());