var xmlhttp

function showHint(str,url)
{
if (str.length==0)
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support XMLHTTP!");
  return;
  }
// url=url+"?q="+str;
url = url + "?q=" + ( ( str.lastIndexOf( ',' ) > 0 ) ? trim( str.substr( str.lastIndexOf( ',' ) + 1 ) ) : trim( str ) );
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
	var s = document.getElementById("txtHint");
	s.className = 'txtHint_visible';
	s.style.position = 'absolute';
  	s.innerHTML=xmlhttp.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function autocomplete( val ){
	var s = document.getElementById( 'txt1' );	
	var __s = document.getElementById( 'txtHint' );
	var d = '';
	
	if( s.value.length > 0 ){
		d = s.value;
		if( strrpos( d, ',' ) === false ){
			s.value = val;
		} else{
			s.value = d.substr( 0, strrpos( d, ',' ) ) + ',' + val;
		}
	} else{
		s.value = val;
	}
	__s.className = 'txtHint_invisible';
}
