$(document).ready(function(){
	create_autocomplete()
});

create_autocomplete = function()
{
	// search_terms.php has the data which populates the list.

	$("#searchPanelText").autocomplete('/searchterm.ashx?ismed=true', {
		max:10,
		autoFill:false,
		matchContains:false,
		selectFirst:false,
		minChars:0,
		width:236,
		matchContains: 'word',
		scrollHeight:500,
		
		formatItem: function(data, i, n, value) {
			return '<a href="/search-results.aspx?term='+ data+'">' + data + '</a>'; //this is the data as listed in the dropdown, can be styled with extra characters/code
		},
		
		formatResult: function(data, value){
			return data; //this is the actual data that gets sent to the form field, you can format it as needed
		}
		
	});
	
	$("#searchPanelText").result(function(){$('#searchPanelForm').submit()}); //submits the form when an item from the list is chosen
	
	
	
	$("#search").autocomplete('/searchterm.ashx', {
		max:10,
		autoFill:false,
		matchContains:false,
		selectFirst:false,
		minChars:0,
		width:236,
		matchContains: 'word',
		scrollHeight:500,
		
		formatItem: function(data, i, n, value) {
			return '<a href="/search-results.aspx?term='+ data+'">' + data + '</a>'; //this is the data as listed in the dropdown, can be styled with extra characters/code
		},
		
		formatResult: function(data, value){
			return data; //this is the actual data that gets sent to the form field, you can format it as needed
		}
		
	});
	
	$("#searchPanelText").result(function(){$('#searchPanelForm').submit()}); //submits the form when an item from the list is chosen
    
    $("#searchDeptsText").autocomplete('/clinics_search_term.aspx', {
		max:10,
		autoFill:false,
		matchContains:false,
		selectFirst:false,
		minChars:0,
		width:236,
		matchContains: 'word',
		scrollHeight:500,
		
		formatItem: function(data, i, n, value) {
			return '' + data; //this is the data as listed in the dropdown, can be styled with extra characters/code
		},
		
		formatResult: function(data, value){
			return data; //this is the actual data that gets sent to the form field, you can format it as needed
		}
	});
	

}

