var Input = {};

Input.Hint = function (input, text) {
  var that = this;

  that.input = $(input);
  that.text = that.input.val();
  
  if (that.text.length > 0) {
    that.input.addClass('focus');
    that.inner = true;
  } else {
    that.text = text || '';
    that.inner = false;
  }

  that.input.focus(function (e) {
    that.onFocus();
  });
  that.input.blur(function (e) {
    that.onBlur();
  });

  that.input.val(that.text);
}

Input.Hint.prototype = {
  'onFocus': function () {
    if (this.input.val() != this.text) {
      return;
    }

    this.input.addClass('focus');
    this.input.val('');
  },

  'onBlur': function () {
    if (this.input.val() != '') {
      return;
    }

    if (!this.inner) {
      this.input.removeClass('focus');
    }
    this.input.val(this.text);
  }
};


