var shitbox = new function() {

	this.div = document.getElementById('shitbox');
	this.divNull = document.getElementById('shitbox_null');
	this.divClock = document.getElementById('shitbox_clock');
	this.divAdd = document.getElementById('shitbox_add');
	this.checkBell = document.getElementById('shitbox_bell');

	this.g = this.get = function(i) {

		this.divClock.innerHTML = ' &raquo;';

		if(this.first == 'NaN') return false;

		o = document.createElement('script');
		o.type = 'text/javascript';
		o.src = '?shitbox,'+Math.floor(Math.random()*9999999)+ this.first;
		this.div.appendChild(o);
		
		clearTimeout(this.timer);
		this.timer = setTimeout('shitbox.g(' + i + ')', 4000);
	}

	this.i = this.insert = function(i, t) {

		if(i <= shitbox.first) return false;

		if(this.divNull) this.divNull.style.display = 'none';

		o = document.createElement('li');
		o.innerHTML = '<ul>' + t + '</ul>';
		o.id = 'shitbox_item_' + i;
		if(shitbox.count++ % 2) o.className = 'l';

		shitbox.div.insertBefore(o, document.getElementById('shitbox_item_' + shitbox.first));
		shitbox.first = i;

		if(this.checkBell.checked == true) this.bell();
	}

	this.a = this.add = function() {

		ajax.post('?shitbox,'+Math.floor(Math.random()*9999999), ajax.params('shitbox_add'));
		this.divAdd.value = '';

	}

	this.b = this.bell = function() {
		o = document.getElementById('shitbox_player');
		if(o != null) o.parentNode.removeChild(o);
		o = document.createElement('div');
		o.id = 'shitbox_player';
		o.innerHTML = '<object id="shitbox_player" name="shitbox_player" data="http://rwm.org.pl/snd/dzwon-01.mp3" type="application/x-mplayer2" width="0" height="0" enablejavascript="true"><param name="filename" value="/snd/dzwon-01.mp3"/><param name="enablejavascript" value="true"/><param name="filename" value="http://rwm.org.pl/snd/dzwon-01.mp3"/></object>';
		document.body.appendChild(o);
	}
}
