/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/
//google.load("jquery", "1.3.1");
//google.setOnLoadCallback(function()
$(function()
{
	// Safely inject CSS3 and give the search results a shadow
	var cssObj = { 'box-shadow' : '#000 1px 1px 4px', // Added when CSS3 is standard
		'-webkit-box-shadow' : '#000 1px 1px 4px', // Safari
		'-moz-box-shadow' : '#000 1px 1px 4px'}; // Firefox 3.5+
	$("#suggestions").css(cssObj);
	
	// Fade out the suggestions box when not active
	 $("input").blur(function(){
	 	$('#suggestions').fadeOut();
	 });
});

function lookup(inputString) {
	if(inputString.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	}
	else
	{
		if(which_search == 'editorials')
		{
			$.post("functions/rpe.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
				$('#suggestions').fadeIn(); // Show the suggestions box
				$('#suggestions').html(data); // Fill the suggestions box
			});
			$("#search_form").attr("action","search_editorial_archive_results.php");
		}
		else
		{
			$.post("functions/rpc.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
				$('#suggestions').fadeIn(); // Show the suggestions box
				$('#suggestions').html(data); // Fill the suggestions box
			});
			$("#search_form").attr("action","search_comics_archive_results.php");
		}
	}
}

function click_submit_search()
{
	clear_searchbox();
	document.search_form.submit();
}

function clear_searchbox()
{
	var search_phrase_val = $('#inputString').val();
	$('#search_phrase').val(search_phrase_val);
	$('#inputString').val('');
}