jQuery(document).ready(function($) {
	var apiKey = '1545a70bf0e9ffb3b73ac23062fbfe87';
	var setID = '72157615021024422';
	var userID = '29594673@N02';

    $.getJSON('http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&photoset_id=' + setID + '&api_key=' + apiKey + '&user_id=' + userID + '&extras=description&format=json&jsoncallback=?', function(data){
            $.each(data.photoset.photo, function(i,item){
                var slideimg = '<div class="slide"><a href="/photos"><img src="http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '.jpg" /></a></div>'; 
                var newthumb = $(".slideshow").append(slideimg);
            });
            
	$('.slideshow').cycle();
	   
	});
	
	$('.story-slides').cycle({ 
		timeout: 12000,
		cleartype:  1,
	    after: onAfter
	});
	

	function onAfter(curr, next, opts, fwd) {
	var index = opts.currSlide;
	//get the height of the current slide
	var $ht = $(this).height();
	//set the container's height to that of the current slide
	$(this).parent().animate({height: $ht});
	}


})
