/* Very basic JS Form Validation for empty fields */
function SubmitForm() {
  var errors = "";
  
  for (i = 0; i < document.forms[0].elements.length; i++) {
    if (document.forms[0].elements[i].value == "") {
      errors+= "- " + document.forms[0].elements[i].id + " is blank.\n";
    }
  }
  
  if (errors != "") {
    alert(errors);
    return false;
  }
}


/* Validates Contact Form */
function ValidateContactForm () {
  if(document.getElementById('name').value=="") {
    alert("You need to complete your Name");
    return false;
  }
  if(document.getElementById('comments').value=="") {
    alert("You need to complete your Comments");
    return false;
  }
  return true;
}


/* Validates Add News Form */
function ValidateAddNews () {
  if(document.getElementById('headline').value=="") {
    alert("You need to complete your News Title");
    return false;
  }
  if(document.getElementById('news_story').value=="") {
    alert("You need to complete your Description");
    return false;
  }
  return true;
}


/* Validates Update Entry Form */
function ValidateEntryForm () {
  if(document.getElementById('name').value=="") {
    alert("You need to complete the Name");
    return false;
  }
  if(document.getElementById('address').value=="") {
    alert("You need to complete the Address");
    return false;
  }
  if(document.getElementById('openinghours').value=="") {
    alert("You need to complete the Opening Hours");
    return false;
  }
  if(document.getElementById('telephone').value=="") {
    alert("You need to complete the Telephone Number");
    return false;
  }
  if(document.getElementById('services').value=="") {
    alert("You need to complete the Services");
    return false;
  }
  return true;
}
