Index: /trunk/webapps/visualizer/traffic_events.txt
===================================================================
--- /trunk/webapps/visualizer/traffic_events.txt	(revision 516)
+++ /trunk/webapps/visualizer/traffic_events.txt	(revision 530)
@@ -1,10 +1,344 @@
-ID    Time        Route    Direction   PostMile    Distance    DotColor
-181   00:00:30    405      N           7.73        3.0         R
-181   00:00:45    405      N           8.40        4.74        Y
-181   00:01:00    405      N           5.73        2.0         R
-181   00:02:00    405      N           0.85        3.2         Y
-181   00:02:30    405      N           2.73        4.0         R
-181   00:07:00    5        N           28.9        1.5         Y
-181   00:08:00    5        N           21.25       2.5         R
-181   00:08:30    5        N           18.61       3.0         Y
-181   00:16:30    405      N           1.73        2.73        R
+###########################################################################
+# FEP Simulator Input File
+#
+# TMC Simulator Full Script
+# v1.0 - Neil Hockaday
+###########################################################################
+# Incident 187 
+# 
+# This is a stalled DOT truck on SB 55 overpass at 405. The truck is hit 
+# by a vehicle, the vehicle is vaulted over the railing, and a 6 vehicle 
+# collision occurs below in the NB 405 lanes. The #2 and 3 lanes are 
+# blocked on SB 55 and the #1, 2, and 3 lanes are blocked on NB 405.
+###########################################################################
+# Incident 188
+# 
+# This is a two vehicle collision between a tomato truck and a car. The 
+# truck spills tomatoes across lanes #3,4,5 right lanes plus shoulder of 
+# NB 5 just north of Lake Forest Drive. 
+###########################################################################
+# Incident 189
+# 
+# This is a suicide attempt and a bomb threat. A man with a bomb strapped 
+# to him is threatening to blow up the interchange at I-405 and Jeffrey 
+# Road. The freeway interchange is shut down completely, causing major 
+# backup in both directions on I-405.
+###########################################################################
+# Incident 190
+# 
+# This is a collision involving a tanker truck and a car that block the #3 
+# and 4 lanes on NB I-5 just north of Main Street.
+###########################################################################
+# Incident 191
+# 
+# This is an RV fire on the shoulder southbound 73 just north of Bear/Baker
+# Street.
+###########################################################################
+# Format
+# 
+# ID    Time      Route   Direction PostMile Distance DotColor
+###########################################################################
+  187   00:00:07  55      S         6.88     0.2      Y
+  187   00:01:37  55      S         6.88     0.2      R
+  187   00:02:07  55      S         7.03     0.2      Y
+  187   00:02:37  55      S         7.03     0.7      Y
+  187   00:03:06  405     N         8.40     0.2      R
+  187   00:03:37  55      S         6.88     1.0      R
+  187   00:04:06  405     N         8.40     0.2      R
+  187   00:04:37  55      S         6.88     2.0      R
+  187   00:04:47  55      N         5.87     0.2      Y
+  187   00:05:06  405     N         8.40     1.0      R
+  187   00:05:36  405     N         7.07     0.2      Y
+  187   00:06:06  405     N         7.07     0.3      Y
+  187   00:07:06  405     N         8.40     1.5      R
+  187   00:07:07  55      S         9.19     0.2      Y
+  187   00:08:06  405     N         6.21     1.5      Y
+  188   00:08:08  5       N         20.00    0.2      Y
+  187   00:09:06  405     N         8.40     2.1      R
+  187   00:09:07  55      S         9.19     0.7      Y
+  188   00:09:08  5       N         20.00    0.2      R
+  187   00:10:06  405     N         6.21     2.0      Y
+  188   00:10:08  5       N         18.61    0.2      Y
+  187   00:11:06  405     N         8.40     2.5      R
+  187   00:11:07  55      S         6.88     0.7      Y
+  188   00:12:08  5       N         18.61    1.2      Y
+  188   00:12:38  5       N         18.61    0.2      R
+  187   00:13:06  405     N         4.03     0.2      Y
+  187   00:14:06  405     N         4.03     0.3      Y
+  188   00:14:08  5       N         17.63    0.1      Y
+  187   00:14:37  55      S         6.88     2.5      R
+  187   00:14:47  55      N         5.87     0.4      Y
+  187   00:15:06  405     N         3.86     0.1      Y
+  187   00:16:06  405     N         8.40     3.5      R
+  187   00:16:07  55      S         9.84     0.2      Y
+  188   00:16:08  5       N         17.63    0.3      Y
+  187   00:17:06  405     N         3.86     0.6      Y
+  188   00:17:08  5       N         17.63    1.0      Y
+  187   00:18:06  405     N         8.40     4.5      R
+  187   00:18:07  55      S         10.40    0.2      Y
+  188   00:18:08  5       N         20.00    1.0      R
+  187   00:19:06  405     N         3.86     0.8      Y
+  188   00:19:08  5       N         20.00    1.5      R
+  188   00:20:08  5       N         20.00    2.0      R
+  187   00:21:05  5       S         30.40    0.1      Y
+  188   00:21:08  5       N         17.63    2.0      Y
+  187   00:22:06  405     N         3.86     1.0      Y
+  188   00:22:08  5       N         20.00    2.5      R
+  187   00:23:05  5       S         30.40    0.2      Y
+  188   00:23:08  5       N         15.35    0.2      Y
+  187   00:24:05  5       S         30.40    0.1      R
+  187   00:24:05  5       S         30.40    0.8      Y
+  187   00:24:06  405     N         3.86     1.6      Y
+  187   00:25:06  405     N         8.40     4.6      R
+  188   00:25:08  5       N         15.35    0.7      Y
+  187   00:26:05  5       S         30.40    1.2      R
+  187   00:26:05  5       S         30.60    1.2      Y
+  188   00:26:08  5       N         20.00    3.5      R
+  188   00:27:08  5       N         15.35    1.5      Y
+  188   00:28:08  5       N         20.00    4.5      R
+  188   00:29:08  5       N         15.35    2.5      Y
+  187   01:01:07  55      S         6.88     0.2      Y
+  187   01:02:07  55      S         6.88     0.2      G
+  187   01:02:17  55      S         7.03     0.2      Y
+  187   01:04:17  55      S         7.03     0.7      Y
+  187   01:05:07  55      S         6.88     0.2      Y
+  187   01:05:37  55      S         7.03     1.5      Y
+  187   01:06:07  55      S         6.88     1.0      G
+  187   01:07:17  55      S         9.19     0.2      Y
+  188   01:08:08  5       N         20.00    0.2      Y
+  187   01:08:17  55      S         9.19     0.9      Y
+  187   01:09:17  55      S         9.19     1.3      Y
+  187   01:09:27  55      S         6.88     2.0      G
+  187   01:10:17  55      S         6.88     3.0      G
+  188   01:11:08  5       N         20.00    0.2      Y
+  187   01:11:17  55      S         6.88     4.0      G
+  187   01:11:35  5       S         30.40    0.1      Y
+  187   01:12:35  5       S         30.40    0.5      Y
+  187   01:13:05  5       S         30.40    1.0      Y
+  187   01:14:05  5       S         30.40    1.5      Y
+  187   01:15:05  5       S         30.40    0.5      G
+  188   01:15:08  5       N         20.00    0.7      Y
+  187   01:16:05  5       S         30.40    1.5      G
+  188   01:20:08  5       N         20.00    1.0      Y
+  187   01:29:06  405     N         8.40     0.2      Y
+  187   01:30:06  405     N         8.40     0.7      Y
+  188   01:30:08  5       N         20.00    1.5      Y
+  187   01:31:06  405     N         8.40     1.2      Y
+  187   01:31:16  405     N         8.40     0.2      G
+  187   01:32:06  405     N         7.07     1.0      Y
+  187   01:33:06  405     N         7.07     1.5      Y
+  187   01:34:16  405     N         8.40     1.2      G
+  187   01:35:06  405     N         5.05     1.0      Y
+  187   01:35:06  405     N         5.05     2.0      Y
+  187   01:35:06  405     N         7.07     2.5      Y
+  188   01:35:08  5       N         20.00    0.2      G
+  188   01:36:08  5       N         19.75    2.0      Y
+  187   01:36:16  405     N         8.40     1.5      G
+  188   01:36:38  5       N         20.00    1.0      G
+  188   01:37:08  5       N         18.90    3.0      Y
+  189   01:37:09  405     S         4.03     0.2      R
+  187   01:37:16  405     N         8.40     2.5      G
+  189   01:37:39  405     S         4.03     0.5      R
+  189   01:38:09  405     S         4.03     1.0      R
+  187   01:38:16  405     N         8.40     3.0      G
+  189   01:38:19  405     N         2.35     0.2      R
+  189   01:38:39  405     S         4.03     1.5      R
+  189   01:38:49  405     N         2.35     0.5      R
+  187   01:39:06  405     N         3.86     1.6      Y
+  189   01:39:09  405     S         4.03     2.0      R
+  189   01:39:09  405     S         4.03     3.0      R
+  189   01:39:19  405     N         2.35     1.0      R
+  189   01:39:39  405     S         4.03     2.5      R
+  189   01:39:39  405     S         4.03     3.5      R
+  189   01:39:49  405     N         2.35     1.5      R
+  188   01:40:08  5       N         20.00    2.3      G
+  189   01:40:09  405     S         4.03     4.0      R
+  187   01:40:16  405     N         8.40     4.0      G
+  189   01:40:33  133     S         9.00     0.2      Y
+  189   01:40:39  405     S         4.03     4.5      R
+  189   01:40:40  5       N         20.59    0.2      R
+  188   01:41:08  5       N         17.63    4.0      Y
+  189   01:41:09  405     S         4.03     5.0      R
+  189   01:41:10  5       N         20.59    0.5      R
+  189   01:41:10  5       N         21.25    0.1      Y
+  187   01:41:16  405     N         8.40     5.0      G
+  189   01:41:40  5       N         20.59    1.0      R
+  189   01:42:09  405     S         4.03     6.0      R
+  189   01:42:10  5       N         20.59    1.5      R
+  187   01:42:16  405     N         8.40     6.0      G
+  189   01:42:34  55      N         5.87     0.2      Y
+  189   01:42:40  5       N         20.59    2.0      R
+  189   01:43:09  405     S         4.03     7.0      R
+  189   01:43:10  5       N         20.59    2.5      R
+  189   01:43:40  5       N         20.59    3.0      R
+  189   01:44:09  405     S         4.03     8.0      R
+  189   01:44:10  5       N         20.59    3.5      R
+  189   01:44:40  5       N         20.59    4.0      R
+  189   01:45:09  405     S         4.03     9.0      R
+  189   01:45:10  5       N         20.59    4.5      R
+  189   01:45:33  133     S         9.00     0.5      Y
+  189   01:45:34  55      N         5.87     0.5      Y
+  189   01:45:40  5       N         20.59    5.0      R
+  189   01:46:09  405     S         4.03     10.0     R
+  189   01:46:40  5       N         20.59    6.0      R
+  189   01:47:09  405     S         4.03     11.0     R
+  189   01:47:40  5       N         20.59    7.0      R
+  189   01:48:09  405     S         4.03     12.0     R
+  189   01:48:40  5       N         20.59    8.0      R
+  189   01:49:09  405     S         4.03     13.0     R
+  189   01:49:40  5       N         20.59    9.0      R
+  189   01:50:09  405     S         4.03     14.0     R
+  189   01:50:33  133     S         9.00     0.5      R
+  189   01:50:34  55      N         5.87     0.7      Y
+  189   01:50:40  5       N         20.59    10.0     R
+  189   01:50:43  133     S         9.00     0.8      R
+  189   01:51:09  405     S         4.03     15.0     R
+  190   01:51:09  5       N         33.20    0.2      Y
+  190   01:52:09  5       N         33.20    0.2      R
+  190   01:52:19  5       N         33.00    0.5      Y
+  190   01:53:09  5       N         32.70    0.2      R
+  190   01:53:19  5       N         32.50    0.5      Y
+  190   01:54:09  5       N         32.50    1.0      Y
+  190   01:55:09  5       N         32.50    1.5      Y
+  190   01:56:09  5       N         32.50    0.5      R
+  190   01:57:09  5       N         32.50    1.5      R
+  190   01:57:19  5       S         33.25    0.1      Y
+  190   01:58:09  5       N         31.00    1.0      Y
+  190   01:58:09  5       N         31.00    1.5      Y
+  190   01:59:09  5       N         31.00    2.0      Y
+  190   02:00:09  5       N         31.00    0.5      R
+  190   02:00:09  5       N         31.00    1.0      R
+  190   02:01:09  55      N         10.40    0.5      Y
+  190   02:01:09  5       N         28.50    0.5      Y
+  190   02:01:09  5       N         29.00    0.5      Y
+  190   02:01:39  55      S         10.84    0.5      Y
+  190   02:02:09  5       N         28.50    1.0      Y
+  190   02:03:09  5       N         28.50    1.5      Y
+  190   02:04:19  55      N         10.40    1.0      Y
+  190   02:04:49  55      S         10.84    1.0      Y
+  190   02:05:09  5       N         31.00    1.5      R
+  190   02:06:09  5       N         31.00    2.0      R
+  190   02:07:09  5       N         28.50    2.0      Y
+  190   02:08:09  5       N         31.00    2.5      R
+  190   02:09:19  261     N         0.50     0.2      Y
+  190   02:09:49  261     S         0.90     0.2      Y
+  190   02:11:09  5       N         28.50    2.5      Y
+  190   02:12:09  55      N         10.40    1.0      Y
+  190   02:12:39  55      S         10.84    1.0      Y
+  189   02:14:09  405     S         4.03     0.2      Y
+  190   02:14:09  5       N         28.50    0.5      R
+  189   02:14:19  405     N         2.35     0.2      Y
+  189   02:14:39  405     S         4.03     0.5      Y
+  189   02:14:49  405     N         2.35     0.5      Y
+  189   02:15:09  405     S         4.03     1.0      Y
+  189   02:15:19  405     N         2.35     1.0      Y
+  189   02:15:39  405     S         4.03     0.2      G
+  189   02:15:49  405     N         2.35     1.5      Y
+  189   02:16:09  405     S         5.03     1.0      Y
+  190   02:16:09  5       N         28.50    0.5      R
+  189   02:16:10  5       N         20.59    0.2      Y
+  189   02:16:19  405     N         2.35     1.0      G
+  189   02:16:39  405     S         4.03     0.5      G
+  189   02:16:40  5       N         20.59    0.5      Y
+  189   02:16:43  133     S         9.00     0.8      G
+  189   02:17:09  405     S         6.03     1.0      Y
+  189   02:17:10  5       N         20.59    12.0     Y
+  189   02:17:19  405     N         2.35     1.5      G
+  189   02:17:39  405     S         4.03     1.0      G
+  189   02:17:40  5       N         20.59    1.0      Y
+  189   02:17:50  5       N         21.25    0.1      G
+  189   02:18:09  405     S         7.03     1.0      Y
+  189   02:18:10  5       N         20.59    1.5      Y
+  189   02:18:39  405     S         4.03     1.5      G
+  189   02:18:40  5       N         20.59    0.2      G
+  191   02:19:02  73      S         27.20    0.2      Y
+  189   02:19:09  405     S         8.03     1.0      Y
+  189   02:19:10  5       N         19.50    1.0      Y
+  189   02:19:39  405     S         4.03     2.0      G
+  189   02:19:40  5       N         20.59    0.5      G
+  189   02:20:09  405     S         9.03     1.0      Y
+  189   02:20:10  5       N         18.50    1.0      Y
+  189   02:20:39  405     S         4.03     2.5      G
+  189   02:20:40  5       N         20.59    1.0      G
+  191   02:21:02  73      S         27.20    0.8      Y
+  189   02:21:09  405     S         10.03    1.0      Y
+  189   02:21:10  5       N         17.50    1.0      Y
+  189   02:21:39  405     S         4.03     3.0      G
+  189   02:21:40  5       N         20.59    1.5      G
+  189   02:22:09  405     S         11.03    1.0      Y
+  189   02:22:10  5       N         16.50    1.0      Y
+  189   02:22:39  405     S         4.03     4.0      G
+  189   02:22:40  5       N         20.59    2.0      G
+  189   02:23:09  405     S         12.03    1.0      Y
+  189   02:23:10  5       N         15.50    1.0      Y
+  189   02:23:39  405     S         4.03     5.0      G
+  189   02:23:40  5       N         20.59    2.0      G
+  191   02:24:02  73      S         27.20    0.2      R
+  189   02:24:09  405     S         13.03    1.0      Y
+  189   02:24:10  5       N         14.50    1.0      Y
+  189   02:24:34  55      N         5.87     0.2      G
+  189   02:24:39  405     S         4.03     6.0      G
+  189   02:24:40  5       N         20.59    3.0      G
+  189   02:24:49  405     S         19.03    1.0      Y
+  191   02:25:02  73      N         26.70    0.2      Y
+  189   02:25:09  405     S         14.03    1.0      Y
+  189   02:25:10  5       N         13.50    1.0      Y
+  189   02:25:39  405     S         4.03     7.0      G
+  189   02:25:40  5       N         20.59    4.0      G
+  191   02:26:02  73      S         27.20    0.8      R
+  189   02:26:09  405     S         14.03    1.0      Y
+  189   02:26:10  5       N         12.50    1.0      Y
+  189   02:26:39  405     S         4.03     7.0      G
+  189   02:26:40  5       N         20.59    4.0      G
+  189   02:27:09  405     S         15.03    1.0      Y
+  190   02:27:09  5       N         33.20    0.2      Y
+  189   02:27:10  5       N         11.50    1.0      Y
+  189   02:27:39  405     S         4.03     9.0      G
+  189   02:27:40  5       N         20.59    4.0      G
+  189   02:28:09  405     S         16.03    1.0      Y
+  189   02:28:39  405     S         4.03     10.0     G
+  189   02:28:40  5       N         20.59    5.0      G
+  189   02:29:09  405     S         17.03    1.0      Y
+  190   02:29:09  5       N         33.20    0.5      Y
+  189   02:29:34  55      N         5.87     0.8      G
+  189   02:29:39  405     S         4.03     12.0     G
+  189   02:29:40  5       N         20.59    6.0      G
+  189   02:29:49  405     S         20.03    1.0      Y
+  189   02:30:09  405     S         18.03    1.0      Y
+  189   02:30:39  405     S         4.03     13.0     G
+  189   02:30:40  5       N         20.59    7.0      G
+  189   02:31:09  405     S         19.03    1.0      Y
+  190   02:31:09  5       N         33.20    0.7      Y
+  189   02:31:39  405     S         4.03     15.0     G
+  189   02:31:40  5       N         20.59    8.0      G
+  189   02:32:09  405     S         20.03    1.0      Y
+  189   02:32:39  405     S         4.03     16.0     G
+  189   02:32:39  405     S         4.03     18.0     G
+  189   02:32:40  5       N         20.59    9.0      G
+  190   02:33:09  5       N         33.20    1.0      Y
+  189   02:33:40  5       N         20.59    10.0     G
+  189   02:34:40  5       N         20.59    11.0     G
+  190   02:35:09  5       N         33.20    1.5      Y
+  191   02:36:02  73      N         26.70    0.2      G
+  191   02:37:02  73      S         27.20    0.2      Y
+  190   02:37:09  5       N         33.20    2.0      Y
+  191   02:39:02  73      S         27.20    0.8      Y
+  190   02:39:09  5       N         33.20    2.5      Y
+  190   02:41:09  5       N         33.20    3.0      Y
+  190   02:46:09  5       N         33.20    0.2      G
+  190   02:46:39  5       N         33.20    0.5      G
+  190   02:46:49  5       S         33.25    0.1      G
+  191   02:47:02  73      S         27.20    0.2      G
+  190   02:47:09  5       N         33.20    0.7      G
+  190   02:47:39  5       N         33.20    1.0      G
+  190   02:48:09  5       N         33.20    1.5      G
+  190   02:48:39  5       N         33.20    2.0      G
+  191   02:49:02  73      S         27.20    0.8      G
+  190   02:49:09  5       N         31.00    2.0      Y
+  190   02:49:39  5       N         33.20    2.5      G
+  190   02:49:39  5       N         33.20    6.0      G
+  190   02:50:09  5       N         30.00    2.0      Y
+  190   02:51:09  55      N         10.40    1.5      G
+  190   02:51:19  261     N         0.50     0.2      G
+  190   02:51:39  55      S         10.84    1.5      G
+  190   02:51:49  261     S         0.90     0.2      G
Index: /trunk/webapps/visualizer/traffic_events_sample.txt
===================================================================
--- /trunk/webapps/visualizer/traffic_events_sample.txt	(revision 530)
+++ /trunk/webapps/visualizer/traffic_events_sample.txt	(revision 530)
@@ -0,0 +1,10 @@
+ID    Time        Route    Direction   PostMile    Distance    DotColor
+181   00:00:30    405      N           7.73        3.0         R
+181   00:00:45    405      N           8.40        4.74        Y
+181   00:01:00    405      N           5.73        2.0         R
+181   00:02:00    405      N           0.85        3.2         Y
+181   00:02:30    405      N           2.73        4.0         R
+181   00:07:00    5        N           28.9        1.5         Y
+181   00:08:00    5        N           21.25       2.5         R
+181   00:08:30    5        N           18.61       3.0         Y
+181   00:16:30    405      N           1.73        2.73        R
Index: /trunk/webapps/visualizer/index.html
===================================================================
--- /trunk/webapps/visualizer/index.html	(revision 528)
+++ /trunk/webapps/visualizer/index.html	(revision 530)
@@ -5,5 +5,5 @@
 <!-- map center button icon from http://icons8.com/.  (Obligatory backlink, don't remove ) -->
   <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
