function ValidateAndSubmit(theform)
{
   //
   // make sure classnote was generated by checking that textarea
   //
   if( document.cnote.classnote.value == "" )
   {
        alert("Your note does not contain any text.  Please make sure you auto-generate the format for your note by completing Step 2.");
        return false;
   }

   //
   // make sure only click the submit form once!
   //
   if (submitcount == 0)
      submitcount++;
   else 
   {
      alert("This form has already been submitted.  Please close this window and wait for submission confirmation or refresh/reload the page and start again.");
      return false;
   }
   // if uploading a photo, pop-up alert box to warn of upload time
   // since the input field will not be displayed if a photo is not 
   // allowed for this note, check the allow_photo flag first, if it's
   // a 1, then we can check the input field.  If we didn't do this, then
   // we would have a js error
   if( document.cnote.types_allow_photo.value == "1" )
   {
       // this note allows photos so the input field should exist
       // and it is safe to do this verification
       if( document.cnote.UploadedFile.value != "" )
       {
           alert("You have elected to upload a photo with this note. \
Please be aware that it may take a minute or two to upload your photo \
depending upon the speed of your internet connection.");
       }
    }

   //      
   // get this far, everything is OK, so submit the form
   //
   theform.submit();

}


