var mousePosition;

function sendSearchKeyword(keyword){
	if (!keyword=='') {
		document.getElementById("search").style.backgroundImage="url(http://woodsrum.co.uk/images/loading.gif)";
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp===null){
			alert ("Browser does not support HTTP Request");
			return;
		}
		var url='http://woodsrum.co.uk/cocktail/search/'+keyword;		
		xmlHttp.onreadystatechange=stateChanged;
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");	
		xmlHttp.send(url);
	} else {
		document.getElementById("searchResults").style.display="none";	
		document.getElementById("cocktails").style.display="inline";
	}
}


function stateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")	{ 
		if (xmlHttp.responseText==0) {
			document.getElementById("search").style.backgroundImage="none";
			document.getElementById("searchResults").style.display="none";
		} else {
			document.getElementById("search").style.backgroundImage="none";		
			document.getElementById("cocktails").style.display="none";			
			document.getElementById("searchResults").style.display="inline";
			document.getElementById("searchResults").innerHTML=xmlHttp.responseText;	
			change=false;
		}
	} 
} 


// load search results from Server
function loadSearchResults(id) {
	document.getElementById("daten").style.display='none';
	document.getElementById("standortVergleich").style.display='inline'; 
  	var url='standorteVergleich.php?project_id='+currentProjectId;
		standorteVergleichRequest=getTheXMLHttpRequest();
		if (standorteVergleichRequest===null){
			alert ("Browser does not support HTTP Request");
			return;
		} 
	standorteVergleichRequest.onreadystatechange=showStandorteVergleich; 
	standorteVergleichRequest.open("GET",url,true);
	standorteVergleichRequest.send(null);		
}

// show search results
function showSearchResults() {
	if (standorteVergleichRequest.readyState=="4" || standorteVergleichRequest.readyState=="complete") {
		document.getElementById('searchResults').innerHTML=standorteVergleichRequest.responseText;
	} 
	document.getElementById("ajax_response").innerHTML='';
} 

function GetXmlHttpObject(){ 
	var objXMLHttp=null;
	if (window.XMLHttpRequest){
		objXMLHttp=new XMLHttpRequest();
	}else if (window.ActiveXObject){
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return objXMLHttp;
}

function sortAlphaAsc(){
	return false;
}


