<!--
var debugEngine = false;

function Engine()
{
	this.xmlhttp = false;
	this.type = null;
	this.src = null;
	this.param = null;
	this.exec = null;
	this.ifrcnt = 0;
	this.iswait = false; //동시에 두개가 호출되었다면

	/*
	* AJAX 기본 클래스 함수
	* type : GET, AGET, POST, IPOST, IGET
	* GET : 동기식 GET (비추천)
	AGET : 비동기식 GET형 (추천)
	POST : 비동기식 POST형 (추천)
	IPOST : 동기식 IFRAME 형 (비추천)
	IGET : 동기식 GET형 (비추천)
	* src : URL
	* param : POST방식에서 사용됨
	* exec : 리턴할 함수명
	*/
	this.execute = function(type, src, param, exec)
	{
		//alert('type : '+type+' src : '+ src+' param : '+param + 'exec : '+ exec);
		this.type = type;
		this.src = src;
		this.param = param;
		this.exec = exec;
		this.getXmlHttpRequest();
		this.iswait = true;

		try
		{
			return this._execute();			
		}
		catch (e)
		{
			this.errorHandle('데이터에 접근할 수 없습니다.'+e);
		}
	}

	this.getXmlHttpRequest = function()
	{
		if(this.iswait == true)
		{
			setTimeout("engine.getXmlHttpRequest();",200);
			return;
		}
		else
		{
			if(window.XMLHttpRequest)
			{
				 // If IE7, Mozilla, Safari, etc: Use native object
				this.xmlhttp = new XMLHttpRequest();
			}
			else if (window.ActiveXObject && !(navigator.userAgent.indexOf('Mac') >= 0 && navigator.userAgent.indexOf("MSIE") >= 0))
			{
				// ...otherwise, use the ActiveX control for IE5.x and IE6
				this.xmlhttp = this._ActiveXObject(["Microsoft.XMLHTTP","MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP"]);
			}
		}
	}


	this._ActiveXObject = function (axarray)
	{
		var returnValue;

		for (var i = 0; i < axarray.length; i++)
		{
			try
			{
				return returnValue = new ActiveXObject(axarray[i]);
			}
			catch (e)
			{
				return null;
			}
		}

		try {
			return new XMLHttpRequest();
		}
		catch (e) {
			return null;
		}
		
		return this.errorHandle("This userAgent isn't support HTTP request");
	}



	// GET, AGET, POST 형식
	this._execute = function()
	{
		if(this.type == 'GET' || this.type == 'AGET')
		{
			this.xmlhttp.open("GET",this.src, this.type == 'GET' ? false : true);
		}
		else if(this.type == 'POST')
		{
			this.xmlhttp.open("POST",this.src, true);
		}
		else if(this.type == 'IPOST' || this.type == 'IGET')
		{
			this._executeIFR();
			return;
		}
		

		this.xmlhttp.setRequestHeader("Content-type", this.type == 'POST' ? "application/x-www-form-urlencoded" : "text/xml");
		//this.xmlhttp.setRequestHeader("Cache-Control", "no-cache");
		//this.xmlhttp.setRequestHeader("Pragma", "no-cache");
		//this.xmlhttp.setRequestHeader("Referer", this.src);

		if(this.type == 'AGET' || this.type == 'POST') // 비동기식 GET, POST
		{
			this.xmlhttp.onreadystatechange = function()
			{
				if(engine.xmlhttp.readyState == 4)
				{
					if(engine.xmlhttp.status == 200)
					{
						var result = engine.xmlhttp.responseXML;
						engine.debugPrint(result);
						if(engine.exec) eval(engine.exec +'(result);');						
						engine.iswait = false;
					}
				}
			}

			if(this.type == 'AGET') this.xmlhttp.send(null);
			else if(this.type == 'POST') this.xmlhttp.send("info="+this.param);
		}
		else if(this.type == 'GET') // 동기식 GET
		{
			this.xmlhttp.send(null);

			if (this.xmlhttp.status == 200)
			{
				this.debugPrint();
				this.iswait = false;
				return ( this.xmlhttp.responseText );
			}
		}
	}


	// IFRAME 형식의 POST //
	this._executeIFR = function()
	{
		var idname = 'ul-ifr-no'+this.ifrcnt
		var xmlDiv = null; var xmlIfr = null; var xmlForm = null; var formInput = null;

		xmlDiv = document.createElement('div');
		if(debugEngine)
			xmlDiv.innerHTML = "<iframe frameborder='0' width='800' height='200' id='" + idname + "' name='" + idname + "'></iframe>";
		else
			xmlDiv.innerHTML = "<iframe frameborder='0' width='0' height='0' id='" + idname + "' name='" + idname + "'></iframe>";
		document.body.appendChild(xmlDiv);

		xmlIfr = document.getElementById(idname);
		xmlIfr.setAttribute('style', 'width:0px; height:0px; border:0px;');

		if(this.type == 'IPOST')
		{
			xmlForm = document.createElement('form');
			xmlForm.setAttribute('id', 'ul-form');
			xmlForm.setAttribute('action', this.src);
			xmlForm.setAttribute('target', idname);
			xmlForm.target = idname;
			xmlForm.setAttribute('method', 'post');

			formInput = document.createElement('input');
			formInput.setAttribute('type', 'hidden');
			formInput.setAttribute('name', 'info');
			formInput.setAttribute('value', this.param);
			xmlForm.appendChild(formInput);

			document.body.appendChild(xmlForm);
			xmlForm.submit();
		}
		else if(this.type == 'IGET')
		{
			xmlIfr.src = this.src;
			document.body.appendChild(xmlIfr);
		}
		this.ifrcnt++;
	}

	// 에러핸들러
	this.errorHandle = function(code)
	{
		alert(code);
	}
		// Debug //
	this.debugPrint = function(value)
	{
		if(debugEngine == 'div')
		{
		}
		else if(debugEngine == 'alert')
			alert(value);
		else
			return;
	}

}
-->