/*
 * jQuery hint plugin
 *
 * version 0.1 (01/13/2009)
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */


;(function($) {
 	$.hint = {tip_text_color: '#AFAFAF', base_text_color: '#000'};
 	
    $.fn.extend({
        hint: function(options) {
            
            
            
            var options = options || {};
            $.hint.tip_text_color = options.hint_color || $.hint.tip_text_color;
            $.hint.base_text_color = options.text_color || $.hint.base_text_color;
            
            return this.each(function() {
                
                var hint_it = function(input){
                    //skiping filled values and equal to rel attribute values
                    if($(input).val().replace(/^\s+/,'').replace(/\s+$/,'').length && $(input).val() != $(input).attr('title')){
                        $(input).css('color', $.hint.base_text_color);
                        return;
                    }
                    
                     $(input).css('color', $.hint.tip_text_color).val($(input).attr('title'))
                     .focus(function(){
                         if($(input).val() == $(input).attr('title')){
                             $(input).css('color', $.hint.base_text_color).val('');
                         }
                     })
                     .blur(function(){
                        hint_it(input);
                      }).change(function(){
                          if($(input).val().replace(/^\s+/,'').replace(/\s+$/,'').length && $(input).val() != $(input).attr('title')){
                              $(input).css('color', $.hint.base_text_color);
                          }
                      });    
                }
              //onload  
              hint_it(this);
            });  
        },
        
        clear_hints: function(){
            return this.each(function() {
               if($(this).attr('title') == $(this).val()){
                   $(this).val('');
               } 
            });
        }
    });
    
    
    
})(jQuery);


