function onKeyDownHandler(inNativeEvent) {var key = getKey(inNativeEvent);if (key == System.key.enter) {login();}}function changeToRegisterForgotPassword() {top.content.location.href = "register.html";}function changeToHome() {top.content.location.href = "home.html";}function changeToContact() {top.content.location.href = "contact.html";}function changeToHelp() {top.content.location.href = "help.html";}function login() {var username = dojo.byId("usernameText").value;var password = dojo.byId("passwordText").value;dojo.xhrPost({url: System.servlet,content: { action:"user.UserLogin", u:username, p:password }, handle: function(data, args) {var status = getContentOfTag(data, "status");if (status == Status.ok) {changeMenuToUserLogin();top.content.location.href = "project.jsp";} else if (status == Status.login.missingField) {alert("Please fill in all required fields");} else if (status == Status.login.invalidCredentials) {alert("Invalid username and/or password");} else if (status == Status.login.inactive) {alert("This user has been deactivated");}}});}function logout() {dojo.xhrPost({url: System.servlet,content: { action:"user.UserLogout" },handle: function(data, args) {changeMenuToUserLogout();top.content.location.href = "home.html";}});}/** Hides all login and register fields and buttons and shows the 'project' and 'logout' button*/function changeMenuToUserLogin() {dojo.byId("changeLoginRegisterButton").style.visibility = "hidden";dojo.byId("usernameDiv").style.visibility = "hidden";dojo.byId("usernameTextStrong").style.visibility = "hidden";dojo.byId("passwordDiv").style.visibility = "hidden";dojo.byId("passwordTextStrong").style.visibility = "hidden";dojo.byId("loginButton").style.visibility = "hidden";dojo.byId("forgotPasswordHref").style.visibility = "hidden";dojo.byId("projectBtn").style.visibility = "visible";dojo.byId("preferencesBtn").style.visibility = "visible";dojo.byId("logoutBtn").style.visibility = "visible";}function changeMenuToUserLogout() {dojo.byId("changeLoginRegisterButton").style.visibility = "visible";dojo.byId("usernameDiv").style.visibility = "visible";dojo.byId("usernameTextStrong").style.visibility = "visible";dojo.byId("passwordDiv").style.visibility = "visible";dojo.byId("passwordTextStrong").style.visibility = "visible";dojo.byId("loginButton").style.visibility = "visible";dojo.byId("forgotPasswordHref").style.visibility = "visible";dojo.byId("projectBtn").style.visibility = "hidden";dojo.byId("preferencesBtn").style.visibility = "hidden";dojo.byId("logoutBtn").style.visibility = "hidden";}function changeToProjects() {top.content.location.href = "project.jsp";}function changeToPreferences() {top.content.location.href = "preferences.html";}