$("document").ready(function () {

	var SBCountImage = $(".CytatItem").length;

	if (SBCountImage>1)
	{
		for (var i = 1; i <= SBCountImage; i++)
		{
			$("#CytatBox-Page").append('<a href="javascript:(void);" rel="'+i+'" class="SlideBox-Button">'+i+'</a>' + "\n");
		}

		$(".SlideBox-Button:first").addClass("SlideBox-ButtonActive");
		$(".CytatItem").css('display', 'none');
		$(".CytatItem:first").fadeIn();

		rotate = function ()
		{	
			var ID = $active.attr("rel") - 1;

			$(".SlideBox-Button").removeClass("SlideBox-ButtonActive");
			$active.addClass("SlideBox-ButtonActive");

			$(".CytatItem").fadeOut(1500);
			$(".CytatItem:eq("+ID+")").fadeIn(1500);
		}; 

		rotateSwitch = function ()
		{		
			play = setInterval(function ()
			{
				$active = $("a.SlideBox-ButtonActive").next();

				if ($active.length === 0)
				{
					$active = $(".SlideBox-Button:first");
				}

				rotate();
			}, 7000);
		};

		rotateSwitch();
	}
});
