/*
    Created by: Andrej Trcek
    Website: http://delavnica.net
    Date: 10/09/2009
*/

socials = {
    init: function(url,id,q,s)
    {
	this.url = url;
	this.id = id;
	this.query = q;
	this.since = s;
	this.showTwitter();
    },
    showTwitter: function()
    {
	$.getJSON(this.url + "?q=" + this.query + "&rpp=20&since=" + this.since + "&callback=?",
	    function(data)
	    {
		if(data.results.length>0)
		{
		    $("#" + socials.id).append('<span class="twitle">@ twitter</span>');
		
		    $.each(data.results, function(i, item)
		    {
			var p = "";
			p = '<span>'
			    + '<a href="http://twitter.com/' + item.from_user  + '" target="_blank"><img src="' + item.profile_image_url + '" /></a>'
			    + '<a href="http://twitter.com/' + item.from_user  + '" target="_blank">' + item.from_user + '</a>: '
			    + item.text
			    + '</span><div class="clear"></div>';
			$("#" + socials.id).append(p);
		    });
		}
	    }
	);
    }
}