function $(name){
  return document.getElementById(name);
}


/**
 * Quick Search form client model
 */

function Search(){};
Search.prototype.searchForm = {
    initialize: function(form, field, emptyText){
        this.form   = $(form);
        this.field  = $(field);
        this.emptyText = emptyText;

        this.form.onsubmit = function(e){return Search.prototype.searchForm.submit(e);};
        if (typeof(this.field.addEventListener) != "undefined"){
          this.field.addEventListener('focus', function(e){Search.prototype.searchForm.focus(e);},false);
          this.field.addEventListener('blur', function(e){Search.prototype.searchForm.blur(e);},false);
        }
        else {
          this.field.attachEvent('onfocus', function(e){Search.prototype.searchForm.focus(e);});
          this.field.attachEvent('onblur', function(e){Search.prototype.searchForm.blur(e);});
        }
      
        this.blur();
    },

    submit : function(event){
        if (this.field.value == this.emptyText || this.field.value == ''){
            return false;
        }
        return true;
    },

    focus : function(event){
        if(this.field.value==this.emptyText){
            this.field.value='';
        }

    },

    blur : function(event){
        if(this.field.value==''){
            this.field.value=this.emptyText;
        }
    }
}
