function Register()
{
	if( ValidateForm() )
	{
		document.RegistrationForm.submit();
	}
}

function ValidateForm()
{
	var sEmail = document.RegistrationForm.sUserName.value.Trim();
	var sPwd1 = document.RegistrationForm.sPassword.value.Trim();
	var sPwd2 = document.RegistrationForm.sPassword1.value.Trim();
	var bReadTerms = document.RegistrationForm.bReadTermsAndConditions;

	if ( sEmail == '' )
	{
		alert( "You must enter an email address!" );
		document.RegistrationForm.sUserName.focus();
		document.RegistrationForm.sUserName.select();
		return false;	
	}
	
	if ( !CheckValidEmail(sEmail) )
	{
		alert( "Invalid email address!" );
		document.RegistrationForm.sUserName.focus();
		document.RegistrationForm.sUserName.select();
		return false;	
	}

	if ( sPwd1 != sPwd2 )
	{
		alert( "Passwords do not match!" );
		document.RegistrationForm.sPassword.value = "";
		document.RegistrationForm.sPassword1.value = "";
		document.RegistrationForm.sPassword.focus();
		
		return false;	
	}
	
	if ( sPwd1 == '' )
	{
		alert( "You must enter a password!" );
		document.RegistrationForm.sPassword.focus();
		return false;	
	}
	
	if ( sPwd1.length < 6 )
	{
		alert( "Your password must have at least 6 characters" );
		document.RegistrationForm.sPassword.focus();
		return false;	
	}
	
	if ( sPwd1.indexOf(' ') > 0 )
	{
		alert( "Your password must not contain empty spaces" );
		document.RegistrationForm.sPassword.focus();
		return false;
	}
	
	if ( bReadTerms.checked != true )
	{
		alert( "Please tick the box to acknowledge that you have read \nand accept our terms & conditions and privacy policy." );
		document.RegistrationForm.bReadTermsAndConditions.focus();
		return false;
	}
	
	return true;
}

function CheckValidEmail( sText )
{
	// Assumes sText is not empty
	var d = sText.split('@')

	if ( d.length != 2 )
	{
		return false;
	}
	else
	{
		var dom = d[1].split('.') ;
		
		if ( dom.length < 2 )
			return false;
	}
	
	return true;
}
