/******************************************************************************
기    능 : 프로젝트에 사용되는 공통 스크립트 포함
/*****************************************************************************
- Index - 
함수설명                                        함수명
----------------------------------------------  ------------------------------
1. 주민번호체크                                 - JuminBusinessCheck
2. 이메일주소체크                               - EmailCheck
3. 날짜입력필드의 "-"제거                       - dateFocus
4. 문자열에서특정문자 삭제                      - remove_char_set
5. 키 이벤트 값 테스트                          - keyEvent
6. 숫자만입력                                   - num_val
7. 전화번호입력(숫자+"-")                       - phoneNum_val
8. IP주소입력(숫자+".")                         - ip_val
9. IP주소값체크                                 - IP_blur
10. 주민등록번호 포커스처리                     - idno_focus
11. 주민등록번호 blur처리                       - idno_blur
12. 날짜필드 포커스처리                         - date_focus
13. 날짜필드 blur처리                           - date_blur
14. YYYYMM 포커스처리                           - yyyymm_focus
15. YYYYMM필드 blur처리                         - yyyymm_blur
16. HHMI 포커스처리(":"제거)                    - hourmin_focus
17. HHMI필드 blur처리(":"추가)                  - hourmin_blur
18. 시분(12)체크                                - hourminHH12_blur
19. 시분(24)체크                                - hourminHH24_blur
20. 필드값길이 계산                             - charBytesChk
21. 필드형식에 따른 입력필드 byte계산           - charLengthChk
22. 텍스트에어리어 길이 체크                    - chkTxarea
23. 날짜형식변경(txt, div)                      - dateFormat
24. 팝업창 중앙에 띄우기                        - pop_center_window
25. 조회일자 범위 및 메시지                     - date_compare_message
26. 조회일자 범위                               - date_compare
27. 뒤로가기버튼 방지                           - back_prevent
28. 입력길이제한                                - textCounter
29. 숫자만입력                                  - keyNumber
30. 숫자와 영문만입력                           - keyNumber2
31. 한글만입력                                  - keyNumber3
32. <br>을 \n으로변환                           - fnBrToEnter
33. 특수문자포함여부 체크                       - char_check
34. 날짜포맷의 오류검증                         - isDate
35. 팝업창생성2                                 - PopWin
36. 날짜 입력포맷 체크                          - date_check
37. 카드번호 입력포맷 체크                      - cardno_check
38. trim공백제거                                - trim
39. comma제거                                   - remove_comma
40. 날짜더하기                                  - getDateAdd
41. 해당날짜의 요일                             - getNowWeek
42. 날짜정보                                    - getDatePart
43. 현재년도까지의 총일수 계산                  - getSumDay
44. 현재년도의 총일수 계산                      - getDayOfYear
45. 팝업창 만들기                               - makePopup
46. 메시지 프레임에 메시지 출력                 - showMessage
47. 특정 문자가 포함되었는지 체크               - chkCharAt
48. HHMISS 포커스처리(":"제거)                  - hourminss_focus
49. HHMISS blur처리(":" 추가)                   - hourminss_blur
50. 주민(법인)번호필드 focus처리("-"제거)       - juminnumFocus
51. 주민(법인)번호필드 blur처리("-"추가)        - juminnumBlur
52. 사업자번호필드 focus처리("-"제거)           - sanumFocus
53. 사업자번호필드 blur처리("-"추가)            - sanumBlur
54. 주민번호입력형식                            - juminFormat
55. 사업자번호 입력형식                         - sanumFormat
56. 화면 정가운데 팝업 띄우기                   - winMoveCenter
57. 메시지 초기화                               - resetMessage
58. 숫자와 + - 입력만 가능                      - num_val2
59. 특정 문자 변환                              - replace
60. 문자열이 숫자로만 구성되었는지 체크         - checkNumber
61. 특정 문자열에서 해당 문자열 변환            - replacestr
62. 엔터키 체크                                 - inEnterKey
63. 숫자인지 체크                    			onlyNumber(obj)
64. 날짜변환                        				convertDate(obj)
65.  trim                       				trim(str)
66.  오른쪽트림                  				rtrim(str)
67.  왼쪽트림                    				ltrim(str)
68.  블랭크체크                   				chk_Blank(str)
69.  년도구하기                   				get_Year(str)
70.  월구하기                     				get_Month(str)
71.  일자구하기                   				get_Day(str)
72.  마지막날짜 구하기            				get_LastDay(str)
73.  윤년                         				chk_LeapYear(str)
74.  - 제거                       				delete_Char(source,char)
75.  년도체크                      				chk_Year(str)
76.  월 체크                      				chk_Month(str)
77.  일체크                        				chk_Day(str)
78.  정해진 구간에 들어가는지 체크    			chk_Between(str, from, to)
79.  valid체크                       			valDate(obj,gu)
80.  날짜변환                        			convert_Date(obj)
81.  숫자체크                        			chk_Number(str)
82.  날짜비교 									CompareDte(daybef,dayaft)
83.  날짜 체크 (입력할때)                        G_chk_Date(obj)
84.  텍스트 입력폼 체크                         checkEmpty(formVar, text)
85.  텍스트 입력폼 길이 체크                    checkLength(formVar, text, textlen)
86.  라디오 박스 선택 체크							checkRadioEmpty(formVar)
87.	 이메일 체크									checkEmail(formVar) 
88.  숫자만 입력 체크								checkKeyNum(formVar)
89.  영문 소문자와 숫자로만 되있는지 체크			checkEngNum(formVar)
90.  한글과 영문 조합인지 체크						checkEngKor(formVar)
checkIncEngNum 
******************************************************************************/

/*
*기능:주민등록번호 strJB가 정상인지 체크
*@param strJB:주민등록번호
*@return 1:true, 0:false
*/
function JuminBusinessCheck(strJB){
	/***** 2004.08.25 외국인 등록번호인경우 검사를 하지 않도록 한다 *****/

if( strJB.value.substr(6, 1) == '5' ||
	strJB.value.substr(6, 1) == '6'     ){
	/***** 외국인 등록번호인 경우 *****/
	return 1;
}else{


	//ex)주민 등록번호 체크 루틴 및 사업자 등록번호 루틴
	//strJB = removeHyphen(strJB);        // "-" 제거
	remove_char_set(strJB, "-");        // "-" 제거

	if (strJB.value.length == 13) {           //주민등록번호체크
		A	= strJB.value.charAt(0);
		B  	= strJB.value.charAt(1);
		C  	= strJB.value.charAt(2);
		D  	= strJB.value.charAt(3);
		E  	= strJB.value.charAt(4);
		F  	= strJB.value.charAt(5);
		G  	= strJB.value.charAt(6);
		H  	= strJB.value.charAt(7);
		I  	= strJB.value.charAt(8);
		J  	= strJB.value.charAt(9);
		K  	= strJB.value.charAt(10);
		L  	= strJB.value.charAt(11);
		Osub  	= strJB.value.charAt(12);

		SUMM = A*2 + B*3 + C*4 + D*5+ E*6+ F*7+G*8+H*9+I*2+J*3+K*4+L*5;
		N = SUMM % 11;
		Modvalue = 11 - N;
		LastVal =  Modvalue % 10 ;
	}else if(strJB.value.length == 10){      //사업자등록번호체크
		a   = strJB.value.charAt(0);
		b  	= strJB.value.charAt(1);
		c  	= strJB.value.charAt(2);
		d  	= strJB.value.charAt(3);
		e  	= strJB.value.charAt(4);
		f  	= strJB.value.charAt(5);
		g  	= strJB.value.charAt(6);
		h  	= strJB.value.charAt(7);
		i  	= strJB.value.charAt(8);
		Osub 	= strJB.value.charAt(9);

		suma = a*1 + b*3 + c*7 + d*1 + e*3 + f*7 + g*1 + h*3;
		sumb = (i*5) %10;
		sumc = parseInt((i*5) / 10,10);
		sumd = sumb + sumc;
		sume = suma + sumd;
		sumf = a + b + c + d + e + f + g + h + i;
		k = sume % 10;
		Modvalue = 10 - k;
		LastVal = Modvalue % 10;

		if (sumf == 0) {
			return 0;
		}
	}else{                              //주민등록번호도 사업자등록번호도 아님
		return 0;
	}

    if(parseInt(C+D) > 12 || parseInt(E+F) > 31 || strJB == "1111111111118" || strJB == "0000000000001"){
        return 0;
    }

  	if(Osub == LastVal){                //계산된 결과가 체크비트랑 맞는지 체크
        //alert("true");
		return 1;
	} else {
	    //alert("false");
		return 0;
	}
}
}


/*
*기능:이메일 주소 체크
*@param text:이메일주소
*@return none
*/
function EmailCheck(text){
    //ex) onBlur="EmailCheck(email)"
    atcnt = 0;      //@count
    atidx = 0;      //@index
    pocnt = 0;      //.count
    p1idx = 0;      //.first idx
    p2idx = 0;      //.last idx
    //flag = false;   //result

    for(i=0; i<text.value.length; i++){
        if(text.value.charAt(i) == "@"){
            ++atcnt;
            atidx = i;
        }

        if(text.value.charAt(i) == "."){
            ++pocnt;
            if(p1idx == 0){
                p1idx = i;  //처음 .를 만나는 위치값 1번만 저장
            }
            p2idx = i;
        }
    }

    if(text.value.length > 0 &&
        (text.value.length < 10 || atcnt != 1 || atidx < 4 || pocnt == 0 || pocnt > 3 ||
        ((p1idx > atidx) && p1idx-atidx < 3) ||
        ((p1idx < atidx) && atidx-p1idx < 3) || ((p1idx != p2idx) && p2idx-p1idx < 3))){
        alert("("+text.value+") 잘못된 형식의 이메일 주소입니다.");
        text.select();
        text.focus;
        return false;
    }
    
    return true;
}


/*
*기능:날짜입력필드의 "-"제거
*@param text:날짜 입력 필드 값
*@return none
*/
function dateFocus(text){
    remove_char_set(text, "-");
    text.select();
}


/*
*기능:문자열에서특정문자 삭제
*@param text:작업대상문자열, str:삭제하고자하는 문자
*@return none
*/
function remove_char_set(text, str){
    //ex) remove_char_set(minid, "-");
    cnt = text.value.length;
    retValue = "";
    for(i=0; i < cnt; i++){
        if(text.value.charAt(i) != str){
             retValue = retValue + text.value.charAt(i);
        }
    }
    text.value = retValue;
}

