
$().ready(function() {

	var options = {
		showTime: 8000,		 	 // Number of milliseconds to show a slide (if autoStart is false)
		transitionTime: 800,	 // Number of milliseconds of transition duration
		autoHeight: false,		 // Whether to automatically adjust the height to fit the current slide
		animateAutoHeight: true, // Whether to animate the automatic height adjustment
		slideType: 'fade',		 // Keep this as 'fade'
		fadeInOut: true,		 // Keep this as true
		doHoverPause: false,	 // Whether to pause the show when user hovers over a slide
		autoStart: false,		 // Whether to start the show automatically
		arrowsLoop: false,		 // Whether the previous/next links should loop to the end/beginning, respectively
		slideChange: function(currentIndex) {
			// Do something when the slide transition is finished
		}
	};
	
    var $slides = $('.slideshow .slide-item'),
		$slideshow = $slides.simpleCrossFade(options),
		slideCount = $slides.length;
	if (!options.autoStart) $slideshow.simpleCrossFade('stop');
	
	$slides.each(function(i, slide) {
		var $slide = $(slide),
			$prev = $slide.find('a.prev-slide'),
			$next = $slide.find('a.next-slide');

		$slide.find('span.slide-counts').html((i+1) + ' of ' + slideCount);
		
		if (!options.arrowsLoop && i == 0) {
			$prev.addClass('disabled');
			$prev.click(function() { return false });
		}
		else {
			$slide.find('a.prev-slide').click(function() {
				$slideshow.simpleCrossFade('previous');
				return false;
			});
		}

		if (!options.arrowsLoop && i == slideCount-1) {
			$next.addClass('disabled');
			$next.click(function() { return false });
		}
		else {
			$next.click(function() {
				$slideshow.simpleCrossFade('next');
				return false;
			});
		}

	});

	// Set slide height based on slide content
	$s1 = $('.slideshow .slide-item:first');
	$s1.find('img').imagesLoaded(function() {
		$s1.parent().css({height: $s1.outerHeight() + 10});
	});
	
});


