function lookup(inputString) {
    if(inputString.length < 3) {
        $('#suggestions').hide();
    } else {
    	var cur = GET('cur');
    	if(cur == 'undefined'){
    		cur = '0';	
    	}
        $.post("/modules/faie_search/autocomplete2.php", {queryString: ""+inputString+"", cCode: ""+cur+""}, function(data){
            if(data.length >0) {
                $('#suggestions').show();
                $('#autoSuggestionsList').html(data);
            }
        });
    }
}

HTTP_GET_VARS=new Array();
strGET=document.location.search.substr(1,document.location.search.length);
if(strGET!='')
    {
    gArr=strGET.split('&');
    for(i=0;i<gArr.length;++i)
        {
        v='';vArr=gArr[i].split('=');
        if(vArr.length>1){v=vArr[1];}
        HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);
        }
    }
 
function GET(v){
	if(!HTTP_GET_VARS[v]){return 'undefined';}
	return HTTP_GET_VARS[v];
}

jQuery(document).ready(function($){
		//insert the DOM of the answer
		suggestionsDom = '<div class="suggestionsBox" id="suggestions" style="display: none;"><div class="suggestionList" id="autoSuggestionsList"></div></div>';
		$('div#col1_content').append(suggestionsDom);
		//we dont need autocomplete
		$('input#f_search_param').attr('autocomplete','off');
		//lookup after onkeyup
		$('input#f_search_param').bind('keyup',function() {
			lookup(this.value);
			});
		$('body').bind('click',function() {
        	$('#suggestions').hide();
			});
});


