﻿
// JScript File

var xmlhttpInd;

   function CreateXmlHttpInd()
	{
		//Creating object of XMLHTTP in IE
		try
		{
			xmlhttpInd = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				xmlhttpInd = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch(oc)
			{
				xmlhttpInd = null;	
			}
		}
		//Creating object of XMLHTTP in Mozilla and Safari 
		if(!xmlhttpInd && typeof XMLHttpRequest != "undefined") 
		{
			xmlhttpInd = new XMLHttpRequest();
		}
	}
    function CountId(strValue)
    {
       	CreateXmlHttpInd();
		document.body.style.cursor = "progress";
	    var requestUrl = "AjaxCountCode.aspx?ClientId="+strValue +"&timeStamp="+ new Date().getTime();
	    //alert(requestUrl);
		if(xmlhttpInd)	{
				xmlhttpInd.onreadystatechange = function(){getRespInd()};
				xmlhttpInd.open("GET", requestUrl,  true);
				xmlhttpInd.send(null);
			}
     }




function getRespInd()
{

	if(xmlhttpInd.readyState == 4)
	{
	
		
		// To make sure valid response is received from the server, 200 means response received is OK
		if(xmlhttpInd.status == 200)
		{	
            var strdata = xmlhttpInd.responseText;
            var arrData = strdata.split("|");
            //alert(strdata)
           if(document.getElementById("txtusername").value==false)
            {
                document.getElementById("txtusername").value="";
		        document.getElementById("txtusername").focus();
		        return false
            }
            else
            { 
              if(eval(arrData[0]) > 0)
               {
                   alert("Client ID Already Exists");
                   document.getElementById("txtusername").value="";
                   document.getElementById("txtusername").focus();
                   document.getElementById("userstat").style.display="none";
                    return false;
               }
              else
              {           
                 document.getElementById("userstat").style.display="";
                     
              }
            }
         }
     }
 }   
    

    function isCharKey(evt)
	{
	    var charCode =(evt.which) ? evt.which : event.keyCode
		
		if((charCode > 90 || charCode < 65) && (charCode > 122 || charCode < 97) && (charCode > 31))
		{
		    if (charCode!=32)
		    {
			    alert("Use Charcters Only");
			    return false;
			}
		}
		else
		{	
		    return true;
	    }
	}
	
	function isCharKey1()
	{
	    var charCode = event.keyCode
		
		if((charCode > 90 || charCode < 65) && (charCode > 122 || charCode < 97) && (charCode > 31))
		{
		    if (charCode!=32)
		    {
			    alert("Use Charcters Only");
			    return false;
			}
		}
		else
		{	
		    return true;
	    }
	}
	
	//Check Digit Entry	
    function checkDigit()
    {
	    if(window.event.keyCode < 48 || window.event.keyCode > 57)
	    {		
		    if(window.event.keyCode == 43 || window.event.keyCode == 45)
		    {
			    event.returnValue = true;
			}
	        else
	        {
			    event.returnValue = false;
			    alert("Use Numbers only");
		    }
	    }
    }
     
    //Email Validation
	
	
    function isalphabet(val)
    {
        if (val.match(/^[a-zA-Z.' ]+$/))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    
    
    function common(val)
    {
        if (val.match(/^[-a-zA-Z0-9 /(.)& ]+$/))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    	
    function isnumber(num)
    {
        if (num.match(/^[0-9 ]+$/))
        {
            return true;
        }
        else 
        {
            return false;
        }
    }
    function validatePwd()
     {   
            var pwd = document.getElementById("txtPassword");
            var conpwd = document.getElementById("txtConfimpwd");  
           
            if(pwd.value=="")
            {
             alert("password cannot be space");
             pwd.value="";
             pwd.focus();
             return false;
            }
            else if(pwd.value!="" && pwd.value.length<6)
            {
                alert("Password should contain atleast six characters");
                pwd.select();
                return false;
            }
            else if(pwd.value!=conpwd.value)
            {
            alert("Password and confirm password should be same")
            pwd.focus();
            return false;
            } 
        }  
    
     function RegValidation()
      {
      var str1=document.getElementById("txtmail").value
      var filter1=/^((?:(?:(?:[a-zA-Z0-9][\.\-\+_]?)*)[a-zA-Z0-9])+)\@((?:(?:(?:[a-zA-Z0-9][\.\-_]?){0,62})[a-zA-Z0-9])+)\.([a-zA-Z0-9]{2,6})$/
         var nam=document.getElementById("txtname");
         var mail=document.getElementById("txtmail");
         var userid=document.getElementById("txtusername");
         var pw=document.getElementById("txtPassword");
         var date=document.getElementById("DDL_Day");
         var conpwd = document.getElementById("txtConfimpwd");  
          var txtVarify = document.getElementById("TxtVerificationCode");
         var Mon= document.getElementById("DDL_Month");
         var Yer = document.getElementById("DDL_Year");
         
          if(nam.value==""|| nam.value==null)
          {
              alert("Please enter name");
              nam.focus();
              return false;
          }
          
           if (document.getElementById("txtmail").value == "")
	        {
		        alert("Please Enter your Email");
		        document.getElementById("txtmail").focus();
		        return false;
	        }
	        else if(document.getElementById("txtmail").value !="")
	        {	 
		        if (!filter1.test(str1))
		        {  
			        alert("Invalid EmailID! Please re-enter.")
			        document.getElementById("txtmail").focus();
			        return false;
		        } 
	        }
          
            if(userid.value==""|| userid.value==null)
          {
              alert("Please enter UserID");
              userid.focus();
             
              return false;
          }
           if(pw.value==""|| pw.value==null)
          {
              alert("Please enter Password");
              pw.focus();
              return false;
              
          }
           if(pw.value!=conpwd.value)
            {
            alert("Password and confirm password should be same")
            conpwd.focus();
            return false;
            } 
           if(isnumber(date.value)==false)
          {
              alert("Please select Date");
              date.focus();
              return false;
          }
          if(isnumber(Mon.value)==false)
          {
              alert("Please select Month");
              Mon.focus();
              return false;
          }
          if(isnumber(Yer.value)==false)
          {
              alert("Please select Year");
              Yer.focus();
              return false;
          }
             if(txtVarify.value==""|| txtVarify.value==null)
          {
              alert("Please type the character you see in the picture");
              txtVarify.focus();
              return false;
              
          }
          
   }
 
