/*
Developed by Kyle Somogyi
*/
function slide_horizontal(_so)
{
	var me = this;

	me.mc = $(_so.mainElement);
	me.imc = $(_so.mainElement).children().not('.buttonPrevious, .buttonNext');
	me.ia = [];
	me.ci = 0;
	me.imc_w = 0;
	me.so = _so;

	me.imc.children().each(function(i, elem)
	{
		me.ia.push($(elem).outerWidth());
		me.imc_w += $(elem).outerWidth();

		$(elem).attr('shiftrIndex', i);
	});

	// Manually set styles
	me.mc.css(
	{
		'overflow': 'hidden',
		'position': 'relative'
	});
	me.imc.css(
	{
		'position': 'absolute',
		'top': '0px',
		'left': '0px',
		'width': me.imc_w+'px'
	});
	me.imc.children().css(
	{
		'float': 'left'
	});
}
slide_horizontal.prototype.next = function()
{
	var me = this;

	var ix=0;
	var fi=0;
	while(ix<me.so.jumpAmount)
	{
		fi+=me.ia[me.ci]
		ix++;
		if(me.ci >= (me.imc.children().length-1))
			me.ci = 0;
		else
			me.ci++;
	}
	me.imc.stop(true, true).animate(
	{
		'left': '-='+fi+'px'
	}, function()
	{
		me.imc.children().each(function(i, elem)
		{
			if(i < me.so.jumpAmount)
				$(this).detach().appendTo(me.imc);
		});
		me.imc.css('left', '0px');
	});
};
slide_horizontal.prototype.prev = function()
{
	var me = this;

	var ix=0;
	var fi=0;
	while(ix<me.so.jumpAmount)
	{
		fi+=me.ia[me.ci]
		ix++;
		if(me.ci <= 0)
			me.ci = me.imc.children().length-1;
		else
			me.ci--;
	}

	$(me.imc.children().get().reverse()).each(function(i, elem)
	{
		if(i < me.so.jumpAmount)
			$(this).detach().prependTo(me.imc);
	});
	me.imc.css('left', '-'+fi+'px');
	me.imc.stop(true, true).animate(
	{
		'left': '0px'
	});
};
/*SHIFTR_ANIMATIONS['slide_horizontal'] = {
	init: function(_so)
	{
		var me = this;

		me.mc = $(_so.mainElement);
		me.imc = $(_so.mainElement).children().not('.buttonPrevious, .buttonNext');
		me.ia = [];
		me.ci = 0;
		me.imc_w = 0;
		me.so = _so;

		me.imc.children().each(function(i, elem)
		{
			me.ia.push($(elem).outerWidth());
			me.imc_w += $(elem).outerWidth();

			$(elem).attr('shiftrIndex', i);
		});

		// Manually set styles
		me.mc.css(
		{
			'overflow': 'hidden',
			'position': 'relative'
		});
		me.imc.css(
		{
			'position': 'absolute',
			'top': '0px',
			'left': '0px',
			'width': me.imc_w+'px'
		});
		me.imc.children().css(
		{
			'float': 'left'
		});
	},
	next: function()
	{
		var me = this;

		var ix=0;
		var fi=0;
		while(ix<me.so.jumpAmount)
		{
			fi+=me.ia[me.ci]
			ix++;
			if(me.ci >= (me.imc.children().length-1))
				me.ci = 0;
			else
				me.ci++;
		}
		me.imc.stop(true, true).animate(
		{
			'left': '-='+fi+'px'
		}, function()
		{
			me.imc.children().each(function(i, elem)
			{
				if(i < me.so.jumpAmount)
					$(this).detach().appendTo(me.imc);
			});
			me.imc.css('left', '0px');
		});
	},
	prev: function()
	{
		var me = this;

		var ix=0;
		var fi=0;
		while(ix<me.so.jumpAmount)
		{
			fi+=me.ia[me.ci]
			ix++;
			if(me.ci <= 0)
				me.ci = me.imc.children().length-1;
			else
				me.ci--;
		}

		$(me.imc.children().get().reverse()).each(function(i, elem)
		{
			if(i < me.so.jumpAmount)
				$(this).detach().prependTo(me.imc);
		});
		me.imc.css('left', '-'+fi+'px');
		me.imc.stop(true, true).animate(
		{
			'left': '0px'
		});
	}
};*/
