Index: trunk/webapps/einotebook/scripts/Events.js
===================================================================
--- trunk/webapps/einotebook/scripts/Events.js	(revision 363)
+++ trunk/webapps/einotebook/scripts/Events.js	(revision 415)
@@ -304,9 +304,10 @@
  * Finds the Event that was last executed by based on given time.
  * @param time The time in seconds.
- * @return The last execute event if at least one event has executed; otherwise, null.
+ * @return The array of last execute event if at least one event has executed; otherwise, null.
  */
 function events_getLastExecutedEvent(time)
 {
-	var event = null;
+	// var event = null;
+	var event_arr = [];
 	if (this.length == 0)
     {
@@ -317,5 +318,5 @@
 	if (this.length == 1 && this[0].time.getSeconds() <= time)
 	{
-		event = this[0];
+		event.push(this[0]);
 	}
 	else
@@ -323,5 +324,5 @@
 		//NOTE: remember that the events are maintained in ascending order by time
 		
-		// FOR each Event
+		// FOR each Event 
 		for (var i = 0; i < this.length - 1; i++)
 		{
@@ -330,5 +331,12 @@
 			    this[i + 1].time.getSeconds() > time)
 			{
-				event = this[i];
+				event_arr.push(this[i]);
+				/* traverse backward to check if there is an event happen at the same time 
+				with the current event */
+				var k = i - 1;
+				while ( k>=0 && (this[k].time.getSeconds() == this[i].time.getSeconds())) {
+					event_arr.push(this[k]);
+					k--;
+				}
 			}
 		}
@@ -337,9 +345,10 @@
 		if (this[this.length - 1].time.getSeconds() <= time)
 		{
-			event = this[this.length - 1];
+			event_arr.push(this[this.length - 1]);
 		}	
 	}
 	
-	return event;
-}
-
+	// return an array of event 
+	return event_arr;
+}
+
