﻿window.addEvent('domready', function(){ 

    autoControls = [
                     'ctl00_MainContentPlaceHolder_memberDetails_textBoxClassification1',   
                     'ctl00_MainContentPlaceHolder_memberDetails_textBoxClassification2',
                     'ctl00_MainContentPlaceHolder_memberDetails_textBoxClassification3'
                   ];
     	           
    for(elIter = 0; elIter < autoControls.length; elIter++)
    {
        var el = $(autoControls[elIter]);
                   
        var completer1 = new Autocompleter.Local(el, tokens, 
        {
            'selectFirst': false,
            'selectMode': 'pick',
            'minLength' : 3,
            'maxChoices': 10,
            'width': 422,
            'delay': 100,
            'filterTokens': function() 
            {
                var regex = new RegExp(this.queryValue.escapeRegExp(), 'i');
                return this.tokens.filter(function(token){
	                return (regex.test(token[0]));
                });
            },
            'injectChoice': function(choice) 
            {                  		                    		                
                var el = new Element
                                (
                                    'li',			                                    
                                    {
                                        'html': this.markQueryValue(choice[0])			                    
                                    }
                                );			                               
	            
                el.inputValue = choice[0];
                this.addChoiceEvents(el).injectInside(this.choices);
            }
        });
        
        // If the browser is not IE set the 
        // ul.autocompleter-choices:margin to Top:1px Left:-2px
        // so it renders correctly in FF.
        if(Browser.Engine.name != 'trident')
        {    
            completer1.choices.style.margin = '1px 0px 0px 0px';
        }		            
    }
});
