function inputCaption(inputId){
   /* Creates a caption inside the provided input using the input title
      and removes it when the field receives focus */
   if(!document.getElementById) return;
   var inputElement = document.getElementById(inputId);
   if(inputElement){
      if(inputElement.title){
         inputElement.className = "captioned";
         inputElement.value = inputElement.title;
         inputElement.onfocus = function(){
            if(inputElement.className == "captioned"){
               inputElement.className = "";
               inputElement.value = ""; 
            } 
         }
         inputElement.blur();
      }
      /* prevent submitting with the caption or an empty value */
      var p = inputElement.parentNode;
      while(p.nodeName != "FORM") p = p.parentNode;
      p.onsubmit = function(){
         if(inputElement.className == "captioned" || inputElement.value == "") return false;
      }
   }
}

window.onload = function(){
   inputCaption('searchField');
}