function getHTTPObject() {
	var xmlhttp = false;
	if (typeof XMLHttpRequest != 'undefined') {
		try {
			xmlhttp = new XMLHttpRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	return xmlhttp;
}

function login(target, failCallback) {
	var username = $("username").value;
	var password = $("password").value;
	var http = getHTTPObject();
	var status = 0;
	// var url = "http://" + username + ":" + password + "@" +
	// this.action.substr(7);
	var url = target;
	if (!username || !password) {
		failCallback();
		return false;
	}
	http.open("get", url + '?n=' + username + '&w=' + password, false);
	http.send("");
	if (200 != http.status) {
		failCallback();
		return false;
	}
	http.open("get", url, true, username, password);
	http.onreadystatechange = function() {
		if (http.readyState >= 2) {
			if (target) {
				status = http.status;
				if (status == 200) {
					document.location = target;
				} else {
					failCallback();
				}
				target = null;
			}
		}
	}
	http.send("");
	return false;
}

function logout() {
	var http = getHTTPObject();
	http.open("get", this.parentNode.action, false, "null", "null");
	http.send("");
	alert("You have been logged out.");
	return false;
}
