(function() {
	var conds = [];
	
	function checkConds() {
		for (var i=0; i<conds.length; i++) {
			if (conds[i][0]()) {
				conds[i][1].call(conds[i][2]);
				conds.splice(i, 1);
				i--;
			}
		}
		
		if (conds.length > 0) {
			setTimeout(checkConds, 50);
		}
	}
	
	FF.Utils = {};
	
	FF.Utils.when = function(condArg, func, thisObj, thisObj2) {
		var cond = condArg;
		if (typeof(cond) === 'object') {
			cond = function() {return condArg.value;};
			if (typeof(func) === 'string') {
				var key = func;
				func = thisObj;
				thisObj = thisObj2;
				cond = function() {return condArg[key];};
			} else {
				cond = function() {return condArg.value;};
			}
		}
		
		conds.push([cond, func, thisObj]);
		
		if (conds.length == 1) {
			checkConds();
		}
	};
	
	FF.Utils.urlParameters = function(s) {
		var s = s || window.location;
		
		var args = {};
		s.toString().replace(/[^?]*\??/, '').split(/&/).forEach(function(a) {
			if (a.match(/\w+=/)) {
				var key = a.replace(/=.*$/, '');
				var value = a.replace(/[^=]*=/, '');
				args[key] = unescape(value);
			}
		});
		
		return args;
	}
})();