-    <title>Visualizer</title> 
+    <title>Visualizer </title> 
 <link rel="icon" 
       type="image/png" 
@@ -14,28 +14,7 @@
   <body>
     <!-- 
-         Version 6.5 Adjust cms dialog dimensions for Chrome.
-	     Version 6.4 Remove fullscreen control. (Use Browser F11 instead).
-         Version 6.3 decomposed into modules for each layer
-         Version 6.2 puts cctv and cms and vds in separate data layers.   
-         Version 6.1 Puts cms messages in json formatted file.  Polls for updates.
-         Version 6.0 Adds speed-dependent images to infowindow for cctv icons
-         Version 5.8 Adds an infowindow with a static image for all cctv icons
-         Version 5.7 integrates CCTV icons and button (but empty click handler)
-         Version 5.6 integrates CMS features
-         Version 5.5 renames title to CPTMS, loads static data on startup and dynamic data
-         every ten seconds.  
-         Version 5.4 adds Search box and Center button
-         Version 5.3 fixed dot color update defect, increased refresh rate to 10 sec.
-         Version 5.2 places red dots overlapping yellow dots.
-         Version 5.1 removes the map and street view buttons and the H3 tag.
-         Version 5 uses precomputed perpendicular vector in dot adjustment function
-         Version 4 Adjust the spacing between dots when the map is zoomed.
-         Version 3 does loadGeoJson only once, and subsequently does an ajax load
-         of the highways file, and selectively updates only those placePins whose
-         color has changed. 
-         @author jdalbey  2019.2.17
+         Visualizer created from CPTMS
+         @author tkumar and jdalbey 2019.11.23
     -->
