Index: trunk/webapps/einotebook/scripts/Incident.js
===================================================================
--- trunk/webapps/einotebook/scripts/Incident.js	(revision 468)
+++ trunk/webapps/einotebook/scripts/Incident.js	(revision 515)
@@ -6,5 +6,5 @@
  * @param summary {String}
  */
-function Incident(time, number, title, summary)
+function Incident(time, number, title, summary, color)
 {	
 	//========== public read-only members ==========//
@@ -13,5 +13,5 @@
 	this.title = title;
 	this.summary = summary;
-	this.expanded = true;
+    this.color = color;  /* hex color code for background of this incident */
 	
 	//========== public methods ==========//
Index: trunk/webapps/einotebook/scripts/Incidents.js
===================================================================
--- trunk/webapps/einotebook/scripts/Incidents.js	(revision 468)
+++ trunk/webapps/einotebook/scripts/Incidents.js	(revision 515)
@@ -7,8 +7,18 @@
 //========== public members ==========/
 incidents.doc = null;
+incidents.colorpallette = [
+"#d8f0f3",        // PowderBlue
+"#dfecdf",        // DarkSeaGreen
+"#fff5cc",        // CornSilk
+"#ffe8e6",        // MistyRose
+"#ffffcc",       // Dark Orange
+"#d8f0f3" ];
 
 //========== public methods ==========//
 incidents.get = incidents_get;
+incidents.collapseAll = incidents_collapseAll;
+incidents.expandAll = incidents_expandAll;
 incidents.add = incidents_add;
+incidents.size = incidents_size;
 
 //=========== method definitions ==========//
@@ -34,4 +44,45 @@
 	return incident;
 }
+/**
+ * Accessor to the number of incidents
+*/
+function incidents_size()
+{
+    return this.length;
+}
+
+/**
+ * Collapses each Incident.
+ */
+function incidents_collapseAll()
+{
+	// FOR each incident
+	for (var i = 0; i < this.length; i++)
+	{
+		// IF the incident is expanded THEN
+		if (this[i].expanded)
+		{
+			// collapse incident
+			this[i].expandAction();
+		}
+	}
+}
+
+/**
+ * Expands each incident.
+ */
+function incidents_expandAll()
+{
+	// FOR each incident
+	for (var i = 0; i < this.length; i++)
+	{
+		// IF incident is collapsed THEN
+		if (!this[i].expanded)
+		{
+			// expand incident
+			this[i].expandAction();
+		}
+	}
+}
 
 /**
Index: trunk/webapps/einotebook/scripts/Event.js
===================================================================
--- trunk/webapps/einotebook/scripts/Event.js	(revision 418)
+++ trunk/webapps/einotebook/scripts/Event.js	(revision 515)
@@ -146,14 +146,14 @@
 	function html()
 	{
-        //console.log("building html for event: ", this.eventHeaderID, incidentColor[this.incident.number]);
+        //console.log("building html for event: ", this.eventHeaderID, this.incident.color); //incidentColor[this.incident.number]);
 
 		return "<table class='event'>" +
 			   "<tr>" +
-			   "<td class='eventHeader' style='background-color:" + incidentColor[this.incident.number] + "'" +
+			   "<td class='eventHeader' style='background-color:" + this.incident.color + "'" +
                "id='" + this.eventHeaderID + "'>" + 
 			      this.headerHTML() + "</td>" +
 			   "</tr>" +
 			   "<tr>" + 
-			   "<td class='eventData' style='background-color:" + incidentColor[this.incident.number] + "' id='" + this.dataID + "'>" + 
+			   "<td class='eventData' style='background-color:" + this.incident.color + "' id='" + this.dataID + "'>" + 
 			   (this.expanded ? this.dataHTML() : "") + 
 			   "</td>" +
@@ -187,5 +187,5 @@
 		events.doc.getElementById(this.eventHeaderID).style.color = "black";
 		events.doc.getElementById(this.dataID).style.color = "black";
-        events.doc.getElementById(this.dataID).style.backgroundColor = incidentColor[this.incident.number];
+        events.doc.getElementById(this.dataID).style.backgroundColor = this.incident.color;
 		
 		// IF this event is expanded THEN
@@ -220,5 +220,5 @@
 	function normalize()
 	{
-        var myColor = incidentColor[this.incident.number];
+        var myColor = this.incident.color;
 		events.doc.getElementById(this.eventHeaderID).style.backgroundColor = "white";
 		events.doc.getElementById(this.eventHeaderID).style.borderColor = "black";
Index: trunk/webapps/einotebook/scripts/LoadEvents.js
===================================================================
--- trunk/webapps/einotebook/scripts/LoadEvents.js	(revision 468)
+++ trunk/webapps/einotebook/scripts/LoadEvents.js	(revision 515)
@@ -42,7 +42,11 @@
                         if (incidents.get(incidentNum) == undefined)
                         {
+                            // prepare title field
                             incidentTitle =  currEvt.childNodes[child].textContent;
+                            // select a color from the pallette
+                            var palletteSize = incidents.colorpallette.length;
+                            var currColor = incidents.colorpallette[incidents.size()]; // modulo palleteSize
                             // Construct the incident
-                            var theIncident = new Incident(evtTime, incidentNum, incidentTitle, "");
+                            var theIncident = new Incident(evtTime, incidentNum, incidentTitle, "", currColor);                        
                             // Add the incident to the list of incidents
                             incidents.add(theIncident);
