/**
 * SlideBox Engine for SlideClients
 *
 * @version
 * 1.2.0
 *
 * Autor: Erwin Bujak
 * Copyright (C) 2011
 *
 */
$(document).ready(function() {

	var CountClients;
	var Width = 888;
	var Active = 0;

	ChangeArrowClients = function (act, co)
	{
		if (co == "Left")
		{
			if (act == 0)
			{
				$("#ClientsArrLeft").addClass("SlideBoxNotActive");
			}
			else
			{
				$("#ClientsArrLeft").removeClass("SlideBoxNotActive");
			}
		}

		if (co == "Right")
		{
			if (act == (CountClients-1))
			{
				$("#ClientsArrRight").addClass("SlideBoxNotActive");
			}
			else
			{
				$("#ClientsArrRight").removeClass("SlideBoxNotActive");
			}
		}
	};

	CountClients = $(".ClientsItem").length;
	$("#ClientsField").css("width", Width*CountClients+"px");

	ChangeArrowClients(Active, "Left");

	$("#ClientsArrRight").click(function () {

		/*if ($(this).attr("class") != "SlideBoxNotActive")
		{*/
			Active += 1;

			if (Active == CountClients)
			{
				Active = 0;

				$("#ClientsField").animate({"left": -Width*Active+"px"}, "slow");
			}
			else
			{
				$("#ClientsField").animate({"left": -Width*Active+"px"}, "slow");
			}

			ChangeArrowClients(Active, "Left");
		/*}*/
	});

	$("#ClientsArrLeft").click(function () {

		if ($(this).attr("class") != "SlideBoxNotActive")
		{
			Active -= 1;

			if (Active < 0)
			{
				Active = (CountClients-1);

				$("#ClientsField").animate({"left": -Width*Active+"px"}, "slow");
			}
			else
			{
				$("#ClientsField").animate({"left": -Width*Active+"px"}, "slow");
			}

			ChangeArrowClients(Active, "Left");
		}
	});
});
