function OBJ_AJAX_HANDLER() {
	
	this.objects 	= new Array();
	this.obj_path	= HTTP_ROOT + 'new/img/';
	
	
	this.init = function(object_nr) {
		
		if (!this.objects[object_nr].req) {
			
			try {
				// Try to create object for Firefox, Safari, IE7 [30], etc.
				this.objects[object_nr].req = new XMLHttpRequest();
			}
			catch (e) {
				try {
					// Try to create object for later versions of IE.
					this.objects[object_nr].req = new ActiveXObject('MSXML2.XMLHTTP');
				}
				catch (e) {
					try {
						// Try to create object for early versions of IE.
						this.objects[object_nr].req = new ActiveXObject('Microsoft.XMLHTTP');
					}
					catch (e) {
						// Could not create an XMLHttpRequest object.
						return false;
					}
					
				}
				
			}
			
 		}
		
 		return this.objects[object_nr].req;
		
	}; // END init
	
	
	this.initObject = function(block_id) {
		
		var object_nr = -1;
		
		// Nosaka vai nav kads brivs vai arii vai netiek izsaukts viens un tas pats skripts atkartoti
		for (var i = 0; i < this.objects.length; i++) {
			
			if (this.objects[i].req != null) {
				
				if (this.objects[i].objectIsFree == true) {
					
					object_nr = i;
					break;
					
				}else if (this.objects[i].block_id == block_id) {
					
					object_nr = i;
					break;
					
				}
				
			}
			
		}
		
		// Izveido jaunu pieeju, ja nav atrasts pieejams cits
		if (object_nr == -1) {
			
			var object_nr = this.objects.length;
			
			function object() {
				
				this.req 				= null;
				this.objectIsFree 	= true;
				this.url 				= null;
				this.method 			= null;
				this.async 				= true;
				this.status 			= null;
				this.statusText 		= '';
				this.postData 			= null;
				this.readyState 		= null;
				this.responseText 	= null;
				this.responseXML 		= null;
				this.block_id			= null;
				this.handleResp 		= null;
				this.responseFormat 	= 'text', // 'text', 'xml', or 'object'
				this.mimeType 			= null;
				
			}
			
			this.objects[object_nr] = new object();
			
		}else {
			this.abort(object_nr);
		}
		
		return object_nr;
		
	}; // END initObject
	
	
	this.doReq = function(object_nr) {
		
		if (!this.init(object_nr)) {
			alert('Could not create XMLHttpRequest object.');
			return;
		}
		
		
		this.objects[object_nr].objectIsFree = false;
		
		this.objects[object_nr].req.open(this.objects[object_nr].method, this.objects[object_nr].url, this.objects[object_nr].async);
		if (this.objects[object_nr].mimeType) {
			try {
				this.objects[object_nr].req.overrideMimeType(this.objects[object_nr].mimeType);
			}
			catch (e) {
				// couldn't override MIME type  --  IE6 or Opera?
			}
		}
		
		
		if (this.objects[object_nr].method == 'POST') {
			
			this.objects[object_nr].req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			this.objects[object_nr].req.setRequestHeader("Content-length", this.objects[object_nr].postData.length);
			this.objects[object_nr].req.setRequestHeader("Connection", "close");
			
		}
		
		
		var self = this; // Fix loss-of-scope in inner function
		this.objects[object_nr].req.onreadystatechange = function() {
			
			var resp = null;
			
			if (self.objects[object_nr].block_id.length > 0) {
				var obj_img_block = fns_getElementById(self.objects[object_nr].block_id);
			}else {
				var obj_img_block = null;
			}
			
			if (self.objects[object_nr].req.readyState == 4) {
				
				if (obj_img_block) {
					obj_img_block.innerHTML = '';
				}
				
				switch (self.objects[object_nr].responseFormat) {
					case 'text'		: resp = self.objects[object_nr].req.responseText; break;
					case 'xml'		: resp = self.objects[object_nr].req.responseXML; break;
					case 'object'	: resp = self.objects[object_nr]; break;
				}
				
				if (self.objects[object_nr].req.status >= 200 && self.objects[object_nr].req.status <= 299) {
					eval(self.objects[object_nr].handleResp);
				}else {
					self.handleErr(object_nr);
				}
				
				self.objects[object_nr].objectIsFree = true;
				
			}else if (self.objects[object_nr].req.readyState < 4) {
				
				if (obj_img_block) {
					obj_img_block.innerHTML = '<img src="' + self.obj_path + 'loader.gif" alt="loading..please wait" />';
				}
				
			}
			
			obj_img_block = null;
		
		};
		
		this.objects[object_nr].req.send(this.objects[object_nr].postData);
		
	}; // END doReq
	
	
	this.setMimeType = function(object_nr, mimeType) {
		this.objects[object_nr].mimeType = mimeType;
	}; // END doReq
	
	
	this.handleErr = function(object_nr) {
		
		var errorWin;
		try {
			//errorWin = window.open('', 'errorWin');
			//errorWin.document.body.innerHTML = this.objects[object_nr].responseText;
		}
		catch (e) {
			alert('An error occurred, but the error message cannot be '
				+ 'displayed. This is probably because of your browser\'s '
				+ 'pop-up blocker.\n'
				+ 'Please allow pop-ups from this web site if you want to '
				+ 'see the full error messages.\n'
				+ '\n'
				+ 'Status Code: ' + this.objects[object_nr].req.status + '\n'
				+ 'Status Description: ' + this.objects[object_nr].req.statusText);
		}
		
	}; // END handleErr
	
	
	this.setHandlerErr = function(object_nr, funcRef) {
		this.objects[object_nr].handleErr = funcRef;  
	}; // END setHandlerErr
	
	
	this.setHandlerBoth = function(object_nr, funcRef) {
		
		this.objects[object_nr].handleResp = funcRef;
		this.objects[object_nr].handleErr = funcRef;
		
	}; // END setHandlerBoth
	
	
	this.abort = function(object_nr) {
		
		if (this.objects[object_nr].req) {
			
			this.objects[object_nr].req.onreadystatechange = function() { };
			this.objects[object_nr].req.abort();
			this.objects[object_nr].req = null;
			
		}
		
	}; // END abort
	
	
	this.doGet = function(url, block_id, hand, format) {
		
		var object_nr = this.initObject(block_id);
		
		this.objects[object_nr].url = url;
		this.objects[object_nr].method = 'GET';
		this.objects[object_nr].block_id = block_id;
		this.objects[object_nr].handleResp = hand;
		this.objects[object_nr].responseFormat = format || 'text';
		
		this.doReq(object_nr);
		
	}; // END doGet
	
	
	this.doPost = function(url, block_id, hand, parameters, format) {
		
		var object_nr = this.initObject(block_id);
		
		this.objects[object_nr].url = url;
		this.objects[object_nr].method = 'POST';
		this.objects[object_nr].block_id = block_id;
		this.objects[object_nr].handleResp = hand;
		this.objects[object_nr].responseFormat = format || 'text';
		this.objects[object_nr].postData = parameters;
		
		//http_request.open("POST",url,true);
		
		
		this.doReq(object_nr);
		
	}; // END doPost
	
	
}// END of CLASS OBJ_AJAX_HANDLER

var OBJ_AH = new OBJ_AJAX_HANDLER();

