/* ---------------------------- */
/* XMLHTTPRequest Enable 		*/
/* ---------------------------- */
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();

/* -------------------------- */
/* SEARCH					 */
/* -------------------------- */
function autosuggest() {
q = document.getElementById('search_q').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'lib/search.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);
}
function autosuggest_adv(kolegia) {
q = document.getElementById('search_q').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'lib/search_adv.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);
}
function autosuggest_tylkoven() {
q = document.getElementById('search_q').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'lib/search_tylkoven.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);
}
function autosuggest_pcterms() {
q = document.getElementById('search_q').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'lib/search_pcterms.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);
}
function autosuggest_polytechnical() {
q = document.getElementById('search_q').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'lib/search_polytechnical.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);
}
function autosuggest_sinonimen() {
q = document.getElementById('search_q').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'lib/search_sinonimen.php?q='+q+'&nocache = '+nocache);
http.onreadystatechange = autosuggestReply;
http.send(null);
}
function autosuggest_dialect() {
q = document.getElementById('search_q').value;
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'lib/search_dialect.php?q='+q+'&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;
		e.style.display="block";
	} else {
		e.style.display="none";
	}
}
}
