document.observe("dom:loaded", function() {

	{ // GET запрос
		var val = $$('.pages_click');
		for (var i = 0; i < val.length; i++) {
			val[i].observe('click', function(event) {
				$('search_form').submit();
			});
		}
	}
	
	if ($('show_short_true_click')) {
		$('show_short_true_click').observe('click', function() {
			$('show_short').setValue(1);
			$('search_form').submit();
		});
	}

	if ($('show_short_false_click')) {
		$('show_short_false_click').observe('click', function() {
			$('show_short').setValue(0);
			$('search_form').submit();
		});
	}
	
	if ($('mes_click')) {
		$('mes_click').observe('click', function() {
			if ($('mes_id').getValue() == '') {
				alert('Введите номер вопроса');
				return;
			}
			
			var href = '/question/id/' + $('mes_id').getValue();
			if ($('mes_id2').getValue()) href = href + '#' + $('mes_id2').getValue();
			if ($('mes_id3').getValue()) href = href + '.' + $('mes_id3').getValue();
			
			location.href = href;
		});
	}
	
	$('by_user').observe('change', function() {
		if ($('by_user').getValue()) {
			$('user_id').enable();
			if ($('user_id').getValue() != -1) $('by_comment').enable();
			else $('by_comment').disable();
		} else $('user_id').disable();
	});

	$('user_id').observe('change', function() {
		if ($('user_id').getValue() != -1) {
			$('by_comment').enable();
		} else {
			$('by_comment').disable();
		}
	});

});

