// sliding caption and image cross fade for Graduation 2011 photo album
// BZonderman, MBreen
$(function() {
		$('.caption').hover(function(){			
			$(this).stop().animate({top: 250}, '1000', 'swing');
		}, function(){
			$(this).stop().animate({top: 300}, '250', 'swing');
		});
	});
	
	$(function(){
		
		var total = $('div.wrap').length;
		var count = total - 1;
		var gonext = true;
		
		for (var i = total - 2; i >= 0; i--){
			$('div.wrap').eq( i ).fadeOut('fast');
		}
		
		function increment(){ 
			count++; 
			if (count >= total){count = 0}	
		}
		function decrement(){ 
			count--;
			if(count < 0){count = total - 1;} 
		}
		
		function showMe(gonext){
			$('div.wrap').eq( count ).fadeOut('slow');
			if ( gonext ){ increment(); } else { decrement(); }
			$('div.wrap').eq( count ).fadeIn('slow');
		}
		
		$('.prev').click(function(){showMe(false);});
		$('.next').click(function(){showMe(true);});
		
});
