/**
 *   KK Form Input Tips ( jQuery )  v0.1b
 *
 *	 Author: Mrkelly
 *
 *	 MSN/Gtalk/Email: chepy.v@gmail.com
 *	 QQ: 23110388
 *   Twitter: @mrkelly
 *	 
 *	 Usage:
 		<input type="text" id="test_input" />
 		
 		<script>
 			$(function(){
 				$('#test_input').input_tips( 'some text to display on it.' );
 			});
 		</script>
 *
 */
 
 
 
(function($) {

	$.fn.input_tips = function( str ) {
	
		initial_target( $(this), str );
		
		$(this).blur(function(){
		
			if ( $(this).val() == '' ) {
				initial_target( $(this), str );
			}
			
		}).focus(function(){
			if ( $(this).val() == str ) {
				clear_target( $(this) );
			}
			
			
		});
	};
	
	// 用于失焦时 use for focus
	function initial_target( target, str ) {
		target.val( str ).css('color', '#999');
	}
	
	// 用于聚焦时 use for blur
	function clear_target( target ) {
		target.css('color', '#333');
		target.val('');
	}
	
})(jQuery);
