<!-- TwitterPop developed by James King //http://www.devscapes.ca> and Stefan Grambart <http://www.stefangrambart.ca -->

var current_tweet = 0;
var max_tweets = 0;
var all_tweets;

function loadTweets(tweets) {
	all_tweets = tweets;
	max_tweets = tweets.length
	//$$('#twitter-pop .bubble')[0].set('morph', {duration: 500, transition: Fx.Transitions.Back.easeInOut});
	setInterval('swapTweet()', 15000);
	swapTweet();
}

function swapTweet() {
	current_tweet++;
	if (current_tweet >= max_tweets) {
		current_tweet = 0;
	}
	bubble = $$('#twitter-pop .bubble')[0];
	
	bubble.set('tween', {
		onComplete: function(el) {
			when = new Date().parse(all_tweets[current_tweet].created_at);
		
			el.getElement('.tweet').innerHTML = all_tweets[current_tweet].text;
			//el.getElement('.when a').innerHTML = when.format('%Y-%m-%d');
			//el.getElement('.when a').setAttribute('href', 'http://twitter.com/robinwhalen/statuses/' + all_tweets[current_tweet].id);
			el.morph({
				width: [0, 375],
				height: [0, 117],
				opacity: [0, 1]
			});
		}
	})
	bubble.tween('opacity', 0);
}
