//////////////////////////////////////////////////////////////////////
// icsGroup.js
//////////////////////////////////////////////////////////////////////

function entry(thisForm) {
  var space = " ";
  var endOfLine = "\r\n";
  var theResult = "";
  var thisOrg = textValue(thisForm.organization);
  var thisWebpage = textValue(thisForm.webpage);
  var thisName = textValue(thisForm.contactName);
  var thisType = contactType(thisForm);
  var thisContact = contact(thisForm);
  var thisNewsletter = textValue(thisForm.newsletterName);
  var thisInfo = textValue(thisForm.extraInformation);
  theResult = thisOrg + " "
            + "[" + (new Date()).getMonthName3() + space + (new Date()).getFullYear() + "]" + endOfLine
            + "website: " + thisWebpage + ", "
            + thisName + ", "
            + thisType + ", "
            + thisNewsletter + " "
            + thisContact + ". "
            + thisInfo;
  return theResult;
}

function contact(thisForm) {
// Return a string representing the first contact.
// Requires the TEXT fields:
//     contactFaxAreaCode, contactFaxNumber,
//     contactEmail
//     contactAddress1, contactAddress2, contactCity, contactRegion, contactPostalCode
  var theResult = "";
  if (textValue(thisForm.contactFaxNumber) != "")
    theResult += " fax: "
      + textValue(thisForm.contactFaxAreaCode)
      + "-"
      + textValue(thisForm.contactFaxNumber);
  if (textValue(thisForm.contactEmail) != "")
    theResult += " email: "
      + textValue(thisForm.contactEmail);
  if (textValue(thisForm.contactAddress1) != "")
    theResult += " address: " + textValue(thisForm.contactAddress1);
  if (textValue(thisForm.contactAddress2) != "")
    theResult += ", "
      + textValue(thisForm.contactAddress2);
  theResult += ", "
    + textValue(thisForm.contactCity) + ", "
    + textValue(thisForm.contactRegion) + " "
    + textValue(thisForm.contactPostalCode);
  return theResult;
}

function contactType(thisForm) {
  var theResult = selectValue(thisForm.contactType);
  var thisOtherType = textValue(thisForm.contactTypeOther);
  if (thisOtherType != "")
    theResult = thisOtherType;
  return theResult;
}
