
$( // document ).ready( 
	function() {
	
	$( "input.autocomplete" ).each( function() { 	
		
		// textboxes must have a class name of 'autocomplete' and a rel="{type}" attribute
		
		var acType = $( this ).attr( "rel" ) || this.id;
		/**/
		$( this ).autocomplete({
			source: "/search_autocomplete.cfm?type=" + acType,
			open: function(event, ui) { // boldens matched text
				$( "li.ui-menu-item a" ).each( function() {
					var searchRegEx = event.target.value.replace(/&/g,"&amp;"); // fixes ampersand matching problem
					searchRegEx = new RegExp("(" + searchRegEx + ")", "gi");
					$(this).html( $(this).html().replace(searchRegEx, "<strong>$1</strong>") );
				})
			},
			minLength:	2
		});
		
	});
});
