/********************************************************************* 

  Javascript code for Design Concepts in Programming Languages Web Supplement 
 
  Author: Lyn Turbak 

  History:
   + 9/01/08 Created, based on 6.821 web supplement pages. 

 ********************************************************************/

/* Write the HTML for the standard DIVs of a CS342 page. 

   selected_file is the (extensionless) name of the displayed page,
     which has a different appearance in the navbar. 

   page_title is the title of the displayed page, which appears in the banner. 

*/
function write_standard_divs(page_title) {
  /* write_pic(); */
  write_banner(page_title);
  write_navbar(page_title);
}


/* Write the HTML for the locked-computer picture */
function write_pic() {
  document.write(
     '"<DIV id="pic">'
     + '<IMAGE src="locked-computer-image.jpg" width=125px>'
     + '</DIV>'
  );
}

/* Write the HTML for the banner. 

   page_title is the title of the displayed page. */
function write_banner(page_title) {
  document.write(
    '<DIV id="banner">'
    + '<SPAN class="year">Wellesley College, Fall 2009</SPAN>'
    + '<BR>'
    + '<SPAN class="coursetitle">CS242 Computer Networks</SPAN>'
  );
  /* document.write(page_title); Ignore the page title in this version */ 
  document.write('</DIV>')
}

function write_navbar(selected_page) {
/* Goal is to write a navbar that looks like: 

  <DIV id="navbar">
   <UL>
    <LI><A class="selected" href="index.html">Home</A></LI>
    <LI><A href="schedule.html">Schedule</A></LI>
    <LI><A href="resources.html">Resources</A></LI>
   </UL>
  </DIV>  

Only one of the links (the one matching selected_page) should be selected.

*/

   var write_link = function (pagetitle, url, comment) {
    /* Write a link in one of the following two forms: 

         <LI><A href="[url]" title="commment">[pagetitle]</A></LI>
         <LI><A class="selected" href="[url] title="[comment]">[pagetitle]</A></LI>

       The class="selected" attribute is only set when [pagetitle] matches [selected_page]

    */
      document.write('<LI><A');
      if (pagetitle == selected_page) {
	  document.write(' class="selected" ');
      }
      document.write(' href="');
      document.write(url);
      document.write('" title="');
      document.write(comment);
      document.write('">');
      document.write(pagetitle);
      document.write('</A></LI>\n');
  }

   /* This isn't used in CS342 */
   var write_unavailable_link = function (pagetitle, url, comment) {
    /* Write a link with the following form: 

         <LI><A class="unavailable" href="[url]" onclick="return false;" title="This content is not available">[pagetitle]</A></LI>

       Note that comment is ignored.

    */
      document.write('<LI><A class= "unavailable" href="');
      document.write(url);
      document.write('" onclick="return false;" title="This content is not yet available">');
      document.write(pagetitle);
      document.write('</A></LI>\n');
  }

  /* Start of DIV and list */
  document.write(
    '<DIV id="navbar">'
    + '<UL>'
  );

  /* Individual links */
  write_link("Home", "index.html", "CS242 home page");
  write_link("Schedule", "schedule.html", "Calendar, readings, & assignments");
  write_link("Resources", "resources.html", "Course resources");
  write_link("Download", "download", "Course resources");
  write_link("CS Dept", "http://cs.wellesley.edu", "Wellesley CS home page");
  write_link("CWIS", "http://www.wellesley.edu", "Wellesley home page");
  /* End of DIV and list */
  document.write(
    ' </UL>\
     </DIV>'
  );


}

