(function( $ ){
  var methods = {
    init : function( value ) { 
      return this.each(function() {
        var initVal = value;
        var $this = $(this);
        var data = $this.data('autoSwap');
        
//        if($this.val() != '') {
//          $this.addClass('complete');
//        }
        
        if ( ! data ) {
         // if( $this.val() == '' ) {
             
            $this.focus(function(){
              $this.removeClass('complete');
              if($this.val() == value)
                $this.val('');
            }).blur(function(){
              if($this.val() == '')
                $this.val(value);
              else {
                $this.addClass('complete');
              }
            });
            $this.val(value);
         // }
          
          $(this).data('autoSwap', {
               target : $this,
               initVal : value
           });
        }
      });
    },
    reset : function( ) { 
      return this.each(function(){
         var $this = $(this),
             data = $this.data('autoSwap');

         if(data) {
           if($this.val() == data.initVal)
            $this.val('');
          }
         $this.removeData('autoSwap');

       })
    
    }
  };

  
  $.fn.autoSwap = function( method ) {  
    if ( methods[method] ) {
      return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
    } else if ( typeof method === 'string' || ! method ) {
      return methods.init.apply( this, arguments );
    } else {
      $.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' );
    }  
  };
})( jQuery );
