var oldML;
var newML;
var firstRun;

function animMove(oldPassedML,newPassedML){
	//initialise margin variables
	if (!firstRun){
		currML=oldPassedML;
		newML=newPassedML;
		firstRun=1;
		}
	
	if (currML != newPassedML) {
		if (currML < newPassedML){
			currML=currML + 1;
			}
		if (currML > newPassedML){
			currML=currML - 1;
			}
		}
	else{
		clearInterval(animMoveInt);
		}
		
	//update CSS
	oElement=document.getElementById("imglist");
	oElement.style.marginLeft=currML + "px";	
	}

function moveUL(dist){
	//initialise animation variable
	firstRun=0;

	//create object of ul imglist
	oElement=document.getElementById("imglist");
	
	//find current margin-left
	mLeft=oElement.style.marginLeft;
	
	//find new integer margin-left
	newMLeft=parseInt(mLeft) + parseInt(dist);
	
	//check against limits
	if (newMLeft>25) newMLeft=25;
	if (newMLeft<-140) newMLeft=-140;
	
	//call animation routine
	animMoveInt=setInterval( function() {animMove(parseInt(mLeft), newMLeft)},5)
}

function shiftLeft(){
	moveUL(126);
}

function shiftRight(){
	moveUL(-126);
}


