$(function() {
var $caption = $('div.caption'), STOP = 1, RUN = 2, PAUSE = 3, 		
  $pause = $('#pause'),
		$resume = $('#resume'),
		$freeze = $('#freeze'),
		$stop = $('#stop'),
		$restart = $('#restart'),
    $caption = $('div.caption'); 
    
	$('#placeholder').crossSlide({
		fade: 1
	}, [
		{
			src:  'Hotel_CB1.JPG',
			alt:  'Keine Radferien und kein Fahrradkauf ohne unser Angebot!',
			from: '100% 100% 1x',
			to:   '100% 0% 1.7x',
			time: 7
		}, {
			src:  'Radferien015.jpg',
			alt:  'Zusammen mit unseren Ausrüstungspartner sind wir für die Radsaison bereit! PRICE Racebike; ASSOS; SPONSER',
			from: 'top left',
			to:   'bottom right 1.7x',
			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();
		$('div.caption').css({ opacity: 0 })
		state(STOP);
	});

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