var fade =
{
	timeout: null,
	animationtype: null,
	container: '#rotatingImagesPreview',
	height: '75px',

	init: function()
	{
		setTimeout(function() {
			$('#form-success-top').fadeOut('slow');
		}, 4000);

		//	Get the dom nodes
		fade.timeout = $('#timeout');
		fade.animationtype = $('#transition');

		$('#submit').attr("disabled", "disabled");

		//	Bind events
		fade.timeout
			.change(fade.update)
			.change(fade.activateSubmit);
		fade.animationtype
			.change(fade.update)
			.change(fade.activateSubmit);

		//	Start the innerfade
		$(fade.container).cycle({
			timeout: fade.timeout.val() * 1000,
			fx: fade.animationtype.val(),
			height: fade.height
		});
	},

	activateSubmit: function()
	{
		$('#submit').removeAttr('disabled');
	},

	update: function()
	{
		$(fade.container).cycle('stop');
		//	reassign the cycle with new settings.
		$(fade.container).cycle({
			timeout: fade.timeout.val() * 1000,
			fx: fade.animationtype.val(),
			height: fade.height
		});
	}
};

$(document).ready(fade.init);

