//======================================
//  HTML Emitter for Course Outline Page
//======================================

//  Get parameters: term, section, year.
var temp = getParString()
temp += '/'
var par = temp.split('/')  //  par[0] = term,  par[1] = section, par[2] = year

//  This color is for the inner table of scheduled exams.
var TABLE_COLOR = 'EEEEEE'  

//  Open outer table.  (Note the left margin.)  Generate page header.
dw("<TABLE WIDTH=600><TR><TD>")

//  Go through all academic terms shown. 
for (i = 0; i < NUM_SEM_SHOWN ; i++) { 
  term = (CURRENT_TERM + i)%3
  //  N O T E:
  //  If the parameter string is null, show all sections for this course.  Otherwise,
  //  show only show the section that corresponds to the term that was clicked.

  if (par[0] == '' || TERM_NAME[term].toLowerCase() == par[0].toLowerCase()) 
    for (timeSlot = TIME_SLOT_1; timeSlot < CLASS[term].length; timeSlot++) { 

      with (CLASS[term][timeSlot])

        if (THIS_COURSE_NAME == course.name) 
          if (par[1] == '' || par[1].toLowerCase() == section.toLowerCase()) {
            THIS_YEAR[THIS_YEAR.length] = CURRENT_YEAR + ((CURRENT_TERM != SPRING)&&(term == SPRING))
            THIS_COURSE_URL = course.relSubDir
            temp = TERM_NAME[term] + ' ' + THIS_YEAR[THIS_YEAR.length - 1] + ', ' +
              'Section ' + section + ', ' + HOURS[term][timeSlot] + ' in ' + where 

            THIS_COURSE_TIME_SLOT[THIS_COURSE_TIME_SLOT.length] = timeSlot
            DESCRIPTOR[DESCRIPTOR.length] = temp
            THIS_TERM[THIS_TERM.length] = term

            if (CLASS[term][timeSlot].webLinks != "")
              THIS_COURSE_LINKS[THIS_COURSE_LINKS.length] = CLASS[term][timeSlot].webLinks
            else THIS_COURSE_LINKS[THIS_COURSE_LINKS.length] = LINKS

            if (CLASS[term][timeSlot].textbook != "")
              THIS_COURSE_TEXTBOOK[THIS_COURSE_TEXTBOOK.length] = CLASS[term][timeSlot].textbook
            else THIS_COURSE_TEXTBOOK[THIS_COURSE_TEXTBOOK.length] = TEXTBOOK

            if (CLASS[term][timeSlot].prerequisites != "")
              THIS_COURSE_PREREQUISITES[THIS_COURSE_PREREQUISITES.length] = CLASS[term][timeSlot].prerequisites
            else THIS_COURSE_PREREQUISITES[THIS_COURSE_PREREQUISITES.length] = PREREQUISITES

            //  Prerequisites, SemesterGrade
            if (CLASS[term][timeSlot].topics != "")
              THIS_COURSE_TOPICS[THIS_COURSE_TOPICS.length] = CLASS[term][timeSlot].topics
            else THIS_COURSE_TOPICS[THIS_COURSE_TOPICS.length] = TOPICS

            if (CLASS[term][timeSlot].semesterGrade != "")
              THIS_COURSE_SEMESTER_GRADE = CLASS[term][timeSlot].semesterGrade
            else THIS_COURSE_SEMESTER_GRADE = SEMESTER_GRADE

            THIS_COURSE_LAB = ''
            THIS_COURSE_LAB_INSTRuCTOR = ''
            INSTRUCTOR_EMAIL = ''
            if (LAB[term][timeSlot] != '') with(LAB[term][timeSlot]) {
              THIS_COURSE_LAB = "Lab: " + when + " in " + where
              THIS_COURSE_LAB_INSTRuCTOR = instructor
              INSTRUCTOR_EMAIL = email
            }
          }
    }
}

// ---------------------------
// Generate the Course Outline
// ---------------------------

