
function AjaxThinRequest()
{
	
}

AjaxThinRequest.prototype.request = undefined;
	
 
AjaxThinRequest.prototype.sendSimplePOST = function(url, poststr) {
		
	poststr=encodeURI(poststr);
	this.request = this.getXMLHTTPRequest();
	var _this = this;
	this.request.open("POST", url, true);
	this.request.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=iso-8859-2");
	//http.setRequestHeader("Accept-Charset", "ISO-8859-2,utf-8;q=0.7,*;q=0.7");
	/* this.request.setRequestHeader("Content-length", parameters.length); */
	this.request.setRequestHeader("Connection", "close");
	this.request.onreadystatechange = function(){
		_this.onData(0)
	};
	////alert(poststr);
	this.request.send(poststr);	

}
	

AjaxThinRequest.prototype.sendGET = function(url, data, level) {
	if(parseInt(level)) {}else{level=0;}
	this.request = this.getXMLHTTPRequest();
	var _this = this;
	this.request.onreadystatechange = function(){
		_this.onData(level)
	};
	this.request.open("GET", url+data, true);
	this.request.send(null);
}

	
AjaxThinRequest.prototype.onData = function(level) {
	try{
		
		if(this.request.readyState == 4) 	{

			if(this.request.status == "200") 		{
				this.action()

			} else {	
				//error
			}
			
		}
	}catch(err){
		console.debug(err);
	}
}



AjaxThinRequest.prototype.getXMLHTTPRequest = function() {
	var HttpObject;
	// MSIE Proprietary method
	/*@cc_on
	@if (@_jscript_version >= 5)
		try {
			HttpObject = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
				HttpObject = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (E) {
				HttpObject = false;
			}
		}
	@else
		xmlhttp = HttpObject;
	@end @*/
	// Mozilla and others method
	if (!HttpObject && typeof XMLHttpRequest != 'undefined') {
		try {
			HttpObject = new XMLHttpRequest();
		}
		catch (e) {
			HttpObject = false;
			//alert('Blad!!!!!!!!');
		}
	}
	return HttpObject;
}

var AjaxThin = {
	level: 0,
	pageControlInit : function() {
		if (!AjaxThin.pageControlModule) throw "AjaxThin.pageControlModule isn't loaded. Script stop.";
		return AjaxThin.pageControlModule
	},
	
	requestInit : function() {
		if (!AjaxThin.request) throw "AjaxThin.request isn't loaded. Script stop.";
		return AjaxThin.request
	},
	
	callbackInit : function() {
		if (!AjaxThin.callback) throw "AjaxThin.callback isn't loaded. Script stop.";
		return AjaxThin.callback
	},
	
	pageControlLoginInit : function() {
		if (!AjaxThin.pageControlLoginModule) throw "AjaxThin.pageControlLoginModule isn't loaded. Script stop.";
		return AjaxThin.pageControlLoginModule
	},
	
	flyingWindowInit : function() {
		if (!AjaxThin.flyingWindowModule) throw "AjaxThin.flyingWindowModule isn't loaded. Script stop.";
		return AjaxThin.flyingWindowModule
	},
	
	coordinates : function() {
		if (!AjaxThin.coordinatesModule) throw "AjaxThin.coordinatesModule module isn't loaded";
		return AjaxThin.coordinatesModule
	}

}

