/*
function postlist_joinKeyDown(e) {
	if(!e) e = window.event;
	var self = e.srcElement;
	if(! self) self = e.target;
	if(! self) return false;

	if(e.keyCode == 13) {
		return postlist_joinList();
	}
	return true;
}
*/
function postlist_joinList(form) {
	var fields = ['email','firstName','lastName','FK_postlist_group','address','postCode','postOffice'];
	var postData = "";
	for(var i in fields) {
		var el = form["postlist-"+fields[i]];
		if(el) {
			postData += "&postlist-"+fields[i]+"="+encodeURIComponent(el.value);
		}
	}
	var func = common_createBoundedWrapper(form, postlist_callback);
	sendXMLHttp("POST", "index.php?action=postlist&postlist-action=joinList&postlist-ajax=1"+postData, func, "0");
	return false;
}

/*
function postlist_resignList() {
	var el = document.getElementById("postlist_joinBox");
	var email = el.value;
	sendXMLHttp("POST", "index.php?action=postlist&postlist-action=resignList&postlist-email="+email, postlist_resignCallback, "0");
	return false;
}
*/

function postlist_callback(xmlResponse, param) {
	if(xmlResponse.responseText) {
		try {
			eval("var response = " + xmlResponse.responseText);
		} catch(e) {
			alert(e);
			return;
		}
		if(response) {
			if(response.message) {
				if(response.success) {
					response.message = response.message.replace(/\n/gi, "<br>");
					this.innerHTML = response.message;
				} else {
					alert(response.message);
				}
			}
		}
	}
}
