function getElementValue(element) {
	switch(element.type) {
		case 'text':
		case 'hidden':
		case 'password':
			return element.value;
		case 'checkbox':
			return (element.checked ? element.value : '');
	}
}

function login(thisForm) {
	var returnVal = true;

	try {
		//set JavascriptEnabled to 1 to indicate to the processing page that it is called through AJAX
		thisForm.AJAX.value = '1';

		var postContent = '';
		var element;
		for (var i = 0; i < thisForm.elements.length; i++)
		{
			element = thisForm.elements[i];
			if(element.name) {
				postContent = postContent + ((postContent != '') ? '&': '?');
				postContent = postContent + element.name + '=' + escape(getElementValue(element));
			}
		}

		var loginResult = loadXMLDoc(thisForm.action, false, postContent);

		var successfulLogin = eval(loginResult.toLowerCase());
		if(successfulLogin)
			location.replace(thisForm.redirectToAfterLogin.value);
		else
			alert('Invalid username or password. Please try again.');

		returnVal = false;
	} catch(e) {
		//alert("Error:\n" + e.description);
	}
	//if there was any errors:
	
	//set JavascriptEnabled to 0 to indicate to the processing page that it is being called normally
	thisForm.AJAX.value = '0';

	//submit the form normally
	return returnVal;
}