var xmlHttp

function checkname(str)
{
if(str.length == 0)
	{ 
	document.getElementById("username_check").innerHTML="";
	return;
	}
xmlHttp=GetXmlHttpObject();
if(xmlHttp == null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	} 
var url = "/includes/ajax/username_check.php";
var params = "username="+str;
xmlHttp.onreadystatechange = stateChanged;
xmlHttp.open("POST",url,true);

//Send the proper header information along with the request
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", params.length);
xmlHttp.setRequestHeader("Connection", "close");

xmlHttp.send(params);
}

function stateChanged() 
{ 
if(xmlHttp.readyState==4)
	{ 
	document.getElementById("username_check").innerHTML = xmlHttp.responseText;
	}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
	{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
	}
catch (e)
	{
	// Internet Explorer
	try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
return xmlHttp;
}
	