// Æ¯¼öÅ° µ¿ÀÛ ¹æÁö
function fnKeyPressHandle() {
  //return;

    // <BACK SPACE>Å° CHECK
    if ( event.keyCode == 8 ) {
         return false;
    }

    // CTRLÅ° CHECK
    if ( window.event.ctrlKey ) {
         // <CTRL + N>Å°·Î »õÃ¢¶ç¿ì±â ¹æÁö
         if ( event.keyCode == 78 ) {
              return false;
         }
    }
}

// Äí±â ÀúÀå
function fnSetCookie( i_name, i_value, i_expday ) {
    if ( (i_name  == null) || (i_name.length  == 0) ) return;
    if ( (i_value == null) || (i_value.length == 0) ) i_value = "";
    if ( i_expday == null ) i_expday = -1;

    var expire = new Date();

    if ( i_value.length > 0 ) {
         if ( i_expday > -1 ) {
              expire.setDate(expire.getDate() + i_expday);

              document.cookie = i_name + "=" + escape(i_value) + "; expires=" + expire.toGMTString() + ";";
         }
         else {
              document.cookie = i_name + "=" + escape(i_value) + ";";
         }
    }
    else {
         document.cookie = i_name + "=; expires=" + expire.toGMTString() + ";";
    }
}

// ÄíÅ° ÀÐ±â
function fnGetCookie( i_name ) {
    if ( (i_name == null) || (i_name.length == 0) ) return null;

    var cookies = document.cookie.split("; ");

    for ( i=0; i < cookies.length; i++ ) {
          var nameval = cookies[i].split("=");

          if ( i_name == nameval[0]) {
               return unescape(nameval[1]);
          }
    }

    return null;
}

// ¹®ÀÚ¿­ ÁÂ¿ì °ø¹éÁ¦°Å
function fnTrim(str) {
    str = str.replace(/^\s*|\s*$/, "");

    return str;
}

// ¿¤¸®¸ÕÆ® ¹®ÀÚ¿­ ÁÂ¿ì °ø¹éÁ¦°Å
function fnEleTrim(ele) {
    ele.value = ele.value.replace(/^\s*|\s*$/, "");

    return ele.value;
}

// ¼ýÀÚÇü ÀÚ·á ÀÔ·Â º¯È¯
function fnInputNumber(obj) {
    var key_value = obj.value;
    if ( key_value.length == 0 ) return;

    // ¼ýÀÚ ÀÌ¿ÜÀÇ °ª °ø¹éÀ¸·Î ´ëÃ¼
    key_value = Number( key_value.replace(/\D/g, '') );

	obj.value = key_value;
}

// ¼ýÀÚÇü °ª¿¡ ÄÞ¸¶ ³Ö±â
function fnFormatNumber(str) {
    uncomm_str = String(str);
    comm_str = "";

    loop_j = uncomm_str.length - 3;

    for( j=loop_j; j>=1 ; j=j-3 ) {
         comm_str=","+uncomm_str.substring(j,j+3)+comm_str;
    }
    comm_str = uncomm_str.substring(0,j+3)+comm_str;

    return comm_str;
}

// ¼ýÀÚÇü °ª¿¡¼­ ÄÞ¸¶ »©±â
function fnOnlyNumber(str) {
  comm_str = String(str);

  uncomm_str="";

  for( i=0; i<comm_str.length; i++ ) {
       substr=comm_str.substring(i,i+1);
       if ( substr != "," )
            uncomm_str += substr;
  }

  return uncomm_str;
}

// ºó °ø¹é ¹®ÀÚ¿­ CHECK
function isempty(s) {
    return ((s == null) || (s.length == 0))
}

// ÀÚ·áÀÇ ±æÀÌ CHECK
function validlength(data_val, len) {
    return (data_val.length >= len);
}

function invalidlength(date_val, len, len2) {
    return ((date_val.length >= len) && (date_val.length <= len2));
}

// ´ÜÀÏ ¹®ÀÚÇü ÀÚ·á CHECK
//function isletter (c)
//{   return ( ((c >= "a") && (c <= "z")) || ((c >= "A") && (c <= "Z")) );
//}

// ´ÜÀÏ ¼ýÀÚÇü ÀÚ·á CHECK
//function isdigit (c)
//{   return ((c >= "0") && (c <= "9"));
//}

