window.pubsub=( function(){ function sub(type,handler){ if(!handler){ var err=new ReferenceError('handler not defined'); throw(err); } checkScope.apply(this); if(!this._events_[type]) this._events_[type]=[]; this._events_[type].push(handler); } function unsub(type,handler){ if(!handler){ var err=new ReferenceError('handler not defined. if you wish to remove all handlers from the event please pass "*" as the handler'); throw err; } checkScope.apply(this); if(type=='*'){ var params=Array.prototype.slice.call(arguments,1); for( var keys = Object.keys(this._events_), count = keys.length, i=0; i