var ProgressIndicator = Class.create();
ProgressIndicator.prototype = {
	
	initialize: function(nev) {
		this.len = 0;
		this.nev = nev;
		// csekk disz: http://dev.rubyonrails.org/ticket/5741
		Ajax.activeRequestCount_fixed = 0; // fixed: prototype.js BUG!
		this.ajaxhandler = {
			onCreate: function(){
				Ajax.activeRequestCount_fixed++;
			},

			onComplete: function(){
				Ajax.activeRequestCount_fixed--;
				if (Ajax.activeRequestCount_fixed == 0){
					this.len = 0;
					this.update();
				}
			}.bind(this),

			onSuccess: function() {
			},
			
			onFailure: function() {
			},
			
			onException: function(request, exception) {
				Ajax.activeRequestCount_fixed--;
			}
		};

		Ajax.Responders.register(this.ajaxhandler);
	},

	add: function(type) {
		this.len = 1;
		this.update();
	},

	remove: function(type) {
		this.len = 0;
		this.update();
	},

	update: function() {
		if (this.len == 0) {
			universe.hideIndicator();
		}
	}

};
