function loader()
{
    this.counter = 0;
}

loader.prototype.start = function()
{
    this.counter++;
    this.triggerLoader();
};

loader.prototype.finish = function()
{
    this.counter--;
    this.triggerLoader();
};

loader.prototype.triggerLoader = function()
{
	if (this.counter == 1) {
        $('#loader').css('display', 'block');
    } else if (this.counter == 0) {
        $('#loader').css('display', 'none');
    }
};
