//ÀÔ·Â¹®ÀÚ±æÀÌÃ¼Å©
function char_check(str)
{
    var i,ch,chlen;
    chlen=0;
    
    for (i=0;i<str.length;i++)
    {
        chStr = escape(str.charAt(i));        //ISO-Latin-1 ¹®ÀÚ¼ÂÀ¸·Î º¯°æ
		if (chStr.substring(0, 2) == '%u')
        {
                if (chStr.substring(2,4) == '00')
                        chlen=chlen+1
                else
                        chlen=chlen+2;        //ÇÑ±Û
        }
        else if (chStr.substring(0,1) == '%')
        {              
                if (parseInt(chStr.substring(1,3), 16) > 127)
                        chlen=chlen+2        //ÇÑ±Û
                else
                        chlen=chlen+1;
        }
        else
        {
                chlen=chlen+1;
        }	
	}
	
    return chlen;    
}

//³¯Â¥Ã¼Å©
function DayChk(obj)
{
  if (obj.value.length == 0) return false;
  b=obj.value.split('-');
  //alert(b[0]);
	if (b.length!=3) 
	{
		alert('³¯Â¥Çü½ÄÀÌ ¸ÂÁö¾Ê½À´Ï´Ù ex)2003-04-04');
		obj.select();
        
	}
	if( isNaN(b[0])){ 
         alert("³âµµÀ» ¼ýÀÚ·Î ÀÔ·ÂÇØÁÖ¼¼¿ä.");
		 obj.select();
        
         return false; 
      } 
	if( isNaN(b[1])){ 
         alert("¿ùÀ» ¼ýÀÚ·Î ÀÔ·ÂÇØÁÖ¼¼¿ä.");          
		 obj.select();
        
         return false; 
      } 
	if( isNaN(b[2])){ 
         alert("ÀÏÀ» ¼ýÀÚ·Î ÀÔ·ÂÇØÁÖ¼¼¿ä.");  
		 obj.select();
        
         return false; 
      } 
 
     /*if(b[0] < new Date().getFullYear()){ // ¿ÃÇØ³âµµº¸´Ù ÀÛ´Ù¸é °ÅÁþ 
         alert('ÀÔ·ÂÇÏ½Å '+b[0]+'Àº Áö³­³âµµÀÔ´Ï´Ù.\n¿Ã¹Ù¸¥ ³âµµ¸¦ ÀÔ·ÂÇØÁÖ¼¼¿ä.'); 
         obj.select();
        
         return false; 
         
      }*/ 

//      if(parseInt(b[1]) < 1 || parseInt(b[1]) > 12 )
//      { 
//         if (parseInt(b[1])==0){
//            b[1].substring(1,1);      
//        alert('¿Ã¹Ù¸¥ ¿ùÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.'); 
//         obj.select();

//         return false; 
//         }
         
//      } 
     if(parseInt(b[1]) < 1 || parseInt(b[1]) > 12 ){ 
         if (parseInt(b[1])==0 && b[1].length<2)
         {
	    alert('¿Ã¹Ù¸¥ ¿ùÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.'); 
             obj.select();
             return false; 
         }
         
         
      } 
     //À±³âÀÎÁö ÆÇ´Ü (2¿ù)
    
      if(b[1] == 2){
         var leapYear = ( b[0]%4 == 0 ) && ( (b[0] % 100 != 0) || (b[0] % 400 == 0) );
       
         if(leapYear && b[2] > 29){       
             alert(b[0]+'³â 2¿ùÀº 29ÀÏÀ» ³ÑÀ» ¼ö ¾øÀ¾´Ï´Ù.'); 
			 obj.select();

             return false; 
          } 
         else if( !leapYear && b[2] > 28){ 
             alert(b[0]+'³â 2¿ùÀº 28ÀÏÀ» ³ÑÀ» ¼ö ¾øÀ¾´Ï´Ù.'); 
             obj.select();

             return false; 
        } 
      }

      if( ( parseInt(b[1]) == 2  || parseInt(b[1]) == 4  || parseInt(b[1]) == 6 || parseInt(b[1]) == 9 || parseInt(b[1]) == 11 ) && (parseInt(b[2]) > 30) ){ 
         alert(parseInt(b[1],10)+"¿ù"+b[2]+"´Â Àß¸øµÈ ³¯Â¥ÀÔ´Ï´Ù.\n" + parseInt(b[1])+"¿ùÀº 30ÀÏÀÌ ¸»ÀÏÀÔ´Ï´Ù."); 
         obj.select();
         return false;        
      } 
	  if( ( parseInt(b[1]) == 1  || parseInt(b[1]) == 3  || parseInt(b[1]) == 5 || parseInt(b[1]) == 7 || parseInt(b[1]) == 8 || parseInt(b[1]) == 10 || parseInt(b[1]) == 12 ) && (parseInt(b[2]) > 31) ){ 
         alert(parseInt(b[1],10)+"¿ù"+b[2]+"´Â Àß¸øµÈ ³¯Â¥ÀÔ´Ï´Ù.\n" + parseInt(b[1])+"¿ùÀº 31ÀÏÀÌ ¸»ÀÏÀÔ´Ï´Ù.");
         obj.select();
         return false;        
      }
      return true;
    
}
//»õ·Î¿î Ã¢º¸ÀÌ±â
function openWindow(theURL,winName,features)
{
    window.open(theURL,winName,features);
}

