function check_register() {
if (document.user_name.first_name.value == "") {
	document.getElementById('error').innerHTML="Please enter first name to continue.";
	document.user_name.first_name.focus();
	return false;
}

if (document.user_name.nickname.value == "") {
	document.getElementById('error').innerHTML="Please enter the nickname to continue.";
	document.user_name.nickname.focus();
	return false;
}

if(trim(document.user_name.nickname.value)=="") {
	document.getElementById('error').innerHTML="Please choose nickname to continue.";
	document.user_name.nickname.value="";
	document.user_name.nickname.focus()
	return false;
}
if(document.user_name.nickname.value.length<=2){
		document.getElementById('error').innerHTML="Length of nickname should be greater than two characters. ";
		document.user_name.nickname.focus();
		return false;
}
if(document.user_name.nickname.value.length>=3){
		var sText=document.user_name.nickname.value;
		var ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";
		var IsNumber=true;
		var Char;	
			for (j = 0; j < sText.length && IsNumber == true; j++) 
			{ 
				Char = sText.charAt(j); 
				if (ValidChars.indexOf(Char) == -1) 
				{
					IsNumber = false;
				}
			}
		 if(IsNumber==false)
		 {
		 document.getElementById('error').innerHTML="Please enter Valid Username. Please do not use special character. ";
			return false;
		 }
	}

if (document.user_name.password1.value == "") {
	document.getElementById('error').innerHTML="Please enter the Password to continue.";
	document.user_name.password1.focus();
	return false;
}	
if(trim(document.user_name.password1.value)=="") {
	document.getElementById('error').innerHTML="Please enter appropriate Password to continue.";
	document.user_name.password1.value="";
	document.user_name.password1.focus()
	return false;
}
if(document.user_name.password1.value.length<5) {
	document.getElementById('error').innerHTML="Length of password should be 5 or more characters or numbers";
	document.user_name.password1.focus();
	return false;
}
if(document.user_name.password1.value.length>20) {
		document.getElementById('error').innerHTML="Length of Password cannot be greater than 20";
		document.user_name.password1.focus();
		return false;
	}

if (document.user_name.email.value == "") {
	document.getElementById('error').innerHTML="Please enter the Email address to continue.";
	document.user_name.email.focus();
	return false;
}	
if(trim(document.user_name.email.value)=="") {
	document.getElementById('error').innerHTML="Please enter appropriate Email to continue.";
	document.user_name.email.value="";
	document.user_name.email.focus()
	return false;
}
if(!checkemail(document.user_name.email)) {
	document.user_name.email.focus()
	return false;
}
if(document.user_name.txt_verification_code.value=='') {
	document.getElementById('error').innerHTML="Please enter Verification Code to continue.";
	document.user_name.txt_verification_code.focus();
	return false;
}
if(document.user_name.txt_verification_code.value!=document.user_name.verifycode.value) {
	document.getElementById('error').innerHTML="Enter correct Verification Code";
	document.user_name.txt_verification_code.focus();
	return false;
}

if(document.user_name.terms.checked==false) {
	document.getElementById('error').innerHTML="You need to agree to terms and conditions to continue.";
	return false;
}
return true;
}

function trim(TRIM_VALUE)
{
	if(TRIM_VALUE.length < 1)
	{
		return"";
    }
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
		return "";
    }
    else
	{
		return TRIM_VALUE;
    }
} 

function RTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0)
	{
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1)
	{
		if(VALUE.charAt(iTemp) == w_space)
		{
		}
		else
		{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} 
	return strTemp;
}

function LTrim(VALUE)
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1)
	{
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length)
	{
	if(VALUE.charAt(iTemp) == w_space)
	{
	}
	else
	{
		strTemp = VALUE.substring(iTemp,v_length);
		break;
	}
	iTemp = iTemp + 1;
	} 
	return strTemp;
} 

function checkemail(emailobj)  {
	//pass form object
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailobj.value))
	{
		return (true)
	}
		document.getElementById('error').innerHTML="Invalid E-mail Address! Please re-enter.";
	return (false);
}