-    <!-- The text area input for the Search Box -->
-    <input id="search-input" class="controls" type="text" placeholder="Search Box">
     <!--The div element where the map appears. -->
     <div id="mapdiv"></div>
@@ -44,10 +23,6 @@
    <!--The div elements where the buttons appear-->
     <div id="ctrButton"><img width="30" src="images/btn_mapcenter.png"></div>
-    <!-- <button id="harButton" class="unstyled-button"><img id="harBtnImg" src="images/btnReady_HAR.png"></button>
-    <button id="cctvButton" class="unstyled-button"><img id="cctvBtnImg" src="images/btnReady_CCTV.png"></button>
-    <button id="cmsButton" class="unstyled-button"><img id="cmsBtnImg" src="images/btnReady_CMS.png"></button>-->
-    <button id="vdsButton" class="unstyled-button"><img id="vdsBtnImg" src="images/btnDepressed_VDS.png"></button>
     <p id="time">00:00:00</p>
-    <button id="start" >Beginning</button>
+    <button id="beginning" >Beginning</button>
     <button id="forward" >Next</button>
 	<button id="backward" >Back</button>
@@ -94,9 +69,9 @@
     var iconVDSwhite = "images/circle_white.png"
     var vds_showing = true;
-    var filters = []; //array to hold markers for visualizer
-    var times = []; //array to hold times of each traffic event
-    times[0] = "00:00:00";
-    var diff_arr = []; // array to hold difference in target markers
-    var index = -1; //to index into above array
+    var targetDots = []; // 2d array containing targetDots parsed from each line in traffic events file
+    var eventTimes = []; //array to hold times of each traffic event
+    eventTimes[0] = "00:00:00";
+    var diff_arr = []; // 2d array containing difference in map state between each event
+    var eventIndex = -1; //to index into above array
 
     // Use larger VDS icons if we're being displayed on the video wall
