//Interface function to toggle animations on/off
function toggleAnimations(){
	var animationsCookie = getCookie("animations");
	if (animationsCookie == "off") {
		animationsCookie = "on"
	} else {
		animationsCookie = "off"
	}
	setCookie("animations", animationsCookie, 30);
}

function setAnimations(animationsValue) {
	setCookie("animations", animationsValue, 30);
//	alert(animationsValue);
}

function isAnimationsOn() {
	var animationsCookie = getCookie("animations");
	return animationsCookie !=  "off";
}

function updateAnimationButtons() {
	if (isAnimationsOn()) {
		$('#imgPlay').show();
		$('#imgPlayActive').hide();
		$('#imgPause').hide();
		$('#imgPauseActive').show();
	} else {
		$('#imgPlay').hide();
		$('#imgPlayActive').show();
		$('#imgPause').show();
		$('#imgPauseActive').hide();
	}
}

function initAnimationButtons() {	
	$('#butPlay').click(function () {
		if (!isAnimationsOn()) {			
			setAnimations("on");
			startSlideShow();
			updateAnimationButtons();
		}
	});
	$('#butPause').click(function() {
		if (isAnimationsOn()) {		
			stopSlideShow();
			setAnimations("off");
			updateAnimationButtons();
		}
	});	
	updateAnimationButtons();
}

function resumeSlideShow() {	
	var $ss = $('#slideshow');
	if (isAnimationsOn()) {
		$ss.cycle('resume');					
	}
} 				

function startSlideShow() {	
	var $ss = $('#slideshow');
	if (isAnimationsOn()) {
		$ss.cycle();					
	}
} 				

function stopSlideShow() {	
	var $ss = $('#slideshow');
	if (isAnimationsOn()) {
		$ss.cycle('pause');					
	}
} 				

