function searchSetup(textbox)
{
/*
	var Out=null;
	var searchFunc=
		function (text,wildCard,caseSens,notCharacter)
		{
			if(typeof Out!='null')
				window.clearTimeout(Out);
			Out=window.setTimeout(function()
				{
				Out=null;
				jQuery.get(
					'asearch.php',
					{q:text},
					function (ans){
						var dom=textbox.get(0)
						jQuery.data(dom,'jsonSuggest').
							buildResults.call(dom,ans);
					},
					'json'
					);
				},800);

			return [{id:0,text:'Loading'}];
		};
	textbox.val('');
	textbox.jsonSuggest(
		searchFunc,
		{
			minCharacters:3,
			maxResults:20,
			ajaxResults:true,
			fixWidth:208,
			onSelect:function(item)
			{
//				$('form#relocate').attr('action',item.url);
//				$('form#relocate').submit();
				document.location=item.url;
			}
		}
		);
*/
	function liFormat (row, i, num) {
		switch(row[1])
		{
		case 'noresult':
			var result = '<div class="link">'+row[2]+'<br></div>';
			break;
		case 'eventimage':
			var result = '<div class="image"><a href="' + row[3] + '" title="' + row[0] + '"><img src="' + row[5] + '" alt="' + row[0] + '" width="50" height="38"></a></div><div class="link"><a href="' + row[3] + '">' + row[0] + '</a><br>' + row[4] + '</div>';
		break;
//			var result = '<div class="link"><a href="' + row[3] + '">' + row[2] + '</a><br>' + row[2] + '</div>';
		case 'placefirst':
			var result = '<div class="link first"><a href="' + row[3] + '">' + row[0] + '</a><br></div>';
			break;
		default:
			var result = '<div class="link"><a href="' + row[3] + '">' + row[0] + '</a><br>'+ row[4] + '</div>';
		}
		return result;
	}
	function selectItem(li) {
		if( li == null ) var sValue = 'А ничего не выбрано!';
		if( !!li.extra ) var sValue = li.extra[1];
		else var sValue = li.selectValue;
		//alert('Выбрана запись с ID: ' + sValue);
		return true;
	}

	function onHide(res)
	{
		var o=$('.uploadPhotosGrayBg');
		o.hide();
	}
	function onShow(res)
	{
		var o=$('.uploadPhotosGrayBg');
		if(o.length==0)
		{
			o=$('<div class="uploadPhotosGrayBg"></div>');
			$('body').append(o);
			o.css('opacity',50/100);
		}
		res.css('z-index',parseInt(o.css('z-index')) +1);
		o.show();
	}
	textbox.val('');
	textbox.autocomplete("/asearch.php", {
	onHide:onHide,onShow:onShow,

	width:250,
	delay:120,
	minChars:3,
	matchSubset:1,
	autoFill:false,
	matchContains:1,
	cacheLength:10,
	selectFirst:true,
	formatItem:liFormat,
	maxItemsToShow:10,
	onItemSelect:selectItem,
	notFound:"|noresult|Ничего не найдено",
	ignoreEnter:true
	});
}


