function Validation()
{
   var args = Validation.arguments;
   var obj
   var result

   if(!args[3])
   {
     return args[3];  
   }

   obj=eval(args[0])
   
   result= false;
   
   switch(args[1])
   {
      case "box":
          
         if(eval(obj.length))
         {
            for(i=0;i<obj.length;i++)
            {  
               if(obj[i].checked)
               {
                  result=true;
                  break;  
               }
            }
         }
         else
         {
            if(obj.checked)
            {
               result=true;
               break;  
            }
         }
         break;
     case "select":
          
          if(obj.selectedIndex!=0)
          {
             result=true;
          }
          break;     
     case "mail":
          if(obj.value.indexOf("@")!=-1&&obj.value.indexOf(".")!=-1)
          {
             result=true;
          }
          break;     
     case "hipon":
          if(obj.value.indexOf("-")==-1)
          {
             result=true;
          }
          break;          
     case "int":
          if(Len(obj.value)>0)
          {
            if(IsNumeric(obj.value))
            {
               result=true;
            }
          }
          else
          {
            result=true;
          }
          break;        
     default:
       if(Len(obj.value)>0)
       {
          result= true;
       }   
          break;     
   }
   
   if(!result)
   {
      if(args[2]!="")
      {
      alert(args[2]);
      if(args[1]==""||args[1]=="mail"||args[1]=="int"){obj.focus();}
      }
   }
   
   return result;

}
function Len(sen) 
{
  
  var blank_pos,text_len;
  blank_pos = sen.indexOf(" ");	
  while (blank_pos != -1)
  {
        sen = sen.replace(" ", "");
		blank_pos  = sen.indexOf(" ");
		
  }
  text_len=sen.length;
  return text_len;
}
function containsCharsOnly(input,chars) {
    for (var inx = 0; inx < input.length; inx++) {
       if (chars.indexOf(input.charAt(inx)) == -1)
           return false;
    }
    return true;
}
function IsNumeric(input) {
    var chars = "0123456789";
    return containsCharsOnly(input,chars);
}


//========================== ÇÊµå Á¦ÇÑ ½ÃÀÛ =============================//
function ChkStrLength() {
this.updateChar = function(length_limit,limit_panel) {
   var comment = event.srcElement;
   var length = this.calculate_msglen(comment.value);
   var textlimit = document.getElementById(limit_panel);
   if(textlimit) textlimit.innerHTML = length;
   if(length > length_limit) {
      alert("ÃÖ´ë " + length_limit + "byteÀÌ¹Ç·Î ÃÊ°úµÈ ±ÛÀÚ¼ö´Â ÀÚµ¿À¸·Î »èÁ¦µË´Ï´Ù.");
      //comment.value = comment.value.replace(/\r\n$/, "");
      comment.value = this.assert_msglen(comment.value, length_limit, limit_panel);
   }
}

this.calculate_msglen = function(message) {
   var nbytes = 0;

   for(i=0; i<message.length; i++) {
      var ch = message.charAt(i);
      if(escape(ch).length > 4) {
         nbytes += 2;
      }
      else if(ch == '\n') {
         if(message.charAt(i-1) != '\r') {
            nbytes += 1;
         }
      }
      else if(ch == '<' || ch == '>') {
         nbytes += 4;
      }
      else {
         nbytes += 1;
      }
   }

   return nbytes;
}

this.assert_msglen = function(message, maximum, limit_panel) {
   var inc = 0;
   var nbytes = 0;
   var msg = "";
   var msglen = message.length;
   var textlimit = document.getElementById(limit_panel);

   for(i=0; i<msglen; i++) {
      var ch = message.charAt(i);
      if(escape(ch).length > 4) {
         inc = 2;
      }
      else if (ch == '\n') {
         if(message.charAt(i-1) != '\r') {
            inc = 1;
         }
      }
      else if (ch == '<' || ch == '>') {
         inc = 4;
      }
      else {
         inc = 1;
      }
      if((nbytes + inc) > maximum) {
         break;
      }
      nbytes += inc;
      msg += ch;
   }
   if(textlimit) textlimit.innerHTML = nbytes;
   return msg;
}
}

var csl2 = new ChkStrLength();

//========================== ÇÊµå Á¦ÇÑ ³¡ =============================//