function Message_Blaster(textarea_id, button_prefix) {
	this.textarea = $(textarea_id);
	this.textarea.observe('focus', this.blankField.bindAsEventListener(this));
	this.textarea.observe('blur', this.refillField.bindAsEventListener(this));
	this.fan_button = $(button_prefix + 'fans');
	this.fan_button.observe('click', this.fanSend.bindAsEventListener(this));
	if($(button_prefix + 'dancers')) {
		this.dancer_button = $(button_prefix + 'dancers');
		this.dancer_button.observe('click', this.dancerSend.bindAsEventListener(this));
	}else{
		this.dancer_button = $(button_prefix + 'friends');
		this.dancer_button.observe('click', this.friendSend.bindAsEventListener(this));
	}
	this.everyone_button = $(button_prefix + 'everyone');
	this.everyone_button.observe('click', this.everyoneSend.bindAsEventListener(this));
	this.select_button = $(button_prefix + 'select');
	this.select_button.observe('click', this.selectionHandling.bindAsEventListener(this));
	this.selection_div = null;
	var sel = $$('.selection-popup');
	if(sel.size() == 0) {
		this.selection_div = $(new Element('div')).addClassName('selection-popup');
		this.selection_div.hide();
		document.body.insert(this.selection_div);
	}else{
		this.selection_div = sel[0];
	}
}
Message_Blaster.prototype = Object.extend({
	blankField: function(event) { 
		if($F(this.textarea) == 'What am I doing right now?') {
			this.textarea.update('');
		}
	},
	refillField: function(event) { 
		if($F(this.textarea) == '') {
			this.textarea.update('What am I doing right now?');
		}
	},
	fanSend: function(event) { 
		ajaxPost('/ajax/status/process', 'up_target=fans&status=' + encodeURIComponent($F(this.textarea)), 'editable');
	},
	friendSend: function(event) { 
		ajaxPost('/ajax/status/process', 'up_target=friends&status=' + encodeURIComponent($F(this.textarea)), 'editable');
	},
	dancerSend: function(event) { 
		ajaxPost('/ajax/status/process', 'up_target=dancers&status=' + encodeURIComponent($F(this.textarea)), 'editable');
	},
	everyoneSend: function(event) { 
		ajaxPost('/ajax/status/process', 'up_target=everyone&status=' + encodeURIComponent($F(this.textarea)), 'editable');
	},
	selectionHandling: function(event) {
		ajaxPopup('/apopup/status/selection', null, null, 'status=' + encodeURIComponent($F(this.textarea)));
		/*this.selection_div.setStyle({position: 'absolute', top: (this.select_button.cumulativeOffset().top + this.select_button.getHeight() - 2) + 'px', left: this.select_button.cumulativeOffset().left + 'px'});
		new Ajax.Request('/ajax/status/selection', {
			onSuccess: function(transport) {
				this.selection_div.update(transport.responseText);
				this.selection_div.show();
				this.setupCheckboxes();
			}.bind(this)
		});
		*/
	},
	setupCheckboxes: function() {
		var div = this.selection_div;
		var mb = this;
		$$(".fans input[type='checkbox'], .dancers input[type='checkbox']").each(function(item) {
			item.up().observe('click', function(event) {
				var orig_target = this.getElementsBySelector('input[type="checkbox"]')[0];
				if($F(orig_target) == 'true') {
					new Ajax.Request('/ajax/status/selection_add?id=' + encodeURIComponent(orig_target.readAttribute('name')), {
						onSuccess: function(transport) {
							div.update(transport.responseText);
							mb.setupCheckboxes();
						}
					});
				}else{
					new Ajax.Request('/ajax/status/selection_remove?id=' + encodeURIComponent(orig_target.readAttribute('name')), {
						onSuccess: function(transport) {
							div.update(transport.responseText);
							mb.setupCheckboxes();
						}
					});
				}
			});
		});
	},
	selectAllCheckboxes: function() { 
		$$(".fans input[type='checkbox'], .dancers input[type='checkbox']").each(function(item) {
			item.checked = true;
		});
	},
	deselectAllCheckboxes: function() {
		$$(".fans input[type='checkbox'], .dancers input[type='checkbox']").each(function(item) {
			item.checked = false;
		});
	}
	}, Message_Blaster.prototype);
