//Start To check UserName
var xmlHttp;
var last = '0';
var CurrentDiv;
function checkCap(enteredcap,divNameForSattus)
{ 
alert('Code:='+enteredcap);
//alert('Message for:='+divNameForSattus);
CurrentDiv=divNameForSattus;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
 
//Take Requested User Name
reqUsername = enteredcap;
//alert(reqUsername);
var url="check_capch.php?c="+enteredcap;
xmlHttp.onreadystatechange=stateChanged 

xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{ 
	

 	capValid = xmlHttp.responseText;
	//alert('IsValidCapta:'+capValid)
	/* username_status this variable value Storing it in hidden field becuase when we submit the form just check the User Name staus whether it's availble or not*/
	//alert(username_status);
	//alert("Output text"+username_status);
	
	
	if(capValid == "")
	{
		capValid = "0";
	}
	
	if(capValid == "0")
	{
		/*document.getElementById('divUserNameStatus').innerHTML = "<font style='color:red; font-size:10pt'>Incorrect Security code,Please retype.</font>";
		document.getElementById('divUserNameStatusValue').innerHTML = "0";*/
		var targetdiv=document.getElementById(CurrentDiv);
		if(targetdiv != null)
		{
			targetdiv.innerHTML = "<font style='color:red; font-size:10pt'>Incorrect Security code, Please retry.</font>";
		}
		document.getElementById('divUserNameStatusValue').innerHTML = "0";
		
	}
	else
	{
		/*document.getElementById('divUserNameStatus').innerHTML = "<font style='color:green; font-size:10pt'>Correct Security code.</font>";*/
		//document.getElementById(divNameForSattus).innerHTML = "<font style='color:green; font-size:10pt'>Correct Security code.</font>";
		var targetdiv=document.getElementById(CurrentDiv);
		if(targetdiv != null)
		{
			targetdiv.innerHTML ="<font style='color:green; font-size:10pt'>Correct Security code.</font>";
		}
		document.getElementById('divUserNameStatusValue').innerHTML = "1";
	}
	

	document.getElementById('hidcapst').value = capValid;
	   
 } 
}

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;
}