
// Slideshow
	var cstatus = '1';
	function pausePlay() {
		if (this.cstatus == '1') {
			this.cstatus = '0';
			$('#slideshow').cycle('pause');
			$('#controller')
				.addClass('play')
				.html('Play')
			;
		} else {
			this.cstatus = '1';
			$('#slideshow').cycle('resume');
			$('#controller')
				.removeClass('play')
				.html('Pause')
			;
		}
	}
	function onAfter(curr,next,opts) {
		var l = this.title;
		var currentCaption = '';
		if (l !='') {
			currentCaption = l;
			//var s = l.split(',');
			//if (s.length > 0) {
			//	currentCaption = s[0];
			//}
		}
		$('#caption').html(currentCaption + '&nbsp;');
		var slideNumber = (opts.currSlide + 1) + ' of ' + opts.slideCount;
	}
	
	function slideshow() {
		if (document.getElementById('slideshow')) {
			var sWidth = document.getElementById('slideshow').style.width;
			var sHeight = document.getElementById('slideshow').style.height;
			$('#slideshow div')
				.width(sWidth)
				.height(sHeight)
			;
	
			$('#slideshow').cycle({
				fx:      'fade', 
				speed:    500, 
				timeout:  4500,
				next:   '#slideshow', 
				pause:   1, 
				after:   onAfter
			})
			
			$('#controller')
				.click(function() {
					pausePlay();
				})
				.html('Pause')
			;
			
			if ($('#slideshow div').length == 1) {
				var currentCaption = $('#slideshow div').attr('title');
				if (currentCaption != '') {
					$('#caption').html(currentCaption);
				}
			}
		}
	}

$(document).ready(function() {
	if (document.getElementById('slideshow')) {
		slideshow();
	}
});


