/*
 ******************************************************************************************
 * PROGRAM ID   :   common.js
 * Description  :	공통적으로 사용되는 자바스크립트 함수
 * Input Parm   :
 * Output Parm  :
 * Include FILE :
 * Using Table  :
 * Return Value :	None
 * Sub Function :	None
 * SE Name          Description                                             Date
 * ------------   -----------------------------------------------------   -----------
 *  ZZERG1004      Initial Create									   	    2009.02.
 ****************************************************************************************
 */

	/************************************************************************************
     *
	 *	Function Name :
     * 	Description :
     *	Return Value : Yes
     *
	 ************************************************************************************/


	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

	function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
	    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
	  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
	}

	MM_reloadPage(true);

	function MM_popupMsg(msg) { //v1.0
	  alert(msg);
	}

  function MM_showHideLayers() { //v6.0
    var i,p,v,obj,args=MM_showHideLayers.arguments;
    for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
      if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
      obj.visibility=v; }
  }

	function NewWin(a,name,pro) {
	  OpenWin = window.open(a,name,pro);
	  OpenWin.focus();
	}

  function CenterWindow(mypage, myname, w, h, scroll) {
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll;
  win = window.open(mypage, myname, winprops);
  }

	/************************************************************************************
     *
	 *	Function Name : LengthCheck()
     * 	Description   : 문자열의 길이를 체크하여 정확성 여부를 판단하여준다
     *	Return Value  : True
     *                  False
     *  usage : if(!LengthCheck(1,100,f.ar_tel_no.value,"MESSAGE",f.ar_tel_no)) return;
	 *					  if(!LengthCheck(1,100,f.ar_tel_no.value,,"Message", null )) return;
	 *					  if(!LengthCheck(1,100,f.ar_tel_no.value,,null, null )) return;
	 ************************************************************************************/
	function LengthCheck(min,max,data,strErrMessage,focus) {

		var count = 0;
		for ( var i=0; i < data.length; i++ ) {
			//if( data.charCodeAt(i) < 127 )
				count++;
			//else
			//	count = count + 2;
		}

		if ((count >= min) && (count <= max) ) return  true;

		if ( strErrMessage != null  ) alert( strErrMessage );

		if ( focus != null ) {
			focus.focus();
			focus.select();
		}

		return false;
	}

	/************************************************************************************
     *
	 *	Function Name : IsTypeCheck()
     * 	Description : Data의 Type을 체크하여준다
     *	Return Value : Yes
     *  usage : 		if(!IsTypeCheck("AN",f.ar_tel_no.value,"MESSAGE",f.ar_tel_no)) return;
	 *					if(!IsTypeCheck("AN",f.ar_tel_no.value,"Message", null )) return;
	 *					if(!IsTypeCheck("AN",f.ar_tel_no.value,null, null )) return;
	 ************************************************************************************/
	function IsTypeCheck(type,data,strErrMessage,focus) {
		var count=0;
		var bSwitch = true;

		switch (type.toUpperCase()) {
			case 'ID' : // id check (영숫자 및 @,_,-,.]만 가능
				for ( var i=0; i < data.length; i++ ) {
					if ( !((data.charCodeAt(i)>47 && data.charCodeAt(i)<58) ||  // 숫자
					     (data.charCodeAt(i)>64 && data.charCodeAt(i)<91) || 	// 영문대문자
					     (data.charCodeAt(i)>96 && data.charCodeAt(i)<123) ||	// 영문소문자
					     (data.charCodeAt(i)==64) || 							// @
					     (data.charCodeAt(i)==46) || 							// .
					     (data.charCodeAt(i)==95) || 							// _
					     (data.charCodeAt(i)==45))  ) {							// -
						bSwitch = false;
						break;
					}
				}
				break;
			case 'F' : //실수체크...
				var Dotcount = 0;
				for ( var i=0; i < data.length; i++ ) {
					if ( data.charCodeAt(i) == 46 ) {
						Dotcount++;
						if ( Dotcount > 1 ){ //도트가 두번이상 표기 되었는지확인하다.
							bSwitch = false;
							break;
						}

						if(i == 0 ) {    //도트가 맨앞에 오지 않았는지 확인한다.
							bSwitch = false;
							break;
						}
					}
					else {
						if ( data.charCodeAt(i) < 48 || data.charCodeAt(i) > 57) {
							bSwitch = false;
							break;
						}
					}
				}
				break;
			case 'FLOAT' : //Return number value 숫자,도트 이외 문자는 자름
				var nRtn="";
				var sData = data.value;
				var Dotcount = 0;
				for ( var i=0; i < sData.length; i++ ) {
					if ( (sData.charCodeAt(i) > 47 && sData.charCodeAt(i) < 58) || sData.charCodeAt(i) == 46) {
						if ( sData.charCodeAt(i) == 46 ) {
							Dotcount++;
							if ( Dotcount > 1 ){ //도트가 두번이상 표기 되었는지확인하다.
								break;
							}

							if(i == 0 ) {    //도트가 맨앞에 오지 않았는지 확인한다.
								break;
							}
						}
						nRtn = nRtn+sData.charAt(i);
					}
				}
				data.value = nRtn;
				return;
				break;
			case 'N' : //Number ASCII Code 48 ~ 57
				for ( var i=0; i < data.length; i++ ) {
					if ( data.charCodeAt(i) < 48 || data.charCodeAt(i) > 57) {
						bSwitch = false;
						break;
					}
				}
				break;
			case 'NUM' : //Return number value 숫자이외 문자는 자름
				var nRtn="";
				var sData = data.value;
				for ( var i=0; i < sData.length; i++ ) {
					if ( sData.charCodeAt(i) > 47 && sData.charCodeAt(i) < 58) {
						nRtn = nRtn+sData.charAt(i);
					}
				}
				data.value = nRtn;
				return;
				break;
			case 'NH' : //Number(48~57) + Hippen( 45 )
				for ( var i=0; i < data.length; i++ ) {
					if ( data.charCodeAt(i) != 45 ) {
						if ( data.charCodeAt(i) < 48 || data.charCodeAt(i) > 57){
							bSwitch = false;
							break;
						}
					}
				}
				break;
			case 'A' : //Alphabetic( 65~90)
				data = data.toUpperCase()
				for ( var i=0; i < data.length; i++ ) {
					if (( data.charCodeAt(i) < 65 || data.charCodeAt(i) > 90 )&& ( data.charCodeAt(i) != 32)) {
							bSwitch = false;
							break;
					}
				}
				break;
			case 'AN' : //AlphaNumeric
				data = data.toUpperCase()
				for ( var i=0; i < data.length; i++ ) {
					if (( data.charCodeAt(i) < 48 || data.charCodeAt(i) > 57)&& ( data.charCodeAt(i) != 32)) {
						if ( data.charCodeAt(i) < 65 || data.charCodeAt(i) > 90 ) {
							bSwitch = false;
							break;
						}
					}
				}
				break;
			case 'ANH' : //AlphaNumeric
				data = data.toUpperCase()
				for ( var i=0; i < data.length; i++ ) {
					if (( data.charCodeAt(i) < 48 || data.charCodeAt(i) > 57) && ( data.charCodeAt(i) != 32) && ( data.charCodeAt(i) != 45)  ) {
						if ( data.charCodeAt(i) < 65 || data.charCodeAt(i) > 90 ) {
							bSwitch = false;
							break;
						}
					}
				}
				break;
			case 'ADH' : //Alphabetic( 65~90) + 도트(46) + Hippen(45) + 공백(32)
				data = data.toUpperCase()
				for ( var i=0; i < data.length; i++ ) {
					if ( (data.charCodeAt(i) < 65 && data.charCodeAt(i) != 45 && data.charCodeAt(i) != 46 && data.charCodeAt(i) != 32) || (data.charCodeAt(i) > 90 && data.charCodeAt(i) != 45 && data.charCodeAt(i) != 46 && data.charCodeAt(i) != 32) ) {
							bSwitch = false;
							break;
						}
				}
				break;
			case 'ENG' : //Only English 숫자 포함
				for ( var i=0; i < data.length; i++ ) {
					if ( data.charCodeAt(i) > 127  ) {
						bSwitch = false;
						break;
					}
				}
				break;
			case 'KOR' : //Only Korean
				for ( var i=0; i < data.length; i++ ) {
					if ( data.charCodeAt(i) < 0xAC00 || data.charCodeAt(i) > 0xD7A3){
						if (( data.charCodeAt(i) < 12593 || data.charCodeAt(i) > 12643 ) && ( data.charCodeAt(i) != 32)) {
							bSwitch = false;
							break;
						}
					}
				}
				break;
			case 'B' : //Blank 문자열중 빈공백 체크 마지막이 공백이라도 false
				for( var i=0; i<data.length; i++) {
					if ( data.charCodeAt(i) == 32 ) {
						bSwitch = false;
						break;
					}
				}
				break;
			case 'BA' : //Blank ALL Space만 입력한 경우
				bSwitch = false;
				for( var i=0; i<data.length; i++) {
					if ( data.charCodeAt(i) != 32 ) {
						bSwitch = true;
						break;
					}
				}
				break;
			case 'E' : //Empty 비어있는 문자열 체크 SPACE만 들어 온경우 체크
				//if( data.length < 1 ) {
				//	bSwitch = false;
				//	break;
				//}

				for( var i=0; i<data.length; i++) {
					if ( data.charCodeAt(i) == 32 ) count++;
				}

				if ( data.length > 0 && count == data.length ) bSwitch = false;

				break;
			case 'EMAIL' : //EMAIL Check
				var len = data.length;
				var strEMail = data.split('@');

				for( var i=0; i<len; i++) {
					if ( data.charCodeAt(i) == 32 ) {
						bSwitch = false;
						break;
					}
					if ( data.charAt(i)==".") count++;
				}

				if( bSwitch && len > 0  ) {
					if ((count==0) || (strEMail.length != 2 )) bSwitch = false;
				}

				break;
			case 'SSN' : // 주민등록번호체크
				if( data.length != 13 ) {
					bSwitch = false;
					break;
				}
				var sum_1 = 0;
				var sum_2 = 0;
				var at = 0;
				sum_1 = (data.charAt(0)*2)+(data.charAt(1)*3)+(data.charAt(2)*4)+(data.charAt(3)*5)+(data.charAt(4)*6)+(data.charAt(5)*7)+(data.charAt(6)*8)+(data.charAt(7)*9)+(data.charAt(8)*2)+(data.charAt(9)*3)+(data.charAt(10)*4)+(data.charAt(11)*5);
				sum_2 = sum_1%11;

				if (sum_2 == 0) {
				    at = 10;
				} else {
				    if (sum_2 == 1) {
				        at = 11;
				    } else {
				        at = sum_2;
				    }
				}

				att = (11-at);

				if (data.charAt(12) != att) bSwitch = false;

				break;
			case 'DATE' : // DATE Check Input : YYYYMMDD

				if( data.length != 8 ) {
					bSwitch = false;
					break;
				}

				var strDayear = data.substr(0, 4);
				var strMonth = data.substr(4, 2);
				var strDay = data.substr(6, 2);
				LastDay = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

				if ((strDayear % 4 == 0) && (strDayear % 100 != 0) || (strDayear % 400 == 0)) {
					LastDay[1] = 29;
				}

				if ((strMonth <= 0) || (strMonth > 12)) {
					bSwitch = false;
					break;
				}

				if ((strDay > LastDay[strMonth-1]) || (strDay <= 0)) {
					bSwitch = false;
				}

				break;
			case 'YYYYMM' : // DATE Check Input : YYYYMM

				if( data.length != 6 ) {
					bSwitch = false;
					break;
				}

				var strDayear = data.substr(0, 4);
				var strMonth = data.substr(4, 2);

				if ((strDayear % 4 == 0) && (strDayear % 100 != 0) || (strDayear % 400 == 0)) {
				}

				if ((strMonth <= 0) || (strMonth > 12)) {
					bSwitch = false;

				}
       			break;

			case 'TEL' : // Phone Number Check
				for ( var i=0; i < data.length; i++ ) {
					// 45 -> '-'
					if ( data.charCodeAt(i) != 45 ) {
						// 48 -> '0' , 57 -> '9'
						if ( data.charCodeAt(i) < 48 || data.charCodeAt(i) > 57) {
							bSwitch = false;
							break;
						}
					}
				}

				if( bSwitch && data.length > 0) {
					if( data.length < 7 || data.length > 13 ) bSwitch = false;
				}

				break;
				
			case 'ZIPCODE' : // Phone Number Check
				for ( var i=0; i < data.length; i++ ) {
					// 45 -> '-'
					if ( data.charCodeAt(i) != 45 ) {
						// 48 -> '0' , 57 -> '9'
						if ( data.charCodeAt(i) < 48 || data.charCodeAt(i) > 57) {
							bSwitch = false;
							break;
						}
					}
				}

				if( bSwitch && data.length > 0) {
					if(!(data.length == 6 || data.length == 7)) bSwitch = false;
				}

				break;
				
			case 'SQ' : // Single Quotation Check
				for ( var i=0; i < data.length; i++ ) {
					if ( data.charAt(i) == "'" ) {
						bSwitch = false;
						break;
					}
				}
				break;

			case 'DQ' : // Double Quotation Check
				for ( var i=0; i < data.length; i++ ) {
					if ( data.charAt(i) == '"' ) {
						bSwitch = false;
						break;
					}
				}
				break;

			case 'FILENAMECHK' : // FILEEXT CHECK
				if(data != ""){
					dataext = data.toUpperCase();

					if ( "/JSP/ASP/PHP/EXE/BAT/".indexOf(dataext) > -1 ) {
							bSwitch = false;
							break;
					}
					break;
				}
				break;
		}
		//정상적이면
		if (bSwitch) return true;

		//비정상적인 경우 메세지가 있는 경우
		if ( strErrMessage != null  ) alert( strErrMessage );

		if ( focus != null ) {
		
			// fckeditor사용시 focus 에러때문에 try사용.
			try {
				focus.focus();
				focus.select();
			}
			catch(e) {
			}
		}

		return false;
	}


   /************************************************************************************
    *  Function Name : NumCheck()
    *  Description : 숫자만 입력받는다.
    *                onkeypress Event에서 사용
    *  Return Value : Yes
    *  usage :   <input type=text name=num value='' size=25 maxlength=15 class=input2
    *                   onkeypress='NumCheck()'>
    ************************************************************************************/
    function NumCheck() {
        // ie에서만 작동 (45:마이너스(-), 46:도트(.))
        var keyCode = event.keyCode
        if (keyCode > 47 && keyCode < 58) {
        }
        else {
//          alert("문자는 사용할 수 없습니다."+"["+keyCode+"]")
            event.returnValue=false;
        }
    }

   /************************************************************************************
    *  Function Name : IsPdf()
    *  Description : 첨부파일이 PDF 인지 아닌지를 체크한다
    *  Return Value : Yes
    *  usage :
    ************************************************************************************/
    function IsPdf(fileName,strErrMessage,focus) {
        var bSwitch = true;
        if (fileName != null && fileName != "") {
             if (!fileName.match(/\.(pdf)$/i)) {
                bSwitch = false;
            }
        }
        		//정상적이면
    		if (bSwitch) return true;

    		//비정상적인 경우 메세지가 있는 경우
    		if ( strErrMessage != null  ) alert( strErrMessage );

    		if ( focus != null ) {
    			focus.focus();
    			focus.select();
    		}
    }
    
   /************************************************************************************
    *  Function Name : IsImage()
    *  Description : 첨부파일이 이미지 인지 아닌지를 체크한다
    *  Return Value : Yes
    *  usage :
    ************************************************************************************/
    function IsImage(fileName,strErrMessage,focus) {
        var bSwitch = true;
        if (fileName != null && fileName != "") {
            if (!fileName.match(/\.(jpg|gif|bmp|png|swf)$/i)) {
                bSwitch = false;
            } else {
			/*	try {
	          	var fso = new ActiveXObject("Scripting.FileSystemObject");
	            	
	            	// 해당 파일이 존재하지 않음
	            	if (!fso.FileExists(fileName)) bSwitch = false;
	            	
	            } catch(e) {
	            	alert(e.message);
	            }*/
            }
        }
        
    	//정상적이면
		if (bSwitch) return true;

		//비정상적인 경우 메세지가 있는 경우
		if ( strErrMessage != null  ) alert( strErrMessage );

		if ( focus != null ) {
			focus.focus();
			focus.select();
		}
    }

   /************************************************************************************
    *  Function Name : NewsZoomIn()
    *  Description : News관련 이미지를 ZoomIn한다
    *  Return Value : Yes
    *  usage :
    ************************************************************************************/
    function NewsZoomIn(news_type,news_no,seq) {

        if(seq==1){
            window.open("/bin/common/news_zoom.html?ar_news_type=" + news_type + "&ar_news_no=" + news_no +"&ar_seq=" + seq,'Zoom','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=180,height=160,location=center');
        }
        else{
            window.open("/bin/common/news_zoom.html?ar_news_type=" + news_type + "&ar_news_no=" + news_no +"&ar_seq=" + seq,'Zoom','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=420,height=340,location=center');
        }
    }

  /************************************************************************************
    *  Function Name : Social_ServiceZoomIn()
    *  Description : News관련 이미지를 ZoomIn한다
    *  Return Value : Yes
    *  usage :
    ************************************************************************************/
    function Social_ServiceZoomIn(social_service_no,seq) {

        if(seq==1){
            window.open("/bin/common/social_service_zoom.html?ar_social_service_no=" + social_service_no +"&ar_seq=" + seq,'Zoom','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=200,height=300,location=center');
        }
        else{
            window.open("/bin/common/social_service_zoom.html?ar_social_service_no=" + social_service_no +"&ar_seq=" + seq,'Zoom','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=390,height=530,location=center');
        }
    }
   /************************************************************************************
    *  Function Name : EngNewsZoomIn()
    *  Description : News관련 이미지를 ZoomIn한다
    *  Return Value : Yes
    *  usage :
    ************************************************************************************/
    function EngNewsZoomIn(news_type,news_no,seq) {

        if(seq==1){
            window.open("/bin/common/eng_news_zoom.html?ar_news_type=" + news_type + "&ar_news_no=" + news_no +"&ar_seq=" + seq,'Zoom','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=180,height=160,location=center');
        }
        else{
            window.open("/bin/common/eng_news_zoom.html?ar_news_type=" + news_type + "&ar_news_no=" + news_no +"&ar_seq=" + seq,'Zoom','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=420,height=340,location=center');
        }
    }

  /************************************************************************************
    *  Function Name : EngSocial_ServiceZoomIn()
    *  Description : News관련 이미지를 ZoomIn한다
    *  Return Value : Yes
    *  usage :
    ************************************************************************************/
    function EngSocial_ServiceZoomIn(social_service_no,seq) {

        if(seq==1){
            window.open("/bin/common/eng_social_service_zoom.html?ar_social_service_no=" + social_service_no +"&ar_seq=" + seq,'Zoom','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=200,height=300,location=center');
        }
        else{
            window.open("/bin/common/eng_social_service_zoom.html?ar_social_service_no=" + social_service_no +"&ar_seq=" + seq,'Zoom','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,width=390,height=530,location=center');
        }
    }

  /************************************************************************************
    *  Function Name : new_window()
    *  Description : Flash 에서 새창 띄우기를 한다.
    *  Return Value : Yes
    *  usage :
    ************************************************************************************/
    function new_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
    {
        toolbar_str   = toolbar ? 'yes' : 'no';
        menubar_str   = menubar ? 'yes' : 'no';
        statusbar_str = statusbar ? 'yes' : 'no';
        scrollbar_str = scrollbar ? 'yes' : 'no';
        resizable_str = resizable ? 'yes' : 'no';
        window.open(url, name, 'left='+left+',top='+top+',width='+width+',height='+height+',toolbar='+toolbar_str+',menubar='+menubar_str+',status='+statusbar_str+',scrollbars='+scrollbar_str+',resizable='+resizable_str);
    }

	/************************************************************************************
     *
	   *	Function Name : ValidateHourMin()
     * 	Description   : 유효한(존재하는) 시(時)분(分)인지 체크
     *	Return Value  : 유효하면 true, 아니면 false를 return
     *
	 ************************************************************************************/
    function ValidateHourMin(hhmm)
    {
        var hh = hhmm.substr(0, 2);
        var mm = hhmm.substr(2, 2);

        if ( hhmm.length != 4 )
        {
            alert("시간을 4자리로 입력하십시요! (예:0930).")
            return(false);
        }

        if ( !IsNumeric(hhmm) )
        {
            alert("시간은 숫자여야 합니다! (예:0930).");
            return(false);
        }

        if ( hh < 1 || hh > 24 )
        {
            alert("올바른 시간(時)이 아닙니다");
            return (false);
        }

        if ( mm < 0 || mm > 59 )
        {
            alert("올바른 분(分)이 아닙니다");
            return (false);
        }

        return (true);
    }

	/************************************************************************************
     *
	 *	Function Name	: autoTab()
     * 	Description			: 정해진 숫자만큼 입력되면 자동으로 탭이동, 예)주민등록번호
     *	Return Value		: 유효하면 true, 아니면 false를 return
     *
	 ************************************************************************************/

	function containsElement(arr, ele)
	{
		var found = false, index = 0;
		try {
			while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
		} catch(e) {}
		return found;
	}

	function getIndex(input)
	{
		var index = -1, i = 0, found = false;
		try {
			while (i < input.form.length && index == -1)
			if (input.form[i] == input)index = i;
				else i++;
		} catch(e) {}
		return index;
	}

  var isNN = (navigator.appName.indexOf("Netscape")!=-1);

	function autoTab(input, len, e)
	{
		try {
			var keyCode = (isNN) ? e.which : e.keyCode;
			var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
			if(input.value.length >= len && !containsElement(filter,keyCode)) {
				input.value = input.value.slice(0, len);
				input.form[(getIndex(input)+1) % input.form.length].focus();
			}
		} catch(e) {}
		return true;
	}
	
	/************************************************************************************
     *
	 *	Function Name	: home.logout
     * 	Description		: admin home, logout
     *	Return Value	: home, logout
     *
	 ************************************************************************************/

	// 로그아웃
	function goLogout(){
		var f = document.cgiform;
    	f.strCommand.value="logout";    	
    	f.action= "/aaddmmpkg.login.Login.doj";
    	f.method = "POST";
    	f.submit();
	}
	
	// 홈
	function goHome(){
		top.location.href="/aaddmmpkg/aaddmmpkg_index.jsp";
	}
	
	/************************************************************************************
     *
	 *	Function Name	: C_Dictionary()
     * 	Description		: 팝업창을 고정되게 한다.
     *	Return Value	: 
     *
	 ************************************************************************************/

   function C_Dictionary() {
    this.List      = new ActiveXObject("Scripting.Dictionary");
    this.set       = C_dictSetMapElement;
    this.get       = C_dictGetMapElement;
    this.remove    = C_dictRemoveMapElement;
    this.count     = C_dictCountMapElement;
    this.exists    = C_dictExistsMapElement;
    this.keys      = C_dictKeysMapElement;
    this.items     = C_dictItemsMapElement;
    this.removeAll = C_dictRemoveAllMapElement;
   }
   function C_dictRemoveAllMapElement(){this.List.RemoveAll();}
   function C_dictItemsMapElement(){return (new VBArray(this.List.Items())).toArray();}
   function C_dictKeysMapElement(){return (new VBArray(this.List.Keys())).toArray();}
   function C_dictExistsMapElement(asKey){return this.List.Exists(asKey);}
   function C_dictCountMapElement(){return this.List.Count;}
   function C_dictSetMapElement(asKey, asValue) {this.List.Item(asKey) = asValue;}
   function C_dictGetMapElement(asKey){
    try {
      return this.List.Item(asKey);
    } catch (e) {
      return undefined;
    }
   }
   function C_dictRemoveMapElement(asKey) {
    try {
      this.List.Remove(asKey);
    } catch (e) {
    }
   }      
	
	/************************************************************************************
     *
	 *	Function Name	: setCookie, getCookie, clearCookie, clearAllCookie
     * 	Description		: cookie
     *	Return Value	: 
     *
	 ************************************************************************************/
	//쿠키 생성 
	function setCookie( name, value, expiredays )
	{
		var todayDate = new Date();
		todayDate.setDate( todayDate.getDate() + expiredays );
		document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
	}
	// 쿠키구하기
    function getCookie(name)
	{
		var nameOfCookie = name + "=";
		var x = 0;
		while ( x <= document.cookie.length )
		{
	  		var y = (x+nameOfCookie.length);
	  		if ( document.cookie.substring( x, y ) == nameOfCookie )
	  		{
	   			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )endOfCookie = document.cookie.length;
	   			return unescape( document.cookie.substring( y, endOfCookie ) );
	  		}
	  		x = document.cookie.indexOf( " ", x ) + 1;
	  		if ( x == 0 )break;
	 	}
	 	return "";
	}
	// 쿠키지우기
	function clearCookie(name)
	{
	    today   = new Date();
	    today.setDate(today.getDate() - 1);
	    document.cookie = name + "=; path=/; expires=" + today.toGMTString() + ";";
	}
	// 모든쿠키 삭제
	function clearAllCookie()
	{
	    cookie  = document.cookie.split(";");
	    total   = cookie.length;
	    for(i=0; i<total; i++) {
	     
	        name = cookie[i].substring(0, cookie[i].indexOf("="));
	        clearCookie(name);
	    }
	}
	
	// 파일다운로드
	function goDownLoad(path, fileName, origin){
		top.blankFrame.location = "/common/download.jsp?path=" + path
		                        + "&filename=" + encodeURIComponent(fileName)
		                        + "&originfilename=" + encodeURIComponent(origin);
    }
    
    // 로그띄우기
    function goLogLIstPopup(p_module_type, p_key1, p_key2){
        var winName = new C_Dictionary();
        var param = "&ar_module_type="+ p_module_type + "&ar_key1="+ p_key1 + "&ar_key2="+ p_key2;
        var url = "/com.Com.doj?strCommand=getLogListPopup" + param;
        window.showModalDialog(url, winName, 'center:yes; dialogwidth:520px; dialogHeight:480px; status:no; help:no; scroll:no');
    }
    
    // 동영상보기
    function NewWindow(mypage,myname,w,h,scroll,resizevalue){
	    var winl = (screen.width-w)/2;
	    var wint = (screen.height-h)/2;
	    var settings = 'height='+h+',';
	    settings += 'width='+w+',';
	    settings += 'top='+wint+',';
	    settings += 'left='+winl+',';
	    settings += 'scrollbars='+scroll+',';
	    settings += 'resizable='+resizevalue;
	    // settings += ',status=yes';
		mypage = '/common/'+mypage;
		
	    var win=window.open(mypage,myname,settings);
	    win.window.focus();
	}
	
	// movie document write
	function JS_viewObj(objhtml) { 
    	document.write(objhtml);
	}
	
	//=====================================
	// search 검색관련
	//=====================================	
	// 헤더 서치 Bg 바꿈
	function clearBg(obj){
		obj.style.background = "";
	}

	function goSearch(lang) {
		var img_lang = "";
		if(lang == "K") img_lang = "";
		else if(lang == "E") img_lang = "/eng";
		else if(lang == "C") img_lang = "/cn";
		else if(lang == "J") img_lang = "/jp";
		
		var obj = document.getElementById("header_search");
		if(obj.value=="") return;
		obj.style.background = "url(/image" + img_lang + "/common/bg_top_search.gif) no-repeat";
		obj.style.backgroundPosition = "3px 4px";
		
		//location.href = "/main.Main.doj?strCommand=indexLeft&ar_category=9991&ar_search_text="+obj.value;
		
		// 서브밑으로 변경
		var linkUrl = "/main.Main.doj?strCommand=indexLeft&ar_category=9991&ar_search_text="+obj.value;
		top.blankFrame.goPage(linkUrl, "mainFrame");
	}

	function refillBg(val, lang){
		var img_lang = "";
		if(lang == "K") img_lang = "";
		else if(lang == "E") img_lang = "/eng";
		else if(lang == "C") img_lang = "/cn";
		else if(lang == "J") img_lang = "/jp";
		
		if(val=="search_bg"){
		    var obj = document.getElementById("header_search");
		    if(obj.value == ""){
				obj.style.background = "url(/image" + img_lang + "/common/bg_top_search.gif) no-repeat";
				obj.style.backgroundPosition = "3px 4px";
			}
		}
		else if(val=="email_bg"){
		    var obj = document.getElementById("input_mail");
		    if(obj.value == ""){
				obj.style.background = "url(/image" + img_lang + "/common/bg_emailservice_form.gif) no-repeat";
				obj.style.backgroundPosition = "3px 1px";
			}
		}
	}
	
		
	//=====================================
	// 유관사이트,재단사이트 팝업(OK)
	//=====================================
	function newpages(sel)
	{
		var index = sel.selectedIndex;
		if (index<1) return false;
		var wi = window.open('','_blank','');
		if (sel.options[index].value != '') {
		wi.location.href = sel.options[index].value;}
	}
	
	//=====================================
	// 북 페이지 이동 관련
	//=====================================	
	function goBookPage(val){
		location.href = "/book/book_main.jsp?ar_book_type="+val;
	}
	
	//=====================================
	// RSS 이동
	//=====================================
	function goRSS(val){
		if(!BrowserVerCheck()){ 
			alert("IE 6.0 이하에서는 RSS 리더기 설치가 필요합니다."); 
			return;
		}
		
		var RSS_win = window.open('/rss.Rss.doj?strCommand='+val, '_new');
		RSS_win.focus();
	}
	
	//======================================
	// ChangeLanguage
	//======================================
	function changeLanguage(lang){
		var f = document.cgiform;
		
		f.target = "mainFrame";
		f.ar_language.value = lang;
		f.strCommand.value = "indexMain";
		f.action = "/main.Main.doj";
		f.method = "POST";
		f.submit();
	}
	
	function changeLanguage2(lang){
		top.location.href="http://www.kf.or.kr";
	}
	
	//======================================
	// BrowserCheck 및 버젼
	//======================================
	function BrowserCheck() {
		var appname = navigator.appName;
		var useragent = navigator.userAgent;
		if(appname == "Microsoft Internet Explorer") appname = "IE";
		else appname = "ETC";
		
		return appname;
	}
	
	function BrowserVerCheck() {
		var appname = navigator.appName;
		var useragent = navigator.userAgent;
		if(appname == "Microsoft Internet Explorer") appname = "IE";
		var IE55 = (useragent.indexOf('MSIE 5.5')>0);  //5.5 버전
		var IE6 = (useragent.indexOf('MSIE 6')>0);     //6.0 버전

		var rtn_version = true;
		if(appname=="IE" && IE55 || IE6) rtn_version = false; //익스플로러이면서 5.5 or 6.0 버전이면...
		else rtn_version = true;
		
		return rtn_version;
	}
	
	//======================================
	// 글의 상태에 맞는 상태명을 리턴함
	//======================================
	function getStatusName(p_status) {
		var statusName = "";
		
		if (p_status == "1") {
			
		} else if (p_status == "2") {
			statusName = "접수완료";
		} else if (p_status == "3") {
			statusName = "반려처리";
		} else if (p_status == "4") {
			
		} else if (p_status == "5") {
			statusName = "승인요청";
		} else if (p_status == "6") {
			statusName = "수정요청";
		} else if (p_status == "7") {
			statusName = "승인거절";
		} else if (p_status == "8") {
			statusName = "승인완료";
		}
		
		return statusName;
	}
	
/********************************************************************************
 *	End Of Program
 ********************************************************************************/