﻿/**
 * 클래스명 : XmlHttp()
 * 기    능 : XML HTTP REQUEST
 * 작 성 일 : 2007.04.19, 이지미디어, 정원광
 *
 */
XmlHttp = function (req, url, hdr, param) {
	this.Xml = null;
	this.Ver = ["MSXML2.XMLHttp.7.0", "MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp"];
	this.Req = req;
	this.Url = url;
	this.Hdr = hdr;
	this.Msg = "";

	// 객체 구하기
	if (window.XMLHttpRequest) {
		this.Xml = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		for (var i = 0; i < this.Ver.length; i++) {
			try {
				this.Xml = new ActiveXObject(this.Ver[i]);
				break;
			} catch (e) {
			}
		}
	}

	// 실행 (기본)
	this.Init = function () {
		this.Xml.open(this.Req, this.Url, false);

		if (this.Hdr.length > 0) {
			this.Xml.setRequestHeader(this.Hdr[0], this.Hdr[1]);
		}

		this.Xml.send(param);

		if (this.Xml.readyState == 4) {
			if (this.Xml.status == 200) {
				this.Msg = this.Xml.responseText;
			}
		}
	}

	// 객체 읽기
	this.Read = function () {
		return this.Xml;
	}

	// 열기
	this.Open = function (req, url, sync) {
		this.Xml.open(req, url, sync);
	}

	// 전송
	this.Send = function () {
		this.Xml.send(null);
	}
}