var topSearchAutoCompleter = new Class.create(withImgAndGroupsAutoCompleter, {
	// переопределяю родительскую функцию
	// тут другой случай, всем @ рулит
	onResultClick: function(val, addInfo) {
		document.location.href = addInfo[3];
	},
	
	_populateResults: function(r) {
		var h = this.config.resultsHolder;

		matches = r;
		
		if (matches.size() < 1) {
			this.hideResults();
			return;
		}
		
		this.clearResultBox(h);
		
		typesData = {};
		typesLimits = {};
		
		matches.each(function(a) {
			var t = a[1][1];
			if (Object.isUndefined(typesData[t])) {
				typesData[t] = 0;
			}
			typesData[t]++;
		});
		
		var typeLimit = Math.floor(this.config.resultsLimit/Object.keys(typesData).size());
		
		/*var typesSizes = {};
		for (t in typesData) {
			typesSizes[typesData[t]] = t;
		}*/
		
		var ul = this.config.resultsHolder.down(this.config.listParent);
		resultsLimit = 0;

		matches.each(function(a, i) {
			if (resultsLimit >= this.config.resultsLimit) {
				throw $break;
			}
			
			var t = a[1][1];
			if (Object.isUndefined(typesLimits[t])) {
				typesLimits[t] = 0;
			}
			
			if (++typesLimits[t] <= typeLimit) {
				this.appendVariant(a, ul);
				resultsLimit++;
			}
		}, this);
		
		this.showResults();
	}
});


