/**
 * SlideBox Engine for Partners
 *
 * @version
 * 1.2.0
 *
 * Autor: Erwin Bujak
 * Copyright (C) 2011
 *
 */
$(window).load(function() {

	var Count, cEl;
	var Width = new Array();
	var Active = 5;
	var Move = 0;

	ChangeArrow = function (act, co)
	{
		if (co == "Left")
		{
			if (act == (Count-1))
			{
				$("#PartnersSlideArrLeft").addClass("NotActive");
			}
			else
			{
				$("#PartnersSlideArrLeft").removeClass("NotActive");
			}
		}

		if (co == "Right")
		{
			if (act == 5)
			{
				$("#PartnersSlideArrRight").addClass("NotActive");
			}
			else
			{
				$("#PartnersSlideArrRight").removeClass("NotActive");
			}
		}
	};

	$("#PartnersSlideField img").each(function (i) {

		Width[i] = $(this).width();
	});

	Count = $("#PartnersSlideField img").length;

	$("#PartnersSlideField").css("width", "5000px");

	$("#PartnersSlideArrRight").addClass("NotActive");

	$("#PartnersSlideArrLeft").click(function () {

		cEl = $(this).attr("class");

		if (cEl != "NotActive")
		{
			Active += 1;

			Move += Width[Active];

			$("#PartnersSlideField").animate({left: "-"+Move+"px"}, "linear");

			ChangeArrow(Active, "Left");
			ChangeArrow(Active, "Right");
		}
	});

	$("#PartnersSlideArrRight").click(function () {

		cEl = $(this).attr("class");

		if (cEl != "NotActive")
		{
			Active -= 1;

			Move -= Width[(Active+1)];

			$("#PartnersSlideField").animate({left: "-"+Move+"px"}, "linear");

			ChangeArrow(Active, "Left");
			ChangeArrow(Active, "Right");
		}
	});
});
