function captchaReload() {
  /*
  Reloads the CAPCHA image.
  */
  
  document.getElementById('reg_captcha_img').src=document.getElementById('reg_captcha_img').src + '?' + (new Date()).getTime();
  document.getElementById('reg_captcha').value="";
  
}

function displayCaptchaInfo() {
  /*
  Displays short explanation of captcha to user.
  */
  removeAllErrors();
  
  try {
    document.getElementById('reg_captcha_info').style.display="inline";
  } catch(err) {
  }
}

function removeCaptchaInfo() {
  /*
  Removes short explanation of captcha to user.
  */
  
  try {
    document.getElementById('reg_captcha_info').style.display="none";
  } catch(err) {
  }
}

function removeAllErrors() {
  /*
  Removes any existing error message
  */
  
  try {
    document.getElementById('reg_email_error').style.display="none";
    document.getElementById('reg_pwd_error').style.display="none";
    document.getElementById('reg_captcha_error').style.display="none";
    document.getElementById('reg_captcha_eval_error').style.display="none";
  } catch(err) {
  }  
}

function formRegValidate() {
  /*
  Validates registration form
  */

  removeCaptchaInfo();
  removeAllErrors();
  
  form=document.getElementById('reg_form');
  strv=new StrValidate();
  
  // Validate e-mail address
  if(!(strv.isEmailAddress(form.reg_email.value))) {
    document.getElementById('reg_email_error').style.display="inline";
    return false;
  } 

  // Validate password
  if(!(strv.withinLength(form.reg_pwd.value,5,20))) {
    document.getElementById('reg_pwd_error').style.display="inline";
    return false;
  } 

  // Validate captcha
  if(!(strv.withinLength(form.reg_captcha.value,4,4))) {
    document.getElementById('reg_captcha_error').style.display="inline";
    return false;
  }   
  return true;
}
