/*
* Author:      Marco Kuiper (http://www.marcofolio.net/)
*/

$j(document).ready(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+
		$j('#suggestions_wish, #suggestions_friend').css(cssObj);
		
		// Fade out the suggestions box when not active
		 $j("input").blur(function(){
			$j('#suggestions_wish, #suggestions_friend').fadeOut();
		 });
});


	


function lookup(inputString, method) {
	var suggestions = method=='searchWish' ? 'suggestions_wish' : 'suggestions_friend';	
	if(inputString.length == 0) {
		$j('#'+suggestions).fadeOut(); // Hide the suggestions box
	} else {
		$j.post("/jelion/units/search/_ajax_list.php?metod="+method, {q: ""+inputString+""}, function(data) { // Do an AJAX call
		// alert(data);
			// Only if have search result
			// дата уже возращает содержимое p
			if( $j(data).html() ){
				$j('#'+suggestions).show(); // Show the suggestions box
				$j('#'+suggestions).html(data); // Fill the suggestions box
			} else {
				$j('#'+suggestions).fadeOut();
			}
		});
	}
}
