// slideshow pagers

function addClass(pagers, pager) {
  // remove all active states
  $(pagers).each(function() {
    $(this).removeClass("active");
  });
  // add state to current list item  
  $(pager).addClass("active");
}

$(document).ready(function() {

  
  // add .js class to body as hook for progressive enhancement in CSS
  $('body').addClass('js').css('visibility','visible');
    
  // fade slideshows
  var $active = "";
  $(".slideshow.pagers li a").click(function() {
    $pager = $(this).attr("href");  
    $active = $pager;
    $("ul#slides li").each(function() {}).fadeOut("fast");
    $($pager).fadeIn("slow");
      addClass(".slideshow.pagers li", $(this).parent().parent()  );
      return false;
    });
  $("ul#slides li").each(function() {}).hide();
  $("ul#slides li:first-child").each(function() {}).show(); 
  addClass(".slideshow.pagers li", ".slideshow.pagers li:last-child");

  // Easing equation, borrowed from jQuery easing plugin
  // http://gsgd.co.uk/sandbox/jquery/easing/
  jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
    return -c * ((t=t/d-1)*t*t*t - 1) + b;
  };


  // carousel in Projects
  $('#slides').serialScroll({
    items:'li',
    prev:'.slideshow.pagers .prev',
    next:'.slideshow.pagers .next',
    duration:600,
    cycle:false,
    easing:'easeOutQuart'
  });
  // hide pagers when reach end of line
  
});


Cufon.replace('.article #primary .column .hreview p, #status.block .inner blockquote p', { fontFamily: 'TrashHand' });
Cufon.replace('h1, #branding dd, #content ol.hfeed h3, .article #content div.hfeed h1.entry-title, .archive #content ol.column.hfeed h4 ', { fontFamily: 'Belizio Bold' });

