Event.observe(window, 'load', function() {
	var forms = document.forms;
	if (forms.length == 0) return;
	var elems = Form.getElements(forms[0]);
	elems.each(function(el) {
		if (el.tagName == 'TEXTAREA') {
			el.onfocus = resizeTextarea;
		}
	});
});
function resizeTextarea()
{
	var min_rows = this.rows;
	var max_rows = min_rows * 3;
	var resize = function() {
		var match = this.value.match(/\r\n?|\n/g);
		var lines = match == null ? 1 : match.length + 2;
		this.rows = Math.max(min_rows, Math.min(lines, max_rows));
	};
	Event.observe(this, 'focus', resize);
	Event.observe(this, 'keyup', resize);
	Event.observe(this, 'mouseup', resize);
}
function mailer(to, subject, body)
{
	to = 'znvygb;' + to;
	to = to.replace(/\*/, '@');
	to = to.replace(/\:/, '.');
	to = to.replace(/\;/, ':');
	to = to.rot13();
	if (typeof subject == 'string') {
		to += '?subject=' + subject + '&';
	}
	if (typeof body == 'string') {
		to += 'body=' + body + '&';
	}
	if (confirm('メールを作成しますか？')) {
		location.href = to;
	}
}
String.prototype.rot13 = function() {
	return this.replace(/[a-z]/ig, function(c) {
		var n;
		return String.fromCharCode((n = c.charCodeAt(0) + 13) > (c <= 'Z' ? 90 : 122) ? n - 26 : n);
	});
};

