function XMLHttp()
{
	function Result(status, responseText)
	{
		this.status = status;
		this.responseText = responseText;
	}
	
	this.id = XMLHttp.Objects.length;
	XMLHttp.Objects[this.id] = this;
	
	this.xmlHttp = null;
	this.responseText = "";
	this.status = 0;
	
	this.results = new Array();
	
	this.request = function(method, url, async, data, onSuccessHandler, onFailHandler, user, password)
	{
		if(this.xmlHttp==null)
			throw new Error("xmlHttp is null.");
		
		if(user==null)
			this.xmlHttp.open(method, url, async);
		else
			this.xmlHttp.open(method, url, async, user, password);
		
		if(async)
		{
			this.onSuccess = onSuccessHandler;
			this.onFail = onFailHandler;
		}
		
		switch(method.toLowerCase())
		{
			case "get":
			case "head":
				this.xmlHttp.send(null);
				break;
			case "post":
				this.xmlHttp.send(data);
				break;
		}
		
		if(async)
			return null;
		else
		{
			this.status = this.xmlHttp.status;
			this.responseText = this.xmlHttp.responseText;
			return new Result(this.status, this.responseText);
		}
	}
	
	try
	{
		if(window.XMLHttpRequest)
		{
			this.xmlHttp = new XMLHttpRequest();
			// ÀÏºÎÀÇ ¸ðÁú¶ó ¹öÀüÀ»Àº readyState property, 
			// onreadystate event¸¦ Áö¿øÇÏÁö ¾ÊÀ¸¹Ç·Î. - from xmlextrs
			if(this.xmlHttp.readyState == null)
			{
				this.xmlHttp.readyState = 1;
				this.xmlHttp.addEventListener("load", function() {
						this.xmlHttp.readyState = 4;
						this.xmlHttp.onreadystatechange();
					}, false);
			}
		}
		
		if(this.xmlHttp==null)
		{
			try
			{
				this.xmlXhttp = new ActiveXObject("MSXML2.XMLHTTP");
			}
			catch(e)
			{
			}
		}
		
		if(this.xmlHttp==null)
		{
			try
			{
				this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
			}
		}

		
		if(this.xmlHttp==null)
		{
			if(window.createRequest)
			{
				try
				{
					this.xmlHttp = window.createRequest();
				}
				catch(e)
				{
				}
			}
		}
		
		
		if(this.xmlHttp==null)
			throw new Error("Can't create XMLHTTP object.");
		
	}
	catch(e)
	{
		throw new Error("Can't create XMLHTTP object.");
	}
	
	this.onSuccess = function(result) {};
	this.onFail = function(result) {}
	
	eval("this.xmlHttp.onreadystatechange = function ()\n"
		+"{\n"
		+"	var obj = XMLHttp.Objects["+this.id+"];\n"
		+"	if(obj.xmlHttp.readyState == 4)\n"
		+"	{\n"
		+"		if(obj.xmlHttp.status == 200)\n"
		+"		{\n"
		+"			obj.status = obj.xmlHttp.status;\n"
		+"			obj.responseText = obj.xmlHttp.responseText;\n"
		+"			obj.onSuccess(new Result(obj.status, obj.responseText));\n"
		+"		}\n"
		+"		else\n"
		+"		{\n"
		+"			obj.status = obj.xmlHttp.status;\n"
		+"			obj.responseText = obj.xmlHttp.responseText;\n"
		+"			obj.onFail(new Result(obj.status, obj.responseText));\n"
		+"		}\n"
		+"	}\n"
		+"}\n");
	
}
XMLHttp.Objects = new Array();



/*




// È£Ãâ ¹æ¹ý
// method, url, async, data, onSuccessHandler, onFailHandler, user, password
// method : "GET", "POST", "HEAD"
// url : È£Ãâ ÁÖ¼Ò
// async : ºñµ¿±â È£Ãâ ¿©ºÎ. true ÀÏ ¶§ ºñµ¿±â È£Ãâ, false ÀÏ ¶§ µ¿±â È£Ãâ
// onSuccessHandler : ºñµ¿±â È£Ãâ ½Ã ¼º°ø ÀÌº¥Æ® ¼ö½Å ÇÚµé·¯
// onFailHandler : ºñµ¿±â È£Ãâ ½Ã ½ÇÆÐ ÀÌº¥Æ® ¼ö½Å ÇÚµé·¯
// user : ÀÎÁõ½Ã »ç¿ëÀÚ ¾ÆÀÌµð.
// password : ÀÎÁõ½Ã »ç¿ëÀÚ ¾ÏÈ£

var ret = null;




// ºñµ¿±â È£Ãâ
function onSuccess(result)
{
	alert("status="+result.status+"\n\nresponseText="+result.responseText);
}

function onFail(result)
{
	alert("status="+result.status+"\n\nresponseText="+result.responseText);
}

var xmlHttp = new XMLHttp();
XMLHttp.request("get", "ajax_service.asp", true, null, onSuccess, onFail, null, null);

// ¾à½Ä È£Ãâ : XMLHttp.request("get", "ajx_service.asp", true, null, onSuccess, onFail); (ÀÎÁõÀÌ ÇÊ¿äÇÏÁö ¾ÊÀ¸¹Ç·Î user, password ÀÎÀÚ¿¡¼­ Á¦¿Ü)





// µ¿±â È£Ãâ : return °ªÀ¸·Î µ¥ÀÌÅÍ°¡ µ¹¾Æ¿Â´Ù.
ret = XMLHttp.request("get", "ajax_service.asp", false, null, onSuccess, onFail, null, null);
if(ret.status == 200)
	; // ¼º°ø
else
	; // ½ÇÆÐ

// ¾à½Ä È£Ãâ : ret = XMLHttp.request("get", "ajax_service.asp", false); (ÀÎÁõ ÇÊ¿ä¾øÀ½. ÀÌº¥Æ® ¼ö½Å ÇÚµé·¯ ÇÊ¿ä¾øÀ½)





*/

