jQuery(document).ready(function($) {
    var apiKey = 'b31575cfffb455e5d7621429d66c23f0';
	var setID = '72157626272235507';
	var userID = '79493308@N00';

    $.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 = '<p class="slide"><a href="/gallery"><img src="http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '.jpg" /></a></p>'; 
                var newthumb = $("#home-slides").append(slideimg);
            });
            
    $('#home-slides').cycle();
		startingSlide: Math.floor(Math.random()*70)
    });
    
    $('.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});
    }


})
