// $Id: flickrinsert.js,v 1.1.2.1 2009/03/03 23:41:47 starnox Exp $

/**
 * @file flickrinsert.js
 *
 * The javascript for Flickr Insert
 */

/**
 * Prepare links in the browser for insert overlay
 */
function FlickrInsert_PrepareAJAX() {
  //Insert button
  $(".flickrinsert_photoset .pager a").click(function() {
    var url = $(this).attr('href');
    url = url.split('page=');
    url = url[1].split('&');
    var photoset = $(this).parent().parent().parent().parent().parent();
    var details = photoset.attr('id');
    $(this).parent().parent().parent().parent().html('<p>Loading...</p><ul class="pager"></ul>');
    
    photoset.load("?q=flickrinsert/ajax/photoset&details="+details+"&page="+url[0], {}, function(){
      FlickrInsert_PrepareAJAX();
    });
    
    return false;
  });
}

/**
 * Make things happen on page load
 */
$(document).ready(function(){
  FlickrInsert_PrepareAJAX();
});