$(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/anima/0002.jpg',
			alt:  'Pink Martini',
			from: '100% 20% 1.5x',
			to:   'bottom right 1x',
			time: 2
		}, {
			src:  'images/anima/0001.jpg',
			alt:  'Olodum',
			from: '100% 80% 1.5x',
			to:   'top left 1x',
			time: 3
		}, {
			src:  'images/anima/0003.jpg',
			alt:  'Pink Martini',
			from: '100% 80% 1.5x',
			to:   '80% 0% 0.6x',
			time: 3
		}, {
			src:  'images/anima/0012.jpg',
			alt:  'Petrona Martinez',
			from: '100% 80% 1.5x',
			to:   'bottom right 0.6x',
			time: 4
		}, {
			src:  'images/anima/0008.jpg',
			alt:  'Tryo',
			from: 'top left',
			to:   'top right 1x',
			time: 3
		}, {
			src:  'images/anima/0015.jpg',
			alt:  'Novalima',
			from: 'top center',
			to:   'bottom left',
			time: 3
		}, {
			src:  'images/anima/0005.jpg',
			alt:  'Olodum',
			from: 'top left',
			to:   'bottom right 1.5x',
			time: 2
		}, {
			src:  'images/anima/0004.jpg',
			alt:  'Ivri Lider',
			from: 'bottom right',
			to:   'top left 1.5x',
			time: 2
		}, {
			src:  'images/anima/0007.jpg',
			alt:  'Vinicio Capossela',
			from: 'top left',
			to:   'bottom right 1.5x',
			time: 4

		}, {
			src:  'images/anima/0014.jpg',
			alt:  'Kevin Johansen',
			from: 'top right',
			to:   'bottom left 1.5x',
			time: 4

		}
		
	], 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);
	});


});

