(function($) {
	$.fn.extend({
		watermark: function(emptyText) {
		  function addWatermark(input) {
				if (input.val() == "") {
					input.addClass("watermark").val(emptyText);
				}
			}

			function removeWatermark(input) {
			  if (input.val() == emptyText) {
			    input.removeClass("watermark").val("");
			  }
			}

			this.filter("input[type=text],input[type=password]").each(function() {
				var $this = $(this)
					.focus(function() { removeWatermark($this); })
					.blur(function() { addWatermark($this); });

				// Remove the watermark before the form submits.
				$this.closest("form").submit(function() { removeWatermark($this); });

				addWatermark($this);
			});
		}
	});
})(jQuery);