$(function()
{
	// Safely inject CSS3 and give the search results a shadow
	var cssObj = { 'box-shadow' : '#888 5px 10px 10px', // Added when CSS3 is standard
		'-webkit-box-shadow' : '#888 5px 10px 10px', // Safari
		'-moz-box-shadow' : '#888 5px 10px 10px'}; // Firefox 3.5+
	$("#suggestions").css(cssObj);
	
	// Fade out the suggestions box when not active
	 $("input").blur(function(){
	 	$('#suggestions').fadeOut();
		$('#search-indicator').hide();
	 });
});

var nr = 0;

function lookup(inputString, inputRegion) {
	nr++;
	lookupCore(inputString, inputRegion, nr);
}

function lookupCore(inputString, inputRegion, myNr) {
	$('#search-indicator').show();
	$.post("search/ajaxSearch", {queryString: ""+inputString+"", regionId: ""+inputRegion+""}, function(data) { // Do an AJAX call
		if (myNr == nr) {
			$('#search-indicator').hide();
			$('#suggestions').fadeIn(); // Show the suggestions box
			$('#suggestions #searchresults').html(data); // Fill the suggestions box
		}
	});
}
