(function($) {
	$.fn.textareaLimiter = function(limit) {
		return this.each(function() {

			var $this = $(this);

			$this.bind('blur focus change keydown keypress keyup change mouseout mouseleave',
					function(e) {
						if ($this.val().length > limit) {
							$this.val($this.val().substr(0, limit));
						}
						$this.next('p').text(
								'Wykorzystano ' + $this.val().length + ' z '
										+ limit + ' znaków.');
					});
			$this.keypress();
		});
	};
})(jQuery);
