﻿
/*keeps track of the left position of each strip, 
this is necessary for when the user clicks the next button before the animation is done*/
var BannerScroller_StripPositons = new Array();


function BannerScroller_ScrollLeft(id, max, amount) {

	var currentposition = BannerScroller_GetCurrentPosition(id);
	BannerScroller_StripPositons[id] = Math.min(currentposition + amount, max);

	BannerScroller_Scroll(id, currentposition);
}

function BannerScroller_ScrollRight(id, max, amount)
{

	var currentposition = BannerScroller_GetCurrentPosition(id);

	BannerScroller_StripPositons[id] = Math.max(currentposition + amount, max);
	
	BannerScroller_Scroll(id, currentposition);
}


function BannerScroller_GetCurrentPosition(id) {
	if (BannerScroller_StripPositons[id] != undefined) {
		return BannerScroller_StripPositons[id];
	}
	return 0;
}

function BannerScroller_Scroll(id, currentposition) {

	
	$(id).animate
	(
		{
			left: BannerScroller_StripPositons[id]
		},
		Math.abs(currentposition - BannerScroller_StripPositons[id]) * 2, //keeps the speed the same no matter how many images are being scrolled
		null
	);
}
