//XMLhttp variable will hold the XMLHttpRequest object
var xmlhttp = false;
        
// If the user is using Mozilla/Firefox/Safari/etc
if (window.XMLHttpRequest) {
        //Intiate the object
        xmlhttp = new XMLHttpRequest();
        //Set the mime type
        xmlhttp.overrideMimeType('text/xml');
}
// If the user is using IE
else if (window.ActiveXObject) {
        //Intiate the object
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

function preSearchA() 
{
        //Put the form data into a variable
	var theQuery = document.getElementById('queryA').value  ;
		
        //If the form data is *not* blank, query the DB and return the results
	if(theQuery !== "") 
	{	
                //This sets a variable with the URL (and query strings) to our PHP script
		var url = 'livesearch.php?q=' + theQuery;
                //Open the URL above "asynchronously" (that's what the "true" is for) using the GET method
		xmlhttp.open('GET', url, true);
                //Check that the PHP script has finished sending us the result
		xmlhttp.onreadystatechange = function() 
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
                                //Replace the content of the "result" DIV with the result returned by the PHP script
				document.getElementById('result').innerHTML = xmlhttp.responseText + ' ';
			} 
			else 
			{
                 //If the PHP script fails to send a response, or sends back an error, display a simple user-friendly notification
				document.getElementById('result').innerHTML = 'Searching...';
			}
		};
		xmlhttp.send(null);  
	}
}
function preSearchB() 
{
        //Put the form data into a variable
	var theQuery = document.getElementById('queryB').value  ;
		
        //If the form data is *not* blank, query the DB and return the results
	if(theQuery !== "") 
	{	
                //This sets a variable with the URL (and query strings) to our PHP script
		var url = 'livesearch.php?q=' + theQuery;
                //Open the URL above "asynchronously" (that's what the "true" is for) using the GET method
		xmlhttp.open('GET', url, true);
                //Check that the PHP script has finished sending us the result
		xmlhttp.onreadystatechange = function() 
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
                                //Replace the content of the "result" DIV with the result returned by the PHP script
				document.getElementById('result').innerHTML = xmlhttp.responseText + ' ';
			} 
			else 
			{
                 //If the PHP script fails to send a response, or sends back an error, display a simple user-friendly notification
				document.getElementById('result').innerHTML = 'Searching...';
			}
		};
		xmlhttp.send(null);  
	}
}
function preSearchC() 
{
        //Put the form data into a variable
	var theQuery = document.getElementById('queryC').value  ;
		
        //If the form data is *not* blank, query the DB and return the results
	if(theQuery !== "") 
	{	
                //This sets a variable with the URL (and query strings) to our PHP script
		var url = 'livesearch.php?q=' + theQuery;
                //Open the URL above "asynchronously" (that's what the "true" is for) using the GET method
		xmlhttp.open('GET', url, true);
                //Check that the PHP script has finished sending us the result
		xmlhttp.onreadystatechange = function() 
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
                                //Replace the content of the "result" DIV with the result returned by the PHP script
				document.getElementById('result').innerHTML = xmlhttp.responseText + ' ';
			} 
			else 
			{
                 //If the PHP script fails to send a response, or sends back an error, display a simple user-friendly notification
				document.getElementById('result').innerHTML = 'Searching...';
			}
		};
		xmlhttp.send(null);  
	}
}
function preSearchD() 
{
        //Put the form data into a variable
	var theQuery = document.getElementById('queryD').value  ;
		
        //If the form data is *not* blank, query the DB and return the results
	if(theQuery !== "") 
	{	
                //This sets a variable with the URL (and query strings) to our PHP script
		var url = 'livesearch.php?q=' + theQuery;
                //Open the URL above "asynchronously" (that's what the "true" is for) using the GET method
		xmlhttp.open('GET', url, true);
                //Check that the PHP script has finished sending us the result
		xmlhttp.onreadystatechange = function() 
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
                                //Replace the content of the "result" DIV with the result returned by the PHP script
				document.getElementById('result').innerHTML = xmlhttp.responseText + ' ';
			} 
			else 
			{
                 //If the PHP script fails to send a response, or sends back an error, display a simple user-friendly notification
				document.getElementById('result').innerHTML = 'Searching...';
			}
		};
		xmlhttp.send(null);  
	}
}
function preSearchE() 
{
        //Put the form data into a variable
	var theQuery = document.getElementById('queryE').value  ;
		
        //If the form data is *not* blank, query the DB and return the results
	if(theQuery !== "") 
	{	
                //This sets a variable with the URL (and query strings) to our PHP script
		var url = 'livesearch.php?q=' + theQuery;
                //Open the URL above "asynchronously" (that's what the "true" is for) using the GET method
		xmlhttp.open('GET', url, true);
                //Check that the PHP script has finished sending us the result
		xmlhttp.onreadystatechange = function() 
		{
			if(xmlhttp.readyState == 4 && xmlhttp.status == 200) 
			{
                                //Replace the content of the "result" DIV with the result returned by the PHP script
				document.getElementById('result').innerHTML = xmlhttp.responseText + ' ';
			} 
			else 
			{
                 //If the PHP script fails to send a response, or sends back an error, display a simple user-friendly notification
				document.getElementById('result').innerHTML = 'Searching...';
			}
		};
		xmlhttp.send(null);  
	}
}
