/* javascript for email form  */

/* function looks at required form fields and checks to see if they
   are an empty string- if so, return false and tell user what needs to 
   be filled in. if true, can submit form.
*/
function checkWholeForm(emailForm)
{

  var emptyFields = ""; // fields variable
  var why = ""; // check variable
  why += "_____________________________________________________________________\n\n";
  why += "The form was not submitted because of the following error(s).\n";
  why += "Please correct these error(s) and re-submit.\n";
  why += "_____________________________________________________________________\n\n";
  why += "- The following required field(s) are empty: \n";
 
  emptyFields += checkIsEmpty(emailForm.email.value, 'Email Address.');  // check email field
  emptyFields += checkIsEmpty(emailForm.subject.value, 'Email Subject.');  // check subject field
  emptyFields += checkIsEmpty(emailForm.text.value, 'Email Text.');  // check text field

  why += emptyFields;

  // is emptyFields empty?
  if (emptyFields != "")
  {
    alert(why); // alert popup- display return from checkIsEmpty()
    return false;
  }
  return true;
}

// look at string, if empty- alert 
function checkIsEmpty(strng, name)
{
  if (strng == "") { return "\t" + name + "\n";
  }
  else { return ""; }
}

/* change colors onfocus */
function setStyle(x) {
  document.getElementById(x).style.background="#e6edf5";
}
function removeStyle(x) {
  document.getElementById(x).style.background="white";
}