/*
*기능:문자열에서특정문자 삭제
*@param text:작업대상문자열, str:삭제하고자하는 문자
*@return none
*/
function removeCharSet(val, str){
    //ex) remove_char_set(minid, "-");
    cnt = val.length;
    retValue = "";
    for(i=0; i < cnt; i++){
        if(val.charAt(i) != str){
             retValue = retValue + val.charAt(i);
        }
    }
    
    return retValue;
}


/*
*기능:키 이벤트 값 테스트
*@param
*@return none
*/
function keyEvent(){
    alert("eventKeyCode = "+event.keyCode);
    return;
}


/*
*기능:숫자만입력
*@param text:입력된 키값
*@return true:숫자, false:숫자 이외의값
*/
function num_val(text){
    //ex onKeydown="javascript:num_val(agentid.value);"
    //ex onKeyDown="javascript:num_val();"
    
    if((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57) ||
        event.keyCode == 8  || event.keyCode == 46  || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39 ||
        event.keyCode == 32  || event.keyCode == 13  || event.keyCode == 17  || event.keyCode == 9  || event.keyCode == 27 || event.keyCode == 109 || event.keyCode == 107){ // 키패드사용
        //return true;
    }else{
        event.returnValue = false;
    }
}


/*
*기능:전화번호입력(숫자+"-")
*@param text:입력된 키값
*@return true:숫자또는"-", false:숫자또는 "-" 이외의값
*/
function phoneNum_val(text){
    //ex onKeydown="javascript:phoneNum_val(telno.value);"
    //ex onKeyDown="javascript:phoneNum_val();"
    if((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57) ||
        event.keyCode == 8  || event.keyCode == 46  || event.keyCode == 9 || event.keyCode == 37 ||
        event.keyCode == 39 || event.keyCode == 45  || event.keyCode == 109 || event.keyCode == 189){ // 키패드사용
        return true;
    }else{
        event.returnValue = false;
    }
}


/*
*기능:IP주소입력(숫자+".")
*@param text:입력된 키값
*@return true:숫자또는".", false:숫자또는 "." 이외의값
*/
function ip_val(text){
    //ip 주소 혹은 소수점을 포함한 숫자체크
    //ex  onKeydown="javascript:ip_val(ipaddr.value);"
    //0:96, 9:105, .:110,190
    //0:48, 1:49, ....... 9:57
    //back:8, del:46, ctrl:17, tab:9, space:32, left:37, right:39, esc:27, enter:13, -:45,(109, 189) +:43

    if((event.keyCode >= 96 && event.keyCode <= 105) || event.keyCode == 110 || event.keyCode == 190 ||
       (event.keyCode >= 48 && event.keyCode <= 57)  || event.keyCode == 32  || event.keyCode == 13  ||
        event.keyCode == 8  || event.keyCode == 46   || event.keyCode == 17  || event.keyCode == 9   ||
        event.keyCode == 37 || event.keyCode == 39   || event.keyCode == 27  ){
        return;
    }else{
        event.returnValue = false;
    }
}


/*
*기능:IP주소값체크
*@param text:입력된 IP주소값
*@return true:주소형식정상, false:비정상주소형식
*/
function IP_blur(text){
    //ex) onBlur="IP_blur(this);"
    str  = text.value;
    flag = false;

    if(str != "" && (str.length >= 7 || str.length <= 19)){
        var arr = str.split(".");

        if(arr.length == 4){
            fcnt = 0;
            for(i=0; i<arr.length; i++){
                if(arr[i].length < 1 || parseInt(arr[i]) < 1 || parseInt(arr[i]) > 255){
                    fcnt ++;
                }
            }

            if(fcnt == 0){
                flag = true;
            }
        }
    }

    if(!flag && str != ""){
        alert("("+text.value+") 올바른 IP주소 형식이 아닙니다.!");
        text.select();
        return false;
    }
}


/*
*기능:주민등록번호 포커스처리("-"제거)
*@param text:주민등록번호 필드값
*@return none
*/
function idno_focus(text){
    //ex) onfocus="javascript:idno_focus(this);"
    onblur = "javascript:idno_blur(this);";
    remove_char_set(text, "-");
    text.select();
}


/*
*기능:주민등록번호 blur처리("-"추가)
*@param text:주민등록번호 필드값
*@return none
*/
function idno_blur(text){
    //ex) onfocus="javascript:idno_blur(this);"
    remove_char_set(text, "-");
    if(text.value == "")    return;
    else if(text.value.length != 13){
        alert("("+text.value+") 주민등록번호 형식이 맞지 않습니다.!");
        text.focus();
        return false;
    }

    flag = JuminBusinessCheck(text.value);
    if(flag == 0){
        alert("("+text.value+") 올바른 주민등록번호가 아닙니다.!");
        text.focus();
        return false;
    }else{
        text.value = text.value.substr(0,6)+"-"+text.value.substr(6,12);
    }
}


/*
*기능:날짜입력 포커스처리("-"제거)
*@param text:날짜입력 필드값
*@return none
*/
function date_focus(text){
    //ex) onfocus="javascript:date_focus(this);"

    onblur="javascript:yyyymm_blur(this);"
    remove_char_set(text, "-");
    text.select();
}


/*
*기능:날짜필드 blur처리("-"추가)
*@param text:날짜필드값
*@return none
*/
function date_blur(text){
    //ex) onblur="javascript:date_blur(this);"
    remove_char_set(text,"-");
    if(text.value == "")   return ;
    else if(text.value.length != 8) {
           alert("(" + text.value + ")날짜형식(YYYYMMDD)이 맞지 않습니다.!");
           text.focus();
           return ;
         }

    intYear  = eval(text.value.substring(0,4));
    intMonth = eval(text.value.substring(4,6));
    intDay   = eval(text.value.substring(6,8));
    strYear  = "";
    strMonth = "";
    strDay   = "";

    strLast  = new Array(12);
    strLast[0] = "31";
    strLast[1] = "28";
    if((intYear %   4) == 0) strLast[1] = "29";
    if((intYear % 100) == 0) strLast[1] = "28";
    if((intYear % 400) == 0) strLast[1] = "29";
    strLast[2]  = "31";
    strLast[3]  = "30";
    strLast[4]  = "31";
    strLast[5]  = "30";
    strLast[6]  = "31";
    strLast[7]  = "31";
    strLast[8]  = "30";
    strLast[9]  = "31";
    strLast[10] = "30";
    strLast[11] = "31";

    strYear = text.value.substring(0,4);
    if(intMonth > 0 && intMonth < 13)
      strMonth = text.value.substring(4,6);
    else {
      alert("(" + text.value + ")날짜(월)형식(YYYYMMDD)이 맞지 않습니다.!");
      text.focus();
      return ;
    }
    if(intDay > 0 && intDay <= eval(strLast[intMonth - 1]))
      strDay = text.value.substring(6,8);
    else {
      alert("(" + text.value + ")날짜(일)형식(YYYYMMDD)이 맞지 않습니다.!");
      text.focus();
      return ;
    }

    text.value = strYear + "-" + strMonth + "-" + strDay;
}


/*
*기능:YYYYMM 포커스처리("-"제거)
*@param text:년월 필드값
*@return none
*/
function yyyymm_focus(text){
    remove_char_set(text, "-");
    text.select();
}


/*
*기능:YYYYMM필드 blur처리("-"추가)
*@param text:년 월 필드값
*@return none
*/
function yyyymm_blur(text){
    //ex) onblur="javascript:yyyymm_blur(this);"
    remove_char_set(text,"-");
    if(text.value == "")   return;
    else if(text.value.length != 6) {
           alert("(" + text.value + ")날짜형식(YYYYMM)이 맞지 않습니다.!");
           text.focus();
           return;
    }
    strYear  = text.value.substring(0,4);
    strMonth = text.value.substring(4);
    if(eval(strYear) <= 0 || eval(strMonth) <= 0 || eval(strMonth) > 12){
        alert("(" + text.value + ")날짜형식(YYYYMM)이 맞지 않습니다.!");
        text.focus();
        return;
    }
    text.value = strYear + "-" + strMonth;
}


/*
*기능:HHMI 포커스처리(":"제거)
*@param text:시 분 필드값
*@return none
*/
function hourmin_focus(text){
    //ex) onfocus="javascript:hourmin_focus(this);"
    remove_char_set(text, ":");
    text.select();
}


/*
*기능:HHMI필드 blur처리(":"추가)
*@param text:시 분 필드값
*@return none
*/
function hourmin_blur(text){
    //ex) onblur="javascript:hourmin_blur(this);"
    remove_char_set(text,":");
    if(text.value == "")   return;
    else if(text.value.length != 4) {
           alert("(" + text.value + ")시간형식(HHMM)이 맞지 않습니다.!");
           text.focus();
           return;
    }
    strHour  = text.value.substring(0,2);
    strMin   = text.value.substring(2);
    if(eval(strHour) < 0 || eval(strMin) < 0 || eval(strHour) > 23 || eval(strMin) > 59){
        alert("(" + text.value + ")시간형식(HHMM)이 맞지 않습니다.!");
        text.focus();
        return;
    }
    text.value = strHour + ":" + strMin;
}


/*
*기능:시분(12)체크 오전시간
*@param text:시(12) 분 필드값
*@return none
*/
function hourminHH12_blur(text){
    //ex) onblur="javascript:hourminHH12_blur(this);"
    //12시 이하의 오전 시간체크
    remove_char_set(text,":");
    if(text.value == "")   return;
    else if(text.value.length != 4) {
           alert("(" + text.value + ")시간형식(HHMM)이 맞지 않습니다.!");
           text.focus();
           return;
    }
    strHour  = text.value.substring(0,2);
    strMin   = text.value.substring(2);
    if(eval(strHour) < 0 || eval(strMin) < 0 || eval(strHour) > 12 || eval(strMin) > 59){
        alert("(" + text.value + ")시간형식(HHMM)이 맞지 않습니다.!");
        text.focus();
        return;
    }
    text.value = strHour + ":" + strMin;
}


/*
*기능:시분(24)체크 오후시간
*@param text:시(24) 분 필드값
*@return none
*/
function hourminHH24_blur(text){
    //ex) onblur="javascript:hourminHH24_blur(this);"
    //12 ~ 24의 오후시간 체크
    remove_char_set(text,":");
    if(text.value == "")   return;
    else if(text.value.length != 4) {
           alert("(" + text.value + ")시간형식(HH24MM)이 맞지 않습니다.!");
           text.select();
           return;
    }
    strHour  = text.value.substring(0,2);
    strMin   = text.value.substring(2);
    if(eval(strHour) < 12 || eval(strMin) < 0 || eval(strHour) > 23 || eval(strMin) > 59){
        alert("(" + text.value + ")시간형식(HH24MM)이 맞지 않습니다.!");
        text.select();
        return;
    }
    text.value = strHour + ":" + strMin;
}


