//= require <mootools-core-1.3-full-nocompat>
//= require <puremvc-mootools-port>
//= require <findsalons/ApplicationFacade>
//= require <findsalons/AsyncProxy>
var PreviewPanelMediator = function()
{
	this.Extends = Mediator;

	/**
	 * @ignore
	 */
	this.initialize = function(viewComponent /* TabBar */)
	{
		this.parent(PreviewPanelMediator.NAME, viewComponent);
		this.previewPanel = this.getViewComponent();
	};

	this.onRegister = function()
	{
		this.previewPanel.addEventListener("dataChange", this.dataChangeHandler, false, 0, this);
	};

	this.listNotificationInterests = function()
	{
		return [ AsyncProxy.LISTING_PREVIEW_RECIEVED ];
	};

	this.handleNotification = function(notification /* Notification */)
	{
		switch (notification.getName())
		{
			case AsyncProxy.LISTING_PREVIEW_RECIEVED:
				this.previewPanel.dataProvider(notification.getBody().data);
				break;
		}
	};

	this.dataChangeHandler = function(event /* UICEvent */)
	{
		var data = event.target.data();
		this.sendNotification(ApplicationFacade.RETRIEVE_LISTING_SUMMARY, data.listing_id);
	};
};
PreviewPanelMediator = new Class(new PreviewPanelMediator());
PreviewPanelMediator.NAME = "PreviewPanelMediator";
