function login(id, pass) {
	sendData ="action=login";
	sendData +="&username=" + id;
	sendData +="&passwd=" + pass;
	httpObj = createXMLHttpRequest(displayCommentData);
	if (httpObj) {
		httpObj.open("POST","servlet/login", false);
		httpObj.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8"); 
		httpObj.send(sendData);
		return httpObj.responseText;
	}
	return null;
}

function postComment(viewtype) {
	sendData ="comment=" + encodeURIComponent(document.getElementById("message").value);
	sendData +="&planid=" + document.getElementById("planid").value;
	sendData +="&parentid=" + document.getElementById("parentid").value;
	sendData +="&viewtype=" + viewtype;
	httpObj = createXMLHttpRequest(displayCommentData);
	if (httpObj) {
		httpObj.open("POST","bbsWriter.html",true);
		httpObj.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8"); 
		httpObj.send(sendData);
	}
	document.getElementById("message").value="";
}

function refleshComment(viewtype) {
	sendData ="planid=" + document.getElementById("planid").value;
	sendData +="&viewtype=" + viewtype;
	httpObj = createXMLHttpRequest(displayCommentData);
	if (httpObj) {
		httpObj.open("POST","bbsView.html",true);
		httpObj.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8"); 
		httpObj.send(sendData);
	}
}
function refleshInfo() {
	sendData ="planid=" + document.getElementById("planid").value;
	httpObj = createXMLHttpRequest(displayInfoData);
	if (httpObj) {
		httpObj.open("POST","treeinfo.html",true);
		httpObj.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8"); 
		httpObj.send(sendData);
	}
}

function displayCommentData() {
	if ((httpObj.readyState == 4) && (httpObj.status == 200)) {
		document.getElementById("com").innerHTML = httpObj.responseText;
	} else {
		document.getElementById("com").innerHTML = "<b>please wait...</b>";
	}
}

function displayInfoData() {
	if ((httpObj.readyState == 4) && (httpObj.status == 200)) {
		document.getElementById("data").innerHTML = httpObj.responseText;
	} else {
		document.getElementById("data").innerHTML = "<b>please wait..</b>";
	}
}

function createXMLHttpRequest(cbFunc){
	var XMLhttpObject = null;
	try {
		XMLhttpObject = new XMLHttpRequest();
	} catch (e) {
		try {
			XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				return null;
			}
		}
	}
	if (XMLhttpObject) 
		XMLhttpObject.onreadystatechange = cbFunc;
	return XMLhttpObject;
}