window.onload = Init;

function Init()
{
  var textBox = document.getElementById("s");
  var tbm = new TextBoxManager(textBox, "Search");

  var searchSubmitButton = document.getElementById("searchSubmitButton");
  searchSubmitButton.onmouseover = function() {
    window.status="";
    return true;
  }

  var commentSubmitButton = document.getElementById("commentSubmitButton");
  commentSubmitButton.onmouseover = function() {
    window.status="";
    return true;
  }
}

function TextBoxManager(textBox, defaultText)
{
  var me = this;

  this.defaultText = (defaultText == null ? this.textBox.value : defaultText);
  this.isVirgin = true;
  this.textBox = textBox;

  this.textBox.value = this.defaultText;

  this.textBox.onchange = function() {
    me.isVirgin = false;
  }

  this.textBox.onfocus = function() {
    if ( me.isVirgin )
      me.textBox.value = "";
  }

  this.textBox.onblur = function() {
    if ( me.textBox.value == "" )
    {
      me.textBox.value = me.defaultText;
      me.isVirgin = true;
    }
  }
}
