//////////////////////////////////////////////////////////////////////
// icsClass.js
//////////////////////////////////////////////////////////////////////
function timePeriod(thisForm) {
// Return a time period of the form 00:00-00:00,
// Requires the SELECT fields: startHour, startMinute, startAmPm, endHour, endMinute, endAmPm
  var theResult = ""
  if (selectValue(thisForm.startAmPm) == "noon")
    theResult = "noon";
  else if (selectValue(thisForm.startAmPm) == "midnight")
    theResult = "midnight";
  else {
    theResult = selectValue(thisForm.startHour)
      + ":"
      + selectValue(thisForm.startMinute);
    if (selectValue(thisForm.startAmPm) != selectValue(thisForm.endAmPm))
      theResult += selectValue(thisForm.startAmPm);
  };
  theResult += "-";
  if (selectValue(thisForm.endAmPm) == "noon")
    theResult += "noon";
  else if (selectValue(thisForm.endAmPm) == "midnight")
    theResult += "midnight";
  else {
    theResult += selectValue(thisForm.endHour)
      + ":"
      + selectValue(thisForm.endMinute)
      + selectValue(thisForm.endAmPm);
  };
  return theResult;
}
function levels(thisForm) {
// Return a string representing the levels.
// Requires the CHECKBOX fields: levelBeg, levelInt, levelAdv
  var theResult = "";
  var count = 0;
  if (thisForm.levelBeg.checked) this[count++] = thisForm.levelBeg.value;
  if (thisForm.levelInt.checked) this[count++] = thisForm.levelInt.value;
  if (thisForm.levelAdv.checked) this[count++] = thisForm.levelAdv.value;
  if (count >= 1) theResult = this[0];
  if (count >= 2) theResult += "/" + this[1];
  if (count >= 3) theResult += "/" + this[2];
  return theResult;
}
function contact1(thisForm) {
// Return a string representing the first contact.
// Requires the TEXT fields:
//     contact1Name,
//     contact1AreaCode, contact1PhoneNumber,
//     contact1FaxAreaCode, contact1FaxNumber,
//     contact1Email
  theResult = "";
  theResult = textValue(thisForm.contact1Name);
  if (textValue(thisForm.contact1PhoneNumber) != "")
    theResult += " "
      + textValue(thisForm.contact1PhoneAreaCode)
      + "-"
      + textValue(thisForm.contact1PhoneNumber);
  if (textValue(thisForm.contact1FaxNumber) != "")
    theResult += " "
      + textValue(thisForm.contact1FaxAreaCode)
      + "-"
      + textValue(thisForm.contact1FaxNumber)
      + "(fax)";
  if (textValue(thisForm.contact1Email) != "")
    theResult += " "
      + textValue(thisForm.contact1Email);
  return theResult;
}
function contact2(thisForm) {
// Return a string representing the first contact.
// Requires the TEXT fields:
//     contact2Name,
//     contact2AreaCode, contact2PhoneNumber,
//     contact2FaxAreaCode, contact2FaxNumber,
//     contact2Email
  theResult = "";
  theResult = textValue(thisForm.contact2Name);
  if (textValue(thisForm.contact2PhoneNumber) != "")
    theResult += " "
      + textValue(thisForm.contact2PhoneAreaCode)
      + "-"
      + textValue(thisForm.contact2PhoneNumber);
  if (textValue(thisForm.contact2FaxNumber) != "")
    theResult += " "
      + textValue(thisForm.contact2FaxAreaCode)
      + "-"
      + textValue(thisForm.contact2FaxNumber)
      + "(fax)";
  if (textValue(thisForm.contact2Email) != "")
    theResult += " "
      + textValue(thisForm.contact2Email);
  return theResult;
}
function contacts(thisForm) {
// Return a string representing the (two) contact(s)
  var theResult = contact1(thisForm);
  var secondContact = contact2(thisForm);
  if (secondContact != "")
    theResult += " or " + secondContact;
  return theResult; 
}
function entry(thisForm) {
  var theResult = "";
  var space = " ";
  var endOfLine = "\r\n";
  var thisRegion = selectValue(thisForm.region);
  var thisCity = textValue(thisForm.city);
  var thisMetro = textValue(thisForm.metro);
  var thisDay = selectValue(thisForm.dayOfWeek);
  var thisTimePeriod = timePeriod(thisForm);
  var thisAgeGroup = radioValue(thisForm.ageGroup);
  var thisLevel = levels(thisForm);
  var thisEmphasis = radioValue(thisForm.emphasis);
  var thisStartMonth = selectValue(thisForm.startMonth);
  var thisEndMonth = selectValue(thisForm.endMonth);
  var thisVenueName = textValue(thisForm.venueName);
  var thisVenueAddress = textValue(thisForm.venueAddress);
  var thisContacts = contacts(thisForm);
  var thisWebPage = textValue(thisForm.webPage);
  theResult = thisRegion + endOfLine
    + thisCity + space
    + thisMetro + endOfLine
    + thisDay + space
    + thisTimePeriod + space
    + thisAgeGroup + space
    + thisLevel + space
    + thisEmphasis + space
    + "(" + thisStartMonth + "-" + thisEndMonth + ")" + space
    + "[" + (new Date()).getMonthName3() + space + (new Date()).getFullYear() + "]"
    + endOfLine
    + thisVenueName + ", " + thisVenueAddress + "." + space
    + textValue(thisForm.extraInfo) + space
    + "Contact " + thisContacts + "." + space
    + "Web site: " + thisWebPage + ".";
  return theResult;
}
