/**
 * @author Paul
 */

$(function() {
	
	twitter.init();
	
});

var twitter = {
	
	init: function()
	{
		twitter.getTweets();
	},
	
	getTweets: function()
	{
		$.ajax({
			type: "GET",
			url: "twitter.php",
			cache: false,
			success: function(data){
				twitter.setTweets(data);
			}
		});
	},
	
	setTweets: function(data)
	{
		var xml = $(data);
		var i = 0;
		xml.find('status').each(function(){
			var s = "<li id='tweet" + i + "'>" + $(this).text() + "</li>";
			$(s).appendTo("#feed");
			
			var alpha = (100 - 20 * i)<20 ? 20 : (100 - 20 * i);
			$("#tweet" + i).css("opacity", alpha/100).css("filter", "alpha(opacity=" + alpha + ")");
			
			i++;
		});
		
		xml.find('avatar').each(function(){
			var img = "<img src='" + $(this).text() + "'/>";
			$(img).appendTo("#profile");
		});
		
		/*var userid = "";
		xml.find('userid').each(function(){
			userid = $(this).text();
		});
		
		xml.find('name').each(function(){
			var name = "<a href='http://www.twitter.com/" + userid + "' target='_blank'><h1>" + $(this).text() + "</a></h1>";
			$(name).appendTo("#profile");
		}); */
	}
		
};











