// global constants; "const" would be nicer as a prefix, but IE doesn't support this, so full capitalization will have to do
var DEFAULT_DOCUMENT_PREFIX = 'Ventura College Mathematics Department: ';
var DEFAULT_DOCUMENT_SUFFIX = 'Course Information Page';
var DEFAULT_DOCUMENT_TITLE = DEFAULT_DOCUMENT_PREFIX + DEFAULT_DOCUMENT_SUFFIX;
var H3_CATALOG_DESCRIPTION = 'Catalog Description';
var H3_STUDENT_LEARNING_OUTCOMES = 'Student Learning Outcomes';
var HTML_CHAR_ENT_NBSP = '\u00A0';
var NOT_AVAILABLE = '(Not available)';
var NO_CATALOG_DATA = 'Sorry, no catalog information could be found for this course.';
var NO_SLO_DATA = 'Sorry, no student learning outcomes could be found for this course.';
var NO_CC_DATA = 'Sorry, no core competencies could be found for this course.';
var NO_LEAD_INST_DATA = 'Sorry, the lead instructor ID specified for this course does not appear in the faculty/staff database.';
var NO_PUB_REP_DATA = 'Sorry, the representative ID specified for this course does not appear in the publishers\' representatives database.';
var ALL_CATALOG_DESCRIPTIONS = '(View catalog descriptions of all mathematics courses)';
var ALL_SLO_DESCRIPTIONS = '(View student learning outcomes for all mathematics courses)';
var ALL_CC_DESCRIPTIONS = '(View core competencies for all mathematics courses)';
var ALL_LEAD_INSTRUCTORS = '(View lead instructors for all mathematics courses)';
var SELECT_ANOTHER_COURSE = '(Select another course)';
var TYPEOF_UNDEFINED = 'undefined';

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function saveMathDeptInfoAll(xmlDoc)
{
  window.MathDeptInfoAllDoc = xmlDoc;
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function createCourseInfoPage(courseUID)
{
  if (KonquerorBrowserWarning(MathDeptInfoAllDoc)) return;

  // grab all 'course', 'member', and 'representative' elements from MathDeptInfoAll XML file
  var c = MathDeptInfoAllDoc.getElementsByTagName('course');
  var m = MathDeptInfoAllDoc.getElementsByTagName('member');
  var r = MathDeptInfoAllDoc.getElementsByTagName('representative');

  // obtain the 'course' element for the correct course
  var courseData; // leave undefined so if getCourseData() is unsuccessful, we can check/exit; getCourseData() issues its own error message, but can't die
  courseData = getCourseData(c, courseUID);
  if ( (typeof courseData) == TYPEOF_UNDEFINED ) return;

  // found the requested course! start to extract and format information to display;

  // remove all possibly pre-existing data (nodes) from the "write_course_info_here" div so it is clean when we begin
  var writeHere = document.getElementById('write_course_info_here');
  while ( writeHere.hasChildNodes() ) writeHere.removeChild(writeHere.firstChild);

  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // catalog description // catalog description // catalog description // catalog description // catalog description // catalog description //
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  createHtmlSectionHeader(writeHere, H3_CATALOG_DESCRIPTION);

  // if course is in the catalog, use its information; otherwise find the related course and use its information; if no related course exists, say so
  var catalogCourseData = null; // leave undefined so if getCatalogCourseData() is unsuccessful, it remains undefined, serving as a failure flag
  catalogCourseData = getCatalogCourseData(c, courseData);
  if ( (typeof catalogCourseData) == TYPEOF_UNDEFINED ) // course does not have a catalog description
  {
    /* <p>Sorry, no catalog information could be found for this course.</p> */
    var noDataPara = document.createElement('p');
    noDataPara.appendChild(document.createTextNode(NO_CATALOG_DATA));
    writeHere.appendChild(noDataPara);
  } // end of course does not have a catalog description

  else // extract and format available catalog information from whatever source was obtained
  {
    // start a definition list, of class 'facstafflist', containing the catalog description for the selected course;
    // setAttribute() coding is funny because IE uses "className" instead of "class" as its Javascript name for the "class" attribute;
    // this might break in a browser that (like IE) recognizes "document.all" but (unlike IE) does not recognize "className"
    /* <dl class="facstafflist"> */
    var defList = document.createElement('dl');
    defList.setAttribute((document.all ? 'className' : 'class'), 'facstafflist');

    // definition-list term gives the course number (including a destination anchor), course name, and number of units of credit offered for the course
    /*   <dt> */
    var defTerm = document.createElement('dt');

    /*     <span class="uppercase">Math Vxx</span> */
    var spanAllCaps = document.createElement('span');
    spanAllCaps.setAttribute((document.all ? 'className' : 'class'), 'uppercase');
    spanAllCaps.appendChild(document.createTextNode(catalogCourseData.getElementsByTagName('course_number')[0].childNodes[0].nodeValue));
    defTerm.appendChild(spanAllCaps);

    /*      -  */
    defTerm.appendChild(document.createTextNode(' - '));

    /*     <span class="uppercase">Algebraic Differential Geometry and Trigonometry of Discrete Linear Health Care Statistics with Applied Calculus</span> */
    spanAllCaps = document.createElement('span');
    spanAllCaps.setAttribute((document.all ? 'className' : 'class'), 'uppercase');
    spanAllCaps.appendChild(document.createTextNode(catalogCourseData.getElementsByTagName('course_name')[0].childNodes[0].nodeValue));
    defTerm.appendChild(spanAllCaps);

    /*      - 5 Units */
    defTerm.appendChild(document.createTextNode(' - '));
    var units = catalogCourseData.getElementsByTagName('units')[0].childNodes[0].nodeValue;
    defTerm.appendChild(document.createTextNode(units));
    defTerm.appendChild(document.createTextNode(HTML_CHAR_ENT_NBSP));
    defTerm.appendChild(document.createTextNode('Unit'));
    if( units != 1 && units != 0.5) defTerm.appendChild(document.createTextNode('s')); // Print "Units" or "Unit" depending whether course is 1 unit or less

    /*   </dt> */
    defList.appendChild(defTerm);

    // definition-list definition gives remaining catalog information, which includes requisites, meeting hours, course description, and, as applicable,
    // extra information, such as former ID, applicability for degree credit, fees, field trips, "same-as" courses, transferability, or CAN data
    /*   <dd> */
    var defDefn = document.createElement('dd');

    if( catalogCourseData.getElementsByTagName('requisites').length > 0 ) // if there are one or more requisites, add them
    {
      /*     <p>Prerequisite: Math Vxx</p> */
      var reqs = catalogCourseData.getElementsByTagName('requisites')[0].childNodes;
      // loop over all requisites for the current course
      var j;
      for (j = 0;  j < reqs.length;  j++)
      {
        if (reqs[j].nodeType != 1) continue;
        var paragraph = document.createElement('p');
        paragraph.appendChild(document.createTextNode(reqs[j].getAttribute('type')));
        paragraph.appendChild(document.createTextNode(': '));
        paragraph.appendChild(document.createTextNode(reqs[j].childNodes[0].nodeValue));
        defDefn.appendChild(paragraph);
      } // end of loop over all requisites
    } // end of if there are one or more requisites

    /*     <p>Hours: 5 lecture weekly</p> */
    paragraph = document.createElement('p');
    paragraph.appendChild(document.createTextNode('Hours: '));
    paragraph.appendChild(document.createTextNode(catalogCourseData.getElementsByTagName('hours')[0].childNodes[0].nodeValue));
    defDefn.appendChild(paragraph);

    /*     <p>This course covers sets, number systems, graphing, functions, and so on. Students will not receive credit if they do not study.</p> */
    paragraph = document.createElement('p');
    paragraph.appendChild(document.createTextNode(catalogCourseData.getElementsByTagName('description')[0].childNodes[0].nodeValue));
    defDefn.appendChild(paragraph);

    /*     <p> */
    paragraph = document.createElement('p');

    if( catalogCourseData.getElementsByTagName('etc')[0].hasChildNodes()) // if course has additional information, add it
    {
      /*     Not applicable for degree credit. Field trips may be required. Fees may be required. Same as CS Vxx. Formerly Math xx. */
      paragraph.appendChild(document.createTextNode(catalogCourseData.getElementsByTagName('etc')[0].childNodes[0].nodeValue));
    } // end of if course has additional information

    if( catalogCourseData.getElementsByTagName('transfer_credit').length > 0 ) // if course is transferable, add the transfer data
    {
      /*     Transfer credit: CSU; UC; credit limitations - see counselor. */
      paragraph.appendChild(document.createTextNode(' Transfer credit: '));
      paragraph.appendChild(document.createTextNode(catalogCourseData.getElementsByTagName('transfer_credit')[0].childNodes[0].nodeValue));
    } // end of if course is transferable

    if( catalogCourseData.getElementsByTagName('can_data').length > 0 ) // if course has CAN information, add it
    {
      /*      <strong>CAN MATH xx.</strong> */
      paragraph.appendChild(document.createTextNode(' '));
      var strong = document.createElement('strong');
      strong.appendChild(document.createTextNode(catalogCourseData.getElementsByTagName('can_data')[0].childNodes[0].nodeValue));
      paragraph.appendChild(strong);
    } // end of if course has CAN information

    /*     </p> */
    defDefn.appendChild(paragraph);

    /*   </dd> */
    defList.appendChild(defDefn);

    /* </dl> */
    writeHere.appendChild(defList);

  } // end of extract and format available catalog information

  // end of catalog description; div contains centered links to catalog descriptions for all courses and top of file
  /* <div class="centered"> */
  var endDiv = document.createElement('div');
  endDiv.setAttribute((document.all ? 'className' : 'class'), 'centered');

  /*   <p><a href="mathdept/CatCourseDesc.shtml">(View catalog descriptions of all mathematics courses)</a></p> */
  paragraph = document.createElement('p');
  var destAnchor = document.createElement('a');
  destAnchor.setAttribute('href', 'mathdept/CatCourseDesc.shtml');
  destAnchor.appendChild(document.createTextNode(ALL_CATALOG_DESCRIPTIONS));
  paragraph.appendChild(destAnchor);
  endDiv.appendChild(paragraph);

  /*   <p><a href="mathdept/CourseInfoMain.shtml#course_information_pages">(Select another course)</a></p> */
  createHtmlLinkSelectAnotherCourse(endDiv);

  /* </div> */
  writeHere.appendChild(endDiv);

  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // student learning outcomes // student learning outcomes // student learning outcomes // student learning outcomes // student learning outcomes //
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  createHtmlSectionHeader(writeHere, H3_STUDENT_LEARNING_OUTCOMES);

  if ( (typeof catalogCourseData) == TYPEOF_UNDEFINED ) // course does not have student learning outcomes
  {
    /* <p>Sorry, no student learning outcomes could be found for this course.</p> */
    noDataPara = document.createElement('p');
    noDataPara.appendChild(document.createTextNode(NO_SLO_DATA));
    writeHere.appendChild(noDataPara);
  } // end of course does not have student learning outcomes

  else // extract and format student learning outcomes
  {
    // grab the 'student_learning_outcomes' node and its child nodes for the current course
    var slo = catalogCourseData.getElementsByTagName('student_learning_outcomes');

    if( slo[0].getElementsByTagName('preamble')[0].hasChildNodes() )  // if there is a SLO preamble, add it
    {
      /* <p>Students will use appropriate techniques to:</p> */
      paragraph = document.createElement('p');
      paragraph.appendChild(document.createTextNode(slo[0].getElementsByTagName('preamble')[0].childNodes[0].nodeValue));
      writeHere.appendChild(paragraph);
    } // end of if there is a SLO preamble

    // grab all 'outcome' elements from within the 'student_learning_outcomes/outcomes' path for the current course
    var o = slo[0].getElementsByTagName('outcomes')[0].getElementsByTagName('outcome');

    // start an ordered list for all learning outcomes for the current course
    /* <ol> */
    var orderedList = document.createElement('ol');

    // loop over all outcomes for the current course and make a list item of each
    for (j = 0;  j < o.length;  j++)
    {
      /*   <li>Solve elementary linear analytic word problems in two variables</li> */
      var olListItem = document.createElement('li');
      olListItem.appendChild(document.createTextNode(o[j].childNodes[0].nodeValue));
      orderedList.appendChild(olListItem);
    } // end of loop over all outcomes

    /* </ol> */
    writeHere.appendChild(orderedList);

  } // end of extract and format student learning outcomes

  // end of student learning outcomes; div contains centered links to student learning outcomes for all courses and top of file
  /* <div class="centered"> */
  endDiv = document.createElement('div');
  endDiv.setAttribute((document.all ? 'className' : 'class'), 'centered');

  /*   <p><a href="mathdept/MathSLO.shtml">(View student learning outcomes for all mathematics courses)</a></p> */
  paragraph = document.createElement('p');
  var destAnchor = document.createElement('a');
  destAnchor.setAttribute('href', 'mathdept/MathSLO.shtml');
  destAnchor.appendChild(document.createTextNode(ALL_SLO_DESCRIPTIONS));
  paragraph.appendChild(destAnchor);
  endDiv.appendChild(paragraph);

  /*   <p><a href="mathdept/CourseInfoMain.shtml#course_information_pages">(Select another course)</a></p> */
  createHtmlLinkSelectAnotherCourse(endDiv);

  /* </div> */
  writeHere.appendChild(endDiv);

  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // core competencies // core competencies // core competencies // core competencies // core competencies // core competencies // core competencies //
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  createHtmlSectionHeader(writeHere, 'Core Competencies');

  if ( (typeof catalogCourseData) == TYPEOF_UNDEFINED ) // course does not have core competencies
  {
    /* <p>Sorry, no core competencies could be found for this course.</p> */
    noDataPara = document.createElement('p');
    noDataPara.appendChild(document.createTextNode(NO_CC_DATA));
    writeHere.appendChild(noDataPara);
  } // end of course does not have core competencies

  else // extract and format core competencies
  {
    // grab all 'competency' elements from within the 'core_competencies' path for the current course
    var comps = catalogCourseData.getElementsByTagName('core_competencies')[0].getElementsByTagName('competency');

    // start an unordered list, of class "orangeballs", to contain all core competencies for the current course
    /* <ul class="orangeballs"> */
    var unorderedList = document.createElement('ul');
    unorderedList.setAttribute((document.all ? 'className' : 'class'), 'orangeballs');

    // loop over all competencies for the current course and make a list item of each
    for (j = 0;  j < comps.length;  j++)
    {
      /*   <li>3.4 Apply principles of scientific reasoning to solve problems</li> */
      var ulListItem = document.createElement('li');
      ulListItem.appendChild(document.createTextNode(comps[j].childNodes[0].nodeValue));
      unorderedList.appendChild(ulListItem);
    } // end of loop over all competencies

    /* </ul> */
    writeHere.appendChild(unorderedList);

  } // end of extract and format core competencies

  // end of core competencies; div contains centered links to core competencies for all courses and top of file
  /* <div class="centered"> */
  endDiv = document.createElement('div');
  endDiv.setAttribute((document.all ? 'className' : 'class'), 'centered');

  /*   <p><a href="http://www.venturacollege.edu/assets/pdf/core_competencies/corecomps_math.pdf">(View core competencies for all mathematics courses)</a></p> */
  paragraph = document.createElement('p');
  var destAnchor = document.createElement('a');
  destAnchor.setAttribute('href', 'http://www.venturacollege.edu/assets/pdf/core_competencies/corecomps_math.pdf');
  destAnchor.appendChild(document.createTextNode(ALL_CC_DESCRIPTIONS));
  paragraph.appendChild(destAnchor);
  endDiv.appendChild(paragraph);

  /*   <p><a href="mathdept/CourseInfoMain.shtml#course_information_pages">(Select another course)</a></p> */
  createHtmlLinkSelectAnotherCourse(endDiv);

  /* </div> */
  writeHere.appendChild(endDiv);

  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // lead instructor // lead instructor // lead instructor // lead instructor // lead instructor // lead instructor // lead instructor //
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  createHtmlSectionHeader(writeHere, 'Lead Instructor');

  // find the right lead instructor among m[] which is the 'member' elements from MathDeptInfoAll.xml
  var leadInstructor; // leave undefined so if getLeadInstructor() is unsuccessful, we can check
  leadInstructor = getLeadInstructor(m, courseData);

  if ( (typeof leadInstructor) == TYPEOF_UNDEFINED ) // lead instructor specified does not match information in MathDeptInfoAll.xml
  {
    /* <p>Sorry, the lead instructor ID specified for this course does not appear in the faculty/staff database.</p> */
    noDataPara = document.createElement('p');
    noDataPara.appendChild(document.createTextNode(NO_LEAD_INST_DATA));
    writeHere.appendChild(noDataPara);
  } // end of lead instructor specified does not match

  else // extract and format lead instructor information
  {
    /* <p><strong>Thomas O'Neill</strong> (ext. xxxx) is the lead instructor for this course</p> */
    paragraph = document.createElement('p');
    strong = document.createElement('strong');
    strong.appendChild(document.createTextNode(leadInstructor.getElementsByTagName('givennames')[0].childNodes[0].nodeValue));
    strong.appendChild(document.createTextNode(' '));
    strong.appendChild(document.createTextNode(leadInstructor.getElementsByTagName('lastname')[0].childNodes[0].nodeValue));
    paragraph.appendChild(strong);
    paragraph.appendChild(document.createTextNode(' (ext. '));
    paragraph.appendChild(document.createTextNode(leadInstructor.getElementsByTagName('extension')[0].childNodes[0].nodeValue));
    paragraph.appendChild(document.createTextNode('\) is the lead instructor for this course.'));
    writeHere.appendChild(paragraph);

  } // end of extract and format lead instructor information

  // end of lead instructor information; div contains centered links to lead instructors for all courses (coming soon) and top of file
  /* <div class="centered"> */
  endDiv = document.createElement('div');
  endDiv.setAttribute((document.all ? 'className' : 'class'), 'centered');

  /*   <p><a href="URL for lead instructors page">(View lead instructors for all mathematics courses)</a></p> */
//  paragraph = document.createElement('p');
//  var destAnchor = document.createElement('a');
//  destAnchor.setAttribute('href', 'URL for lead instructors page');
//  destAnchor.appendChild(document.createTextNode(ALL_LEAD_INSTRUCTORS));
//  paragraph.appendChild(destAnchor);
//  endDiv.appendChild(paragraph);

  /*   <p><a href="mathdept/CourseInfoMain.shtml#course_information_pages">(Select another course)</a></p> */
  createHtmlLinkSelectAnotherCourse(endDiv);

  /* </div> */
  writeHere.appendChild(endDiv);

  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // textbook information // textbook information // textbook information // textbook information // textbook information // textbook information //
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  /* <h3>Textbook Information</h3> */
  createHtmlSectionHeader(writeHere, 'Textbook Information');

  // how many textbooks are used in this course?
  var numtexts = courseData.getElementsByTagName('number_of_texts')[0].childNodes[0].nodeValue;

  // start an unordered list, of class "orangeballs", to contain all textbooks for the current course
  /* <ul class="orangeballs"> */
  var unorderedList = document.createElement('ul');
  unorderedList.setAttribute((document.all ? 'className' : 'class'), 'orangeballs');

  // loop over all textbooks for the current course and make a list item of each
  var nt;
  for (nt = 0;  nt < numtexts;  nt++) // loop over textbooks
  {
    /*   <li> */
    var title = courseData.getElementsByTagName('text')[nt].getElementsByTagName('text_title')[0].childNodes[0].nodeValue;
    var textNumberListItem = document.createElement('li');
    /*     <strong>Textbook #1 (Intermediate Algebra):</strong> */
    createTextbookNumberHeader(textNumberListItem, nt, title);

    // start a definition list, of class 'facstafflist', containing the textbook information for the selected course;
    /*     <dl class="facstafflist"> */
    defList = document.createElement('dl');
    defList.setAttribute((document.all ? 'className' : 'class'), 'facstafflist');

    // check each textbook datum; if available, retrieve and display the information; otherwise indicate "Not available"
    var defTerms = ['Textbook author', 'Textbook title', 'Textbook edition', 'City of publication', 'Publisher', 'Year of publication', 'ISBN'];
    var textElements = ['text_author', 'text_title', 'text_edition', 'pub_city', 'pub_company', 'pub_year', 'text_isbn'];
    var i;
    for (i = 0;  i < defTerms.length;  i++) // loop over the data items that describe a textbook
    {
      // definition-list term contains the label
      /*     <dt>Texbook author|title|edition|etc:</dt> */
      defTerm = document.createElement('dt');
      defTerm.appendChild(document.createTextNode(defTerms[i]));
      defTerm.appendChild(document.createTextNode(':'));
      defList.appendChild(defTerm);

      // definition-list definition contains the data value or (Not available)
      /*     <dd>data_value OR (Not available)</dd> */
      defDefn = document.createElement('dd');
      var datum = courseData.getElementsByTagName('text')[nt].getElementsByTagName(textElements[i])[0]; // extract the node containing the corresponding datum

      if ( datum.hasChildNodes() ) // not blank; get and format the datum value
        defDefn.appendChild(document.createTextNode(datum.childNodes[0].nodeValue));
      else // blank; indicate (Not available)
        defDefn.appendChild(document.createTextNode(NOT_AVAILABLE));
      defList.appendChild(defDefn);
    } // end of loop over the data items that describe a textbook

    /*     </dl> */
    textNumberListItem.appendChild(defList);
    /*   </li> */
    unorderedList.appendChild(textNumberListItem);
  } // end of loop over textbooks

  /* </ul> */
  writeHere.appendChild(unorderedList);

  // end of textbook information; div contains centered link to top of file
  /* <div class="centered"> */
  endDiv = document.createElement('div');
  endDiv.setAttribute((document.all ? 'className' : 'class'), 'centered');

  /*   <p><a href="mathdept/CourseInfoMain.shtml#course_information_pages">(Select another course)</a></p> */
  createHtmlLinkSelectAnotherCourse(endDiv);

  /* </div> */
  writeHere.appendChild(endDiv);

  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // course coverage requirements // course coverage requirements // course coverage requirements // course coverage requirements //
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  createHtmlSectionHeader(writeHere, 'Course Coverage Requirements');

  // start a definition list, of class 'facstafflist', containing the course coverage requirements from each textbook for the current course
  /* <dl class="facstafflist"> */
  var defList = document.createElement('dl');
  defList.setAttribute((document.all ? 'className' : 'class'), 'facstafflist');

  // loop over all textbooks for the current course; each term/definition pair corresponds to one text/its coverage requirements
  var nt;
  for (nt = 0;  nt < numtexts;  nt++) // loop over textbooks
  {
    /*   <dt> */
    var title = courseData.getElementsByTagName('text')[nt].getElementsByTagName('text_title')[0].childNodes[0].nodeValue;
    var defTerm = document.createElement('dt');
    /*     <strong>Textbook #1 (Intermediate Algebra):</strong> */
    createTextbookNumberHeader(defTerm, nt, title);
    /*   </dt> */
    defList.appendChild(defTerm);

    /*   <dd>data_value OR (Not available)</dd> */
    defDefn = document.createElement('dd');
    datum = courseData.getElementsByTagName('text')[nt].getElementsByTagName('coverage')[0]; // extract the node containing the course coverage information
    if ( datum.hasChildNodes() ) // not blank; get and format the course coverage information
      defDefn.appendChild(document.createTextNode(datum.childNodes[0].nodeValue));
    else // blank; indicate (Not available)
      defDefn.appendChild(document.createTextNode(NOT_AVAILABLE));
    defList.appendChild(defDefn);
  } // end of loop over textbooks

    /* </dl> */
    writeHere.appendChild(defList);

  // end of course coverage requirements; div contains centered link to top of file
  /* <div class="centered"> */
  endDiv = document.createElement('div');
  endDiv.setAttribute((document.all ? 'className' : 'class'), 'centered');

  /*   <p><a href="mathdept/CourseInfoMain.shtml#course_information_pages">(Select another course)</a></p> */
  createHtmlLinkSelectAnotherCourse(endDiv);

  /* </div> */
  writeHere.appendChild(endDiv);

  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // additional information // additional information // additional information // additional information // additional information //
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  createHtmlSectionHeader(writeHere, 'Additional Information');

  // start a definition list, of class 'facstafflist', containing additional information regarding each textbook for the current course
  /* <dl class="facstafflist"> */
  var defList = document.createElement('dl');
  defList.setAttribute((document.all ? 'className' : 'class'), 'facstafflist');

  // loop over all textbooks for the current course; each term/definition pair corresponds to one text/its additional information
  var nt;
  for (nt = 0;  nt < numtexts;  nt++) // loop over textbooks
  {
    /*   <dt> */
    var title = courseData.getElementsByTagName('text')[nt].getElementsByTagName('text_title')[0].childNodes[0].nodeValue;
    var defTerm = document.createElement('dt');
    /*     <strong>Textbook #1 (Intermediate Algebra):</strong> */
    createTextbookNumberHeader(defTerm, nt, title);
    /*   </dt> */
    defList.appendChild(defTerm);

    /*   <dd>data_value OR (Not available)</dd> */
    defDefn = document.createElement('dd');
    datum = courseData.getElementsByTagName('text')[nt].getElementsByTagName('additional_info')[0]; // extract the node containing the additional information
    if ( datum.hasChildNodes() ) // not blank; get and format the additional information
      defDefn.appendChild(document.createTextNode(datum.childNodes[0].nodeValue));
    else // blank; indicate (Not available)
      defDefn.appendChild(document.createTextNode(NOT_AVAILABLE));
    defList.appendChild(defDefn);
  } // end of loop over textbooks

    /* </dl> */
    writeHere.appendChild(defList);

  // end of additional information; div contains centered link to top of file
  /* <div class="centered"> */
  endDiv = document.createElement('div');
  endDiv.setAttribute((document.all ? 'className' : 'class'), 'centered');

  /*   <p><a href="mathdept/CourseInfoMain.shtml#course_information_pages">(Select another course)</a></p> */
  createHtmlLinkSelectAnotherCourse(endDiv);

  /* </div> */
  writeHere.appendChild(endDiv);

  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  // textbook publisher's representative // textbook publisher's representative // textbook publisher's representative //
  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  createHtmlSectionHeader(writeHere, 'Textbook Publisher\'s Representative');

  // start a definition list, of class 'facstafflist', containing publisher's rep information associated with each textbook for the current course
  /* <dl class="facstafflist"> */
  var defList = document.createElement('dl');
  defList.setAttribute((document.all ? 'className' : 'class'), 'facstafflist');

  // loop over all textbooks for the current course; each term/definition pair corresponds to one text/its publisher's rep information
  var nt;
  for (nt = 0;  nt < numtexts;  nt++) // loop over textbooks
  {
    /*   <dt> */
    var title = courseData.getElementsByTagName('text')[nt].getElementsByTagName('text_title')[0].childNodes[0].nodeValue;
    var defTerm = document.createElement('dt');
    /*     <strong>Textbook #1 (Intermediate Algebra):</strong> */
    createTextbookNumberHeader(defTerm, nt, title);
    /*   </dt> */
    defList.appendChild(defTerm);

    // find the right representative among r[] which is the 'representative' elements from MathDeptInfoAll.xml
    var publisherRep; // leave undefined so if getPublisherRep() is unsuccessful, we can check
    publisherRep = getPublisherRep(r, courseData, nt);

    /*   <dd>data_values OR (Not available)</dd> */
    var defDefn = document.createElement('dd');
    if ( (typeof publisherRep) == TYPEOF_UNDEFINED ) // representative specified does not match information in MathDeptInfoAll.xml
    {
      /*     Sorry, the representative ID specified for this course does not appear in the publishers' representatives database. */
      defDefn.appendChild(document.createTextNode(NO_PUB_REP_DATA));
    } // end of representative specified does not match

    else // extract and format publisher's representative information
    {
      /*     Cengage Pearson Plato Wiley<br />Perry Pubrep<br />(800) 555-1212 */
      defDefn.appendChild(document.createTextNode(publisherRep.getElementsByTagName('organization')[0].childNodes[0].nodeValue));
      defDefn.appendChild(document.createElement('br'));
      defDefn.appendChild(document.createTextNode(publisherRep.getElementsByTagName('rep_name')[0].childNodes[0].nodeValue));
      defDefn.appendChild(document.createElement('br'));
      defDefn.appendChild(document.createTextNode(publisherRep.getElementsByTagName('rep_phone')[0].childNodes[0].nodeValue));
      defList.appendChild(defDefn);
    } // end of extract and format publisher's representative information
  } // end of loop over textbooks

    /* </dl> */
    writeHere.appendChild(defList);

  // end of textbook publisher's representative; div contains centered link to top of file
  /* <div class="centered"> */
  endDiv = document.createElement('div');
  endDiv.setAttribute((document.all ? 'className' : 'class'), 'centered');

  /*   <p><a href="mathdept/CourseInfoMain.shtml#course_information_pages">(Select another course)</a></p> */
  createHtmlLinkSelectAnotherCourse(endDiv);

  /* </div> */
  writeHere.appendChild(endDiv);

  // move the window focus to the beginning of the course information
  window.location.hash = 'write_course_info_here';
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function getCourseData(c, courseUID)
{
  // return the 'course' element from the list of elements in argument c whose unique ID matches the value of argument 'courseUID'
  var i;
  for (i = 0;  i < c.length;  i++)
  {
    if( c[i].getElementsByTagName('unique_ID')[0].childNodes[0].nodeValue == courseUID )
    {
      document.title = DEFAULT_DOCUMENT_PREFIX + c[i].getElementsByTagName('course_number')[0].childNodes[0].nodeValue + ' ' + DEFAULT_DOCUMENT_SUFFIX;
      return c[i];
    }
  }
  notifyUserOfError('Sorry; the course you requested could not be found in the database. Please select another course.');
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function getCatalogCourseData(c, courseData)
{
  // if this course has catalog data; return its 'course' element; otherwise return the 'course' element of the related course that has catalog data
  if( courseData.getElementsByTagName('has_catalog_entry')[0].childNodes[0].nodeValue == 'Y' )
  {
    return courseData;
  }
  else // course has no catalog data; seek related course
  {
    var relatedCourse = courseData.getElementsByTagName('related_course_ID')[0];
    if ( relatedCourse != null ) // entry for related course exists in database
    {
      var i;
      for (i = 0;  i < c.length;  i++) // loop over all courses searching for the related course
      {
        if( c[i].getElementsByTagName('unique_ID')[0].childNodes[0].nodeValue == relatedCourse.childNodes[0].nodeValue ) // found related course
        {
          return c[i];
        } // end of found related course
      } // end of loop over all courses
    } // end of entry for related course exists in database
    // function returns nothing if it can't find a course that has catalog information
  } // end of course has no catalog data
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function getPublisherRep(r, courseData, nt)
{
  var i;
  for (i = 0;  i < r.length;  i++)
  {
    if( r[i].getElementsByTagName('organization')[0].childNodes[0].nodeValue == courseData.getElementsByTagName('text')[nt].getElementsByTagName('pub_xref')[0].childNodes[0].nodeValue )
    {
      return r[i];
    }
  }
  // function returns nothing if it can't find a publisher's representative with a matching organization
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function notifyUserOfError(errMsg)
{
  document.title = DEFAULT_DOCUMENT_TITLE;
  alert(errMsg);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function createHtmlSectionHeader(writeHere, sectionHeader)
{
  /* <hr /> */
  writeHere.appendChild(document.createElement('hr'));

  /* <h3>Section Header Title</h3> */
  var header = document.createElement('h3');
  header.appendChild(document.createTextNode(sectionHeader));
  writeHere.appendChild(header);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function createTextbookNumberHeader(textNumberListItem, nt, title)
{
  /*     <strong>Textbook #1 (Intermediate Algebra):</strong> */
  var strong = document.createElement('strong');
  strong.appendChild(document.createTextNode('Textbook #'));
  strong.appendChild(document.createTextNode(nt + 1));
  strong.appendChild(document.createTextNode(' ('));
  strong.appendChild(document.createTextNode(title));
  strong.appendChild(document.createTextNode('):'));
  textNumberListItem.appendChild(strong);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
function createHtmlLinkSelectAnotherCourse(endDiv)
{
  /*   <p><a href="mathdept/CourseInfoMain.shtml#course_information_pages">(Select another course)</a></p> */
  paragraph = document.createElement('p');
  var destAnchor = document.createElement('a');
  destAnchor.setAttribute('href', 'mathdept/CourseInfoMain.shtml#course_information_pages');
  destAnchor.onclick = function(){document.title = DEFAULT_DOCUMENT_TITLE;};
  destAnchor.appendChild(document.createTextNode(SELECT_ANOTHER_COURSE));
  paragraph.appendChild(destAnchor);
  endDiv.appendChild(paragraph);
}
