function openPhotoWin( thenoteid )
{
   var browser=navigator.appName + " " + navigator.appVersion;
   var theurl;

   theurl = '$$SA_CGI_URL?FNC=OpenPhotoWin__Aview_main_html___##Sa_url_orgcode##___' + thenoteid;

   if (browser.substring(0, 8)=="Netscape")
      {
      var picwin = window.open(theurl, 'ClassNotes', 'scrollbars=yes,location=no,toolbar=no,status=no,resizable=yes,width=700,height=550');

      if (picwin.opener == null)
	 { picwin.opener = window; }
      else
	 { 
	 if (browser.substring(0, 12)=="Netscape 2.0")
	    picwin.document.cnote.display.focus();
	 else
	    picwin.focus();
	 }
      }
   else
      {
      var picwin = window.open(theurl, 'ClassNotes', 'scrollbars=yes,location=no,toolbar=no,status=no,resizable=yes,width=700,height=550');

      if (picwin.opener == null)
	 { picwin.opener = window; }
      }
}

function openPhotoWinView( thenoteid )
{
   var browser=navigator.appName + " " + navigator.appVersion;
   var theurl;

   theurl = '$$SA_CGI_URL?FNC=OpenPhotoWin__Aview_main_html___##Sa_member_orgcode##___' + thenoteid;

   if (browser.substring(0, 8)=="Netscape")
      {
      var picwin = window.open(theurl, 'ClassNotes', 'scrollbars=yes,location=no,toolbar=no,status=no,resizable=yes,width=700,height=550');

      if (picwin.opener == null)
	 { picwin.opener = window; }
      else
	 { 
	 if (browser.substring(0, 12)=="Netscape 2.0")
	    picwin.document.forms[0].display.focus();
	 else
	    picwin.focus();
	 }
      }
   else
      {
      var picwin = window.open(theurl, 'ClassNotes', 'scrollbars=yes,location=no,toolbar=no,status=no,resizable=yes,width=700,height=550');

      if (picwin.opener == null)
	 { picwin.opener = window; }
      }
}

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();

}

