/************************************************************
 *
 * Copyright (c) 2005 Brian T. Kelley. All Rights Reserved.
 *
 ***********************************************************/

function logInPasswordKeyPress(e) {
	var key = (e.charCode) ? (e.charCode) : ((e.which) ? (e.which) : (e.keyCode));
	if(key == 13)
		validateCredentials();
} // function logInPasswordKeyPress(e)

function validateCredentials() {
	var username = new String(document.getElementById("LogIn_Username").value);
	var password = new String(document.getElementById("LogIn_Password").value);
	
	username = xmlEncode(username);
	password = xmlEncode(password);
	
	var args = ["username", username, "password", password];
	loadXmlDocument("", "Security", "Authenticate", args, validateLogInRequest);
} // function validateCredentials()

function validateLogInRequest() {
	if(req.readyState == 4) {
		var errorLabel = document.getElementById("LogIn_Error");
		if(req.status == 200) {
			// If we do not have a WebUser object, then the user is invalid.
			if(req.responseXML.getElementsByTagName("WebUser")[0] == null)
				errorLabel.style.display = "inline";
			else {
				errorLabel.style.display = "none";
				__doPostBack('LogIn$Submit','');
			} // else
		} // if
		else {
			errorLabel.innerHTML = "There was an error communicating with the server.<br /><br />";
			errorLabel.style.display = "inline";
			__doPostBack('LogIn$Submit','');
		} // else
	} // if
} // function validateLogInRequest()
