(function ($) {
	$.fn.inputHint = function(options) {
		options = $.extend({hintClass: 'hint', hintAttr: 'title'}, options || {});
		function hintFor(element) {
			var h;
			if (options.using && (h = $(options.using, element)).length > 0) {
				return h.text();
			} else {
				return $(element).attr(options.hintAttr) || '';
			}
		}
		function showHint() {
			if ($(this).val() == '') {
				$(this).addClass(options.hintClass).val(hintFor(this));
			}
		}
		function removeHint() {
			if ($(this).hasClass(options.hintClass)) $(this).removeClass(options.hintClass).val('');
		}
		this.filter(function() { return !!hintFor(this); })
			.focus(removeHint).blur(showHint).blur();
        this.each(function() {
            var self = this;
            $(this).parents('form').submit(function() { removeHint.apply(self); });
        });
		return this.end();
	};
})(jQuery);