diff --git a/dev/js/spec/matchSpec.js b/dev/js/spec/matchSpec.js
index 09c8da7..bee5f86 100644
--- a/dev/js/spec/matchSpec.js
+++ b/dev/js/spec/matchSpec.js
@@ -217,7 +217,7 @@
 
     it('should be initializable by Object', function () {
       expect(function() {
-	matchClass.create()
+	      matchClass.create()
       }).toThrow(new Error('Missing parameters'));
 
       expect(matchClass.create(match)).toBeTruthy();
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index 16ddf82..6f2c391 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -5,6 +5,8 @@
 
   var vcClass =          require('vc');
   var docClass =         require('vc/doc');
+  var menuClass =        require('vc/menu');
+  var prefixClass =      require('vc/prefix');
   var docGroupClass =    require('vc/docgroup');
   var unspecifiedClass = require('vc/unspecified');
   var operatorsClass =   require('vc/operators');
@@ -15,14 +17,14 @@
   buildFactory = function (objClass, defaults) {
     return {
       create : function (overwrites) {
-	var newObj = {};
-	for (var prop in defaults) {
-	  newObj[prop] = defaults[prop];
-	};
-	for (var prop in overwrites) {
-	  newObj[prop] = overwrites[prop];
-	};
-	return objClass.create().fromJson(newObj);
+	      var newObj = {};
+	      for (var prop in defaults) {
+	        newObj[prop] = defaults[prop];
+	      };
+	      for (var prop in overwrites) {
+	        newObj[prop] = overwrites[prop];
+	      };
+	      return objClass.create().fromJson(newObj);
       }
     }
   };
@@ -148,7 +150,7 @@
 
       // No valid string
       doc = stringFactory.create({
-	value : undefined
+	      value : undefined
       });
       expect(doc).toBeUndefined();
 
@@ -787,7 +789,7 @@
     });
   });
 
-  describe('KorAP.VirtualCollection', function () {
+  describe('KorAP.VirtualCorpus', function () {
     var simpleGroupFactory = buildFactory(docGroupClass, {
       "@type" : "koral:docGroup",
       "operation" : "operation:and",
@@ -2022,12 +2024,49 @@
       var sv = stringValClass.create();
       var count = 1;
       sv.store = function (value, regex) {
-	expect(regex).toBe(true);
-	expect(value).toBe('tree');
+	      expect(regex).toBe(true);
+	      expect(value).toBe('tree');
       };
       sv.regex(true);
       sv.value('tree');
       sv.element().lastChild.click();
     });
   });
+
+  // Check prefix
+  describe('KorAP.VC.Prefix', function () {
+
+    it('should be initializable', function () {
+      var p = prefixClass.create();
+      expect(p.element().classList.contains('pref')).toBeTruthy();
+      expect(p.isSet()).not.toBeTruthy();
+    });
+
+
+    it('should be clickable', function () {
+      var vc = vcClass.create([
+	      ['a', null],
+	      ['b', null],
+	      ['c', null]
+	    ]).fromJson();
+      expect(vc.element().firstChild.classList.contains('unspecified')).toBeTruthy();
+
+      // This should open up the menu
+      vc.element().firstChild.firstChild.click();
+      expect(vc.element().firstChild.firstChild.tagName).toEqual('UL');
+
+      KorAP._vcKeyMenu._prefix.clear();
+      KorAP._vcKeyMenu._prefix.add('x');
+
+      var prefElement = vc.element().querySelector('span.pref');
+      expect(prefElement.innerText).toEqual('x');
+
+      // This should add key 'x' to VC
+      prefElement.click();
+
+      expect(vc.element().firstChild.classList.contains('doc')).toBeTruthy();
+      expect(vc.element().firstChild.firstChild.className).toEqual('key');
+      expect(vc.element().firstChild.firstChild.innerText).toEqual('x');
+    });
+  });
 });
