(function($){
	$.fn.extend({ 
		titledInput: function(options) {
			var defaultOptions = {
					attribute: "title",
					setOnLoad: true
			};
			options = $.extend(defaultOptions, options);
				
			return this.each(function() {
				var $that = $(this);
				
				var focusHandler = function() {
					if ($that.val() == $that.attr(options.attribute)) {
						$that.val("");
					}
				};
				
				var blurHandler = function() {
					if (!$that.val() || $that.val().trim().length == 0) {
						$that.val($that.attr(options.attribute));
					}
				};
				
				$that.focus(focusHandler);
				$that.blur(blurHandler);
				
				if (options.setOnLoad) {
					blurHandler();
				}
			});
		}
	});
})(jQuery);

