var rse_t;
var rse_old_value;

function rse_stop_search_locations()
{
	clearTimeout(rse_t);
}

function rse_search_locations(string)
{
	if (string == rse_old_value) return;
	rse_t = setTimeout( function() {
		selbox = document.getElementById('rse_locations');
		var url = 'index.php?option=com_rsevents';
		var params = 'task=location_filter&tmpl=component&string='+ string +'&randomTime='+Math.random();
		xml=buildXmlHttp();

		xml.open('POST',url,true);
		

		xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xml.setRequestHeader("Content-length", params.length);
		xml.setRequestHeader("Connection", "close");
		
		xml.onreadystatechange=function()
		{
			if(xml.readyState==4)
			{		
				document.getElementById('rse_hideme').style.display = 'none';
				selbox.innerHTML  = xml.responseText;
			}
		}
		xml.send(params);
		rse_old_value = string;
		document.getElementById('rse_hideme').style.display = '';
	}, 1000);
}

function buildXmlHttp()
{
	var xmlHttp;
	try
	{
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}