// JavaScript Document
function validations(x)
{
	if(x.gender.value=="")
	{
		alert("Please select Gender");
		return false;
	}
	if(x.f_name.value=="")
	{
		alert("Please enter First Name");
		x.f_name.focus();
		return false;
	}
	if(x.l_name.value=="")
	{
		alert("Please enter Last Name");
		x.l_name.focus();
		return false;
	}
	if(x.user_name.value=="")
	{
		alert("Please enter User Name");
		x.user_name.focus();
		return false;
	}
	var rg=/^([a-zA-Z0-9])+$/;
	
	if(rg.test(x.user_name.value)==false)
	{
		alert("Please enter only valid characters");
		x.user_name.value = '';
		x.user_name.focus();
		return false;
	}
	
	if(x.pass.value=="")
	{
	alert("Please enter password");
	x.pass.focus();
	return (false);
	}
	if(x.pass.value.length<6)
	{
		alert("Password should be greater than 6 characters");
		x.pass.focus();
		return (false);
	}
	if(x.pass_again.value=="")
	{
	alert("Please Re enter password");
	x.pass_again.focus();
	return (false);
	}
	if(x.pass.value!=x.pass_again.value)
	{
		alert("Passwords do not match");
		x.pass_again.focus();
		return (false);
	}
	if (x.email.value == "")
	{
	alert("Please enter a value for the \"Email\" field.");
	x.email.focus();
	return (false);
	}
		// test if valid email address, must have @ and .
	var checkEmail = "@.";
	var checkStr = x.email.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkEmail.length;  j++)
	{
	if (ch == checkEmail.charAt(j) && ch == "@")
	EmailAt = true;
	if (ch == checkEmail.charAt(j) && ch == ".")
	EmailPeriod = true;
		  if (EmailAt && EmailPeriod)
			break;
		  if (j == checkEmail.length)
			break;
		}
		// if both the @ and . were in the string
	if (EmailAt && EmailPeriod)
	{
			EmailValid = true
			break;
		}
	}
	if (!EmailValid)
	{
	alert("The \"email\" field must contain an \"@\" and a \".\".");
	x.email.focus();
	return (false);
	}
	if(x.accept.checked==false)
	{
		alert("You MUST have to accept our Terms and Conditions.");
		return (false);
	}
}