@@ -125,12 +100,4 @@
     }
 
-    // Initialize the view/hide buttons 
-    function initLayerButtons()
-    {
-        initVDSbutton();
-        initForwardbutton();
-        initVDSicons();
-    }
-
     // Initialize the map and load the points
     function initMap()
@@ -148,17 +115,11 @@
 
         // setup the search box and center button
-        initSearch();
+        //initSearch();
         initCenter();
         
-        loadVDSlayer(); // go load the map data
-        processVDS();
+        initializeVDSlayer(); // go load the map data
 
-        initLayerButtons(); // setup the show/hide layer buttons
-
-        updateVDSlayer();
-        setTimeout(function() {
-            buildDiff();
-            updateVDSlayer();
-        }, 3000);
+        initControlButtons();
+        initVDSicons()
 
         // Listen for zoom changes and move the vds dots so as to keep a nice
Index: /trunk/webapps/visualizer/js/vdsLayer.js
===================================================================
--- /trunk/webapps/visualizer/js/vdsLayer.js	(revision 528)
+++ /trunk/webapps/visualizer/js/vdsLayer.js	(revision 530)
@@ -1,26 +1,4 @@
-    // Build a solid colored icon to use instead of the classic pin
-    function dotSymbol(color) 
-    {
-        var iconPath = iconVDSwhite;
-        if (color == 'red')
-        {
-           iconPath = iconVDSred;
-        }
-        else if (color == 'yellow')
-        {
-            iconPath = iconVDSyellow;
-        }
-        else if (color == 'lime')
-        {
-            iconPath = iconVDSgreen;
-        }
-        return {
-            url: iconPath, 
-            anchor: new google.maps.Point(6, 6)
-        };
-    }
-
     // Load the map data from a json file and style all the points
