/* 
   This library will be my library of javascript routines to make
   menus for my personal website. 

   Maybe this library is just one function.
*/


/* I will want to use the argument to specify various menus suitable
   for various pages.  These will want to be made out of chunks which
   will be defined by further helper functions.  For example:
   appendF05Classes() should make all the appendItems for my fall 05
   classes.  I should do this chunkifying on the fly as I go forward*/

function makeMenu(menu){	/* Inserts and populates a menu
				   division. */
  var menuDiv = document.createElement("div");
  var BASE = "http://www.swarthmore.edu/NatSci/thunter1/";

  menuDiv.setAttribute("id", "Menu"); /* id must match css sheet */

  /* The menu is made with helper functions defined below. This code
     is essentially where I specify the data.  If the data is to be
     used in any more sophisticated way, or if I end up fragmenting
     its location too much, I may want to consider making a data
     structure for it.  I am not sure how best to structure the data
     though, so I'll wait for the need.*/
  switch(menu){
  case "home":
      feedback(); appendHr();
      appendH3("Classes Info");
//       appendItem("For all students", BASE + "allClasses.html");
      classesF11();
      appendHr();allstuds();
      appendItem("Some old classes", BASE + "previous_courses.htm");
//       appendHr();
//       appendH3("Other Info");
//       appendItem("My schedule", BASE + "schedule.html");
      appendHr();
      uplinks();
    break;
	case "old":
	    appendH3("Spring 2011");classesS11();
		appendH3("Spring 2010");classesS10();
		appendH3("Fall 2009");classesF09();
		appendH3("Spring 2009");classesS09();
		appendH3("Fall 2008");classesF08();
		appendH3("Spring 2008");classesS08();
		appendH3("Fall 2007");classesF07();
		appendH3("Fall 2006");classesF06();
		appendH3("Spring 2006");classesS06();
		appendH3("Fall 2005"); classesF05();
		 appendHr();
		uplinks();
		break;
	case "26F11":
	    feedback(); appendHr();
	    appendH3("Math 26 Links")
	    appendItem("Home", "index.html");
		appendItem("General Info.", "geninfo.html");	    
		appendHr();allstuds();
		appendHr();uplinks();
		break; 
	case "34S11":
		feedback(); appendHr();
		appendH3("Math 34 links");
		appendItem("Home", "index.html");
		appendItem("General Info.", "geninfo.html");
		appendItem("Schedule", "schedule.html");
		appendHr();allstuds();
		appendHr();uplinks();
		break; 
	case "101S11":
		feedback(); appendHr();
		appendH3("Math 101");
		appendItem("Home", "index.html");
		appendItem("General Info.", "geninfo.html");
		appendItem("Schedule", "schedule.html");
		appendItem("Presentation advice", BASE + "presAdvice.html", 
			"Advice on how to give presentations.");
		appendItem("Syl. for Examiners", "syllabusForHonors.html",
			"Syllabus for External Examiners")
		appendHr();
		appendH3("Weekly plans");
		appendItem("1: Jan 18", "week01.html");
		appendItem("2: Jan 25", "week02.html");
		appendItem("3: Feb 1", "week03.html");
		appendItem("4: Feb 8", "week04.html");
		appendItem("5: Feb 15", "week05.html");
		appendItem("6: Feb 22", "week06.html");
		appendItem("7: Mar 1", "week07.html");
		appendItem("8: Mar 15", "week08.html");
		appendItem("9: Mar 22", "week09.html");
		appendItem("10: Mar 29", "week10.html");
		appendItem("11: Apr 5", "week11.html");
		appendItem("12: Apr 12", "week12.html");
		appendItem("13: Apr 19", "week13.html");
		appendItem("14: Apr 26 ", "week14.html");
		appendHr();uplinks();
		break;
	case "34S10":
		feedback(); appendHr();
		appendH3("Math 34 links");
		appendItem("Home", "index.html");
		appendItem("General Info.", "geninfo.html");
		appendItem("Schedule", "schedule.html");
		appendHr();allstuds();
		appendHr();uplinks();
		break; 
  case "102S10":
      feedback(); appendHr();
      appendH3("Math 102 links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "geninfo.html");
      appendItem("Schedule", "schedule.html");
      appendItem("Presentation advice", BASE + "presAdvice.html", 
		 "Advice on how to give presentations.");
      appendItem("Syl. for Examiners", "syllabusForHonors.html",
		 "Syllabus for External Examiners")
      appendHr();
      appendH3("Weekly plans");
      appendItem("1: Jan 18", "week01.html");
      appendItem("2: Jan 25", "week02.html");
      appendItem("3: Feb 1", "week03.html");
      appendItem("4: Feb 8", "week04.html");
      appendItem("5: Feb 15", "week05.html");
      appendItem("6: Feb 22", "week06.html");
      appendItem("7: Mar 1", "week07.html");
      appendItem("8: Mar 15", "week08.html");
      appendItem("9: Mar 22", "week09.html");
      appendItem("10: Mar 29", "week10.html");
      appendItem("11: Apr 5", "week11.html");
      appendItem("12: Apr 12", "week12.html");
      appendItem("13: Apr 19", "week13.html");
      appendItem("14: Apr 26 ", "week14.html");
      appendHr();uplinks();
      break;
  case "34F09":
      feedback(); appendHr();
      appendH3("Math 34 links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "geninfo.html");
      appendItem("Schedule", "schedule.html");
      appendHr();allstuds();
      appendHr();uplinks();
      break; 
  case "67F09":
      feedback(); appendHr();
      appendH3("Math 67 links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "geninfo.html");
      appendItem("Schedule", "schedule.html");
      appendItem("Writing HW", BASE + "homework.html", "Links with advice about how to write homework.")
      appendItem("Linear Algebra notes", "small.pdf");
      appendHr();allstuds();
      appendHr();uplinks();
      break; 
  case "35S09":
      feedback(); appendHr();
      appendH3("Math 35 links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Schedule", "schedule.html");
      appendHr();uplinks();
      break; 
	case "101S09":
		feedback(); appendHr();
		appendH3("Math 101");
		appendItem("Home", "index.html");
		appendItem("General Info.", "syllabus.html");
		appendItem("Schedule", "schedule.html");
		appendItem("Presentation advice", BASE + "presAdvice.html", 
			"Advice on how to give presentations.");
		appendItem("Syl. for Examiners", "syllabusForHonors.html",
			"Syllabus for External Examiners")
		appendHr();
		appendH3("Weekly plans");
		appendItem("1: Jan 19", "week01.html");
		appendItem("2: Jan 26", "week02.html");
		appendItem("3: Feb 2", "week03.html");
		appendItem("4: Feb 9", "week04.html");
		appendItem("5: Feb 16", "week05.html");
		appendItem("6: Feb 23", "week06.html");
		appendItem("7: Mar 2", "week07.html");
		appendItem("8: Mar 16", "week08.html");
		appendItem("9: Mar 23", "week09.html");
		appendItem("10: Mar 30", "week10.html");
		appendItem("11: Apr 6", "week11.html");
		appendItem("12: Apr 13", "week12.html");
		appendItem("13: Apr 20", "week13.html");
		appendItem("14: Apr 27 ", "week14.html");
		appendHr();uplinks();
		break;
  case "28F08":
      feedback(); appendHr();
      appendH3("Math 28 links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Schedule", "schedule.html");
      appendItem("STN", "small.pdf", 'My "Small theory notes"');
      appendItem("MPN", "minimalPolynomail.pdf", 'My "notes on the minimal polynomial"');
      appendHr();uplinks();
      break; 
  case "97F08":
      feedback(); appendHr();
      appendH3("Math 97 links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Schedule", "schedule.html");
      appendItem("The Paper", "paper.html");
      appendItem("The Poster", "poster.html");
      appendItem("Academic Honesty", BASE + "honesty.html");
      appendHr();uplinks();
      break; 
  case "67F08":
      feedback(); appendHr();
      appendH3("Math 67 links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Schedule", "schedule.html");
      appendItem("Writing HW", BASE + "homework.html", "Links with advice about how to write homework.")
      appendItem("Linear Algebra notes", "small.pdf");
      appendHr();uplinks();
      break; 
  case "43S08":
      feedback(); appendHr();
      appendH3("Math 43 links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Schedule", "schedule.html");
      appendItem("Gallery", "gallery.html", "A gallery of visuals used in the lectures.");
      appendHr();uplinks();
      break;
  case "34S08":
      feedback(); appendHr();
      appendH3("Math 34 links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Schedule", "schedule.html");
      appendHr();uplinks();
      break; 
  case "102S08":
      feedback(); appendHr();
      appendH3("Math 102");
      appendItem("Home", "index.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Schedule", "schedule.html");
      appendItem("Presentation advice", BASE + "presAdvice.html", 
		 "Advice on how to give presentations.");
      appendHr();
      appendH3("Weekly plans");
      appendItem("1: Jan 24", "week01.html");
      appendItem("2: Jan 31", "week02.html");
      appendItem("3: Feb 7", "week03.html");
      appendItem("4: Feb 14", "week04.html");
      appendItem("5: Feb 21", "week05.html");
      appendItem("6: Feb 28", "week06.html");
      appendItem("7: Mar 6", "week07.html");
      appendItem("8: Mar 20", "week08.html");
      appendItem("9: Mar 27", "week09.html");
      appendItem("10: Apr 3", "week10.html");
      appendItem("11: Apr 10", "week11.html");
      appendItem("12: Apr 17", "week12.html");
      appendItem("13: Apr 24", "week13.html");
      appendItem("14: May 1", "week14.html");
      appendHr();uplinks();
      break;
  case "103F07":
      feedback(); appendHr();
      appendH3("Math 103");
      appendItem("Home", "index.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Schedule", "schedule.html");
      appendItem("Presentation advice", BASE + "presAdvice.html", 
		 "Advice on how to give presentations.");
      appendItem("Info on our text", "text.html");
      appendHr();
      appendH3("Weekly plans");
      appendItem("1: Sep 6", "week01.html");
      appendItem("2: Sep 13", "week02.html");
      appendItem("3: Sep 20", "week03.html");
      appendItem("4: Sep 27", "week04.html");
      appendItem("5: Oct 4", "week05.html");
      appendItem("6: Oct 11", "week06.html");
      appendItem("7: Oct 25", "week07.html");
      appendItem("8: Nov 1", "week08.html");
      appendItem("9: Nov 8", "week09.html");
      appendItem("10: Nov 15", "week10.html");
      appendItem("11: Nov 29", "week11.html");
      appendItem("12: Dec 6", "week12.html");
      appendItem("13: Dec 11", "week13.html");
      appendHr();uplinks();
      break;
  case "26F06":
      feedback(); appendHr();
      appendH3("Math 26 links");
      appendItem("Home", "index.html");
      appendItem("Schedule", "schedule.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Text Supplement", "notes.pdf");
      appendItem("Slides", "lectureNotes.pdf");
      appendItem("Web Resources", "web.html");
      appendItem("Calendar", "gcal.html");
      appendHr();
      appendH3("This year's Exams");
      appendItem("1st Midterm", "m1F06.pdf");
      appendItem("2nd Midterm", "m2F06.pdf");
      appendItem("Final", "f.pdf");
      appendHr();
      appendH3("Last year's Exams");
      appendItem("1st Midterm", "m1.pdf");
      appendItem("2nd Midterm", "m2.pdf");
      appendItem("Final", "final.pdf");
      appendHr();uplinks();
      break; 
  case "49S06":
      feedback(); appendHr();
      appendH3("Math 49(2) links");
      appendItem("Home", "index.html");
      appendItem("General Info.", "syllabus.html");
      appendItem("Schedule", "schedule.html");
      appendHr();uplinks();
      break; 
  case "104S06":
    feedback();appendHr();
    appendH3("Math 104 links");
    appendItem("Home", "index.html");
    appendItem("General Info.", "syllabus.html");
    appendItem("Schedule", "schedule.html", "Brief combined plan");
    appendItem("Mondays", "mondaySlots.html", 
	       "Who meets with me when on Mondays");
    appendItem("Presentation advice", BASE + "presAdvice.html", 
	       "Advice on how to give presentations.");
    appendItem("Text Info","texts.html", "Errata and other links for our texts.");
    appendHr();
    appendH3("Weekly plans");
    appendItem("1: Jan 17", "01.html");
    appendItem("2: Jan 24", "02.html");
    appendItem("3: Jan 31", "03.html");
    appendItem("4: Feb 7", "04.html");
    appendItem("5: Feb 14", "05.html");
    appendItem("6: Feb 21", "06.html");
    appendItem("7: Feb 28", "07.html");
    appendItem("8: Mar 14", "08.html");
    appendItem("9: Mar 21", "09.html");
    appendItem("10: Mar 28", "10.html");
    appendItem("11: Apr 4", "11.html");
    appendItem("12: Apr 11", "12.html");
    appendItem("13: Apr 18", "13.html");
    appendItem("14: Apr 25", "14.html");
    appendHr();
    uplinks();
    break;
  case "allstuds":
    feedback();appendHr();
    allstuds();
    appendHr();
    uplinks();
    break;
  default:
    appendH3("switch ran through");
  }

  document.body.appendChild(menuDiv); /* put the div into the document. */


  /* I could make one append function with an additional argument.  It
     doesn't save much at this point, though.*/
  function appendH3(text){	/* Make a header with the text. */
    var h3 = document.createElement("h3");
    h3.appendChild(document.createTextNode(text));
    menuDiv.appendChild(h3);
  }
  function appendItem(text, url, title) { /* make a link with the text
					     linked to the url with a
					     little helper box
					     containing the title*/
    var a = document.createElement("a");
    a.setAttribute("href", url);
    a.appendChild(document.createTextNode(text));
    if (title){  a.setAttribute("title",title);};
    menuDiv.appendChild(a);
    menuDiv.appendChild(document.createElement("br"));
  }
  function appendHr(){		/* Put in an hrule */
    menuDiv.appendChild(document.createElement("hr"));
  }
  function feedback(){
    appendH3("Feedback");
    appendItem("Comment Box",
	       BASE + "anon.html",
	       "feedback via annonymous email");
  }
  function allstuds(){
    appendH3("Info for all my students");
    appendItem("How to study", BASE + "advice.html", "Advice on how to do math.");
    appendItem("How to write HW", BASE + "homework.html",
	       "Advice on writing up homework.")
    appendItem("How to present", BASE + "presAdvice.html", "Advice on how to give presentations.");
    appendItem("Accommodations", 
	       "http://www.swarthmore.edu/x7687.xml",
	       "guidelines for accessing accommodations" +  
	       "for students with disabilities.");
    appendItem("Academic Honesty", BASE + "honesty.html", 
	       "Policy on collaboration and academic honesty.");
    appendItem("My schedule", BASE + "schedule.html");
  }

  function uplinks(){
    appendH3("Uplinks");
    appendItem("Hunter Home", BASE);
    appendItem("Maths/Stats Home", "http://www.swarthmore.edu/NatSci/Math/");
    appendItem("Swarthmore Home", "http://www.swarthmore.edu");
    appendItem("Swat Schedule",
	       "http://www.trico.haverford.edu/" + 
	       "cgi-bin/courseguide/cgi-bin/search.cgi",
	       "Meeting times and places for trico classes");
    appendItem("Swat Calendar",
	       "http://www.swarthmore.edu/academics/academic_calendar.html", 
	       "Academic Calendar with Add/Drop date, vacations, etc.");
    appendItem("Maths/Stats Catalog",
	       "http://www.swarthmore.edu/" + 
	       "academics/course_catalog/math_stats.html");
    }
  function classesF05(){
    appendItem("Math 15(2) Fall '05", BASE + "Classes/15sec2F05/index.html");
    appendItem("Math 26(2) Fall '05", BASE + "Classes/26F05/index.html");
    appendItem("Math 28S Fall '05", BASE + "Classes/28SF05/index.html");
  }
  function classesS06(){
    appendItem("Math 104 Spring '06", BASE + "Classes/104S06/index.html");
    appendItem("Math 49 Spring '06", BASE + "Classes/49S06/index.html");
  }
  function classesF06(){
    appendItem("Math 26(1&2) Fall '06", BASE + "Classes/26F06/index.html");
  }
  function classesF07(){
  appendItem("Math 103 Fall '07", BASE + "Classes/103F07/index.html");
  }
  function classesS08(){
      appendItem("Math 34 Spring '08", BASE + "Classes/34S08/index.html");
      appendItem("Math 43 Spring '08", BASE + "Classes/43S08/index.html");
      appendItem("Math 102(1) Spring '08", BASE + "Classes/102S08/index.html");
  }
  function classesF08(){
      appendItem("Math 28 Fall '08", BASE + "Classes/28F08/index.html");
      appendItem("Math 67 Fall '08", BASE + "Classes/67F08/index.html");
      appendItem("Math 97 Fall '08", BASE + "Classes/97F08/index.html");
  }
  function classesS09(){
      appendItem("Math 35 Spring '09", BASE + "Classes/35S09/index.html");
      appendItem("Math 101 Spring '09", BASE + "Classes/101S09/index.html");
  }
  function classesF09(){
      appendItem("Math 34 Fall '09", BASE + "Classes/34F09/index.html");
      appendItem("Math 67 Fall '09", BASE + "Classes/67F09/index.html");
  }
	function classesS10(){
		appendItem("Math 34(2) Spring '10", BASE + "Classes/34S10/index.html");
		appendItem("Math 102 Spring '10", BASE + "Classes/102S10/index.html");
	}
	function classesS11(){
		appendItem("Math 34 Spring '11", BASE + "Classes/34S11/index.html");
		appendItem("Math 101 Spring '11", BASE + "Classes/101S11/index.html");
	}
		function classesF11(){
		appendItem("Math 26 Fall '11", BASE + "Classes/26F11/index.html");
	}
}