diff --git a/dev/js/src/hint/prefix.js b/dev/js/src/hint/prefix.js
index bdc7bdf..dc14d5c 100644
--- a/dev/js/src/hint/prefix.js
+++ b/dev/js/src/hint/prefix.js
@@ -6,7 +6,7 @@
      */
     create : function (params) {
       return Object.create(prefixClass).
-	upgradeTo(this)._init(params);
+	      upgradeTo(this)._init(params);
     },
 
     /**
diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index 8619d89..e575b7e 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -21,9 +21,9 @@
   'menu/slider',
   'util'
 ], function (defaultItemClass,
-	     defaultPrefixClass,
-	     defaultLengthFieldClass,
-	     sliderClass) {
+             defaultPrefixClass,
+             defaultLengthFieldClass,
+             sliderClass) {
 
   // Default maximum number of menu items
   var menuLimit = 8;
@@ -62,25 +62,25 @@
     _init : function (list, params) {
 
       if (params === undefined)
-	params = {};
+        params = {};
 
       this._itemClass = params["itemClass"] || defaultItemClass;
 
       // Add prefix object
       if (params["prefixClass"] !== undefined) {
-	this._prefix = params["prefixClass"].create();
+        this._prefix = params["prefixClass"].create();
       }
       else {
-	this._prefix = defaultPrefixClass.create();
+        this._prefix = defaultPrefixClass.create();
       };
       this._prefix._menu = this;
 
       // Add lengthField object
       if (params["lengthFieldClass"] !== undefined) {
-	this._lengthField = params["lengthFieldClass"].create();
+        this._lengthField = params["lengthFieldClass"].create();
       }
       else {
-	this._lengthField = defaultLengthFieldClass.create();
+        this._lengthField = defaultLengthFieldClass.create();
       };
       this._lengthField._menu = this;
 
@@ -90,12 +90,12 @@
       // Create the element
       var el = document.createElement("ul");
       with (el) {
-	style.outline = 0;
-	setAttribute('tabindex', 0);
-	classList.add('menu', 'roll');
-	appendChild(this._prefix.element());
-	appendChild(this._lengthField.element());
-	appendChild(this._slider.element());
+        style.outline = 0;
+        setAttribute('tabindex', 0);
+        classList.add('menu', 'roll');
+        appendChild(this._prefix.element());
+        appendChild(this._lengthField.element());
+        appendChild(this._slider.element());
       };
 
       // This has to be cleaned up later on
@@ -103,44 +103,44 @@
 
       // Arrow keys
       el.addEventListener(
-	'keydown',
-	this._keydown.bind(this),
-	false
+        'keydown',
+        this._keydown.bind(this),
+        false
       );
 
       // Strings
       el.addEventListener(
-	'keypress',
-	this._keypress.bind(this),
-	false
+        'keypress',
+        this._keypress.bind(this),
+        false
       );
 
       // Mousewheel
       el.addEventListener(
-	'wheel',
-	this._mousewheel.bind(this),
-	false
+        'wheel',
+        this._mousewheel.bind(this),
+        false
       );
       this._element = el;
-
+      
       this._items = new Array();
 
       var i = 0;
       // Initialize item list based on parameters
       for (i in list) {
-	var obj = this._itemClass.create(list[i]);
+        var obj = this._itemClass.create(list[i]);
 
-	// This may become circular
-	obj["_menu"] = this;
-	this._lengthField.add(list[i]);
-	this._items.push(obj);
+        // This may become circular
+        obj["_menu"] = this;
+        this._lengthField.add(list[i]);
+        this._items.push(obj);
       };
 
       this._limit = menuLimit;
       this._slider.length(this.liveLength())
-	.limit(this._limit)
-	.reInit();
-
+        .limit(this._limit)
+        .reInit();
+      
       this._firstActive = false; // Show the first item active always?
       this.offset = 0;
       this.position = 0;
@@ -152,11 +152,11 @@
 
       // Create a new list
       if (this._list === undefined) {
-	this._list = [];
+        this._list = [];
       }
       else if (this._list.length !== 0) {
-	this._boundary(false);
-	this._list.length = 0;
+        this._boundary(false);
+        this._list.length = 0;
       };
 
       // Offset is initially zero
@@ -165,16 +165,16 @@
       // There is no prefix set
       if (this.prefix().length <= 0) {
 
-	// add all items to the list and lowlight
-	var i = 0;
-	for (; i < this._items.length; i++) {
-	  this._list.push(i);
-	  this._items[i].lowlight();
-	};
+        // add all items to the list and lowlight
+        var i = 0;
+        for (; i < this._items.length; i++) {
+          this._list.push(i);
+          this._items[i].lowlight();
+        };
 
-	this._slider.length(i).reInit();;
+        this._slider.length(i).reInit();;
 
-	return true;
+        return true;
       };
 
       /*
@@ -186,8 +186,8 @@
       // Iterate over all items and choose preferred matching items
       // i.e. the matching happens at the word start
       for (pos = 0; pos < this._items.length; pos++) {
-	if ((this.item(pos).lcField().indexOf(prefix)) >= 0)
-	  this._list.push(pos);
+        if ((this.item(pos).lcField().indexOf(prefix)) >= 0)
+          this._list.push(pos);
       };
 
       // The list is empty - so lower your expectations
@@ -195,10 +195,10 @@
       // i.e. the matching happens anywhere in the word
       prefix = prefix.substring(1);
       if (this._list.length == 0) {
-	for (pos = 0; pos < this._items.length; pos++) {
-	  if ((this.item(pos).lcField().indexOf(prefix)) >= 0)
-	    this._list.push(pos);
-	};
+        for (pos = 0; pos < this._items.length; pos++) {
+          if ((this.item(pos).lcField().indexOf(prefix)) >= 0)
+            this._list.push(pos);
+        };
       };
 
       this._slider.length(this._list.length).reInit();
@@ -217,11 +217,11 @@
 
       // Remove circular reference to "this" in menu
       if (this._element != undefined)
-	delete this._element["menu"]; 
+        delete this._element["menu"]; 
 
       // 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]["_menu"];
       };
 
       // Remove circular reference to "this" in prefix
@@ -245,9 +245,9 @@
 
       delta = e.deltaY / 120;
       if (delta > 0)
-	this.next();
+        this.next();
       else if (delta < 0)
-	this.prev();
+        this.prev();
       e.halt();
     },
 
@@ -258,66 +258,66 @@
 
       switch (code) {
       case 27: // 'Esc'
-	e.halt();
-	this.hide();
-	break;
+        e.halt();
+        this.hide();
+        break;
 
       case 38: // 'Up'
-	e.halt();
-	this.prev();
-	break;
+        e.halt();
+        this.prev();
+        break;
       case 33: // 'Page up'
-	e.halt();
-	this.pageUp();
-	break;
+        e.halt();
+        this.pageUp();
+        break;
       case 40: // 'Down'
-	e.halt();
-	this.next();
-	break;
+        e.halt();
+        this.next();
+        break;
       case 34: // 'Page down'
-	e.halt();
-	this.pageDown();
-	break;
+        e.halt();
+        this.pageDown();
+        break;
       case 39: // 'Right'
-	if (this._prefix.active())
-	  break;
+        if (this._prefix.active())
+          break;
 
-	var item = this.liveItem(this.position);
-
-	if (item["further"] !== undefined) {
-	  item["further"].bind(item).apply();
-	};
-
-	e.halt();
-	break;
+        var item = this.liveItem(this.position);
+        
+        if (item["further"] !== undefined) {
+          item["further"].bind(item).apply();
+        };
+        
+        e.halt();
+        break;
       case 13: // 'Enter'
 
-	// Click on prefix
-	if (this._prefix.active())
-	  this._prefix.onclick(e);
+        // Click on prefix
+        if (this._prefix.active())
+          this._prefix.onclick(e);
 
-	// Click on item
-	else
-	  this.liveItem(this.position).onclick(e);
-	e.halt();
-	break;
+        // Click on item
+        else
+          this.liveItem(this.position).onclick(e);
+        e.halt();
+        break;
       case 8: // 'Backspace'
-	this._prefix.chop();
-	this.show();
-	e.halt();
-	break;
+        this._prefix.chop();
+        this.show();
+        e.halt();
+        break;
       };
     },
 
     // Add characters to prefix
     _keypress : function (e) {
       if (e.charCode !== 0) {
-	e.halt();
-	var c = String.fromCharCode(_codeFromEvent(e));
-
-	// Add prefix
-	this._prefix.add(c);
-	this.show();
+        e.halt();
+        var c = String.fromCharCode(_codeFromEvent(e));
+        
+        // Add prefix
+        this._prefix.add(c);
+        this.show();
       };
     },
 
@@ -327,14 +327,14 @@
      */
     screen : function (nr) {
       if (nr < 0) {
-	nr = 0
+        nr = 0
       }
       else if (nr > (this.liveLength() - this.limit())) {
-	nr = (this.liveLength() - this.limit());
+        nr = (this.liveLength() - this.limit());
       };
 
       if (this.offset === nr)
-	return;
+        return;
 
       this._showItems(nr);
     },
