function checkRegistration(oForm)
{
  with (oForm) {
    if (first_name.value == '') {
      alert('Please enter your first name')
      first_name.focus()
      return false
    }
    if (surname.value == '') {
      alert('Please enter your surname')
      surname.focus()
      return false
    }
    if (email.value == '' || !isEmailValid(email)) {
      alert('Please enter a valid email address')
      email.focus()
      return false
    }
    if (password.value == '') {
      alert('Please enter a password')
      password.focus()
      return false
    }
    if (((typeof(existing_password) != 'undefined' && existing_password && existing_password.value != password.value) || typeof(existing_password) == 'undefined') && cpassword.value != password.value) {
      alert('Please make sure password and password confirmation are identical')
      cpassword.focus()
      return false
    }
  }
  if (oForm.javascript_check) {
    oForm.javascript_check.value = '1'
  }
  reWebmail = /^.+@((yahoo\.co|hotmail\.co)(m|\.uk))$/gi
  if (reWebmail.exec(oForm.email.value)) {
    if (!confirm('WARNING:\nUsers have experienced difficulties receiving their activation emails\nusing webmail email addresses in the past. Please ensure your\n' + RegExp.$1 + ' account is currently active and does not have a full\ninbox before clicking OK.')) {
      return false
    }
  }
  return true
}

function isEmailValid(oEmail)
{
  str = oEmail.value
  r1 = new RegExp('(@.*@)|(\\.\\.)|(@\\.)|(^\\.)')
  r2 = new RegExp('^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$')
  return (!r1.test(str) && r2.test(str))
}