var commentLimit = 500;
document.observe('dom:loaded',
	function (e) {
		$$('.tx-guestbook-form-textarea').each(
			function (n) {
				var counter = n.previous('div.guestbookCounter').down('span.counter');
				counter.innerHTML = (commentLimit - n.value.length) + '';
				
				Cufon.replace(counter,{fontFamily:'standard 07_53'});
				
				var oldComment = n.value;
				n.observe('keyup',
					function (e) {
						if (n.value.length > commentLimit) {
							n.value = oldComment;
							n.scrollTop = n.scrollHeight;
						} else {
							oldComment = n.value;
						}
						
						counter.innerHTML = commentLimit - n.value.length;
						Cufon.replace(counter,{fontFamily:'standard 07_53'});
					}
				);
			}
		);
	}
);