/*
*기능:필드값길이 계산
*@param text:길이를 계산하려는 필드값
*@return 문자열의 길이
*/
function charBytesChk(text){
    //ex)cnt = charBytesChk(document.test.id.value);
    byteCnt = 0;

    for(i=0; i<text.length; i++){
        strEsc = escape(text.charAt(i)).length;
        if(strEsc > 4){
            byteCnt += 2;       //한글 2byte
        }else{
            byteCnt += 1;          //기타 1byte
        }
    }
    return byteCnt;     //계산된 문자열 길이
}

/*
*기능:필드값길이 계산
*@param text:길이를 계산하려는 필드값
*@return 문자열의 길이
*/
function hangulExist(text){
    //ex)cnt = charBytesChk(document.test.id.value);
    bFlag = false;

    for(i=0; i<text.length; i++){
        strEsc = escape(text.charAt(i)).length;
        if(strEsc > 4){
            bFlag = true;
        }
    }
    return bFlag;     //계산된 문자열 길이
}


/*
*기능:필드형식에 따른 입력필드 byte계산 **검증거쳐야 함
*@param obj:객체명, len:허용최대길이, type:입력허용된타입
*@return 문자열의 bytes값
*/
function charLengthChk(obj, len, type){
	str = obj.value;
	code = true;		//입력값이 바른지..
	byteCnt = 0;		//바이트 값..
	typeflag = 0;		//허용문자 타입 플레그	a:한글포함 e:영문포함 s:일부특수문자 포함 n:모든문자
	txt = "";

	for(i=0; i < str.length; i++){
		strEsc = escape(str.charAt(i)).length;
		str1 = str.charAt(i);

		if(strEsc > 4){
			byteCnt += 2;					//한글 2바이트
			if(type == "e" || type == "s"){
				code = false;
				typeflag = 1;
			}
		}else if(strEsc == 1){
			if(str1 >= 0 && str1 <= 9){
				byteCnt ++;				//숫자 1바이트
			}else if(str1 == "@" || str1 == "*" || str1 == "_" || str1 == "-" || str1 == "+" || str1 == "." || str1 == "/"){
				byteCnt ++;
				if(type != "s"){
					code = false;				//escape 1바이트특수문자
				}
			}else{
				byteCnt ++;				//영문 1바이트
			}
		}else{
			byteCnt ++;
			code = false;	 				//기타 특수문자.
		}

		if(code == false && type != "n"){
			msg = "허용된 문자가 아닙니다...";
			if(typeflag == 1){
				msg += "\n\n입력 필드에 한글이 포함되어 있습니다.";
			}
			alert(msg);
			obj.value = txt;
			break;
		}

		if(byteCnt > len){
			alert("입력 자리수 초과 입니다. \n\n"+len+"bytes 까지 입력 가능합니다.");
			obj.value = txt;
			break;
		}else{
			txt += str1;
		}
	}
	return false;
}


/* 위와 유사한 입력 바이트 체크 함수.*/
//name : 객체이름, len: 최대길이, gb: 입력여부체크
function chkTxarea(name, len, gb) {
	var form = document.forms[0];
	var obj = eval("form."+ name);
	var j = 0;
	var k = 0;
	var tempStr;
	var tempStr2;

	obj.value = ltrim(obj.value);
	for(var i = 0; i < obj.value.length; i++  )	{
	  tempStr = obj.value.charCodeAt(i);
	  tempStr2 = tempStr.toString();
	  if(tempStr2.length >= 5) {
		j++;		//한글
	  } else {
		k++;		//영문
	  }
	}

	var ln = k+(j*2);

	if(gb=="D" && ln == 0) {
		alert("내용을 입력하세요.");
		obj.focus();
		obj.select();
		return false;
	}
	if(ln > len) {
			alert(len+"Byte 이내로 입력하세요. (현재 "+ ln +" Byte)");
			obj.focus();
			obj.select();
			return false;
	} else
		return true;
}


/*
*기능:날짜형식변경(20010101 - 2001/01/01, 200101 - 2001-01..)
*@param date_type:변경하고자하는 날짜필드값
*@return 정상:변경된 날짜값, 그이외엔:"원래값"
*/
function dateFormat(date_val, stradd){
    if(date_val.length == 6 && stradd.length == 1){         //년월
        date_val = date_val.substring(0,4)+stradd+date_val.substring(4,6);
    }else if(date_val.length == 8 && stradd.length == 1){   //년월일
        date_val = date_val.substring(0,4)+stradd+date_val.substring(4,6)+stradd+date_val.substring(6,8);
    }
    return date_val
}


/*
*기능:팝업창 중앙에 띄우기
*@param fileName:팝업대상파일, window_Name:팝업윈도우명, windowW:윈도우넓이, windowH:윈도우높이, property:속성
*@return none
*/
function pop_center_window(fileName,window_Name, windowW,windowH,property){
    windowX = Math.ceil( (window.screen.width - windowW) / 2 );
    windowY = Math.ceil( (window.screen.height - windowH) / 2 );
    var url = fileName;
    if(property=='' || property == null){
        window.open(url,window_Name,"width="+windowW+",height="+windowH+",left="+windowX+",top="+windowY);
    }else{
        window.open(url,window_Name,property+",width="+windowW+",height="+windowH+",left="+windowX+",top="+windowY);
    }
}


/*
*기능:조회일자 범위 및 메시지
*@param fromDate:시작일자, toDate:종료일자, message:범위순서가 틀릴경우 메시지
*@return none
*/
function date_compare_message(fromDate, toDate, message){
    if(fromDate > toDate) {
        alert(message);
        return false;
    }else{
        return true;
    }
}


/*
*기능:조회일자 범위
*@param fromDate:시작일자, toDate:종료일자
*@return none
*/
function date_compare(fromDate, toDate){
    if(fromDate > toDate) {
        alert("검색범위가 올바르지 않습니다");
        return false;
    }else{
        return true;
    }
}


/*
*기능:뒤로가기버튼 방지
*@param
*@return none
*/
function back_prevent(){
    history.go(1);
}


/*
*기능:입력길이제한
*@param field:필드명, maxlimit:제한길이
*@return none
*/
function textCounter(field, maxlimit) {
    if (field.value.length > maxlimit) {
        var textValue = field.value.substring(0, maxlimit);
        field.value = "";
        alert("입력제한 : "+maxlimit+"자 까지 입력할 수 있습니다.");
        field.value = textValue;
    }
}


/*
*기능:숫자만입력
*@param
*@return none
*/
function keyNumber(){
    if ((event.keyCode<48) || (event.keyCode>57))
        event.returnValue=false;
    return true;
}


/*
*기능:숫자와 영문만입력
*@param
*@return none
*/
function keyNumber2() {
    if ((event.keyCode<48) || (event.keyCode>57 && event.keyCode<97) || (event.keyCode>122))
        event.returnValue=false;
    return true;
}


/*
*기능:한글만입력
*@param
*@return none
*/
function keyNumber3() {
    if ((event.keyCode>31) && (event.keyCode<128))
        event.returnValue=false;
    return true;
}


/*
*기능:특수문자포함여부 체크
*@param
*@return true:정상, false:포함된문자 있음
*/
function char_check() {
    var event_code = event.keyCode;
    switch(event_code) {
        case 34:
            event.returnValue=false;
            break;
        case 39:
            event.returnValue=false;
            break;
        case 44:
            event.returnValue=false;
            break;
        case 60:
            event.returnValue=false;
            break;
        case 62:
            event.returnValue=false;
            break;
    }
    return true;
}


/*
*기능:날짜포맷의 오류검증
*@param
*@return none
*/
function isDate(obj, bFocus){
    var m3 = obj.value;

    if (m3.length == 0)
        return  true;

    if (m3.length != 8 && m3.length != 10){
        alert("날짜입력 오류입니다.");
        obj.value = "";
        if ( bFocus )
           obj.focus();
        return false;
    }

    if (m3.length == 10)
        m3 = strDateUnFormat(m3);

    year = m3.substring(0,4);
    m1   = m3.substring(4,5);
    m2   = m3.substring(5,6);
    d1   = m3.substring(6,7);
    d2   = m3.substring(7,8);

    if(m1=='0')
        month = m2;
    else
        month = m1 + m2;

    if( (month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12))
        day = 31;
    else if( (month==4)||(month==6)||(month==9)||(month==11))
        day = 30;
    else if(month==2){
        if ((((year % 4)==0) && ((year % 100)!=0)) || ((year % 400)==0))
            day = 29;
        else
            day = 28;
    }

    if(d1=='0')
        date = d2;
    else
        date = d1 + d2;

    if( (year < 1900) || (year > 2050) || (month < 1) || (month > 12) || (date < 1) || (date > day)){
        alert("날짜입력 오류입니다.");
        obj.value = "";
        if ( bFocus )
           obj.focus();
        return false;
    }

    // 성공
    return true;
}


/*
*기능 : 팝업창생성2
*@param  페이지url, 팝업창이름, width, height, scroll여부
*@return none
*/
function PopWin(url,popname,w,h,scroll){
    var win= null;

    var winl = (screen.width-w)/2;
    var wint = (screen.height-h)/2;
    var settings ='toolbar=no,status=no,location=no,directories=no,';
    settings +='height='+h+',';
    settings +='width='+w+',';
    settings +='top='+wint+',';
    settings +='left='+winl+',';
    settings +='scrollbars='+scroll+',';
    settings +='resizable=yes';
    win=window.open(url,popname,settings);
    if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}


/*
* 처리내용 : 날짜 입력포맷 체크
* @param obj:날짜필드 객체
* @return
*/
function date_check(obj){
    i=obj.value.length-1;
    if(obj.value.length==0) return;

    // backspace 의 Ascii 값이 8이다.
    if(event.keyCode == "8") {
      if(i==3 || i==6) {
            obj.value=obj.value.substring(0,i);
      }
      return;
    }

    if (obj.value == null || obj.value.replace(/ /gi,"") == "") {
        alert('반드시 정해진 형식대로 입력하세요 1');
        obj.value=obj.value.substring(0,i);
    }

    if(i!=4 && i!=7){
        if(obj.value.substring(i,i+1) > '9' || obj.value.substring(i,i+1) < '0'){
          alert('반드시 정해진 형식대로 입력하세요 2');
          obj.value=obj.value.substring(0,i);
          return;
        }
    }

    if(obj.value.length==4 && event.keyCode != "8")
        obj.value=obj.value+"-";

    if(obj.value.length==7 && event.keyCode != "8")
        obj.value=obj.value+"-";

    prevlen=obj.value.length;
}


