/*
 * Simple plugin for converting a text input's title attribute to some sample text.
 */
(function($) {

	$.fn.egText = function(options) {
		options  = $.extend({ }, $.fn.egText.defaults, options || { });
		var $all = this;
		$all.focus(function() {
				var $this = $(this);
				if(!$this.data(options.dataKey))
					$this.data(options.dataKey, 'yes').removeClass(options.egClass).val('');
			})
			.blur(function() {
				var $this = $(this);
				if($this.val() == '')
					$this.addClass(options.egClass).removeData(options.dataKey).val($this.attr('title'));
				else
					$this.data(options.dataKey, 'yes');
			})
			.blur();
		$.unique($all.closest('form')).submit(function() {
			$all.each(function() {
				var $this = $(this);
				if(!$this.data(options.dataKey))
					$this.val('');
			});
			return true;
		});
	};

	$.fn.egText.defaults = {
		dataKey: 'egText',	// The key we use for storing our state with .data(), just in case there are conflicts...
		egClass: 'lolite'	// The CSS class to add to the <input> when we're displaying the example text.
	};

})(jQuery);

// $HeadURL: http://localhost/svn/isos/tmpl/static/jquery/egText.js $
// $Id: egText.js 5989 2010-08-17 18:23:42Z mu $