@@ -359,11 +359,11 @@
      */
     limit : function (limit) {
       if (arguments.length === 1) {
-	if (this._limit !== limit) {
-	  this._limit = limit;
-	  this._slider.limit(limit).reInit();
-	};
-	return this;
+        if (this._limit !== limit) {
+          this._limit = limit;
+          this._slider.limit(limit).reInit();
+        };
+        return this;
       };
       return this._limit;
     },
@@ -377,7 +377,7 @@
      */
     upgradeTo : function (props) {
       for (var prop in props) {
-	this[prop] = props[prop];
+        this[prop] = props[prop];
       };
       return this;
     },
@@ -398,13 +398,13 @@
       // Initialize the list
       if (!this._initList()) {
 
-	// The prefix is not active
-	this._prefix.active(true);
+        // The prefix is not active
+        this._prefix.active(true);
 
-	// finally show the element
-	this._element.classList.add('visible');
-
-	return true;
+        // finally show the element
+        this._element.classList.add('visible');
+        
+        return true;
       };
 
       var offset = 0;
@@ -412,33 +412,33 @@
       // Set a chosen value to active and move the viewport
       if (arguments.length === 1) {
 
-	// Normalize active value
-	if (active < 0) {
-	  active = 0;
-	}
-	else if (active >= this.liveLength()) {
-	  active = this.liveLength() - 1;
-	};
+        // Normalize active value
+        if (active < 0) {
+          active = 0;
+        }
+        else if (active >= this.liveLength()) {
+          active = this.liveLength() - 1;
+        };
 
-	// Item is outside the first viewport
-	if (active >= this._limit) {
-	  offset = active;
-	  if (offset > (this.liveLength() - this._limit)) {
-	      offset = this.liveLength() - this._limit;
-	  };
-	};
-
-	this.position = active;
+        // Item is outside the first viewport
+        if (active >= this._limit) {
+          offset = active;
+          if (offset > (this.liveLength() - this._limit)) {
+            offset = this.liveLength() - this._limit;
+          };
+        };
+        
+        this.position = active;
       }
 
       // Choose the first item
       else if (this._firstActive) {
-	this.position = 0;
+        this.position = 0;
       }
 
       // Choose no item
       else {
-	this.position = -1;
+        this.position = -1;
       };
 
       this.offset = offset;
@@ -446,7 +446,7 @@
 
       // Make chosen value active
       if (this.position !== -1) {
-	this.liveItem(this.position).active(true);
+        this.liveItem(this.position).active(true);
       };
 
       // The prefix is not active
@@ -487,8 +487,8 @@
      */
     prefix : function (pref) {
       if (arguments.length === 1) {
-	this._prefix.value(pref);
-	return this;
+        this._prefix.value(pref);
+        return this;
       };
       return this._prefix.value();
     },
@@ -518,9 +518,9 @@
       var children = this._element.childNodes;
       // Leave the prefix and lengthField
       for (var i = children.length - 1; i >= 3; i--) {
-	this._element.removeChild(
-	  children[i]
-	);
+        this._element.removeChild(
+          children[i]
+        );
       };
     },
 
@@ -542,8 +542,8 @@
      */
     liveItem : function (index) {
       if (this._list === undefined)
-	if (!this._initList())
-	  return;
+        if (!this._initList())
+          return;
 
       return this._items[this._list[index]];
     },
@@ -557,7 +557,7 @@
      */
     shownItem : function (index) {
       if (index >= this.limit())
-	return;
+        return;
       return this.liveItem(this.offset + index);
     },
 
@@ -575,7 +575,7 @@
      */
     liveLength : function () {
       if (this._list === undefined)
-	this._initList();
+        this._initList();
       return this._list.length;
     },
 
@@ -587,11 +587,11 @@
 
       // No list
       if (this.liveLength() === 0)
-	return;
+        return;
 
       // Deactivate old item
       if (this.position !== -1 && !this._prefix.active()) {
-	this.liveItem(this.position).active(false);
+        this.liveItem(this.position).active(false);
       };
 
       // Get new active item
@@ -601,33 +601,33 @@
       // The next element is undefined - roll to top or to prefix
       if (newItem === undefined) {
 
-	// Activate prefix
-	var prefix = this._prefix;
+        // Activate prefix
+        var prefix = this._prefix;
 
-	// Prefix is set and not active - choose!
-	if (prefix.isSet() && !prefix.active()) {
-	  this.position--;
-	  prefix.active(true);
-	  return;
-	}
+        // Prefix is set and not active - choose!
+        if (prefix.isSet() && !prefix.active()) {
+          this.position--;
+          prefix.active(true);
+          return;
+        }
 
-	// Choose first item
-	else {
-	  newItem = this.liveItem(0);
-	  // choose first item
-	  this.position = 0;
-	  this._showItems(0);
-	};
+        // Choose first item
+        else {
+          newItem = this.liveItem(0);
+          // choose first item
+          this.position = 0;
+          this._showItems(0);
+        };
       }
 
       // The next element is after the viewport - roll down
       else if (this.position >= (this.limit() + this.offset)) {
-	this.screen(this.position - this.limit() + 1);
+        this.screen(this.position - this.limit() + 1);
       }
 
       // The next element is before the viewport - roll up
       else if (this.position <= this.offset) {
-	this.screen(this.position);
+        this.screen(this.position);
       };
 
       this._prefix.active(false);
@@ -641,20 +641,20 @@
 
       // No list
       if (this.liveLength() === 0)
-	return;
+        return;
 
       // Deactivate old item
       if (!this._prefix.active()) {
 
-	// No active element set
-	if (this.position === -1) {
-	  this.position = this.liveLength();
-	}
+        // No active element set
+        if (this.position === -1) {
+          this.position = this.liveLength();
+        }
 
-	// No active element set
-	else {
-	  this.liveItem(this.position--).active(false);
-	};
+        // No active element set
+        else {
+          this.liveItem(this.position--).active(false);
+        };
       };
 
       // Get new active item
