function loadingIndicator(optionArr){
	if(!loadingIndicator.instance){
		loadingIndicator.instance = this;
	}else if(loadingIndicator.instance.properties.singleton){
		return loadingIndicator.instance;
	}
	
	var randNumber = Math.round(Math.random(1000)*10000);
	this.properties = {
		showOnAjax: 1,
		randNumber: randNumber,
		loadBlockId: 'loading_content'+randNumber,
		vertical: 'top', 								/*top, bottom, center*/
		horizontal: 'right', 							/*top, bottom, center*/
		ready: 0,
		loadBlockObj: null,
		singleton: 1,
		indicatorText: '',
		active: 0
	}

	var counter = 0;
	var _self = this;

	this.init = function(options){
		$.extend(_self.properties, options);
		_self.createLoadBlock();
		_self.setText(_self.properties.indicatorText);
	}
	
	this.createLoadBlock = function(){
		if(!document.getElementById(_self.properties.loadBlockId)){
			$('<div id="'+_self.properties.loadBlockId+'" class="loading_block"><div></div><span></span></div>').appendTo('body');
			_self.properties.loadBlockObj = $('#'+_self.properties.loadBlockId);
			_self.setPosition(_self.properties.vertical, _self.properties.horizontal);
			_self.properties.loadBlockObj
				.css('display', 'none')
				.ajaxSend(function(e, jqxhr, settings){
					if(!settings.backend){
						counter++;
						_self.show();
					}
				})
				.ajaxStop(function(){_self.hide();});
				/*.ajaxComplete(function(e, jqxhr, settings){
					if(!settings.backend){
						console.log(counter)
						counter--;
						if(!counter){
							_self.hide();
						}
					}
				})*/
		}
		return this;
	}
	
	this.setText = function(text){
		_self.properties.loadBlockObj.find('span').html(text);
	}
	
	this.setPosition = function(vertical, horizontal){
		_self.properties.vertical = vertical;
		_self.properties.horizontal = horizontal;
		var top = '0px';
		var bottom = '';
		var left = '';
		var right = '0px';
		switch(vertical){
			case 'bottom':{
				top = ''; bottom = '0px';
				break;
			};
			case 'center':{
				top = ($(window).height()/2 - _self.properties.loadBlockObj.outerHeight()/2)+'px';
				bottom = '';
				break;
			};
			case 'top':
			default:{
				top = '0px'; bottom = '';
				break;
			};
		}
		switch(horizontal){
			case 'left':{
				right = ''; left = '0px';
				break;
			};
			case 'center':{
				left = ($(window).width()/2 - _self.properties.loadBlockObj.outerWidth()/2)+'px';
				right = '';
				break;
			};
			case 'right':
			default:{
				right = '0px'; left = '';
				break;
			};
		}
		_self.properties.loadBlockObj.css({'position': 'fixed', 'top':top, 'bottom':bottom, 'left':left, 'right':right});
		return this;
	}
	
	this.show = function(){
		if(!_self.properties.active){
			_self.properties.active = 1;
			_self.setPosition(_self.properties.vertical, _self.properties.horizontal);
			_self.properties.loadBlockObj.fadeIn(100);
		}
		return this;
	}
	
	this.hide = function(){
		_self.properties.active = 0;
		_self.properties.loadBlockObj.fadeOut(100);
		return this;
	}

	_self.init(optionArr);
};