/**
 * JavaScript for the SearchBox component
 *
 * @author Ben Barber (bbarber@i2rd.com)
 * @require i2rd-util.js
 * @param id the input ID.
 * @param kw optional keyword to use. 
 * 	Must be specified if the keyword differs from the input value.
 *  May be an empty string.
 */
if (typeof SB === 'undefined') {
  SB={};
  SB.init = function(id,kw) {
    var input = document.getElementById(id);
    if(arguments.length < 2) {kw = input.value;}
    var clearDefault = function() {if (this.value === kw) this.value = '';};
    var setDefault = function() {if (this.value === '') this.value = kw;};    
    i2rd.addEvent(input, 'focus', i2rd.bind(clearDefault, input));
    i2rd.addEvent(input, 'blur', i2rd.bind(setDefault, input));
  };
}
