var VsaLogin=Class.create({url_verify:"/cgi-bin/login_request.pl?",initialize:function(a){this.domUsername=$("username");
this.domPassword=$("password");this.domWarning=$("warning");this.domLoginButton=$("login-button");
this.domUsernameBlock=$("username-block");this.domPasswordBlock=$("password-block");
this.domLofinForm=$("login-form");this.domUsername.focus();this.restWarnings();this.domUsername.observe("keypress",function(c){var b=c.keyCode||c.which;
if(b==Event.KEY_RETURN){this.domPassword.focus()}}.bind(this),false);this.domPassword.observe("keypress",function(c){var b=c.keyCode||c.which;
if(b==Event.KEY_RETURN){this.tryLogin()}}.bind(this),false);this.domLoginButton.observe("click",this.tryLogin.bind(this))
},restWarnings:function(){this.domWarning.hide();this.domWarning.removeText();this.domUsernameBlock.removeClassName("table-enlight");
this.domPasswordBlock.removeClassName("table-enlight")},showWarnings:function(d,a){var c=new Element("h3").update(d);
this.domWarning.insert(c);var b=new Element("p").update(a);this.domWarning.insert(b);
this.domWarning.show()},loginWarnung:function(a){switch(a){case"noUsername":this.showWarnings("Benutzername fehlt","Bitte geben sie ihren VSA Loginnamen in das markierte Feld ein.");
break;case"noPassword":this.showWarnings("Passwort fehlt","Bitte geben sie ihr VSA Passwort in das markierte Feld ein.");
break;case"wrongPassword":this.showWarnings("Passwort falsch","Das angegebene Passwort oder der Benutzername sind ungültig.");
break;case"commErr":this.showWarnings("Verbindungsfehler","Es werden Wartungsarbeiten durchgeführt oder es liegt einen Störung vor.                           Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wenden Sie sich an den Support.");
break;default:this.showWarnings("Unbekannter Fehler","Bitte wenden sie sich an den Support")
}},tryLogin:function(){this.restWarnings();console.debug(this.domPassword);if(this.domUsername.value.length==0){this.domUsernameBlock.addClassName("table-enlight");
this.domUsername.focus();this.loginWarnung("noUsername")}else{if(this.domPassword.value.length==0){this.domPasswordBlock.addClassName("table-enlight");
this.domPassword.focus();this.loginWarnung("noPassword")}else{var a=new Ajax.Request(this.url_verify+getSid(),{method:"post",parameters:{username:this.domUsername.value,password:this.domPassword.value},onSuccess:this.loginResult.bind(this),onFailure:function(b){console.debug(b);
this.loginWarnung("commErr")}.bind(this)})}}},loginResult:function(c){var a=c.responseXML;
var b=a.getElementsByTagName("results")[0];var d=getXmlValue(b,"error");if(d==-1){this.domLofinForm.submit()
}else{this.domPassword.focus();this.loginWarnung("wrongPassword")}}});function init_vsa_login(){var a=new VsaLogin()
}Event.observe(window,"load",init_vsa_login);