// Font replacement
Cufon.replace('h1');
Cufon.replace('h3');

function displayImages(data) {
	var flickrlink = "";
	$.each(data.items, function(i,item){
		if ( i == 1 ) return false;
		flickrlink = item.link;
	});
	$('#flickr').wrap("<a href='"+flickrlink+"'></a>");
}	

var urlregexp = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)(\w?.)/gi;

$(document).ready(function(){
	//$.getJSON("http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key=4b115b72ee353fbeca8fe5324d734799&photoset_id=72157621686397661&format=json&jsoncallback=?", displayImages);
	//$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?id=21103443@N06&tags=poster&format=json&jsoncallback=?", displayImages);
	$('.zoom').fadeTo(0, 0.25);
	$('.screenshots').hover(
		function(){
			$(this).find('.zoom').fadeTo(100, 0.8);
		},
		function(){
			$(this).find('.zoom').fadeTo(100, 0.25);
		}
	);
	/*$("a.group").fancybox({
		'zoomSpeedIn': 300, 
		'zoomSpeedOut':	300,
		'zoomSpeedChange': 250, 
		'overlayShow': true,
		'overlayOpacity': 0.4,
		'padding': 0
	});*/
	Shadowbox.init({
	    handleOversize:     "resize",
	    overlayOpacity: 0.85,
	    counterType:    "skip",
	    animSequence: "hw",
	    continuous: true
	});
	// Make URLs clickable
	var tweet = $('.thebox p').text();
	tweet = tweet.replace(urlregexp, "<a href='$1$8' target='_blank'>$1$8</a>");
	tweet = tweet.replace(/(^|\s)@(\w+)/g, "$1<a href='http://www.twitter.com/$2'>@$2</a>");
	tweet = tweet.replace(/(^|\s)#(\w+)/g, "$1<a href='http://search.twitter.com/search?q=%23$2'>#$2</a>");
	$('.thebox p').html("&ldquo;"+tweet+"&rdquo;");
});