var NPRosterSearchUI = Class.create({ isDebug: false, initialize: function(contextPath) { this.debug('initialize('+contextPath+')'); this.contextPath = contextPath; var self = this; var ac = new Ajax.Autocompleter( 'searchTerms', 'searchResults', contextPath+'/nodec/performSearch.action', {afterUpdateElement: function(textInput, li) { self.elementSelected(textInput, li); }, minChars: 3, frequency: 0.2} ); this.searchTermsInput = $('searchTerms'); if(this.searchTermsInput) { this.searchTermsInput.focus(); } }, debug: function(val) { if(this.isDebug == true && $('debug_div')) { $('debug_div').innerHTML += 'debug: ' + val + '
'; } }, elementSelected: function(textInput, li) { this.debug('elementSelected(' + textInput + ', ' + li.id + ')'); var identifier = li.id; var entityType = li.getAttribute('entityType'); var entityId = li.getAttribute('entityId'); this.debug("entityType = " + entityType + ", entityId = " + entityId); if(entityType == 'pers') { this.debug('pers'); location.href = this.contextPath + '/default/member.action?memberId=' + entityId; //location.href = "http://www.google.com/"; } else if(entityType == 'cust') { this.debug('cust'); location.href = this.contextPath + '/default/customer.action?customerId=' + entityId; } else if(entityType == 'comm') { this.debug('comm'); location.href = this.contextPath + '/default/committee.action?committeeId=' + entityId; } } });