/*
* 처리내용 : 카드번호 입력포맷 체크 - 검증절차요망
* @param obj:카드번호필드객체
* @return
*/
function cardno_check(obj){
    i=obj.value.length-1;
    if(obj.value.length==0) return;

    // backspace 의 Ascii 값이 8이다.
    if(event.keyCode == "8") {
      //1234-5678-9012-1234
      if(i==4 || i==9 || i==14) {
            obj.value=obj.value.substring(0,i);
      }
      return;
    }

    if (obj.value == null || obj.value.replace(/ /gi,"") == "") {
        alert('반드시 정해진 형식대로 입력하세요 1');
        obj.value=obj.value.substring(0,i);
    }

    if(i!=4 && i!=9 && i!=14){
        if(obj.value.substring(i,i+1) > '9' || obj.value.substring(i,i+1) < '0'){
          alert('반드시 정해진 형식대로 입력하세요 2');
          obj.value=obj.value.substring(0,i);
          return;
        }
    }

    if(obj.value.length==4 && event.keyCode != "8")
        obj.value=obj.value+"-";

    if(obj.value.length==9 && event.keyCode != "8")
        obj.value=obj.value+"-";

    if(obj.value.length==14 && event.keyCode != "8")
        obj.value=obj.value+"-";
}


/*
* 처리내용 : trim공백제거
* @param text:공백을 제거할 문자열
* @return 공백을 제거한 문자열
*/
function trim(text){
	if(text != null){
	    cnt = text.length;
	    obj = new Array(cnt);
	    for(i = 0; i < cnt; i++){
	        obj[i] = text.charAt(i);
	    }
	    obj = obj.reverse();
	    retValue = "";
	    for(i = 0; i < cnt; i++){
	        if(obj[i] != " ") break;
	        if(obj[i] == " ") obj[i] = "";
	    }
	    obj = obj.reverse();
	    for(i = 0; i < cnt; i++){
	        retValue = retValue + obj[i].toString();
	    }
	}else{//null이면
		retValue = "";
	}
    return retValue;
}


/*
* 처리내용 : comma제거 - remove_char_set()함수를 이용하는게 효과적
* @param text:,를 제거할 문자열
* @return comma를 제거한 문자열
*/
function remove_comma(text){
    cnt = text.value.length;
    retValue = "";
    for(i=0; i < cnt; i++){
        if(text.value.charAt(i) != ','){
             retValue = retValue + text.value.charAt(i);
        }
    }
    text.value = retValue;
}


/*
* 처리내용 : 날짜더하기
* @param inFlag:날짜형식구분, inAdd:증가값, inDate:대상날짜
* @return 더해진 날짜
*/
function getDateAdd(inFlag, inAdd, inDate){
   
    retValue = "";
    tmpDate  = inDate;
    //tmpDate  = remove_char_ret(inDate, "-");
    intYear = eval(tmpDate.substring(0, 4));
    intMon  = eval(tmpDate.substring(4, 6)) - 1;
    intDay  = eval(tmpDate.substring(6));
    date = new Date(intYear, intMon, intDay);
    inFlag = inFlag.toUpperCase();
    if(inFlag == "YY")        date = new Date(intYear + inAdd, intMon, intDay);
    else if(inFlag == "YYYY") date = new Date(intYear + inAdd, intMon, intDay);
    else if(inFlag == "MM")   date = new Date(intYear, intMon + inAdd, intDay);
    else if(inFlag == "DD")   date = new Date(intYear, intMon, intDay + inAdd);
    else{
      retValue = inDate;
      return retValue;
    }
    
    strYear = date.getYear().toString();
    strMon  = (date.getMonth() + 1).toString();
    if(date.getMonth() + 1 < 10) strMon = "0" + strMon;
    strDay  = (date.getDate()).toString();
    if(date.getDate() < 10) strDay = "0" + strDay;
  //  retValue = strYear + "-" + strMon + "-" + strDay;
    retValue = strYear + strMon + strDay;
    return retValue;
}


/*
* 처리내용 : 해당날짜의 요일
* @param yyyy:년, mm:월, dd:일
* @return 입력된 년월일에 대한 해당요
*/
function getNowWeek(yyyy, mm, dd){ // 1월 --> 0
    ret_value = 0;
    c_now = new Date(yyyy, mm, dd);
    ret_value = c_now.getDay();
    return ret_value;
}


/*
* 처리내용 : 날짜정보
* @param inFlag:년월일, inDate:대상날짜..
* @return 입력된 년월일에 대한 해당요
*/
function getDatePart(inFlag, inDate){
    inDate = remove_char_ret(inDate, "-");
    inFlag = inFlag.toUpperCase();
    if(inFlag == "YY" || inFlag == "YYYY"){ // 년도
          retValue = eval(inDate.substring(0, 4));
    }
    else if(inFlag == "MM"){ // 월
        retValue = eval(inDate.substring(4, 6));
    }
    else if(inFlag == "DD"){ // 일
        retValue = eval(inDate.substring(6));
    }
    else if(inFlag == "DY"){ // 해당년도의 몇번재 날...
        retValue = this.getDayOfYear(inDate);
    }
    else if(inFlag == "WK"){ // 몇번째 주...
        firstDayWeek = 0; // 1월 1일의 요일
        sumDay       = 0; // 총일수
        firstDayWeek     = getNowWeek(eval(inDate.substring(0, 4)), 0, 1);
        sumDay           = getDayOfYear(inDate);
        retValue = parseInt(((eval(sumDay) + eval(firstDayWeek) - 1) / 7)) + 1;
    }
    else if(inFlag == "DW"){ // 요일
        retValue = getNowWeek(eval(inDate.substring(0, 4))
                            , eval(inDate.substring(4, 6)) - 1
                            , eval(inDate.substring(6)));
    }
    return retValue;
}


/*
* 처리내용 : 현재년도까지의 총일수 계산
* @param inDate:기준년월일
* @return 기간내 총일수계산값
*/
function getSumDay(inDate){
    retValue   = 0;
    intLeapCnt = 0;
    preDay     = 0;
    currDay    = 0;
    currLeap = false;
    intYear = eval(inDate.substring(0, 4));
    intMon  = eval(inDate.substring(4, 6));
    intDay  = eval(inDate.substring(6));
    for(i = 1; i < intYear; i++){ // 전년도까지의 윤년 체크
        if(i %   4 == 0) intLeapCnt++;
        if(i % 100 == 0) intLeapCnt--;
        if(i % 400 == 0) intLeapCnt++;
    }
    preDay = ((intYear - 1) * 365) + intLeapCnt; // 전년도까지 일수
    if(intYear %   4 == 0) currLeap = true  ; // 현재년도 윤년계산
    if(intYear % 100 == 0) currLeap = false ;
    if(intYear % 400 == 0) currLeap = true  ;
    for(i = 1; i < intMon; i++){ // 전월까지 일수 계산
        if(i ==  1) currDay += 31;
        if(i ==  2){ if(currLeap == true) currDay += 29; else currDay += 28; }
        if(i ==  3) currDay += 31;
        if(i ==  4) currDay += 30;
        if(i ==  5) currDay += 31;
        if(i ==  6) currDay += 30;
        if(i ==  7) currDay += 31;
        if(i ==  8) currDay += 31;
        if(i ==  9) currDay += 30;
        if(i == 10) currDay += 31;
        if(i == 11) currDay += 30;
        if(i == 12) currDay += 31;
    }
    currDay += intDay ; // 현재년의 전월까지와 현월의 일수 합
    retValue = preDay + currDay ; //전년까지의 일수와 현재년의 일수 합
    return retValue;
}


/*
* 처리내용 : 현재년도의 총일수 계산
* @param inDate:기준년월일
* @return 총일수계산값
*/
function getDayOfYear(inDate){
    retValue   = 0;
    intLeapCnt = 0;
    currDay    = 0;
    currLeap = false;

    intYear = eval(inDate.substring(0, 4));
    intMon  = eval(inDate.substring(4, 6));
    intDay  = eval(inDate.substring(6));

    if(intYear %   4 == 0) currLeap = true  ; // 현재년도 윤년계산
    if(intYear % 100 == 0) currLeap = false ;
    if(intYear % 400 == 0) currLeap = true  ;

    for(i = 1; i < intMon; i++){ // 전월까지 일수 계산
        if(i ==  1) currDay += 31;
        if(i ==  2){ if(currLeap == true) currDay += 29; else currDay += 28; }
        if(i ==  3) currDay += 31;
        if(i ==  4) currDay += 30;
        if(i ==  5) currDay += 31;
        if(i ==  6) currDay += 30;
        if(i ==  7) currDay += 31;
        if(i ==  8) currDay += 31;
        if(i ==  9) currDay += 30;
        if(i == 10) currDay += 31;
        if(i == 11) currDay += 30;
        if(i == 12) currDay += 31;
    }
    currDay += intDay ; // 현재년의 전월까지와 현월의 일수 합
    retValue = currDay ; //전년까지의 일수와 현재년의 일수 합
    return retValue;
}


/*
* 처리내용 : 팝업 윈도우 생성
* @param inDate:기준년월일
* @return 총일수계산값
*/
var wname;
function makePopup(ppage, pname, pwidth, pheight, type){
    //이부분에 팝업 타입을 정의 하세요..
    if(type == 1){
        type = "directories=no, menubar=no, toolbars=no, resizable=no";
    }else if(type == 2){
	    type = "directories=yes, menubar=no, toolbars=no, resizable=no";
    }else if(type == 3){
	    type = "directories=yes, menubar=yes, toolbars=yes, resizable=yes";
    }else{
        type = "menubar=no, toolbars=no, resizable=yes";
    }

    type = type + ' width='+pwidth+', height='+pheight;
	/*
	obj = window.wname;
	if(obj == null){

		wname = window.open(ppage, pname, type);
	}
	*/

	obj = window.wname;
	//alert("window.wname="+obj);

	if(obj == null){
		wname = window.open(ppage, pname, type);
	}

	wname.focus();
}

