function linkTweet(tweet) {
	// this one's for regular http links, it's a beauty
	exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
	tweet = tweet.replace(exp,"<a href='$1'>$1</a>");
	// link mentions
	tweet = tweet.replace(/(^|\s)@(\w+)/g, '$1<a href="http://www.twitter.com/$2">@$2</a>');
	// link hashtags
	return tweet.replace(/(^|\s)#(\w+)/g, '$1<a href="http://search.twitter.com/search?q=%23$2">#$2</a>');
};
$(function() {    
	// initialize scrollable
	$(".carousel-holder").scrollable({circular: true}).autoscroll(7000);
	
	var api = $(".carousel-holder").data("scrollable");
	api. onBeforeSeek(function() {
		//console.log('onBeforeSeek Tiggered: ' + this.getIndex());
		$(".text-box .l-side").fadeOut();
	});
	api.onSeek(function() {
		//console.log('onSeek Tiggered: ' + this.getIndex());
		category = $("ul.items li.item"+this.getIndex()+" .category").html();
		$(".text-box .l-side .category").html(category);
		caption = $("ul.items li.item"+this.getIndex()+" .caption").html();
		$(".text-box .l-side .caption").html(caption);
		$(".text-box .l-side").fadeIn();
	});
	
	// on page load
	category = $("ul.items li.item"+api.getIndex()+" .category").html();
	$(".text-box .l-side .category").html(category);
	caption = $("ul.items li.item"+api.getIndex()+" .caption").html();
	$(".text-box .l-side .caption").html(caption);
	$(".text-box .l-side").fadeIn();
	

	var url='http://api.twitter.com/1/statuses/user_timeline/spyder_trap.json?callback=?'; // make the url
	$.getJSON(url,function(tweet){ // get the tweets
		latestTweet = linkTweet(tweet[0].text); // grab just the most recent tweet
		$("p#spydertweet").html(latestTweet);
		$("p#spydertweet").slideDown(); // make an entrance
	});
});