// ¹®ÀÚÇü ÀÚ·á CHECK
function isletter (str) {
    var len=str.length;
    for(i=0; i<len; i++) {
        if ( ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) || ((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ) {
        }
        else {
               return false;
        }
    }
    return true;
}

// ¼ýÀÚÇü ÀÚ·á CHECK
function isdigit (str) {
    var len=str.length;
    for(i=0; i<len; i++) {
        if ((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) {
        }
        else {
             return false;
        }
    }
    return true;
}

// ÀÌ¸ÞÀÏ ÀÔ·Â CHECK
function isemail(checkstr) {
    var checkok = "@";
    if (checkstr.length == 0) {return (false);}

    for (i = 0;  i < checkstr.length;  i++) {
         ch = checkstr.charAt(i);
         if (ch == checkok) {return (true) }
    }
    return (false);
}

// ´ÜÀÏ¹®ÀÚ ´ëÃ¼ (¿øº»¹®ÀÚ¿­, ´ëÃ¼´ë»ó ¹®ÀÚ, ´ëÃ¼ÇÒ ¹®ÀÚ)
function replacechar(str, tarch, repch) {
    var nowch  = "";
    var sumstr = "";

    var len=str.length;
    for(i=0; i<len; i++) {
        if (str.charAt(i) == tarch) {
            nowch = repch;
        }
        else {
            nowch = str.charAt(i);
        }
        sumstr = sumstr + nowch;
    }
    return sumstr;
}

// ÁÖ¹Îµî·Ï¹øÈ£ CHECK
function socialcheck(soid) {
    var IDtot = 0;
    var IDAdd = "234567892345";

    for(i=0;i<12;i++) {
        IDtot = IDtot + parseInt(soid.substring(i,i+1)) * parseInt(IDAdd.substring(i,i+1));
    }

    IDtot= 11 - (IDtot%11);

    if(IDtot==10) {
       IDtot = 0;
    }
    else if(IDtot==11){
       IDtot = 1;
    }

    var tid = parseInt(soid.substring(12,13));

    if ( tid == IDtot ) {
         return true;
    }
    else {
         return false;
    }
}

// »ç¾÷ÀÚµî·Ï¹øÈ£ CHECK
function businesscheck(buid) {
    if ( buid.length < 10 ) return false;

    var sum      = 0;
    var getlist  = new Array(10);
    var chkvalue = new Array("1","3","7","1","3","7","1","3","5");

    for ( i=0; i < 10; i++ ) {
          getlist[i] = buid.substring(i, i+1);
    }

    for ( i=0; i < 9; i++) {
          sum = sum + getlist[i] * chkvalue[i];
    }

    sum    = sum + parseInt((getlist[8] * 5) / 10);
    sidliy = sum % 10;
    sidchk = 0;

    if ( sidliy != 0 ) {
         sidchk = 10 - sidliy;
    }
    else {
        sidchk = 0;
    }

    if ( sidchk == getlist[9] ) {
         return true;
    }
    else {
         return false;
    }
}

// ´ÙÀ½ ÀÔ·ÂÆûÀ¸·Î ÀÌµ¿
function fnNextInput( i_ele, i_len ) {
    if ( i_ele.value.length == i_len ) {
         var next = i_ele.nextSibling;

         while ( next != null ) {
                 if ( next.nodeName == "INPUT" ) {
                      next.focus();
                      break;
                 }

                 next = next.nextSibling;
         }
    }
}

function isEmpty( data )
{
   for ( var i = 0 ; i < data.length ; i++ ){
      if ( data.substring( i, i+1 ) != " " )
         return false;}
   return true;}

// ÆË¾÷
function fnPopup( i_url, i_name ) {
    if ( i_name == null ) i_name = "_blank";

    return window.open(i_url, i_name, "width=0, height=0, titlebar=no, menubar=no, toolbar=no, location=no, status=no, resizable=no, status=no, scrollbars=yes");
}

function fnPop( i_url, i_name , i_width, i_height) {
    if ( i_name == null ) i_name = "_blank";

    window.open(i_url, i_name, "width="+i_width+", height="+i_height+", titlebar=no, menubar=no, toolbar=no, location=no, status=no, resizable=no, status=no, scrollbars=no");
}


function fnPop2( i_url, i_name , i_width, i_height, i_resizable, i_scrollbars) {
    if ( i_name == null ) i_name = "_blank";

    window.open(i_url, i_name, "width="+i_width+", height="+i_height+", titlebar=no, menubar=no, toolbar=no, location=no, status=no, resizable="+i_resizable+", status=no, scrollbars="+i_scrollbars+"");
}

