function IsInteger(sText)
{
   var ValidChars = "0123456789";
   var IsInteger=true;
   var Char;
   for (i = 0; i < sText.length && IsInteger == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsInteger = false;
         }
      }
   return IsInteger;
}


function validateUserRegistration(form) 
{
  //alert('Checking form...');
  var errorMsg = '';
  
  // Test that all the required fields are filled out ok

  if (form.username.value == "" )
  {
    errorMsg += 'A valid email address is required as your username\n';
	form.username.focus();
  }
  else
  {
	x = form.username.value.indexOf('@');
	y = form.username.value.indexOf('.');

    if (x < 1 || x == (form.username.value.length-1) || y < 1 ) 
	{
	  errorMsg += 'You must give a valid email address as your username.\n';
	  form.username.focus();
	  form.username.select();
	}
	  
    s = form.username.value.indexOf(' ');
    if (s != -1)
	{
	  errorMsg += 'Please check your email address. It should not contain spaces or have leading/trailing spaces \n';
	  form.username.focus();
	  form.username.select();
	}
  }	
  
   if (form.password.value == "")
  {
    errorMsg += 'A password is required.\n';
    form.password.focus();
  }
  
  if (form.name.value == "")
  {
    errorMsg += 'Your name is required.\n';
    form.name.focus();
  }
  
   if (!form.agreement.checked)
  	errorMsg += 'Please indicate that you are in agreement with our Terms & Conditions and Privacy Policy\n';

  
   if (errorMsg) 
	alert(errorMsg);
		
  document.returnValue = (errorMsg == '');
}