-    function loadVDSlayer()
+    function initializeVDSlayer()
     {
         // Load the static map data and call saveCoords when done
@@ -46,4 +24,27 @@
         });
     }
+
+    // Build a solid colored icon to use instead of the classic pin
+    function dotSymbol(color) 
+    {
+        var iconPath = iconVDSwhite;
+        if (color == 'red')
+        {
+           iconPath = iconVDSred;
+        }
+        else if (color == 'yellow')
+        {
+            iconPath = iconVDSyellow;
+        }
+        else if (color == 'lime')
+        {
+            iconPath = iconVDSgreen;
+        }
+        return {
+            url: iconPath, 
+            anchor: new google.maps.Point(6, 6)
+        };
+    }
+
     // callback when load GeoJson completes
     // save each feature's Point as the original coordinates for later reference
@@ -56,8 +57,7 @@
             vds_coords[feature.getId()] = pt; // save the Point in a dictionary
         });
-        // update the dot colors from the dynamic json data 
-        updateVDSlayer();
         // go adjust the marker coordinates so dots don't overlap
         adjustCoords(calcDistanceFactor());
+        processVDS();
     } 
 
@@ -114,4 +114,110 @@
     }
 
+    // Load the highways static json file and update the map
+    function resetVDSlayer()
+    {
+        eventIndex = -1;
+        loadJSON(kMapStartupFile, function(response)
+        {
+            // Parse JSON string into object
+            //initialVDSjson = JSON.parse(response);
+            // Process each new marker - lookup in current map
+            var initialVDSjsonFeatures = JSON.parse(response).features
+            initialVDSjsonFeatures.forEach(updateMarker);
+        });
+    }
+
+    function getColorName(str){
+        if (str === "R\r" || str === "R")
+            return "red";
+        else if (str === "Y\r" || str === "Y")
+            return "yellow";
+        else if (str === "G\r" || str === "G")
+            return "lime";
+    }
+
+// Parses the traffic events file and builds an array of target dots for each line
+    function processVDS() {
+        //var parsed_JSON;
+        loadJSON(kMapStartupFile, function(response)
+        { 
+            // Parse JSON string into object
+            parsed_JSON = JSON.parse(response);
+            // Process each new marker - lookup in current map
+            var parsed_features =  parsed_JSON.features;
+            parsed_features.forEach(updateMarker);
+            var eventsFile = '';
+            // Request the traffic events data file
+            var xmlhttp = new XMLHttpRequest();
+            xmlhttp.open("GET",trafficEventsFile,true); // Ask the server for the traffic events file
+            // Establish listener for handling the traffic events once file is read
+            xmlhttp.onreadystatechange = function()
+            {
+                if(xmlhttp.status == 200 && xmlhttp.readyState == 4)
+                {
+                    eventsFile = xmlhttp.responseText;
+                    // Process the traffic events file
+                    var lines = eventsFile.toString().split("\n");
+                    // For each line in the events file
+                    for (var line = 1; line < lines.length; line++) 
+                    {
+                        var trimmedLine = lines[line].trim();
+                        if (trimmedLine[0] !== '#') //ignores lines with #
+                        {
+                            var dots = [];                            
+                            var event = trimmedLine.split(/[ ,]+/);
+                            var start = parseFloat(event[4]); // extract postmile field
+                            var range = parseFloat(event[5]); // extract distance
+                            var newColor = getColorName(event[6]); // extract DotColor
+                            eventTimes.push(event[1]);  // extract the event time
+                            // Process each VDS in the highway network
+                            parsed_features.forEach(function (marker) {
+                                var marker_fields = marker.id.split(" ");
+                                // See if this marker's highway and direction match to this event
+                                if (marker_fields[0] === event[2] && marker_fields[1] === event[3])
+                                {   //computes difference in postmiles
+                                    var dist = parseFloat(marker_fields[2]) - start; 
+                                    // If this marker is within computed range
+                                    if (dist <= range && dist >= 0) 
+                                    {
+                                        // Add the marker to the dots representing this event
+                                        dots.push({"marker": marker, "color": newColor});
+                                    }
+                                }
+                            });
+                            targetDots.push(dots); // add this events dots to the list of targetdots
+                        } // end if
+                    }  // end for              
+                    // After the traffic events are processed,  go build the differences array
+                    buildDiff();      // side effect: leaves map with last event showing
+                    resetVDSlayer();  // restore the map to initial state
+                }
+            };
+            xmlhttp.send();
+        });
+    }
+
+    // Calls updateMarker for all targetDots after storing the previous marker in diff_arr 
+    // This function only needs to be done once, during startup.
+    function buildDiff() 
+    {
+        for (var i = 0; i <= targetDots.length; i++)
+        {
+            if  (targetDots[i] !== undefined)
+            {
+                var targetMarkers = new Array();
+                targetDots[i].forEach(function(item)
+                {
+                    item.marker.properties.color = item.color;
+                    storePrev(item.marker, targetMarkers);
+                    updateMarker(item.marker);
+                });
+                diff_arr.push(targetMarkers);
+            }
+        }
+    }
+    // Helper function for BuildDiff
+    // Store the previous colors of the targetDots
+    // so it will available if the user goes "back".
     function storePrev(marker, targetMarkers) 
     {
@@ -129,176 +235,88 @@
     }
 
