function findCid(texto) {
	var ajax = openAjax();
	var recipiente = gE('boxList');
	
	if(recipiente.style.display == 'block'){
		if(window.event.keyCode == 40){
			gE("lista").focus();
			gE("lista").selectedIndex = 0;
		}	
	}
	
	if(!texto){
		recipiente.innerHTML = "";
		recipiente.style.display = "none";
	}else{
		recipiente.style.display = "block";
	}
	ajax.open('GET', '/bib_ajax/busca.php?function=1&texto='+texto, true); 
	ajax.onreadystatechange = function() {
		if (ajax.readyState == 4) {
			if (ajax.status == 200) {
				document.body.style.cursor = 'default';
				recipiente.innerHTML = ajax.responseText;
			}
		}
	}
	ajax.send(null);
}

/*
function pesquisar(buscar,e) { 
    var whichCode;
    if (!e) var e = window.event;
    if (e.keyCode) whichCode = e.keyCode;
    else if (e.which) whichCode = e.which;
    var key = ''
    key = String.fromCharCode(whichCode);  // Pega o valor da tecla a partir do seu código.
    if (whichCode == 40 || whichCode == 38) { //Se a tecla pressionada foi seta para baixo.
        if (document.getElementById("boxList").style.display == "block") { 
            document.getElementById("lista").focus(); //Passa o foco para a listbox.
            document.getElementById("lista").selectedIndex = 0; 
        }
    } else { //Se outra tecla qualquer foi pressionada
        window.clearTimeout(settimeId); //Limpa qualquer chamada agendada anteriormente.
        if (buscar.length > 0) { //Se tem alguma string para ser procurada.
            settimeId = window.setTimeout("startHttpReq('"+buscar+"')",2000); 
        } else { //Caso contrário esconde a listbox.
            document.getElementById("listboxresult").style.visibility="hidden";
            document.getElementById("listboxresult").disabled = true; //desabilita a listbox.
        }
    }
}
*/
