$().ready(function() {
	$("#searchInput").autocomplete("/jquery/autocomplete/suggestSearch.php", {
		width: 225,
//		multiple: true,
//		multipleSeparator: ", ",

		minChars:2,
		maxItemsToShow:10,
		loadingClass: "ac_loading",
		matchContains: true,
		formatItem: function(row, i, max) { // zformatuje nacteny zaznam
			return "" + row[1] + ""; // i + "/" + max + 
		},
		formatMatch: function(row, i, max) { // zformatuje prvni zvoleny zaznam
			return "" + row[1] + ""; // + " " + row[1];
		},
		formatResult: function(row, i, max) { // zformatuje hodnotu vracenou do inputu
			return "" + row[1] + "";
		},
		scroll: true,
		scrollHeight: 120
	}).result(function(event, row) {
		if(row[2]!=""){
			location.href = row[2];
		} else {
			location.href = "/?search="+encodeURI(row[1]);
		}
	});

});


$().ready(function() {
	$("#groupsInput").autocomplete("/jquery/autocomplete/suggestSearch.php?uGroup=user_groups", {
		width: 225,
//		multiple: true,
//		multipleSeparator: ", ",

		minChars:2,
		maxItemsToShow:10,
		loadingClass: "ac_loading",
		matchContains: true,
		formatItem: function(row, i, max) { // zformatuje nacteny zaznam
			return "" + row[0] + ""; // i + "/" + max + 
		},
		formatMatch: function(row, i, max) { // zformatuje prvni zvoleny zaznam
			return "" + row[0] + ""; // + " " + row[1];
		},
		formatResult: function(row, i, max) { // zformatuje hodnotu vracenou do inputu
			return "" + row[0] + "";
		},
		scroll: true,
		scrollHeight: 120
	}).result(function(event, row) {
		location.href = row[2];
	});

});
