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;
}