jQuery.fn.extend({
  SearchBoxPresenter: function(properties) {
    return this.each(function() {
      if (properties != undefined) {
        this.__properties = properties;
      }
      changeEvent = function() {
        $(this.parentNode).publixeRegistrChange('text', this.value);
      };
      clickEvent = function() {
        w = this.parentNode;
        $(w).publixeEvent(w.__properties.onClick);
      };
      $(this).keypress(function (e) {
        if (e.which == 13) {
          $('input', this).change();
          $('button', this).click();
        }
      });

      $('input', this).change(changeEvent);
      if (this.__properties != undefined) {
        if (this.__properties.defaultText != undefined) {
          sel = $('input', this);
          e = sel.get(0);
          e.value = this.__properties.defaultText;
          e.__defaultText = this.__properties.defaultText;

          sel.blur(function() {
            if (this.value == '') {
              this.value = this.__defaultText;
            }
          });
          sel.click(function() {
            if (this.value == this.__defaultText) {
              this.value = '';
            }
          });
        }
        if (this.__properties.onClick != undefined) {
          $('button', this).click(clickEvent);
        }
      }

    });
  }
});
