function AJAXConnector()
{
  this.XmlHttp = this.GetHttpObject();
}
 
AJAXConnector.prototype.GetHttpObject = function()
{ 
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
  {
    try 
    {
      xmlhttp = new XMLHttpRequest();
    }
     catch (e) 
     {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
 
AJAXConnector.prototype.DoCallBack = function(requestURL, elementID, queryString)
{
   if( this.XmlHttp )
  {
    if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
    {
      var oThis = this;
      //this.XmlHttp.open('get', requestURL +"?"+ queryString, true);
      this.XmlHttp.open('post', requestURL, true);
      this.XmlHttp.onreadystatechange = function(){ oThis.ReadyStateChange(elementID, 1); };
      this.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
      this.XmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;?charset=euc-kr");
      
      this.XmlHttp.send(queryString);
    }
  }
}
 
 AJAXConnector.prototype.DoCallBackReturnValue=function(requestURL, queryString)
 {
	  if( this.XmlHttp )
	{
		if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
		{
			var oThis = this;
			//this.XmlHttp.open('get', requestURL +"?"+ queryString, true);
			this.XmlHttp.open('post', requestURL, true);
			this.XmlHttp.onreadystatechange = function(){ oThis.ReadyStateChange("dataOnly", 2); };
      		this.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			this.XmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;?charset=euc-kr");
			this.XmlHttp.send(queryString);
		}
	}
 }

AJAXConnector.prototype.DoCallBackReturnCustom=function(requestURL, queryString, returnMethod)
 {
	  if( this.XmlHttp )
	{
		if( this.XmlHttp.readyState == 4 || this.XmlHttp.readyState == 0 )
		{
			var oThis = this;
			//this.XmlHttp.open('get', requestURL +"?"+ queryString, true);
			this.XmlHttp.open('post', requestURL, true);
			this.XmlHttp.onreadystatechange = function(){ oThis.ReadyStateChange(returnMethod, 3); };
			this.XmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			this.XmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;?charset=euc-kr");
			this.XmlHttp.send(queryString);
		}
	}
 }

AJAXConnector.prototype.AbortCallBack = function()
{
  if( this.XmlHttp )
    this.XmlHttp.abort();
}
 
AJAXConnector.prototype.OnLoading = function()
{
  // Loading
}
 
AJAXConnector.prototype.OnLoaded = function()
{
  // Loaded
}
 
AJAXConnector.prototype.OnInteractive = function()
{
  // Interactive
}
 
AJAXConnector.prototype.OnComplete = function(responseText, responseXml)
{
  // Complete
}
 
AJAXConnector.prototype.OnAbort = function()
{
  // Abort
}
 
AJAXConnector.prototype.OnError = function(status, statusText)
{
  // Error
  alert("AJAX½ÇÇàµµÁß ¿¹¿Ü°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù");
}
 
AJAXConnector.prototype.ReadyStateChange = function(elementID, returnedType)
{
  if( this.XmlHttp.readyState == 1 )
  {
    this.OnLoading();
  }
  else if( this.XmlHttp.readyState == 2 )
  {
    this.OnLoaded();
  }
  else if( this.XmlHttp.readyState == 3 )
  {
    this.OnInteractive();
  }
  else if( this.XmlHttp.readyState == 4 )
  {
    if( this.XmlHttp.status == 0 )
      this.OnAbort();
    else if( this.XmlHttp.status == 200 && this.XmlHttp.statusText == "OK" )
    {
		var self = this;
		var returnHTML=	this.XmlHttp.responseText;
		
		switch (returnedType)
		{
			case 1:
				var objElement;
				objElement=document.getElementById(elementID);
				objElement.innerHTML=returnHTML;
				break;
			case 2:
				ExecuteAJAXComplete(returnHTML);
				break;
			case 3:
				elementID.ExecuteAJAXComplete(returnHTML);
				//call(elementID(returnHTML));
				break;
		}
		
      this.OnComplete(this.XmlHttp.responseText, this.XmlHttp.responseXML);
    }
    else
    {
		var self = this;
		var returnHTML=	this.XmlHttp.responseText;
		
		switch (returnedType)
		{
			case 1:
				var objElement;
				objElement=document.getElementById(elementID);
				objElement.innerHTML=returnHTML;
				break;
			case 2:
				ExecuteAJAXComplete(returnHTML);
				break;
			case 3:
				elementID.ExecuteAJAXComplete(returnHTML);
				//call(elementID(returnHTML));
				 break;
		}
		
      this.OnError(this.XmlHttp.status, this.XmlHttp.statusText, this.XmlHttp.responseText);   
     }
  }
}

//AJAXConnector Section 