-    // Load the highways dynamic json file and update the map
-    function updateVDSlayer()
-    {
-        index = -1;
-        var parsed_JSON;
-        loadJSON(kVDSstatusFile, function(response)
-        {
-            // Parse JSON string into object
-            parsed_JSON = JSON.parse(response);
-            // Process each new marker - lookup in current map
-            parsed_JSON.features.forEach(updateMarker);
-        });
-    }
-
-    function getColorName(str){
-        if (str === "R\r" || str === "R")
-            return "red";
-        else if (str === "Y\r" || str === "Y")
-            return "yellow";
-        else if (str === "G\r" || str === "G")
-            return "lime";
-    }
-
-    function processVDS() {
-        var parsed_JSON;
-        loadJSON(kVDSstatusFile, function(response)
-        { 
-            // Parse JSON string into object
-            parsed_JSON = JSON.parse(response);
-            // Process each new marker - lookup in current map
-            var array =  parsed_JSON.features;
-            var txt = '';
-            var xmlhttp = new XMLHttpRequest();
-            xmlhttp.onreadystatechange = function(){
-                if(xmlhttp.status == 200 && xmlhttp.readyState == 4){
-                    txt = xmlhttp.responseText;
-                    var lines = txt.toString().split("\n");
-                    for (var line = 1; line < lines.length; line++) {
-                        filters[line-1] = [];
-                        var event = lines[line].split(/[ ,]+/);
-                        var start = parseFloat(event[4]); // 7.73
-                        var range = parseFloat(event[5]); // 0.5
-                        var newColor = getColorName(event[6]); // "R"
-                        times.push(event[1]);
-                        array.forEach(function (marker) {
-                            var id_arr = marker.id.split(" ");
-                            if (id_arr[0] === event[2] && id_arr[1] === event[3]){
-                                var dist = parseFloat(id_arr[2]) - start; //difference of postmiles
-                                if (dist <= range && dist >= 0){
-                                    filters[line-1].push({"marker": marker, "color": newColor});
-                                }
-                            }
-                        });
-                    }
-                }
-            };
-            xmlhttp.open("GET",trafficEventsFile,true); //read traffic events text file
-            xmlhttp.send();
-        });
-    }
-      
-    // updates color for each marker based on color in filters array
-    function updateVDS(forwards) { 
-		if (forwards) {
-            index++;
-            if (index >= filters.length) 
-            {
-                index = filters.length - 1;
-            }
-            if  (filters[index] !== undefined) {
-                filters[index].forEach(function(item){
-                    item.marker.properties.color = item.color;
-                    updateMarker(item.marker);
-                });
-            }
-        }
-		else {
-            if  (diff_arr[index] !== undefined) {
-                diff_arr[index].forEach(function(item){
-                    updateMarker(item);
-                });
-            }
-            index--; 
-            if (index < -1)
-            {
-                index = -1;
-            }
-        }
-    }
-
-    function buildDiff() 
-    {
-        for (var i = 0; i <= filters.length; i++)
-        {
-            if  (filters[i] !== undefined)
-            {
-                var targetMarkers = new Array();
-                filters[i].forEach(function(item){
-                    item.marker.properties.color = item.color;
-                    storePrev(item.marker, targetMarkers);
-                    updateMarker(item.marker);
-                });
-                diff_arr.push(targetMarkers);
-            }
-        }
-    }
-
-function initVDSbutton()
-{
-
-    var vdsBtnDiv = document.getElementById('vdsButton');
-    map.controls[google.maps.ControlPosition.LEFT_BOTTOM].push(vdsBtnDiv)
-    vdsBtnDiv.title = 'Click to toggle vds view';
-
-    // Setup the click event listeners to toggle icon display
-    vdsBtnDiv.addEventListener('click', function()
-    {
-        vds_showing = !vds_showing;
-        // reveal or hide all the dots
-        map.data.forEach(function(feature)
-        {
-            map.data.overrideStyle(feature,
-            {
-                visible: vds_showing
+
+
+    // Increments the eventIndex from and updates all the targetDots on map
+    function updateForwards() {
+        eventIndex++;
+        // limit eventIndex to length of targetDots
+        if (eventIndex >= targetDots.length) 
+        {
+            eventIndex = targetDots.length - 1;
+        }
+        // update all the target dots
+        if  (targetDots[eventIndex] !== undefined) {
+            targetDots[eventIndex].forEach(function(item){
+                item.marker.properties.color = item.color;
+                updateMarker(item.marker);
             });
-        });
-        // Determine which button image to show
-        if (vds_showing)
-        {
-            pic = "images/btnDepressed_VDS.png"
-        }
-        else
-        {
-            pic = "images/btnReady_VDS.png"
-        }
-        document.getElementById('vdsBtnImg').src = pic;
-    });
-}
-
-// init beginning and next buttons as well as time display on map
-function initForwardbutton()
+        }
+    }
+
+    // Decrements the eventIndex and updates all the targetDots from diff_arr on map
+    function updateBackwards() {
+        //update each target dot in order to revert to previous color
+        if  (diff_arr[eventIndex] !== undefined) {
+            diff_arr[eventIndex].forEach(function(item){
+                updateMarker(item);
+            });
+        }
+        eventIndex--; 
+        // restrict eventIndex to -1
+        if (eventIndex < -1)
+        {
+            eventIndex = -1;
+        }
+    }
+    
+
+// init beginning, forward and back buttons as well as time display on map
+function initControlButtons()
 {
     var i = 0;
+    // setup the time display
     var time = document.getElementById('time');
     map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(time)
-    var start = document.getElementById('start');
-    map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(start)
-    start.title = 'Click to see the first event';
+    // set up the "beginning" button
+    var beginning = document.getElementById('beginning');
+    map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(beginning)
+    beginning.title = 'Click to see the first event';
+    // set up the "next" button
     var forward = document.getElementById('forward');
     map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(forward)
+    // set up the "back" button
 	var backward = document.getElementById('backward');
 	map.controls[google.maps.ControlPosition.BOTTOM_CENTER].push(backward)
     forward.title = 'Click to see the next event';
-    //console.log(diff_arr);
+    //console.log(targetDots, eventTimes);
+    // Establish the listeners for each button
     forward.addEventListener('click', function() {
-        updateVDS(1);
-        if (i < times.length - 1)
+        updateForwards();
+        backward.disabled = false;
+        if (i < eventTimes.length - 1) // get the next eventTime 
         {
             ++i;
-            time.innerHTML = times[i];
+            time.innerHTML = eventTimes[i];
+        }
+        if (eventIndex === targetDots.length - 1) // disable next button if last event reached
+        {
+            forward.disabled = true;
         }
     });
 	backward.addEventListener('click', function() {
-        updateVDS(0);
-        if (i > 0)
+        updateBackwards();
+        forward.disabled = false;
+        if (i > 0)  // get the prev eventTime 
         {
             --i;
-            time.innerHTML = times[i];
+            time.innerHTML = eventTimes[i];
+        }
+        if (eventIndex < 0) // disable back button if at first event 
+        {
+            backward.disabled = true;
         }
 	});
-    start.addEventListener('click', function() {
-        updateVDSlayer();
+    beginning.addEventListener('click', function() {
+        resetVDSlayer(); // redraw markers on map from startup file
         i = 0;
         time.innerHTML = "00:00:00";
