function getData(dataSource)
{
	var XMLHttpRequestObject = false;

	// create the XMLHttpObject
	if (window.XMLHttpRequest) 
	{
		XMLHttpRequestObject = new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) 
	{
		XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp");
	}
	
	// retrieve the keywords 
	// from the text file
	
	if(XMLHttpRequestObject) 
	{
		XMLHttpRequestObject.open("GET", dataSource);
		
		XMLHttpRequestObject.onreadystatechange = function()
		{
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) 
			{
				// create an array with the results
				var result=XMLHttpRequestObject.responseText.split(",");
				
				// display menu
				showMenu(result);				
				
				// clear the Object
				delete XMLHttpRequestObject;
				XMLHttpRequestObject = null;
				
			}
		}
		XMLHttpRequestObject.send(null);
	}
}

function showMenu(array_result)
{
	// this function displays the 
	// menu items for selection
	
	var table_data = ''; // stores the data displayed by table
				
	// place these on attached code
	if((array_result.length>0)&&array_result[0]!='undefined')
	{
		// start formatting
		table_data += "<table id=toolBar border=0 width=267>";
		
		for(var loopIndex=0;loopIndex<array_result.length;loopIndex++)
			table_data += "<tr><td><a href='#' onclick=\"updateSearchBox('"+array_result[loopIndex]+"');return false;\" id=menu>"+array_result[loopIndex]+"</a></td></tr>";
		
		// finish formatting
		table_data += "</table>";
		
		// attach to the div
		attachDetails(table_data);
	}		
}

function attachDetails(table_data)
{
	// this function attaches
	// the help assistant 
	// depending on browser
	// type
	
	var search_text = document.getElementById('search_text');	
	var optionsRecord = document.getElementById('optionsRecord');
	
	optionsRecord.style.visibility = "hidden";
	optionsRecord.innerHTML = table_data;
	optionsRecord.style.visibility = "visible";
}

function getSuggest(keyEvent)
{
	// this function gets the data
	// about the KeyEvent 
	// that occured
	keyEvent = (keyEvent) ? keyEvent: window.event;
	input = (keyEvent.target) ? keyEvent.target : keyEvent.srcElement;
	if (keyEvent.type == "keyup") 
	{
		if (!input.value=='') 
			getData("get_suggest.php?qu=" +input.value);
		else 
		{
			var optionsRecord = document.getElementById("optionsRecord");
			optionsRecord.innerHTML = "";
		}
	}
}
	
function updateSearchBox(data)
{
	// this function simply 
	// puts the selected 
	// data into the textbox
	
	var search_text = document.getElementById('search_text');
	var optionsRecord = document.getElementById('optionsRecord');
	
	search_text.value = data;
	optionsRecord.style.visibility = 'hidden';
}

function closeHelp()
{
	// this function closes 
	// the search suggest
	// when the <BODY> tag is 
	// clicked
	var optionsRecord = document.getElementById('optionsRecord');
	optionsRecord.style.visibility = 'hidden';
}


