/**
 * Hint (for input text)
 *
 * @version 1.1 (11/05/2009)
 * @requires jQuery v1.3 or later
 * @author Ju-Sun Lee <jusun@zaang.com>
 * @copyright Copyright (c) 2009 Ju-Sun Lee, Zaang Inc
 * 
 * USAGE:
 * add to stylesheet: .hintme { #999 }
 * add to input text: class="hint" title="your hint here"
 */
(function($) {

	$.fn.hint = function(settings) {
		
		var config = {source:'title',cssClass:'hintme'};
		if (settings) $.extend(config, settings);

		this.each(function() {
			var me = $(this);
			
			me.focus(function() {
				if (me.val() == me.attr(config.source)) {
					me.val('');
					me.removeClass(config.cssClass);
				}
				return false;
			});

			me.blur(function() {
				if (me.val() == '') {
					me.val( me.attr(config.source) );
					me.addClass(config.cssClass);
				}
			});
			
			me.closest('form').submit(function() {
				me.focus();
			});
			
			me.blur();			
		});

		return this;

	};

})(jQuery);


// default class
$(function(){ $('.hint').hint(); });