$(function() {
	var $test3 = $('#test3'),
		$caption = $('div.caption'),
		$pause = $('#pause'),
		$resume = $('#resume'),
		$freeze = $('#freeze'),
		$stop = $('#stop'),
		$restart = $('#restart'),
		captions = ['Sand Castle', 'Sunflower', 'Flip Flops', 'Rubber Ring'],
		STOP = 1, RUN = 2, PAUSE = 3;

	$test3.crossSlide({
		fade: 1
	}, [
		{
			src:  'mainpage_slideshow/2_04.jpg',
			from: '100% 80% 1.5x',
			to:   '80% 0% 1.1x',
			time: 4
		}, {
			src:  'mainpage_slideshow/2_01.jpg',
			from: 'top right 1.5x',
			to:   '30% 50% 1.2x',
			time: 3
		}, {
			src:  'mainpage_slideshow/2_07.jpg',
			from: '100% 0% 1.3x',
			to:   '50% 100% 1.0x',
			time: 4
		}, {
			src:  'mainpage_slideshow/2_10.jpg',
			from: 'top right',
			to:   'bottom left 1.1x',
			time: 4
		}
	], function(idx, img, idxOut, imgOut) {
		if (idxOut == undefined) {
			$caption.text(captions[idx]).animate({ opacity: .7 })
		} else {
			$caption.animate({ opacity: 0 })
		}
	});
	$caption.show().css({ opacity: 0 })

	function state(state) {
		$pause.attr('disabled', state != RUN);
		$resume.attr('disabled', state != PAUSE);
		$freeze.attr('disabled', state == STOP);
		$stop.attr('disabled', state == STOP);
	}
	state(RUN);

});
