﻿(function(window){
	var TriggerClass = function(){
		var queue = [];  // private array - function queue
		this.add = function() { // public void - enqueue function(s)
			var args = arguments;
			args.length === 1 ?	queue.push(args[0]) : (function(len, i){
				while(i < len) { queue.push(args[i++]); };
			})(args.length, -1);
		};
		this.execute = function(){ // public void - execute all queued functions
			var bin;
			while(queue.length > 0) {
				bin = queue.splice(0,1)[0];
				typeof bin === "function" && bin();
			};
			bin = null;
		};
	};
	window.Triggers = new TriggerClass();
})(window);

