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

	
	

	$test3.crossSlide({
		fade: 1
	}, [
		{
			src:  'images/img_1.jpg',
			alt:  'Mirror Showroom',
			from: '0% 0% 1.3x',
			to:   '100% 50% 1.4x',
			time: 10
		}, {
			src:  'images/img_2.jpg',
			alt:  'Sunflower',
			from: 'top left  1.3x',
			to:   'bottom right 1.4x',
			time: 6
		}, {
			src:  'images/img_3.jpg',
			alt:  'Flip Flops',
			from: '100% 100% 1.4x',
			to:   '80% 0% 1.3x',
			time: 10
		}, 
		{
			src:  'images/img_4.jpg',
			alt:  'Flip Flops',
			from: '100% 100% 1.3x',
			to:   '80% 0% 1.4x',
			time: 10
		},{
			src:  'images/img_5.jpg',
			alt:  'Flip Flops',
			from: '100% 100% 1.4x',
			to:   '80% 0% 1.3x',
			time: 10
		},{
			src:  'images/img_6.jpg',
			alt:  'Rubber Ring',
			from: '0% 50% 1.5x',
			to:   '30% 50% 1.6x',
			time: 10
		}
	], 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);
	});

	
});
