$(document).ready(function() {

  $(".comments").click(function() {
    x = $(this).parents("div").siblings(".extras");
    if (x.css("display") == "none") { x.show("blind",{direction:"vertical"},1500); } 
    else { x.hide("blind",{ direction:"vertical"},1500); }
    return false;
  });

  $("a[rel='prev']").click(function() {
    $.get("comicWidget.php" + this.search + "&rel=prev",function(data){
       $("a[rel='prev']").replaceWith(data);
       refreshLinks();
    });
    return false;
  });

  $("a[rel='next']").click(function() {
    $.get("comicWidget.php" + this.search + "&rel=next",function(data){
       $("a[rel='next']").replaceWith(data);
       refreshLinks();
    });
    return false;
  });


  function refreshLinks () {
     $(".comments").live("click",function() {
       x = $(this).parents("div").siblings(".extras");
       if (x.css("display") == "none") { x.show("blind",{direction:"vertical"},1500); } 
       else { x.hide("blind",{ direction:"vertical"},1500); }
       return false;
     });
     $("a[rel='prev']").live("click",function() {
       $.get("comicWidget.php" + this.search + "&rel=prev",function(data){
         $("a[rel='prev']").replaceWith(data);
         refreshLinks();
       });
       return false;
     });
     $("a[rel='next']").live("click",function() {
       $.get("comicWidget.php" + this.search + "&rel=next",function(data){
         $("a[rel='next']").replaceWith(data);
         refreshLinks();
       });
       return false;
     });
  }


});
