/*----------------------------------------------------
 * Input TextBox¿¡ ¹®ÀÚÃ¼Å©
 * : onfocus ¹ß»ý ½Ã str ¹®ÀÚ¿Í °°À¸¸é value=''
 ----------------------------------------------------*/
function input_str_check(f, str) {
  if(f==null) return;
  
  if(f.value==str) f.value='';
  
  return; 
}

/*----------------------------------------------------
 * ¹®ÀÚ¿­ ±æÀÌ¸¦ Àé´Ù.
 * ÇÑ±ÛÀÇ °æ¿ì gubunÀÌ YÀÌ¸é ÇÑ ±ÛÀÚ¸¦ 2¹ÙÀÌÆ®·Î °è»êÇÑ´Ù.
 ----------------------------------------------------*/
function dataLength_ck(value,gubun){
  if(gubun=="Y" || gubun=="y"){
    var cnt = 0;
    for(var i=0;i<value.length;i++){
      if(value.charCodeAt(i) <129)
        cnt = cnt + 1;
      else
        cnt = cnt + 2;
    }
    return cnt;
  }else
    return value.length;
}

/*----------------------------------------------------
* ¹®ÀÚÀÔ·ÂÀ» ±ÝÁöÇÑ´Ù. 
* ÅØ½ºÆ® ÇÊµåµî¿¡¼­ onKeyPress="javascript:checkKeys()"·Î 
* »ç¿ëÇÏ¸é µÈ´Ù.
----------------------------------------------------*/
function checkKeys(e) { // ¹®ÀÚÀÔ·Â ±ÝÁö ÇÔ¼ö ¼³Á¤
  if( event.keyCode < 48 || event.keyCode > 57 ) {
    event.keyCode=0;
    return;
  }
}

/*----------------------------------------------------
 * ¾ÆÀÌµð ¼ýÀÚ·Î ½ÃÀÛÇÏ´Â ÀÔ·ÂÀ» ±ÝÁöÇÑ´Ù. 
 ----------------------------------------------------*/
function idNumCheck(str) {
  str=new String(str);
  var chklist="0123456789";

  if(chklist.indexOf(str.charAt(0)) >= 0) {
    alert("¼ýÀÚ·Î ½ÃÀÛ ÇÒ ¼ö ¾ø½À´Ï´Ù.");
    return false;
  }
  
  return true;
}

/*----------------------------------------------------
 * °ø¹éÀÔ·ÂÀ» ±ÝÁöÇÑ´Ù. 
 ----------------------------------------------------*/
