$(document).ready(function(){
			
			var $image = $('#images img');
			var count = $image.length;
			var num = 1;
			
			$('#images').cycle({
				fx: 'fade', 
	            startingSlide: 0,  // start on the slide that was in the markup 
	            timeout:  0, 
	            speed:    750,
	            prev:    '#prev', 
	            next:    '#next, #images', 
	            before:   onBefore,
	            after:     onAfter,
   		   		cleartypeNoBg: false
			});
			
			$('#next').click(function(){
				num = num +1;
			});
			
			$('#prev').click(function(){
				num = num -1;
			});
			
			function onBefore() {
				var nextImg = $('#images img:nth-child('+num+')').attr('src');
				$('<img/>').attr('src', nextImg).css('top', '0px').css( 'position', 'absolute').appendTo('#images');
		
			}
			function onAfter(curr,next,opts) {
			var caption = "figure " + (opts.currSlide + 1) + " of " + (opts.slideCount);
			$('#counter').html(caption);
 
			}
		});

