$(function() {
	var $test1 = $('#test1'),
		$test2 = $('#test2'),
		$test3 = $('#test3'),
		$test4 = $('#test4'),
		$caption = $('div.caption'),
		$pause = $('#pause'),
		$resume = $('#resume'),
		$freeze = $('#freeze'),
		$stop = $('#stop'),
		$restart = $('#restart'),
		STOP = 1, RUN = 2, PAUSE = 3;


	$test3.crossSlide({
		fade: 2
	}, [
		{
			src:  'jquery/dayton_river.jpg',
			alt:  'Sand Castle',
			from: 'top right',
			to:   'bottom center 1.5x',
			time: 7
		}, {
			src:  'jquery/dayton_stealth.jpg',
			alt:  'Sand Castle',
			from: 'top left',
			to:   'bottom center 1.5x',
			time: 7
		}, {
			src:  'jquery/dayton_ai.jpg',
			alt:  'Sand Castle',
			from: '70% 80% 1.5x',
			to:   '80% 0% 1.1x',
			time: 7
		}, {
			src:  'jquery/dayton_rail.jpg',
			alt:  'Sand Castle',
			from: 'top right',
			to:   'bottom center 1.5x',
			time: 7
		}, {
			src:  'jquery/dayton_church.jpg',
			alt:  'Sand Castle',
			from: 'top left',
			to:   'bottom center 1.5x',
			time: 7
		}, {
			src:  'jquery/dayton_carillon.jpg',
			alt:  'Sunflower',
			from: 'bottom center 1x',
			to:   'top center 1.5x',
			time: 7
		}, {
			src:  'jquery/dayton_fountain.jpg',
			alt:  'Flip Flops',
			from: '70% 80% 1.5x',
			to:   '80% 0% 1x',
			time: 7
		}, {
			src:  'jquery/dayton_civilwar.jpg',
			alt:  'Flip Flops',
			from: '70% 80% 1.5x',
			to:   '80% 0% 1x',
			time: 7
		}, {
			src:  'jquery/dayton_main.jpg',
			alt:  'Rubber Ring',
			from: 'top left',
			to:   'bottom center 1.5x',
			time: 7
		}, {
			src:  'jquery/dayton_schuster.jpg',
			alt:  'Rubber Ring',
			from: 'top left 1.5x',
			to:   'bottom center 1x',
			time: 7
		}
	], function(idx, img, idxOut, imgOut) {
		if (idxOut == undefined) {
			$caption.text(img.alt).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);

	$pause.click(function() {
		$test3.crossSlidePause();
		state(PAUSE);
	});

	$resume.click(function() {
		$test3.crossSlideResume();
		state(RUN);
	})

	$freeze.click(function() {
		$test3.crossSlideFreeze();
		state(STOP);
	});

	$stop.click(function() {
		$test3.crossSlideStop();
		$caption.css({ opacity: 0 })
		state(STOP);
	});

	$restart.click(function() {
		$test3.crossSlideRestart();
		state(RUN);
	});


});

