/*
AJAX functions for the autocomplete functionnality of the header search.
*/
//search() is actually unused..
function search(caller){
	$('aSearchCritere').value = caller.innerHTML;
}

function createObject() {
	var request_type;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_type = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else{
		request_type = new XMLHttpRequest();
	}
	return request_type;
}

var http = createObject();

/*
function autosuggest() {
	q = document.getElementById('aSearchCritere').value;
	// Set a random number to add to URL request
	nocache = Math.random();
	http.open('get', '/js/ajax_script/search_autocomplete.php?q='+q+'&nocache = '+nocache);
	http.onreadystatechange = autosuggestReply;
	http.send(null);
}
*/
function autosuggest(iUnivers) {
	q = document.getElementById('aSearchCritere').value;
	// Set a random number to add to URL request
	nocache = Math.random();
	http.open('get', '/js/ajax_script/search_autocomplete.php?q='+q+'&univers= '+iUnivers+'&nocache = '+nocache);
	http.onreadystatechange = autosuggestReply;
	http.send(null);
}
function autosuggestReply() {
if(http.readyState == 4){
	var response = http.responseText;
	e = document.getElementById('results');
	if(response!=""){
		e.innerHTML=response;
		/* pour faire apparaitre les suggetsions */
		e.style.display="block";
	}
	else{
		e.style.display="none";
	}
}
}