var xmlHttp
var str
function checkuser(val)
{ 

str = val;
		if(str != ''){
			
			
			xmlHttp=GetXmlHttpObject();
			if (xmlHttp==null)
			  {
			  alert ("Your browser does not support AJAX!");
			  return;
			  } 
			var url="checkuser.php";
			url=url+"?q="+str;
			
			xmlHttp.onreadystatechange=stateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);
			
		}

}

function stateChanged() 
{ 
  if (xmlHttp.readyState==4)
	{ 
 	if(str != ''){
	 
				var res =  xmlHttp.responseText;
				var not =  '<font color="red">This user name not available..</font>';
				var yes =  '<font color="green">This user name available..</font>';
				if(res == 'yes'){		
					document.getElementById("checkuser").innerHTML=not;
					document.getElementById("rtUserName").style.background = "#CC3300";
					document.getElementById("rtUserName").focus();
					}
				if(res == 'no'){	
				 document.getElementById("checkuser").innerHTML=yes;
				 document.getElementById("rtUserName").style.background = "#ffffff";
				 }
   			}
  }
}
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;
}