$(document).ready(function() {
  $("a.slideshow").live("click", function() {
    var link = $(this);
    $.getJSON(this.href, function(urls) {
      // create list
      var photoList = $("<div id='gallery-photos' style='display:none;'>");
      for (var i in urls)
        photoList.append( $("<a>").attr("href", urls[i]).attr("rel", "photo-group") );

      // remove / add to dom
      $("#gallery-photos").remove();
      $("body").append(photoList);

      // create slideshow
      $("#gallery-photos a").fancybox();

      // init slideshow
      $("#gallery-photos a:first").click();
    });
    return false;
  });
});
