APE.Controller = new Class({
	
	Extends: APE.Client,
	
	Implements: Options,
	
	options: {
		container: null
	},
	
	initialize: function(options){
		this.setOptions(options);
		this.container = $(this.options.container) || document.body;

		this.onRaw('postmsg', this.onMsg);
		this.addEvent('load',this.start);
	},
	
	start: function(core){
		this.core.start({'name': $time().toString()});
	},
	
	onMsg: function(raw){
		new Element('div', {
			'class': 'nothing',	
		}).inject(this.container);
			
		new Element('div', {
			'class': 'forum_topic_userpic',
			html: decodeURIComponent("<img alt='profile pic' src='" + raw.data.userpic + "' width='50' height='50' />")
		}).inject(this.container);		
		new Element('div', {
			'class': 'forum_topic_username',
			html: decodeURIComponent(raw.data.username)
		}).inject(this.container);
		new Element('div', {
			'class': 'message',
			html: decodeURIComponent(raw.data.message + "<br> <br> <div class='topic_date'>" + raw.data.date + "</div>")
		}).inject(this.container);

	}
	
});

