Index: trunk/webapps/einotebook/script/script.js
===================================================================
--- trunk/webapps/einotebook/script/script.js	(revision 401)
+++ trunk/webapps/einotebook/script/script.js	(revision 415)
@@ -13,10 +13,12 @@
 function jumpToLastExecutedEvent()
 {	
-	var lastEvent = Script.events.getLastExecutedEvent(readCookie("time"));
-	
+	var lastEventArray = Script.events.getLastExecutedEvent(readCookie("time"));
+
 	// IF a current event exists THEN
-	if (lastEvent != null)
-	{
-		lastEvent.focus();
+	if (lastEventArray != null)
+	{
+        // Move window focus to first event of the current ones
+        var last = lastEventArray.length - 1;
+	    lastEventArray[last].focus();
 	}
 	else
@@ -33,51 +35,51 @@
 function highlightLatestEvent() 
 {
-	var currentEvent = Script.events.getLastExecutedEvent(readCookie("time"));
+	var currentEventArray = Script.events.getLastExecutedEvent(readCookie("time"));
 
 	// IF the old event is has not been set THEN
-	if (typeof highlightLatestEvent.oldEvent == 'undefined')
-	{
-		highlightLatestEvent.oldEvent = new Object();
-		highlightLatestEvent.oldEvent.id = Event.invalidID;
-	}
-	
+	if (typeof highlightLatestEvent.oldEventArray == 'undefined')
+	{
+		highlightLatestEvent.oldEventArray = []; /* set up array of old events */
+		var currentEvent = new Object(); 
+		highlightLatestEvent.oldEventArray.push(currentEvent);
+		highlightLatestEvent.oldEventArray[0].id = Event.invalidID;
+	}
+
 	// IF a current event exists THEN
-	if (currentEvent != null)
-	{
-		// IF there is a new current event THEN
-		if (highlightLatestEvent.oldEvent.id != currentEvent.id)
-		{
-			currentEvent.highlight();
-			
-			// IF there was previously a current event THEN
-			if (highlightLatestEvent.oldEvent.id != Event.invalidID && currentEvent.id != 0)
-			{
-				highlightLatestEvent.oldEvent.unhighlight();
+	if (currentEventArray !== null)
+	{
+		var found = false; /* check if a current event is found in the old event array */
+
+		/* traverse the array of current event to check 
+		if there is event already in the old event array */
+		// IF there is a new current event THEN	
+		for (j=0; j<highlightLatestEvent.oldEventArray.length; j++) {
+			var oldEvent = highlightLatestEvent.oldEventArray[j];
+			found = false;
+			for (i=0; i<currentEventArray.length; i++) {
+				var currentEvent = currentEventArray[i];
+				if (oldEvent.id === currentEvent.id)
+				{
+					found = true;	
+					break;		
+				} 
 			}
-			
-			highlightLatestEvent.oldEvent = currentEvent;			
+			/* unhighlight all the events that are no longer current */
+			if (!found && oldEvent.id !== Event.invalidID) {
+				oldEvent.unhighlight();
+			}		
 		}
+
+		/* highlight the current event in the array */
+		for (i=0; i<currentEventArray.length; i++) {
+			currentEventArray[i].highlight();
+		}
+
+		/* update the old events array with current event array */
+		highlightLatestEvent.oldEventArray = currentEventArray;
 	}
 
     // Set timer to do this again in one second
 	setTimeout("highlightLatestEvent()", 1000);
-}
-
-
-/** Change color of text of expired events so they appear disabled.
-  * @param events The list of events
-  * @param currEvent The current event
-  */
-function greyOldEvents(events, currEvent)
-{
-	  // Examine all events
-   for (var evtNum = 0; evtNum < events.length; evtNum++)
-   {
-		// Change color of those before current time and Event
-      if (events[evtNum].time.compareTo(currEvent.time) < 0 && currEvent.id != events[evtNum].id) 
-      {
-			events[evtNum].unhighlight();
-      }
-	}
 }
 
@@ -101,6 +103,6 @@
 		// add the Event's html
 		html += Script.events[i].html();
-	}
-       
+        //console.log(Script.events[i].html());
+	}
 	
 	// display events in iframe
@@ -115,5 +117,4 @@
 	Script.events.win.scrollTo(0, readCookie('scriptScrollY'));
 	
-	greyOldEvents(Script.events, Script.events.getLastExecutedEvent(readCookie("time")));
 	highlightLatestEvent();
 
