//<!--
$(document).ready(function()
{
	var $focused_search_textfield;
	
	$('.search_text,.physician_search_text').focus(function(event)
	{
		$focused_search_textfield = $(event.target);
	});
	
	$('.search_text').autocomplete( base_url +'search/get_autocomplete_cities', {
		autoFill: false,
		cacheLength:10,
		//dataType: 'json',
		delay: 10,
		//highlight: false,
		highlightItem: true,
		matchCase: false,
		matchContains: true,
		matchSubset: true,
		max: 30,
		minChars: 2,
		multiple: false,
		multipleSeparator: ', ',
		mustMatch: false,
		selectFirst: false,
		scroll: true,
		scrollHeight: 100,
		width: 0,
		extraParams: { 'type': function() { return $focused_search_textfield.parents('form').find('input[name=type]').val(); } },//{ country: function() { return $("#country").val(); } }
		formatItem: function(data, i, n, value) {
			return data[0];// + " (<strong>id: " + data[1] + "</strong>)";
		}, 
		formatResult: function(data, value) {
			return data[0].replace(/(<.+?>)/gi, '');
		}/*,
		formatMatch: function(data, value) {
			return data[0].replace(/(, )/gi, '');
		}*/
	});

	$('.physician_search_text').autocomplete( base_url +'search/get_autocomplete_cities', {
		autoFill: false,
		cacheLength:10,
		//dataType: 'json',
		delay: 10,
		//highlight: false,
		highlightItem: true,
		matchCase: false,
		matchContains: true,
		matchSubset: true,
		max: 30,
		minChars: 2,
		multiple: false,
		multipleSeparator: ', ',
		mustMatch: false,
		selectFirst: false,
		scroll: true,
		scrollHeight: 100,
		width: 0,
		extraParams: { 'type': function() { return $focused_search_textfield.parents('form').find('input[name=type]').val(); } },//{ country: function() { return $("#country").val(); } }
		formatItem: function(data, i, n, value) {
			return data[0];// + " (<strong>id: " + data[1] + "</strong>)";
		}, 
		formatResult: function(data, value) {
			return data[0].replace(/(<.+?>)/gi, '');
		}/*,
		formatMatch: function(data, value) {
			return data[0].replace(/(, )/gi, '');
		}*/
	});
	
	/*
	$("#search_text").result(function(event, data, formatted) {
		if (data)
			$(this).parent().next().find("input").val(data[1]);
	});
	*/
});
//-->