String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)|($\s*)/g, "");
}

String.prototype.isid = function() {
	if (this.search(/[^A-Za-z0-9_-]/) == -1)
		return true;
	else 
		return false;
}

String.prototype.isalpha = function() {
	if (this.search(/[^A-Za-z]/) == -1)
		return true;
	else
		return false;
}

String.prototype.isnumber = function() {
	if (this.search(/[^0-9]/) == -1)
		return true;
	else
		return false;
}

String.prototype.isemail = function() {
   var flag, md, pd, i;
   var str;

   if ( (md = this.indexOf("@")) < 0 )
      return false;
   else if ( md == 0 )
      return false;
   else if (this.substring(0, md).search(/[^.A-Za-z0-9_-]/) != -1)
      return false;
   else if ( (pd = this.indexOf(".")) < 0 )
      return false;
   else if ( (pd + 1 )== this.length || (pd - 1) == md )
      return false;
   else if (this.substring(md+1, this.length).search(/[^.A-Za-z0-9_-]/) != -1)
      return false;
   else
      return true;
}

String.prototype.korlen = function() {
   var temp;
   var set = 0;
   var mycount = 0;
   
   for( k = 0 ; k < this.length ; k++ ){
      temp = this.charAt(k);
   
      if( escape(temp).length > 4 ) {
         mycount += 2; 
      }
      else mycount++;
   }

   return mycount;
}

String.prototype.isssn = function() {
   
   var first  = new Array(6);
   var second = new Array(7);
   var total = 0;
   var tmp = 0;
   
   if ( this.length != 13 )
      return false;
   else {
      for ( i = 1 ; i < 7 ; i++ )
         first[i] = this.substring(i - 1, i);
   
      for ( i = 1 ; i < 8 ; i++ )
         second[i] = this.substring(6 + i - 1, i + 6);
   
      for ( i = 1 ; i < 7 ; i++ ) {
         if ( i < 3 )
            tmp = Number( second[i] ) * ( i + 7 );
         else if ( i >= 3 )
            tmp = Number( second[i] ) * ( ( i + 9 ) % 10 );
      
         total = total + Number( first[i] ) * ( i + 1 ) + tmp;
      }
   
      if ( Number( second[7] ) != ((11 - ( total % 11 ) ) % 10 ) ) 
         return false;
   }
   return true;
}

String.prototype.ByteLength = function() {
	var i,ch;
	var strLength = this.length;
	var count = 0;

	for(i=0;i<strLength;i++)
	{
		ch = escape(this.charAt(i));

		if(ch.length > 4)
			count += 2;
		else if(ch!='\r') 
			count++;
	}
	return count;
}

/**
 * 문자열을 형식화(3자리마다 콤마 삽입)된 식으로 반환합니다.
 */
String.prototype.NumberFormat = function() {
	var str = this.replace(/,/g,"");
	var strLength = str.length;

	if (strLength<=3) return str;
	
    var strOutput = "";
    var mod = 3 - (strLength % 3);
	var i;

    for (i=0; i<strLength; i++) 
	{
		strOutput+=str.charAt(i); 
        if (i < strLength - 1) 
		{
			mod++; 
            if ((mod % 3) == 0) 
			{ 
				strOutput +=","; 
                mod = 0; 
			}
		} 
	} 
	return strOutput;
}

/**
 * 3자리수마다 ","처리 삭제 wookki25 2005-09-21
 */
String.prototype.DeNumberFormat = function() {
	var str = this.replace(/,/g,"");
	return str;
}

String.prototype.isKorean = function() {
	Unicode = this.charCodeAt(0);
	if ( !(44032 <= Unicode && Unicode <= 55203) )
		return false;
	else
		return true;
}

String.prototype.isEnglish = function() {
	if (this.search(/[^A-Za-z]/) == -1)
	   return true;
	else
	   return false;
}

String.prototype.lenH = function() {
   var temp;
   var set = 0;
   var mycount = 0;
      
   for( k = 0 ; k < this.length ; k++ ){
      temp = this.charAt(k);
      
      if( escape(temp).length > 4 ) {
         mycount += 2; 
      }
      else mycount++;
   }

   return mycount;
}