
var xmlHttp = null;

function _openXmlHttp() {
	if(xmlHttp != null) {
		return;
	}
	if(window.XMLHttpRequest){
		xmlHttp = new XMLHttpRequest();
	} else {
		if(window.ActiveXObject){
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
}

function _sendXmlHttp(url, query, isAsync) {
	if(query != null) {
		xmlHttp.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
		xmlHttp.open("POST", url, isAsync);
	} else {
		xmlHttp.open("GET", url, isAsync);
	}
	xmlHttp.send(query);
}

function syncLoad(a,b){
	alert(a);
}

function _syncLoad(url, query) {
	_openXmlHttp();
	_sendXmlHttp(url, query, false);
	return xmlHttp.responseText;
}

function _asyncLoadHtml(url, query, id) {
	_openXmlHttp();
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			alert(xmlHttp.responseText);
			document.getElementById(id).innerHTML = xmlHttp.responseText;
		}
	}
	_sendXmlHttp(url, query, true);
}

function _asyncLoadText(url, query, id){
	_openXmlHttp();
	xmlHttp.onreadystatechange = function() {
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200){
			document.getElementById("resChkAjax").innerText = xmlHttp.responseText;
		}
	}
	_sendXmlHttp(url, query, true);
}
