function strayegg_chat(
	in_frame,
	in_channel,
	in_display
) {

	this.frame = in_frame+' .frame';
	this.input = in_frame+' .input .newmsg';
	this.postbutton = in_frame+' .input a';

	this.channel = in_channel;
	this.display = in_display;
	
	this.post = function() {
		// Register an action in the parent
		if ($(this.input).val().length > 0) {
			this.parent.queueaction(	   
				this.channel,
				{a:'post',t:$(this.input).val()}	   
			);
			$(this.input).val('');
		}
	}
	
	this.handler = function(data) {
		if (data.RS.length > 0) {
			for (var i=0;i<data.RS.length;i++) {
				$(this.frame)
					.append($('<p>'+data.RS[i].MSG+'</p>').addClass('msg').fadeIn()
					.append($('<div>'+data.RS[i].DT+'</div>').addClass('dt'))
					.append($('<div>'+data.RS[i].USR+'</div>').addClass('usr'))
				);
				if (data.RS[i].SELF==1) {
					$(this.frame+' p:last').addClass('own');
				}
			}
			while ($(this.frame+' p').size() > this.display) {
				$(this.frame+' p:first').remove();
			}
		}
	}

	$(this.input).keyup(function(event){
		if (event.keyCode == '13') {
			this.post();
		}
	}.bind(this));

	$(this.postbutton).click(this.post.bind(this));
}


