//////////////////////////////
// Scroll Functionality		//
// Dev:		OS				//
// Data:	29-10-08		//
//////////////////////////////
//var xVelocity = -48.5;//starting velocity for a moving start
var xVelocity = 0;//starting velocity for a moving start
//var xPos = 498;//starting position off-screen for moving starting
var xPos = 0;//starting position off-screen for moving starting
var friction = 10;
var itemWidth = 130;//width of each item to calculate total width
var numItems = 0;


function UpdateScroll(){
	document.getElementById('item_wrapper').style.left = xPos+"px";//update position by variable
	xPos += xVelocity;//update position variable by adding velocity
	xVelocity = xVelocity-xVelocity/friction;//apply friction to the velocity
	//document.getElementById('debug').innerHTML="test:"+(xPos-(itemWidth*4))+" / "+-(numItems*itemWidth);
}

function ScrollLeft(){
	if(xPos<-400){
		xVelocity+=48.5;
	}
}

function ScrollRight(){
	if(xPos-(itemWidth*4)>-(numItems*itemWidth)){//scroll if there are more items after the current three
		xVelocity-=48.5;
	}
}

function ImageSwap(strElement, strImage){
		document.getElementById(strElement).src=strImage;//swaps the images of the left/right arrows with animations
}

function initiate(intNum){//sets the number of items and updates the width of the wrapper
	numItems = intNum;
	document.getElementById('item_wrapper').style.width = (numItems*itemWidth)+"px";
	var aniInterval = setInterval(UpdateScroll,20);
}