// Get the HTTP Object
function getHTTPObject(){
	if(window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) return new XMLHttpRequest();
	else {
		alert("Your browser does not support AJAX");
		return null;	
	}	
}


// Change the value of the outputText field
function setFilterOutput(){
	if(httpObject.readyState == 4){
		if(httpObject.responseText.length > 0) { // Something was found
			document.getElementById('searchBoxOutput').innerHTML = httpObject.responseText;
		}else if(document.getElementById('searchBoxOutput').value.length > 0){
			document.getElementById('searchBoxOutput').innerHTML = "Geen resultaat gevonden!";
		}else{ // Geen invoer
			document.getElementById('searchBoxOutput').innerHTML = "";
		}
	}
}

function doSearch(){
	httpObject = getHTTPObject();
	if(httpObject != null){
		
		httpObject.onreadystatechange = function () {
			if(httpObject.readyState == 4){
				if(httpObject.responseText.length > 0) { // Something was found
					document.getElementById('searchBoxOutput').innerHTML = httpObject.responseText;
					document.getElementById('searchBoxOutput').style.display = "block";
					
				}else if(document.getElementById('searchBoxInput').value.length > 0){
					document.getElementById('searchBoxOutput').innerHTML = "Geen resultaat gevonden!";
					document.getElementById('searchBoxOutput').style.display = "block";
				}else{ // Geen invoer
					document.getElementById('searchBoxOutput').innerHTML = "";
					document.getElementById('searchBoxOutput').style.display = "none";
				}
			}
		};
		httpObject.open("GET","http://www.lupuspatientengroep.nl/new/ajax/doSearch.php?q="+document.getElementById('searchBoxInput').value,true);
		httpObject.send(null);
			
	}
}