for (k = 0; k < THIS_COURSE_TIME_SLOT.length; k++) {
  put("<P>&nbsp;</P><H2 ALIGN=CENTER>" + document.title + "<BR>Course Outline</H2>")
  put('<H3 ALIGN=CENTER>' + DESCRIPTOR[k])
  if (THIS_COURSE_LAB != '') put("<BR>" + THIS_COURSE_LAB + "<BR>")
  put('</H3>')
  put("<H3 ALIGN=CENTER><I>Check the tablet PC class notes frequently for updates.</I></H3>")

  // Instructor, Hours, Text and Prerequisites

  dw("<H3 ALIGN=CENTER>Instructor, Hours, Text and Prerequisites</H3>")
  dw('<P>The instructor is Dr. L. Tavernini, ' + MY_OFFICE + ' (phone: 458-5554, email: ' +
    '<A HREF="mailto:lucio.tavernini@utsa.edu">lucio.tavernini@utsa.edu</A>).')

  // List office hours
  dw("  Office hours are " + OFFICE_HOURS[THIS_TERM[k]] + ".  ")

  //  List course URL's 
  if (THIS_COURSE_LINKS[k] !== "") dw(THIS_COURSE_LINKS[k])
  else dw(LINKS)

  //  List course lab instructor.         
  if (THIS_COURSE_LAB_INSTRuCTOR !== "") {  
    if (THIS_COURSE_LAB_INSTRuCTOR !== "tba") 
      dw("<P>The course lab instructor (TA) is " + THIS_COURSE_LAB_INSTRuCTOR + ", email: " +
        "<A HREF='mailto:" + INSTRUCTOR_EMAIL + "'>" + INSTRUCTOR_EMAIL + "</A>. ")
    else dw("<P>The course lab instructor (TA) will be announced at a later time. ")
    dw("Your TA will be in charge of all matters related to the lab.<P>")
  }

  //  List course textbook. 
  if (THIS_COURSE_TEXTBOOK[k] !== "") dw("<P>" + THIS_COURSE_TEXTBOOK[k] + "<P>")
  else dw("<P>" + TEXTBOOK + "<P>")
     
  //  List course prerequisites. 
  if (THIS_COURSE_PREREQUISITES[k] !== "") dw("<P>" + THIS_COURSE_PREREQUISITES[k] + "<P>")
  else dw("<P>" + PREREQUISITES + "<P>")

  //  Semester Grade
  dw("<H3 ALIGN=CENTER>Semester Grade</H3>" + THIS_COURSE_SEMESTER_GRADE)

  //  List course topics. 
  dw("<H3 ALIGN=CENTER>Purpose and Topics</H3>")
  if (THIS_COURSE_TOPICS[k] !== "") dw("<P>" + THIS_COURSE_TOPICS[k] + "<P>")
  else dw("<P>" + TOPICS + "<P>")

  //  Exam Schedule and Other Important Dates

  if ((j = EXAM[THIS_TERM[k]][THIS_COURSE_TIME_SLOT[k]].length) !== 0) {
    dw("<H3 ALIGN=CENTER>Exam Schedule and Other Important Dates</H3>")
    dw("<P>The exams are scheduled as follows.</P>")
    dw("<P><TABLE ALIGN=CENTER CELLPADDING=8 CELLSPACING=0 BORDER=0 BGCOLOR=" + TABLE_COLOR + " WIDTH=440>")

    dw("<TR><TD ALIGN=RIGHT><B>Exam</B></TD><TD ALIGN=CENTER><B>Date and Time</B></TD></TR>")
      for (i = 0; i < j; i++) {
        temp = EXAM[THIS_TERM[k]][THIS_COURSE_TIME_SLOT[k]][i] + '<BR>'
        if (i == j - 1) 
          dw("<TR><TD ALIGN=RIGHT>Final" + "</TD><TD ALIGN=CENTER>" + temp + "</TD></TR>")
        else dw("<TR><TD ALIGN=RIGHT>" + (i + 1) + "</TD><TD ALIGN=CENTER>" + temp + "</TD></TR>")
      }
    dw("</TABLE></P>")
  }
  else  
    dw("<H3 ALIGN=CENTER>Important Dates</H3>")

  //  Important Dates for All Courses
  dw("<P>Important dates and University holidays follow:</P>")
  dw("<UL>")
  for (i = 0; i < SPECIAL_DAYS[THIS_TERM[k]].length; i++)
    dw('<LI>' + SPECIAL_DAYS[THIS_TERM[k]][i] + '</LI>')
  dw("</UL></P>")

  //  Section-Specific Important Dates
  if (SECTION_SPECIAL_DAYS[THIS_TERM[k]][THIS_COURSE_TIME_SLOT[k]].length > 0) {
    dw("<P>Section-specific events follow:</P>")
    dw("<UL>")
    for (i = 0; i < SECTION_SPECIAL_DAYS[THIS_TERM[k]][THIS_COURSE_TIME_SLOT[k]].length; i++)
      dw('<LI>' + SECTION_SPECIAL_DAYS[THIS_TERM[k]] [THIS_COURSE_TIME_SLOT[k]][i] + '</LI>')
    dw("</UL></P>")
  }
}

//  Close outer table.
dw("</TD></TR></TABLE></CENTER><P>&nbsp;</P>")



