
$(function(){
if ( $('body.category-people').length > 0 ){
 // shuffle post order
 var wrapper = $('#post-wrapper');
 var posts = wrapper.children();
 for (i=0; i<posts.length; i++) {
  wrapper.prepend(posts[ Math.floor( posts.length * Math.random() )]);
 }

 // create carousel for 'who we are' posts
 $('.category-people #wrapper').append('<a href="#" id="previous" title="previous">previous</a>').append('<a href="#" id="next" title="next">next</a>').addClass('carousel');
 var total_width = $('.category-people .post').length*722;
 $('.carousel #post-wrapper').css({'width': total_width + 'px'});
 $('#post-wrapper').css({'margin-left': 0}); // IE needs this
 $('a#previous, a#next').click(function(e){
 e.preventDefault();
 var marg = parseInt($('#post-wrapper').css('margin-left'));
 var newMarg;
 if (e.target.title == 'previous') {
  newMarg = marg + 722;
  if (newMarg > 0) newMarg = -total_width + 722;
}
 else {
  newMarg = marg - 722;
  if (newMarg <= -total_width) newMarg = 0;
}
 $('#post-wrapper').animate({
 marginLeft: newMarg + 'px'
 }, 1500, 'swing');
 });
} // end if
});
