$(document).ready(function(){	
	jQuery.extend( jQuery.easing, {
		easeOutSine: function (x, t, b, c, d) {
			return c * Math.sin(t/d * (Math.PI/2)) + b;
		}
	});
	
	function startSlideshow() {
		if($("#slideshow").length > 0) {
			var initialLoad = true;
			var offsetWidth = 15;
			var itemWidth = 17;
			
			/* markup, displayTime, and fx are global variables created in the dsp_frontpage.cfm file */
			$('#slides').cycle('stop').remove();
			$('#slideshow').html(markup);
			$('#slides').cycle({
				fx: fx, 
				speed: 600, 
				timeout: displayTime, 
				sync: true, 
				easing: 'easeOutSine', 
				delay:-1500, 
				pause: 1,
				pager: "#slideshow_controls",
				pagerAnchorBuilder: function(idx, slide) {
					return '<div class="default_slide"></div>';
				},
				before: function(curr, next, opts) {
					if(initialLoad == false) $("#current_slide").fadeOut(500);
					else {
						initialLoad = false;
						$("#current_slide").show(500);
					}
				},
				after: function(curr, next, opts) {
					$("#current_slide").css("left", ((opts.currSlide * itemWidth) + offsetWidth)).fadeIn(500);
					
					//console.debug(opts);
					//console.debug(opts.elements[opts.currSlide+1]);
					$("#caption").html(opts.elements[opts.currSlide].children[0].alt);

					
					
				}
			});
		}
	}
	
	startSlideshow();
});