function blankCheck(str) {
 str=new String(str);
 var sp=" ";
 var len=str.length;
 
 for(var i=0;i<len;i++){
   if(sp.indexOf(str.charAt(i)) >= 0){
     alert("°ø¹é(space)Àº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
     return false;
     break;
   }
 }
 
 return true;
}

/*----------------------------------------------------
 * ÇÑ±ÛÀÔ·ÂÀ» ±ÝÁöÇÑ´Ù. 
 ----------------------------------------------------*/
function korCheck(str) {
  str=new String(str);
  var chklist="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*().-_+=<,>?':;[]{}";
  var len=str.length;
  
  for(var i=0;i<len;i++){
    if(chklist.indexOf(str.charAt(i)) < 0) {
      alert("ÇÑ±ÛÀº »ç¿ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
      return false;
      break;
    }
  }
  
  return true;
}

/*----------------------------------------------------
 * ¾ÆÀÌµð ¼ýÀÚ·Î ½ÃÀÛÇÏ´Â ÀÔ·ÂÀ» ±ÝÁöÇÑ´Ù. 
 ----------------------------------------------------*/
function numCheck(str) {
  var chklist="0123456789";
  var len=str.length;

  str=new String(str);

  for(var i=0;i<len;i++) {
    if(chklist.indexOf(str.charAt(i)) == -1) {
      alert("¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.");
      return false;
      break;
    }
  }
  
  return true;
}

/*----------------------------------------------------
 * ¼Ò¼ýÁ¡ ÀÚ¸® ÀÔ·Â Ã¼Å©
 * ÅØ½ºÆ® ÇÊµåµî¿¡¼­ num_chk(this.form.tel_home, tl, n); ·Î »ç¿ëÇÏ¸é µÈ´Ù.
 * tl = ÀüÃ¼ Çã¿ë ÀÚ¸®¼ö, n = ¼Ò¼öÁ¡ ÀÌÇÏ Çã¿ë ÀÚ¸®¼ö
   (¡Ø Á¤¼ö Çã¿ë ÀÚ¸®¼ö´Â = tl-n-1 : ¼Ò¼öÁ¡ -1)
 ----------------------------------------------------*/
function floatCheck(fname, tl, n){
  var num=new String(fname.value);
  var arr=new Array;
  arr=num.split(".");

 if(arr.length!=0 && arr.length>2) {
    alert("Àß¸ø ÀÔ·Â ÇÏ¼Ì½À´Ï´Ù.");
    return false;
 } else if(arr.length>=2 && n==0) {
    alert("Á¤¼ö·Î ÀÔ·Â ÇØ ÁÖ¼¼¿ä.");
    return false;
 } else {
   if(arr.length>=1 && new String(arr[0]).length>(tl-n-1)) {
    alert("ÀÔ·Â °ªÀ» ÃÊ°ú Çß½À´Ï´Ù.");
    return false;
   }
   if(arr.length>1 && new String(arr[1]).length>n) {
    alert("¼Ò¼öÁ¡ ÀÌÇÏ "+n+"ÀÚ¸® ±îÁö ÀÔ´Ï´Ù.");
    return false;
   }
 }
  
  for(i=0; i<arr.length; i++)
    if(!numCheck(arr[i])) {
      return false;
      break;
    }

  return true;
}

/*----------------------------------------------------
 * ¹®ÀÚÀÔ·ÂÀ» ±ÝÁöÇÑ´Ù. 
 * ÅØ½ºÆ® ÇÊµåµî¿¡¼­ onkeyup="num_chk(this.form.tel_home);"·Î 
 * »ç¿ëÇÏ¸é µÈ´Ù.
----------------------------------------------------*/
  function num_chk(fname) {
    if(isNaN(fname.value)) {
      alert('¼ýÀÚ¸¸ ÀÔ·Â °¡´ÉÇÕ´Ï´Ù.');
      fname.value='';
      fname.focus();
      return;
    }
  }

/*----------------------------------------------------
 * ÀÔ·ÂÇÑ ¼ýÀÚ¸¦ °¡°Ý Æ÷¸Ë (000,000,000)À¸·Î º¯È¯½ÃÄÑÁØ´Ù.
 ----------------------------------------------------*/
function reformNumFormat(svalue, flag) {
  var str = new String(svalue);
  var ss = "";
  var pos = 0;

  for (i=str.length - 1; i>= 0; i--) {
    pos++;
    ss = str.substring(i, i + 1) + ss;
    if ((pos % 3 == 0) && (pos < str.length)) {
      ss = "," + ss;
    }
  }
  return ss;
}

/*----------------------------------------------------
 * °¡°ÝÆ÷¸ËÀ¸·Î Ç¥½ÃµÈ ¹®ÀÚ¸¦ ÀÏ¹Ý ¼ýÀÚ·Î ¹Ù²Ù¾îÁØ´Ù.
 ----------------------------------------------------*/
function reformNormalFormat(svalue, flag) {
  var str = new String(svalue);
  var ss = "";

  for( i = 0; i < str.length; i++) {
    if( str.substring(i, i+1) != "," ) {
      ss = ss + str.substring(i, i+1);
    }
  }
  return ss;
}


/*----------------------------------------------------
 * StringÀ» ³Ñ°Ü ÁÖ¸é (ÇÑ±Û, ¿µ¹®, ASCIIÆ¯¼ö¹®ÀÚ Æ÷ÇÔ) ¿øÇÏ´Â ±æÀÌ·Î Àß¶ó¼­
 * ³¡¿¡ ... À» ¹ÝÈ¯½ÃÄÑÁÖ´Â method.  
 * ÀÚ¸£°íÀÚ ÇÏ´Â »çÀÌÁî(maxval)°¡ 30ÀÏ °æ¿ì ½ÇÁ¦ StringÀº 27ÀÚ¸®¸¸ Â÷ÁöÇÏ°Ô µÇ°í
 * ³ª¸ÓÁö 3ÀÚ¸®´Â "..." ÀÌ Â÷ÁöÇÏ°Ô µÊ. 
 *
 * SINCE : 2003.07.21
 * BY  :   Gadenia (gadenia@ibgen.com)
 ----------------------------------------------------*/
function resizeText(value, maxval) {
  var cnt = 0;
  var result = "";


  for(var i = 0; i < value.length; i++) {

    if( cnt+3 > eval(maxval) ) {
      return result+"...";
    } else {
      if( value.charCodeAt(i) < 129 ) {
        if( cnt+1 < eval(maxval) ) {
          cnt = cnt + 1;
          result += value.charAt(i);
        } else {
          return result+"...";
        }
      } else {
        if( cnt+2 < eval(maxval) ) {
          cnt = cnt + 2;
          result += value.charAt(i);
        } else {
          return result+"...";
        }
      }
    }
  }
  return result;
}

/*----------------------------------------------------
 * ÀÌ¸ÞÀÏ ÁÖ¼ÒÀÇ ÀûÇÕ¼ºÀ» ÆÇº°ÇÑ´Ù. 
 * ÁÖÀÇ: null Ã¼Å©´Â ÇÏÁö ¾Ê´Â´Ù. ÇÊ¼ö°ªÀÌ ¾Æ´Ï¹Ç·Î nullÃ¼Å©´Â °¢°¢ÀÇ jsp¿¡¼­ ÇÒ°Í
 ----------------------------------------------------*/
function email_ck(value){
  var ind=value.indexOf('@');
  var beforeAt=value.substring(0,ind);
  var afterAt=value.substring(ind);
  if(ind==-1){
    alert("¸ÞÀÏÁÖ¼Ò¸¦ Á¤È®ÇÏ°Ô ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
    return false;
  }else if(beforeAt.length==0){
    alert("¸ÞÀÏÁÖ¼Ò¸¦ Á¤È®ÇÏ°Ô ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
    return false;
  }else{
    var dotind=afterAt.indexOf('.');
    if(dotind==-1){
      alert("¸ÞÀÏÁÖ¼Ò¸¦ Á¤È®ÇÏ°Ô ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
      return false;
    }else{
      var beforeDot = afterAt.substring(1,dotind);
      var afterDot = afterAt.substring(dotind+1);
      if(beforeDot.length==0){
        alert("¸ÞÀÏÁÖ¼Ò¸¦ Á¤È®ÇÏ°Ô ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
        return false;
      }else if(afterDot.length==0){
        alert("¸ÞÀÏÁÖ¼Ò¸¦ Á¤È®ÇÏ°Ô ÀÔ·ÂÇØ ÁÖ¼¼¿ä.");
        return false;
      }
      
    }
  }
  return true;
}

/*-----------------------------------------------------------------------------------------------------------------------
 * ÁÖ¹Îµî·Ï¹øÈ£°¡ ¿Ã¹Ù¸¥Áö ÆÇº°ÇÏ´Â ÇÔ¼ö
 * JuminNum : 13ÀÚ¸® ÁÖ¹Î¹øÈ£
 * input : Æ÷Ä¿½º¿¡ À§Ä¡ÇÒ input type ÀÌ¸§(ex. document.form.jumin)
 * ÁÖ¹Î¹øÈ£ Ã¼Å©½ºÅ©¸³Æ® ¹Ø¿¡´Ù if( !isJuminNumValid(JuminNum, input) ) return;  Ãß°¡
-----------------------------------------------------------------------------------------------------------------------*/
function isJuminNumValid(JuminNum, input) {

  if (isNaN(JuminNum) || JuminNum.indexOf(".") != -1) {
    alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
    input.focus();
    return false;
  }

  strKeyValue = new String("234567892345");
  strSocialNo = new String(JuminNum);

  DigitSum = 0;
  for (i=0; i<=11; i++)
    DigitSum = DigitSum + parseInt(strSocialNo.substring(i, i+1)) * parseInt(strKeyValue.substring(i, i+1));

  i = 1;

  while((i * 11) <= DigitSum) {
    i = i + 1;
  }

  CheckDigit = ((i * 11) - DigitSum) % 10;

  if (CheckDigit != strSocialNo.substring(12, 13))  {
    alert("ÁÖ¹Î¹øÈ£°¡ ¿Ã¹Ù¸£Áö ¾Ê½À´Ï´Ù.");
    input.focus();
    return false;
  } else { return true; }

}

/*-----------------------------------------------------------------------------------------------------------------------
 * ÁÖ¹Îµî·Ï¹øÈ£µîÀ» ÀÔ·Â¹ÞÀ»¶§ »ç¿ëÇÏ´Â ÀÚµ¿À¸·Î ÅÇ ÀÌµ¿½ÃÅ°±â
 * ÇØ´ç ÅØ½ºÆ® ÇÊµå¿¡´Ù onKeyUp="return autoTab(this, 6, event);"  ·Î »ç¿ëÇÒ°Í
-----------------------------------------------------------------------------------------------------------------------*/
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
        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);
        if(input.form[(getIndex(input)+1) % input.form.length].style.visibility!="hidden")
            input.form[(getIndex(input)+1) % input.form.length].focus();
}

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

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

/*-----------------------------------------------------------------------------------------------------------------------
 * ¹®ÀÚ¿­ÀÇ ¸ðµç °ø¹éÀ» Á¦°Å ÇÔ¼ö
 * ÇØ´ç ÅØ½ºÆ® ÇÊµå¿¡´Ù  onfocusout="javascript:this.value=allTrim(this.value);"  ·Î »ç¿ëÇÒ°Í
-----------------------------------------------------------------------------------------------------------------------*/
function allTrim(a) {

  for (; a.indexOf(" ") != -1 ;) {
    a = a.replace(" ","") 
  }
  return a;
}

// all trim
String.prototype.trim = function() {
    return this.replace(/(^ *)|( *$)/g, "");
}
// left trim
String.prototype.ltrim = function() {
    return this.replace(/(^ *)/g, "");
}
// right trim
String.prototype.rtrim = function() {
    return this.replace(/( *$)/g, "");
}

/*----------------------------------------------------------------------------------------------
 * ÀÔ·Â°ªÀÌ Æ¯Á¤ ¹®ÀÚ(chars)¸¸À¸·Î µÇ¾îÀÖ´ÂÁö Ã¼Å©
 * Æ¯Á¤ ¹®ÀÚ¸¸ Çã¿ëÇÏ·Á ÇÒ ¶§ »ç¿ë
 * ex) if (!containsCharsOnly(form.blood,"ABO")) {
 *         alert("Ç÷¾×Çü ÇÊµå¿¡´Â A,B,O ¹®ÀÚ¸¸ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.");
 *     }
 * ÁÖÀÇ: null Ã¼Å©´Â ÇÏÁö ¾Ê´Â´Ù. ÇÊ¼ö°ªÀÌ ¾Æ´Ï¹Ç·Î nullÃ¼Å©´Â °¢°¢ÀÇ jsp¿¡¼­ ÇÒ°Í
 -------------------------------------------------------------------------------------------------*/
function containsCharsOnly(input,chars) {
    for (var inx = 0; inx < input.value.length; inx++) {
       if (chars.indexOf(input.value.charAt(inx)) == -1)
           return false;
    }
    return true;
}

/*--------------------------------------------------------------------------------------------
 * ÀÔ·Â°ª¿¡ ¼ýÀÚ¸¸ ÀÖ´ÂÁö Ã¼Å©
 * ex) if( !isNumber(form.inputname) ){
        alert("¼ýÀÚ¸¸ ÀÔ·Â°¡´ÉÇÕ´Ï´Ù");
 *     }
 * ÁÖÀÇ: null Ã¼Å©´Â ÇÏÁö ¾Ê´Â´Ù. ÇÊ¼ö°ªÀÌ ¾Æ´Ï¹Ç·Î nullÃ¼Å©´Â °¢°¢ÀÇ jsp¿¡¼­ ÇÒ°Í
--------------------------------------------------------------------------------------------*/
function isNumber(input) {
    var chars = "0123456789";
    return containsCharsOnly(input,chars);
}

/*--------------------------------------------------------------------------------------------
 * Select BoxÀÇ Option ¸ðµÎ »èÁ¦
 * ex) removeOptions(obj) : obj´Â Select Box °´Ã¼
--------------------------------------------------------------------------------------------*/
function removeOptions(obj) {
  while(obj.length)
    obj.options.remove(0);
}

function setChecked(obj, str) {
    for(var i=0; i<obj.length; i++) {
        if(obj[i].value==str) {
            obj[i].checked = true;
            break;
        }
    }
}

function setSelected(obj, str) {
    for(var i=0; i<obj.length; i++) {
        if(obj[i].value==str) {
            obj[i].selected = true;
            break;
        }
    }
}

/*--------------------------------------------------------------------------------------------
 * Radio Button ÀÇ Value 
 * ex) removeOptions(obj) : obj´Â Select Box °´Ã¼
--------------------------------------------------------------------------------------------*/
function getRadioValue(obj) {
  var radioValue="";
  for(i=0; i<obj.length; i++){
    if(obj[i].checked){
      radioValue = obj[i].value;
      break;
    }
  }
  
  return radioValue;
}

// iframe ÀÚÁ¾ ½ºÅ©·Ñ Á¶Á¤

// fire fox                     
// ie 6.0                      
// Mozilla 1.75        
// Netscape 7.0

function getReSize(ifrmId, w, h) {
    var objFrame = document.getElementById(ifrmId);
    var objBody = objFrame.document.body;
 
    /*
    ifrmHeight = objBody.scrollHeight + (objBody.offsetHeight - objBody.clientHeight);
    
    if (ifrmHeight > h) {
           objFrame.style.height = ifrmHeight;
    } else {
    alert(h);
           objFrame.style.height = h;
    }
    */
    
    objFrame.style.width  = w;
    objFrame.style.height = h;
}

function check_count(obj, length) {
    var content = obj.value
    var total_length = 0;
    for(inx = 0; inx < obj.value.length; inx ++) {
        int_value=content.charCodeAt(inx);
        if(int_value > 255)
            total_length += 2;
        else
            total_length += 1;
    }
    if(obj.value != "Á÷Á¢ ÀÔ·Â°¡´É(10ÀÚÀÌ³»)" && total_length > length) {
        alert(length/2 + "ÀÚ¸¦ ÃÊ°úÇÏ¿´½À´Ï´Ù");
    }
}

/*--------------------------------------------------------------------------------------------
 * Ã¼Å©¹Ú½º¿¡ ¸ðµÎ ¼±ÅÃ, ¸ðµÎÇØÁ¦..
 *checkall(checkname);
--------------------------------------------------------------------------------------------*/
function checkall(checkname){
    var el_collection=document.getElementsByName(checkname);

    if(el_collection.length){
        bool = allCheck(el_collection);
        for (c=0;c<el_collection.length;c++)
            el_collection[c].checked=bool;
    } else {
        el_collection.checked=!el_collection.checked;
    }
}

function allCheck(el_collection){
    for( i=0; i<el_collection.length; i++ )
        if( !el_collection[i].checked ) 
            return true;

    return false;
}

/*--------------------------------------------------------------------------------------------
 * Ã¼Å©¹Ú½º¿¡ ¸ðµÎ ¼±ÅÃ, ¸ðµÎÇØÁ¦..
 * setCheck(checkname, false);
--------------------------------------------------------------------------------------------*/
function setCheck(checkname, bool) {
    var el_collection=document.getElementsByName(checkname);

    if(el_collection.length)
        for (c=0;c<el_collection.length;c++)
            el_collection[c].checked=bool;
}

/*--------------------------------------------------------------------------------------------
 * Ã¼Å©¹Ú½º¿¡ Ã¼Å©µÈ °³¼ö ±¸ÇÏ±â
 * checkCnt(obj);  - Ã¼Å©¹Ú½º object
--------------------------------------------------------------------------------------------*/
function getCheckedCnt(obj) {

    if(!obj)  return 0;

    var cnt=0;
    for(var i=0; i<obj.length; i++)
        if(obj[i].checked)
            cnt++;

    return cnt;
}

/*--------------------------------------------------------------------------------------------
 * setInnerText("totKidsCnt", "1°³");
 * <span id="totKidsCnt"></span>
--------------------------------------------------------------------------------------------*/
function setInnerText(id, text) {
    var span_el = document.getElementById(id);
    var new_el = document.createElement(span_el.nodeName);
    new_el.appendChild(document.createTextNode(text));
    span_el.parentNode.replaceChild(new_el, span_el);
}

/*--------------------------------------------------------------------------------------------
 * urlCopy("trackbackUrl");
 * <DIV id="trackbackUrl"></span>
--------------------------------------------------------------------------------------------*/
function urlCopy(trackbackID) {
    urlId = document.getElementById(trackbackID);

    text = document.body.createTextRange();
    text.moveToElementText(urlId);
    text.execCommand("Copy");
    alert("ÁÖ¼Ò°¡ Å¬¸³º¸µå¿¡ º¹»ç µÇ¾ú½À´Ï´Ù.");
}

function phoneFormatCheck(str_phone) {
    
    //var re_phone = /^(0[2-6][0-5]?|01[01346-9])-?([1-9]{1}[0-9]{2,3})-?([0-9]{4})$/; 
    var re_phone = /^(0[2-6][0-5]?|01[01346-9])-([1-9]{1}[0-9]{2,3})-([0-9]{4})$/; 
    
    if (!re_phone.exec(str_phone)) {
        alert("ÀüÈ­¹øÈ£ Çü½ÄÀÌ Æ²·È½À´Ï´Ù. : "+str_phone+"\n\n¿¹) 02-2222-3333");
        return false
    }
    
    return true;
}

function dateFormatCheck(str_datetime, format) {
    
    switch(format) {
        case "YYYY-MM-DD" :
            re_date = /^\d{4}-\d{2}-\d{2}$/;
            break;
        case "YYYY-MM" :
            re_date = /^\d{4}-\d{2}$/;
            break;
    }
    
    if (!re_date.exec(str_datetime)) {
        alert("³¯Â¥ Çü½ÄÀÌ Æ²·È½À´Ï´Ù. : "+str_datetime+"\n\n¿¹) "+format);
        return false
    }
    
    var y = str_datetime.substring(0, 4);
    var m = str_datetime.substring(5, 7);
    var d = str_datetime.substring(8);
    
    var er = 0; // ¿¡·¯ º¯¼ö
    var daa = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    if (y%1000 != 0 && y%4 == 0) daa[1] = 29; // À±³â
    if(format=="YYYY-MM-DD")
        if (d > daa[m-1] || d < 1) er = 1; // ³¯Â¥ Ã¼Å©
    if (m < 1 || m > 12) er = 1; // ¿ù Ã¼Å©
    if (m%1 != 0 || y%1 != 0 || d%1 != 0) er = 1; // Á¤¼ö Ã¼Å©
    
    if(er == 1) {
        alert("³¯Â¥¸¦ Àß¸ø ÀÔ·Â ÇÏ¼Ì½À´Ï´Ù.");
        return false;
    } else
        return true;
}

/**
 * ÀÔ·Â°ªÀÌ »ç¿ëÀÚ°¡ Á¤ÀÇÇÑ Æ÷¸Ë Çü½ÄÀÎÁö Ã¼Å©
 * ÀÚ¼¼ÇÑ format Çü½ÄÀº ÀÚ¹Ù½ºÅ©¸³Æ®ÀÇ `regular expression`À» ÂüÁ¶
 */
function isValidFormat(input,format) {
    if (input.value.search(format) != -1) {
        return true; //¿Ã¹Ù¸¥ Æ÷¸Ë Çü½Ä
    }
    return false;
}

/**
 * ÀÔ·Â°ªÀÌ ÀüÈ­¹øÈ£ Çü½Ä(¼ýÀÚ-¼ýÀÚ-¼ýÀÚ)ÀÎÁö Ã¼Å©
 */
function isValidPhone(input) {
    var format = /^(\d+)-(\d+)-(\d+)$/;
    return isValidFormat(input,format);
}

/**
 * ÀÌ¹ÌÁö Å¬¸¯½Ã ÆË¾÷
 */
String.prototype.popupImage = function(width, height) {
    var img_view = this;
    
    htmlz = "<html><head><title>ÀÌ¹ÌÁöÅ©°Ôº¸±â</title><style>body{margin:0;cursor:pointer;}</style></head><body scroll=auto onclick='top.window.close();'><img src='"+img_view+"' title='Å¬¸¯ÇÏ½Ã¸é ´ÝÈü´Ï´Ù.'></body></html>";
    
    imagez = window.open('', "image", "width=500, height=689, top=0,left=0,scrollbars=auto,resizable=1,toolbar=0,menubar=0,location=0,directories=0,status=1");
    imagez.document.open();
    imagez.document.write(htmlz);
    imagez.document.close();
}

/* ¹®ÀÚ¿­ Ã¼Å© */
function CheckByte(str)
{
    var i;
    var strLen;
    var strByte;
    strLen = str.length;
    var IEYES = 0;
    var menufacture = navigator.appName;
    var version = navigator.appVersion;
    if( ( menufacture.indexOf('¸¶ÀÌÅ©·Î¼ÒÇÁÆ®') >= 0 || menufacture.indexOf('Microsoft') >= 0 )
   && (version.indexOf('4.0') >= 0 || version.indexOf('5.0') >= 0
       || version.indexOf('6.0') >= 0 || version.indexOf('7.0') >= 0
       || version.indexOf('8.0') >= 0 || version.indexOf('9.0') >= 0 ) )
    {
       IEYES = 1;
    }


    // IE4.0 ÀÌ»ó
    if(IEYES == 1)
    {
        for(i=0, strByte=0;i<strLen;i++)
        {
            if(str.charAt(i) >= ' ' && str.charAt(i) <= '~' )
                strByte++;
            else
                strByte += 2;
        }
        return strByte;
    }
    // NetscapeÀÏ °æ¿ì
    else
    {
        return strLen;
    }
}


function menuMove(id, mode) { 
    // mode can be 'first', 'last', 'up', 'down' 
    var obj = document.getElementById(id); 
    var idx = obj.selectedIndex; 
    if (idx < 0) idx = obj.selectedIndex = 0; 

    var opt = obj.options[obj.selectedIndex]; 

    switch (mode) { 
        case 'first': 
            obj.insertBefore(opt, obj.options[0]); 
            break; 
        case 'last': 
            obj.appendChild(opt); 
            break; 
        case 'up': 
            if (idx > 0) obj.insertBefore(opt, obj.options[idx-1]); 
            break; 
        case 'down': 
            if (idx < obj.options.length-1) obj.insertBefore(obj.options[idx+1], opt); 
            break; 
    } 
} 

document.getElementsByClassName = function(className) { 
    var children = document.getElementsByTagName('*') || document.all; 
    var elements = []; 
    for(var i=0, l=children.length; i<l; i++) { 
        var childClass = (children[i].className) ? children[i].className.split(' ') : false; 
        if(childClass) 
            for(var n=0, m=childClass.length; n<m; n++) 
                if(childClass[n] == className) elements.push(children[i]); 
    } 
    return elements; 
}


// À¯È¿¼º Ã¼Å©
function chkValue(objectName, msg, isSet) {
    var val = eval('document.'+objectName+'.value');

    if (val.replace(' ', '') == '') {
        alert(msg+' ÀÔ·ÂÇØ ÁÖ¼¼¿ä');
        if (isSet) eval('document.'+objectName+'.focus();');
        return false;
    }
    return true;
}


function _getTime() {
  // ½Ã°£°ú °ü·ÃµÈ º¯¼ö ÃÊ±âÈ­
  var now = new Date();
  var year = now.getFullYear();
  var month = now.getMonth()+1;
  var day = now.getDay()+1;
  var hour = now.getHours();
  var minute = now.getMinutes();
  var second = now.getSeconds();
  now = null

  //hour = (hour == 0) ? 12 : hour
  if( month < 10 ) month = "0" + month      // 10¿ù ¹Ì¸¸ÀÏ °æ¿ì ¾Õ¿¡ 0À» ºÙ¿©ÁÜ
  if( day < 10 ) day = "0" + day            // 10ÀÏ ¹Ì¸¸ÀÏ °æ¿ì ¾Õ¿¡ 0À» ºÙ¿©ÁÜ
  if( hour < 10 ) hour = "0" + hour         // 10½Ã ¹Ì¸¸ÀÏ °æ¿ì ¾Õ¿¡ 0À» ºÙ¿©ÁÜ
  if( minute < 10 ) minute = "0" + minute   // 10ºÐ ¹Ì¸¸ÀÏ °æ¿ì ¾Õ¿¡ 0À» ºÙ¿©ÁÜ

  // ½Ã°£ ¹®ÀÚ¿­ ¹ÝÈ¯
  return year +''+ month +''+ day +''+ hour +''+ minute +''+ second;
}

        
        
//ÀÌ¹ÌÁö ¸®»çÀÌÁî
function resizeImg(imgID, maxWidth, maxHeight){
 imgWidth = document.getElementById(imgID).width;
 imgHeight = document.getElementById(imgID).height;

 if(imgWidth > maxWidth || imgHeight > maxHeight){
  if(imgWidth > imgHeight){
   reWidth  = maxWidth;
   reHeight = Math.round((imgHeight * reWidth) / imgWidth) ;
  }else{
   reHeight = maxHeight;
   reWidth  = Math.round((reHeight * imgWidth) / imgHeight) ;
  }
 }else{
  reWidth  = imgWidth ;
  reHeight = imgHeight ;
 }

 document.getElementById(imgID).width = reWidth;
 document.getElementById(imgID).height = reHeight;
}

function showDivForm(obj) {
    var e = isMIE() ? event : evt;
    var pwdtop = (e.clientY + 1 + document.body.scrollTop)+'px';
    var pwdleft = isMIE()? (document.documentElement.offsetWidth/2 + 100)+'px':(self.innerWidth/2-125)+'px';
    obj.style.left = pwdleft;
    obj.style.top = pwdtop;
    obj.style.display = 'inline';
}

function isMIE() {
    if (navigator.appName == 'Microsoft Internet Explorer') return true;
    else false;
}

function setSelectBox(combo, comboVal){
	for(var i=0; i<combo.options.length; i++ ) {
		if( combo.options[i].value == comboVal ) {
			combo.options[i].selected = true;
			break;
		}
	}
}

