<!--
///
function check_username()
{
index=1
fld_length=spaceStripper(document.form1.user.value," ","");
		if((fld_length.length==0) || (document.form1.user.value =="") || (fld_length.length<=4) ||  (fld_length.length>=11)) 
		{
		   alert("Please enter/select the user name. Enter 5-8 chars only");		   
		   index=0
		   document.form1.user.focus();
	    }
	    
     if(fld_length.length!=0)
        {
			if (!isAlpNum(document.form1.user))
			{
			index=0			
			document.form1.user.focus();
			}
			 else
			 {			
			var firstCharectar = document.form1.user.value;
			if ( (firstCharectar.substr(0,1)=="0") || (firstCharectar.substr(0,1)=="1") || (firstCharectar.substr(0,1)=="2") || (firstCharectar.substr(0,1)=="3") || (firstCharectar.substr(0,1)=="4") || (firstCharectar.substr(0,1)=="5") || (firstCharectar.substr(0,1)=="6") || (firstCharectar.substr(0,1)=="7") || (firstCharectar.substr(0,1)=="8") || (firstCharectar.substr(0,1)=="9") )
					{
					index=0
				alert("User name should not start with a number");
				//document.form1.user.value="";
				document.form1.user.focus();				
					}
			  }
		}	  
	   	   
	   if (index==1) 
	   {  
	   	document.form1.method="post";
		document.form1.action="check_user.asp";
		document.form1.submit();
		}
	
}



//


///


function spaceStripper(incomingText,str1,str2)
	{
		workString=incomingText;
		while (workString.indexOf(str1)!=-1)
		{
			workString=workString.substring(0,workString.indexOf(str1))+str2+workString.substring(workString.indexOf(str1)+str1.length,workString.length);
		}
		return workString;
	}

//Function to check whether the input is of alphanumeric type 
	var isAlphabetNum=0;
	function isAlpNum(incomingText)
	{
		isAlphabetNum=0;
		alphastr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
		Name=incomingText.name;
		textvalue=incomingText.value;
			for (counter=0;counter<textvalue.length;counter++)
			{
				find=textvalue.charAt(counter);
				if(alphastr.indexOf(find)==-1)
				{
					isAlphabetNum=1;
				}
			}
			if(isAlphabetNum==1)
			{
				alert("Please enter alphabets & numbers only for username & Password");
				incomingText.value="";
				incomingText.focus();
				return false;
			}
			else 
			{
				return true;
			}
	}
	
///
var testresults
function checkemail()
{
var str=document.form1.email.value;
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true;
else{
alert("Please input a valid email address!")
testresults=false;
}
return (testresults);
}

function checkbae(){
if (document.layers||document.getElementById||document.all)
return checkemail()
else
return true;
}	

///

function submit_values()
	{

//Validation of the User Name field
		fld_length1=spaceStripper(document.form1.firstname.value," ","");
		if((fld_length1.length==0) || (document.form1.firstname.value =="") ) 
		{
		    alert("Please enter firstname.");
		   document.form1.firstname.focus();
	       return false; 
        }
        fld_length1=spaceStripper(document.form1.lastname.value," ","");
		if((fld_length1.length==0) || (document.form1.lastname.value =="") ) 
		{
		    alert("Please enter lastname.");
		   document.form1.lastname.focus();
	       return false; 
        }
       
       //validation for email		
	email_length=spaceStripper(document.form1.email.value," ","");
	//alert(document.form1.email.value);
	if ((email_length.length >0) && (!checkbae())) 
		{	
	return false;
		}
if (document.form1.email.value!=document.form1.email2.value) 
		{
		alert("Your emails are not matching.");	
	return false;
		}
       
//Validation of the password field
		fld_length=spaceStripper(document.form1.pwd.value," ","");
		if((fld_length.length==0) || (document.form1.pwd.value =="") || (fld_length.length<=5) ||  (fld_length.length>=16)) 
		{
		   alert("Please enter the password 6-8 chars.");
		   document.form1.pwd.focus();
		   return false; 
		}
			
			if (!isAlpNum(document.form1.pwd))
		{
			return false;
		}	 

if (document.form1.pwd.value!=document.form1.pwd2.value)
		{
		alert("Passwords don't match.");
			return false;
		}	 
	
	if ((document.form1.firstname.value=="") || (document.form1.pwd.value=="") || (document.form1.lastname.value=="") || (document.form1.address.value=="") || (document.form1.pin.value=="") || (document.form1.country.value=="") || (document.form1.city.value=="") || (document.form1.phone.value=="") || (document.form1.email.value==""))

	{
	 alert("Please fill all details marked as * Required ");
	return false;
	}
	
	
	if(document.form1.securityCode.value=="")
{
alert("Please fill in Security code")
document.form1.securityCode.focus;
return false;
}
			
	
}


///
function submit_values2()
	{
		
	//Validation of the User Name field
		fld_length1=spaceStripper(document.form1.firstname.value," ","");
		if((fld_length1.length==0) || (document.form1.firstname.value =="") ) 
		{
		    alert("Please enter firstname.");
		   document.form1.firstname.focus();
	       return false; 
        }
        fld_length1=spaceStripper(document.form1.lastname.value," ","");
		if((fld_length1.length==0) || (document.form1.lastname.value =="") ) 
		{
		    alert("Please enter lastname.");
		   document.form1.lastname.focus();
	       return false; 
        }
       
       //validation for email		
	email_length=spaceStripper(document.form1.email.value," ","");
	//alert(document.form1.email.value);
	if ((email_length.length >0) && (!checkbae())) 
		{	
	return false;
		}

       
//Validation of the password field
		fld_length=spaceStripper(document.form1.pwd.value," ","");
		if((fld_length.length==0) || (document.form1.pwd.value =="") || (fld_length.length<=5) ||  (fld_length.length>=16)) 
		{
		   alert("Please enter the password 6-8 chars.");
		   document.form1.pwd.focus();
		   return false; 
		}
			
			if (!isAlpNum(document.form1.pwd))
		{
			return false;
		}	 

if (document.form1.pwd.value!=document.form1.pwd2.value)
		{
		alert("Passwords don't match.");
			return false;
		}	 
	
	if ((document.form1.firstname.value=="") || (document.form1.pwd.value=="") || (document.form1.lastname.value=="") || (document.form1.address.value=="") || (document.form1.pin.value=="") || (document.form1.country.value=="") || (document.form1.city.value=="") || (document.form1.phone.value=="") || (document.form1.email.value==""))

	{
	 alert("Please fill all details marked as * Required ");
	return false;
	}		
	
//alert("");
document.form1.mode.value="Modify";
	
}



//-->