//*********************************************************
// 새로운 창 열기
//
//  1.URL 2.새윈도우명 4.넓이 5.높이, 6. 옵션
//*********************************************************
 
function popupWin(winURL, winName, winWidth, winHeight, winOption) {

	var l = 16, t = 16; 	// 윈도우 위치(x, y)
	var props = "";
 	
	if (winOption == "") {
		props += "toolbar=0,location=0,directories=0,status=0,menubar=0,";	//윈도우 옵션
		props += "scrollbars=1,resizable=0,copyhistory=0,";
	} else {
		props = winOption;
	}

	props += "width=" + winWidth + ",height=" + winHeight;

	if (window.screen && window.screen.availWidth) {

		l = Math.floor(((screen.availWidth - winWidth)/2) + 5);
		t = Math.floor((screen.availHeight - winHeight)/2);
		if (l < 0) l = 0;
		if (t < 0) t = 0;
		props += ",left=" + l + ",top=" + t;
	}

	var aWinObj = window.open(winURL, winName, props);
	aWinObj.focus();

}
 

/*
* 처리내용 : 메시지 프레임에 메시지전송
* @param 전송될 메시지
* @return
*/
function showMessage(message){
	var targetObj = top.MSGFrame;

	if(targetObj == null){											//메인에서의 실행이 아니면..
		if(opener){
			targetObj = opener.top.MSGFrame;			//팝업에서인가?
		}
	}

	if(targetObj != null){
		targetObj.document.all.message.value = message;
	}
}


/*
* 처리내용 : 문자열에 특정 문자가 포함되었는지 체크
* @param 문자열
* @return 문자열 포함갯수
*/
function chkCharAt(str, fnd){
	var cnt = 0;
	for(i=0; i<str.length; i++){
		if(str.charAt(i) == fnd){
			++cnt;
		}
	}
	return cnt;
}


/*
*기능:HHMISS 포커스처리(":"제거)
*@param text:시 분 초 필드값
*@return none
*/
function hourminss_focus(text){
    //ex) onfocus="javascript:hourminss_focus(this);"
    remove_char_set(text, ":");
    text.select();
}


/*
*기능:HHMISS필드 blur처리(":"추가)
*@param text:시 분 초 필드값
*@return none
*/
function hourminss_blur(text){
    //ex) onblur="javascript:hourminss_blur(this);"
    remove_char_set(text,":");
    if(text.value == "")   return;
    else if(text.value.length != 6) {
           alert("(" + text.value + ")시간형식(HHMMSS)이 맞지 않습니다.!");
           text.focus();
           return;
    }
    strHour  = text.value.substring(0,2);
    strMin   = text.value.substring(2,4);
    strSs	= text.value.substring(4);

    if(eval(strHour) < 0 || eval(strMin) < 0  || eval(strSs) < 0 || eval(strHour) > 23 || eval(strMin) > 59 || eval(strSs) > 59){
        alert("(" + text.value + ")시간형식(HHMMSS)이 맞지 않습니다.!");
        text.focus();
        return;
    }
    text.value = strHour + ":" + strMin + ":" + strSs;
}


/*
*기능:주민(법인)번호필드 focus처리("-"제거)
*@param text:주민번호 필드값
*@return none
*/
function juminnumFocus(text){
    //ex) onfocus="javascript:juminnumFocus(this);"
    if(text.value.length > 6){
    	remove_char_set(text, "-");
   	}
    text.select();
}


/*
*기능:주민(법인)번호필드 blur처리("-"추가)
*@param text:주민번호 필드값
*@return none
*/
function juminnumBlur(text){
    //ex) onfocus="javascript:juminnumBlur(this);"
    //alert(text.value.length);
	if(text.value.length > 0 && text.value.length != 13){
		alert("주민(법인)번호가 잘못되었습니다.");
		text.select();
		return false;
	}else if(text.value.length == 13){
    	text.value = text.value.substring(0, 6)+"-"+text.value.substring(6);
   	}

}


/*
*기능:사업자번호필드 focus처리("-"제거)
*@param text:주민번호 필드값
*@return none
*/
function sanumFocus(text){
    //ex) onfocus="javascript:sanumFocus(this);"
    if(text.value.length > 3){
    	remove_char_set(text, "-");
   	}
    text.select();
}


/*
*기능:사업자번호필드 blur처리("-"추가)
*@param text:사업자번호 필드값
*@return none
*/
function sanumBlur(text){
    //ex) onfocus="javascript:sanumBlur(this);"
    //alert(text.value.length);
	if(text.value.length > 0 && text.value.length != 10){
		alert("사업자번호(10자리)가 잘못되었습니다.");
		text.select();
		return false;
	}else if(text.value.length == 10){
    	text.value = text.value.substring(0, 3)+"-"+text.value.substring(3, 2)+"-"+text.value.substring(5);
   	}
}


/*
*기능:주민번호입력형식
*@param text:입력한 주민번호 숫자
*@return none
*/
function juminFormat(text){
    //ex onkeydown="javascript:juminFormat(this);"
    if(text.value.length <= 13 && ((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57))){
    	//숫자 입력이면..
		ivalue = text.value + String.fromCharCode(event.keyCode);
		event.returnValue = false;

		temp = "";
	    for(i=0; i <ivalue.length; i++){
	        if(ivalue.charAt(i) != '-'){
	             temp += ivalue.charAt(i);
	        }
	    }

	    if(temp.length >= 6){
			text.value = temp.substring(0,6)+"-"+temp.substring(6);
		}else{
			text.value = temp;
		}
    }else if(event.keyCode == 8  || event.keyCode == 46  || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39 ||
        event.keyCode == 32  || event.keyCode == 13  || event.keyCode == 17  || event.keyCode == 9  || event.keyCode == 27  ){
		//특수키입력..
    }else{
        event.returnValue = false;
    }
}


/*
*기능:사업자번호입력형식
*@param text:입력한 사업자번호 숫자
*@return none
*/
function sanumFormat(text){
    //ex onkeydown="javascript:sanumFormat(this);"
    if(text.value.length <= 10 && ((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57))){
    	//숫자 입력이면..

		ivalue = text.value + String.fromCharCode(event.keyCode);
		event.returnValue = false;

		temp = "";
	    for(i=0; i <ivalue.length; i++){
	        if(ivalue.charAt(i) != '-'){
	             temp += ivalue.charAt(i);
	        }
	    }

	    if(temp.length == 3){
	   		text.value = temp.substring(0,3)+"-";
	   	}else if(temp.length == 5){
			text.value = temp.substring(0,3)+"-"+temp.substring(3,2)+"-";
		}else{
			text.value = temp;
		}

    }else if(event.keyCode == 8  || event.keyCode == 46  || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39 ||
        event.keyCode == 32  || event.keyCode == 13  || event.keyCode == 17  || event.keyCode == 9  || event.keyCode == 27  ){
		//특수키입력..
    }else{
        event.returnValue = false;
    }
}


/*
*기능:사업자번호입력형식
*@param text:입력한 사업자번호 숫자
*@return none
*/
function sanumFormat(text){
    //ex onkeydown="javascript:sanumFormat(this);"
    if(text.value.length <= 11 && ((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57))){
    	//숫자 입력이면..

		ivalue = text.value + String.fromCharCode(event.keyCode);
		event.returnValue = false;

		temp = "";
	    for(i=0; i <ivalue.length; i++){
	        if(ivalue.charAt(i) != '-'){
	             temp += ivalue.charAt(i);
	        }
	    }

	    if(temp.length >= 3 && temp.length < 5){
	   		text.value = temp.substring(0,3)+"-"+temp.substring(3);
	   	}else if(temp.length >= 5){
			text.value = temp.substring(0,3)+"-"+temp.substring(3,5)+"-"+temp.substring(5);
		}else{
			text.value = temp;
		}

    }else if(event.keyCode == 8  || event.keyCode == 46  || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39 ||
        event.keyCode == 32  || event.keyCode == 13  || event.keyCode == 17  || event.keyCode == 9  || event.keyCode == 27  ){
		//특수키입력..
    }else{
        event.returnValue = false;
    }
}


/*
*기능:화면 정가운데 팝업 띄우기
*@param
*@return
*/
function winMoveCenter() {
  if(document.layers) {
    var sleft = screen.width / 2 - outerWidth / 2;
    var stop = screen.height / 2 - outerHeight / 2;
  }else{
    var sleft = screen.width / 2 - document.body.offsetWidth / 2;
    var stop = -75 + screen.height / 2 - document.body.offsetHeight / 2;
  }
  self.moveTo(sleft, stop);
}


/*
*기능:메시지 지우기
*@param
*@return
*/
function resetMessage(){
	var targetObj = top.MSGFrame;

	if(targetObj == null){											//메인에서의 실행이 아니면..
		if(opener){
			targetObj = opener.top.MSGFrame;			//팝업에서인가?
		}
	}

	if(targetObj != null){
		targetObj.document.all.message.value ="";
	}
}


/*
*기능:숫자와 + , - 만입력
*@param text:입력된 키값
*@return true:숫자, false:숫자 이외의값
*/
function num_val2(text){
    //ex onKeydown="javascript:num_val(agentid.value)
    //ex onKeyDown="javascript:num_val();"
    if((event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode >= 48 && event.keyCode <= 57) ||
        event.keyCode == 8  || event.keyCode == 46  || event.keyCode == 9 || event.keyCode == 37 || event.keyCode == 39 ||
        event.keyCode == 32  || event.keyCode == 13  || event.keyCode == 17  || event.keyCode == 9  || event.keyCode == 27 || event.keyCode == 109 ||
        event.keyCode == 107 || event.keyCode == 189 || event.keyCode == 16 ||event.keyCode == 187){ // 키패드사용
        //return true;
    }else{
        event.returnValue = false;
    }

}


/*
*기능:특정 문자 변환
*@param text:원본 문자
*@param oldstr:찾는문자
*@param newstr:대체하는 문자
*@return 변환된 문자열
*/
function replace(text, oldstr, newstr){
    cnt = text.length;
    retValue = "";
    for(i=0; i < cnt; i++){
        if(text.charAt(i) == oldstr){
            retValue += newstr;
        }else{
            retValue += text.charAt(i);
        }
    }
    return retValue;
}

/*
*기능:숫자로만 구성되었는지 체크
*@param str:검색문자열
*@return 숫자이면 true, 아니면 false
*/
function checkNumber(str){
	var flag = true;
	for(i=0; i< str.length; i++){
		if(str.charAt(i) < '0' || str.charAt(i) > '9'){
			flag = false;
			break;
		}
	}
	return flag;
}

