var StrLength = Class.create();

StrLength.prototype = {
	initialize: function(option) {
		var str = $(option.id).value;
		this.strlength = str.length;

		str = str.replace(/[\n|\r|\t|\f|\b]/g, '');
		this.strcount = str.length;

		str = escape(str);
		this.byte = 0;
		for (var i = 0; i < str.length; i++, this.byte++) {
			if (str.charAt(i) == '%') {
				if (str.charAt(++i) == 'u') {
					i += 3;
					this.byte++;
				}
				i++;
			}
		}
	},
	show: function(option) {
		var length = Math.ceil(this.byte / 2);
		$(option.error).innerHTML = (length > option.over) ? option.over + '文字までです!' : '';
		$(option.count).value = length;
	}
}

