var ConclusionPanel = new Class({
	
	Implements : [Options, Events],
	
	options: {
		onAnswer: $empty
	},
	
	container: undefined,
	searchBus: undefined,
	
	conclusions: {},
	
	initialize: function(container, options)
	{
		this.container = $(container);
		this.setOptions(options);
		this.conclusions = new Hash(this.conclusions);
		this.setUp();
	},
	
	setUp: function()
	{
		this.searchBus = new SearchBus();
		this.searchBus.registerCallback(this.conclusionAnsweredCallback.bind(this), "onConclusionAnswered");
	},
	
	removeConclusions: function()
	{
		this.conclusions.each(function(conclusion){
			conclusion.destroy();
		}.bind(this))
		
		this.conclusions = new Hash({});
	},
	
	conclusionAnsweredCallback: function(params)
	{
		this.conclusions.erase(params.conclusion.getId());
		params.conclusion.destroy();
	},	
	
	onAnswerConclusion: function(answer, conclusion)
	{
		this.searchBus.trigger("onConclusionAnswered", {answer:answer, conclusion:conclusion});
		this.fireEvent("onAnswer", answer, conclusion);
	},
	
	addConclusion: function(conclusion)
	{
		
		if($defined(this.conclusions[conclusion.getId()]))
		{
			return false;
		}
		
		this.conclusions[conclusion.getId()] = conclusion;
		conclusion.removeEvents();
		conclusion.addEvent("onAnswer", this.onAnswerConclusion.bind(this))
		conclusion.inject(this.container);
		conclusion.highlight();
	},
	
	loading: function()
	{
		this.container.addClass("loading");
	},
	
	loaded: function()
	{
		this.container.removeClass("loading");
	}
	
});