/*******************************************************************************
	Description		: String handling functions
	Last Modified	: 2003.05.06
*******************************************************************************/
/*
	Syntax			: int String::bytes(void)
	Description		: This function returns the length of string in bytes.
*/
String.prototype.bytes = function() {
	var blen = 0;		// length (bytes)

	for(var i = 0; i < this.length; i++)
		blen += (this.charCodeAt(i) > 128) ? 2 : 1;

	return blen;
}

/*
	Syntax			: string String::cut(int len)
	Description		: This function cuts the string by 'len' (bytes).
*/
String.prototype.cut = function(len) {
	var blen = 0;		// length (bytes)

	for(var i = 0; i < this.length; i++) {
		blen += (this.charCodeAt(i) > 128) ? 2 : 1;
		if(blen > len) return this.substring(0, i) + "...";
	}

	return this;
} 
