$(document).ready(function(){
	function autocomplete(func, where, from){
		var str = '/xajax/xajax.php?func=' + func + '&from=' + $('#' + from + ' option:selected').val() + '&responseType=html';
		$('#' + where).autocomplete(str);
		if (from) $('#' + from).change(function(){
			$('#' + where).autocomplete(str);
		});
	}
	autocomplete('searchsuggest_with_country', 'city', false);
	$('input[limit]').limit();
	$('textarea[limit]').limit();
	
	$('#showQa').click(function(){
		$('#formQa').show();
		return false;
	});
	$('#hideQa').click(function(){
		$('#formQa').hide();
		return false;
	});
	
	$('#complaint a').click(function(){
		$.post("/xajax/xajax.php", {
			func: "sendComplaintQA",
			item: $('input[name="question_id"]').attr('value'),
			action: $(this).text(),
			span: 1
		}, function(xml){
			$('#statusComplaint').html('<ul class="message status"><li>Спасибо. Ваше сообщение отправлено!</li></ul>');
		}, "xml");
		$('#complaint').hide();
		;
		return false;
	});
});
