var forumShoutbox = function() {
	var updateUrl = null;
	function shoutboxUpdate() {
		jQuery.get(updateUrl, {}, function(data){
			jQuery('#box').html(data)
		});
	}
	function resizeShoutbox() {
		rh = jQuery('#recommended_inner').outerHeight();
		rh = rh < 200 ? 200 : rh;
		sf = jQuery('#shout_form').outerHeight();
		sf = typeof(sf) == 'undefined' ? 0 : sf
		jQuery('#box').css('height',
			[rh - sf - 3, 'px'].join('')
		);
	}
	return {
	setupReadable: function(argv) {
		updateUrl = argv.updateUrl;
		jQuery(document).ready(function(){
			setInterval('forumShoutbox.update()', 71001);
			resizeShoutbox();
		});
	},
	setupWriteable: function() {
		jQuery(document).ready(function(){
			jQuery('#shoutarea').focus(function(){
				jQuery('#counter').show();
			});
			jQuery('#shoutarea').blur(function(){
				jQuery('#counter').hide();
			});
			jQuery('#shoutarea').keyup(function(){
				if (this.value.length > 300) {
					this.value = this.value.substring(0, 300);
				} else {
					document.getElementById('limit').innerHTML = this.value.length;
				}
			});
			jQuery('#shoutboxForm').submit(function(event){
				var l = jQuery('#shoutarea')[0].value.length;
				if (l == 0 || l > 300) {
					event.preventDefault();
					return ;
				}
				jQuery('#shout-submit').attr('disabled', 'disabled');
			});
		});
	},
	update: function() {
		shoutboxUpdate();
	}}
}();