$(document).ready(function(){

  /* Open External Links in New Window */
	$("a[rel=external]").attr("target","_blank");

	/* Scroll to Section */
  $("ul#navigation li a").click(function(){
    var section = $(this).attr("href");
    $("html, body").animate({scrollTop: $(section).offset().top}, 500, "easeInOutCirc");
    return false;
  });
  
  /* Slideshow */
  $("ul#projects li:first").addClass("current");
  $(".project").hide();
  $(".project:first").show();
  $("ul#projects li a").click(function() {
    var index = $("ul#projects li a").index(this);
    $("ul#projects li").removeClass("current");
    $(this).parent().addClass("current");
    $(".project").fadeOut(300);
    $(".project").eq(index).fadeIn(300);
    return false;
  });
  
  /* Project Slideshow */
	$(".project ul").each(function(i){
    $(this).after('<ul class="project-navigation '+i+'"></ul>').cycle({ 
      fx: "scrollHorz",
      easeIn:  'easeInCirc', 
      easeOut: 'easeInCirc',
      speed: 400,
      timeout: 0,
      pause: 1,
      cleartypeNoBg: true,
      pauseOnPagerHover: 1,
      pager: "ul." + i,
      activePagerClass: "current",
      pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="javascript:void(0)"></a></li>';
      }
    });
  });

});
