14c14
<       var $input = $('#' + this.id.substr(0, this.id.length - 13))
---
>       var $input = $('#' + this.id.substr(0, this.id.length - 13),context)
44c44
<   this.ariaLive = $('#' + this.input.id + '-autocomplete-aria-live');
---
>   this.ariaLive = $('#' + $input.attr('id') + '-autocomplete-aria-live');
46c46
< 
---
>   
50,51c50,57
<     .blur(function () { ac.hidePopup(); ac.db.cancel(); });
< 
---
>     .blur(function () { 
>       if (!ac.selected && ac.db.cache[this.value] && ac.db.cache[this.value][this.value]) {
>         $input.data('autocompleteValue',ac.db.cache[this.value][this.value]);    
>         ac.select($input);
>       }
>       ac.hidePopup(); 
>       ac.db.cancel(); 
>     });
61a68,70
>     case 13:
>        this.hidePopup();
>        return true;
96d104
<     case 13: // Enter.
102c110
<       if (input.value.length > 0)
---
>       if (input.value.length > 0) {
104c112,113
<       else
---
>       }
>       else {
105a115
>       }
114c124,150
<   this.input.value = $(node).data('autocompleteValue');
---
>   var autocompleteValue = $(node).data('autocompleteValue');
>   this.input.value = autocompleteValue['key'];
>   $('.autocomplete-'+this.input.name).each(function () {
>     var $name;
>     if ($(this).hasClass("stripid")) {
>       var reg=/.*[^0-9]/;
>       $name = reg.exec(this.name);
>     }
>     else {
>       $name = this.name;
>     }
>      
>     if (this.type.indexOf("select")==0) {
>       $(this).val(autocompleteValue[$name]);
>     }
>     else if (this.type.indexOf("checkbox")==0) {
>       if ((autocompleteValue[$name]==1) || (autocompleteValue[$name]=='true') || (autocompleteValue[$name]==true)) {
>         $(this).attr('checked', true);
>       }
>       else {
>         $(this).attr('checked', false);
>       }
>     }
>     else {
>       this.value = autocompleteValue[$name];
>     }
>   });
168c204,205
<     this.input.value = $(this.selected).data('autocompleteValue');
---
>   this.select(this.selected);  
>     //this.input.value = $().data('autocompleteValue')['key'];
218a256,261
>     var match = new Array();
>     if ((typeof matches[key]) == "object") {
>       match = matches[key];
>     }
>     match.key = key;
>     match.title = (matches[key].title?matches[key].title:matches[key]); 
220c263
<       .html($('<div></div>').html(matches[key]))
---
>       .html($('<div></div>').html(match.title))
224c267
<       .data('autocompleteValue', key)
---
>       .data('autocompleteValue', match)
