// global short cuts
var YUI = {
	Y:	 YAHOO,
	D:	 YAHOO.util.Dom,
	E:	 YAHOO.util.Event,
	A:	 YAHOO.util.Anim,
	C:	 YAHOO.util.Connect,
	Dd:	 YAHOO.util.DD,
	El:	 YAHOO.util.Element,
	W:	 YAHOO.widget,
	Cfg: YAHOO.util.Config,
	Ce:  YAHOO.util.CustomEvent,
	Ea:  YAHOO.util.Easing,
	Ux:  {} // custom components
}; // end YUI

YUI.Ux.listener = function(){
	/* ---------------------------------------------------
	Sets up any existing component subscriptions as well as create any new custom events

	Paramters:
		class: @Function Required - The component you are adding events too
		listeners: @Object Required - Object which keys are the events. You can add new events in this manner. Parameters for each key in listeners are:
			callback: @Function Optional - Callback function to execute when the event is fired
			config: @Object Optional - Object passed along during the event fire
			fire: @Boolean Optional - Flag to tell the event to fire (or not) immediatly after subscribing
	----------------------------------------------------*/
	return {
		init: function(cmp, listeners){
			var callback, config, fire;
			for (var evt in listeners){
				callback = listeners[evt].callback || null;
				config = listeners[evt].config || null;
				fire = listeners[evt].fire || null;
				if (!cmp.hasEvent(evt)) cmp.createEvent(evt, config);
				if (callback) cmp.subscribe(evt, listeners[evt].callback);
				if (fire) cmp.fireEvent(evt, config);
			}
		} // end init
	}; // end interface
}(); // end YUI.Ux.listener
