if(typeof(HTTPD_REQUEST_INCLUDE) != "boolean") {
	HTTPD_REQUEST_INCLUDE = true;
    
    function Httpd()
	{    
	  this.Ip = "127.0.0.1";
	  this.Port = MASTERPORT;
	  this.Response = "";
	  this.listRequest = null; // new XMLHttpRequest();
	  this.askRequest = null;
	  this.lock = false;
	  this.requestArr = [];
    };
    
	function GetFreeRequest(me)
	{
		for(var i = 0;i<me.requestArr.length;i++)
		{
			if(!me.requestArr[i].busy)
			{
				return me.requestArr[i];
			}
		}
		me.requestArr.push({"obj":new XMLHttpRequest(), "busy":false});
		return me.requestArr[i];
	};
	
    Httpd.prototype.SetIp = function (ip){
        this.Ip = ip;
    };
    
	Httpd.prototype.SetPort = function(port)
	{
		this.Port = port;
	}
	
    Httpd.prototype.SendRequest = function (path, payload) {
		if(MASTER_REPORT_RETRY_COUNT >= MASTER_REPORT_RETRY_TIME)
			return null;
		try {
			var fileListOnServer = "http://" + this.Ip + ":" + this.Port + "/" + path;			
			var sth = $e('extention_plugin').post(fileListOnServer, payload);
			//dumpMsg(sth);
			MASTER_REPORT_RETRY_COUNT = 0;
			return sth;		
		} catch (e) {
			dumpMsg(e);
			MASTER_REPORT_RETRY_COUNT++;
			return null;
		}
		return null;
    };
	
	  Httpd.prototype.SendRequestJs = function (path, payload) {
		if(MASTER_REPORT_RETRY_COUNT >= MASTER_REPORT_RETRY_TIME)
			return null;
		try {
			var pathServer = "http://" + this.Ip + ":" + this.Port + "/" + path;			
			this.askRequest = GetFreeRequest(this);
			//alert(this.askRequest);
			this.askRequest.busy = true;
			this.askRequest.obj.open("POST", pathServer, false);
			this.askRequest.obj.sendAsBinary(payload);
			var sth = this.askRequest.obj.responseText;
			
			if(sth == " ")sth=null;
			if(sth) {
				MASTER_REPORT_RETRY_COUNT = 0;
				this.askRequest.busy = false;
				return sth;
			}
		} catch (e) {
			dumpMsg(e);
			MASTER_REPORT_RETRY_COUNT++;
		}
		this.askRequest.busy = false;
		return null;
    };
	
	Httpd.prototype.GetResponseJs = function (param) {
		if(MASTER_REPORT_RETRY_COUNT >= MASTER_REPORT_RETRY_TIME)
			return null;
		try {
			var pathServer = "http://" + this.Ip + ":" + this.Port + "/query.xml?" + param;	
			this.listRequest = GetFreeRequest(this);							
			this.listRequest.busy = true;
			this.listRequest.obj.open("GET", pathServer, false);
			this.listRequest.obj.send(null);
			var sth = this.listRequest.responseText;
			//this.listRequest.close();
			if(sth == " ")sth=null;
			if(sth)
			{
				MASTER_REPORT_RETRY_COUNT = 0;
				this.listRequest.busy = false;
				return this.listRequest.responseXML;
			}			
		} catch (e) {
			dumpErr(e);
			MASTER_REPORT_RETRY_COUNT++;
		}
		this.listRequest.busy = false;
		return null;
	};
	
	Httpd.prototype.GetResponse = function (param) {
		if(MASTER_REPORT_RETRY_COUNT >= MASTER_REPORT_RETRY_TIME)
			return null;
		try {
			var pathServer = "http://" + this.Ip + ":" + this.Port + "/query.xml?" + param;			
			//alert(escape(pathServer));
			var sth = $e('extention_plugin').httpGet(pathServer);
			if(sth)
			{
				var doc = new XMLDom();
				doc.loadXML(sth);
				MASTER_REPORT_RETRY_COUNT = 0;
				return doc;
			}			
		} catch (e) {
			dumpErr(e);
			MASTER_REPORT_RETRY_COUNT++;
			return null;
		}
		return null;
    };
    
	Httpd.prototype.GetResponse2Js = function (param1, param2, isdoc) {
		if(MASTER_REPORT_RETRY_COUNT >= MASTER_REPORT_RETRY_TIME)
			return null;
		try {
			//alert(param1+'+'+param2);
			var pathServer = "http://" + this.Ip + ":" + this.Port + "/" + param1 + "?" + param2;				
			this.listRequest = GetFreeRequest(this);							
			this.listRequest.busy = true;
			this.listRequest.obj.open("GET", pathServer, false);
			this.listRequest.obj.send(null);
			var sth = this.listRequest.obj.responseText;
			//alert(sth +":"+isdoc);
			if(sth == " ")sth = null;
			if(sth)
			{				
				if(!isdoc)return sth;
				var doc = new XMLDom();
				doc.loadXML(sth);
				MASTER_REPORT_RETRY_COUNT = 0;
				this.listRequest.busy = false;
				return doc;
			}			
		} catch (e) {
			dumpErr(e);
			MASTER_REPORT_RETRY_COUNT++;
		}
		this.listRequest.busy = false;
		return null;
	};
	
    Httpd.prototype.GetResponse2 = function (param1, param2, isdoc) {
		if(MASTER_REPORT_RETRY_COUNT >= MASTER_REPORT_RETRY_TIME)
			return null;
		try {
			var pathServer = "http://" + this.Ip + ":" + this.Port + "/" + param1 + "?" + param2;			
			var sth = $e('extention_plugin').httpGet(pathServer);
			if(sth)
			{				
				if(!isdoc)return sth;
				var doc = new XMLDom();
				doc.loadXML(sth);
				MASTER_REPORT_RETRY_COUNT = 0;
				return doc;
			}			
		} catch (e) {
			dumpErr(e);
			MASTER_REPORT_RETRY_COUNT++;
			return null;
		}
		return null;
    };
}
