function DoLoginOnNewline(frm)
{
	// If the key pressed wasn't newline, then ignore it
	// and pass it through.
	if (event.keyCode != 13)
		return true;

	// If the form validated, do the login.
	if (ValidateForm(frm, document.all.login))
		frm.submit();

	return false;
}

function ForgotPassword(frm, elemClicked)
{
	frm.requestType.value = elemClicked.title;

	if (frm.username.value == "")
	{
		alert("To retrieve you password, you must first enter your username.");
		FocusIfExists(frm.username);
		return false;
	}

	if (!IsValidEmail(frm.username.value))
	{
		alert("To retrieve you password, you must first enter your username\n" +
			  "and it must be a valid email address, e.g. peter@example.com or jo@no.mail.");
		FocusIfExists(document.frm.username);
		return false;
	}

	return true;
}

function ValidateForm(frm, elemClicked)
{
	frm.requestType.value = elemClicked.title;

	var errors = "";
	if (frm.username.value == "")
		errors += "\nEmail Address is required.";
	else if (!IsValidEmail(frm.username.value))
		errors += "\nEmail Address is invalid.";

	if (frm.password.value == "")
		errors += "\nPassword is required.";

	if (errors != "")
		alert("The following error(s) have occured:\n" + errors);

	return (errors == "");
}
