(function(){
this["ev"] = {};
var store = {};
ev.on = function( type , fn ) {
!store[type] && (store[type] = []);
store[type].push( fn );
};
ev.trigger = function( type , args ) {
for( var i = 0; i < store[type].length; i++) {
if( typeof store[type][i] === 'function' )
store[type][i].apply( this , args || [] );
else
throw new Error("Event is not defined");
}
};
// ...
}());