@@ -663,39 +663,39 @@
       // The previous element is undefined - roll to bottom
       if (newItem === undefined) {
 
-	// Activate prefix
-	var prefix = this._prefix;
-	var offset =  this.liveLength() - this.limit();
+        // Activate prefix
+        var prefix = this._prefix;
+        var offset =  this.liveLength() - this.limit();
+        
+        // Normalize offset
+        offset = offset < 0 ? 0 : offset;
 
-	// Normalize offset
-	offset = offset < 0 ? 0 : offset;
+        // Choose the last item
+        this.position = this.liveLength() - 1;
+        
+        // Prefix is set and not active - choose!
+        if (prefix.isSet() && !prefix.active()) {
+          this.position++;
+          prefix.active(true);
+          this.offset = offset;
+          return;
+        }
 
-	// Choose the last item
-	this.position = this.liveLength() - 1;
-
-	// Prefix is set and not active - choose!
-	if (prefix.isSet() && !prefix.active()) {
-	  this.position++;
-	  prefix.active(true);
-	  this.offset = offset;
-	  return;
-	}
-
-	// Choose last item
-	else {
-	  newItem = this.liveItem(this.position);
-	  this._showItems(offset);
-	};
+        // Choose last item
+        else {
+          newItem = this.liveItem(this.position);
+          this._showItems(offset);
+        };
       }
 
       // The previous element is before the view - roll up
       else if (this.position < this.offset) {
-	this.screen(this.position);
+        this.screen(this.position);
       }
 
       // The previous element is after the view - roll down
       else if (this.position >= (this.limit() + this.offset)) {
-	this.screen(this.position - this.limit() + 2);
+        this.screen(this.position - this.limit() + 2);
       };
 
       this._prefix.active(false);
@@ -721,9 +721,9 @@
     // Unmark all items
     _unmark : function () {
       for (var i in this._list) {
-	var item = this._items[this._list[i]];
-	item.lowlight();
-	item.active(false);	
+        var item = this._items[this._list[i]];
+        item.lowlight();
+        item.active(false);  
       };
     },
 
@@ -739,48 +739,48 @@
 
       // optimization: scroll down one step
       if (this.offset === (off - 1)) {
-	this.offset = off;
+        this.offset = off;
 
-	// Remove the HTML node from the first item
-	// leave lengthField/prefix/slider
-	this._element.removeChild(this._element.children[3]);
-	var pos = this.offset + this.limit() - 1;
-	this._append(this._list[pos]);
+        // Remove the HTML node from the first item
+        // leave lengthField/prefix/slider
+        this._element.removeChild(this._element.children[3]);
+        var pos = this.offset + this.limit() - 1;
+        this._append(this._list[pos]);
       }
 
       // optimization: scroll up one step
       else if (this.offset === (off + 1)) {
-	this.offset = off;
+        this.offset = off;
 
-	// Remove the HTML node from the last item
-	this._element.removeChild(this._element.lastChild);
+        // Remove the HTML node from the last item
+        this._element.removeChild(this._element.lastChild);
 
-	this._prepend(this._list[this.offset]);
+        this._prepend(this._list[this.offset]);
       }
       else {
-	this.offset = off;
+        this.offset = off;
 
-	// Remove all items
-	this.removeItems();
+        // Remove all items
+        this.removeItems();
 
-	// Use list
-	var shown = 0;
-	var i;
+        // Use list
+        var shown = 0;
+        var i;
 
-	for (i in this._list) {
+        for (i in this._list) {
 
-	  // Don't show - it's before offset
-	  shown++;
-	  if (shown <= off)
-	    continue;
+          // Don't show - it's before offset
+          shown++;
+          if (shown <= off)
+            continue;
 
-	  var itemNr = this._list[i];
-	  var item = this.item(itemNr);
-	  this._append(itemNr);
-
-	  if (shown >= (this.limit() + off))
-	    break;
-	};
+          var itemNr = this._list[i];
+          var item = this.item(itemNr);
+          this._append(itemNr);
+          
+          if (shown >= (this.limit() + off))
+            break;
+        };
       };
 
       // set the slider to the new offset
@@ -794,7 +794,7 @@
 
       // Highlight based on prefix
       if (this.prefix().length > 0) {
-	item.highlight(this.prefix().toLowerCase());
+        item.highlight(this.prefix().toLowerCase());
       };
 
 
@@ -809,15 +809,15 @@
 
       // Highlight based on prefix
       if (this.prefix().length > 0) {
-	item.highlight(this.prefix().toLowerCase());
+        item.highlight(this.prefix().toLowerCase());
       };
 
       var e = this.element();
 
       // Append element after lengthField/prefix/slider
       e.insertBefore(
-	item.element(),
-	e.children[3]
+        item.element(),
+        e.children[3]
       );
     }
   };
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index e551d63..3e9f16e 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -84,50 +84,50 @@
 
       // Inject localized css styles
       if (!KorAP._overrideStyles) {
-	var sheet = KorAP.newStyleSheet();
+	      var sheet = KorAP.newStyleSheet();
 
-	// Add css rule for OR operations
-	sheet.insertRule(
-	  '.vc .docGroup[data-operation=or] > .doc::before,' +
-	  '.vc .docGroup[data-operation=or] > .docGroup::before ' +
-	    '{ content: "' + loc.OR + '" }',
-	  0
-	);
+	      // Add css rule for OR operations
+	      sheet.insertRule(
+	        '.vc .docGroup[data-operation=or] > .doc::before,' +
+	          '.vc .docGroup[data-operation=or] > .docGroup::before ' +
+	          '{ content: "' + loc.OR + '" }',
+	        0
+	      );
 
-	// Add css rule for AND operations
-	sheet.insertRule(
-	  '.vc .docGroup[data-operation=and] > .doc::before,' +
-	  '.vc .docGroup[data-operation=and] > .docGroup::before ' +
-	    '{ content: "' + loc.AND + '" }',
-	  1
-	);
+	      // Add css rule for AND operations
+	      sheet.insertRule(
+	        '.vc .docGroup[data-operation=and] > .doc::before,' +
+	          '.vc .docGroup[data-operation=and] > .docGroup::before ' +
+	          '{ content: "' + loc.AND + '" }',
+	        1
+	      );
 
-	KorAP._overrideStyles = true;
+	      KorAP._overrideStyles = true;
 
-	// Create key menu
-	KorAP._vcKeyMenu = menuClass.create(keyList);
-	KorAP._vcKeyMenu.limit(6);
+	      // Create key menu
+	      KorAP._vcKeyMenu = menuClass.create(keyList);
+	      KorAP._vcKeyMenu.limit(6);
 
-	// Create match menus ....
-	KorAP._vcMatchopMenu = {
-	  'string' : menuClass.create([
-	    ['eq', null],
-	    ['ne', null],
-	    ['contains', null],
-	    ['containsnot', null]
-	  ]),
-	  'date' : menuClass.create([
-	    ['eq', null],
-	    ['geq', null],
-	    ['leq', null]
-	  ]),
-	  'regex' : menuClass.create([
-	    ['eq', null],
-	    ['ne', null],
-	    ['contains', null],
-	    ['containsnot', null]
-	  ])
-	};
+	      // Create match menus ....
+	      KorAP._vcMatchopMenu = {
+	        'string' : menuClass.create([
+	          ['eq', null],
+	          ['ne', null],
+	          ['contains', null],
+	          ['containsnot', null]
+	        ]),
+	        'date' : menuClass.create([
+	          ['eq', null],
+	          ['geq', null],
+	          ['leq', null]
+	        ]),
+	        'regex' : menuClass.create([
+	          ['eq', null],
+	          ['ne', null],
+	          ['contains', null],
+	          ['containsnot', null]
+	        ])
+	      };
       };
 
       return this;
