// START FLOWERS namespace
var FLOWERS = {

  // START formText function
  // This function controls the display of a default value in the header and footer form boxes.
  formText: function() {
    var inputArray = new Array('searchtext','email');
    var labelText = new Array();
    for (i in inputArray) { // Get the label text for each input field.
      theLabel = document.getElementById(inputArray[i]).parentNode.getElementsByTagName("label");
      labelText[i] = theLabel[0].innerHTML;
    }
  
    // START setText function
    // This controls the default value and the rendering/clear of it within the text boxes.
    function setText() {
      for (i in inputArray) {
        document.getElementById(inputArray[i]).value = labelText[i]; // Set the default value equal to the text of the hidden LABEL.
        document.getElementById(inputArray[i]).onfocus = clearText;
        document.getElementById(inputArray[i]).onblur = resetText;
      }
    }
    // END setText function
    
    // START clearText function
    // If on entry to the field the value is the default, remove it.
    function clearText() {
      for (i in inputArray) {
        if (inputArray[i] == this.id) {
          if (document.getElementById(this.id).value == labelText[i]) {
            document.getElementById(this.id).value = '';
          }
          break;
        }
      }
    }
    // END clearText function
    
    // START resetText function
    // If on leaving the field the value is blank, restore the default value.
    function resetText() {
      for (i in inputArray) {
        if (inputArray[i] == this.id) {
          if (document.getElementById(this.id).value == '') {
            document.getElementById(this.id).value = labelText[i];
          }
          break;
        }
      }
    }
    // END resetText function
  
  setText();
  
  }
  // END formText function
  
}
// END FLOWERS namespace

window.onload = FLOWERS.formText;