function OkToSubmit()
{
//      var form = document.getElementById("reunionForm");
  var dateDelim = "-";
  var form = document.reunionForm;
  var result = false;   //don't submit
  var errors = 0;
  var errorMsg = "Please fix the following:\n";
  if( form )
  {
    var cost          = form.cost.value;
    var hasCost       = (cost.length > 0);
    var isValidCents  = false;
    if( hasCost )
    {
      if( !isNaN(cost) )
      {
        if( cost.indexOf(".") != -1 )
        {
          var re_validCents = /^\d*[.](\d{2})$/;
          isValidCents = (re_validCents.test(cost) && (cost.replace(re_validCents, "$1") >= 0) && (cost.replace(re_validCents, "$1") <= 99) );
        }
        else
        isValidCents = true;    //whole number
      }
    }
    var costIsValid   = (cost.length == 0 || (cost.length > 0 && !isNaN(cost) && isValidCents));
    var rsvpDeadline  = form.rsvpd_month.value + dateDelim + form.rsvpd_date.value + dateDelim + form.rsvpd_year.value;
    var reunionDate   = form.reunion_month.value + dateDelim + form.reunion_date.value + dateDelim + form.reunion_year.value;
    var reunionTime   = form.reunion_hour.value + ":" + form.reunion_minute.value + " " + form.reunion_timeofday.value;
    var rsvpTo        = form.rsvp_to.value;
    var payableTo     = form.payable_to.value;
    var details       = form.extra_detail.value;
/*
    alert("cost: " + cost + "\ndeadline: " + rsvpDeadline + "\nrsvpTo: " + rsvpTo +
          "\npayableTo: " + payableTo + "\ndetails: " + details +
          "\nrsvpTo.length = " + rsvpTo.length + "\ndetails.length = " + details.length +
          "\nreunionDate = " + reunionDate);
*/
    //validate cost
    if( !costIsValid )
    {
      errors++;
      errorMsg += "\tInvalid cost.\n";
      costIsValid = false;
    }

    //validate RSVP To
    if( rsvpTo.length == 0 )
    {
      errors++;
      errorMsg += "\tPlease enter some RSVP contact information.\n";
    }

    //validate PayableTo
    if( hasCost && payableTo.length == 0 )
    {
      errors++;
      errorMsg += "\tPlease enter who to make checks payable to.\n";
    }

    //validate details
    if( details.length == 0 )
    {
      errors++;
      errorMsg += "\tPlease enter the reunion details.\n";
    }
    
    //validate dates
    var dRSVP         = new Date(rsvpDeadline);
    var dReunion      = new Date(reunionDate + " " + reunionTime);
    var rightNow         = new Date();
//alert("rsvp: " + dRSVP + "\nreunion: " + dReunion + "\nrightNow: " + rightNow);
    if( dRSVP <= rightNow )
    {
      errors++;
      errorMsg += "\tInvalid RSVP Deadline.\n";
    }
    if( dReunion <= rightNow )
    {
      errors++;
      errorMsg += "\tInvalid Reunion Date.\n";
    }
  }

  if( errors == 0 )
  {
    result = confirm("Confirm that everything is accurate.\n" +
                    "Once submitted, you won't be able to change it.\n" +
                    "Click 'Cancel' to make revisions.\n" +
                    "Click 'OK' to proceed.");
  }
  else
    alert(errorMsg);


  return result;
}


function PostSubmit()
{
  var dateDelim = "/";
  var result = false;
  var form = document.reunionForm;
  if( form && form.rsvp_deadline && form.reunion_datetime )
  {
    try
    {
      //normal format
      var rsvpDeadline  = form.rsvpd_month.value + dateDelim + form.rsvpd_date.value + dateDelim + form.rsvpd_year.value;
      var reunionDate   = form.reunion_month.value + dateDelim + form.reunion_date.value + dateDelim + form.reunion_year.value + " " +
                          form.reunion_hour.value + ":" + form.reunion_minute.value + form.reunion_timeofday.value;
      form.rsvp_deadline.value = rsvpDeadline;
      form.reunion_datetime.value = reunionDate;
      result = true;
    }
    catch( e )
    {
      //do nothing - it'll return false on its own.
    }
  }
  
  return result;
}