@@ -148,26 +148,25 @@
      * based on a KoralQuery collection document 
      */
     fromJson : function (json) {
-
       if (json !== undefined) {
-	// Parse root document
-	if (json['@type'] == 'koral:doc') {
-	  this._root = docClass.create(this, json);
-	}
-	// parse root group
-	else if (json['@type'] == 'koral:docGroup') {
-	  this._root = docGroupClass.create(this, json);
-	}
-	// Unknown collection type
-	else {
-	  KorAP.log(813, "Collection type is not supported");
-	  return;
-	};
+	      // Parse root document
+	      if (json['@type'] == 'koral:doc') {
+	        this._root = docClass.create(this, json);
+	      }
+	      // parse root group
+	      else if (json['@type'] == 'koral:docGroup') {
+	        this._root = docGroupClass.create(this, json);
+	      }
+	      // Unknown collection type
+	      else {
+	        KorAP.log(813, "Collection type is not supported");
+	        return;
+	      };
       }
 
       else {
-	// Add unspecified object
-	this._root = unspecDocClass.create(this);
+	      // Add unspecified object
+	      this._root = unspecDocClass.create(this);
       };
 
       // Init element and update
@@ -195,24 +194,24 @@
      */
     root : function (obj) {
       if (arguments.length === 1) {
-	var e = this.element();
+	      var e = this.element();
 
-	if (e.firstChild !== null) {
-	  if (e.firstChild !== obj.element()) {
-	    e.replaceChild(obj.element(), e.firstChild);
-	  };
-	}
+	      if (e.firstChild !== null) {
+	        if (e.firstChild !== obj.element()) {
+	          e.replaceChild(obj.element(), e.firstChild);
+	        };
+	      }
 
-	// Append root element
-	else {
-	  e.appendChild(obj.element());
-	};
+	      // Append root element
+	      else {
+	        e.appendChild(obj.element());
+	      };
 
-	// Update parent child relations
-	this._root = obj;
-	obj.parent(this);
+	      // Update parent child relations
+	      this._root = obj;
+	      obj.parent(this);
 
-	this.update();
+	      this.update();
       };
       return this._root;
     },
diff --git a/dev/js/src/vc/chooseitem.js b/dev/js/src/vc/chooseitem.js
index b2d3c1b..5dc42b3 100644
--- a/dev/js/src/vc/chooseitem.js
+++ b/dev/js/src/vc/chooseitem.js
@@ -13,14 +13,14 @@
      */
     create : function (params) {
       return Object.create(itemClass)
-	.upgradeTo(this)
-	._init(params);
+	      .upgradeTo(this)
+	      ._init(params);
     },
 
     // Initialize item object
     _init : function (params) {
       if (params[0] === undefined)
-	throw new Error("Missing parameters");
+	      throw new Error("Missing parameters");
       
       this._id  = params[0];
       this._name = params[1];
@@ -38,8 +38,8 @@
      */
     onclick : function (e) {
       this.menu().release(
-	this._id,
-	this._name
+	      this._id,
+	      this._name
       );
       e.halt();
     },
@@ -72,7 +72,7 @@
 
       // already defined
       if (this._element !== undefined)
-	return this._element;
+	      return this._element;
 
       // Create list item
       var li = document.createElement("li");
diff --git a/dev/js/src/vc/doc.js b/dev/js/src/vc/doc.js
index f22f3b4..b56ba53 100644
--- a/dev/js/src/vc/doc.js
+++ b/dev/js/src/vc/doc.js
@@ -41,13 +41,13 @@
 
       // Create the object, inheriting from Json-LD class
       var obj = Object(jsonldClass).
-	create().
-	upgradeTo(this).
-	fromJson(json);
+          create().
+          upgradeTo(this).
+          fromJson(json);
 
       // Bind the parent
       if (parent !== undefined)
-	obj._parent = parent;
+        obj._parent = parent;
       
       obj.__changed = true;
       return obj;
@@ -58,7 +58,7 @@
      */
     update : function () {
       if (this._element === undefined)
-	return this.element();
+        return this.element();
       
       // Get element
       var e = this._element;
@@ -69,82 +69,82 @@
       // Check if there is a change
       if (this.__changed) {
 
-	// Was rewritten
-	if (this.rewrites() !== undefined) {
-	  e.classList.add("rewritten");
-	};
+        // Was rewritten
+        if (this.rewrites() !== undefined) {
+          e.classList.add("rewritten");
+        };
 
-	// Added key
-	this._keyE = document.createElement('span');
-	this._keyE.setAttribute('class', 'key');
+        // Added key
+        this._keyE = document.createElement('span');
+        this._keyE.setAttribute('class', 'key');
 
-	// Change key
-	this._keyE.addEventListener('click', this._changeKey.bind(this));
+        // Change key
+        this._keyE.addEventListener('click', this._changeKey.bind(this));
 
-	if (this.key()) {
-	  var k = this.key();
-	  if (loc['VC_' + k] !== undefined)
-	    k = loc['VC_' + k];
-	  this._keyE.appendChild(document.createTextNode(k));
-	};
+        if (this.key()) {
+          var k = this.key();
+          if (loc['VC_' + k] !== undefined)
+            k = loc['VC_' + k];
+          this._keyE.appendChild(document.createTextNode(k));
+        };
 
-	// Added match operator
-	this._matchopE = document.createElement('span');
-	this._matchopE.setAttribute('data-type', this.type());
-	this._matchopE.setAttribute('class', 'match');
-	this._matchopE.appendChild(
-	  document.createTextNode(this.matchop())
-	);
+        // Added match operator
+        this._matchopE = document.createElement('span');
+        this._matchopE.setAttribute('data-type', this.type());
+        this._matchopE.setAttribute('class', 'match');
+        this._matchopE.appendChild(
+          document.createTextNode(this.matchop())
+        );
 
-	// Change matchop
-	this._matchopE.addEventListener(
-	  'click',
-	  this._changeMatchop.bind(this)
-	);
+        // Change matchop
+        this._matchopE.addEventListener(
+          'click',
+          this._changeMatchop.bind(this)
+        );
 
-	// Added value operator
-	this._valueE = document.createElement('span');
-	this._valueE.setAttribute('data-type', this.type());
-	this._valueE.setAttribute('class', 'value');
-	if (this.value()) {
-	  this._valueE.appendChild(document.createTextNode(this.value()));
-	}
-	else {
-	  this._valueE.appendChild(document.createTextNode(loc.EMPTY));
-	};
+        // Added value operator
+        this._valueE = document.createElement('span');
+        this._valueE.setAttribute('data-type', this.type());
+        this._valueE.setAttribute('class', 'value');
+        if (this.value()) {
+          this._valueE.appendChild(document.createTextNode(this.value()));
+        }
+        else {
+          this._valueE.appendChild(document.createTextNode(loc.EMPTY));
+        };
 
-	// Change value
-	this._valueE.addEventListener(
-	  'click',
-	  this._changeValue.bind(this)
-	);
+        // Change value
+        this._valueE.addEventListener(
+          'click',
+          this._changeValue.bind(this)
+        );
 
 
-	// Remove all element children
-	_removeChildren(e);
+        // Remove all element children
+        _removeChildren(e);
 
-	// Add spans
-	e.appendChild(this._keyE);
-	e.appendChild(this._matchopE);
-	e.appendChild(this._valueE);
+        // Add spans
+        e.appendChild(this._keyE);
+        e.appendChild(this._matchopE);
+        e.appendChild(this._valueE);
 
-	this.__changed = false;
+        this.__changed = false;
       };
 
       if (this._rewrites !== undefined) {
-	e.appendChild(this._rewrites.element());
+        e.appendChild(this._rewrites.element());
       };
 
       if (this._parent !== undefined) {
-	// Set operators
-	var op = this.operators(
-	  true,
-	  true,
-	  true
-	);
+        // Set operators
+        var op = this.operators(
+          true,
+          true,
+          true
+        );
 
-	// Append new operators
-	e.appendChild(op.element());
+        // Append new operators
+        e.appendChild(op.element());
       };
       
       return e;
@@ -156,7 +156,7 @@
      */
     element : function () {
       if (this._element !== undefined)
-	return this._element;
+        return this._element;
 
       this._element = document.createElement('div');
       this._element.setAttribute('class', 'doc');
@@ -182,105 +182,105 @@
      */
     fromJson : function (json) {
       if (json === undefined)
-	return this;
+        return this;
 
       if (json["@type"] === undefined) {
-	KorAP.log(701, "JSON-LD group has no @type attribute");
-	return;
+        KorAP.log(701, "JSON-LD group has no @type attribute");
+        return;
       };
 
       if (json["value"] === undefined ||
-	  typeof json["value"] != 'string') {
-	KorAP.log(805, "Value is invalid");
-	return;
+          typeof json["value"] != 'string') {
+        KorAP.log(805, "Value is invalid");
+        return;
       };
 
       // There is a defined key
       if (json["key"] !== undefined &&
-	  typeof json["key"] === 'string') {
+          typeof json["key"] === 'string') {
 
-	// Set key
-	this.key(json["key"]);
+        // Set key
+        this.key(json["key"]);
 
-	// Set match operation
-	if (json["match"] !== undefined) {
-	  if (typeof json["match"] === 'string') {
-	    this.matchop(json["match"]);
-	  }
-	  else {
-	    KorAP.log(802, "Match type is not supported by value type");
-	    return;
-	  };
-	};
+        // Set match operation
+        if (json["match"] !== undefined) {
+          if (typeof json["match"] === 'string') {
+            this.matchop(json["match"]);
+          }
+          else {
+            KorAP.log(802, "Match type is not supported by value type");
+            return;
+          };
+        };
 
-	// Key is a string
-	if (json["type"] === undefined ||
-	    json["type"] == "type:string") {
-	  this.type("string");
+        // Key is a string
+        if (json["type"] === undefined ||
+            json["type"] == "type:string") {
+          this.type("string");
 
-	  // Check match type
-	  if (!KorAP._validStringMatchRE.test(this.matchop())) {
-	    KorAP.log(802, "Match type is not supported by value type");
-	    return;
-	  };
+          // Check match type
+          if (!KorAP._validStringMatchRE.test(this.matchop())) {
+            KorAP.log(802, "Match type is not supported by value type");
+            return;
+          };
 
-	  // Set string value
-	  this.value(json["value"]);
-	}
+          // Set string value
+          this.value(json["value"]);
+        }
 
-	// Key is a date
-	else if (json["type"] === "type:date") {
-	  this.type("date");
+        // Key is a date
+        else if (json["type"] === "type:date") {
+          this.type("date");
 
-	  if (json["value"] !== undefined &&
-	      KorAP._validDateRE.test(json["value"])) {
+          if (json["value"] !== undefined &&
+              KorAP._validDateRE.test(json["value"])) {
 
-	    if (!KorAP._validDateMatchRE.test(this.matchop())) {
-	      KorAP.log(802, "Match type is not supported by value type");
-	      return;
-	    };
+            if (!KorAP._validDateMatchRE.test(this.matchop())) {
+              KorAP.log(802, "Match type is not supported by value type");
+              return;
+            };
 
-	    // Set value
-	    this.value(json["value"]);
-	  }
-	  else {
-	    KorAP.log(806, "Value is not a valid date string");
-	    return;
-	  };
-	}
+            // Set value
+            this.value(json["value"]);
+          }
+          else {
+            KorAP.log(806, "Value is not a valid date string");
+            return;
+          };
+        }
 
-	// Key is a regular expression
-	else if (json["type"] === "type:regex") {
-	  this.type("regex");
+        // Key is a regular expression
+        else if (json["type"] === "type:regex") {
+          this.type("regex");
 
-	  try {
+          try {
 
-	    // Try to create a regular expression
-	    var check = new RegExp(json["value"]);
+            // Try to create a regular expression
+            var check = new RegExp(json["value"]);
 
-	    if (!_validRegexMatchRE.test(this.matchop())) {
-	      KorAP.log(802, "Match type is not supported by value type");
-	      return;
-	    };
+            if (!_validRegexMatchRE.test(this.matchop())) {
+              KorAP.log(802, "Match type is not supported by value type");
+              return;
+            };
 
-	    this.value(json["value"]);
-	  }
+            this.value(json["value"]);
+          }
 
-	  catch (e) {
-	    KorAP.log(807, "Value is not a valid regular expression");
-	    return;
-	  };
-	  this.type("regex");
-	}
+          catch (e) {
+            KorAP.log(807, "Value is not a valid regular expression");
+            return;
+          };
+          this.type("regex");
+        }
 
-	else {
-	  KorAP.log(804, "Unknown value type");
-	  return;
-	};
+        else {
+          KorAP.log(804, "Unknown value type");
+          return;
+        };
       };
 
       if (json["rewrites"] !== undefined) {
-	this._rewrites = rewriteListClass.create(json["rewrites"]);
+        this._rewrites = rewriteListClass.create(json["rewrites"]);
       };
       
       return this;
@@ -291,9 +291,9 @@
      */
     key : function (value) {
       if (arguments.length === 1) {
-	this._key = value;
-	this._changed();
-	return this;
+        this._key = value;
+        this._changed();
+        return this;
       };
       return this._key;
     },
@@ -304,24 +304,24 @@
 
       // Insert menu
       this._element.insertBefore(
-	menu.element(),
-	this._keyE
+        menu.element(),
+        this._keyE
       );
 
       // Release event
       var that = this;
       menu.released(function (key, type) {
-	var doc = that.key(key).type(type);
+        var doc = that.key(key).type(type);
 
-	// This may not be compatible - then switch to default
-	doc.matchop(doc.matchop());
-	doc.value(doc.value());
+        // This may not be compatible - then switch to default
+        doc.matchop(doc.matchop());
+        doc.value(doc.value());
 
-	// Update the doc
-	doc.update();
+        // Update the doc
+        doc.update();
 
-	// hide!
-	this.hide();
+        // hide!
+        this.hide();
       });
 
       // TODO: Highlight the old value!
@@ -334,25 +334,25 @@
      */
     matchop : function (match) {
       if (arguments.length === 1) {
-	var m = match.replace(/^match:/, '');
-	if (
-	  (this._type === undefined)
-	    ||
-	    (
-	      (this._type === 'string' || this._type === 'regex') &&
-		KorAP._validStringMatchRE.test(m)
-	    )
-	    ||
-	    (this._type === 'date' && KorAP._validDateMatchRE.test(m))
-	) {
-	  this._matchop = m;
-	}
-	else {
-	  this._matchop = "eq";
-	};
+        var m = match.replace(/^match:/, '');
+        if (
+          (this._type === undefined)
+            ||
+            (
+              (this._type === 'string' || this._type === 'regex') &&
+                KorAP._validStringMatchRE.test(m)
+            )
+            ||
+            (this._type === 'date' && KorAP._validDateMatchRE.test(m))
+        ) {
+          this._matchop = m;
+        }
+        else {
+          this._matchop = "eq";
+        };
 
-	this._changed();
-	return this;
+        this._changed();
+        return this;
       };
       return this._matchop || "eq";
     },
@@ -363,21 +363,21 @@
       var menu = KorAP._vcMatchopMenu[this.type()];
 
       if (menu === undefined) {
-	KorAP.log(0, "Unable to init menu for " + this.type());
-	return;
+        KorAP.log(0, "Unable to init menu for " + this.type());
+        return;
       };
 
       // Insert menu
       this._element.insertBefore(
-	menu.element(),
-	this._matchopE
+        menu.element(),
+        this._matchopE
       );
 
       // Release event
       var that = this;
       menu.released(function (mo) {
-	that.matchop(mo).update();
-	this.hide();
+        that.matchop(mo).update();
+        this.hide();
       });
 
       menu.show();
@@ -390,9 +390,9 @@
      */
     type : function (type) {
       if (arguments.length === 1) {
-	this._type = type;
-	this._changed();
-	return this;
+        this._type = type;
+        this._changed();
+        return this;
       };
       return this._type || "string";
     },
@@ -403,14 +403,14 @@
      */
     value : function (value) {
       if (arguments.length === 1) {
-	if (this._type === 'date' && !KorAP._validDateRE.test(value)) {
-	  delete this._value;
-	}
-	else {
-	  this._value = value;
-	};
-	this._changed();
-	return this;
+        if (this._type === 'date' && !KorAP._validDateRE.test(value)) {
+          delete this._value;
+        }
+        else {
+          this._value = value;
+        };
+        this._changed();
+        return this;
       };
       return this._value;
     },
@@ -423,70 +423,69 @@
 
       // Show datepicker
       if (this.type() === 'date') {
-	var dp = KorAP._vcDatePicker;
-	dp.fromString(v)
+        var dp = KorAP._vcDatePicker;
+        dp.fromString(v)
 
-	// Todo: change this
-	dp.onclick(function (selected) {
+        // Todo: change this
+        dp.onclick(function (selected) {
 
-	  // There are values selected
-	  if (selected['year']) {
-	    that.value(this.toString());
-	    that.update();
-	    return;
-	  };
+          // There are values selected
+          if (selected['year']) {
+            that.value(this.toString());
+            that.update();
+            return;
+          };
 
-	  // Remove datepicker
-	  that._element.removeChild(
-	    dp.element()
-	  );
-	});
+          // Remove datepicker
+          that._element.removeChild(
+            dp.element()
+          );
+        });
 
-	// Get element of the date picker
-	var dpElem = dp.show();
+        // Get element of the date picker
+        var dpElem = dp.show();
 
-	this._element.insertBefore(
-	  dpElem,
-	  this._valueE
-	);
+        this._element.insertBefore(
+          dpElem,
+          this._valueE
+        );
 
-	dpElem.focus();
-	/*
-	dpElem.addEventListener('blur', function (e) {
-	  e.halt();
-
-	  // Remove datepicker
-	  // TODO: If focus is not set to string input
-	  that._element.removeChild(this);
-	});
-	*/
+        dpElem.focus();
+        /*
+          dpElem.addEventListener('blur', function (e) {
+          e.halt();
+          
+          // Remove datepicker
+          // TODO: If focus is not set to string input
+          that._element.removeChild(this);
+          });
+        */
       }
       else {
-	var regex = this.type() === 'regex' ? true : false;
-	var str = stringValClass.create(this.value(), regex);
-	var strElem = str.element();
+        var regex = this.type() === 'regex' ? true : false;
+        var str = stringValClass.create(this.value(), regex);
+        var strElem = str.element();
 
+        str.store = function (value, regex) {
+          that.value(value);
+          if (regex === true)
+            that.type('regex');
+          else
+            that.type('string');
+          
+          that._element.removeChild(
+            this._element
+          );
+          that.update();
+        };
 
-	str.store = function (value, regex) {
-	  that.value(value);
-	  if (regex === true)
-	    that.type('regex');
-	  else
-	    that.type('string');
+        // Insert element
+        this._element.insertBefore(
+          strElem,
+          this._valueE
+        );
 
-	  that._element.removeChild(
-	    this._element
-	  );
-	  that.update();
-	};
-
-	// Insert element
-	this._element.insertBefore(
-	  strElem,
-	  this._valueE
-	);
-
-	str.focus();
+        str.focus();
       };
     },
 
@@ -498,37 +497,39 @@
     _changed : function () {
       this.__changed = true;
       
-      if (this._parent) {
-      };
+      /*
+        if (this._parent) {
+        };
+      */
 
       if (this._rewrites === undefined)
-	return;
+        return;
 
       delete this["_rewrites"];
 
       if (this._element === undefined)
-	return;
+        return;
       this._element.classList.remove("rewritten");
     },
 
 
     toJson : function () {
       if (!this.matchop() || !this.key())
-	return {};
+        return {};
       
       return {
-	"@type" : "koral:" + this.ldType(),
-	"key"   : this.key(),
-	"match" : "match:" + this.matchop(),
-	"value" : this.value() || '',
-	"type"  : "type:" + this.type()
+        "@type" : "koral:" + this.ldType(),
+        "key"   : this.key(),
+        "match" : "match:" + this.matchop(),
+        "value" : this.value() || '',
+        "type"  : "type:" + this.type()
       };
     },
 
 
     toQuery : function () {
       if (!this.matchop() || !this.key())
-	return "";
+        return "";
 
       // Build doc string based on key
       var string = this.key() + ' ';
@@ -536,26 +537,26 @@
       // Add match operator
       switch (this.matchop()) {
       case "ne":
-	string += '!=';
-	break;
+        string += '!=';
+        break;
       case "contains":
-	string += '~';
-	break;
+        string += '~';
+        break;
       case "excludes":
-	string += '!~';
-	break;
+        string += '!~';
+        break;
       case "containsnot":
-	string += '!~';
-	break;
+        string += '!~';
+        break;
       case "geq":
-	string += 'since';
-	break;
+        string += 'since';
+        break;
       case "leq":
-	string += 'until';
-	break;
+        string += 'until';
+        break;
       default:
-	string += (this.type() == 'date') ? 'in' : '=';
-	break;
+        string += (this.type() == 'date') ? 'in' : '=';
+        break;
       };
 
       string += ' ';
@@ -563,14 +564,14 @@
       // Add value
       switch (this.type()) {
       case "date":
-	return string + this.value();
-	break;
+        return string + this.value();
+        break;
       case "regex":
-	return string + '/' + this.value() + '/';
-	break;
+        return string + '/' + this.value() + '/';
+        break;
       case "string":
-	return string + '"' + this.value().quote() + '"';
-	break;
+        return string + '"' + this.value().quote() + '"';
+        break;
       };
 
       return "";
diff --git a/dev/js/src/vc/menu.js b/dev/js/src/vc/menu.js
index 5840438..af4f8e1 100644
--- a/dev/js/src/vc/menu.js
+++ b/dev/js/src/vc/menu.js
@@ -1,19 +1,22 @@
 /**
  * Menu showing all key fields.
  */
-define(['menu', 'vc/item'], function (menuClass, itemClass) {
+define(['menu', 'vc/item', 'vc/prefix'], function (menuClass, itemClass, prefixClass) {
   return {
     create : function (params) {
       var obj = Object.create(menuClass)
-	.upgradeTo(this)
-	._init(params, {itemClass : itemClass});
+          .upgradeTo(this)
+          ._init(params, {
+            itemClass : itemClass,
+            prefixClass : prefixClass
+          });
       obj.limit(6);
 
       // This is only domspecific
       obj.element().addEventListener('blur', function (e) {
-	this.menu.hide();
+        this.menu.hide();
       });
-
+ 
       return obj;
     },
 
@@ -29,7 +32,7 @@
      */
     release : function (key, type) {
       if (this._cb !== undefined)
-	this._cb(key, type);
+        this._cb(key, type);
     }
   };
 });
diff --git a/dev/js/src/vc/prefix.js b/dev/js/src/vc/prefix.js
new file mode 100644
index 0000000..5deefe4
--- /dev/null
+++ b/dev/js/src/vc/prefix.js
@@ -0,0 +1,21 @@
+define(['menu/prefix'], function (prefixClass) {
+  return {
+
+    /**
+     * Create prefix object for the hint helper menu.
+     */
+    create : function (params) {
+      return Object.create(prefixClass).
+	      upgradeTo(this)._init(params);
+    },
+
+    /**
+     * Override the prefix action.
+     */
+    onclick : function (e) {
+      var m = this.menu();
+      var value = this.value();
+      m.release(value, "string");
+    }
+  };
+});
