//John-David Dalton's blur bug fix.
Ajax.Autocompleter.prototype.onBlur = function(event){
	Position.prepare();
	var withinUpdate = Position.withinIncludingScrolloffsets(this.update, Event.pointerX(event), Event.pointerY(event) );
	
	//don't hide the results if user blurred to the results panel (allows user to scroll results list)
	if(!withinUpdate){
		//needed to make click events working
		setTimeout(this.hide.bind(this), 250);
		this.hasFocus = false;
		this.active = false;
	}
};
Ajax.Autocompleter.prototype.startIndicator = function(event){
	 $(this.element).addClassName('ajaxIndicator');
};
Ajax.Autocompleter.prototype.stopIndicator = function(event){
	$(this.element).removeClassName('ajaxIndicator');
};
Event.observe(window, 'load', function(){
	new Ajax.Autocompleter(
		"FaceplateSearch", 
		"FaceplateSearchResults", 
		"/_includes/faceplate_search.php", 
		{
			minChars: 2,
			afterUpdateElement: function(inputEl, liEl){				
//				window.location = '/faceplate-profile/'+liEl.id+'.html';
 window.location = '/faceplate-profile/'+liEl.id+'/'+liEl.innerHTML.stripTags().replace(/^\s+|\s+$/g, '').replace(/\s/g, '-')+'.html';
			}
		}
	);
});
