var twitbox = (function() {
	var $twits = $("div.twits");
	var prima = true;
	var twit_rss = "../php/twitbox.php?lingua=<?php echo $l?>";

	this.update = function() {
		$.getJSON(twit_rss, null, function(items) {
			var primo = true;
			$.each(items,function(k,v) {
				if (v.text === undefined)
					return;
				if (primo) {
					primo = false;
					$twits.empty();
				}
				$("<p><strong>•</strong> "+v.ts_locale+"<br />"+v.text+"</p>").appendTo($twits);
			});

			if (!prima)
				return;

			$("div.twitbox").fadeIn(500);
			prima = false;
		});
	}
	var handler = null;
	this.autoupdate = function() {
		handler = setInterval(this.update,60*1000);
	};
	return this;
})();