/*
*기능:특정 문자열에서 해당 문자열 변환
*@param text:원본 문자열
*@param oldstr:찾는문자열
*@param newstr:대체하는 문자열
*@return 변환된 문자열
*/
function replacestr(text, oldstr, newstr){
    oldlen = oldstr.length;
    cnt = text.length;
    retValue = "";
    for(i=0; i < cnt; i++){
        if(text.substr(i, oldlen) == oldstr){
            retValue += newstr;
            i+=oldlen-1;
        }else{
            retValue += text.charAt(i);
        }
        //alert("retValue="+retValue+"##"+"i="+i);
    }
    return retValue;
}

/*
*기능 : 리턴키 체크 리턴키면 true, 아니면 false
* @param key event
* @return
*/
function isEnterKey(){
    if(event.keyCode == 13)
        return true;
    else
        return false;
}

/*
*기능 : 숫자인지 체크
* @param key event
* @return
*/
function onlyNumber(obj)
{
	key =obj.event.keyCode;
	//alert('key = '+key);
	if ( key == 13  || key == 9 )
	{   // 엔터,TAB
		return true;
	}
	if(obj.event.shiftKey == true){
		obj.event.returnValue = false;
		return true;
    	}
	if (key == 91 || key == 92 || key == 93 || key == 229 || key == 21 || key == 25 || key == 19 ) return true;

	if (key >= 112 && key <= 123) {       // function key
		obj.event.returnValue = true;
		return true;
	}

	if ((key == 40) || (key == 38 )) {    // 위, 아래 화살표
		obj.event.returnValue = true;
		return true;
	}

	if (( key > 95) && ( key < 106 )) {   // 우측 키패드 숫자 key
		obj.event.returnValue = true;
		return true;
	}

	if (( key > 47) && ( key < 58 )) {    // 키보드 상단 숫자 key
		obj.event.returnValue = true;
		return true;
	}
	if (( key == 37)||( key == 39 )||( key == 46)||( key == 8 )) {  // 좌,우 화살표,DEL,BACKS,-
		obj.event.returnValue = true;
		return true;
	}
	if (obj.event.altKey || obj.event.shiftKey || obj.event.ctrlKey)
	{
		obj.event.returnValue = true;
		return true;
	}
	if (( key > 36) && ( key < 41 ))
	{    // 좌,상,우,하 화살표
		obj.event.returnValue = true;
		return true;
	}
	if (( key > 32) && ( key < 37 ))
	{    // Page-Up, Page-Down, End, Home
		obj.event.returnValue = true;
		return true;
	}
	if (( key == 45) || ( key == 46 ) || ( key == 144 ))
	{    // Insert,Delete,NumLock
		obj.event.returnValue = true;
		return true;
	}
	if (( key == 46)||( key == 8 )||( key == 17)||( key == 18 )||( key == 20)||( key == 27 ))
	{  // DEL,BACKS,Ctrl,Alt,CapsLock,Esc
		obj.event.returnValue = true;
		return true;
	}
	obj.event.returnValue=false;
	//alert('숫자만 입력 가능합니다.');
	return false;
}

/*
*기능 : 날짜변환
* @param key event
* @return
*/
function convertDate(obj)
{
if (!chk_Number(obj.value)) return false;
	str = obj.value;
	len=obj.value.length;
    switch(len)  {
		case 4:
			str = str + "-";
			obj.value = str;
			break;
       	case 7:
			str = str + "-";
			obj.value = str;
			break;
	}
}

/*
*기능 : 숫자체크
* @param key event
* @return
*/
function chk_Number(str)
{
  RefString = "-1234567890";
  DecimalPoints = 0;
  for (var i=0; i<str.length; i++)
  {
	  TempChar = str.substring(i, i+1);
	  if (RefString.indexOf(TempChar,0) == -1) { return false; }
  }
  return true;
}

/*
*기능 : - 제거
* @param key event
* @return
*/
function delete_Char(source,char)
{
	//alert("s="+source+ "char="+char);
	if (typeof(source) == "string")
	{
		//alert("s1");
		return replace(source,char,'');
	}
	else if (typeof(source) == "object")
	{
		//alert("s2");
		source.value = replace(source.value,char,'');
	}
	else
	{
		//alert("s3");
		alert("지원하지 않는 형태입니다.");
	}
}

/*
*기능 : 대체
* @param key event
* @return
*/
function replace(str,regular_expression,replacement_string)
{
	var re = new RegExp(regular_expression,"ig");
	return str.replace(re,replacement_string);
 	return str;
}

/*
*기능 : trim
* @param key event
* @return
*/
function trim(str)
{
  var rV;

  rV = ltrim(str);
  rV = rtrim(rV);
  return (rV);
}

/*
*기능 : 오른쪽트림
* @param key event
* @return
*/
function rtrim(str)
{
  var index;
  var ch = " ";

  if (chk_Blank(str)) return (str);
  for (index = str.length - 1; index >= 0; index--)
    if (str.charAt(index) != ch) break;
  return (str.substring(0, index + 1));
}

/*
*기능 : 년체크
* @param key event
* @return
*/
function chk_Year(str)
{
	var year;
	var to;
	today = new Date();
	to    = today.getYear() + 100;
	to    += "";
	if (to.length == 2) to = (parseInt(to, 10) + 1900) + "";

	str   = trim(str);
	year  = get_Year(str);
	//alert("year="+year);
	return (chk_Between(year, "1901", to));
}

/*
*기능 : 년도구하기
* @param key event
* @return
*/
function get_Year(str)
{
	str = delete_Char(str,'-');
	str = trim(str);
	return (str.substr(0, 4));
}

/*
*기능 : 왼쪽트림
* @param key event
* @return
*/
function ltrim(str)
{
  var index;
  var len;
  var ch = " ";

  if (chk_Blank(str)) return (str);
  len = str.length;
  for (index = 0; index < str.length; index++, len--)
    if (str.charAt(index) != ch) break;
  return (str.substring(index, index + len));
}

/*
*기능 : 블랭크체크
* @param key event
* @return
*/
function chk_Blank(str)
{
  var rV = false;

  if ((str == "") || (str == null) || (str == "null")) rV = true;
  return rV;
}

/*
*기능 : 월구하기
* @param key event
* @return
*/
function get_Month(str)
{
	str = delete_Char(str,'-');
	str = trim(str);
	return (str.substr(4, 2));
}

/*
*기능 : 일자구하기
* @param key event
* @return
*/
function get_Day(str)
{
	str = delete_Char(str,'-');
	str = trim(str);
	return (str.substr(6, 2));
}

/*
*기능 : 마지막날짜 구하기
* @param key event
* @return
*/
function get_LastDay(str)
{

  var maxday = new Array("31", "28", "31", "30", "31", "30",
                         "31", "31", "30", "31", "30", "31");
  var month = get_Month(str);
  var day   = maxday[parseInt(month, 10) - 1];

  if (chk_LeapYear(str))
    if (month == "02") day = "29";

  return (day);
}

/*
*기능 : 윤년
* @param key event
* @return
*/
function chk_LeapYear(str)
{
  var year;

  str = trim(str);
  year = parseInt(get_Year(str), 10);
  if ( (year%4   == 0) &&
      ((year%100 != 0) || (year%400 == 0)) ) return (true);
  return (false);
}

/*
*기능 : 월 체크
* @param key event
* @return
*/
function chk_Month(str)
{
  var month;
  str   = trim(str);
  month = get_Month(str);
  return (chk_Between(month, "01", "12"));
}

/*
*기능 : 일체크
* @param key event
* @return
*/
function chk_Day(str)
{
  //var str = obj.value;
  var day;
  str      = trim(str);
  var last_day = get_LastDay(str);
  //alert("last_day="+last_day);
  day      = get_Day(str);
  //alert(chk_Between(day, "01", last_day));
  return (chk_Between(day, "01", last_day));

}

/*
*기능 : 정해진 구간에 들어가는지 체크
* @param key event
* @return
*/
function chk_Between(str, from, to)
{
  if ((str < from) || (str > to)) return (false);
  return (true);
}

/*
*기능 : valid체크
* @param key event
* @return
*/
function valDate(obj,gu){
	convert_Date(obj);
	if(gu== "1"){
    	if(obj.value.indexOf("-") == -1){
    	    if(obj.value.length > 0){
    	        alert("일자를 정확히 입력해 주십시요");
    	        obj.value = "";
    	        obj.focus();
    	        return false;
    	    }
    	}
    }else if(gu== "2"){
    	if(obj.value.indexOf("-") == -1){
    	    if(obj.value.length > 0){
    	        alert("일자를 정확히 입력해 주십시요");
    	        obj.value = "";
    	        obj.focus();
    	        return false;
    	    }
    	}
    }
}

/*
*기능 : 온키업시 날짜변환
* @param key event
* @return
*/
function convert_Date(obj)
{
	obj.value = delete_Char(obj.value,'-');

	switch(obj.value.length)
	{
		case 0 :
				return;
				break;
		case 6 :
				if (parseInt(obj.value.substring(0,2),10)  > 80 )
				{
					obj.value = "19"+obj.value;
				}
				else
				{
					obj.value = "20"+obj.value;
				}
				break;
		case 8 :
				break;
		default :
				obj.focus();
				return;
				break;
	}
	var realDate = chk_Date(obj.value);
	if (!realDate)
	{
		obj.focus();
		return;
	}

	str = obj.value;
	str = str.substring(0,4) + "-" + str.substring(4,6) + "-" + str.substring(6);
	obj.value = str;
}

/*
*기능 : 시작일과 종료일 날짜를 비교한다.
* @param daybef,dayaft
* @return true,false
*/
function CompareDte(daybef,dayaft) {

		daybef = daybef.replace("-","");
		daybef = daybef.replace("-","");//replace를 두번해야 - 2개 다 없어짐

		dayaft = dayaft.replace("-","");
		dayaft = dayaft.replace("-","");//replace를 두번해야 - 2개 다 없어짐

		daybef = new Date(daybef.substr(0,4), daybef.substr(4,2), daybef.substr(6,2));//희망일자 (년도,월,일)
		dayaft = new Date(dayaft.substr(0,4), dayaft.substr(4,2), dayaft.substr(6,2));//희망일자 (년도,월,일)

		daybef = daybef.getTime(); //1970년 1월 1일 00 시 00 분 00 초를 기준으로 한 시간으로 바꾸어줌
		dayaft = dayaft.getTime(); //1970년 1월 1일 00 시 00 분 00 초를 기준으로 한 시간으로 바꾸어줌

		count = daybef - dayaft;
		count = Math.floor(count/(24*3600*1000));

	    if(daybef != "" && dayaft != "" && count>0 )
		{
			return false ;
		}
		return true;
}

