var xmlHttp;


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;
}

// AJAX function for xmlHttp request for change state
function search_find_user_name() 
{ 
var v;
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	if (v=0)
	{
		document.getElementById(obj).visible=false;
	 v=1;
	}
	document.getElementById("valid_user").innerHTML=xmlHttp.responseText;
 }
 	else  {
	
		if (v=0)
		{
			document.getElementById(obj).visible=true; v=1;
		}
		}
}


function find_user_name(val)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request");
	 return;
	 }
	document.getElementById("valid_user").style.display="block";
	var randomnumber=Math.floor(Math.random()*11);
	var url="ajax_find_user_name.php?UserName="+val+"&rand_var="+randomnumber;
	xmlHttp.onreadystatechange= function () { search_find_user_name() };
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
