(function($) {
	$.fn.watermark = function(c, t) {
		var x = function(e) {
			var i = $(this);
			var w = t || i.attr('title');
			if (!i.val() || (i.val() == w)) {
				var $c = $($("<div />").append(i.val("").clone()).html().replace(/type=\"?password\"?/, 'type="text"')).val(w).addClass(c);
				i.replaceWith($c);
				$c.focus(function() {
					$c.replaceWith(i); i.bind('blur', x); setTimeout(function() {i.focus();}, 1);
				})
				.change(function() {
					i.val($c.val()); $c.val(w); i.val() && $c.replaceWith(i);
				})
				.closest('form').submit(function() {
					$c.replaceWith(i);
				});
			}
		};
		return $(this).bind('change', x).change();
	};
})(jQuery);