/*
*기능 : 입력시 날짜 오류검증을 한다.
* @param obj
* @return true,false
*/
function G_chk_Date(obj)
{
    var str = obj.value;
    //alert(str);
	str = delete_Char(str,'-');
	//alert("a1");
	str = trim(str);
	if (!chk_Number(str)) return (false);
	//alert("a2");

	if(str.length == 1 && str != "2") {
		alert("년도가 허용범위밖에 있습니다.");
		obj.value= "";
		return;
	}
	if(str.length == 4) {//년
		if(chk_Year(str) == false){
	  		alert("년도가 허용범위밖에 있습니다.");
	        obj.value= "";
	        return;
	    }
    }
	if(str.length == 6) {//월
		if(chk_Month(str) == false){
	  		alert("월이 허용범위밖에 있습니다.");
	        obj.value= "";
	        return;
	    }
    }
	if(str.length == 8) {//일
		if(chk_Day(str) == false){
	  		alert("일자가 허용범위밖에 있습니다.");
	        obj.value= "";
	        return;
	    }
    }
    if (str.length != 8)       return (false);
	return (true);
}





//*********************************************************
// 텍스트 입력폼 체크
//*********************************************************
function checkEmpty(formVar, text)
{       
	if (trim(formVar.value).length < 1) {
		alert("" + text + "");
		formVar.value="";
		formVar.focus();
		return false;
	} 
	return true;
}


function checkEmptyArray(vObj, vMsg) {

    if (vObj.length !=undefined) {
       for(iLoop=0; iLoop < vObj.length; iLoop++ ) {
           if (!checkEmpty(vObj[iLoop], vMsg)) return false;
       }
      
    } else {
        if (!checkEmpty(vObj, vMsg)) return false;
    }
    
    return true;
}

//*********************************************************
// 텍스트 입력폼 길이 체크
//*********************************************************
function checkLength(formVar, text, textlen)
{
	if (charBytesChk(formVar.value) < textlen) {
		alert("" + text + "  길이는 " + textlen + "자리 입니다!");
		formVar.focus();
		return false;
	}
	return true;
}

function checkLength2(formVar, text, textlen1, textlen2)
{
	if (charBytesChk(formVar.value) < textlen1 || charBytesChk(formVar.value) > textlen2) {
		alert("" + text + "는 " + textlen1 + "~" + textlen2 + "자 까지 가능합니다.");
		formVar.focus();
		return false;
	}
	return true;
}

function fileDelete(fileNo) {
	var winURL="/lib/file_delete.php?file_no="+ fileNo;

	window.location.href=winURL;
}

function fileUpCheck(vObj) {

    if (vObj.length !=undefined) {
 
       for(iLoop=0; iLoop < vObj.length; iLoop++ ) {
           if (!fileTypeCheck(vObj[iLoop])) return false;
       }
      
    } else {
        if (!fileTypeCheck(vObj)) return false;
    }
    
    return true;
}

function fileUpImageCheck(vObj) {

    if (vObj.length !=undefined) {
 
       for(iLoop=0; iLoop < vObj.length; iLoop++ ) {
           if (!fileImageTypeCheck(vObj[iLoop])) {
               vObj[iLoop].focus();
               return false;
           }    
       }
      
    } else {
        if (!fileImageTypeCheck(vObj)) {
            vObj.focus();   
            return false;
        }    
    }
    
    return true;
}
 
function fileTypeCheck(vObj) {
    var vVal = vObj.value;
    
    if (trim(vVal).length < 1) return true;
    
     vFile = vVal.slice(vVal.lastIndexOf("\\") + 1);
    
      if (hangulExist(vFile) )  {
          alert("파일명에 한글이 포함되어 있습니다.\n\n한글로 된 파일명은 Upload 할 수 없습니다.");
          return false;
      }
         
    vVal = vVal.toUpperCase();	
    
    if ( vVal.indexOf(".ALZ")  > 0) { return true; }
    else if( vVal.indexOf(".BMP")  > 0) { return true; }
    else if( vVal.indexOf(".DOC")  > 0) { return true; }
    else if( vVal.indexOf(".EXE")  > 0) { return true; }
    else if( vVal.indexOf(".GIF")  > 0) { return true; }
    else if( vVal.indexOf(".GUL")  > 0) { return true; }
    else if( vVal.indexOf(".HTM")  > 0) { return true; }
    else if( vVal.indexOf(".HWP")  > 0) { return true; }
    else if( vVal.indexOf(".JPG")  > 0) { return true; }
    else if( vVal.indexOf(".PDF")  > 0) { return true; }
    else if( vVal.indexOf(".PPT")  > 0) { return true; }
    else if( vVal.indexOf(".RAR")  > 0) { return true; }
    else if( vVal.indexOf(".TXT")  > 0) { return true; }
    else if( vVal.indexOf(".WAV")  > 0) { return true; }
    else if( vVal.indexOf(".XLS")  > 0) { return true; }
    else if( vVal.indexOf(".ZIP")  > 0) { return true; }
    
    alert("확장자가 [alz, bmp, doc, exe, gif, gul, htm, hwp, jpg, pdf, ppt, rar, txt, wav, xls, zip ]인 파일만 올릴 수 있습니다.");
    vObj.focus();
    return false;
	
}

function fileImageTypeCheck(vObj) {
    var vVal = vObj.value;
    
    if (trim(vVal).length < 1) return true;

     vFile = vVal.slice(vVal.lastIndexOf("\\") + 1);

 
     if (hangulExist(vFile) )  {
          alert("파일명에 한글이 포함되어 있습니다.\n\n한글로 된 파일명은 Upload 할 수 없습니다.");
          return false;
     }
 
    vVal = vVal.toUpperCase();	
    
    if( vVal.indexOf(".GIF")  > 0) { return true; }
    else if( vVal.indexOf(".JPG")  > 0) { return true; }
    else if( vVal.indexOf(".BMP")  > 0) { return true; }
    
    alert("확장자가 [gif, jpg, bmp]인 파일만 올릴 수 있습니다.");

    return false;
	
}

function imageWidthResize(vId, vImgFile, vSize) {
    	         
    var img_obj = new Image();
    img_obj.src = vImgFile;

    if ( parseInt(img_obj.width) > parseInt(vSize) ) {
        document.all[vId].width = vSize;
    }    
}                   


//*********************************************************
// 날짜 선택용 캘린더 보기(오늘날짜까지만 나오는 캘린더)
//*********************************************************
function show_cal(first_second,top_height){
 
	document.frames["calframe"].document.location="/lib/opencal_all.html";
	document.all["calendar"].style.visibility = "visible";
	document.all["calendar"].style.top=top_height;
	document.all["calendar"].style.left= first_second - 65 ;//;259+((first_second-1)*72);
}
 

//*********************************************************
// 날짜 선택용 캘린더 보기(오늘날짜까지만 나오는 캘린더)
//*********************************************************
function show_calAll(first_second,top_height){
	document.frames["calframe"].document.location="/lib/opencal_all.html";
	document.all["calendar"].style.visibility = "visible";
	document.all["calendar"].style.top=top_height;
	document.all["calendar"].style.left= first_second  - 65 ;
}

//*********************************************************
// 배열형식의 박스 선택 체크
//*********************************************************
function checkArrayEmpty(formVar, text, limit) {
	var cnt = 0;
	if(typeof(limit) == "undefined") limit = 1;

	if(formVar.length) {
		for(i=0;i<formVar.length;i++) {
			if(formVar[i].checked) {
				cnt++;
			}
		}
	} else {
		if(formVar.checked) {
			cnt++;
		}
	}

	if(cnt < limit)	{
		alert("" + text + "");
		if(formVar.length) {
			formVar[0].focus(); 
		} else { 
			formVar.focus(); 
		}

		return false;
	}

	return true;
}

//*********************************************************
// 이메일 체크
//*********************************************************
function checkEmail(formVar) {
	var str = formVar.value;
	var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
	if (re.test(str) == true) { return true; }

	alert('잘못된 EMAIL 형식입니다.');
	//formVar.focus();
	//formVar.select();
	return false;
}


function writeText(id, str) {
	var strTag = str;

	if (document.all)
		document.all[id].innerHTML = strTag;
	else
		with (document[id].document) {
			open();
			write(strTag);
			close();
		}
}

function checkKeyNum(formVar) {
  strKey=formVar.value;
  if(isNaN(strKey) || strKey==" " || strKey.indexOf('0x') > 0){
	alert("숫자만 가능합니다.");
	formVar.value="";
	formVar.focus();	
  }
  if(strKey.match("-"))
	formVar.value=strKey.replace("-","");
  
  
	
}

function checkEngNum(formVar, txt) {
  var strVar = formVar.value.toLowerCase() ;
  
  for(var i = 0; i < strVar.length; i++) {
	 var chr = strVar.substr(i,1);
	 if((chr < '0' || chr > '9') && (chr < 'a' || chr > 'z') ) {
		alert(txt);
		formVar.focus();
		return false;
	 }
  }
  return true;   
}

function checkEngNum2(strVar, txt) {
  
  for(var i = 0; i < strVar.length; i++) {
	 var chr = strVar.substr(i,1);
	 if((chr < '0' || chr > '9') && (chr < 'a' || chr > 'z') ) {
		alert(txt);
		return false;
	 }
  }
  return true;   
}

function checkEngNum3(formVar, txt) {
  var strVar = formVar.value.toLowerCase() ;
  
  for(var i = 0; i < strVar.length; i++) {
	 var chr = strVar.substr(i,1);
	 if ( chr != ' ')  {
		 if((chr < '0' || chr > '9') && (chr < 'a' || chr > 'z') ) {
			alert(txt);
			formVar.focus();
			return false;
		 }
		}
  }
  return true;   
}


/*
*기능:구분자를 이용한 배열수
*@param text:문자열
*/
function splitCharCount(vText, strDel){
 
     var strVal  = trim(vText);
   
    if(strVal == "" ) return 0;
 
    var arr = strVal.split(strDel);
     
    fcnt = 0
    for(i=0; i<arr.length; i++){
       if(arr[i].length > 0) fcnt ++;
    }
    
    return fcnt ;
}

