$(document).ready(function()
{
	if ($('#blip').length == 0) return false;

	$('#blip #news li').remove();

	var time = Math.round(new Date().getTime() / 100000); // enables caching for 100 seconds
	var url = 'http://api.blip.pl/users/livechat/statuses?limit=5&time='+time+'&callback=?';

	$.ajax({
		type: "GET",
		url: url,
		dataType: "json",
		cache: false,
		success: function (posts)
		{
			var post;
			for (var i=0, len=posts.length; i < len; ++i)
			{
				post = posts[i];
				post.body = post.body.replace(/(#(\w)+ ?)+$/, '')
				post.body = post.body.replace(/#/g, '');
				if (post.body.length > 120) post.body = post.body.substr(0,110)+'&hellip;';

				$('#blip #news').append('<li><a href="http://blip.pl/s/' + post.id + '">' + post.body + '</a></li>');
			}
			$('#blip').append('</ul>');
			$('#blip').fadeIn();

			$('#blip #news').innerfade({
				animationtype: 'fade',
				speed: 250,
				timeout: 6500,
				type: 'sequence',
				containerheight: '1em'
			});
		}
	});
});