var dataArea = '';
var dataUrl = '';
function setArea(area,url){
	dataArea = area;
	dataUrl	 = url;
	startRequestLibonline();
	handleStateChangeLibonline();
}
function createXMLHttpRequestLibonline() {
	// for IE
	if (window.ActiveXObject) 
	{
	xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	// for other browsers
	else if (window.XMLHttpRequest) 
	{
	xmlHttp = new XMLHttpRequest();
	}
}

// Ajax: startRequest
function startRequestLibonline() {
	createXMLHttpRequestLibonline();
	xmlHttp.onreadystatechange = handleStateChangeLibonline;
	xmlHttp.open("GET",dataUrl	, true);
	xmlHttp.send(null);
}

// Ajax: handleStateChange
function handleStateChangeLibonline() {
	
	if(xmlHttp.readyState == 4) {
		if(xmlHttp.status == 200) {
			
		document.getElementById(dataArea).innerHTML = '' + xmlHttp.responseText + '';
	   }
	}
	else {
	document.getElementById(dataArea).innerHTML = "<li> Now Loading !! </li> ";
	}
}

function fill(thisValue) {
		document.getElementById('searchTxt').value = thisValue;
		document.getElementById('suggestions').style.display = 'none'
}
function searchFunc() {
	var inputString = document.getElementById('searchTxt').value;
	var filter = document.getElementById('filter').selectedIndex+1;
	
	inputString = encodeURIComponent(inputString);
	
	if(inputString == '') {
			// Hide the suggestion box.
			document.getElementById('suggestions').style.display = 'none'; 
	}
	else {
		document.getElementById('suggestions').style.display = 'block'; 
		var url = "index2.php?option=com_libonline&task=modulesearch&queryString="+inputString+"&filter="+filter;
	
		setArea('autoSuggestionsList',url);
		//setTimeout(hide(), 12000);
	}
} // lookup
function libonlineSearch(){
	var inputString = document.getElementById('searchTxt').value;
	var filter = document.getElementById('filter').selectedIndex;
	
	//alert('<? echo JURI::base();?>index.php?option=com_libonline&filter='+filter+'&search='+inputString+'&Itemid=<? echo $itemid; ?>');
	window.location = 'index.php?option=com_libonline&filter='+filter+'&search='+inputString+'&Itemid=157';
	
}