//*********************************************************
// 입력시 항목 checked 하기
//
//  parameter	:	1. form.object
//					2. string
//	return		:
//*********************************************************
function checkSubjectCode(formVar, str) {
  if(trim(str) != '') {
	formVar.checked = true;
  } else {
	formVar.checked = false;
  }
}


function checkEngKor(formVar, txt) {

  var strVar = formVar.value;
  var reg = /[^a-zㄱ-힣]/i; 
  if( reg.test(strVar) ){ 
	alert(txt);
	formVar.focus();
	return false;
  }
  return true;   
}



function checkEngKorNum(strVar, txt) {

  var reg = /[^a-zㄱ-힣0-9]/i; 
  if( reg.test(strVar) ){ 
	alert(txt);
	return false;
  }
  return true;   
}

function checkEngKorNumField(formVar, txt) {

  var strVar = formVar.value;
  var reg = /[^a-zㄱ-힣0-9]/i; 
  if( reg.test(strVar) ){ 
	alert(txt);
	formVar.focus();
	return false;
  }
  return true;   
}

function checkRadioEmpty(formVar, vMag) {
    bFlag = false;
    
    if (formVar.length !=undefined) {
 
       for(iLoop=0; iLoop < formVar.length; iLoop++ ) {
          if (formVar[iLoop].checked) bFlag = true;
       }
      
    } else {
        if (formVar.checked) bFlag = true;  
    }
    
    if (!bFlag) alert(vMag);
    return  bFlag;    
    
}  

function checkRadioValue(formVar) {
    retVal = "";
    
    if (formVar.length !=undefined) {
 
       for(iLoop=0; iLoop < formVar.length; iLoop++ ) {
          if (formVar[iLoop].checked) {
             if (retVal != "" ) retVal = retVal +",";
             retVal = retVal + formVar[iLoop].value; 
          }   
       }
      
    } else {
        if (formVar.checked) retVal =formVar.value; 
    }
    
    return  retVal;    
    
}  


function fileDownload(fileNo) {

    var winURL="/lib/file_download.php?file_no=" +fileNo;
	window.location.href=winURL;

}

//*********************************************************
// 주민등록번호 체크
//*********************************************************
function checkRegNum(jumin){
	ch1= jumin.charAt(0);
	ch2= jumin.charAt(1);
	ch3= jumin.charAt(2);
	ch4= jumin.charAt(3);
	ch5= jumin.charAt(4);
	ch6= jumin.charAt(5);
	ch7= jumin.charAt(6);
	ch8= jumin.charAt(7);
	ch9= jumin.charAt(8);
	ch10= jumin.charAt(9);
	ch11= jumin.charAt(10);
	ch12= jumin.charAt(11);
	ch13= jumin.charAt(12);
	kflag = 2;
	chtot =0;
	ch_buf = ch1 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch2 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch3 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch4 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch5 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch6 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch7 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch8 * kflag;
	chtot = chtot + ch_buf;
	kflag=2;
	ch_buf = ch9 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch10 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch11 * kflag;
	chtot = chtot + ch_buf;
	kflag++;
	ch_buf = ch12 * kflag;
	chtot = chtot + ch_buf;
	chtot = chtot % 11;
	last = 11 - chtot;
	if(last == 10)
	last = 0;
	if(last == 11)
	last = 1;
	if(last == ch13)
	return true;
	else
	return false;
}
 
function printopen() {
	window.open('/lib/print.php','printview','toolbar=no,location=No,scrollbars=yes,width=716 height=600, resizable=yes');
}
  
/*
*기능 : 영문자와 숫자가 조합되었는지 점검
* @param key event
* @return
*/
function checkIncEngNum(formVar, txt) {
  var strVar    = formVar.value;
  var cntNumber = 0;
  var cntChar   = 0;

  for(var i = 0; i < strVar.length; i++) {
	var chr = strVar.substr(i,1);

    if( !(chr < '0' || chr > '9') ) { cntNumber++; }
    if( !(chr < 'a' || chr > 'z') ) { cntChar++; }
    if( !(chr < 'A' || chr > 'Z') ) { cntChar++; }
  }

  if( cntNumber == 0 || cntChar == 0 || ((cntNumber + cntChar) != strVar.length) ) {
	alert(txt);
	formVar.focus();
    return false;
  }

  return true;   
}



/**
 * 쿠키값 추출
 * @param cookieName 쿠키명
 */
function getCookie( cookieName )
{
   var search = cookieName + "=";
   var cookie = document.cookie;

   // 현재 쿠키가 존재할 경우
   if( cookie.length > 0 )
   {
      // 해당 쿠키명이 존재하는지 검색한 후 존재하면 위치를 리턴.
      startIndex = cookie.indexOf( cookieName );

      // 만약 존재한다면
      if( startIndex != -1 )
      {
         // 값을 얻어내기 위해 시작 인덱스 조절
         startIndex += cookieName.length;

         // 값을 얻어내기 위해 종료 인덱스 추출
         endIndex = cookie.indexOf( ";", startIndex );

         // 만약 종료 인덱스를 못찾게 되면 쿠키 전체길이로 설정
         if( endIndex == -1) endIndex = cookie.length;

         // 쿠키값을 추출하여 리턴
         return unescape( cookie.substring( startIndex + 1, endIndex ) );
      } else {
         // 쿠키 내에 해당 쿠키가 존재하지 않을 경우
         return false;
      }
   } else {
      // 쿠키 자체가 없을 경우
      return false;
   }
}

 

/**
* 쿠키 설정
* @param cookieName 쿠키명
* @param cookieValue 쿠키값
* @param expireDay 쿠키 유효날짜
*/
function setCookie( cookieName, cookieValue, expireDate )
{
   var today = new Date();
   today.setDate( today.getDate() + parseInt( expireDate ) );
   document.cookie = cookieName + "=" + escape( cookieValue ) + "; path=/; expires=" + today.toGMTString() + ";"
}

/**
* 쿠키 삭제
* @param cookieName 삭제할 쿠키명
*/
function deleteCookie( cookieName )
{
   var expireDate = new Date();
  
   //어제 날짜를 쿠키 소멸 날짜로 설정한다.
   expireDate.setDate( expireDate.getDate() - 1 );
   document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
}

function fCheckKorEngOnly(vChar, vMsg)
{
   if ( vChar == null ) return false ;
   
   for(var i=0; i < vChar.length; i++){ 

     var c = vChar.charCodeAt(i); 
 
     //( 0xAC00 <= c && c <= 0xD7A3 ) 초중종성이 모인 한글자 
     //( 0x3131 <= c && c <= 0x318E ) 자음 모음 

     if(!( ( 0xAC00 <= c && c <= 0xD7A3 ) || ( 0x3131 <= c && c <= 0x318E ) ||
           ( 0x61   <= c && c <= 0x7A   ) || ( 0x41   <= c && c <= 0x5A   ) )
       ) {
           alert(vMsg);
           return false ; 
         }
   }  
   return true ;    
    
} 
 
 
// 한글이외의 문자가 있을경우 false 
// 한자나 숫자 영문의 경우 false 

function checkKoreanOnly( koreanChar ) {
   
   if ( koreanChar == null ) return false ;
   
   for(var i=0; i < koreanChar.length; i++){ 

     var c=koreanChar.charCodeAt(i); 

     //( 0xAC00 <= c && c <= 0xD7A3 ) 초중종성이 모인 한글자 
     //( 0x3131 <= c && c <= 0x318E ) 자음 모음 

     if( !( ( 0xAC00 <= c && c <= 0xD7A3 ) || ( 0x3131 <= c && c <= 0x318E ) ) ) {      
        return false ; 
     }
   }  
   return true ;
}

// 영문 이외의 캐릭터가 있을경우 false 

function checkEnglishOnly( englishChar ) {  
    
    if ( englishChar == null ) return false ;
       
    for( var i=0; i < englishChar.length;i++){          
       var c=englishChar.charCodeAt(i);       
       if( !( (  0x61 <= c && c <= 0x7A ) || ( 0x41 <= c && c <= 0x5A ) ) ) {         
        return false ;       
       }
     }      
    return true ;
     
} 

// 숫자 이외의 캐릭터가 있을경우 false 

function checkDigitOnly( digitChar ) {  
    
    if ( digitChar == null ) return false ;
       
    for(var i=0;i<digitChar.length;i++){          
       var c=digitChar.charCodeAt(i);       
       if( !(  0x30 <= c && c <= 0x39 ) ) {         
        return false ;       
       }
     }      
    return true ;
     
}

 
  function fShowMovie(vId, vUrl, vWidth, vHeight)
{
         if ( vUrl == "" ) return;
    
         document.write("<OBJECT  id="+vId+" name="+vId+" classid=CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6 ");
         document.write("        width='"+ vWidth +"' height='"+vHeight+"' type=application/x-oleobject VIEWASTEXT standby='로딩중입니다.'>    ");
         document.write("   <PARAM NAME='AnimationAtStart' VALUE='0'>                                                        ");
         document.write("   <PARAM NAME='URL' VALUE='"+ vUrl + "'>                                                           ");
         document.write("   <PARAM NAME='AutoStart' VALUE='1'>                                                               ");
         document.write("   <PARAM NAME='PlayCount' VALUE='1'>                                                               ");
         document.write("   <PARAM NAME='Volume' VALUE='70'>                                                                 ");
         document.write("   <PARAM NAME='enableContextMenu' VALUE='0'>                                                       ");
         document.write("   <PARAM NAME='currrentMarker' VALUE='1'>                                                          ");
         document.write("   <PARAM NAME='ShowStatusBar' VALUE='1'>                                                           ");
         document.write("   <param name='ShowControls' value='true'>                                                         ");  
         document.write("   <param name='ShowAudioControls' value='true'>                                                    ");
         document.write("   <param name='ShowDisplay' value='false'>                                                         ");
         document.write("   <param name='ShowTracker' value='true'>                                                          ");
         document.write("   <param name='ShowStatusBar' value='true'>                                                        ");
         document.write("   <param name='EnablePositionControls' value='true'>                                               ");   
         document.write("   <param name='EnableTracker' value='true'>                                                        ");
         document.write("   <PARAM NAME='currentPosition' VALUE='1'>                                                         ");
         document.write("   <PARAM NAME='defaultFrame' VALUE='0'>                                                            ");

         document.write("   <PARAM NAME='wmode' VALUE='transparent'>                                                         ");
         document.write("</OBJECT>                                                                                           ");
}<!-- 
 -->
