//----------------------------------------------------------------------------------------------------
// Check input field values, set them, and replace them
//----------------------------------------------------------------------------------------------------

$(document).ready(function(){
  
  /** 
    * Declare variables to contain the object we need to control
    */
  var emailField = document.getElementById("email_address");
  var EMAILFIELD = "YOUR EMAIL ADDRESS HERE";
  
  /** 
    * Set the default value of the "Search" field
    */
  //emailField.value = EMAILFIELD;
  
  /**
    * Set onclick functions to replace text if user clicks in the input field
    */
  emailField.onclick      = replaceTxt;
  
  /**
    * Set onclick functions to insert text if user clicks in the input field
    */
  emailField.onblur      = insertTxt;
  
  /** 
    * Create the function that will replace the current text with nothing
    */
  function replaceTxt() {
    if (this.value == "YOUR EMAIL ADDRESS HERE" ||
    this.value == "Invalid E-mail Address!" ||
    this.value=="Your e-mail has been sent!") {
      this.value = "";
    }
  }
  
  /** 
    * Create the function that will insert text into a blank input field
    */
  function insertTxt() {
    if (this.value == "") {
      switch(this.id) {
        case "email_address":
          this.value = EMAILFIELD;
          break;
        default:
          //alert('ERROR!!! ' + this.id);
      }
    }
  }
});