var Observable = Class.create({
 		initialize: function(options){
 			this.listeners = $H({});
 			this.suspended = false;
 			
 			if(!options){
 				return;
			}
 			
 			$H(options || {}).each(function(option){
 				var key = option.key;
 				var value =  option.value;
 				var t = typeof option.value;
 					
 				if(key == "scope"){
 					return;
 				}
 					
 				if(t == "function"){
 					this.on(key, value, options.scope, value.delay);
 				}
 					
 				if(t == "object"){
 					this.on(key, value.callback, value.scope || options.scope, value.delay);
 				}
 			}.bind(this)) 			
 		},
 		on: function(name, callback, scope, delay){
 			var listener = this.listeners.get(name);
 			
 			if(Object.isUndefined(listener)){
 				listener = this.listeners.set(name, []);
 			}
 			
 				
 			listener.push({
 				_callback: callback,
 				delay: delay || 0,
 				remove: this.un.bind(this).curry(name, callback),
 				callback: delay ? callback.delay.curry(delay) : callback
 			});
 			
 		},
 		un: function(name, callback){
 			var remove = [];
 			var listeners = this.listeners.get(name);
 			
 			if(listeners){
 				listeners.each(function(event){
 					if(!callback || (callback == event._callback)){
 						console.log(!callback || (callback == event._callback));
 						remove.push(event);
 					}
 				});
 				
 				this.listeners.set(name, listeners.without.apply(listeners, remove));
 			}
 		},
 		dispatch: function(){
 			if(this.suspended){
 				return;
 			}
 			
 			var args = $A(arguments);
 			
 			return (this.listeners.get(args.shift()) || []).collect(function(event){
 				try{
 					event.callback.apply(event, args.concat(event));
 				}catch(e){ };
 			});
 		},
 		suspendEvents: function(){
 			this.suspended = true;
 		},
 		resumeEvents: function(){
 			this.suspended = false;
 		}
});
