function check_availability(a)
{
if (isValidUserName(a)==true)
//if (document.forms("form1").elements("unm").value!='')
{
	var objdoc;
	var ab1=new Array();
	var ab2=new Array();
	
	var httpob = null;
    if (window.XMLHttpRequest) {
      // If IE7, Mozilla, Safari, and so on: Use native object.
      httpob = new XMLHttpRequest();
    }
    else
    {
      if (window.ActiveXObject) {
         // ...otherwise, use the ActiveX control for IE5.x and IE6.
         httpob = new ActiveXObject('MSXML2.XMLHTTP.3.0');
      }
    }
	    //var httpob=new ActiveXObject("Microsoft.XMLHTTP");

	    httpob.open("POST","check.asp?unm="+ a ,false);
	    httpob.send();
	    ab1=httpob.responseText;
	    ab2=ab1.split("^");
	    alert(ab2[0]);
	
		if(ab2[1]=='found')
		{  
    		//document.forms("form1").elements("unm").value=''; 
		    document.forms("form1").elements("unm").focus();
            document.forms("form1").elements("unm").select();
		}
		else
		{  
    	    document.forms("form1").elements("pwd").focus();
            document.forms("form1").elements("pwd").select();
		}
		  
}
else
{
     document.forms("form1").elements("unm").focus();
     document.forms("form1").elements("unm").select();
}
}

function isValidUserName(unm)
{
    var splchr1= new Array("<",">","?","#","%","!","-","_")            
    
    
    if(unm.value == "")
       {
            alert("Please enter username");
            return(false);
        }
    
    for(i=0;i<=splchr1.length;i++)
    {
	    for(j=0;j<=unm.length;j++)
	    {
		    if(unm.substr(j,1)==splchr1[i]) 
		    {
         		    alert("Special characters - not allowed in Username");
           		    return(false);
		    }
	    }
    }

    if((unm.length<6)||(unm.length>15))
            {
                alert("Username should be between 6 to 15 characters");
                return(false);        
            }
    return (true);            
}

function OnChangedUsername()
{
    if(document.form1.unm.value == "")
    {
    document.form1.btnCheckAvailability.disabled = true;
    }
    else
    {
    document.form1.btnCheckAvailability.disabled = false;
    }
}
