<!--
                ////////////////////////////////////////////////////////////////////////
                // This function prevents the submission of the form when users press
                // the enter key and instead it calls the isEmpty function.
                ////////////////////////////////////////////////////////////////////////
                function screenkey(e)
                        {
                                // here we check if the key pressed is enter
                                var whichCode = (window.Event) ? e.which : e.keyCode;
                                if ( whichCode == "13" )
                                        {
                                                // if the key pressed is enter, we don't submit the form
                                                // and instead trigger the validation function called
                                                // "isEmpty()"
                                                e.cancelBubble = true;
                                e.returnValue = false;
                                                isEmpty();
                                        }
                                return;
                        }
                ////////////////////////////////////////////////////////////////////////


                ////////////////////////////////////////////////////////////////////////
                // This function displays an error message for the empty fields as well
                // as turning the field label red and colouring the field itself
                ////////////////////////////////////////////////////////////////////////
                function makeError(fieldLabel, field, errorMessage)
                        {
                                // first, we assign the elements to variable so we can handle
                                // them elegantly
                                var fieldLabel = document.getElementById(fieldLabel);
                                var field = document.getElementById(field);
                                var errorMessage = document.getElementById(errorMessage);

                                // colour the username field label
                                fieldLabel.className="error";

                                // show the error message for empty username field
                                errorMessage.style.display="block";

                                // colour the empty field
                                field.style.background="#ffc";

                                // position the cursor on the empty field
                                field.focus();
                        }
                ////////////////////////////////////////////////////////////////////////


                ////////////////////////////////////////////////////////////////////////
                // This function removes the error message for the empty fields as well
                // as removing the red field label and colouring the field
                ////////////////////////////////////////////////////////////////////////
                function makeOkay(fieldLabel, field, errorMessage)
                        {
                                // firts, we assign the elements to variable so we can handle
                                // them elegantly
                                var fieldLabel = document.getElementById(fieldLabel);
                                var errorMessage = document.getElementById(errorMessage);
                                var field = document.getElementById(field);

                                // de-colour the empty field label
                                fieldLabel.className="okay";

                                // hide the error message
                                errorMessage.style.display="none";

                                // de-colour the empty field
                                field.style.background="#fff";
                        }
                ////////////////////////////////////////////////////////////////////////


                ////////////////////////////////////////////////////////////////////////
                // This function checks for empty fields and calls makeError when a
                // field is empty and it calls makeOkay when an empty filled has been
                // corrected.
                ////////////////////////////////////////////////////////////////////////
                function isEmpty()
                        {
                                // here we assign the values of the fields to variables
                                var user = document.getElementById("user").value;
                                var pass = document.getElementById("pass").value;

                                // checking if the username field is empty
                                if (user == "")
                                        {
                                                // if the username field is empty, we call the makeError
                                                // function for the username field
                                                makeError("userLabel", "user", "errorMessageUser");

                                                // checking if the password field is not empty when the
                                                // username field is. This is used to turn off previously
                                                // triggered errors upon corrected state.
                                                if (pass != "")
                                                        {
                                                                makeOkay("passLabel", "pass", "errorMessagePass");
                                                        }

                                        }

                                // if the password field is empty, we call the makeError function
                                // for the username field.
                                else if (pass == "")
                                        {
                                                makeError("passLabel", "pass", "errorMessagePass");

                                                // checking if the username field is not empty when the
                                                // password field is this is used to turn off previously
                                                // triggered errors upon corrected state
                                                if (user != "")
                                                        {
                                                                makeOkay("userLabel", "user", "errorMessageUser");
                                                        }
                                        }

                                // if both fields have something in them, then proceed with
                                // finding out if there is and @ symbol in the username
                                else { isWellFormatted() }

                        }
                ////////////////////////////////////////////////////////////////////////


                ////////////////////////////////////////////////////////////////////////
                // This function checks if there is an @ symbol in the username. If
                // it finds one, it leaves the username alone and calls the function
                // submitForm. If it doesn't find one, it calls the function appendDomain.
                ////////////////////////////////////////////////////////////////////////
                function isWellFormatted()
                        {
                                // assign the content of the username field to a variable
                                var user = document.getElementById("user").value;

                                // assign indexOf value to a variable
                                hasAt = user.indexOf('@');

                                // check to see if there is an @ symbol in the content of the
                                // username
                                if (hasAt != "-1")
                                        {
                                                // there is an @ in the username
                                                // then, all we do here is we call the submitForm function
                                                submitForm(user, user);
                                        }
                                else
                                        {
                                                // there isn't an @ in the username
                                                // then, we have to call the function that appends the
                                                // domain to the username when we call it, we will pass
                                                // the username value we got using this function
                                                appendDomain(user);
                                        }
                        }
                ////////////////////////////////////////////////////////////////////////


                ////////////////////////////////////////////////////////////////////////
                // This function appends the domain as defiend in the domain variable
                // to the username value. Then, it calls the function  submitForm
                ////////////////////////////////////////////////////////////////////////
                function appendDomain(user)
                        {
                                // here we concatenate the username and the domain values
                                var emailAddress =  user + domain;

                                // and now we are ready to submit the form
                                submitForm(emailAddress, user);
                        }
                ////////////////////////////////////////////////////////////////////////


                ////////////////////////////////////////////////////////////////////////
                // This function appends the domain as defiend in the domain variable
                // to the username value. Then, it calls the function  submitForm
                ////////////////////////////////////////////////////////////////////////
                function submitForm(emailAddress, user)
                        {

                                // the value of the username field is changed to the new
                                // username@domain value
                                document.getElementById("user").value = emailAddress;

                                // form is submitted
                                document.login.submit();

                                // once the form is submitted, we reset the username field value
                                // to what the user entered originally, so there's no visual
                                // confusion.
                                document.getElementById("user").value = user;
                        }
                ////////////////////////////////////////////////////////////////////////

-->
