Make treemenu a singleton

Change-Id: I0cb71df1f80c0f5d9f134a7fcf4563c3719d2302
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index d7ec89f..b2ec25b 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -122,9 +122,36 @@
         false
       );
       this._element = el;
+
+      this._limit = menuLimit;
       
       this._items = new Array();
 
+      // TODO:
+      // Make this separate from _init
+      this.readItems(list);
+
+      return this;
+    },
+
+    // Read items to add to list
+    readItems : function (list) {
+
+      this._list = undefined;
+
+      // Remove circular reference to "this" in items
+      for (var i = 0; i < this._items.length; i++) {
+        delete this._items[i]["_menu"];
+        delete this._items[i];
+      };
+
+      this._items = new Array();
+      this.removeItems();
+
+
+      // Initialize items
+      this._lengthField.reset();
+
       var i = 0;
       // Initialize item list based on parameters
       for (i in list) {
@@ -136,17 +163,16 @@
         this._items.push(obj);
       };
 
-      this._limit = menuLimit;
       this._slider.length(this.liveLength())
         .limit(this._limit)
         .reInit();
       
-      this._firstActive = false; // Show the first item active always?
+      this._firstActive = false;
+      // Show the first item active always?
       this.offset = 0;
       this.position = 0;
-      return this;
     },
-
+    
     // Initialize the item list
     _initList : function () {
 
@@ -172,7 +198,7 @@
           this._items[i].lowlight();
         };
 
-        this._slider.length(i).reInit();;
+        this._slider.length(i).reInit();
 
         return true;
       };