/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/
google.load("jquery", "1.3.1");
var searchQuery = null;
google.setOnLoadCallback(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();
	 });
});

function lookup(inputString) {
		if (searchQuery != null)
			searchQuery.abort();
	if(inputString.length == 0) {
		$('#suggestions').fadeOut(); // Hide the suggestions box
	} else {
		//$.post(" http://www.techmania.ch/SearchPopup.aspx", { queryString: "" + inputString + "" }, function (data)
	
	searchQuery = $.ajax({
		type: "POST",
		contentType: "application/json; charset=utf-8",
		url: "http://www.techmania.ch/SearchPopup.asmx/SearchQuery",
		data: "{'query': '" + inputString + "'}",
		dataType: "json",
		success: function (data)
		//$.post(" http://localhost/Techmania/SearchPopup.aspx", { queryString: "" + inputString + "" }, function (data)
	{ // Do an AJAX call
		$('#suggestions').fadeIn(); // Show the suggestions box

			/*if (data.indexOf("<form") >= 0) {
			$('#suggestions').html(data.substr(0, data.indexOf("<form"))); // Fill the suggestions box
		}
				else*/
			$('#suggestions').html(data);
		}
	});
	}
}