function getXMLHttpRequest() {
    var xhr = null;

    if (window.XMLHttpRequest || window.ActiveXObject) {
            if (window.ActiveXObject) {
                    try {
                            xhr = new ActiveXObject("Msxml2.XMLHTTP");
                    } catch(e) {
                            xhr = new ActiveXObject("Microsoft.XMLHTTP");
                    }
            } else {
                    xhr = new XMLHttpRequest();
            }
    } else {
            alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
            return null;
    }

    return xhr;
}

function lookup(inputString) 
{
	if(inputString.length == 0) 
	{
		// Hide the suggestion box.
		document.getElementById('suggestions').style.display='none';
	} 
	else 
	{
		var xhr = getXMLHttpRequest();
		xhr.open("POST", "index.php?c=index&a=ajaxAutoSearchVille&nohtml", true);
		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xhr.send("queryString="+inputString);

		xhr.onreadystatechange = function () {
			if(xhr.readyState == 4)
			{	
				if(xhr.responseText.lenght != '')
				{
					document.getElementById('suggestions').style.display='block'; 
					document.getElementById('autoSuggestionsList').innerHTML = xhr.responseText;
				}
			}
		}
	}
} // lookup
	
function fill() {
	//document.getElementById('inputString').value = (thisValue);
	setTimeout("document.getElementById('suggestions').style.display='none';", 200);
}
