//Fade constants.// var userContentFadeOut = 800; var userContentFadeIn = 1400; var mainFadeImageDelay = 0; var mainFadeImagePeriod = 2000; var mainFadeTitleDelay = 500; var mainFadeTitlePeriod = 1500; var mainFadeContentDelay = 1500; var mainFadeContentPeriod = 1000; //Variables used to show/hide the top content and make the buttons along the bottom function.// var selectedTextId; var selectedImageId; var selectedBlackTextImage; var visibleContentBlock; //Variables used by the login dialog.// var isDisplayingLogin = false; //Login information.// var isLoggedIn = false; var canDownloadPresentationBrief = false; var userName = 0; // // Initializes the main view. // function init() { checkLogin(240000); } // // Sends a ping to the server on a regular basis to prevent loss of the session and to check the logged in status of the user. // Updates the logLink to display Log In or Log Out depending on the login state. // interval: The time increment between pings to the server, in milliseconds. // function checkLogin(interval) { var url = "/PingController.java"; var httpRequest = null; if(window.XMLHttpRequest) { httpRequest = new XMLHttpRequest(); } else if(window.ActiveXObject) { httpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } else { return; } if(httpRequest != null) { httpRequest.onreadystatechange = function() { if(httpRequest.readyState == 4) { if((httpRequest.status == 200) || (httpRequest.status == 0)) { if(httpRequest.responseText != "" && !isLoggedIn) { document.getElementById("logLink").innerHTML = "Log Out"; isLoggedIn = true; if(httpRequest.responseText != userName) { userName = httpRequest.responseText; document.getElementById("welcomeSpan").innerHTML = "Logged in as: " + userName; } } else if(httpRequest.responseText == "" && isLoggedIn) { document.getElementById("logLink").innerHTML = "Log In"; document.getElementById("welcomeSpan").innerHTML = ""; isLoggedIn = false; } if(interval > 0) { setTimeout("checkLogin('" + interval + "')", interval); } } } } httpRequest.open("POST",url,true); httpRequest.send(null); } } // // Called by the login link at the top of the main page. // Displays the login dialog. // function showLogin() { var loginDiv = document.getElementById('loginDiv'); var changePasswordDiv = document.getElementById('changePasswordDiv'); var resetPasswordDiv = document.getElementById('resetPasswordDiv'); var resetPasswordSuccessDiv = document.getElementById('resetPasswordSuccessDiv'); var emailNotValidatedDiv = document.getElementById('emailNotValidatedDiv'); var validationEmailResentDiv = document.getElementById('validationEmailResentDiv'); var errorTextControl = document.getElementById("errorText"); loginDiv.style.display = 'block'; loginDiv.style.visibility = 'visible'; changePasswordDiv.style.display = 'none'; changePasswordDiv.style.visibility = 'hidden'; resetPasswordDiv.style.display = 'none'; resetPasswordDiv.style.visibility = 'hidden'; resetPasswordSuccessDiv.style.display = 'none'; resetPasswordSuccessDiv.style.visibility = 'hidden'; emailNotValidatedDiv.style.display = 'none'; emailNotValidatedDiv.style.visibility = 'hidden'; validationEmailResentDiv.style.display = 'none'; validationEmailResentDiv.style.visibility = 'hidden'; displayDialog("dialogBackground", "loginDialog"); var focusComponent = document.getElementById("userNameInput"); if(focusComponent != null) { focusComponent.focus(); if(focusComponent.type != null && focusComponent.type == "text") { focusComponent.select(); } } if(errorTextControl) { errorTextControl.innerHTML = ""; errorTextControl.style.visibility = "hidden"; errorTextControl.style.display = "block"; } } // // Switches between visible components. // fromComponentId: The component ID that will become invisible. // toComponentId: The component ID that will become visible. // focusComponentId: The component ID that will gain focus. // fade: Whether a fade should occur. This should be non-null if true. function switchComponents(fromComponentId, toComponentId, focusComponentId, fade) { var errorText = document.getElementById("errorText"); if(errorText) { errorText.innerHTML = ""; errorText.style.visibility = "hidden"; } replaceFade(fromComponentId, fade ? userContentFadeOut : 0, 5, toComponentId, fade ? userContentFadeIn : 0, 5, focusComponentId); } // // Called by the mouse over and out functions of the images and text associated with the main menu items. // function mainMenuRollover(textImageId, imageUrl) { if(selectedTextId != textImageId) { document.getElementById(textImageId).src = imageUrl; }//if// }//mainMenuRollover()// // // Opens terms of use for the site. // function openTermsOfUse() { var w = window.open('/legal/TermsOfUse.txt', 'Terms of Use', 'width=800,height=700,status,scrollbars,resizable'); w.focus(); } // // Opens privacy policy for the site. // function openPrivacyPolicy() { var w = window.open('/legal/PrivacyPolicy.txt', 'Privacy Policy', 'width=800,height=700,status,scrollbars,resizable'); w.focus(); } // // Opens a window to send a message to the company. // function contactUsClicked() { var w = window.open('/secure/ContactUsViewController.java', 'ContactUsEditor', 'width=800,height=700,status,scrollbars,resizable'); w.focus(); } // // Sets the error text element. The error text element is currently only used by the login view portion. // function setErrorText(errorText) { var errorTextControl = document.getElementById("errorText"); if(errorTextControl) { errorTextControl.innerHTML = errorText; errorTextControl.style.visibility = "visible"; } } // // Clears the error text element. The error text element is currently only used by the login view portion. // function clearErrorText() { var errorTextControl = document.getElementById("errorText"); if(errorTextControl) { errorTextControl.innerHTML = ""; errorTextControl.style.visibility = "hidden"; } } // // Sends the login form data to the server. // function sendLoginForm(form, successPathName) { var changePassword = form.changePasswordCheckbox && form.changePasswordCheckbox.checked; var anonymous = form.anonymousLoginCheckbox && form.anonymousLoginCheckbox.checked; if(!successPathName) { successPathName = "/secure/authenticated/index.html"; } if(anonymous || validateLoginForm(form)) { var login = form.userNameInput.value; var password = form.userPasswordInput.value; sendLoginData(login, password, changePassword anonymous, successPathName); } } // // Sends the login data to the server. // function sendLoginData(login, password, changePassword, anonymous, successPathName) { var url; var request = null; if(!successPathName) { successPathName = "/secure/authenticated/index.html"; } if(anonymous) { url = "/secure/LoginController.java?login=" + encodeURIComponent("anonymous"); } else { url = "/secure/LoginController.java?login=" + encodeURIComponent(login) + "&password=" + encodeURIComponent(password) + "&changePassword=" + encodeURIComponent(changePassword ? "true" : "false"); } if(window.XMLHttpRequest) { request = new XMLHttpRequest(); } else if(window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); } else { return; } if(request != null) { request.open("POST", url, false); request.send(null); if((request.status == 200) || (request.status == 0)) { if(request.responseText.indexOf("success") == 0) { //Load the logged in page.// location.pathname = successPathName; } else if(request.responseText.indexOf("change-password") == 0) { switchComponents('loginDiv', 'changePasswordDiv', 'newPasswordInput'); document.getElementById('oldPasswordHiddenInput').value = password; document.getElementById('userLoginHiddenInput').value = login; } else if(request.responseText.indexOf("email-not-validated") == 0) { switchComponents('loginDiv', 'emailNotValidatedDiv', 'userEmailAddressInput'); //The response text will be followed by the user id and then the user's email address separated by colons.// document.getElementById("revalidateEmailForm").userIdInput.value = request.responseText.substring(request.responseText.indexOf(":") + 1, request.responseText.lastIndexOf(":")); document.getElementById("revalidateEmailForm").userEmailAddressInput.value = request.responseText.substring(request.responseText.lastIndexOf(":") + 1, request.responseText.length); clearErrorText(); } else { //Unexpected: For now just show a bad login.// if(anonymous) { setErrorText("Anonymous login failed for an unknown reason."); } else { setErrorText("Invalid login name or password."); } } } else { //Show the error text to the user: bad login.// if(anonymous) { setErrorText("Anonymous login failed for an unknown reason."); } else { setErrorText("Invalid login name or password."); } } } } // // Validates the login form. // function validateLoginForm(form) { var login = form.login.value; var password = form.password.value; var errorText = document.getElementById("errorText"); if(login == null) { setErrorText("A login and password must first be provided."); return false; } else if(login.toLowerCase() == "anonymous") { setErrorText("Anonymous is not a valid login name."); return false; } else { return true; } } // // Sends the change password form data to the server. // function sendChangePasswordForm(form, successPathName) { var login = form.userLoginHiddenInput.value; var oldPassword = form.oldPasswordHiddenInput.value; var newPassword = form.newPasswordInput.value; var url = "/secure/LoginController.java?login=" + encodeURIComponent(login) + "&password=" + encodeURIComponent(oldPassword) + "&newPassword=" + encodeURIComponent(newPassword); var request = null; var isNewPasswordValid = newPassword != null && newPassword.length >= 4; if(!successPathName) { successPathName = "/secure/authenticated/index.html"; } if(!isNewPasswordValid) { setErrorText("The password must be a minimum of 4 characters long."); } else { if(window.XMLHttpRequest) { request = new XMLHttpRequest(); } else if(window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); } else { return; } if(request != null) { request.open("POST", url, false); request.send(null); if((request.status == 200) || (request.status == 0)) { if(request.responseText == "success") { //Load the logged in page.// location.href = successPathName; } else if(request.responseText == "bad-password") { setErrorText("The password must be a minimum of 4 characters long."); } else if(request.responseText.indexOf("email-not-validated") == 0) { switchComponents('loginDiv', 'emailNotValidatedDiv', 'userEmailAddressInput'); //The response text will be followed by the user id and then the user's email address separated by colons.// document.getElementById("userIdInput").value=request.responseText.substring(request.responseText.indexOf(":") + 1, request.responseText.lastIndexOf(":")); document.getElementById("userEmailAddressInput").value=request.responseText.substring(request.responseText.lastIndexOf(":") + 1, request.responseText.length); clearErrorText(); } else { //Unexpected: For now just show a bad login.// setErrorText("Invalid login name or password."); } } else { //Show the error text to the user: bad login.// setErrorText("Invalid login name or password."); } } } } // // Sends the reset password form data to the server. // function sendResetPasswordForm(form) { if(validateResetPasswordForm(form)) { var login = form.resetPasswordUserNameInput.value; var email = form.resetPasswordEmailInput.value; var url = "/secure/ResetPasswordController.java?login=" + encodeURIComponent(login) + "&email=" + encodeURIComponent(email); var request = null; if(window.XMLHttpRequest) { request = new XMLHttpRequest(); } else if(window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); } else { return; } if(request != null) { request.open("POST", url, false); request.send(null); if((request.status == 200) || (request.status == 0)) { if(request.responseText == "success") { switchComponents('resetPasswordDiv', 'resetPasswordSuccessDiv', null); } else if(request.responseText.indexOf("bad-email") == 0) { setErrorText("Invalid email name."); } else if(request.responseText.indexOf("bad-login") == 0) { setErrorText("Invalid login address."); } else { //Unexpected: For now just show a bad data msg.// setErrorText("Invalid login name or email address."); } } else { //Show the error text to the user: bad data.// setErrorText("Invalid login name or email address."); } } } } // // Validates the reset password form. // function validateResetPasswordForm(form) { return true; } // // Requests a reminder email be sent to the address containing the user's login name. // function emailLoginName(emailAddress) { var url = "/secure/EmailLoginNameController.java?email=" + emailAddress; var request; if(window.XMLHttpRequest) { request = new XMLHttpRequest(); } else { request = new ActiveXObject("Microsoft.XMLHTTP"); } if(request != null) { request.open("POST", url, false); request.send(null); setErrorText("An email will be sent shorty containing your login name."); } } // // Sends the revalidate email request to the server. // function sendRevalidateEmailForm(form) { var email = form.userEmailAddressInput.value; var userId = form.userIdInput.value; var url; var request = null; if(email != null && email.length > 0) { var isEmailValid = validateNewUserEmail(email, false) == 0; if(isEmailValid) { clearErrorText(); url = "/secure/RevalidateEmailController.java?id=" + encodeURIComponent(userId) + "&email=" + encodeURIComponent(email); } else { setErrorText("A valid email address is required to validate the account."); } } else { clearErrorText(); url = "/secure/RevalidateEmailController.java?id=" + encodeURIComponent(userId); } if(url != null) { if(window.XMLHttpRequest) { request = new XMLHttpRequest(); } else if(window.ActiveXObject) { request = new ActiveXObject("Microsoft.XMLHTTP"); } else { return; } if(request != null) { request.onreadystatechange = function() { if(request.readyState == 4) { if((request.status == 200) || (request.status == 0)) { if(request.responseText == "success") { //Display the success message.// switchComponents('emailNotValidatedDiv', 'validationEmailResentDiv', null); clearErrorText(); } else if(request.responseText == "failed") { //Display a message indicating that the server is unable to send email at the moment.// setErrorText("The server is having a problem sending email at the moment. We appologize for the inconvience, please try again later."); } else { //Unexpected: For now just show a bad login.// setErrorText("The server is having a problem processing your request at this time. We appologize for the inconvience, please try again later."); } } else { //Show the error text to the user: bad login.// setErrorText("The server is having a problem processing your request at this time. We appologize for the inconvience, please try again later."); } } } request.open("POST", url, true); request.send(null); } } } // // // BEGIN DIALOG CODE // // var visibleDialog = null; var visibleBackground = null; var oldResizeHandler = null; var dialogOffsetMetrics = null; var dialogOffsetNumber = null; // // Displays the given dialog with the given background panel. // backgroundId: The optional identifier for the background panel being used. // dialogId: The non-optional identifier of the dialog being displayed. // verticalOffset: The pixel offset from the top of the window to the top of the dialog. This may be a percent, in which case it is the percent of the window not taken by the dialog that occurs between the dialog top and the window top. Example: 10px, 10%. // function displayDialog(backgroundId, dialogId, verticalOffset) { var offsetRegex = /(\d+)(px|%)?/i; var regexResults = verticalOffset == null ? null : offsetRegex.exec(verticalOffset); if(regexResults != null) { dialogOffsetNumber = regexResults[1]; dialogOffsetMetrics = regexResults[2]; } else { dialogOffsetNumber = 33; dialogOffsetMetrics = "%"; } hideDialog(); visibleDialog = document.getElementById(dialogId); if(backgroundId != null) { visibleBackground = document.getElementById(backgroundId); visibleBackground.style.display = "block"; visibleBackground.style.visibility = "visible"; } else { visibleBackground = null; } //Make the dialog visible.// visibleDialog.style.display = "block"; visibleDialog.style.visibility = "visible"; //Size things.// oldResizeHandler = window.onresize; window.onresize = resizeWindow; resizeWindow(); } function hideDialog() { if(visibleDialog) { if(visibleBackground) { visibleBackground.style.display = "none"; visibleBackground.style.visibility = "hidden"; visibleBackground = null; } visibleDialog.style.display = "none"; visibleDialog.style.visibility = "hidden"; visibleDialog = null; window.onresize = oldResizeHandler; oldResizeHandler = null; } } function resizeWindow() { if(visibleDialog) { var windowHeight = 0; var windowWidth = 0; if(navigator.appName.indexOf("Microsoft") != -1) { var htmlHeight = document.body.parentNode.clientHeight; windowHeight = htmlHeight < window.screen.height ? htmlHeight : window.screen.height; //document.body.offsetHeight; //alert("window height:" + windowHeight + "; html height:" + htmlHeight + "; offset height:" + document.body.offsetHeight); windowWidth = document.body.offsetWidth; } else { windowHeight = window.innerHeight; windowWidth = window.innerWidth; } //alert(windowHeight + " " + windowWidth + " " + visibleDialog.clientHeight + " " + visibleDialog.clientWidth); var boundingRect = visibleDialog.getBoundingClientRect(); if(visibleBackground) { visibleBackground.style.top = 0; visibleBackground.style.left = 0; visibleBackground.style.bottom = windowHeight; visibleBackground.style.right = windowWidth; visibleBackground.style.height = windowHeight; visibleBackground.style.width = windowWidth; } if(dialogOffsetMetrics == "%") { visibleDialog.style.top = Math.round(((windowHeight - visibleDialog.clientHeight) / 100) * dialogOffsetNumber) + "px"; } else { visibleDialog.style.top = dialogOffsetNumber; } //Always center on the horizontal axis.// visibleDialog.style.left = Math.round((windowWidth - visibleDialog.clientWidth) / 2) + "px"; } if(oldResizeHandler) { oldResizeHandler(); } } // // // END DIALOG CODE // //