var xmlHttp

function showHint(str){
	if (str.length==0)  { 
	  document.getElementById("txtHint").innerHTML="";
	  return;
	}
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
	  return;
	} 
	var url="checkUsername.php";
	url=url+"?q="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
} 

function stateChanged(){ 
	if (xmlHttp.readyState==4){ 
		if (xmlHttp.responseText == 'yes'){
			myContent = '<a href="join_'+document.getElementById('nick').value+'.htm"><img src="des_img/buttons/join.gif" alt="Join!" /></a>';
		} else if (xmlHttp.responseText == 'short'){
			myContent = '<span class="red"><img src="des_img/icons/no.gif" /> too short</span>';
		} else {
			myContent = '<span class="red"><img src="des_img/icons/no.gif" /> unavailable</span>';
		}
		document.getElementById("available").innerHTML=myContent;
	}
}

function GetXmlHttpObject(){
	var xmlHttp=null;
	try {
	  xmlHttp=new XMLHttpRequest();
	} catch (e){
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
}