google.setOnLoadCallback(function(){
	// Fade out the suggestions box when not active
	$("input").blur(function(){
		$('#suggestions').fadeOut();
		$('#authorsuggestions').fadeOut();
	});
});


function lookup(inputString) {
   if(inputString.length == 0) {
      $('#suggestions').fadeOut(); // Hide the suggestions box
   } else if(inputString.length >= 3) {
      $.post("/search/", {q: ""+inputString+""}, function(data) { // Do an AJAX call
         $('#suggestions').fadeIn(); // Show the suggestions box
         $('#suggestions').html(data); // Fill the suggestions box
      });
   }
}


function lookupAuthor(inputString) {
   if(inputString.length == 0) {
      $('#authorsuggestions').fadeOut(); // Hide the suggestions box
   } else if(inputString.length >= 2) {
      $.post("/downloads/authorsearch.php", {q: ""+inputString+""}, function(data) { // Do an AJAX call
         $('#authorsuggestions').fadeIn(); // Show the suggestions box
         $('#authorsuggestions').html(data); // Fill the suggestions box
      });
   }
}