function name() {
  var okay_to_process = false;
  if (document.getElementById('entrant_name').value.length < 1) {
     document.getElementById("msg_entrant_name").innerHTML="You must enter your legal name before proceeding";
    okay_to_process = false;
  } else {
     document.getElementById("msg_entrant_name").innerHTML="";
     okay_to_process = true;
  }
  return okay_to_process;
}

function email() {
  var okay_to_process = false;
  if (document.getElementById('entrant_email').value.length < 1) {
     document.getElementById("msg_entrant_email").innerHTML = "You must enter a valid email address.";
     okay_to_process = false;
  } else {
     document.getElementById("msg_entrant_email").innerHTML="";
     okay_to_process = true;
  }
  return okay_to_process;
}

function file_existing() {
  var okay_to_process = false;
  var myform = document.forms['smiths'];
  var total_files=0;

  thisFileRef = "uploaded_file";
  if (document.getElementById(thisFileRef).value.length >=5) {
      var fileName = document.getElementById(thisFileRef).value;
      var fileLength = fileName.length-3;
      var fileExt = fileName.substring(fileLength, fileLength+3).toLowerCase();
      if ((fileExt != 'jpg') && (fileExt != 'gif') && (fileExt != 'png')) {
             document.getElementById("msg_uploaded_file").innerHTML = "File Rejected and Removed.  Uploads must be either a .jpg, .png or .gif format!";
             document.getElementById("uploaded_file").value = null;
	     document.getElementById("msg_uploaded_file").innerHTML = "Please select a file to upload.";
             okay_to_process = false;
      } else {
             total_files++;
             document.getElementById("msg_uploaded_file").innerHTML = "";
             okay_to_process = true;
      }
  } else {
	document.getElementById("uploaded_file").value = null;
	document.getElementById("msg_uploaded_file").innerHTML = "Please select a file to upload.";
        okay_to_process = false;
  }

  if (total_files == 0 && okay_to_process == true) {
        alert('There is no file selected for upload.  Please select a file to upload and press the Submit button to proceed.');    
        okay_to_process = false;
  }
  return okay_to_process;
}

function okToSubmit() {
  name();
  email();
  file_existing();
  if (name() == true && email() == true && file_existing() == true) {
    return true;
  } else {
    return false;
  }
}

