(function($) {
      
  $.fn.example = function(text, args) {
    
    var options = $.extend({}, $.fn.example.defaults, args);
    
    var callback = $.isFunction(text);
    
    if (!$.fn.example.bound_class_names[options.class_name]) {

      $(window).unload(function() {
        $('.' + options.class_name).val('');
      });
      
      $('form').submit(function() {
        
        $(this).find('.' + options.class_name).val('');
      });
      
      $.fn.example.bound_class_names[options.class_name] = true;      
    }
    
    return this.each(function() {
      
      var $this = $(this);
      
      if ($.browser.msie && !$this.attr('defaultValue') &&
          (callback ? $this.val() != '' : $this.val() == text)) {
        $this.val('');
      }

      if ($this.val() == '') {
        $this.addClass(options.class_name);
        
        $this.val(callback ? text.call(this) : text);
      }
    
      if (options.hide_label) {
        var label = $('label[@for=' + $this.attr('id') + ']');
        
        label.next('br').hide();
        label.hide();
      }

      $this.focus(function() {
        
        if ($(this).is('.' + options.class_name)) {
          $(this).val('').css({color: '#000'});
          $(this).removeClass(options.class_name);
        }
      });
    
      $this.blur(function() {
        if ($(this).val() == '') {
          $(this).addClass(options.class_name).css({color: '#ccc'});
          
          $(this).val(callback ? text.call(this) : text);
        }
      });
    });
  };
  
  $.fn.example.defaults = {
    class_name: 'example',
    
    hide_label: false
  };
  
  $.fn.example.bound_class_names = [];
  
})(jQuery);


/* Поля */
$(document).ready(function(){
	$('#auth_login').css({color: '#ccc'}).example('Логин');
	$('#auth_password').css({color: '#ccc'}).example('Пароль');
	$('#search-input').css({color: '#ccc'}).example('Впишите название вещи');
})
/* /Поля */
