

var EventDispatcher = Class.create( {
	
	
	types : undefined,
	
	initialize : function(){
		
		
		this.types = new Array();
	},
	
	addEventListener : function( type, listener ){
		
		if( this.types[type] == undefined )
		  return;
		else
		 this.types[type].push( listener );
	},
	
	removeEventListener : function( type, listener ){
		
		if( this.types[type] == undefined )
			return;
		else if( this.types[type][this.types[type].indexOf( listener )] )
			this.types[type].splice( index, 1 );
	},
	
	
	dispatchEvent : function( type, event ){
		var i = undefined;
		if( this.types[type] )
			for( i in this.types[type] )
				  this.types[type][i](event);
		else console.error( "type " + type + " doesn't exist" );
		
	}
	
	
} )