var list1; 
var list2Num;
$(function() {
      $("input.autobox.0").autobox({
        ajax: "list",
        match: function(typed) { return this.text.match(new RegExp(typed)); },
        insertText: function(obj) { return obj.text },
        templateText: "<li>Heya: <%= text %></li>",
        prevals : ['fred@wilma.com', 'betty@barney.com']
      });

      
      var box =
      $("input.autobox.1").autobox({
        list: list1,
        match: function(typed) {
          this.typed = typed;
          this.pre_match = this.text;
          this.match = this.post_match = '';
          if (!this.ajax && !typed || typed.length == 0) { return true; }
          var match_at = this.text.search(new RegExp("\\b" + typed, "i"));
          if (match_at != -1) {
            this.pre_match = this.text.slice(0,match_at);
            this.match = this.text.slice(match_at,match_at + typed.length);
            this.post_match = this.text.slice(match_at + typed.length);
            return true;
          }
          return false;
        },
        insertText: function(obj) { return obj.text },
        templateText: "<li><%= pre_match %><span class='matching' ><%= match %></span><%= post_match %></li>"
      });
      

      $("input.autobox.2").autobox({
        ajax: "list",
        match: function(typed) { return this.text.match(new RegExp(typed, "i")); },
        insertText: function(obj) { return obj.text },
        templateText: "<li>Hey: <%= text %></li>"
      })

      $("input.autobox")
        .bind("activate.autobox", function(e, d) { console.log(d); })
        .bind("cancel.autobox", function(e) { console.log("Cancelled"); });
    });