  //submit login form
  function doChallengeResponse() {
    str = document.login.username.value + ":" +
          MD5(document.login.password.value) + ":" +
          document.login.challenge.value;

    document.login.response.value = MD5(str);
    document.login.password.value = "";
    document.login.submit();
  }

  // Activate the appropriate input form field.
  function ActivateLoginBox() {
    if (document.login.username.value == '') {
      document.login.username.focus();
    } else {
      document.login.password.focus();
    }
  }


  // Activate the appropriate input form field.
  function ActivateRegisterBox() {
    if (document.register.email.value == '') {
      document.register.email.focus();
    } else {
      document.register.password.focus();
    }
  }

function cancelLogin(theUrl) {
    if (theUrl==null) theUrl = "index.php";
    window.location = theUrl+"?cancel_login=1";
}

function registerUser(theUrl) {
    if (theUrl==null) theUrl = "index.php";
    window.location = theUrl+"?lact=register";
}

function verifyRegister() {
    
    var messages = Array();
    
    if (document.register.password.value.length<5) {
        messages.push(" - Hasło jest zbyt krótkie! Minimalna długość hasła to 5 znaków");
    }     

    if (document.register.password.value != document.register.confirm_password.value)
        {
             messages.push("- Hasło i jego potwierdzenie nie są identyczne!");
             
        }
    var em = document.register.email.value;
    
    if (
        (em.indexOf("@") == -1) || 
        (em.charAt(0) == ".") || 
        (em.charAt(0) == "@") ||
        (em < 6) || 
        (em.indexOf(".") == -1) || 
        (em.charAt(em.indexOf("@")+1) == ".") || 
        (em.charAt(em.indexOf("@")-1) == ".")
    ) {
        messages.push(" - Adres email jest niepoprawny!");
    }     

    if (document.register.email.value != document.register.conf_email.value)
        {
             messages.push(" - Email i jego potwierdzenie nie są identyczne!");
             
        }

    if (messages.length>0) {
        var msg = messages.join("\n");
        alert(msg);
        return false;    
    }
    
    //document.register.submit();
    return true;
            
}
