// email_form.js for stepback.ca
// functionality for the email list form

function isDefined(property) {
  return (typeof property != 'undefined');
}

function emailFormInit() {
   if (document.getElementById('label-email') && document.getElementById('input-email')) {
   
      // take label for the input box and display it in the box
      doBlurEmailInput()
      
      // add event handlers to toggle display of the label
      var inputField = document.getElementById('input-email');
      addEvent(inputField, 'focus', doFocusEmailInput, false);
      addEvent(inputField, 'blur', doBlurEmailInput, false);
   }
}

// turn label off when focus is put on the input box
function doFocusEmailInput() {
   var labelText = document.getElementById('label-email').innerHTML;
   var inputField = document.getElementById('input-email');
   if (inputField.value == labelText) {
      inputField.value = '';
   }  
}

// turn label on when focus is removed from the input box
function doBlurEmailInput() {
   var labelText = document.getElementById('label-email').innerHTML;
   var inputField = document.getElementById('input-email');
   if (inputField.value == '') {
      inputField.value = labelText;
   }
}

// call emailFormInit when document finishes loading
addEvent(window, 'load', emailFormInit, false);


