$(document).ready(function() {
  /* Setup a global hover */
  $(".hover").hover(
    function() {
      $(this).children().not(".over").hide();
      $(".over",this).show();
    },
    function () {
      $(this).children().not(".over").show();
      $(".over",this).hide();
    }
  );
  
  /* Hide via javascript (as opposed to CSS) */
  $(".hidden-js").hide();

  /* Series rollover */
  $(".series-list li").hover(
    function() {
      $(".series-rollover",this).stop().animate({top:"-1.9em"},{duration:500,easing:"easeOutQuart"});
      $(".series-thumbnail a img",$(this).parent()).not($("a img",this)).stop().fadeTo(500,0.4,"easeOutQuart");
      $(".new-badge",$(this).parent()).not($(".new-badge",this)).stop().animate({left:"214px"},{duration:500,easing:"easeOutQuart"});
      $(".hot-badge",$(this).parent()).not($(".hot-badge",this)).stop().animate({left:"214px"},{duration:500,easing:"easeOutQuart"});
    },
    function() {
      $(".series-rollover",this).stop().animate({top:"0"},{duration:500,easing:"easeOutQuart"});
      $(".series-thumbnail a img,",$(this).parent()).not($("a img",this)).stop().fadeTo(500,1,"easeOutQuart");
      $(".new-badge",$(this).parent()).not($(".new-badge",this)).stop().animate({left:"157px"},{duration:500,easing:"easeOutExpo"});
      $(".hot-badge",$(this).parent()).not($(".hot-badge",this)).stop().animate({left:"157px"},{duration:500,easing:"easeOutExpo"});
    }
  );
  
  /* Series love-it button */
  $(".series-list .love-it").click(function() {
    var href=$(this).attr("href");
    var target=$(this).parent();
    target.html("Wait for it...");
    $.ajax({
      url:href,
      error:function() {
        target.html("Uh-oh! There was an error...");
      },
      success:function() {
        target.html("Thanks for the love!");
      }
    });
    return false;
  });
  
  $("#debug").hover(
    function() {$(this).stop().fadeTo(500,1);},
    function() {$(this).stop().fadeTo(500,0.55);}
  );
});

function trim(str) {
 return str.replace(/^\s+|\s+$/g,'');
}