window.log = function(){
  log.history = log.history || [];   // store logs to an array for reference
  log.history.push(arguments);
  if(this.console) {
      arguments.callee = arguments.callee.caller;
      console.log( Array.prototype.slice.call(arguments) );
  }
};
// make it safe to use console.log always
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();)b[a]=b[a]||c})(window.console=window.console||{});

/**	
 * jQuery pub/sub plugin by Peter Higgins (dante@dojotoolkit.org)
 * Loosely based on Dojo publish/subscribe API, limited in scope. Rewritten blindly.
 * Original is (c) Dojo Foundation 2004-2010. Released under either AFL or new BSD, see:
 * http://dojofoundation.org/license for more information.
 *
 *  @link https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js
 */	

;(function(d){
	var cache = {};

	d.publish = function(/* String */topic, /* Array? */args){
		cache[topic] && d.each(cache[topic], function(){
			this.apply(d, args || []);
		});
	};

	d.subscribe = function(/* String */topic, /* Function */callback){
		if(!cache[topic]){
			cache[topic] = [];
		}
		cache[topic].push(callback);
		return [topic, callback]; // Array
	};

	d.unsubscribe = function(/* Array */handle){
		var t = handle[0];
		cache[t] && d.each(cache[t], function(idx){
			if(this == handle[1]){
				cache[t].splice(idx, 1);
			}
		});
	};

})(window.jQuery);


