$(function() {
	var $Index1 = $('#Index1'),

		$caption = $('div.caption'),
		$pause = $('#pause'),
		$resume = $('#resume'),
		$freeze = $('#freeze'),
		$stop = $('#stop'),
		$restart = $('#restart'),
		captions = [
'4-week-old tomatoes utilizing the Tower Garden Tomato Cage for support',
'12-week-old tomatoes, vine ripe and ready to eat!',
'Tomatoes planted at the bottom can run up a trellis or across the patio. There is room for other crops above.',
'Dwarf cherry tomatoes taste delicious!',
'8-foot Tower Gardens in this hobby-size greenhouse. Two add-on kits create 36 planting spaces per tower.',
'A single Tower Garden can be home to 36 different types of plants, or just one of your favorites!',
'Edible flowers look good, smell great, and taste even better.',
'Grow all of your own fruits and vegetables year round in the comfort of your own back yard!',
'Grow fresh strawberries year-round!',
'Harvest fresh lettuces, herbs, and vegetables right outside the kitchen door, year-round.',
'Increase your Tower Garden yield even more with an add-on kit, and make it even taller!',
'Rooftop farms can feed hundreds of people in an urban environment.',
'Rooftop farms reduce the heat in a building while providing fresh, locally grown, low carbon footprint food.',
'Soil-less growing! In this photo, roots can be seen growing inside the Tower Garden aeroponic growing chamber.',
'The Tower Garden eliminates weeding, bending, and tilling! Just watch your plants grow and harvest the food!',
'The Tower Garden is the easiest garden on earth! So simple, "black thumbs" become green!',
'The Tower Garden produces clean, nutritious, pesticide-free plants. No dirt and no bugs!',
'Tower Garden accessories include wheels for easy moving, and a plant cage for extra large crops.',
'Two-week-old lettuce seedling being transplanted into a Tower Garden.'],
		STOP = 1, RUN = 2, PAUSE = 3;

$Index1.crossSlide({
		fade: 1,
		variant: true,
		
	}, [
		{
			src:  'IndexPgSlideShowPix/01.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/03.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {	
			src:  'IndexPgSlideShowPix/18.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/05.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/02.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/04.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/06.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/07.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/08.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/09.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/11.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/12.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/13.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/14.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/15.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		},  {
			src:  'IndexPgSlideShowPix/16.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/17.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/19.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}, {
			src:  'IndexPgSlideShowPix/20.jpg',
			from: '100% 100% 1.0x',
			to:   '100% 100% 1.0x',
			time: 5
		}

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

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

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

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

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

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

	
});