// ¼ýÀÚÀÔ·ÂÃ¼Å©
function checkNum(objNumBox)   
{
    var numBoxValue = objNumBox.value;

    for(var i=0;i<numBoxValue.length;i++)
    {
        if(isNaN(numBoxValue.charAt(i)))
        {
           window.alert("¼ýÀÚ¸¸ ÀÔ·ÂÇØÁÖ¼¼¿ä.");
           objNumBox.value = '';
           for(var j=0;j<i;j++)
           {
               objNumBox.value += numBoxValue.charAt(j);
           }
           return;
        } 
    }
return true;
}

//¿ìÆí¹øÈ£ Ã¢¶ç¿ì±â
function Post(FormName)
{
	myWindow = window.open("/common/post_search.asp?txtFormName=" + FormName, "PostNo", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,copyhistory=0,width=450 ,height=400");
}

//Æû°´Ã¼¿¡¼­ °´Ã¼À¯¹« È®ÀÎ
function namechk(obj,sname)
{
  
  for(i=0;i<obj.elements.length;i++)
	 {
		if (obj.elements[i].name==sname)
		{
			return true;
			break;
		}
	 }
	 return false;
}

function MfStop(obj){ 
obj.stop(); 
} 
function MfStart(obj){ 
obj.start(); 
}
//checkbox¸¦ ÀüÃ¼¼±ÅÃ,ÀüÃ¼ÇØÁ¦ÇÑ´Ù.
function ToggleCheck(obj,flag) 
{
    for (var i=0;i< obj.length; i++) 
    { 
	obj[i].checked=(flag == 'Check') ? 1 : 0; 
    } 
}

//ÄíÅ°¸¦ ¼±Á¤ÇÑ´Ù.
function setCookie( name, value, expires, domain)
{
	var path;
	var secure;
	path = "/";
	
	var todayDate = new Date();
	todayDate.setDate( todayDate.getDate() + expires );
	
	document.cookie = name + "=" + escape(value) +
	((path) ? "; path=" + path : "") +
	((expires) ? "; expires=" + todayDate.toGMTString() : "") +
	((domain) ? "; domain=" + domain : "") + 
	((secure) ? "; secure" : "");
}
//ÄíÅ°°ªÀ» ÀúÀåÇÏ°í ¿­¸°Ã¢À» ´Ý´Â´Ù.
function closeWin(form, eventNM, expires, domain)
{
	if ( form.winCheck.checked ) {
		setCookie(eventNM, "done", expires, domain);
	}
	self.close();
}

//»õ·Î¿îÃ¢À» ¿¬°í ÀÚ½ÅÀ» ´Ý´Â´Ù.
function openerGo(url)
{
	opener.location.href = url;
	self.close();
}


//ÄíÅ°°ªÀ» °¡Á®¿Â´Ù
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 "";
}

//-------------------------------------------------
//ÀÌ¸ÞÀÏÀ» Ã¼Å©ÇÑ´Ù. 1
//-------------------------------------------------
	function CheckEmail(str){
		emailStr = str.value
		if(emailStr != "") {
			var emailPat=/^(.+)@(.+)$/
			var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
			var validChars="\[^\\s" + specialChars + "\]"
			var firstChars=validChars
			var quotedUser="(\"[^\"]*\")"
			var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
			var atom="(" + firstChars + validChars + "*" + ")"
			var word="(" + atom + "|" + quotedUser + ")"
			var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
			var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
			var matchArray=emailStr.match(emailPat)
			if (matchArray==null) {
				alert("E-mail ÁÖ¼Ò¸¦ Á¤È®È÷ ÀÔ·ÂÇØ ÁÖ½Ã±â ¹Ù¶ø´Ï´Ù.");
				str.focus();
				return false;
				}
		}
	}


	function BrdImg(Img) {
		openImg = window.open('', 'openImg','width=100,height=100,left=0,top=0,resizable=no,scrollbars=no');
		openImg.focus();
		openImg.document.write('<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
		openImg.document.write('<img src="'+Img+'" style="cursor:hand" alt="Close" OnClick="self.close()" ID="img">');
		openImg.document.write('</body>');
		openImg.window.resizeTo(openImg.document.body.scrollWidth+10,openImg.document.body.scrollHeight+25);
		openImg.document.close();
		//openImg.window.resizeBy(0,0)
	}
