function getHTTPObject() {
  var xmlhttp;
/*@cc_on
/*@if (@_jscript_version >= 5)
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
@else @/*
    xmlhttp = false;
/*@end
@*/
  if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined') {
        try {
            xmlhttp = new XMLHttpRequest();
        } catch (e) {
             xmlhttp = false;
        }
  } return xmlhttp;
}

function login() {
  var username = document.getElementById("form-username").value;
  var password = document.getElementById("form-password").value;
  this.http.open("get", this.action, false, username, password);
  this.http.send("");
  if (this.http.status == 200) {
        document.location = this.action;
        return false;
  } else {
    this.http.open("get", this.action, false, "null", "null");
    this.http.send("");
    alert("Incorrect username and/or password.");
    return false;
  }
}


function createForm(jshttpauth, http) {
   var form = document.createElement("form");
   form.action = jshttpauth.href;
   form.method = "post";
   form.onsubmit = login;
   form.http = http;
   var username = document.createElement("label");
   var usernameInput = document.createElement("input");
   usernameInput.name = "username";
   usernameInput.type = "text";
   usernameInput.id = "form-username";
   //username.appendChild(document.createTextNode("Benutzername "));
   username.appendChild(usernameInput);
   var password = document.createElement("label");
   var passwordInput = document.createElement("input");
   passwordInput.name = "password";
   passwordInput.type = "password";
   passwordInput.id = "form-password";
   //password.appendChild(document.createTextNode("Kennwort "));
   password.appendChild(document.createElement("br"));
   password.appendChild(passwordInput);
   password.appendChild(document.createElement("br"));
   var submit = document.createElement("input");
   submit.type = "submit";
   submit.value = "Anmelden";
   form.appendChild(username);
   form.appendChild(password);
   form.appendChild(submit);
   jshttpauth.parentNode.replaceChild(form, jshttpauth);
}

