$hintHandler	= false;
$hintDelay		= 200;

$(document).ready(function() {
	$('#search').keyup(function() {
		if ($('#search').attr('value').length > 2) {
			if ($hintHandler) { clearTimeout($hintHandler); }
			$hintHandler	= setTimeout("makeSearch()", $hintDelay);
		}
	});

	$('body').click(function(event) {
		if ((event.target.className != 'line') && (event.target.className != 'search_results')) {
			$('#search_ajax').css('display','none');
		}
	});

	$(document).keypress(function(event) {
		if (event.keyCode == 27) {
			$('#search_ajax').css('display','none');
		}
	});
});

function makeSearch() {
	jQuery.get('/in_site/tools/ajax/search.php', $('#fSearch').serialize(), function(data) {
		if (data) {
			$('#search_ajax').html(data);
			$('#search_ajax').css('display', 'block');
		} else {
			$('#search_ajax').css('display', 'none');
		}
	}, 'html');

}
