$(document).ready(function() { 
    $("#autopoisk-no-js").show();

    var timeoutID = false;

    $("#inputString").keyup(function() { 
        lookup(this.value); 
        if(timeoutID) { 
            clearTimeout(timeoutID); 
        } 
		var thisval = this.value;
        timeoutID = setTimeout(function() { 
            pageTracker._trackPageview('/?gsearch=' + thisval);
        }, 1000); 
    }); 
	});

function lookup(inputString) {
    if(inputString.length == 0) {
        $("#suggestions").hide();
    } else {
        $.post("/rpc.php", {queryString:inputString}, function(data){
            if(data.length >0) {
                $("#suggestions").show();
                $("#autoSuggestionsList").html(data);
            }
        });
    }
}
